agentix-cli 0.48.0 → 0.50.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 +17 -0
- package/apps/mac-voice/Sources/AgentXVoice/AgentClient.swift +17 -5
- package/apps/mac-voice/Sources/AgentXVoice/Config.swift +6 -1
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +5 -2
- package/dist/{App-EXB4HP3B.js → App-KE4SURSS.js} +2 -2
- package/dist/{ChatApp-XMNE3SPH.js → ChatApp-NNHIKXO2.js} +2 -2
- package/dist/{agent-ORYXXL5K.js → agent-RY7Z3IYY.js} +2 -2
- package/dist/{board-dashboard-2B3HYIXD.js → board-dashboard-RUOASCSQ.js} +6 -6
- package/dist/board-dashboard-RUOASCSQ.js.map +1 -0
- package/dist/{chunk-DLKRPK5M.js → chunk-4BNQSUWV.js} +7 -2
- package/dist/{chunk-DLKRPK5M.js.map → chunk-4BNQSUWV.js.map} +1 -1
- package/dist/{chunk-26OP3X5B.js → chunk-4NBWF4TL.js} +2 -2
- package/dist/{chunk-P7MR53U7.js → chunk-4TITGMPX.js} +2 -2
- package/dist/{chunk-XM7ZQW4F.js → chunk-5ALS7SVV.js} +2 -2
- package/dist/{chunk-3ZHMIWSV.js → chunk-5XQCGPQJ.js} +2 -2
- package/dist/{chunk-DVNIFP7S.js → chunk-6VKCUMCN.js} +2 -2
- package/dist/{chunk-GCHUE3TN.js → chunk-7WDJW37G.js} +2 -2
- package/dist/{chunk-FRHSQVFN.js → chunk-AQASR6KR.js} +3 -3
- package/dist/chunk-AQASR6KR.js.map +1 -0
- package/dist/{chunk-M5R3PWW5.js → chunk-B5XHX44Y.js} +2 -2
- package/dist/{chunk-4ZX4E7P3.js → chunk-BYD55JXH.js} +8 -8
- package/dist/chunk-BYD55JXH.js.map +1 -0
- package/dist/{chunk-DIV66W3N.js → chunk-EMI3VJLH.js} +10 -10
- package/dist/chunk-EMI3VJLH.js.map +1 -0
- package/dist/chunk-HRBKSZ34.js +2 -0
- package/dist/chunk-HRBKSZ34.js.map +1 -0
- package/dist/{chunk-MLLEOFX2.js → chunk-IXUEJBHD.js} +2 -2
- package/dist/{chunk-LDILAHMN.js → chunk-JVNFRS26.js} +2 -2
- package/dist/{chunk-GIK7S3OY.js → chunk-N2XXKFJ6.js} +7 -7
- package/dist/chunk-N2XXKFJ6.js.map +1 -0
- package/dist/{chunk-DJQA2CWD.js → chunk-N6EWZGIX.js} +6 -6
- package/dist/{chunk-DJQA2CWD.js.map → chunk-N6EWZGIX.js.map} +1 -1
- package/dist/{chunk-HEQPHUTR.js → chunk-NLZD2QKF.js} +2 -2
- package/dist/chunk-OHA3J5ZV.js +243 -0
- package/dist/chunk-OHA3J5ZV.js.map +1 -0
- package/dist/{chunk-P5JXQRBH.js → chunk-OTW5MPFT.js} +2 -2
- package/dist/{chunk-WMI5B36E.js → chunk-OUZ7YVQZ.js} +2 -2
- package/dist/{chunk-GAGVFSZM.js → chunk-P2ZYT5D6.js} +2 -2
- package/dist/chunk-P2ZYT5D6.js.map +1 -0
- package/dist/{chunk-2WPTP5HO.js → chunk-PZCTCCC5.js} +2 -2
- package/dist/chunk-Q7C3X3R6.js +61 -0
- package/dist/chunk-Q7C3X3R6.js.map +1 -0
- package/dist/{chunk-3WLO2UKI.js → chunk-QDE75R4U.js} +2 -2
- package/dist/{chunk-ZUZESPCH.js → chunk-TTL37CS5.js} +64 -64
- package/dist/chunk-TTL37CS5.js.map +1 -0
- package/dist/{chunk-2GSEEKQK.js → chunk-TUNQFPVA.js} +2 -2
- package/dist/{chunk-SL657MIM.js → chunk-WQLBJ2O5.js} +2 -2
- package/dist/{chunk-OZX7HVHC.js → chunk-Y6I3BYWV.js} +172 -165
- package/dist/chunk-Y6I3BYWV.js.map +1 -0
- package/dist/{chunk-SFLF64Q3.js → chunk-Z3IP66SL.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/client-JZTH46N2.js +2 -0
- package/dist/{compaction-U5SAYTX6.js → compaction-PIZINFHR.js} +2 -2
- package/dist/{config-ROQ4VEU3.js → config-R47ITLIY.js} +2 -2
- package/dist/config-mutator-T6JGXJ26.js +2 -0
- package/dist/context-planner-FJMU5WAT.js +17 -0
- package/dist/context-planner-FJMU5WAT.js.map +1 -0
- package/dist/doctor-2DMGAWMW.js +2 -0
- package/dist/failure-candidates-ARRMFXRY.js +8 -0
- package/dist/failure-candidates-ARRMFXRY.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +1 -1
- package/dist/memory-extract-OWTI6MN5.js +2 -0
- package/dist/processes-KUJJ7XE7.js +2 -0
- package/dist/program-KY5ZYPFN.js +2 -0
- package/dist/promote-57YNOVXV.js +2 -0
- package/dist/proposals-TX2HBBYV.js +2 -0
- package/dist/query-ZT7WXY2F.js +2 -0
- package/dist/registry-LLAFJJN4.js +2 -0
- package/dist/{request-planner-FAFNFVFX.js → request-planner-PEAYYXAP.js} +2 -2
- package/dist/{review-candidates-2XKJ2R6U.js → review-candidates-W7NIHNAI.js} +2 -2
- package/dist/{routing-PUPVGJ77.js → routing-7LCO7UJ7.js} +2 -2
- package/dist/schedule-tool-ZD3VBUBW.js +2 -0
- package/dist/scheduler-GC3FQKXY.js +2 -0
- package/dist/{seat-2MW3DEXX.js → seat-HR6QMAR2.js} +2 -2
- package/dist/{select-Q3AGLQQX.js → select-4XYRIZ5L.js} +2 -2
- package/dist/{surface-usage-FM2ZHGYE.js → surface-usage-V2BX4SBD.js} +2 -2
- package/dist/{tool-IVUNSAXY.js → tool-PAQ47HV2.js} +2 -2
- package/dist/wiki-EREMPSAE.js +2 -0
- package/package.json +1 -1
- package/dist/board-dashboard-2B3HYIXD.js.map +0 -1
- package/dist/chunk-4ZX4E7P3.js.map +0 -1
- package/dist/chunk-7DXE264B.js +0 -2
- package/dist/chunk-7DXE264B.js.map +0 -1
- package/dist/chunk-DIV66W3N.js.map +0 -1
- package/dist/chunk-FRHSQVFN.js.map +0 -1
- package/dist/chunk-GAGVFSZM.js.map +0 -1
- package/dist/chunk-GIK7S3OY.js.map +0 -1
- package/dist/chunk-OZX7HVHC.js.map +0 -1
- package/dist/chunk-RYLTCOYE.js +0 -241
- package/dist/chunk-RYLTCOYE.js.map +0 -1
- package/dist/chunk-WZGABQ72.js +0 -59
- package/dist/chunk-WZGABQ72.js.map +0 -1
- package/dist/chunk-ZUZESPCH.js.map +0 -1
- package/dist/client-6HCY7UMW.js +0 -2
- package/dist/config-mutator-ML4BAOFT.js +0 -2
- package/dist/context-planner-AQHJMVY2.js +0 -17
- package/dist/context-planner-AQHJMVY2.js.map +0 -1
- package/dist/doctor-3HWGAPET.js +0 -2
- package/dist/memory-extract-YZI2QZVR.js +0 -2
- package/dist/processes-XWRGOLMT.js +0 -2
- package/dist/program-JLZOHWIU.js +0 -2
- package/dist/promote-YGNTKEXI.js +0 -2
- package/dist/proposals-MWMEXRDW.js +0 -2
- package/dist/query-V76JDSOC.js +0 -2
- package/dist/registry-DKN4HEI3.js +0 -2
- package/dist/schedule-tool-6J7AHAHH.js +0 -2
- package/dist/scheduler-ZHQBSSRH.js +0 -2
- package/dist/wiki-FPX2YBKS.js +0 -2
- /package/dist/{App-EXB4HP3B.js.map → App-KE4SURSS.js.map} +0 -0
- /package/dist/{ChatApp-XMNE3SPH.js.map → ChatApp-NNHIKXO2.js.map} +0 -0
- /package/dist/{agent-ORYXXL5K.js.map → agent-RY7Z3IYY.js.map} +0 -0
- /package/dist/{chunk-26OP3X5B.js.map → chunk-4NBWF4TL.js.map} +0 -0
- /package/dist/{chunk-P7MR53U7.js.map → chunk-4TITGMPX.js.map} +0 -0
- /package/dist/{chunk-XM7ZQW4F.js.map → chunk-5ALS7SVV.js.map} +0 -0
- /package/dist/{chunk-3ZHMIWSV.js.map → chunk-5XQCGPQJ.js.map} +0 -0
- /package/dist/{chunk-DVNIFP7S.js.map → chunk-6VKCUMCN.js.map} +0 -0
- /package/dist/{chunk-GCHUE3TN.js.map → chunk-7WDJW37G.js.map} +0 -0
- /package/dist/{chunk-M5R3PWW5.js.map → chunk-B5XHX44Y.js.map} +0 -0
- /package/dist/{chunk-MLLEOFX2.js.map → chunk-IXUEJBHD.js.map} +0 -0
- /package/dist/{chunk-LDILAHMN.js.map → chunk-JVNFRS26.js.map} +0 -0
- /package/dist/{chunk-HEQPHUTR.js.map → chunk-NLZD2QKF.js.map} +0 -0
- /package/dist/{chunk-P5JXQRBH.js.map → chunk-OTW5MPFT.js.map} +0 -0
- /package/dist/{chunk-WMI5B36E.js.map → chunk-OUZ7YVQZ.js.map} +0 -0
- /package/dist/{chunk-2WPTP5HO.js.map → chunk-PZCTCCC5.js.map} +0 -0
- /package/dist/{chunk-3WLO2UKI.js.map → chunk-QDE75R4U.js.map} +0 -0
- /package/dist/{chunk-2GSEEKQK.js.map → chunk-TUNQFPVA.js.map} +0 -0
- /package/dist/{chunk-SL657MIM.js.map → chunk-WQLBJ2O5.js.map} +0 -0
- /package/dist/{chunk-SFLF64Q3.js.map → chunk-Z3IP66SL.js.map} +0 -0
- /package/dist/{client-6HCY7UMW.js.map → client-JZTH46N2.js.map} +0 -0
- /package/dist/{compaction-U5SAYTX6.js.map → compaction-PIZINFHR.js.map} +0 -0
- /package/dist/{config-ROQ4VEU3.js.map → config-R47ITLIY.js.map} +0 -0
- /package/dist/{config-mutator-ML4BAOFT.js.map → config-mutator-T6JGXJ26.js.map} +0 -0
- /package/dist/{doctor-3HWGAPET.js.map → doctor-2DMGAWMW.js.map} +0 -0
- /package/dist/{memory-extract-YZI2QZVR.js.map → memory-extract-OWTI6MN5.js.map} +0 -0
- /package/dist/{processes-XWRGOLMT.js.map → processes-KUJJ7XE7.js.map} +0 -0
- /package/dist/{program-JLZOHWIU.js.map → program-KY5ZYPFN.js.map} +0 -0
- /package/dist/{promote-YGNTKEXI.js.map → promote-57YNOVXV.js.map} +0 -0
- /package/dist/{proposals-MWMEXRDW.js.map → proposals-TX2HBBYV.js.map} +0 -0
- /package/dist/{query-V76JDSOC.js.map → query-ZT7WXY2F.js.map} +0 -0
- /package/dist/{registry-DKN4HEI3.js.map → registry-LLAFJJN4.js.map} +0 -0
- /package/dist/{request-planner-FAFNFVFX.js.map → request-planner-PEAYYXAP.js.map} +0 -0
- /package/dist/{review-candidates-2XKJ2R6U.js.map → review-candidates-W7NIHNAI.js.map} +0 -0
- /package/dist/{routing-PUPVGJ77.js.map → routing-7LCO7UJ7.js.map} +0 -0
- /package/dist/{schedule-tool-6J7AHAHH.js.map → schedule-tool-ZD3VBUBW.js.map} +0 -0
- /package/dist/{scheduler-ZHQBSSRH.js.map → scheduler-GC3FQKXY.js.map} +0 -0
- /package/dist/{seat-2MW3DEXX.js.map → seat-HR6QMAR2.js.map} +0 -0
- /package/dist/{select-Q3AGLQQX.js.map → select-4XYRIZ5L.js.map} +0 -0
- /package/dist/{surface-usage-FM2ZHGYE.js.map → surface-usage-V2BX4SBD.js.map} +0 -0
- /package/dist/{tool-IVUNSAXY.js.map → tool-PAQ47HV2.js.map} +0 -0
- /package/dist/{wiki-FPX2YBKS.js.map → wiki-EREMPSAE.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as et,b as tt,c as nt,d as S,e as A,f as N}from"./chunk-F4HZTZHW.js";import{a as Te,b as ft}from"./chunk-AJONZWLT.js";import{a as ne,b as He}from"./chunk-ZTEU5JVQ.js";import{o as we,p as Ke}from"./chunk-LCIREYTD.js";import{o as We,p as Ze}from"./chunk-
|
|
1
|
+
import{a as et,b as tt,c as nt,d as S,e as A,f as N}from"./chunk-F4HZTZHW.js";import{a as Te,b as ft}from"./chunk-AJONZWLT.js";import{a as ne,b as He}from"./chunk-ZTEU5JVQ.js";import{o as we,p as Ke}from"./chunk-LCIREYTD.js";import{o as We,p as Ze}from"./chunk-P2ZYT5D6.js";import{a as rt,b as ot,c as st,d as it,e as at,f as ct,g as ut,h as lt,i as dt,j as pt,k as mt,l as bt}from"./chunk-BH3GTCZ6.js";import{b as E,c as Ye,d as he}from"./chunk-FIOB3MEX.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 gt(){$.clear(),X.clear()}var $,X,C=E(()=>{"use strict";$=new Map,X=new Map});import yt from"better-sqlite3";import{createHash as ht}from"crypto";import{mkdirSync as wt}from"fs";import{dirname as Tt,resolve as Et}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 kt(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 xt(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&&Rt(e),t<2&&At(e),t<3&&St(e)}function St(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 At(e){e.exec(`
|
|
@@ -111,4 +111,4 @@ import{a as et,b as tt,c as nt,d as S,e as A,f as N}from"./chunk-F4HZTZHW.js";im
|
|
|
111
111
|
`)}if(!m)throw new Error(`local decision backend could not get a valid answer after ${f+1} attempt(s): ${h}`);let M={},L=!1;for(let[k,q]of Object.entries(s.questions)){let x=_(q,m[k],{normalize:e.normalizeProbabilities??!0});M[k]=x.answer,x.repaired&&(L=!0)}return{model:a,answers:M,usage:g,meta:{backend:"local",structureMode:c,answerMode:"probabilities",repaired:L,retries:f,stateTruncated:l.truncated,latencyMs:Date.now()-i}}}finally{b()}}}}async function $t(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:B,description:"Report a probability distribution for every question.",input_schema:se(t)}],{...o,toolChoice:{type:"tool",name:B}}),a=i.content.find(c=>c.type==="tool_use"&&c.name===B),u=a&&a.type==="tool_use"?a.input:null;return{answers:Pe(u),usage:{inputTokens:i.usage.input_tokens,outputTokens:i.usage.output_tokens}}}async function Vt(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:Pe(Te(a.content??"")),usage:{inputTokens:0,outputTokens:a.tokensUsed??0}}}function Pe(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 zt(e,t){return e!=="auto"?e:t.generateRaw&&me[t.name]?.structuredOutput?"tool":"text"}function Jt(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 Bt,Pt,qt,Be,Xt,be=E(()=>{"use strict";Ke();Ue();ft();j();Y();N();z();Bt="claude-code",Pt="claude-haiku-4-5-20251001",qt=24e3,Be=2e3,Xt=3e4});import{readFileSync as Gt}from"fs";import{homedir as Yt}from"os";import{join as Kt}from"path";function v(e={}){let t=(e.baseUrl??Ht).replace(/\/+$/,""),r=e.path??"/classifier",n=e.name??"simple-jev",o=e.maxStateChars??Zt,s=e.maxChoiceOptions??en,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),on(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:y,dispose:d}=sn(a.abortSignal,a.timeoutMs??e.timeoutMs??Wt);try{let b={"Content-Type":"application/json"},g=rn(e.apiKeyEnv,e.apiKeyFile);g&&(b.Authorization=`Bearer ${g}`);let w=await p(`${t}${r}`,{method:"POST",headers:b,body:JSON.stringify({model:c,state:l.text,questions:nn(a.questions)}),signal:y});if(!w.ok){let k=await w.text().catch(()=>"");throw new Error(`${n} ${w.status}: ${k.slice(0,300)}`)}let f=await w.json(),m=F(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 h=m.data,M={},L=!1;for(let[k,q]of Object.entries(a.questions)){let x=_(q,h[k]);M[k]=x.answer,x.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 nn(e){let t={};for(let[r,n]of Object.entries(e))t[r]=n.instructions?n:{...n,instructions:tn[n.type]};return t}function rn(e,t){let r=e?process.env[e]:void 0;if(r)return r;if(!t)return;let n=t.startsWith("~/")?Kt(Yt(),t.slice(2)):t;if(!Z.has(n))try{let o=Gt(n,"utf-8").trim();Z.set(n,o.length>0?o:null)}catch{Z.set(n,null)}return Z.get(n)??void 0}function on(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 sn(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 Ht,Wt,Zt,en,tn,Z,fe=E(()=>{"use strict";j();N();z();Y();Ht="http://127.0.0.1:8000/v1",Wt=3e4,Zt=6e3,en=50;tn={choice:"Which option best fits?",score:"Which level best fits?",noul:"Is this true of the state?"};Z=new Map});var qe={};Ye(qe,{DecisionStore:()=>I,MAX_CHOICE_OPTIONS:()=>MAX_CHOICE_OPTIONS,SYSTEM_PROMPT:()=>J,TOOL_NAME:()=>B,UNCERTAINTY_HIGH:()=>Ce,UNCERTAINTY_LOW:()=>De,_resetDecisionBackendsForTesting:()=>gt,agreement:()=>rt,answerView:()=>Q,applyRecalibrator:()=>ue,applyTemperature:()=>lt,askSeat:()=>pn,band:()=>Ie,bootstrapInterval:()=>pt,brier:()=>at,buildDesign:()=>Ne,calibrationReport:()=>mt,choice:()=>tt,compareCalibrators:()=>Lt,confidenceFor:()=>re,configureDecisions:()=>cn,coverageCurve:()=>ut,createLocalDecisionBackend:()=>W,createMockDecisionBackend:()=>H,createSimpleJevBackend:()=>v,decisionsRuntime:()=>ln,describeIssues:()=>U,ece:()=>st,expectedScore:()=>Ae,finalizeAnswer:()=>_,fitLogistic:()=>ve,fitRecalibrator:()=>P,fitTemperature:()=>dt,getDecisionBackend:()=>D,getSeatMode:()=>Ve,labelsOf:()=>S,listDecisionBackends:()=>Ee,logLoss:()=>ct,logit:()=>le,mce:()=>it,measureConsistency:()=>Qt,normalizeDistribution:()=>xe,normalizedNegEntropy:()=>oe,noul:()=>et,pMax:()=>Se,parseSeatMode:()=>ge,rawAnswerSchema:()=>Re,rawAnswersSchema:()=>F,recordSeatOutcome:()=>dn,registerBuiltinDecisionBackends:()=>an,registerDecisionBackend:()=>R,reliabilityBins:()=>ot,renderQuestions:()=>_e,renderShapeInstructions:()=>ae,renderState:()=>G,renderUserPrompt:()=>ie,resetDecisionsRuntime:()=>un,score:()=>nt,seatEnvVar:()=>$e,sigmoid:()=>de,toolInputSchema:()=>se,validateQuestions:()=>A,withUid:()=>Qe});function an(e={},t={},r={},n={}){R("mock",()=>H()),R("local",()=>W(e)),R("simple-jev",()=>v(t)),R("jev",()=>v({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",()=>v({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 Xe=E(()=>{"use strict";ke();N();j();z();C();Y();V();bt();Me();je();ze();pe();be();fe();C();pe();be();fe()});function cn(e){T={...ye,...T,...e},ee=!0}function un(){T={...ye,seats:{}},ee=!1}function mn(){if(!ee){ee=!0;try{let{loadDaemonConfig:e}=(Ze(),he(We)),t=e()?.decisions;if(!t?.enabled)return;let{registerBuiltinDecisionBackends:r}=(Xe(),he(qe)),n=t.backends??{};r(n.local,n.simpleJev,n.jev,n.typesafe);let o=null;try{o=new I({path:t.dbPath})}catch{}T={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 ln(){return T}function ge(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return bn.includes(t)?t:null}function $e(e){return`AGENTX_DECISION_SEAT_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}function Ve(e,t=process.env){mn();let r=ge(t[$e(e)]);return r||(T.enabled?ge(T.seats[e]?.mode)??"off":"off")}function dn(e,t,r=!1){if(!(!e||!T.store))try{T.store.recordOutcome(e,t,r)}catch{}}async function pn(e,t,r,n={}){let o=Ve(e);if(o==="off")return null;let s=T.seats[e]??{mode:o},i=n.backend??s.backend??T.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}),l=fn(e,o,t,r,c,n,s);return{answers:c.answers,callId:l,mode:o}}catch(u){return gn(e,o,t,r,i,n,s,a,u),yn(e,i,u),null}}function fn(e,t,r,n,o,s,i){if(!T.store)return null;try{return T.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:Ge(s.incumbent),links:s.links,features:s.features,keepState:!i.redactState})}catch{return null}}function gn(e,t,r,n,o,s,i,a,u){if(T.store)try{T.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:Ge(s.incumbent),links:s.links,features:s.features,error:String(u?.message??u).slice(0,500),keepState:!i.redactState})}catch{}}function Ge(e){if(!e)return;let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r]={value:n});return t}function yn(e,t,r){let n=Date.now();n-Je<6e4||(Je=n,console.warn(`[decisions] seat "${e}" on backend "${t}" failed: ${r?.message??r}`))}var ye,T,ee,bn,Je,ze=E(()=>{C();V();ye={enabled:!1,defaultBackend:"local",seats:{},store:null},T={...ye},ee=!1;bn=["off","shadow","active"];Je=0});export{D as a,Ee as b,C as c,I as d,V as e,Lt as f,Me as g,Qt as h,je as i,me as j,Un as k,Ue as l,an as m,Xe as n,cn as o,un as p,ln as q,ge as r,$e as s,Ve as t,dn as u,pn as v,ze as w};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-4NBWF4TL.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as q,b as O,c as R,d as B,f as b,g as S,h as E,i as w,j as y}from"./chunk-
|
|
1
|
+
import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as q,b as O,c as R,d as B,f as b,g as S,h as E,i as w,j as y}from"./chunk-5XQCGPQJ.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-NLZD2QKF.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function A(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",u=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",p=[`- ${n} [${h}] ${e.schedule} \u2014 ${S(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${u}`];return e.notify&&p.push(` notify: ${e.notify.channel} ${e.notify.chatId}`),e.command?p.push(` command: ${A(String(e.command))}`):e.prompt&&p.push(` prompt: ${A(String(e.prompt))}`),p.join(`
|
|
2
2
|
`)}async function k(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(u){return`Could not notify the operator (${u?.message??u}); the request is still recorded.`}}async function re(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),u=t.now?t.now():new Date,h;try{h=V(t.configPath)}catch(a){return`Error: ${a.message}`}let p=h.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(p).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,f])=>Q(i,f,u)).join(`
|
|
3
3
|
`):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!h.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),m=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=D(a);if(!i)return`Error: couldn't parse "${a}". ${O}.`;let f=s(n.agent)||e.agentId;if(!h.agents?.[f])return`Error: agent "${f}" not found on this node.`;let g=s(n.timezone)||q;if(!B(g))return`Error: unknown timezone "${g}".`;let d=o||_(i.matched,f);if(!R(d))return`Error: invalid id "${d}" (letters, digits, "-" and "_" only).`;if(p[d])return`Error: a schedule "${d}" already exists. Pick another \`id\`.`;let $=K(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let z={action:"create",requestedBy:e.agentId,requestedAt:u.toISOString()},L=b({parsed:i,agent:f,prompt:l,timezone:g,notify:$,enabled:!1,createdBy:e.agentId,approval:z}),v=await m(U=>I(U,`crons.${d}`,L));if(!v.success)return`Error: ${v.error}`;let N=w(E(i.cron,g,u),g),G=[`Schedule approval requested by ${e.agentId}`,`Create: ${d}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${N}`,`Agent: ${f}`,$?`Notify: ${$.channel} ${$.chatId}`:"Notify: none",`Prompt: ${A(l,400)}`,"",`Approve: agentx schedule approve ${d}`,`Reject: agentx schedule reject ${d}`].join(`
|
|
4
4
|
`),H=await k(h,t,G);return[`Requested schedule "${d}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${N}.`,"It is saved DISABLED and will not run until the operator approves it.",H].join(`
|
|
5
5
|
`)}if(!o)return`Error: ${r} needs \`id\`.`;let c=p[o];if(!c)return`Error: schedule "${o}" not found.`;if(!Y(h,c,e))return Z(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&y(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await m(i=>I(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(y(c)&&c.approval.requestedBy===e.agentId){let d=await m($=>P($,`crons.${o}`));return d.success?`Withdrew the pending request "${o}".`:`Error: ${d.error}`}if(y(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:u.toISOString()},l=await m(d=>{if(!x(d,`crons.${o}`))throw new Error(`schedule "${o}" not found`);I(d,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",f=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${S(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?w(E(c.schedule,i,u),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
|
|
6
6
|
`),g=await k(h,t,f);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
|
|
7
7
|
`)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function oe(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),u=s(r?e.AGENTX_CHANNEL:n.channel),h=s(r?e.AGENTX_CHAT_ID:n.chatId),p=s(n.accountId);return{agentId:t,channel:u,chatId:h,...p?{accountId:p}:{}}}export{re as a,oe as b};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-4TITGMPX.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v as l,w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{v as l,w}from"./chunk-4NBWF4TL.js";import{a as i,f as p}from"./chunk-F4HZTZHW.js";w();p();var d="task-tier";function u(e){return{task:f(e.message,2e3),agent:e.agent,channel:e.channel??null,continuesExistingSession:e.isFollowUp??!1,...e.toolsAvailable?{toolsAvailable:e.toolsAvailable}:{}}}var c={needsFlagship:i("This task needs the strongest available model to be done correctly.",{true:"Doing it well takes real reasoning: writing or reviewing code, diagnosing a failure, planning work across several steps, weighing a judgement, handling money, touching production or anything irreversible, following a long or ambiguous instruction, or work where being subtly wrong would not be noticed. Anything where a weaker model would produce something that LOOKS right belongs here.",false:"It is mechanical and its result is obvious on sight: acknowledging or confirming a message, restating or formatting something already written, a greeting, a status echo, reading one file and reporting what it says, a lookup with one right answer, a scheduled heartbeat with nothing to decide."})};function g(e){return e.needsFlagship.noul}function f(e,n){return e.length>n?`${e.slice(0,n)}\u2026`:e}var h=.2,m=60*60*1e3;function F(e,n){if(e==="claude-code"){let t=n?.cheapModels?.[e]??n?.cheapModel;return t&&/^(claude-|haiku$|sonnet$|opus$)/.test(t)?t:void 0}if(e==="codex-cli"){let t=n?.cheapModels?.[e];return t&&/^(gpt-|o\d)/.test(t)?t:void 0}}async function M(e){let n=(o,r=null)=>({downgraded:!1,needsFlagship:r,reason:o});if(e.channel==="voice"||e.channel==="desktop"||e.channel==="opencode")return n(`${e.channel} requests retain the configured model`);if(!e.cheapModel)return n("no cheaper model configured");if(e.isFollowUp){let o=e.sessionIdleMs??0,r=e.cacheTtlMs??m;if(o<r)return n(`follow-up on a warm cache (idle ${Math.round(o/1e3)}s) \u2014 swapping would cost more than it saves`)}let t;try{t=await l(d,u(e),c,{incumbent:{needsFlagship:1},features:{agent:e.agent,channel:e.channel??"unknown"}})}catch{return n("routing seat threw \u2014 keeping the flagship")}if(!t)return n("routing seat unavailable \u2014 keeping the flagship");let s=g(t.answers);if(t.mode!=="active")return n(`shadow \u2014 would ${s<(e.threshold??h)?"downgrade":"keep"} (${s.toFixed(2)})`,s);let a=e.threshold??h;return s>=a?n(`needs the flagship (${s.toFixed(2)})`,s):{model:e.cheapModel,downgraded:!0,needsFlagship:s,reason:`mechanical task (${s.toFixed(2)} below ${a}) \u2192 ${e.cheapModel}`}}export{F as a,M as b};
|
|
2
|
+
//# sourceMappingURL=chunk-5ALS7SVV.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{k as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{k as p}from"./chunk-B5XHX44Y.js";import{b as i,c as u,d as l,e as c}from"./chunk-NLZD2QKF.js";import d from"cronstrue";var f=Intl.DateTimeFormat().resolvedOptions().timeZone,m=600,E='Try: "every morning at 9", "weekdays at 6pm", "every 15 minutes", "every monday at 10am", "1st of every month at noon", "daily at 9:30am", "every hour"',g=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;function w(e){return g.test(e)}function x(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}function $(e){return e?e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r==="log"||r==="notify"||r==="disable"):["log"]}function S(e){let r=[...e.onError??["log"]];e.notify&&!r.includes("notify")&&r.push("notify");let t={enabled:e.enabled??!0,schedule:e.parsed.cron,timezone:e.timezone||f,agent:e.agent,prompt:e.prompt,timeout:e.timeout??m,onError:r};return e.model&&(t.model=e.model),e.notify&&(t.notify=e.notify),e.createdBy&&(t.createdBy=e.createdBy),e.approval&&(t.approval=e.approval),t}function P(e){try{return d.toString(e,{use24HourTimeFormat:!1})}catch{return e}}function T(e,r,t=new Date){try{return p(e,t,r)}catch{return null}}function A(e,r){if(!e)return"unknown (no match within a year)";try{return`${new Intl.DateTimeFormat("en-GB",{timeZone:r,weekday:"short",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)} (${r})`}catch{return e.toISOString()}}function h(e){return e?.approval?.action==="create"}async function D(e,r={}){let t="",o=await i(n=>{let a=l(n,`crons.${e}`);if(!a)throw new Error(`cron "${e}" not found`);let s=a.approval;if(!s)throw new Error(`cron "${e}" has no pending request`);s.action==="create"?(delete a.approval,a.enabled=!0,t=`${e} approved and enabled (requested by ${s.requestedBy})`):(c(n,`crons.${e}`),t=`${e} deletion approved; job removed (requested by ${s.requestedBy})`)},{configPath:r.configPath,reload:r.reload});return o.success?{success:!0,message:t,result:o}:{success:!1,message:o.error||"failed",result:o}}async function I(e,r={}){let t="",o=await i(n=>{let a=l(n,`crons.${e}`);if(!a)throw new Error(`cron "${e}" not found`);let s=a.approval;if(!s)throw new Error(`cron "${e}" has no pending request`);s.action==="create"?(c(n,`crons.${e}`),t=`${e} rejected; pending job removed`):(delete a.approval,t=`${e} deletion rejected; job kept`)},{configPath:r.configPath,reload:r.reload});return o.success?{success:!0,message:t,result:o}:{success:!1,message:o.error||"failed",result:o}}async function O(e,r,t={}){return i(o=>{let n=l(o,`crons.${e}`);if(!n)throw new Error(`cron "${e}" not found`);if(r&&h(n))throw new Error(`cron "${e}" is awaiting approval; run \`agentx schedule approve ${e}\``);u(o,`crons.${e}.enabled`,r)},{configPath:t.configPath,reload:t.reload})}export{f as a,E as b,w as c,x as d,$ as e,S as f,P as g,T as h,A as i,h as j,D as k,I as l,O as m};
|
|
2
|
+
//# sourceMappingURL=chunk-5XQCGPQJ.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as u,b as f}from"./chunk-
|
|
1
|
+
import{a as u,b as f}from"./chunk-HRBKSZ34.js";var d=new Set(["cron","a2a","workflow","selftest"]),g=[[/^User:\s*You are\s/i,"role brief"],[/^User:\s*(Run|Execute)\s/i,"run instruction"],[/^User:\s*\[MISSED RUN/i,"missed cron run"],[/^User:\s*(\[[^\]]{0,40}\]:?\s*)?\[Recent group conversation\]/i,"group chat dump"]];function l(e){if(e.responseLength<=50)return{capture:!1,reason:"response too short"};let r=(e.channel??"").toLowerCase().split("@")[0];if(d.has(r))return{capture:!1,reason:`machine channel: ${r}`};let n=e.content.slice(0,400);for(let[o,c]of g)if(o.test(n))return{capture:!1,reason:c};return{capture:!0}}var y="claude-haiku-4-20250514",w=`You are a memory extraction system for an AI agent. Given a conversation exchange, extract facts worth remembering for future conversations across different chat sessions.
|
|
2
2
|
|
|
3
3
|
Extract ONLY facts that would help the agent in FUTURE, DIFFERENT conversations:
|
|
4
4
|
- User preferences and instructions ("never do X", "always use Y")
|
|
@@ -20,4 +20,4 @@ For each fact, output a JSON array:
|
|
|
20
20
|
If nothing worth remembering, output: []`;async function I(e,s,r,n,o){if(s.length<20&&r.length<50||!l({channel:n.channel,content:`User: ${s}`,responseLength:r.length}).capture)return;let{createProvider:h}=await import("./providers-KO2DODIO.js"),i=(await h("claude").generate([{role:"system",content:w},{role:"user",content:`${n.sender} (via ${n.channel}): ${s}
|
|
21
21
|
|
|
22
22
|
Agent: ${r}`}],{model:y,maxTokens:512})).content.trim().match(/\[[\s\S]*\]/);if(!i)return;let a=JSON.parse(i[0]);if(!Array.isArray(a)||a.length===0)return;let m=new Date().toISOString().slice(0,10),p=u(n.channel);for(let t of a)typeof t?.content=="string"&&(t.category==="secret"||f(t.content)||o.hasSimilar(e,t.content)||o.addMemory(e,{agentId:e,category:t.category,content:t.content,keywords:t.keywords||[],source:{...n,date:m,trust:p},expiresAt:t.category==="task-state"?new Date(Date.now()+7*24*60*60*1e3).toISOString():void 0}));Math.random()<.02&&o.prune(e)}export{l as a,I as b};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-6VKCUMCN.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e}from"./chunk-
|
|
1
|
+
import{c as e}from"./chunk-4BNQSUWV.js";function i(t={}){let r=`<div class="ax-proc__kpis" id="proc-kpis" hidden></div>
|
|
2
2
|
<div class="ax-proc__root">
|
|
3
3
|
<aside class="ax-proc__list">
|
|
4
4
|
<header>
|
|
@@ -253,4 +253,4 @@ import{c as e}from"./chunk-DLKRPK5M.js";function i(t={}){let r=`<div class="ax-p
|
|
|
253
253
|
setInterval(refresh, 5000);
|
|
254
254
|
})();
|
|
255
255
|
`;export{i as a};
|
|
256
|
-
//# sourceMappingURL=chunk-
|
|
256
|
+
//# sourceMappingURL=chunk-7WDJW37G.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{existsSync as c,mkdirSync as l,readdirSync as g,readFileSync as d,renameSync as u,writeFileSync as m}from"fs";import{resolve as i}from"path";function
|
|
2
|
-
`),u(e,o)}function P(r,t){try{return JSON.parse(d(a(r,t),"utf-8"))}catch{return null}}function v(r,t){let o=
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{existsSync as c,mkdirSync as l,readdirSync as g,readFileSync as d,renameSync as u,writeFileSync as m}from"fs";import{resolve as i}from"path";function n(r){return i(r,"_proposals")}function a(r,t){if(!/^[a-z0-9-]+$/.test(t))throw new Error(`invalid proposal id: ${t}`);return i(n(r),`${t}.json`)}function y(r,t){let o=new Date(r).toISOString().slice(0,10),e=t.replace(/\.md$/,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48);return`${o}-${e||"article"}-${Math.random().toString(36).slice(2,6)}`}function x(r,t){l(n(r),{recursive:!0});let o=a(r,t.id),e=`${o}.${process.pid}.tmp`;m(e,JSON.stringify(t,null,2)+`
|
|
2
|
+
`),u(e,o)}function P(r,t){try{return JSON.parse(d(a(r,t),"utf-8"))}catch{return null}}function v(r,t){let o=n(r);if(!c(o))return[];let e=[];for(let p of g(o).filter(s=>s.endsWith(".json")).sort()){let s=P(r,p.slice(0,-5));s&&(!t||s.status===t)&&e.push(s)}return e}export{n as a,y as b,x as c,P as d,v as e};
|
|
3
|
+
//# sourceMappingURL=chunk-AQASR6KR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/wiki/proposals.ts"],"sourcesContent":["import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from \"fs\"\nimport { resolve } from \"path\"\n\n// --- Promotion proposals: lessons wait for a human before the wiki ---\n//\n// `wiki promote` used to write public, org-wide articles straight into the\n// shared wiki from a nightly job. A wrong lesson, or one planted through a\n// poisoned memory, reached every agent the next morning. Now the judge's\n// output becomes a proposal here, with the evidence that produced it, and\n// only an operator's approval writes the article (promote.ts).\n//\n// Storage only: one JSON file per proposal under `<wiki>/_proposals/`.\n// The wiki index skips `_`-prefixed folders, so pending proposals are\n// invisible to agents.\n\nexport type ProposalStatus = \"pending\" | \"approved\" | \"rejected\"\n\n/** The article the judge wants to write. Same shape as PromotedArticle. */\nexport interface ProposedArticle {\n path: string\n title: string\n type?: string\n related?: string[]\n tags: string[]\n content: string\n promotedFrom: string[]\n}\n\n/** One memory, review finding or recurring failure behind the proposal. */\nexport interface ProposalSource {\n stamp: string\n kind: \"memory\" | \"review\" | \"failure\"\n agentId: string\n type: string\n name: string\n description: string\n /** Distinct sessions a review finding or failure appeared in. */\n occurrences?: number\n /** Some of those sessions, for a reviewer to open. */\n sessions?: string[]\n /** Some of the failed runs (task ids), for `agentx trace show`. */\n tasks?: string[]\n /** A recurring failure's signature: the failing tool, the error class\n * and how many runs hit it. The agent is `agentId`. */\n failure?: { tool: string; errorClass: string; runs: number }\n /** Who wrote the memory, and in which task (agent-memory provenance). */\n author?: string\n taskId?: string\n updatedAt: string\n /** Start of the memory body. */\n excerpt: string\n}\n\nexport interface ProposalEvidence {\n /** Agents whose memories, reviews or failures back it. */\n agents: string[]\n /** Highest recurrence among its sources (1 for plain memories). */\n occurrences: number\n sources: ProposalSource[]\n}\n\nexport interface PromotionProposal {\n id: string\n createdAt: string\n status: ProposalStatus\n article: ProposedArticle\n evidence: ProposalEvidence\n /** Set when the article already existed: approval refuses if it has\n * changed since, so a proposal can't silently revert someone's edit. */\n replaces?: { lastUpdated: string; contentHash: string }\n decidedBy?: string\n decidedAt?: string\n reason?: string\n}\n\nexport function proposalsDir(wikiDir: string): string {\n return resolve(wikiDir, \"_proposals\")\n}\n\nfunction fileFor(wikiDir: string, id: string): string {\n if (!/^[a-z0-9-]+$/.test(id)) throw new Error(`invalid proposal id: ${id}`)\n return resolve(proposalsDir(wikiDir), `${id}.json`)\n}\n\nexport function newProposalId(now: number, path: string): string {\n const day = new Date(now).toISOString().slice(0, 10)\n const slug = path.replace(/\\.md$/, \"\").toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\").slice(0, 48)\n return `${day}-${slug || \"article\"}-${Math.random().toString(36).slice(2, 6)}`\n}\n\nexport function saveProposal(wikiDir: string, p: PromotionProposal): void {\n mkdirSync(proposalsDir(wikiDir), { recursive: true })\n const path = fileFor(wikiDir, p.id)\n const tmp = `${path}.${process.pid}.tmp`\n writeFileSync(tmp, JSON.stringify(p, null, 2) + \"\\n\")\n renameSync(tmp, path)\n}\n\nexport function readProposal(wikiDir: string, id: string): PromotionProposal | null {\n try {\n return JSON.parse(readFileSync(fileFor(wikiDir, id), \"utf-8\")) as PromotionProposal\n } catch {\n return null\n }\n}\n\n/** Proposals, oldest first; only `status` ones when given. */\nexport function listProposals(wikiDir: string, status?: ProposalStatus): PromotionProposal[] {\n const dir = proposalsDir(wikiDir)\n if (!existsSync(dir)) return []\n const out: PromotionProposal[] = []\n for (const f of readdirSync(dir).filter((f) => f.endsWith(\".json\")).sort()) {\n const p = readProposal(wikiDir, f.slice(0, -5))\n if (p && (!status || p.status === status)) out.push(p)\n }\n return out\n}\n"],"mappings":"AAAA,OAAS,cAAAA,EAAY,aAAAC,EAAW,eAAAC,EAAa,gBAAAC,EAAc,cAAAC,EAAY,iBAAAC,MAAqB,KAC5F,OAAS,WAAAC,MAAe,OA0EjB,SAASC,EAAaC,EAAyB,CACpD,OAAOF,EAAQE,EAAS,YAAY,CACtC,CAEA,SAASC,EAAQD,EAAiBE,EAAoB,CACpD,GAAI,CAAC,eAAe,KAAKA,CAAE,EAAG,MAAM,IAAI,MAAM,wBAAwBA,GAAI,EAC1E,OAAOJ,EAAQC,EAAaC,CAAO,EAAG,GAAGE,QAAS,CACpD,CAEO,SAASC,EAAcC,EAAaC,EAAsB,CAC/D,IAAMC,EAAM,IAAI,KAAKF,CAAG,EAAE,YAAY,EAAE,MAAM,EAAG,EAAE,EAC7CG,EAAOF,EAAK,QAAQ,QAAS,EAAE,EAAE,YAAY,EAAE,QAAQ,cAAe,GAAG,EAAE,QAAQ,WAAY,EAAE,EAAE,MAAM,EAAG,EAAE,EACpH,MAAO,GAAGC,KAAOC,GAAQ,aAAa,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,GAC7E,CAEO,SAASC,EAAaR,EAAiBS,EAA4B,CACxEhB,EAAUM,EAAaC,CAAO,EAAG,CAAE,UAAW,EAAK,CAAC,EACpD,IAAMK,EAAOJ,EAAQD,EAASS,EAAE,EAAE,EAC5BC,EAAM,GAAGL,KAAQ,QAAQ,UAC/BR,EAAca,EAAK,KAAK,UAAUD,EAAG,KAAM,CAAC,EAAI;AAAA,CAAI,EACpDb,EAAWc,EAAKL,CAAI,CACtB,CAEO,SAASM,EAAaX,EAAiBE,EAAsC,CAClF,GAAI,CACF,OAAO,KAAK,MAAMP,EAAaM,EAAQD,EAASE,CAAE,EAAG,OAAO,CAAC,CAC/D,MAAE,CACA,OAAO,IACT,CACF,CAGO,SAASU,EAAcZ,EAAiBa,EAA8C,CAC3F,IAAMC,EAAMf,EAAaC,CAAO,EAChC,GAAI,CAACR,EAAWsB,CAAG,EAAG,MAAO,CAAC,EAC9B,IAAMC,EAA2B,CAAC,EAClC,QAAWC,KAAKtB,EAAYoB,CAAG,EAAE,OAAQE,GAAMA,EAAE,SAAS,OAAO,CAAC,EAAE,KAAK,EAAG,CAC1E,IAAMP,EAAIE,EAAaX,EAASgB,EAAE,MAAM,EAAG,EAAE,CAAC,EAC1CP,IAAM,CAACI,GAAUJ,EAAE,SAAWI,IAASE,EAAI,KAAKN,CAAC,EAEvD,OAAOM,CACT","names":["existsSync","mkdirSync","readdirSync","readFileSync","renameSync","writeFileSync","resolve","proposalsDir","wikiDir","fileFor","id","newProposalId","now","path","day","slug","saveProposal","p","tmp","readProposal","listProposals","status","dir","out","f"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as S,c as O}from"./chunk-
|
|
1
|
+
import{b as S,c as O}from"./chunk-NLZD2QKF.js";import{a as T,b as M}from"./chunk-ZTEU5JVQ.js";import{a as C,b as ne}from"./chunk-L2WSPY6S.js";import{e as k}from"./chunk-FIOB3MEX.js";import{execFile as ye}from"child_process";import{writeFileSync as z,mkdirSync as $,existsSync as b,readFileSync as Te}from"fs";import{resolve as _}from"path";var re=["off","shadow","authoritative"],ie={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},se="INTENT_LEDGER_MODE";function X(r,e=process.env){let t=F(e[ie[r]]);if(t)return t;let n=F(e[se]);return n||"off"}function F(r){if(typeof r!="string")return null;let e=r.trim().toLowerCase();return re.includes(e)?e:null}M();import oe from"better-sqlite3";import{existsSync as $e,mkdirSync as de}from"fs";import{dirname as ce,resolve as ae}from"path";var I=class{db;path;constructor(e={}){this.path=ae(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),de(ce(this.path),{recursive:!0}),this.db=new oe(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),ge(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let n=this.findEventBySourceId(e.source,e.sourceEventId);if(n)return n}let t={id:e.id??T(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
|
|
2
2
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(t.id,t.ts,t.source,t.sourceEventId,t.project,t.subject,t.intent,t.rawJson),t}findEventBySourceId(e,t){let n=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
|
|
3
3
|
FROM intent_events WHERE source = ? AND source_event_id = ?`).get(e,t);return n?P(n):null}getEventById(e){let t=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
|
|
4
4
|
FROM intent_events WHERE id = ?`).get(e);return t?P(t):null}recordDecision(e){this.db.prepare(`INSERT INTO intent_decisions (event_id, decided_at, decided_by, agent_id, outcome, reason)
|
|
@@ -120,4 +120,4 @@ ${i.prompt}`,i.maxOutputTokens),agentId:i.agent,autonomy:i.autonomy,timeoutMinut
|
|
|
120
120
|
`);return t.length<=e?t.join(`
|
|
121
121
|
`):t.slice(-e).join(`
|
|
122
122
|
`)}function Ne(r,e,t){return new Promise((n,i)=>{ye("/bin/sh",["-c",r],{timeout:e,maxBuffer:8*1024*1024,...t?{env:t}:{}},(s,d,o)=>{if(s&&s.killed){i(new Error(`command timed out after ${Math.round(e/1e3)}s`));return}n({stdout:String(d??""),stderr:String(o??""),code:s?typeof s.code=="number"?s.code:1:0})})})}export{I as a,U as b,X as c,Me as d,Y as e,H as f,Ve as g,Ie as h,Q as i,Z as j,ee as k,Re as l,x as m};
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-B5XHX44Y.js.map
|