agentix-cli 0.165.1 → 0.167.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/README.md +1 -1
- package/dist/{App-NV2JJMHN.js → App-ZV3MJ73U.js} +2 -2
- package/dist/{ChatApp-CIGDPS3A.js → ChatApp-GPGF3SVJ.js} +2 -2
- package/dist/{absorb-eval-VPAASHZG.js → absorb-eval-IJLOYYIL.js} +2 -2
- package/dist/{agent-UFMIPTQZ.js → agent-4BNF462Q.js} +2 -2
- package/dist/{board-dashboard-NUEVGTM7.js → board-dashboard-ZF2FN2K5.js} +399 -305
- package/dist/board-dashboard-ZF2FN2K5.js.map +1 -0
- package/dist/{chunk-QT63Q6C5.js → chunk-236CUFAC.js} +2 -2
- package/dist/{chunk-KVSHZKAL.js → chunk-2HB6AH4T.js} +2 -2
- package/dist/{chunk-FK2TJZNJ.js → chunk-3H2P5XRF.js} +2 -2
- package/dist/{chunk-T5IGXFSW.js → chunk-4S7JQ7B3.js} +2 -2
- package/dist/{chunk-EXJGRK2N.js → chunk-56I4CDWP.js} +3 -3
- package/dist/chunk-56I4CDWP.js.map +1 -0
- package/dist/{chunk-CRUNUMVO.js → chunk-5GJMPB6Q.js} +2 -2
- package/dist/{chunk-V7R5AJVN.js → chunk-7PWM4GYY.js} +2 -2
- package/dist/chunk-BE64IJWM.js +11 -0
- package/dist/chunk-BE64IJWM.js.map +1 -0
- package/dist/{chunk-AYK2MO3B.js → chunk-CTN4KYE6.js} +2 -2
- package/dist/chunk-CZLUBWNU.js +92 -0
- package/dist/chunk-CZLUBWNU.js.map +1 -0
- package/dist/{chunk-BC7VOHNH.js → chunk-DPPYNUQW.js} +2 -2
- package/dist/{chunk-GJ4SQRAE.js → chunk-ECFANHQ5.js} +2 -2
- package/dist/{chunk-6Y53LLIX.js → chunk-FIL6QI6N.js} +2 -2
- package/dist/{chunk-A3GDFLFB.js → chunk-FSTWXYWA.js} +2 -2
- package/dist/{chunk-4SJ2VFVI.js → chunk-GGQZLFYH.js} +2 -2
- package/dist/{chunk-RUB4HZEG.js → chunk-GVU6YS3Y.js} +2 -2
- package/dist/{chunk-73SESASJ.js → chunk-IJT6KKST.js} +2 -2
- package/dist/chunk-KDDV3VFJ.js +41 -0
- package/dist/chunk-KDDV3VFJ.js.map +1 -0
- package/dist/{chunk-ON7Y3JSP.js → chunk-MQFHPGLC.js} +3 -3
- package/dist/{chunk-CGE5EAWC.js → chunk-N5JY7SSX.js} +2 -2
- package/dist/{chunk-YUGYKMY6.js → chunk-OPCGTZU4.js} +2 -2
- package/dist/{chunk-KTJ6234K.js → chunk-PHLILSAY.js} +258 -258
- package/dist/chunk-PHLILSAY.js.map +1 -0
- package/dist/{chunk-DAWJHJKD.js → chunk-RDT4NCBI.js} +2 -2
- package/dist/{chunk-PSTEWKR3.js → chunk-RGUQY65H.js} +2 -2
- package/dist/{chunk-CDPQQAK6.js → chunk-S3KWNMPJ.js} +2 -2
- package/dist/{chunk-NCEYJFF5.js → chunk-SAFOO6XY.js} +2 -2
- package/dist/{chunk-Y6JSB5II.js → chunk-SMPADAHT.js} +2 -2
- package/dist/{chunk-S6ZZKRDB.js → chunk-UGPCMA7S.js} +2 -2
- package/dist/{chunk-VL74KOR7.js → chunk-VJVXEVZ7.js} +18 -9
- package/dist/{chunk-VL74KOR7.js.map → chunk-VJVXEVZ7.js.map} +1 -1
- package/dist/{chunk-ILHTAVZZ.js → chunk-ZA7DX4A2.js} +85 -85
- package/dist/chunk-ZA7DX4A2.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/{client-D3CYQPUD.js → client-SQOWAVPJ.js} +2 -2
- package/dist/{config-OTO56OCX.js → config-7JJZJFLZ.js} +2 -2
- package/dist/{config-mutate-5KKGQHC6.js → config-mutate-JERIV7AP.js} +2 -2
- package/dist/config-mutator-4IUU4ANZ.js +2 -0
- package/dist/{contributions-SMSYSHPU.js → contributions-XSHL4IU5.js} +2 -2
- package/dist/{doctor-5PFLKGNU.js → doctor-TBZE4NNW.js} +2 -2
- package/dist/{failure-candidates-HNENLQJC.js → failure-candidates-WGSFI7GR.js} +2 -2
- package/dist/{follow-up-tool-ME4DV7HT.js → follow-up-tool-QC4NXZJT.js} +2 -2
- package/dist/{hub-WGUNZ2D5.js → hub-VRESIG2H.js} +2 -2
- package/dist/index.d.ts +108 -39
- package/dist/index.js +1 -1
- package/dist/{program-GBPLSXFF.js → program-KFZOGLFE.js} +203 -203
- package/dist/{program-GBPLSXFF.js.map → program-KFZOGLFE.js.map} +1 -1
- package/dist/{promote-TQ3OZ7EC.js → promote-BFFD52TZ.js} +2 -2
- package/dist/{query-M4VWXBHF.js → query-MIODGHPL.js} +2 -2
- package/dist/{query-settings-Y4PWFLYK.js → query-settings-X4BTVQHH.js} +2 -2
- package/dist/{registry-GLNCV3KP.js → registry-TRWLGN2A.js} +2 -2
- package/dist/{request-planner-FE3C2QFQ.js → request-planner-2QGXWCOJ.js} +2 -2
- package/dist/{review-candidates-R7QKVGMQ.js → review-candidates-NJVISKTY.js} +2 -2
- package/dist/{routing-6J4OHUJS.js → routing-4AS2E5XG.js} +2 -2
- package/dist/schedule-tool-GGL5SGM6.js +2 -0
- package/dist/{scheduler-XDLJAWGC.js → scheduler-S7PRYZNI.js} +2 -2
- package/dist/{seat-35AZG54F.js → seat-MOPQDOX3.js} +2 -2
- package/dist/{select-6PC26YUI.js → select-RVIZALFB.js} +2 -2
- package/dist/{set-enabled-UJOLDPZV.js → set-enabled-AWWWMEYU.js} +2 -2
- package/dist/token-tracker-XTHSSPLB.js +2 -0
- package/dist/tool-7U4T5ZF7.js +8 -0
- package/dist/tool-7U4T5ZF7.js.map +1 -0
- package/dist/{tool-QLIJQQ7W.js → tool-HJQJWJAH.js} +2 -2
- package/dist/traces-O4TIZ4SM.js +2 -0
- package/dist/{wiki-W7L5EJTZ.js → wiki-BLCQBJG3.js} +2 -2
- package/dist/wiki-enrich-U5KPQ6P7.js +2 -0
- package/dist/{workflow-pilot-25NMZYUO.js → workflow-pilot-MKG6CJ6V.js} +2 -2
- package/package.json +1 -1
- package/dist/board-dashboard-NUEVGTM7.js.map +0 -1
- package/dist/chunk-AXDNFXYU.js +0 -41
- package/dist/chunk-AXDNFXYU.js.map +0 -1
- package/dist/chunk-EXJGRK2N.js.map +0 -1
- package/dist/chunk-ILHTAVZZ.js.map +0 -1
- package/dist/chunk-IVTO54EM.js +0 -90
- package/dist/chunk-IVTO54EM.js.map +0 -1
- package/dist/chunk-KTJ6234K.js.map +0 -1
- package/dist/chunk-XIRM45DH.js +0 -11
- package/dist/chunk-XIRM45DH.js.map +0 -1
- package/dist/config-mutator-XBUGJZER.js +0 -2
- package/dist/schedule-tool-FE3TWOGS.js +0 -2
- package/dist/token-tracker-B2UFOH46.js +0 -2
- package/dist/tool-LAMDUPTX.js +0 -6
- package/dist/tool-LAMDUPTX.js.map +0 -1
- package/dist/traces-G4HRLRA3.js +0 -2
- package/dist/wiki-enrich-3ZCL5TEC.js +0 -2
- /package/dist/{App-NV2JJMHN.js.map → App-ZV3MJ73U.js.map} +0 -0
- /package/dist/{ChatApp-CIGDPS3A.js.map → ChatApp-GPGF3SVJ.js.map} +0 -0
- /package/dist/{absorb-eval-VPAASHZG.js.map → absorb-eval-IJLOYYIL.js.map} +0 -0
- /package/dist/{agent-UFMIPTQZ.js.map → agent-4BNF462Q.js.map} +0 -0
- /package/dist/{chunk-QT63Q6C5.js.map → chunk-236CUFAC.js.map} +0 -0
- /package/dist/{chunk-KVSHZKAL.js.map → chunk-2HB6AH4T.js.map} +0 -0
- /package/dist/{chunk-FK2TJZNJ.js.map → chunk-3H2P5XRF.js.map} +0 -0
- /package/dist/{chunk-T5IGXFSW.js.map → chunk-4S7JQ7B3.js.map} +0 -0
- /package/dist/{chunk-CRUNUMVO.js.map → chunk-5GJMPB6Q.js.map} +0 -0
- /package/dist/{chunk-V7R5AJVN.js.map → chunk-7PWM4GYY.js.map} +0 -0
- /package/dist/{chunk-AYK2MO3B.js.map → chunk-CTN4KYE6.js.map} +0 -0
- /package/dist/{chunk-BC7VOHNH.js.map → chunk-DPPYNUQW.js.map} +0 -0
- /package/dist/{chunk-GJ4SQRAE.js.map → chunk-ECFANHQ5.js.map} +0 -0
- /package/dist/{chunk-6Y53LLIX.js.map → chunk-FIL6QI6N.js.map} +0 -0
- /package/dist/{chunk-A3GDFLFB.js.map → chunk-FSTWXYWA.js.map} +0 -0
- /package/dist/{chunk-4SJ2VFVI.js.map → chunk-GGQZLFYH.js.map} +0 -0
- /package/dist/{chunk-RUB4HZEG.js.map → chunk-GVU6YS3Y.js.map} +0 -0
- /package/dist/{chunk-73SESASJ.js.map → chunk-IJT6KKST.js.map} +0 -0
- /package/dist/{chunk-ON7Y3JSP.js.map → chunk-MQFHPGLC.js.map} +0 -0
- /package/dist/{chunk-CGE5EAWC.js.map → chunk-N5JY7SSX.js.map} +0 -0
- /package/dist/{chunk-YUGYKMY6.js.map → chunk-OPCGTZU4.js.map} +0 -0
- /package/dist/{chunk-DAWJHJKD.js.map → chunk-RDT4NCBI.js.map} +0 -0
- /package/dist/{chunk-PSTEWKR3.js.map → chunk-RGUQY65H.js.map} +0 -0
- /package/dist/{chunk-CDPQQAK6.js.map → chunk-S3KWNMPJ.js.map} +0 -0
- /package/dist/{chunk-NCEYJFF5.js.map → chunk-SAFOO6XY.js.map} +0 -0
- /package/dist/{chunk-Y6JSB5II.js.map → chunk-SMPADAHT.js.map} +0 -0
- /package/dist/{chunk-S6ZZKRDB.js.map → chunk-UGPCMA7S.js.map} +0 -0
- /package/dist/{client-D3CYQPUD.js.map → client-SQOWAVPJ.js.map} +0 -0
- /package/dist/{config-OTO56OCX.js.map → config-7JJZJFLZ.js.map} +0 -0
- /package/dist/{config-mutate-5KKGQHC6.js.map → config-mutate-JERIV7AP.js.map} +0 -0
- /package/dist/{config-mutator-XBUGJZER.js.map → config-mutator-4IUU4ANZ.js.map} +0 -0
- /package/dist/{contributions-SMSYSHPU.js.map → contributions-XSHL4IU5.js.map} +0 -0
- /package/dist/{doctor-5PFLKGNU.js.map → doctor-TBZE4NNW.js.map} +0 -0
- /package/dist/{failure-candidates-HNENLQJC.js.map → failure-candidates-WGSFI7GR.js.map} +0 -0
- /package/dist/{follow-up-tool-ME4DV7HT.js.map → follow-up-tool-QC4NXZJT.js.map} +0 -0
- /package/dist/{hub-WGUNZ2D5.js.map → hub-VRESIG2H.js.map} +0 -0
- /package/dist/{promote-TQ3OZ7EC.js.map → promote-BFFD52TZ.js.map} +0 -0
- /package/dist/{query-M4VWXBHF.js.map → query-MIODGHPL.js.map} +0 -0
- /package/dist/{query-settings-Y4PWFLYK.js.map → query-settings-X4BTVQHH.js.map} +0 -0
- /package/dist/{registry-GLNCV3KP.js.map → registry-TRWLGN2A.js.map} +0 -0
- /package/dist/{request-planner-FE3C2QFQ.js.map → request-planner-2QGXWCOJ.js.map} +0 -0
- /package/dist/{review-candidates-R7QKVGMQ.js.map → review-candidates-NJVISKTY.js.map} +0 -0
- /package/dist/{routing-6J4OHUJS.js.map → routing-4AS2E5XG.js.map} +0 -0
- /package/dist/{schedule-tool-FE3TWOGS.js.map → schedule-tool-GGL5SGM6.js.map} +0 -0
- /package/dist/{scheduler-XDLJAWGC.js.map → scheduler-S7PRYZNI.js.map} +0 -0
- /package/dist/{seat-35AZG54F.js.map → seat-MOPQDOX3.js.map} +0 -0
- /package/dist/{select-6PC26YUI.js.map → select-RVIZALFB.js.map} +0 -0
- /package/dist/{set-enabled-UJOLDPZV.js.map → set-enabled-AWWWMEYU.js.map} +0 -0
- /package/dist/{token-tracker-B2UFOH46.js.map → token-tracker-XTHSSPLB.js.map} +0 -0
- /package/dist/{tool-QLIJQQ7W.js.map → tool-HJQJWJAH.js.map} +0 -0
- /package/dist/{traces-G4HRLRA3.js.map → traces-O4TIZ4SM.js.map} +0 -0
- /package/dist/{wiki-W7L5EJTZ.js.map → wiki-BLCQBJG3.js.map} +0 -0
- /package/dist/{wiki-enrich-3ZCL5TEC.js.map → wiki-enrich-U5KPQ6P7.js.map} +0 -0
- /package/dist/{workflow-pilot-25NMZYUO.js.map → workflow-pilot-MKG6CJ6V.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as rt,b as ot,c as st,d as x,e as A,f as v}from"./chunk-72SZI2UW.js";import{a as ne,b as et}from"./chunk-FCPTN6NF.js";import{a as Te,b as ht}from"./chunk-MCI3DIWW.js";import{o as we,p as Ze}from"./chunk-6QLRRSKU.js";import{sb as tt,tb as nt}from"./chunk-
|
|
1
|
+
import{a as rt,b as ot,c as st,d as x,e as A,f as v}from"./chunk-72SZI2UW.js";import{a as ne,b as et}from"./chunk-FCPTN6NF.js";import{a as Te,b as ht}from"./chunk-MCI3DIWW.js";import{o as we,p as Ze}from"./chunk-6QLRRSKU.js";import{sb as tt,tb as nt}from"./chunk-CZLUBWNU.js";import{a as it,b as at,c as ct,d as ut,e as lt,f as dt,g as pt,h as mt,i as bt,j as ft,k as gt,l as yt}from"./chunk-RGDKHYY2.js";import{a as E,b as We,c as he}from"./chunk-QIJLFPWE.js";function R(e,t){$.set(e,t),X.delete(e)}function D(e){let t=X.get(e);if(t)return t;let r=$.get(e);if(!r){let o=Ee();throw new Error(`unknown decision backend "${e}"`+(o.length>0?` \u2014 registered: ${o.join(", ")}`:" \u2014 none registered"))}let n=r();return X.set(e,n),n}function Ee(){return[...$.keys()].sort()}function wt(){$.clear(),X.clear()}var $,X,C=E(()=>{"use strict";$=new Map,X=new Map});import Tt from"better-sqlite3";import{createHash as Et}from"crypto";import{mkdirSync as kt}from"fs";import{dirname as St,resolve as xt}from"path";function Q(e){if(e.type==="noul"){let r=e.noul,n={yes:r,no:1-r},o=r>=.5?"yes":"no",s=Math.abs(r-.5)*2;return{predicted:o,confidence:s,probabilities:n,topLabel:o,topProb:Math.max(r,1-r),expectedScore:null,pMax:Math.max(r,1-r),negEntropy:s}}if(e.type==="choice")return{predicted:e.choice,confidence:e.confidence,probabilities:{...e.probabilities},topLabel:e.choice,topProb:e.probabilities[e.choice]??0,expectedScore:null,pMax:e.pMax,negEntropy:e.negEntropy};let t=String(Math.round(e.score));return{predicted:t,confidence:e.confidence,probabilities:{...e.probabilities},topLabel:t,topProb:e.probabilities[t]??0,expectedScore:e.score,pMax:e.pMax,negEntropy:e.negEntropy}}function At(e){if(typeof e!="string"||e.length===0)return{};try{let t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Rt(e){e.exec("CREATE TABLE IF NOT EXISTS schema_version (v INTEGER PRIMARY KEY);");let t=e.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0;t<1&&vt(e),t<2&&Ot(e),t<3&&_t(e)}function _t(e){e.exec(`
|
|
2
2
|
ALTER TABLE decision_calls ADD COLUMN features_json TEXT;
|
|
3
3
|
INSERT INTO schema_version (v) VALUES (3);
|
|
4
4
|
`)}function Ot(e){e.exec(`
|
|
@@ -111,4 +111,4 @@ import{a as rt,b as ot,c as st,d as x,e as A,f as v}from"./chunk-72SZI2UW.js";im
|
|
|
111
111
|
`)}if(!m)throw new Error(`local decision backend could not get a valid answer after ${f+1} attempt(s): ${w}`);let M={},L=!1;for(let[k,q]of Object.entries(s.questions)){let S=_(q,m[k],{normalize:e.normalizeProbabilities??!0});M[k]=S.answer,S.repaired&&(L=!0)}return{model:a,answers:M,usage:h,meta:{backend:"local",structureMode:c,answerMode:"probabilities",repaired:L,retries:f,stateTruncated:l.truncated,latencyMs:Date.now()-i}}}finally{b()}}}}async function Jt(e,t,r,n,o){if(!e.generateRaw)throw new Error(`provider "${e.name}" has no generateRaw(); use structureMode "text"`);let s=[{role:"user",content:r},...n?[{role:"user",content:n}]:[]],i=await e.generateRaw(s,J,[{name:F,description:"Report a probability distribution for every question.",input_schema:se(t)}],{...o,toolChoice:{type:"tool",name:F}}),a=i.content.find(c=>c.type==="tool_use"&&c.name===F),u=a&&a.type==="tool_use"?a.input:null;return{answers:Be(u),usage:{inputTokens:i.usage.input_tokens,outputTokens:i.usage.output_tokens}}}async function Gt(e,t,r,n,o){let s=[r,ae(t)].join(`
|
|
112
112
|
`),i=[{role:"system",content:J},{role:"user",content:s},...n?[{role:"user",content:n}]:[]],a=await e.generate(i,o);return{answers:Be(Te(a.content??"")),usage:{inputTokens:0,outputTokens:a.tokensUsed??0}}}function Be(e){if(e&&typeof e=="object"&&!Array.isArray(e)){let t=e;if(t.answers&&typeof t.answers=="object")return t.answers}return e}function Yt(e,t){return e!=="auto"?e:t.generateRaw&&me[t.name]?.structuredOutput?"tool":"text"}function Kt(e,t){let r=new AbortController,n=setTimeout(()=>r.abort(new Error(`decision timed out after ${t}ms`)),t),o=()=>r.abort(e?.reason);return e&&(e.aborted?o():e.addEventListener("abort",o,{once:!0})),{signal:r.signal,dispose:()=>{clearTimeout(n),e?.removeEventListener("abort",o)}}}var Xt,$t,Vt,Fe,zt,be=E(()=>{"use strict";Ze();Ue();ht();j();Y();v();z();Xt="claude-code",$t="claude-haiku-4-5-20251001",Vt=24e3,Fe=2e3,zt=3e4});import{readFileSync as Ht}from"fs";import{homedir as Wt}from"os";import{join as Zt}from"path";function N(e={}){let t=(e.baseUrl??en).replace(/\/+$/,""),r=e.path??"/classifier",n=e.name??"simple-jev",o=e.maxStateChars??nn,s=e.maxChoiceOptions??rn,i={probabilitySource:e.probabilitySource??"logits",calibratedProbabilities:!1,maxChoiceOptions:s,maxStateChars:o,parallelQuestions:!0,images:!1};return{name:n,capabilities:i,async decide(a){A(a.questions),cn(a.questions,s);let u=Date.now(),c=a.model??e.model;if(!c)throw new Error("simple-jev backend needs a model id");let l=G(a.state,o),p=e.fetchImpl??fetch,{signal:g,dispose:d}=un(a.abortSignal,a.timeoutMs??e.timeoutMs??tn);try{let b={"Content-Type":"application/json"},h=an(e.apiKeyEnv,e.apiKeyFile);h&&(b.Authorization=`Bearer ${h}`);let T=await qe(p(`${t}${r}`,{method:"POST",headers:b,body:JSON.stringify({model:c,state:l.text,questions:sn(a.questions)}),signal:g}),g);if(!T.ok){let k=await T.text().catch(()=>"");throw new Error(`${n} ${T.status}: ${k.slice(0,300)}`)}let f=await qe(T.json(),g),m=P(a.questions).safeParse(f.answers);if(!m.success)throw new Error(`${n} returned a response that does not match the requested questions (contract drift, not a model slip \u2014 retrying will not help):
|
|
113
113
|
${U(m.error)}`);let w=m.data,M={},L=!1;for(let[k,q]of Object.entries(a.questions)){let S=_(q,w[k]);M[k]=S.answer,S.repaired&&(L=!0)}return{model:f.model??c,answers:M,usage:{inputTokens:f.usage?.input_tokens??0,outputTokens:f.usage?.output_tokens??0},meta:{backend:n,structureMode:i.probabilitySource==="native"?"native":"logprobs",answerMode:"probabilities",repaired:L,retries:0,stateTruncated:l.truncated,latencyMs:Date.now()-u}}}finally{d()}}}}function sn(e){let t={};for(let[r,n]of Object.entries(e))t[r]=n.instructions?n:{...n,instructions:on[n.type]};return t}function an(e,t){let r=e?process.env[e]:void 0;if(r)return r;if(!t)return;let n=t.startsWith("~/")?Zt(Wt(),t.slice(2)):t;if(!Z.has(n))try{let o=Ht(n,"utf-8").trim();Z.set(n,o.length>0?o:null)}catch{Z.set(n,null)}return Z.get(n)??void 0}function cn(e,t){for(let[r,n]of Object.entries(e))if(n.type==="choice"){let o=Object.keys(n.criteria).length;if(o>t)throw new Error(`question "${r}": accepts at most ${t} choice options, got ${o}`)}else if(n.type==="score"&&n.criteria.length>t)throw new Error(`question "${r}": accepts at most ${t} score levels, got ${n.criteria.length}`)}function qe(e,t){return t.aborted?Promise.reject(t.reason??new Error("aborted")):new Promise((r,n)=>{let o=()=>n(t.reason??new Error("aborted"));t.addEventListener("abort",o,{once:!0}),e.then(s=>{t.removeEventListener("abort",o),r(s)},s=>{t.removeEventListener("abort",o),n(s)})})}function un(e,t){let r=new AbortController,n=setTimeout(()=>r.abort(new Error(`decision timed out after ${t}ms`)),t),o=()=>r.abort(e?.reason);return e&&(e.aborted?o():e.addEventListener("abort",o,{once:!0})),{signal:r.signal,dispose:()=>{clearTimeout(n),e?.removeEventListener("abort",o)}}}var en,tn,nn,rn,on,Z,fe=E(()=>{"use strict";j();v();z();Y();en="http://127.0.0.1:8000/v1",tn=3e4,nn=6e3,rn=50;on={choice:"Which option best fits?",score:"Which level best fits?",noul:"Is this true of the state?"};Z=new Map});var Xe={};We(Xe,{DEFAULT_SEAT_TIMEOUT_MS:()=>Ve,DecisionStore:()=>I,MAX_CHOICE_OPTIONS:()=>MAX_CHOICE_OPTIONS,SYSTEM_PROMPT:()=>J,TOOL_NAME:()=>F,UNCERTAINTY_HIGH:()=>Ce,UNCERTAINTY_LOW:()=>De,_resetDecisionBackendsForTesting:()=>wt,agreement:()=>it,answerView:()=>Q,applyRecalibrator:()=>ue,applyTemperature:()=>mt,askSeat:()=>yn,band:()=>Ie,bootstrapInterval:()=>ft,brier:()=>lt,buildDesign:()=>ve,calibrationReport:()=>gt,choice:()=>ot,compareCalibrators:()=>It,confidenceFor:()=>re,configureDecisions:()=>pn,configuredSeatTimeout:()=>dn,coverageCurve:()=>pt,createLocalDecisionBackend:()=>W,createMockDecisionBackend:()=>H,createSimpleJevBackend:()=>N,decisionsRuntime:()=>bn,describeIssues:()=>U,ece:()=>ct,expectedScore:()=>Ae,finalizeAnswer:()=>_,fitLogistic:()=>Ne,fitRecalibrator:()=>B,fitTemperature:()=>bt,getDecisionBackend:()=>D,getSeatMode:()=>Je,labelSeatCall:()=>fn,labelsOf:()=>x,listDecisionBackends:()=>Ee,logLoss:()=>dt,logit:()=>le,mce:()=>ut,measureConsistency:()=>Ut,normalizeDistribution:()=>Se,normalizedNegEntropy:()=>oe,noul:()=>rt,pMax:()=>xe,parseSeatMode:()=>ge,rawAnswerSchema:()=>Re,rawAnswersSchema:()=>P,recordSeatOutcome:()=>gn,registerBuiltinDecisionBackends:()=>ln,registerDecisionBackend:()=>R,reliabilityBins:()=>at,renderQuestions:()=>_e,renderShapeInstructions:()=>ae,renderState:()=>G,renderUserPrompt:()=>ie,resetDecisionsRuntime:()=>mn,score:()=>st,seatEnvVar:()=>ze,sigmoid:()=>de,toolInputSchema:()=>se,validateQuestions:()=>A,withUid:()=>Qe});function ln(e={},t={},r={},n={}){R("mock",()=>H()),R("local",()=>W(e)),R("simple-jev",()=>N(t)),R("jev",()=>N({name:"jev",baseUrl:"https://openrouter.ai/api/alpha",path:"/decisions",model:"jev-latest",apiKeyEnv:"OPENROUTER_API_KEY",apiKeyFile:"~/.agentx/openrouter-key.txt",probabilitySource:"native",maxChoiceOptions:255,maxStateChars:9e4,...r})),R("typesafe",()=>N({name:"typesafe",baseUrl:"https://api.typesafe.ai/v1",path:"/systemone",model:"jev-latest",apiKeyEnv:"TYPESAFE_API_KEY",apiKeyFile:"~/.agentx/typesafe-key.txt",probabilitySource:"native",maxChoiceOptions:255,maxStateChars:9e4,...n}))}var $e=E(()=>{"use strict";ke();v();j();z();C();Y();V();yt();Me();je();Ge();pe();be();fe();C();pe();be();fe()});function dn(e){return Ke(),y.seats[e]?.timeoutMs}function pn(e){y={...ye,...y,...e},ee=!0}function mn(){y={...ye,seats:{}},ee=!1}function Ke(){if(!ee){ee=!0;try{let{loadDaemonConfig:e}=(nt(),he(tt)),t=e()?.decisions;if(!t?.enabled)return;let{registerBuiltinDecisionBackends:r}=($e(),he(Xe)),n=t.backends??{};r(n.local,n.simpleJev,n.jev,n.typesafe);let o=null;try{o=new I({path:t.dbPath})}catch{}y={enabled:!0,defaultBackend:t.defaultBackend,store:o,seats:Object.fromEntries(Object.entries(t.seats??{}).map(([s,i])=>[s,{...i,redactState:t.redactState,keepStateRows:t.keepStateRows}]))}}catch{}}}function bn(){return y}function ge(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return hn.includes(t)?t:null}function ze(e){return`AGENTX_DECISION_SEAT_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}function Je(e,t=process.env){Ke();let r=ge(t[ze(e)]);return r||(y.enabled?ge(y.seats[e]?.mode)??"off":"off")}function fn(e,t,r,n={}){if(!(!e||!y.store))try{y.store.label(e,t,r,n)}catch{}}function gn(e,t,r=!1){if(!(!e||!y.store))try{y.store.recordOutcome(e,t,r)}catch{}}async function yn(e,t,r,n={}){let o=Je(e);if(o==="off")return null;let s=y.seats[e]??{mode:o},i=n.backend??s.backend??y.defaultBackend,a=Date.now();try{let c=await D(i).decide({state:t,questions:r,model:n.model??s.model,abortSignal:n.signal,timeoutMs:n.timeoutMs??s.timeoutMs??(y.seats[e]?Ve:void 0)}),l=wn(e,o,t,r,c,n,s);return{answers:c.answers,callId:l,mode:o}}catch(u){return Tn(e,o,t,r,i,n,s,a,u),En(e,i,u),null}}function wn(e,t,r,n,o,s,i){if(!y.store)return null;try{return y.store.recordCall({seat:e,mode:t,backend:o.meta.backend,model:o.model,meta:o.meta,state:r,questions:n,answers:o.answers,usage:o.usage,incumbent:He(s.incumbent),links:s.links,features:s.features,keepState:!i.redactState})}catch{return null}}function Tn(e,t,r,n,o,s,i,a,u){if(y.store)try{y.store.recordCall({seat:e,mode:t,backend:o,model:s.model??i.model??"unknown",meta:{structureMode:"text",answerMode:"probabilities",retries:0,stateTruncated:!1,latencyMs:Date.now()-a},state:r,questions:n,answers:{},incumbent:He(s.incumbent),links:s.links,features:s.features,error:String(u?.message??u).slice(0,500),keepState:!i.redactState})}catch{}}function He(e){if(!e)return;let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]={value:n});return t}function En(e,t,r){let n=Date.now();n-Ye<6e4||(Ye=n,console.warn(`[decisions] seat "${e}" on backend "${t}" failed: ${r?.message??r}`))}var Ve,ye,y,ee,hn,Ye,Ge=E(()=>{C();V();Ve=1e4;ye={enabled:!1,defaultBackend:"local",seats:{},store:null},y={...ye},ee=!1;hn=["off","shadow","active"];Ye=0});export{D as a,Ee as b,C as c,I as d,V as e,It as f,Me as g,Ut as h,je as i,me as j,Xn as k,Ue as l,ln as m,$e as n,Ve as o,dn as p,pn as q,mn as r,bn as s,ge as t,ze as u,Je as v,fn as w,gn as x,yn as y,Ge as z};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-236CUFAC.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{kb as l,tb as m}from"./chunk-
|
|
1
|
+
import{kb as l,tb as m}from"./chunk-CZLUBWNU.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
|
|
2
2
|
`,f=t+".tmp";a(f,c,"utf-8");try{JSON.parse(u(f,"utf-8"))}catch(d){throw new Error(`config did not round-trip cleanly: ${d.message}`)}let r;return n.skipBackup||(r=`${t}.bak.${Date.now()}`,y(t,r)),a(t,c,"utf-8"),n.skipReload||h().catch(()=>{}),{summary:s.summary,payload:s.payload,backupPath:r}}function S(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(g(t)&&!n.overwrite)throw new Error(`agentx.json already exists at ${t}. Pass overwrite=true to replace it.`);return a(t,JSON.stringify(e,null,2)+`
|
|
3
3
|
`,"utf-8"),{file:t}}async function h(){try{let n=l().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${n}/reload`,{method:"POST"}).catch(()=>null)}catch{}}export{P as a,S as b};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-2HB6AH4T.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{d as h}from"./chunk-
|
|
1
|
+
import{d as h}from"./chunk-ECFANHQ5.js";var d=["main contact","primary contact","point of contact","billing contact","technical contact","decision maker"],f=/[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g,w=/\b(role|title|position|job)\s*\**\s*[::]\s*\**\s*([^\n;|]+)/gi;function L(t,c,e=[]){let l=[c,...e].join(`
|
|
2
2
|
`),a=l.toLowerCase(),i=h(t,l);for(let s of p(t.match(f)??[]))a.includes(s.toLowerCase())||i.push(`email ${s}`);let m=t.toLowerCase();for(let s of d)m.includes(s)&&!a.includes(s)&&i.push(`marker "${s}"`);for(let s of t.matchAll(w)){let n=s[2].replace(/\*+/g,"").trim();n&&!a.includes(n.toLowerCase())&&i.push(`${s[1].toLowerCase()} "${n}"`)}return p(i)}function p(t){return[...new Set(t)]}var $=.9,g=/^\s*(?:wait\b|here(?:'s| is) the (?:updated|modified|patched|revised)|i (?:must|need to|will|should) (?:output|return|write)|(?:okay|ok|sure)[,.!]\s|let me\b|as requested\b)/im;function k(t,c){let e=[],l=t.split(`
|
|
3
3
|
`).filter(o=>o.trim()).length,a=c.split(`
|
|
4
4
|
`).filter(o=>o.trim()).length;l>=5&&a<Math.floor(l*$)&&e.push(`the article shrinks from ${l} to ${a} lines`);let i=c.match(g);i&&!t.match(g)&&e.push(`it contains the model's own commentary ("${i[0].trim().slice(0,40)}")`);let m=o=>{let r=new Map;for(let u of o.split(`
|
|
5
5
|
`))/^#{1,6} /.test(u)&&r.set(u.trim(),(r.get(u.trim())??0)+1);return r},s=m(t);for(let[o,r]of m(c))r>1&&r>(s.get(o)??0)&&e.push(`the heading "${o}" appears ${r} times`);let n=L(t,c);return n.length&&e.push(`it drops ${n.length} fact(s): ${n.slice(0,6).join(", ")}${n.length>6?", \u2026":""}`),e}export{L as a,k as b};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-3H2P5XRF.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as k}from"./chunk-IMLAPB7G.js";import{k as y}from"./chunk-LQS27HSV.js";import{d as V}from"./chunk-QPABR72X.js";import{b as z}from"./chunk-KP7KDLZ2.js";import{V as B,W as J,X,Y as K,aa as N,fa as Oe}from"./chunk-
|
|
1
|
+
import{a as k}from"./chunk-IMLAPB7G.js";import{k as y}from"./chunk-LQS27HSV.js";import{d as V}from"./chunk-QPABR72X.js";import{b as z}from"./chunk-KP7KDLZ2.js";import{V as B,W as J,X,Y as K,aa as N,fa as Oe}from"./chunk-CZLUBWNU.js";import{existsSync as Q,readFileSync as Ie}from"node:fs";import{dirname as A,join as h}from"node:path";import{fileURLToPath as Ee}from"node:url";import{homedir as Ce}from"node:os";var M="tn.acme.agentx.voice",gt="AgentX Desktop.app",Y="AgentX Helper.app";function yt(e,t,n){return e!=="darwin"||t!=="arm64"||Number(n.split(".")[0])<23?"AgentX Desktop currently requires Apple Silicon and macOS 14 or newer.":null}function ht(e,t){if(t&&!Object.hasOwn(e,t))throw new Error(`Unknown agent: ${t}. Run agentx agent list.`);let n=t||Object.keys(e)[0];if(!n)throw new Error("No agents configured. Run agentx setup first.");return n}function T(e){return`'${e.replace(/'/g,"'\\''")}'`}var Z="/usr/bin:/bin:/usr/sbin:/sbin";function wt(e,t){return t||[...new Set([...e?[A(e)]:[],...Z.split(":")])].join(":")}function R(e){let t={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};return e.replace(/&(amp|lt|gt|quot|apos);/g,(n,r)=>t[r])}function St(e){let t=e.match(/<key>PATH<\/key>\s*<string>([^<]*)<\/string>/);return t?R(t[1]):Z}var xt=e=>/agentx\.voice.*\.plist$/.test(e);function vt(e,t){let n=null,r=[];for(let{file:o,plist:i}of[...t].sort((s,u)=>s.file<u.file?-1:1)){let s=i.match(/<key>Label<\/key>\s*<string>([^<]*)<\/string>/)?.[1],u=i.match(/<key>ProgramArguments<\/key>\s*<array>\s*<string>([^<]*)<\/string>/)?.[1];!s||!u||!R(u).endsWith("/Contents/MacOS/AgentXVoice")||(n?r.push({file:o,label:R(s)}):n={file:o,label:R(s)})}return{keep:n??{file:h(e,`${M}.plist`),label:M},remove:r}}function ee(e,t,n){for(let r of t.split(":"))if(r&&n(h(r,e)))return h(r,e);return null}function bt(e){let t=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),n={PATH:e.path,...e.agent?{AGENTX_VOICE_AGENT:e.agent}:{},AGENTX_DAEMON_URL:e.url,AGENTX_MAC_HELPER:e.helper,AGENTX_PASTE_COMMAND:`cd ${T(e.cwd)} && ${T(e.node)} ${T(e.cli)} paste`};return`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
3
|
<plist version="1.0"><dict>
|
|
4
4
|
<key>Label</key><string>${t(e.label??M)}</string>
|
|
@@ -33,4 +33,4 @@ function run(argv) {
|
|
|
33
33
|
`),it(r,n)}var ut=5*6e4;function Cn(e,t,n=Date.now()){let r=Ae(e),o=r.checkedAt?Date.parse(r.checkedAt):NaN;return!r.cards||!(n-o<=ut)?!1:r.items[`card:${t}`]?.state!=="failed"}var U=24*36e5;function Re(e,t,n){let r=e+t.dueAfterMinutes*6e4;return new Date(n!==void 0&&Number.isFinite(n)?Math.max(e,Math.min(r,n)):r)}function lt(e,t,n,r){let o=Date.parse(e.expires),i=[f(e.ask,y.ask)];return e.choices?.length&&i.push(...e.choices.map((s,u)=>`${u+1}. ${s}`)),e.recommend&&i.push(`Recommended: ${f(e.recommend,y.recommend)}`),i.push(`Answer: ${n}`,`agentx: card=${e.id}`),{key:`card:${e.id}`,title:f(e.title,y.title),notes:i.join(`
|
|
34
34
|
`),due:Re(r,t,o),priority:Number.isFinite(o)&&o-r<=U?"high":"none"}}function ct(e,t,n,r){let o=[f(e.question||e.text,y.ask),`Asked of ${e.agentId}.`,`Answer: ${n}`,`agentx: request=${e.id}`],i=e.dueAt??void 0;return{key:`request:${e.id}`,title:W(e,y.title).headline,notes:o.join(`
|
|
35
35
|
`),due:Re(r,t,i),priority:i!==void 0&&i-r<=U?"high":"none"}}async function Tn(e){let{root:t,settings:n,tasks:r,log:o}=e,i=e.now??Date.now(),s=new Date(i).toISOString(),u={created:0,completed:0,dismissed:0,failed:0},l=Ae(t);delete l.lastError;let p=a=>{l.lastError={at:s,message:a}},S=new Map;try{if(n.include.includes("card"))for(let a of e.cards())a.status==="pending"&&Date.parse(a.expires)>i&&S.set(`card:${a.id}`,lt(a,n,e.answerUrl,i));if(n.include.includes("request"))for(let a of e.requests())a.state==="waiting_owner"&&S.set(`request:${a.id}`,ct(a,n,e.answerUrl,i))}catch(a){return o(`[mirror] could not read what is waiting: ${a?.message??a}`),p(String(a?.message??a)),Ne(t,l),u}let G=!0,v=new Map,Pe=async a=>{if(!v.has(a))try{v.set(a,new Set((await r.listOpen(a)).map(c=>c.id)))}catch(c){o(`[mirror] could not read list "${a}": ${c?.message??c}`),p(String(c?.message??c)),v.set(a,null),G=!1}return v.get(a)};for(let[a,c]of Object.entries(l.items)){if(c.state!=="open"||!c.id)continue;let d=await Pe(c.list);if(d)if(S.has(a))d.has(c.id)||(l.items[a]={...c,state:"dismissed",at:s},u.dismissed++,o(`[mirror] ${a}: its task was ticked off or deleted; it stays on the Desk and is not mirrored again`));else{if(d.has(c.id))try{await r.complete(c.id)}catch(g){o(`[mirror] ${a}: could not complete its task: ${g?.message??g}`),p(String(g?.message??g));continue}l.items[a]={...c,state:"completed",at:s},u.completed++}}let E=null,x=[];for(let[a,c]of S){let d=l.items[a];if(d&&(d.state==="open"||d.state==="dismissed")||d?.state==="failed"&&d.failures>=j)continue;if(E===null)try{await r.ensureList(n.list),E=!0}catch(m){o(`[mirror] could not make list "${n.list}": ${m?.message??m}`),p(String(m?.message??m)),E=!1}let g=d?.state==="failed"?d.failures:0;try{let{id:m}=await r.add({list:n.list,title:c.title,notes:c.notes,due:c.due,priority:c.priority});l.items[a]={id:m,list:n.list,state:"open",at:s,failures:0},u.created++}catch(m){let b=String(m?.message??m),C=g+1;l.items[a]={list:n.list,state:"failed",at:s,failures:C,lastError:b},p(b),u.failed++,o(`[mirror] ${a}: could not add to Reminders (${C}/${j}): ${b}`),C===j&&x.push({title:c.title,message:b})}}let $e=l.failureToldAt?Date.parse(l.failureToldAt):NaN;if(x.length&&!(i-$e<U)){let a=x[0],c=x.length>1?` (and ${x.length-1} more)`:"";try{await e.notify("Could not add to Reminders",`${a.title}${c}: ${f(a.message,200)}. Still on the Desk.`),l.failureToldAt=s}catch(d){o(`[mirror] could not tell the owner: ${d?.message??d}`)}}G&&(l.checkedAt=s,l.cards=n.include.includes("card"));for(let[a,c]of Object.entries(l.items))c.state!=="open"&&!S.has(a)&&i-Date.parse(c.at)>at&&delete l.items[a];return Ne(t,l),u}export{gn as a,he as b,H as c,F as d,yn as e,hn as f,Ze as g,wn as h,Sn as i,xn as j,W as k,f as l,Rn as m,gt as n,Y as o,yt as p,ht as q,wt as r,St as s,xt as t,vt as u,ee as v,bt as w,Nt as x,Te as y,Me as z,_e as A,_ as B,se as C,q as D,ye as E,un as F,ln as G,cn as H,Ae as I,Cn as J,Tn as K};
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
36
|
+
//# sourceMappingURL=chunk-4S7JQ7B3.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ne}from"./chunk-GTJIKXDB.js";import{C as dn,J as mn,k as O}from"./chunk-
|
|
1
|
+
import{a as Ne}from"./chunk-GTJIKXDB.js";import{C as dn,J as mn,k as O}from"./chunk-4S7JQ7B3.js";import{a as w}from"./chunk-VUEQ4SL5.js";import{f as pn,i as gn,k as De,l as Ce,n as X,o as W,q as fn}from"./chunk-LQS27HSV.js";import{t as ln,u as cn}from"./chunk-IJT6KKST.js";import{d as on,e as an}from"./chunk-AQASR6KR.js";import{b as un}from"./chunk-2VDO2HEK.js";import{a as tn,b as nn,d as rn,e as sn}from"./chunk-MNG2AMKZ.js";import{g as Jt,h as Yt,i as Zt,k as Qt,l as en}from"./chunk-S3KWNMPJ.js";import{a as Kt,c as Gt}from"./chunk-KP7KDLZ2.js";import{b as Ae,pa as Xt,ra as oe,sa as Ie,ua as Te}from"./chunk-KDDV3VFJ.js";import{q as zt}from"./chunk-RGUQY65H.js";import{a as Bt,b as Ht}from"./chunk-5GJMPB6Q.js";import{ab as Ee,ba as Mt,ca as Ut,ea as Ft,fa as Wt,jb as qt,kb as jt,p as se,q as Ot,r as Pt,s as Ns,tb as Vt}from"./chunk-CZLUBWNU.js";import{a as Re,h as Ls}from"./chunk-BRK6M6LA.js";import{j as _e,r as Os}from"./chunk-UEEB3UTU.js";import{existsSync as Ps,readdirSync as Ms,readFileSync as Us,statSync as Fs}from"fs";import{resolve as Ws}from"path";function hn(t,e,n=Date.now(),r=7){let s=r*864e5,o=new Map;for(let i of e){let a=o.get(i.workflowId);a?a.push(i):o.set(i.workflowId,[i])}return t.map(i=>{let a=o.get(i.id)??[],l=a.filter(f=>n-f.at<=s),d=a.filter(f=>n-f.at>s&&n-f.at<=s*2),c=l.filter(f=>f.status==="failed").length,u=a.filter(f=>f.status==="paused").length,p=a.length?Math.max(...a.map(f=>f.at)):null,g=a.length?d.length>0&&l.length===0?"dormant":l.length>0&&c*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:i.id,name:i.name||i.id,state:g,lastRunAt:p,recent:l.length,prior:d.length,failed:c,paused:u}}).sort((i,a)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[i.state]-l[a.state]||(a.lastRunAt??0)-(i.lastRunAt??0)})}var ie=new Map;function rc(t,e=1e3){if(!Ps(t))return[];let n=Ms(t).filter(o=>o.endsWith(".jsonl")).map(o=>{let i=Ws(t,o);return{path:i,mtime:Fs(i).mtimeMs}}).sort((o,i)=>i.mtime-o.mtime).slice(0,e),r=new Set(n.map(o=>o.path));for(let o of ie.keys())r.has(o)||ie.delete(o);let s=[];for(let{path:o,mtime:i}of n){let a=ie.get(o);if(a&&a.mtime===i){a.summary&&s.push(a.summary);continue}let l=qs(o,i);ie.set(o,{mtime:i,summary:l}),l&&s.push(l)}return s}function qs(t,e){try{let n=Us(t,"utf-8").split(`
|
|
2
2
|
`).filter(Boolean);if(!n.length)return null;let r=JSON.parse(n[0]),s=r.run?.workflowId;if(!s)return null;let o=r.run?.status??"unknown";for(let i=n.length-1;i>=0;i--){let a=JSON.parse(n[i]),l=a.status??a.run?.status;if(l){o=l;break}}return{workflowId:s,status:o,at:e}}catch{return null}}var js={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},k={routines:200,summary:160,filters:6,filterValue:60,text:120},Vs=(t,e,n)=>{try{return zt(t,e,n)}catch{return null}},bn=864e5;function ac(t){let e=t.now??Date.now(),n={...js,...t.thresholds},r=t.nextFire??Vs,s=[];for(let a of t.crons){let l=t.cronRuns.get(a.id)??[],d=a.timezone||"UTC",c=l.map(g=>({at:Date.parse(g.startedAt),status:g.status})),u=l[0],p={id:`cron:${a.id}`,source:"cron",kind:"schedule",name:E(a.id,k.text),trigger:{schedule:E(a.schedule,k.text),timezone:d},agent:a.agent||null,enabled:a.enabled,state:a.enabled?"enabled":"disabled",nextRunAt:a.enabled?Le(a.nextRun)??Le(r(a.schedule,new Date(e),d)):null,lastRun:u?{at:u.startedAt,status:u.status,summary:Gs(u.status==="success"?void 0:u.errorSummary,k.summary)}:null,lastSuccessAt:l.find(g=>g.status==="success")?.startedAt??null,consecutiveFailures:yn(c),sampledRuns:l.length,flags:[],attention:null};p.flags=wn(p,c,a.schedule,d,null,e,n,r),s.push(kn(p))}let o=new Map(hn(t.workflows.map(a=>({id:a.id,name:a.title})),t.workflowRuns,e).map(a=>[a.id,a])),i=new Map;for(let a of t.workflowRuns){let l=i.get(a.workflowId);l?l.push(a):i.set(a.workflowId,[a])}for(let a of t.workflows){let l=a.nodes.find(T=>T.type.startsWith("trigger."));if(!l||l.type!=="trigger.cron"&&l.type!=="trigger.hook")continue;let d=l.config??{},c=a.state||"active",u=c==="active",p=(i.get(a.id)??[]).slice().sort((T,$e)=>$e.at-T.at),g=p.map(T=>({at:T.at,status:zs(T.status)})),f=g[0],m=l.type==="trigger.cron",b=typeof d.spec=="string"?d.spec:"",x=typeof d.timezone=="string"?d.timezone:"UTC",F={id:`workflow:${a.id}`,source:"workflow",kind:m?"schedule":"event",name:E(a.title||a.id,k.text),trigger:m?{schedule:E(b,k.text),timezone:x}:{event:E(typeof d.event=="string"?d.event:"",k.text),filters:Ks(d.filter,a)},agent:Xs(a),enabled:u,state:c,nextRunAt:m&&u&&b?Le(r(b,new Date(e),x)):null,lastRun:f?{at:new Date(f.at).toISOString(),status:f.status}:null,lastSuccessAt:(()=>{let T=g.find($e=>$e.status==="success");return T?new Date(T.at).toISOString():null})(),consecutiveFailures:yn(g),sampledRuns:p.length,flags:[],attention:null},re=Date.parse(a.updated||a.created||"");F.flags=m?wn(F,g,b,x,Number.isFinite(re)?re:null,e,n,r):Bs(F,o.get(a.id)?.state==="dormant",Number.isFinite(re)?re:null,e,n),s.push(kn(F))}return s.sort(Hs).slice(0,k.routines)}function yn(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 wn(t,e,n,r,s,o,i,a){let l=[],d=e.length?e[0].at:null;if(!t.enabled){let p=xn(d,s,o,i);return p&&l.push(p),l}if(t.consecutiveFailures>=i.failStreak&&l.push({reason:"failing",detail:`${t.consecutiveFailures} failed attempts in a row`}),d===null)return l.push({reason:"never-ran",detail:"No persisted attempt"}),l;let c=new Date(d),u=null;for(let p=0;p<i.missedFires&&(u=a(n,c,r),!!u);p++)c=u;return u&&o>u.getTime()+i.graceMs&&l.push({reason:"overdue",detail:`No attempt since ${new Date(d).toISOString()}; ${i.missedFires} scheduled fires missed`}),l}function Bs(t,e,n,r,s){let o=[],i=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let a=xn(i,n,r,s);return a&&o.push(a),o}return t.consecutiveFailures>=s.failStreak&&o.push({reason:"failing",detail:`${t.consecutiveFailures} failed runs in a row`}),i===null?o.push({reason:"never-ran",detail:"No run recorded for this trigger"}):e&&o.push({reason:"dormant",detail:"Fired in the prior week, silent in the last one"}),o}function xn(t,e,n,r){let s=Math.max(t??0,e??0);return s&&n-s<r.disabledDays*bn?null:{reason:"disabled-long",detail:s?`Disabled; no activity for ${Math.floor((n-s)/bn)} days`:"Disabled and never ran"}}function kn(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 Sn={critical:0,warning:1,info:2};function Hs(t,e){let n=t.attention?Sn[t.attention]:3,r=e.attention?Sn[e.attention]:3;return n-r||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function zs(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 Xs(t){if(t.ownerAgent)return E(t.ownerAgent,k.text);let e=t.nodes.find(n=>n.type==="agent"&&typeof n.config?.agentId=="string"&&n.config.agentId);return e?E(String(e.config.agentId),k.text):null}function Ks(t,e){let n=[],r=e?.project;if(r&&n.push(E(`project=${r}`,k.filterValue)),t&&typeof t=="object"&&!Array.isArray(t))for(let[s,o]of Object.entries(t)){let i=Array.isArray(o)?o.map(String):o==null?[]:[String(o)];i.length&&n.push(E(`${s}=${i.join(",")}`,k.filterValue))}return n.slice(0,k.filters)}function Le(t){if(!t)return null;let e=t instanceof Date?t:new Date(t);return Number.isFinite(e.getTime())?e.toISOString():null}function E(t,e){return t.length<=e?t:t.slice(0,e-3)+"..."}function Gs(t,e){return t===void 0?void 0:E(t,e)}import{mkdirSync as Js,readFileSync as Ys,renameSync as Zs,writeFileSync as Qs}from"fs";import{resolve as eo}from"path";function vn(t){return eo(Ce(t),"_state.json")}function v(t){try{let e=JSON.parse(Ys(vn(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 K(t,e){Js(Ce(t),{recursive:!0});let n=vn(t),r=`${n}.${process.pid}.tmp`;Qs(r,JSON.stringify(e,null,2)+`
|
|
3
3
|
`),Zs(r,n)}function $n(t,e,n,r=Date.now()){let s=v(t),o={};for(let[i,a]of Object.entries(s.snoozed))Date.parse(a)>r&&(o[i]=a);o[e]=n.toISOString(),K(t,{...s,snoozed:o})}function pc(t,e){K(t,{...v(t),lastDigest:e})}function Oe(t,e,n,r=Date.now()){let s=v(t),o=new Set(n),i={};for(let[l,d]of Object.entries(s.popped??{}))o.has(l)&&(i[l]=d);i[e]=new Date(r).toISOString();let a=(s.wanted??[]).filter(l=>l!==e&&o.has(l));K(t,{...s,popped:i,wanted:a})}function Rn(t,e){let n=v(t);K(t,{...n,wanted:[...(n.wanted??[]).filter(r=>r!==e),e]})}function gc(t,e=Date.now()){K(t,{...v(t),popped:{},passAt:new Date(e).toISOString()})}import{existsSync as to,readFileSync as no}from"fs";Vt();Ls();function _n(t){let e=Bt(t),n={};if(to(e))try{n=qt(JSON.parse(no(e,"utf-8")))}catch{n={}}let r=Ee.safeParse(n?.requests);return r.success?r.data:Ee.parse(void 0)}async function wc(t,e={}){let n=(t.channels??[]).filter(r=>!Re.has(r.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(r=>`"${r}"`).join(", ")}: use ${[...Re].join(", ")}`}:Ht(r=>{let s=r.requests??={};for(let o of["enabled","channels","from","staleAfterHours","retentionDays","settleHandedBack"])t[o]!==void 0&&(s[o]=t[o]);if(t.plans){let o=s.plans??={};for(let i of["enabled","stallMinutes","maxNudges","approveKinds","disabledAgents","requireForWork","requireOverMinutes"])t.plans[i]!==void 0&&(o[i]=t.plans[i])}if(t.headlines?.enabled!==void 0&&((s.headlines??={}).enabled=t.headlines.enabled),t.catchPromises){let o=s.catchPromises??={};for(let i of["enabled","dailyCap"])t.catchPromises[i]!==void 0&&(o[i]=t.catchPromises[i])}if(t.checkers){let o=s.checkers??={};for(let i of["enabled","checkEveryMinutes"])t.checkers[i]!==void 0&&(o[i]=t.checkers[i])}},{configPath:e.configPath,reload:e.reload})}import{existsSync as G,readdirSync as bo,readFileSync as yo}from"fs";import{resolve as A}from"path";import{randomBytes as In}from"crypto";import{existsSync as so,mkdirSync as oo,readdirSync as io,readFileSync as ao,renameSync as Tn,unlinkSync as lo,writeFileSync as co}from"fs";import{resolve as Dn}from"path";function En(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var ro=t=>t.trim().split(`
|
|
4
4
|
`).pop()?.slice(0,300)||"no output";async function An(t,e,n,r=Ne){let s=await r(t.bin,[...En(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return s.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${ro(s.stderr||s.stdout)}`}}async function xc(t,e,n,r,s=Ne){return(await s(t.bin,[...En(t),"--read-only","media","download","--chat",e,"--id",n,"--output",r],{timeoutMs:12e4})).code===0}var uo=2e3,po=t=>An(t.wacli,t.to,t.text);function Pe(t){return Dn(t,".agentx","whatsapp-triage","drafts")}var go=t=>/^[a-z0-9-]{8,64}$/.test(t),ae=(t,e)=>Dn(Pe(t),`${e}.json`);function Cn(t,e){oo(Pe(t),{recursive:!0});let n=ae(t,e.id),r=`${n}.${process.pid}.tmp`;co(r,JSON.stringify(e,null,2)+`
|
|
@@ -53,7 +53,7 @@ import{a as Ne}from"./chunk-GTJIKXDB.js";import{C as dn,J as mn,k as O}from"./ch
|
|
|
53
53
|
`)}function Pn(t){return!!t.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'request_plans'").get()}function Me(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 On(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 ho={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"},ce=class{constructor(e){this.db=e;mo(e)}create(e,n,r,s){let o=this.db.prepare("INSERT INTO request_plans (request_id, created_by, created_at, state) VALUES (?, ?, ?, 'active')"),i=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
55
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);this.db.transaction(()=>{o.run(e,n,s),r.forEach((a,l)=>{let d=l===0,c=d&&a.agentId===n&&a.kind!=="message";i.run(e,l+1,a.name,a.kind,a.agentId,a.doneWhen,d?"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,c?s:null,s)}),this.event(e,null,"created",`${r.length} steps, written by ${n}`,s)})()}get(e){let n=this.db.prepare("SELECT * FROM request_plans WHERE request_id = ?").get(e);return n?Me(n):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(On)}step(e,n){let r=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,n);return r?On(r):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(Me)}updateStep(e,n,r){let s=[],o=[];for(let[i,a]of Object.entries(r)){let l=ho[i];!l||a===void 0||(s.push(`${l} = ?`),o.push(typeof a=="boolean"?a?1:0:a))}s.length&&this.db.prepare(`UPDATE request_plan_steps SET ${s.join(", ")} WHERE request_id = ? AND idx = ?`).run(...o,e,n)}finish(e,n,r){return this.db.prepare("UPDATE request_plans SET state = ?, finished_at = ? WHERE request_id = ? AND state = 'active'").run(n,r,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(Me)}event(e,n,r,s,o){this.db.prepare("INSERT INTO request_plan_events (request_id, step, at, kind, detail) VALUES (?, ?, ?, ?, ?)").run(e,n,o,r,s.replace(/\s+/g," ").trim().slice(0,fo))}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(r=>({requestId:r.request_id,step:r.step??null,at:r.at,kind:r.kind,detail:r.detail}))}},Cc=Mt;var Fn=["card","schedule","memory","wiki","whatsapp","request"],wo=280;function q(t,e=wo){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}function Ue(t){if(t.configPath)return A(t.configPath);let e=[A(t.root,"agentx.json"),A(t.root,".agentx","config.json")];return e.find(n=>G(n))??e[0]}function Fe(t){return t.wikiDir?A(t.wikiDir):A(t.root,".agentx","wiki")}function ko(t){return W(t.root,"pending").map(So)}function So(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:q([t.context,t.draft?`Suggested message: ${t.draft}`:""].filter(Boolean).join(" \xB7 "))}:{}}}function xo(t){let e=Ue(t);if(!G(e))return[];let n;try{n=JSON.parse(yo(e,"utf-8"))}catch{return[]}let r=new Date(t.now??Date.now()),s=[];for(let[o,i]of Object.entries(n?.crons??{})){let a=i?.approval;if(!a||a.action!=="create"&&a.action!=="delete")continue;let l=i.timezone||"UTC",d=i.schedule?Jt(i.schedule):"",c=i.schedule?`${d.charAt(0).toLowerCase()}${d.slice(1)} (${i.schedule})`:"no schedule",u=String(i.prompt??i.command??""),p=a.action==="create";s.push({key:`schedule:${o}`,kind:"schedule",title:p?`New schedule "${o}" for ${i.agent??"an agent"}`:`Delete schedule "${o}"`,ask:p?`Let ${i.agent??"the agent"} run this ${c}?`:`Remove the schedule "${o}" (${c})?`,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:q(`${u}${p&&i.schedule?` \xB7 first run ${Zt(Yt(i.schedule,l,r),l)}`:""}`),more:"agentx schedule list"})}return s}function Wn(t){let e=A(t,".agentx","memory");return G(e)?bo(e).filter(n=>n.endsWith(".jsonl")).map(n=>n.slice(0,-6)).sort():[]}function vo(t){let e=Wn(t.root);if(e.length===0)return[];let n=new Ae(t.root),r=[];for(let s of e)for(let o of n.held(s))r.push({key:`memory:${s}/${o.id}`,kind:"memory",title:`Fact ${s} learned from ${o.source.channel}`,ask:`Let ${s} use this fact in its prompts?`,yes:"use it",no:"keep it out for good",raised_by:s,created_at:o.createdAt,detail:q(o.content),more:`agentx memory facts held --agent ${s}`});return r}function $o(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 Ro(t){return an(Fe(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:q(`${$o(n)} ${e.article.content}`),more:`agentx wiki proposals show ${e.id}`}})}function _o(t){return Nn(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:q(`${e.triage}: ${e.summary}`),more:"agentx whatsapp triage log"}))}function P(t){if(t.requests)return t.requests;if(A(t.root)!==process.cwd()||!G(A(t.root,".agentx","db.sqlite")))return null;let e=_e({quiet:!0});if(!e)return null;let n=Mn.get(e);return!n&&!Ut(e)?null:(n||Mn.set(e,n=new Ft(e)),n)}var Mn=new WeakMap;function Kc(t){if(t.plans)return t.plans;if(t.requests||A(t.root)!==process.cwd()||!G(A(t.root,".agentx","db.sqlite")))return null;let e=_e({quiet:!0});if(!e||!Pn(e))return null;let n=Un.get(e);return n||Un.set(e,n=new ce(e)),n}var Un=new WeakMap;function Eo(t){let e=P(t);return e?e.listByState("needs_attention").map(n=>({key:`request:${n.id}`,kind:"request",title:O(n,120).headline,ask:`Not finished. 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:q(`${n.attentionReason??"It needs attention"}. You said (${n.channel}): ${n.text}`),more:`agentx requests show ${n.id}`})):[]}var qn={card:ko,schedule:xo,memory:vo,wiki:Ro,whatsapp:_o,request:Eo};function Ao(t,e){let n=t.expires?Date.parse(t.expires):1/0,r=e.expires?Date.parse(e.expires):1/0;return n!==r?n-r:(Date.parse(t.created_at)||0)-(Date.parse(e.created_at)||0)}function jn(t,e={}){let n=t.now??Date.now(),{snoozed:r}=v(t.root),s=[],o=[],i=0;for(let a of e.kinds??Fn){let l;try{l=qn[a](t)}catch(d){o.push({kind:a,error:String(d?.message??d).slice(0,200)});continue}for(let d of l){let c=r[d.key];if(c&&Date.parse(c)>n){if(!e.includeSnoozed){i++;continue}d.snoozed_until=c}s.push(d)}}return s.sort(Ao),{items:s,snoozed:i,errors:o}}function Io(t){let e=t.indexOf(":");if(e<=0)return null;let n=t.slice(0,e),r=t.slice(e+1);return!Fn.includes(n)||!r?null:{kind:n,ref:r}}function To(t,e,n){switch(e){case"card":return X(t.root,n)?.status==="pending";case"wiki":return on(Fe(t),n)?.status==="pending";case"whatsapp":return le(t.root,n)?.status==="pending";default:return qn[e](t).some(r=>r.key===`${e}:${n}`)}}async function Vn(t,e,n,r={}){let s=Io(e);if(!s)return{ok:!1,error:`unknown item "${e}": use a key from \`agentx approvals list\``};let{kind:o,ref:i}=s,a=t.now??Date.now(),l=r.by??"operator";if(n==="later"){if(!To(t,o,i))return{ok:!1,error:`nothing waiting for "${e}"`};let c=r.laterHours&&r.laterHours>0?r.laterHours:24,u=new Date(a+c*36e5);return $n(t.root,e,u,a),{ok:!0,message:`${e} put off until ${u.toISOString()}`}}let d=n==="yes";switch(o){case"card":{let c=fn(t.root,i,d?"yes":"no",{by:l,note:r.note,now:a,choice:r.choice,text:r.text});return c.ok?{ok:!0,message:`${e}: ${c.card.raised_by} will be told ${d?"yes":"no"}${c.card.choice?` (${c.card.choice}${c.card.choice_suggested?", the suggested option":""})`:""}`}:c}case"schedule":{let c=await(d?Qt:en)(i,{configPath:Ue(t),reload:t.reload});return c.success?{ok:!0,message:c.message}:{ok:!1,error:c.message}}case"memory":{let c=i.indexOf("/");if(c<=0)return{ok:!1,error:"memory keys look like memory:<agent>/<fact-id>"};let u=i.slice(0,c),p=i.slice(c+1);if(!Wn(t.root).includes(u))return{ok:!1,error:`no memory for agent "${u}"`};let g=new Ae(t.root);return g.held(u).some(f=>f.id===p)?(g.review(u,p,d?"approved":"rejected",l),{ok:!0,message:`${e} ${d?"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 c=Fe(t),u=d?ln(c,i,{by:l,force:r.force,now:a}):cn(c,i,{by:l,reason:r.note,now:a});return u.ok?{ok:!0,message:d?`${u.proposal.article.path} written to the shared wiki`:`${e} rejected`}:u}case"whatsapp":{let c=await Ln(t.root,i,d?"yes":"no",{by:l,now:a,send:t.sendWhatsApp});return c.ok?{ok:!0,message:d?`${e}: sent to ${c.draft.chat_name||c.draft.to}`:`${e}: dropped, nothing sent`}:c}case"request":{let c=P(t),u=c?.get(i);return!c||!u||u.state!=="needs_attention"?{ok:!1,error:`nothing waiting for "${e}"`}:d?_n(Ue(t)).enabled?(c.requestPickup(i,a),{ok:!0,message:`${e}: ${u.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."}:(c.close(i,"dropped",r.note?.trim()||`dropped by ${l}`,a),{ok:!0,message:`${e}: dropped`})}}}var Do=3,Co=7,No=50,qe=120,Lo=280,We=600,Hn=36e5,Oo=24*Hn;function Yc(t){let e=new Set;for(let n of t)for(let r of n.runningTasks??[])r.traceId&&e.add(r.traceId);return e}function j(t,e){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}var de=t=>new Date(t).toISOString();function Po(t,e,n){let r=e.key.slice(0,Math.max(0,e.key.indexOf(":")))||"card";return{key:e.key,kind:r,column:"yours",node:t.node,nodeName:t.nodeName,title:j(e.title,qe),...e.ask?{ask:j(e.ask,We)}:{},...e.detail?{facts:j(e.detail,Lo)}:{},...e.recommend?{recommend:e.recommend}:{},...e.raisedBy?{agent:e.raisedBy}:{},...e.yes?{yes:e.yes}:{},...e.no?{no:e.no}:{},...e.choices?.length?{choices:e.choices}:{},...e.draft?{draft:e.draft}:{},...e.expires?{expires:e.expires}:{},...e.ifSilent?{ifSilent:e.ifSilent}:{},...e.createdAt?{askedAt:e.createdAt}:{},can:{answer:!0,later:!0,reply:n&&r==="request"}}}var Mo={done:"Done",declined:"Declined",dropped:"Dropped"};function zn(t,e,n){let{record:r,links:s}=e,o=O(r,qe),i={key:`request:${r.id}`,kind:"request",node:t.node,nodeName:t.nodeName,title:o.headline,need:o.need,...r.headline?{said:j(o.said,We)}:{},agent:r.agentId,askedAt:de(r.createdAt),changedAt:de(r.stateChangedAt??r.updatedAt)};switch(r.state){case"candidate":case"needs_attention":return null;case"waiting_owner":return s.some(a=>a.kind==="card"&&n.has(`card:${a.ref}`))?null:{...i,column:"yours",...r.question?{ask:j(r.question,We)}:{},can:{answer:!1,later:!1,reply:!0}};case"in_progress":case"waiting_other":{let a=s.some(d=>d.kind==="run"&&!!t.liveRuns?.has(d.ref)),l=t.now-r.updatedAt<(t.quietHours??Do)*Hn;return{...i,column:a||l?"agent":"quiet",...a?{live:a}:{},can:{answer:!1,later:!1,reply:!a}}}default:{let a=r.state==="done"?r.evidence:r.closeReason;return{...i,need:void 0,column:"done",changedAt:de(r.closedAt??r.stateChangedAt??r.updatedAt),outcome:Mo[r.state]??r.state,...a?{evidence:a}:{},can:{answer:!1,later:!1,reply:!1}}}}}function Uo(t){return t.status==="decided"?t.verdict==="yes"?`Answered yes${t.choice?`: ${t.choice}`:""}`:"Answered no":t.status==="expired"?`No answer in time: ${t.outcome==="discard"?"discarded":t.outcome==="pause"?"paused":"kept"}`:"Closed by the agent"}function Fo(t,e){return{key:`card:${e.id}`,kind:"card",column:"done",node:t.node,nodeName:t.nodeName,title:j(e.title,qe),ask:e.ask,agent:e.raised_by,askedAt:e.created_at,...e.decided_at?{changedAt:e.decided_at}:{},outcome:Uo(e),...e.resolution?{evidence:e.resolution}:{},can:{answer:!1,later:!1,reply:!1}}}var $=t=>t&&Date.parse(t)||0,Bn=(t,e)=>t.map(n=>n[e]).filter(n=>!!$(n)).sort((n,r)=>$(n)-$(r))[0];function je(t){let e=[],n=[];for(let s of t.inbox){s.error&&n.push(`What waits on ${s.nodeName} could not be read: ${s.error}`);for(let o of s.items)e.push(Po(s,o,s.node===t.node))}let r=Xn(t,e);for(let s of t.requests??[]){let o=zn(t,s,r);o?.column==="yours"&&e.push(o)}return{cards:e,errors:n}}function Xn(t,e){return new Set([...e.filter(n=>n.node===t.node).map(n=>n.key),...t.deferred??[]])}function Zc(t){let e=je(t.owner?{...t,requests:null}:t),n=t.owner?[...t.owner.items,...e.cards]:e.cards,r=t.owner?[...t.owner.errors,...e.errors]:e.errors,s=Xn(t,n),o=[],i=[],a=[];for(let p of t.requests??[]){let g=zn(t,p,s);g&&g.column!=="yours"&&{agent:o,quiet:i,done:a}[g.column].push(g)}let l=t.now-(t.doneDays??Co)*Oo;for(let p of t.cards)p.status!=="pending"&&$(p.decided_at)>=l&&a.push(Fo(t,p));o.sort((p,g)=>$(g.changedAt)-$(p.changedAt)),i.sort((p,g)=>$(p.changedAt)-$(g.changedAt)),a.sort((p,g)=>$(g.changedAt)-$(p.changedAt));let d=a.filter(p=>$(p.changedAt)>=l).slice(0,No),c=Bn(n,"askedAt"),u=Bn(i,"changedAt");return{ts:de(t.now),cards:[...n,...o,...i,...d],figures:{yours:{count:n.length,...c?{oldest:c}:{},...t.owner?.later?{later:t.owner.later}:{}},agent:{count:o.length},quiet:{count:i.length,...u?{oldest:u}:{}},done:{count:d.length}},errors:r}}function Wo(t){return{key:t.key,title:t.title,ask:t.ask,recommend:t.recommend,yes:t.yes,no:t.no,raisedBy:t.raised_by,expires:t.expires,...t.if_silent?{ifSilent:t.if_silent}:{},...t.choices?{choices:t.choices}:{},...t.draft?{draft:t.draft}:{},...t.detail?{detail:t.detail}:{},...t.created_at?{createdAt:t.created_at}:{}}}function qo(t,e,n){let r=t.map(s=>s.askedAt).filter(s=>!!s&&!!Date.parse(s)).sort((s,o)=>Date.parse(s)-Date.parse(o));return{count:t.length,later:e,...r[0]?{oldest:r[0]}:{},items:t,errors:n}}function nd(t,e){let n=t.now??Date.now(),r=[],s=jn(t,{includeSnoozed:!0});for(let c of s.errors)r.push(`What waits (${c.kind}) could not be read: ${c.error}`);let o=s.items.filter(c=>!c.snoozed_until),i=new Set(s.items.filter(c=>c.snoozed_until).map(c=>c.key)),a=null;try{let c=P(t);c&&(a=c.listByState("waiting_owner").map(u=>({record:u,links:c.links(u.id)})))}catch(c){r.push(`Requests could not be read: ${c?.message??c}`)}let{cards:l,errors:d}=je({now:n,node:e.url,nodeName:e.name,inbox:[{node:e.url,nodeName:e.name,items:o.map(Wo)}],requests:a,deferred:i});return qo(l,i.size,[...r,...d])}import{readFileSync as jo}from"fs";var Vo=1e4,Kn=/^[0-9a-f]{7,64}$/i;function od(t){let e=t.fetch??fetch;return async n=>{if(n==="self"){let i=t.self();return i&&Kn.test(i)?{source:n,commit:i}:{source:n,commit:null,error:"this build does not carry its commit (run from source?)"}}let r;try{r=await e(n,{signal:AbortSignal.timeout(Vo)})}catch(i){return{source:n,commit:null,error:`could not be reached: ${String(i?.message??i).slice(0,200)}`}}if(!r.ok)return{source:n,commit:null,error:`HTTP ${r.status}`};let s=await r.json().catch(()=>null),o=t.field.split(".").reduce((i,a)=>i&&typeof i=="object"?i[a]:void 0,s);return typeof o=="string"&&Kn.test(o.trim())?{source:n,commit:o.trim()}:{source:n,commit:null,error:`no commit under "${t.field}"`}}}function id(t){let e=t.requests.checkers,n=t.channels.github,r=e?.github?.token??n?.token;if(!r&&n?.tokenFile)try{r=jo(n.tokenFile,"utf-8").trim().split(`
|
|
56
|
-
`)[0].trim()||void 0}catch{}let s=t.channels.gitlab;return{github:{apiUrl:e?.github?.apiUrl??"https://api.github.com",token:r},gitlab:{url:e?.gitlab?.url??s?.host??"https://gitlab.com",token:e?.gitlab?.token??s?.token}}}var Gn=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function ld(t){return t==="/api/memory"||t.startsWith("/api/memory/")||t==="/approvals"||t.startsWith("/approvals/")||t==="/screen"||t==="/native/notes"||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"||t==="/owner/told"||t==="/owner/presence"}function cd(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)||/^\/channels\/[^/]+\/switch$/.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 dd(t){return Gn.has(t)}function ud(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(Gn.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 pd(t,e=process.env){let n=new Set;e.MESH_TOKEN&&n.add(e.MESH_TOKEN);for(let r of t.mesh?.peers||[])r.token&&n.add(r.token);return n}function gd(t,e,n=process.env){let r=o=>o.replace(/\/+$/,"");return(e===r(t.daemonUrl)?t.token:t.daemons.find(o=>r(o.url)===e)?.token)||n.MESH_TOKEN||void 0}function ue(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function Bo(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function Ho(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function md(t,e=Ho()){let n=ue(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let s=Bo(n),o=[ue(t.host),ue(t["x-forwarded-host"])].filter(Boolean).map(i=>i.toLowerCase());return s&&o.includes(s)?"same-origin":"foreign"}let r=ue(t["sec-fetch-site"]).toLowerCase();return r==="cross-site"||r==="same-site"?"foreign":"none"}function hd(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as kr,mkdirSync as ki,readFileSync as Si,renameSync as xi,writeFileSync as vi}from"fs";import{homedir as $i}from"os";import{dirname as Ri,join as _i}from"path";import{execFile as ni,execFileSync as ri}from"child_process";import{execFileSync as zo}from"child_process";import{existsSync as Yn,mkdirSync as Xo,readdirSync as Ko,readFileSync as Zn,renameSync as Go,writeFileSync as Jo}from"fs";import{homedir as Qn}from"os";import{join as Be}from"path";var R="siri:",er="com.apple.ttsbundle.gryphon-neural_",tr=t=>!!t&&t.startsWith(er),Yo=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],Zo=()=>{try{return zo("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ve;function He(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ve!==void 0)return Ve;let{platform:n=process.platform,exists:r=Yn,prefDomain:s=Zo}=t,o=n==="darwin"&&Yo.every(i=>r(i))&&s();return e||(Ve=o),o}var nr=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],rr={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"},ze=t=>rr[t.toLowerCase()]??null;function pe(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 Qo=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function ei(t){let e=new Map;for(let n of t)for(let[,r,s,o]of n.matchAll(Qo)){let i=`${r}-${s}`,a=`${er}${o}_${i}_premium`;e.has(a)||e.set(a,{id:a,name:o[0].toUpperCase()+o.slice(1),locale:i,quality:"premium",gender:rr[o]??null,siri:!0})}return[...e.values()]}function ge(t=nr,e={}){if(!He(e))return[];let n=[];for(let r of t){let s;try{s=Ko(r)}catch{continue}for(let o of s)try{n.push(Zn(Be(r,o,"Info.plist"),"latin1"))}catch{}}return ei(n)}var Jn=`#!/bin/sh
|
|
56
|
+
`)[0].trim()||void 0}catch{}let s=t.channels.gitlab;return{github:{apiUrl:e?.github?.apiUrl??"https://api.github.com",token:r},gitlab:{url:e?.gitlab?.url??s?.host??"https://gitlab.com",token:e?.gitlab?.token??s?.token}}}var Gn=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function ld(t){return t==="/api/memory"||t.startsWith("/api/memory/")||t==="/approvals"||t.startsWith("/approvals/")||t==="/screen"||t==="/native/notes"||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"||t==="/owner/told"||t==="/owner/presence"}function cd(t){return t==="/reload"||t==="/api/processes/kill"||t==="/send"||t==="/send/agent"||t==="/send/contact"||t==="/mesh/announce"||t==="/events"||t==="/voice/settings"||t==="/voice/preview"||/^\/api\/tasks\/[^/]+\/(cancel|followup)$/.test(t)||/^\/mesh\/guests\/[^/]+\/(pause|resume|end|update)$/.test(t)||/^\/crons\/[^/]+\/enabled$/.test(t)||/^\/channels\/[^/]+\/switch$/.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 dd(t){return Gn.has(t)}function ud(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(Gn.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 pd(t,e=process.env){let n=new Set;e.MESH_TOKEN&&n.add(e.MESH_TOKEN);for(let r of t.mesh?.peers||[])r.token&&n.add(r.token);return n}function gd(t,e,n=process.env){let r=o=>o.replace(/\/+$/,"");return(e===r(t.daemonUrl)?t.token:t.daemons.find(o=>r(o.url)===e)?.token)||n.MESH_TOKEN||void 0}function ue(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function Bo(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function Ho(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function md(t,e=Ho()){let n=ue(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let s=Bo(n),o=[ue(t.host),ue(t["x-forwarded-host"])].filter(Boolean).map(i=>i.toLowerCase());return s&&o.includes(s)?"same-origin":"foreign"}let r=ue(t["sec-fetch-site"]).toLowerCase();return r==="cross-site"||r==="same-site"?"foreign":"none"}function hd(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as kr,mkdirSync as ki,readFileSync as Si,renameSync as xi,writeFileSync as vi}from"fs";import{homedir as $i}from"os";import{dirname as Ri,join as _i}from"path";import{execFile as ni,execFileSync as ri}from"child_process";import{execFileSync as zo}from"child_process";import{existsSync as Yn,mkdirSync as Xo,readdirSync as Ko,readFileSync as Zn,renameSync as Go,writeFileSync as Jo}from"fs";import{homedir as Qn}from"os";import{join as Be}from"path";var R="siri:",er="com.apple.ttsbundle.gryphon-neural_",tr=t=>!!t&&t.startsWith(er),Yo=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],Zo=()=>{try{return zo("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ve;function He(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ve!==void 0)return Ve;let{platform:n=process.platform,exists:r=Yn,prefDomain:s=Zo}=t,o=n==="darwin"&&Yo.every(i=>r(i))&&s();return e||(Ve=o),o}var nr=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],rr={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"},ze=t=>rr[t.toLowerCase()]??null;function pe(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 Qo=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function ei(t){let e=new Map;for(let n of t)for(let[,r,s,o]of n.matchAll(Qo)){let i=`${r}-${s}`,a=`${er}${o}_${i}_premium`;e.has(a)||e.set(a,{id:a,name:o[0].toUpperCase()+o.slice(1),locale:i,quality:"premium",gender:rr[o]??null,siri:!0})}return[...e.values()]}function ge(t=nr,e={}){if(!He(e))return[];let n=[];for(let r of t){let s;try{s=Ko(r)}catch{continue}for(let o of s)try{n.push(Zn(Be(r,o,"Info.plist"),"latin1"))}catch{}}return ei(n)}var Jn=`#!/bin/sh
|
|
57
57
|
# Written by agentx; shared by the daemon and AgentX Voice. Do not edit.
|
|
58
58
|
# siri-say.sh [voice] < text speak one line. A Siri voice id switches
|
|
59
59
|
# the OS default for it; any other id is
|
|
@@ -575,4 +575,4 @@ Document the arguments, commands, or files the skill expects. Example:
|
|
|
575
575
|
claude-code ${Lt(t)} --arg value
|
|
576
576
|
\`\`\`
|
|
577
577
|
`}Vt();var Is={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function Ts(t){return{...Is,...t??{},regions:{...t?.regions??{}},buffer:{...Is.buffer,...t?.buffer??{}}}}function pg(t){try{return Ts(jt(t).screen)}catch{return Ts(void 0)}}var ec=/^[a-z][\w-]*$/,Ds=["window","screen","menubar","notifications"];function ne(t,e,n,r){let s=Number(t);if(t===""||t===null||!Number.isFinite(s)||!n(s))throw new Error(`${e} must be ${r}`);return s}var ve=(t,e)=>ne(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function Cs(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 gg(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=ve(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=ve(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=ve(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=ne(e.stableMs,"stableMs",s=>Number.isInteger(s)&&s>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=ne(e.changeThreshold,"changeThreshold",s=>s>=0&&s<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let s={...n.regions??{}};for(let[o,i]of Object.entries(e.regions)){if(!ec.test(o))throw new Error(`region name "${o}" must be lowercase letters, digits, - or _`);i===null?delete s[o]:s[o]=Cs(i)}n.regions=s}if(e.buffer&&typeof e.buffer=="object"){let s=e.buffer,o={...n.buffer??{}};"enabled"in s&&(o.enabled=!!s.enabled),"seconds"in s&&(o.seconds=ne(s.seconds,"buffer.seconds",i=>i>0&&i<=120,"above 0 and at most 120")),"fps"in s&&(o.fps=ne(s.fps,"buffer.fps",i=>i>0&&i<=10,"above 0 and at most 10")),"maxPixels"in s&&(o.maxPixels=ve(s.maxPixels,"buffer.maxPixels")),"region"in s&&(o.region=String(s.region).trim()),n.buffer=o}let r=n.buffer?.region;if(r!==void 0&&!Ds.includes(r)&&!n.regions?.[r])try{Cs(r)}catch{throw new Error(`buffer.region "${r}" is not a region \u2014 use ${[...Ds,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{hn as a,rc as b,pt as c,Xi as d,Ki as e,tu as f,nu as g,ru as h,iu as i,au as j,lu as k,Ir as l,Tr as m,cu as n,Dr as o,uu as p,gu as q,N as r,Cr as s,k as t,ac as u,Or as v,wu as w,xu as x,Mr as y,vu as z,Ur as A,$u as B,Z as C,Sa as D,Ru as E,_u as F,Wr as G,xc as H,po as I,Ac as J,Ln as K,v as L,pc as M,gc as N,Dc as O,ce as P,Cc as Q,_n as R,wc as S,P as T,Kc as U,jn as V,Vn as W,Co as X,No as Y,Yc as Z,Zc as _,Wo as $,nd as aa,jr as ba,Iu as ca,od as da,id as ea,Rr as fa,rt as ga,Wi as ha,ts as ia,op as ja,ip as ka,il as la,dp as ma,as as na,up as oa,pp as pa,yp as qa,bl as ra,wp as sa,ld as ta,cd as ua,dd as va,ud as wa,pd as xa,gd as ya,md as za,hd as Aa,Rd as Ba,Ke as Ca,_d as Da,Ed as Ea,J as Fa,Y as Ga,vl as Ha,Ap as Ia,Ip as Ja,Tp as Ka,Dp as La,xt as Ma,Cp as Na,Ye as Oa,Ze as Pa,he as Qa,pi as Ra,fi as Sa,Cd as Ta,et as Ua,tt as Va,mi as Wa,hi as Xa,fr as Ya,yr as Za,Nd as _a,wi as $a,Ld as ab,Ei as bb,Ti as cb,nt as db,Ci as eb,wr as fb,L as gb,ys as hb,ws as ib,ks as jb,$t as kb,Up as lb,Cl as mb,xs as nb,vs as ob,Gp as pb,Jp as qb,Kl as rb,Yp as sb,Rs as tb,be as ub,zd as vb,dt as wb,Qd as xb,tg as yb,ng as zb,rg as Ab,sg as Bb,og as Cb,ig as Db,ag as Eb,lg as Fb,cg as Gb,Is as Hb,Ts as Ib,pg as Jb,Ds as Kb,gg as Lb};
|
|
578
|
-
//# sourceMappingURL=chunk-
|
|
578
|
+
//# sourceMappingURL=chunk-56I4CDWP.js.map
|