agentix-cli 0.47.1 → 0.48.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/apps/mac-helper/Sources/AgentXHelper/Buffer.swift +65 -0
- package/apps/mac-helper/Sources/AgentXHelper/Notify.swift +26 -0
- package/apps/mac-helper/Sources/AgentXHelper/Ring.swift +58 -0
- package/apps/mac-helper/Sources/AgentXHelper/Screens.swift +7 -0
- package/apps/mac-helper/Sources/AgentXHelper/Vision.swift +13 -8
- package/apps/mac-helper/Sources/AgentXHelper/Watch.swift +87 -0
- package/apps/mac-helper/Sources/AgentXHelper/main.swift +72 -18
- package/dist/{App-RZDJH6MK.js → App-EXB4HP3B.js} +2 -2
- package/dist/{ChatApp-6TXOFUDH.js → ChatApp-XMNE3SPH.js} +2 -2
- package/dist/{agent-I6RXAEXG.js → agent-ORYXXL5K.js} +2 -2
- package/dist/{board-dashboard-4LAQOB74.js → board-dashboard-2B3HYIXD.js} +493 -131
- package/dist/board-dashboard-2B3HYIXD.js.map +1 -0
- package/dist/{chunk-BZLHS3VF.js → chunk-26OP3X5B.js} +2 -2
- package/dist/{chunk-VHTFHGVW.js → chunk-2GSEEKQK.js} +51 -51
- package/dist/chunk-2GSEEKQK.js.map +1 -0
- package/dist/{chunk-FNLGY4UV.js → chunk-2WPTP5HO.js} +2 -2
- package/dist/{chunk-MDTKQZC6.js → chunk-3WLO2UKI.js} +2 -2
- package/dist/chunk-3ZHMIWSV.js +2 -0
- package/dist/chunk-3ZHMIWSV.js.map +1 -0
- package/dist/{chunk-YIXQDOPN.js → chunk-4ZX4E7P3.js} +185 -179
- package/dist/chunk-4ZX4E7P3.js.map +1 -0
- package/dist/chunk-7DXE264B.js +2 -0
- package/dist/chunk-7DXE264B.js.map +1 -0
- package/dist/chunk-DIV66W3N.js +28 -0
- package/dist/chunk-DIV66W3N.js.map +1 -0
- package/dist/{chunk-7CVJ4JOE.js → chunk-DLKRPK5M.js} +2 -2
- package/dist/chunk-DVNIFP7S.js +23 -0
- package/dist/chunk-DVNIFP7S.js.map +1 -0
- package/dist/chunk-FULEQYM6.js +13 -0
- package/dist/chunk-FULEQYM6.js.map +1 -0
- package/dist/chunk-GAGVFSZM.js +15 -0
- package/dist/{chunk-ANLKBCYH.js.map → chunk-GAGVFSZM.js.map} +1 -1
- package/dist/{chunk-3RHPZXCR.js → chunk-GCHUE3TN.js} +2 -2
- package/dist/chunk-GIK7S3OY.js +19 -0
- package/dist/chunk-GIK7S3OY.js.map +1 -0
- package/dist/{chunk-J63MRNXF.js → chunk-HEQPHUTR.js} +2 -2
- package/dist/{chunk-KTM7HSEB.js → chunk-LDILAHMN.js} +2 -2
- package/dist/{chunk-V7FYSZSV.js → chunk-LQRBGQIR.js} +2 -2
- package/dist/chunk-LQRBGQIR.js.map +1 -0
- package/dist/{chunk-LYOXXD4T.js → chunk-M5R3PWW5.js} +2 -2
- package/dist/{chunk-BJWK7FPT.js → chunk-MLLEOFX2.js} +2 -2
- package/dist/{chunk-QURVHYBP.js → chunk-OZX7HVHC.js} +168 -165
- package/dist/chunk-OZX7HVHC.js.map +1 -0
- package/dist/chunk-P5JXQRBH.js +7 -0
- package/dist/chunk-P5JXQRBH.js.map +1 -0
- package/dist/{schedule-tool-6SNLG2NA.js → chunk-P7MR53U7.js} +3 -3
- package/dist/{schedule-tool-6SNLG2NA.js.map → chunk-P7MR53U7.js.map} +1 -1
- package/dist/chunk-RKPAVWXF.js +2 -0
- package/dist/chunk-RKPAVWXF.js.map +1 -0
- package/dist/{chunk-VZDKE2EZ.js → chunk-RYLTCOYE.js} +2 -2
- package/dist/{chunk-XMWOV2D5.js → chunk-SL657MIM.js} +2 -2
- package/dist/chunk-WMI5B36E.js +5 -0
- package/dist/{chunk-BHPIAG3E.js.map → chunk-WMI5B36E.js.map} +1 -1
- package/dist/{chunk-NXJBAKBR.js → chunk-XM7ZQW4F.js} +2 -2
- package/dist/{chunk-XMRI32CY.js → chunk-ZUZESPCH.js} +61 -71
- package/dist/chunk-ZUZESPCH.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client-6HCY7UMW.js +2 -0
- package/dist/{compaction-QXU3A4LQ.js → compaction-U5SAYTX6.js} +2 -2
- package/dist/config-ROQ4VEU3.js +2 -0
- package/dist/config-mutator-ML4BAOFT.js +2 -0
- package/dist/doctor-3HWGAPET.js +2 -0
- package/dist/index.d.ts +258 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/memory-extract-YZI2QZVR.js +2 -0
- package/dist/processes-XWRGOLMT.js +2 -0
- package/dist/program-JLZOHWIU.js +2 -0
- package/dist/{promote-RNSGW4AJ.js → promote-YGNTKEXI.js} +2 -2
- package/dist/query-V76JDSOC.js +2 -0
- package/dist/registry-DKN4HEI3.js +2 -0
- package/dist/{request-planner-5354IOYM.js → request-planner-FAFNFVFX.js} +2 -2
- package/dist/{review-candidates-UTWMO7UO.js → review-candidates-2XKJ2R6U.js} +2 -2
- package/dist/{routing-JGNWB6VJ.js → routing-PUPVGJ77.js} +2 -2
- package/dist/schedule-tool-6J7AHAHH.js +2 -0
- package/dist/scheduler-ZHQBSSRH.js +2 -0
- package/dist/{seat-STLDEYSO.js → seat-2MW3DEXX.js} +2 -2
- package/dist/{select-VP66P6XB.js → select-Q3AGLQQX.js} +2 -2
- package/dist/tool-IVUNSAXY.js +2 -0
- package/dist/tool-IVUNSAXY.js.map +1 -0
- package/dist/wiki-FPX2YBKS.js +2 -0
- package/dist/wiki-FPX2YBKS.js.map +1 -0
- package/package.json +1 -1
- package/dist/board-dashboard-4LAQOB74.js.map +0 -1
- package/dist/chunk-7L6M3P2N.js +0 -13
- package/dist/chunk-7L6M3P2N.js.map +0 -1
- package/dist/chunk-ANLKBCYH.js +0 -15
- package/dist/chunk-BHPIAG3E.js +0 -5
- package/dist/chunk-CQR6C5FU.js +0 -23
- package/dist/chunk-CQR6C5FU.js.map +0 -1
- package/dist/chunk-FQBPSL36.js +0 -25
- package/dist/chunk-FQBPSL36.js.map +0 -1
- package/dist/chunk-FXGSSZAP.js +0 -9
- package/dist/chunk-FXGSSZAP.js.map +0 -1
- package/dist/chunk-OSSI6R4K.js +0 -2
- package/dist/chunk-OSSI6R4K.js.map +0 -1
- package/dist/chunk-QURVHYBP.js.map +0 -1
- package/dist/chunk-V7FYSZSV.js.map +0 -1
- package/dist/chunk-VHTFHGVW.js.map +0 -1
- package/dist/chunk-W544ZCCO.js +0 -7
- package/dist/chunk-W544ZCCO.js.map +0 -1
- package/dist/chunk-XMRI32CY.js.map +0 -1
- package/dist/chunk-YIXQDOPN.js.map +0 -1
- package/dist/client-LAIP23IP.js +0 -2
- package/dist/config-OZ2OOKFA.js +0 -2
- package/dist/config-mutator-EUF7QQ4V.js +0 -2
- package/dist/doctor-PEE3F5TX.js +0 -2
- package/dist/memory-extract-3TO7UC5B.js +0 -2
- package/dist/processes-I3XAPHG7.js +0 -2
- package/dist/program-PMHQRD5E.js +0 -2
- package/dist/query-BOUVRUU4.js +0 -2
- package/dist/registry-GGU43EOI.js +0 -2
- package/dist/scheduler-N25EAWF6.js +0 -2
- package/dist/wiki-SKIIAVCU.js +0 -2
- /package/dist/{App-RZDJH6MK.js.map → App-EXB4HP3B.js.map} +0 -0
- /package/dist/{ChatApp-6TXOFUDH.js.map → ChatApp-XMNE3SPH.js.map} +0 -0
- /package/dist/{agent-I6RXAEXG.js.map → agent-ORYXXL5K.js.map} +0 -0
- /package/dist/{chunk-BZLHS3VF.js.map → chunk-26OP3X5B.js.map} +0 -0
- /package/dist/{chunk-FNLGY4UV.js.map → chunk-2WPTP5HO.js.map} +0 -0
- /package/dist/{chunk-MDTKQZC6.js.map → chunk-3WLO2UKI.js.map} +0 -0
- /package/dist/{chunk-7CVJ4JOE.js.map → chunk-DLKRPK5M.js.map} +0 -0
- /package/dist/{chunk-3RHPZXCR.js.map → chunk-GCHUE3TN.js.map} +0 -0
- /package/dist/{chunk-J63MRNXF.js.map → chunk-HEQPHUTR.js.map} +0 -0
- /package/dist/{chunk-KTM7HSEB.js.map → chunk-LDILAHMN.js.map} +0 -0
- /package/dist/{chunk-LYOXXD4T.js.map → chunk-M5R3PWW5.js.map} +0 -0
- /package/dist/{chunk-BJWK7FPT.js.map → chunk-MLLEOFX2.js.map} +0 -0
- /package/dist/{chunk-VZDKE2EZ.js.map → chunk-RYLTCOYE.js.map} +0 -0
- /package/dist/{chunk-XMWOV2D5.js.map → chunk-SL657MIM.js.map} +0 -0
- /package/dist/{chunk-NXJBAKBR.js.map → chunk-XM7ZQW4F.js.map} +0 -0
- /package/dist/{client-LAIP23IP.js.map → client-6HCY7UMW.js.map} +0 -0
- /package/dist/{compaction-QXU3A4LQ.js.map → compaction-U5SAYTX6.js.map} +0 -0
- /package/dist/{config-OZ2OOKFA.js.map → config-ROQ4VEU3.js.map} +0 -0
- /package/dist/{config-mutator-EUF7QQ4V.js.map → config-mutator-ML4BAOFT.js.map} +0 -0
- /package/dist/{doctor-PEE3F5TX.js.map → doctor-3HWGAPET.js.map} +0 -0
- /package/dist/{memory-extract-3TO7UC5B.js.map → memory-extract-YZI2QZVR.js.map} +0 -0
- /package/dist/{processes-I3XAPHG7.js.map → processes-XWRGOLMT.js.map} +0 -0
- /package/dist/{program-PMHQRD5E.js.map → program-JLZOHWIU.js.map} +0 -0
- /package/dist/{promote-RNSGW4AJ.js.map → promote-YGNTKEXI.js.map} +0 -0
- /package/dist/{query-BOUVRUU4.js.map → query-V76JDSOC.js.map} +0 -0
- /package/dist/{registry-GGU43EOI.js.map → registry-DKN4HEI3.js.map} +0 -0
- /package/dist/{request-planner-5354IOYM.js.map → request-planner-FAFNFVFX.js.map} +0 -0
- /package/dist/{review-candidates-UTWMO7UO.js.map → review-candidates-2XKJ2R6U.js.map} +0 -0
- /package/dist/{routing-JGNWB6VJ.js.map → routing-PUPVGJ77.js.map} +0 -0
- /package/dist/{scheduler-N25EAWF6.js.map → schedule-tool-6J7AHAHH.js.map} +0 -0
- /package/dist/{seat-STLDEYSO.js.map → scheduler-ZHQBSSRH.js.map} +0 -0
- /package/dist/{wiki-SKIIAVCU.js.map → seat-2MW3DEXX.js.map} +0 -0
- /package/dist/{select-VP66P6XB.js.map → select-Q3AGLQQX.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{
|
|
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-GAGVFSZM.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-26OP3X5B.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{b as
|
|
2
|
-
`,p=n+".tmp";
|
|
3
|
-
`,"utf-8"),{file:n}}async function
|
|
1
|
+
import{b as Q,c as Z,d as ee,e as F,f as I,g as j,h as W}from"./chunk-DLKRPK5M.js";import{a as G,b as V}from"./chunk-HEQPHUTR.js";import{a as X}from"./chunk-MLLEOFX2.js";import{j as O,l as Y,m as B,p as M}from"./chunk-GAGVFSZM.js";import{existsSync as _,readFileSync as le,writeFileSync as de,appendFileSync as $e,mkdirSync as Ae}from"fs";import{dirname as Se,resolve as R}from"path";import{fileURLToPath as Ie}from"url";import{hostname as Ce}from"os";import{spawn as Ee}from"child_process";M();import{existsSync as ne,readFileSync as te,writeFileSync as L,copyFileSync as be}from"fs";import{resolve as ae}from"path";function re(e,t={}){let n=t.configPath||ae(process.cwd(),"agentx.json");if(!ne(n))throw new Error(`agentx.json not found at ${n}`);let a=JSON.parse(te(n,"utf-8")),r=e(a),i=typeof r=="string"?{summary:r}:r,l=JSON.stringify(a,null,2)+`
|
|
2
|
+
`,p=n+".tmp";L(p,l,"utf-8");try{JSON.parse(te(p,"utf-8"))}catch(c){throw new Error(`config did not round-trip cleanly: ${c.message}`)}let s;return t.skipBackup||(s=`${n}.bak.${Date.now()}`,be(n,s)),L(n,l,"utf-8"),t.skipReload||ye().catch(()=>{}),{summary:i.summary,payload:i.payload,backupPath:s}}function ie(e,t={}){let n=t.configPath||ae(process.cwd(),"agentx.json");if(ne(n)&&!t.overwrite)throw new Error(`agentx.json already exists at ${n}. Pass overwrite=true to replace it.`);return L(n,JSON.stringify(e,null,2)+`
|
|
3
|
+
`,"utf-8"),{file:n}}async function ye(){try{let t=B().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${t}/reload`,{method:"POST"}).catch(()=>null)}catch{}}function se(e,t){let n=e.configExists?e.agentCount===0?"Add your first agent":"Add another agent":"Set up your team",a=`<header class="ax-topbar">
|
|
4
4
|
<div class="ax-topbar__left">
|
|
5
5
|
<div class="ax-brand">
|
|
6
6
|
<span class="ax-brand__mark">AX</span>
|
|
@@ -16,7 +16,7 @@ import{b as Y,c as X,d as G,e as D,f as I,g as M,h as W}from"./chunk-7CVJ4JOE.js
|
|
|
16
16
|
<button data-theme-opt="light">Light</button>
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
|
-
</header>`,r=W(1,"Team basics",I({name:"nodeName",label:"Team name",hint:"(what you'd call this AgentX install)",value:
|
|
19
|
+
</header>`,r=W(1,"Team basics",I({name:"nodeName",label:"Team name",hint:"(what you'd call this AgentX install)",value:t,placeholder:"My Team",required:!0})),i=W(2,"First agent",j([I({name:"agentName",label:"Agent name",value:"Assistant",placeholder:"Support Bot",required:!0}),I({name:"agentId",label:"Agent id",hint:"(lowercase, no spaces)",value:"assistant",pattern:"[a-z0-9][a-z0-9_-]*",required:!0})])+I({name:"triggerWords",label:"Trigger words",hint:"(comma or space separated \u2014 e.g. <code>@support, support</code>)",value:"@assistant, assistant",required:!0})+j([I({name:"tier",label:"AI engine",type:"select",options:[{value:"claude-code",label:"Claude Code (recommended)",selected:!0},{value:"codex-cli",label:"Codex CLI"},{value:"opencode",label:"OpenCode CLI"},{value:"sdk",label:"Anthropic API (BYO key)"},{value:"orchestrator",label:"Orchestrator (any provider)"}]}),I({name:"model",label:"Model",hint:"(optional)",value:"claude-sonnet-4-6",placeholder:"claude-sonnet-4-6"})])+I({name:"personality",label:"Personality / instructions",hint:"(optional \u2014 what this agent does, in plain English)",type:"textarea",placeholder:"You are a support agent for Acme Co. Answer customer questions about our product, be friendly, keep replies short."})),l=W(3,"First channel",`
|
|
20
20
|
<label class="ax-toggle"><input type="checkbox" id="enableTelegram" /> Connect Telegram now</label>
|
|
21
21
|
<div class="ax-optional" id="telegramFields">
|
|
22
22
|
${I({name:"telegramAccountId",label:"Account id",hint:"(a label you choose \u2014 e.g. <code>support</code>)",value:"default"})}
|
|
@@ -25,25 +25,25 @@ import{b as Y,c as X,d as G,e as D,f as I,g as M,h as W}from"./chunk-7CVJ4JOE.js
|
|
|
25
25
|
</div>
|
|
26
26
|
`),p=W(4,"Anthropic API key",I({name:"anthropicApiKey",label:"API key",hint:"(optional \u2014 skip if you're using Claude Code)",type:"password",placeholder:"sk-ant-\u2026",extraAttrs:'autocomplete="off"'})+`<div class="ax-hint-block">
|
|
27
27
|
The key is stored in <code>.env</code> as <code>ANTHROPIC_API_KEY</code> and used to authenticate requests to Anthropic. Keep it private.
|
|
28
|
-
</div>`),
|
|
29
|
-
<h1 class="ax-wizard__h1">${
|
|
28
|
+
</div>`),s=e.configExists?`<div class="ax-banner">Existing install: <b>${e.agentCount}</b> agent(s), <b>${e.channelCount}</b> channel(s) already configured. This wizard will add to it.</div>`:"",c=`<div class="ax-wizard">
|
|
29
|
+
<h1 class="ax-wizard__h1">${ee(n)}</h1>
|
|
30
30
|
<p class="ax-wizard__lead">Fill in the basics below. We'll write <code>agentx.json</code>, set up a folder for your first agent, and point you at the next step.</p>
|
|
31
31
|
|
|
32
|
-
${
|
|
32
|
+
${s}
|
|
33
33
|
|
|
34
34
|
<div id="msg" class="ax-msg"></div>
|
|
35
35
|
|
|
36
36
|
<form id="wizard" autocomplete="off">
|
|
37
37
|
${r}
|
|
38
|
-
${
|
|
39
|
-
${
|
|
38
|
+
${i}
|
|
39
|
+
${l}
|
|
40
40
|
${p}
|
|
41
41
|
<footer class="ax-actions">
|
|
42
|
-
${
|
|
43
|
-
${
|
|
42
|
+
${F("Save and continue",{type:"submit",primary:!0,id:"submitBtn"})}
|
|
43
|
+
${F("Skip, I'll do it later",{onclick:"window.location.href='/live'"})}
|
|
44
44
|
</footer>
|
|
45
45
|
</form>
|
|
46
|
-
</div>`;return
|
|
46
|
+
</div>`;return Z({title:"AgentX \u2014 Setup",activeTab:"custom",subtitle:"Setup",customHeader:a,noMain:!0,body:c,css:ke,scripts:we})}var ke=`
|
|
47
47
|
/* Pre-dashboard topbar variant \u2014 no tab nav, the pills are the only chrome. */
|
|
48
48
|
.ax-topbar__right a.ax-skip {
|
|
49
49
|
padding: 4px 10px; border: 1px solid var(--ax-border-2); border-radius: 4px;
|
|
@@ -100,7 +100,7 @@ import{b as Y,c as X,d as G,e as D,f as I,g as M,h as W}from"./chunk-7CVJ4JOE.js
|
|
|
100
100
|
.ax-next-steps code { background: var(--ax-surface-2); padding: 1px 6px; border-radius: 3px; color: var(--ax-text); font-family: var(--ax-mono); font-size: var(--ax-fs-sm); }
|
|
101
101
|
.ax-startd { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
102
102
|
.ax-startd__status { color: var(--ax-text-2); font-size: var(--ax-fs-sm); }
|
|
103
|
-
.ax-startd__status a { color: var(--ax-accent); }`,
|
|
103
|
+
.ax-startd__status a { color: var(--ax-accent); }`,we=`<script>
|
|
104
104
|
document.getElementById('enableTelegram').addEventListener('change', (e) => {
|
|
105
105
|
document.getElementById('telegramFields').classList.toggle('is-show', e.target.checked);
|
|
106
106
|
});
|
|
@@ -174,18 +174,18 @@ document.getElementById('wizard').addEventListener('submit', async (e) => {
|
|
|
174
174
|
btn.disabled = false; btn.textContent = 'Save and continue';
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
|
-
</script>`;
|
|
177
|
+
</script>`;M();function ce(e=process.cwd()){let t=R(e,"agentx.json");if(!_(t))return{configExists:!1,agentCount:0,channelCount:0};try{let n=JSON.parse(le(t,"utf-8")),a=n.agents?Object.keys(n.agents).length:0,r=n.channels?Object.values(n.channels).filter(i=>i&&i.enabled).length:0;return{configExists:!0,agentCount:a,channelCount:r,nodeName:n.node?.name}}catch{return{configExists:!1,agentCount:0,channelCount:0}}}function Te(e,t=process.cwd()){if(!e.nodeName?.trim())throw new Error("Team name is required.");if(!e.agent?.id?.trim())throw new Error("Agent id is required.");if(!/^[a-z0-9][a-z0-9_-]*$/.test(e.agent.id))throw new Error("Agent id must be lowercase (letters, digits, -, _) and start with a letter or digit.");if(!e.agent.name?.trim())throw new Error("Agent name is required.");let n=ze(e.agent.triggerWords);if(n.length===0)throw new Error("At least one trigger word is required.");if(e.agent.tier!=="claude-code"&&e.agent.tier!=="codex-cli"&&e.agent.tier!=="opencode"&&e.agent.tier!=="sdk"&&e.agent.tier!=="orchestrator")throw new Error("AI engine must be claude-code, codex-cli, opencode, sdk, or orchestrator.");let a=R(t,"agentx.json"),r=R(t,".env"),i=R(t,"agents",e.agent.id),l=ce(t);Ae(i,{recursive:!0});let p=R(i,"CLAUDE.md");if(!_(p)){let x=e.agent.personality?.trim()||`You are ${e.agent.name}, an assistant on the ${e.nodeName} team.`;de(p,`# ${e.agent.name}
|
|
178
178
|
|
|
179
179
|
${x}
|
|
180
|
-
`)}let
|
|
181
|
-
`));return}if(r.length>0){let
|
|
180
|
+
`)}let s=e.telegram?`TG_${e.agent.id.toUpperCase()}_BOT_TOKEN`:void 0,c;if(l.configExists)c=re(d=>{if(d.node=d.node||{},d.node.name||(d.node.name=e.nodeName),d.node.id||(d.node.id=pe(e.nodeName)||"team"),d.node.bind||(d.node.bind="127.0.0.1:18800"),d.node.defaultAgent=d.node.defaultAgent||e.agent.id,d.providers=d.providers||{},d.providers.claude||(d.providers.claude={apiKey:"${ANTHROPIC_API_KEY}"}),d.agents=d.agents||{},d.agents[e.agent.id])throw new Error(`Agent "${e.agent.id}" already exists.`);return d.agents[e.agent.id]=ge(e,i,n),e.telegram&&(d.channels=d.channels||{},d.channels.telegram=d.channels.telegram||{enabled:!0,accounts:{},policy:{dm:"pair",group:"mention-required"}},d.channels.telegram.enabled=!0,d.channels.telegram.accounts=d.channels.telegram.accounts||{},d.channels.telegram.accounts[e.telegram.accountId]=me(e,s)),{summary:`added agent "${e.agent.id}"`+(e.telegram?" + telegram account":"")}},{configPath:a}).backupPath;else{let x=Re(e,i,n,s);ie(x,{configPath:a})}Pe(r,e,s);let g=[];return(e.anthropicApiKey||!_(R(t,".env")))&&g.push("Double-check the API keys in .env"),e.agent.tier==="claude-code"&&g.push("Run claude --version to confirm Claude Code is installed (needed for the claude-code engine)"),e.agent.tier==="codex-cli"&&g.push("Run codex --version to confirm Codex CLI is installed (needed for the codex-cli engine)"),e.agent.tier==="opencode"&&g.push("Run opencode --version to confirm OpenCode is installed and authenticated"),g.push("Start the daemon: agentx daemon start"),g.push("Open the dashboard: http://127.0.0.1:4202"),{summary:l.configExists?`Added agent "${e.agent.id}" to your team.`:`Initialized your team with first agent "${e.agent.id}".`,nextSteps:g,backupPath:c}}function ze(e){return(e||"").split(/[,\s]+/).map(t=>t.trim()).filter(Boolean).filter((t,n,a)=>a.indexOf(t)===n)}function pe(e){return(e||"").toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")}function Re(e,t,n,a){let i={node:{id:pe(e.nodeName)||"team",name:e.nodeName,bind:"127.0.0.1:18800",defaultAgent:e.agent.id},providers:{claude:{apiKey:"${ANTHROPIC_API_KEY}"}},agents:{[e.agent.id]:ge(e,t,n)},channels:{},crons:{},mesh:{enabled:!1,peers:[],discovery:"static",healthCheck:{interval:60,timeout:10}},dashboard:{enabled:!0,port:4202,bind:"127.0.0.1",daemonUrl:"http://localhost:18800"},boards:[]};return e.telegram&&a?i.channels.telegram={enabled:!0,accounts:{[e.telegram.accountId]:me(e,a)},policy:{dm:"pair",group:"mention-required"}}:i.channels.telegram={enabled:!1,accounts:{},policy:{dm:"pair",group:"mention-required"}},i}function ge(e,t,n){let a={name:e.agent.name,workspace:t,tier:e.agent.tier,mentions:n,maxConcurrent:2,permissionMode:"default"};return e.agent.model&&(a.model=e.agent.model),e.agent.personality?.trim()&&(a.systemPrompt=e.agent.personality.trim().slice(0,400)),a}function me(e,t){return e.telegram?.botUsername,{token:"${"+t+"}",agentBinding:e.agent.id}}function Pe(e,t,n){let a=_(e)?le(e,"utf-8"):"",r=[];if(t.anthropicApiKey&&!a.includes("ANTHROPIC_API_KEY=")&&r.push(`ANTHROPIC_API_KEY=${t.anthropicApiKey}`),t.telegram&&n&&!a.includes(`${n}=`)&&r.push(`${n}=${t.telegram.botToken}`),!_(e)){de(e,[...["# AgentX environment variables","# (Never commit this file \u2014 it contains secrets.)",""],...r,""].join(`
|
|
181
|
+
`));return}if(r.length>0){let i=a.endsWith(`
|
|
182
182
|
`)?"":`
|
|
183
|
-
|
|
183
|
+
`;$e(e,i+r.join(`
|
|
184
184
|
`)+`
|
|
185
|
-
`)}}function
|
|
186
|
-
`,"utf-8")}create(
|
|
185
|
+
`)}}function bt(e,t){let n=ce(),a=n.nodeName||Ce().replace(/\.local$/,""),r=se(n,a);t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(r)}async function yt(e,t){let n="";await new Promise(r=>{e.on("data",i=>{n+=i}),e.on("end",()=>r())});let a;try{a=JSON.parse(n)}catch{t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Invalid JSON"}));return}try{let r=Te(a);t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify(r))}catch(r){t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:r.message||"wizard failed"}))}}async function kt(e,t){t.setHeader("Content-Type","application/json");let n;try{n=B().node?.bind||"127.0.0.1:18800"}catch(l){t.writeHead(400),t.end(JSON.stringify({ok:!1,error:`Config validation failed: ${l.message}`}));return}let a=`http://${n.replace(/^0\.0\.0\.0/,"127.0.0.1")}`;if(await oe(a)){t.writeHead(200),t.end(JSON.stringify({ok:!0,url:a,alreadyRunning:!0}));return}let r=process.argv[1]||R(Se(Ie(import.meta.url)),"cli.js");try{Ee(process.execPath,[r,"daemon","start"],{detached:!0,stdio:"ignore",cwd:process.cwd()}).unref()}catch(l){t.writeHead(500),t.end(JSON.stringify({ok:!1,error:`Failed to spawn daemon: ${l.message}`,manualUrl:a}));return}let i=Date.now()+12e3;for(;Date.now()<i;)if(await new Promise(l=>setTimeout(l,400)),await oe(a)){t.writeHead(200),t.end(JSON.stringify({ok:!0,url:a,alreadyRunning:!1}));return}t.writeHead(504),t.end(JSON.stringify({ok:!1,error:"Daemon spawn succeeded but never bound the port within 12s \u2014 check `agentx daemon status` and the dotfile log for errors.",manualUrl:a}))}async function oe(e){try{let t=await fetch(e,{method:"GET",signal:AbortSignal.timeout(800)});return t.status>0&&t.status<600}catch{return!1}}import{createHash as Ue,randomBytes as ue}from"crypto";import{existsSync as We,mkdirSync as _e,readFileSync as Ne,writeFileSync as Be}from"fs";import{resolve as De,dirname as He}from"path";var J="agx_live_",Oe=".agentx/tokens.json",he=class{file;constructor(t=process.cwd(),n=Oe){this.file=De(t,n)}load(){if(!We(this.file))return[];try{return JSON.parse(Ne(this.file,"utf-8"))}catch{return[]}}save(t){_e(He(this.file),{recursive:!0}),Be(this.file,JSON.stringify(t,null,2)+`
|
|
186
|
+
`,"utf-8")}create(t){if(!t.name?.trim())throw new Error("Token name is required.");if(!Array.isArray(t.scopes)||t.scopes.length===0)throw new Error("At least one scope is required.");for(let l of t.scopes)if(!Me(l))throw new Error(`Invalid scope: ${l}`);let n=ue(32).toString("hex"),a=J+n,r={id:"tok_"+ue(4).toString("hex"),name:t.name.trim(),prefix:J+n.slice(0,4),hash:fe(a),scopes:[...t.scopes],createdAt:new Date().toISOString(),expiresAt:t.expiresInDays?new Date(Date.now()+t.expiresInDays*86400*1e3).toISOString():void 0},i=this.load();return i.push(r),this.save(i),{token:a,record:r}}list(){return this.load()}revoke(t){let n=this.load(),a=n.find(r=>r.id===t);return a?(a.revokedAt=new Date().toISOString(),this.save(n),a):null}verify(t){if(!t||!t.startsWith(J))return null;let n=fe(t),a=this.load(),r=a.find(p=>p.hash===n);if(!r||r.revokedAt||r.expiresAt&&Date.parse(r.expiresAt)<Date.now())return null;let i=Date.now(),l=r.lastUsedAt?Date.parse(r.lastUsedAt):0;if(i-l>6e4){r.lastUsedAt=new Date(i).toISOString();try{this.save(a)}catch{}}return r}};function It(e,t){return!!(e.scopes.includes(t)||t.startsWith("agent:")&&e.scopes.includes("agent:*")||t==="dashboard:read"&&e.scopes.includes("dashboard:write"))}function Me(e){return e==="dashboard:read"||e==="dashboard:write"||e==="agent:*"||/^agent:[a-z0-9][a-z0-9_-]*$/.test(e)||e==="mesh:peer"}function fe(e){return"sha256:"+Ue("sha256").update(e).digest("hex")}function Ct(e){let t=e.headers.authorization,n=Array.isArray(t)?t[0]:t;if(n&&n.toLowerCase().startsWith("bearer "))return n.slice(7).trim();if(e.url)try{let r=new URL(e.url,"http://localhost").searchParams.get("token");if(r)return r}catch{}return null}import{createServer as Fe}from"http";var D=class{peers;cache=new Map;ttl=3e4;constructor(t){this.peers=t.map(n=>({url:n.replace(/\/$/,"")}))}async getRemoteAgents(){let t=[];return await Promise.all(this.peers.map(async n=>{try{let a=await this.fetchJson(`${n.url}/wiki/agents`);n.nodeId=a.nodeId;for(let r of a.agents||[])(r.totalEntries>0||r.totalArticles>0)&&t.push({...r,nodeId:a.nodeId,peerUrl:n.url})}catch{}})),t}async getRemoteArticles(t,n){try{return(await this.fetchJson(`${t}/wiki/articles?agent=${encodeURIComponent(n)}`)).articles||[]}catch{return[]}}async getRemoteArticle(t,n,a){try{let r=await this.fetchJson(`${t}/wiki/article?agent=${encodeURIComponent(n)}&path=${encodeURIComponent(a)}`);return{meta:{title:r.title,tags:r.tags||[],owner:r.owner,access:"public",created:r.created,lastUpdated:r.lastUpdated,sources:r.sources||[]},content:r.content,path:r.path}}catch{return null}}async fetchJson(t){let n=this.cache.get(t);if(n&&Date.now()-n.ts<this.ttl)return n.data;let a=await fetch(t,{signal:AbortSignal.timeout(5e3)});if(!a.ok)throw new Error(`HTTP ${a.status}`);let r=await a.json();return this.cache.set(t,{data:r,ts:Date.now()}),r}};function o(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function je(e){return e.replace(/<!--\s*tags?:[^>]*-->\s*\n?/gi,"")}function ve(e,t){return`<a href="${t?`/agent/${encodeURIComponent(t)}/tag/${encodeURIComponent(e)}`:`/tag/${encodeURIComponent(e)}`}" class="tag">${o(e)}</a>`}function P(e,t){return(e||[]).map(n=>ve(n,t)).join(" ")}function Le(e,t){if(!e)return;let n=t.get(e);if(n)return n;let a=new Set(t.values());if(a.has(e))return e;let r=e.endsWith(".md")?e:`${e}.md`;if(a.has(r))return r;let i=e.toLowerCase();for(let[l,p]of t)if(l.toLowerCase()===i)return p}function H(e,t,n=""){return Q(je(e),{wikilink:(a,r)=>{let i=Le(a,t);return i?`<a href="${n}/article/${encodeURIComponent(i)}" class="wikilink">${r}</a>`:`<a href="${n}/search?q=${encodeURIComponent(a)}" class="wikilink broken" title="Not found \u2014 click to search">${r}</a>`}})}var Je=`<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
187
187
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
188
|
-
<link href="https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300..600;1,6..72,300..600&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">`,
|
|
188
|
+
<link href="https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300..600;1,6..72,300..600&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">`,qe=`
|
|
189
189
|
:root {
|
|
190
190
|
--bg: #FAF8F3;
|
|
191
191
|
--bg-raised: #FFFFFF;
|
|
@@ -652,14 +652,14 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
652
652
|
.sidebar { display: none; }
|
|
653
653
|
.main { padding: 20px; grid-column: 1; }
|
|
654
654
|
}
|
|
655
|
-
`;function $(t,
|
|
655
|
+
`;function $(e,t,n,a=""){return`<!DOCTYPE html>
|
|
656
656
|
<html lang="en">
|
|
657
657
|
<head>
|
|
658
658
|
<meta charset="utf-8">
|
|
659
659
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
660
|
-
<title>${
|
|
661
|
-
${
|
|
662
|
-
<style>${
|
|
660
|
+
<title>${o(e)} \u2014 AgentX Wiki</title>
|
|
661
|
+
${Je}
|
|
662
|
+
<style>${qe}</style>
|
|
663
663
|
<script>(function(){try{var t=localStorage.getItem('wiki-theme');if(t)document.documentElement.setAttribute('data-theme',t)}catch(e){}})();</script>
|
|
664
664
|
</head>
|
|
665
665
|
<body>
|
|
@@ -671,7 +671,7 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
671
671
|
</a>
|
|
672
672
|
<form class="topbar-search" action="/search" method="get">
|
|
673
673
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
|
|
674
|
-
<input type="search" name="q" placeholder="Search every wiki\u2026" value="${
|
|
674
|
+
<input type="search" name="q" placeholder="Search every wiki\u2026" value="${o(a)}" autocomplete="off" />
|
|
675
675
|
<kbd>\u2318K</kbd>
|
|
676
676
|
</form>
|
|
677
677
|
<div class="topbar-tools">
|
|
@@ -680,7 +680,7 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
680
680
|
</button>
|
|
681
681
|
</div>
|
|
682
682
|
</header>
|
|
683
|
-
<nav class="sidebar">${
|
|
683
|
+
<nav class="sidebar">${t}</nav>
|
|
684
684
|
<main class="main">${n}</main>
|
|
685
685
|
</div>
|
|
686
686
|
<script>
|
|
@@ -704,37 +704,37 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
704
704
|
})();
|
|
705
705
|
</script>
|
|
706
706
|
</body>
|
|
707
|
-
</html>`}function
|
|
707
|
+
</html>`}function q(e){let t=new Map;for(let n of e){let a=n.path.includes("/")?n.path.split("/").slice(0,-1).join("/"):"/",r=t.get(a)||[];r.push(n),t.set(a,r)}return new Map([...t].sort((n,a)=>n[0].localeCompare(a[0])))}function K(e){return e==="/"?"Root":e.split("/").pop().replace(/-/g," ")}function C(e,t){let n='<div class="nav-section">';n+=`<a class="nav-item${t?"":" active"}" href="/">Home</a>`,n+='<a class="nav-item" href="/entries">All entries</a>',n+="</div>";for(let a of e){let r=`/agent/${encodeURIComponent(a.agentId)}`;n+='<div class="nav-section">',n+=`<a class="nav-agent-header" href="${r}">`,n+=`<span class="name">${o(a.agentId)}</span>`,n+=`<span class="badge">${a.totalArticles}</span>`,n+="</a>",n+='<div class="nav-agent-children">';let i=q(a.articles);for(let[l,p]of i){n+=`<div class="nav-agent-type-label">${K(l)}</div>`;for(let s of p){let g=`${a.agentId}/${s.path}`===t;n+=`<a class="nav-item${g?" active":""}" href="${r}/article/${encodeURIComponent(s.path)}">${o(s.title)}</a>`}}n+="</div>",n+="</div>"}return n}function Ke(e,t,n){let a=t||e.summary(),i=e.getSharedStore().listEntries().length,l=a.reduce((g,x)=>g+x.totalArticles,0),p=a.reduce((g,x)=>g+x.unabsorbed,0),s=new Set((n||[]).map(g=>g.agentId)),c=`<div class="page-head">
|
|
708
708
|
<div>
|
|
709
709
|
<h1>AgentX Wiki</h1>
|
|
710
710
|
<p class="page-sub">Agent-owned institutional knowledge, typed and cross-referenced. Everything here compiles from raw conversation entries through the nightly absorb pass.</p>
|
|
711
711
|
</div>
|
|
712
|
-
</div>`;if(
|
|
712
|
+
</div>`;if(c+='<div class="stat-strip">',c+=`<div class="stat-cell"><div class="label">Agents</div><div class="number">${a.length}</div></div>`,c+=`<div class="stat-cell"><div class="label">Articles</div><div class="number">${l}</div></div>`,c+=`<div class="stat-cell"><div class="label">Raw entries</div><div class="number">${i}</div></div>`,p>0&&(c+=`<div class="stat-cell"><div class="label">Unabsorbed</div><div class="number">${p}</div></div>`),n&&n.length>0){let g=new Set(n.map(x=>x.nodeId));c+=`<div class="stat-cell"><div class="label">Mesh nodes</div><div class="number">${g.size}</div></div>`}c+="</div>",c+='<div class="section-head"><h2>Agent wikis</h2></div>',c+='<div class="agent-grid">';for(let g of a){let x=g.unabsorbed>0?`<span class="tag" style="color:var(--warn);background:color-mix(in oklch, var(--warn) 12%, transparent)">${g.unabsorbed} unabsorbed</span>`:'<span class="tag" style="color:var(--ok);background:color-mix(in oklch, var(--ok) 12%, transparent)">up to date</span>',h=s.has(g.agentId)&&!e.listAgents().includes(g.agentId)?' <span class="tag" style="color:var(--cool);background:var(--cool-soft)">remote</span>':"";if(c+='<div class="agent-card">',c+=`<h3><a href="/agent/${encodeURIComponent(g.agentId)}">${o(g.agentId)}</a>${h}</h3>`,c+=`<div class="agent-stats">
|
|
713
713
|
<span><strong>${g.totalArticles}</strong> articles</span>
|
|
714
714
|
<span><strong>${g.totalEntries}</strong> entries</span>
|
|
715
715
|
${x}
|
|
716
|
-
</div>`,g.articles.length>0){
|
|
717
|
-
<div class="meta-line">${
|
|
718
|
-
<p>${
|
|
719
|
-
</div>`}let x=
|
|
720
|
-
<span class="kind">${
|
|
721
|
-
<span class="article">${
|
|
722
|
-
<span class="msg">${
|
|
723
|
-
</div>`;
|
|
716
|
+
</div>`,g.articles.length>0){c+='<div class="article-list">';for(let f of g.articles.slice(0,6)){let T=P((f.tags||[]).slice(0,2),g.agentId);c+=`<div class="article-row">${T} <a class="article-title" href="/agent/${encodeURIComponent(g.agentId)}/article/${encodeURIComponent(f.path)}">${o(f.title)}</a></div>`}g.articles.length>6&&(c+=`<div class="article-row"><a class="article-title" style="color:var(--muted)" href="/agent/${encodeURIComponent(g.agentId)}">+ ${g.articles.length-6} more \u2192</a></div>`),c+="</div>"}c+="</div>"}return c+="</div>",$("Hub",C(a),c)}function Ye(e,t,n){let a=n||e.summary(),r=a.find(d=>d.agentId===t);if(!r)return $("Not Found",C(a),"<h1>Agent not found</h1>");let i=r.peerUrl!==void 0,l=e.getAgentEntries(t),p=r.articles||[],s=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">${o(t)}</span></nav>`;if(s+=`<div class="page-head"><div><h1>${o(t)}</h1>`,i&&(s+=`<p class="page-sub"><span class="tag" style="color:var(--cool);background:var(--cool-soft)">remote @ ${o(r.nodeId)}</span></p>`),s+="</div></div>",s+='<div class="stat-strip">',s+=`<div class="stat-cell"><div class="label">Articles</div><div class="number">${r.totalArticles}</div></div>`,s+=`<div class="stat-cell"><div class="label">Entries</div><div class="number">${r.totalEntries}</div></div>`,s+=`<div class="stat-cell"><div class="label">Unabsorbed</div><div class="number">${r.unabsorbed}</div></div>`,s+="</div>",p.length>0){s+='<div class="section-head"><h2>Articles</h2><span class="mono" style="font-size:12px;color:var(--muted)">'+p.length+" total</span></div>";let d=q(p);for(let[h,f]of d){s+=`<h3 class="display" style="font-size:17px;color:var(--muted);font-weight:500;margin:20px 0 8px">${K(h)}</h3>`,s+='<div class="agent-card" style="padding:4px 14px"><div class="article-list">';for(let T of f)s+=`<div class="article-row">${P((T.tags||[]).slice(0,3),t)} <a class="article-title" href="/agent/${encodeURIComponent(t)}/article/${encodeURIComponent(T.path)}">${o(T.title)}</a></div>`;s+="</div></div>"}}let c=l.slice(-5).reverse();if(c.length>0){s+='<div class="section-head"><h2>Recent entries</h2><a class="btn ghost" href="/entries">See all \u2192</a></div>';for(let d of c)s+=`<div class="entry-card">
|
|
717
|
+
<div class="meta-line">${d.date} \xB7 via ${o(d.source)} \xB7 <code>${o(d.id)}</code></div>
|
|
718
|
+
<p>${o(d.content.slice(0,300))}${d.content.length>300?"\u2026":""}</p>
|
|
719
|
+
</div>`}let x=e.getAgentWiki(t).lint();if(x.length>0){s+=`<div class="section-head"><h2>Health issues</h2><span class="mono" style="font-size:12px;color:var(--warn)">${x.length}</span></div>`,s+='<div class="health-list">';for(let d of x)s+=`<div class="health-row">
|
|
720
|
+
<span class="kind">${o(d.type)}</span>
|
|
721
|
+
<span class="article">${o(d.article)}</span>
|
|
722
|
+
<span class="msg">${o(d.message)}</span>
|
|
723
|
+
</div>`;s+="</div>"}return $(t,C(a,t),s)}function Xe(e,t,n,a){let r=e.getAgentWiki(t),i=r.readArticle(n);if(!i)return null;let l=a||e.summary(),p=r.rebuildIndex(),s=new Map;for(let h of p.articles)s.set(h.title,h.path);let c=`/agent/${encodeURIComponent(t)}`,x=r.buildBacklinks()[i.meta.title]||[],d=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${c}">${o(t)}</a> <span class="sep">/</span> <span class="current">${o(i.meta.title)}</span></nav>`;if(d+=`<article class="prose"><h1>${o(i.meta.title)}</h1>`,d+='<dl class="meta">',i.meta.type&&(d+=`<dt>Type</dt><dd>${ve(i.meta.type,t)}</dd>`),i.meta.tags?.length&&(d+=`<dt>Tags</dt><dd>${P(i.meta.tags,t)}</dd>`),i.meta.owner&&(d+=`<dt>Owner</dt><dd>${o(i.meta.owner)}</dd>`),d+=`<dt>Created</dt><dd>${o(i.meta.created||"\u2014")}</dd>`,d+=`<dt>Updated</dt><dd>${o(i.meta.lastUpdated||"\u2014")}</dd>`,i.meta.sources?.length&&(d+=`<dt>Sources</dt><dd>${i.meta.sources.length} entries</dd>`),d+="</dl>",d+=H(i.content,s,c),x.length>0){d+='<div class="backlinks"><h4>Pages that link here</h4><ul>';for(let h of x){let f=r.readArticle(h);d+=`<li><a href="${c}/article/${encodeURIComponent(h)}">${o(f?.meta.title||h)}</a></li>`}d+="</ul></div>"}return d+="</article>",$(i.meta.title,C(l,`${t}/${n}`),d)}function Ge(e,t){let n=t||e.summary(),r=e.getSharedStore().listEntries(),i='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Entries</span></nav>';i+='<div class="page-head"><div><h1>All raw entries</h1><p class="page-sub">Every conversation line that the ingest pipeline captured. Absorb compiles these into typed articles nightly.</p></div></div>';let l=new Map;for(let p of r){let s=l.get(p.date)||[];s.push(p),l.set(p.date,s)}for(let[p,s]of[...l].reverse()){i+=`<div class="section-head"><h2>${p}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${s.length} entries</span></div>`;for(let c of s)i+=`<div class="entry-card">
|
|
724
724
|
<div class="meta-line">
|
|
725
|
-
<a href="/agent/${encodeURIComponent(
|
|
726
|
-
\xB7 via ${
|
|
725
|
+
<a href="/agent/${encodeURIComponent(c.agentId)}">${o(c.agentId)}</a>
|
|
726
|
+
\xB7 via ${o(c.source)} \xB7 <code>${o(c.id)}</code>
|
|
727
727
|
</div>
|
|
728
|
-
<p>${
|
|
729
|
-
</div>`}return $("All Entries",C(n),
|
|
730
|
-
<div class="meta-line">${
|
|
731
|
-
<h3><a href="${x}/article/${encodeURIComponent(g.path)}">${
|
|
732
|
-
<p>${
|
|
733
|
-
</div>`)}
|
|
734
|
-
<div class="meta-line">${
|
|
735
|
-
<h3><a href="${g}/article/${encodeURIComponent(
|
|
736
|
-
</div>`}
|
|
737
|
-
<div class="meta-line">${
|
|
738
|
-
<h3><a href="${p}/article/${encodeURIComponent(
|
|
739
|
-
</div>`;return $(`${
|
|
740
|
-
//# sourceMappingURL=chunk-
|
|
728
|
+
<p>${o(c.content.slice(0,400))}${c.content.length>400?"\u2026":""}</p>
|
|
729
|
+
</div>`}return $("All Entries",C(n),i)}function Ve(e,t,n){let a=n||e.summary(),r='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Search</span></nav>';r+=`<div class="page-head"><div><h1>\u201C${o(t)}\u201D</h1><p class="page-sub">Full-text search across every agent's wiki.</p></div></div>`;let i=0,l=[];for(let p of a){let c=e.getAgentWiki(p.agentId).findRelevant(t,void 0,10);if(c.length>0){l.push(`<div class="section-head"><h2>${o(p.agentId)}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${c.length} match${c.length===1?"":"es"}</span></div>`);for(let g of c){let x=`/agent/${encodeURIComponent(p.agentId)}`;l.push(`<div class="entry-card">
|
|
730
|
+
<div class="meta-line">${P((g.meta.tags||[]).slice(0,3),p.agentId)}</div>
|
|
731
|
+
<h3><a href="${x}/article/${encodeURIComponent(g.path)}">${o(g.meta.title)}</a></h3>
|
|
732
|
+
<p>${o(g.content.slice(0,240))}\u2026</p>
|
|
733
|
+
</div>`)}i+=c.length}}return r+=l.join(""),i===0&&(r+='<p style="color:var(--muted);margin-top:24px">No matching articles found.</p>'),$(`Search: ${t}`,C(a),r,t)}function Qe(e,t,n){let a=n||e.summary(),r='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Tag</span></nav>';r+=`<div class="page-head"><div><h1>${o(t)}</h1><p class="page-sub">All articles tagged <span class="tag">${o(t)}</span>, across every agent.</p></div></div>`;let i=0;for(let l of a){let p;try{p=e.getAgentWiki(l.agentId)}catch{continue}let s=p.findByTags([t],void 0,100);if(s.length!==0){r+=`<div class="section-head"><h2>${o(l.agentId)}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${s.length}</span></div>`;for(let c of s){let g=`/agent/${encodeURIComponent(l.agentId)}`;r+=`<div class="entry-card">
|
|
734
|
+
<div class="meta-line">${P((c.meta.tags||[]).slice(0,6),l.agentId)}</div>
|
|
735
|
+
<h3><a href="${g}/article/${encodeURIComponent(c.path)}">${o(c.meta.title)}</a></h3>
|
|
736
|
+
</div>`}i+=s.length}}return i===0&&(r+=`<p style="color:var(--muted);margin-top:24px">No articles tagged <code>${o(t)}</code>.</p>`),$(`Tag: ${t}`,C(a),r)}function Ze(e,t,n,a){let r=a||e.summary(),i;try{i=e.getAgentWiki(t)}catch{return $(`Tag: ${n}`,C(r),`<h1>Agent not found: ${o(t)}</h1>`)}let l=i.findByTags([n],void 0,100),p=`/agent/${encodeURIComponent(t)}`,s=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${p}">${o(t)}</a> <span class="sep">/</span> <span class="current">${o(n)}</span></nav>`;s+=`<div class="page-head"><div><h1>${o(n)}</h1><p class="page-sub">${l.length} article${l.length===1?"":"s"} tagged <code>${o(n)}</code> in <b>${o(t)}</b>.</p></div></div>`;for(let c of l)s+=`<div class="entry-card">
|
|
737
|
+
<div class="meta-line">${P((c.meta.tags||[]).slice(0,6),t)}</div>
|
|
738
|
+
<h3><a href="${p}/article/${encodeURIComponent(c.path)}">${o(c.meta.title)}</a></h3>
|
|
739
|
+
</div>`;return $(`${t} \xB7 ${n}`,C(r),s)}function U(e,t,n){let a=e.rebuildIndex(),r=q(a.articles.map(l=>({title:l.title,path:l.path,tags:l.tags}))),i='<div class="nav-section">';i+=`<div class="nav-section-title">${o(t)}</div>`,i+=`<a class="nav-item${n?"":" active"}" href="/">Home</a>`,i+='<a class="nav-item" href="/lint">Health check</a>',i+="</div>";for(let[l,p]of r){i+='<div class="nav-section">',i+=`<div class="nav-section-title">${K(l)}</div>`;for(let s of p){let c=s.path===n;i+=`<a class="nav-item${c?" active":""}" href="/article/${encodeURIComponent(s.path)}">${o(s.title)}</a>`}i+="</div>"}return i}function et(e){let{wikiDir:t,agentFilter:n,peerUrls:a=[],mode:r="graph",pathPrefix:i=""}=e,l=i.replace(/\/+$/,""),p=new X(t,void 0,r),s=a.length>0?new D(a):null;return async(c,g)=>{let x=new URL(c.url||"/","http://localhost"),d=decodeURIComponent(x.pathname),h=l&&d.startsWith(l)?d.slice(l.length)||"/":d,f=null,T=200;try{if(h.startsWith("/remote/")&&s){let y=h.slice(8).split("/article/");if(y.length===2){let[b,v]=y,m=b.indexOf("/"),k=decodeURIComponent(b.slice(0,m)),u=b.slice(m+1),w=await s.getRemoteArticle(k,u,v);if(w){let z=await s.getRemoteAgents(),N=[...p.summary(),...z.map(S=>({...S,agentId:`${S.agentId} @${S.nodeId}`}))],A=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote</span> ${o(u)} @ ${o(k)}</div>`;A+=`<h1>${o(w.meta.title)}</h1>`,A+='<dl class="meta">',A+=`<dt>Tags</dt><dd>${(w.meta.tags||[]).map(S=>`<span class="tag">${S}</span>`).join(" ")}</dd>`,A+=`<dt>Owner</dt><dd>${o(w.meta.owner)}</dd>`,A+=`<dt>Source</dt><dd><span class="tag">remote</span> ${o(k)}</dd>`,A+=`<dt>Updated</dt><dd>${w.meta.lastUpdated}</dd>`,A+="</dl>";let E=new Map;A+=H(w.content,E),f=$(w.meta.title,C(N),A)}}}if(!f&&n){let y=p.getAgentWiki(n);if(h==="/"||h===""){let b=y.rebuildIndex(),v=p.getAgentEntries(n),m=`<h1>${o(n)}</h1>`;if(m+='<div class="stats">',m+=`<div class="stat-card"><div class="number">${b.articles.length}</div><div class="label">Articles</div></div>`,m+=`<div class="stat-card"><div class="number">${v.length}</div><div class="label">Entries</div></div>`,m+="</div>",b.articles.length>0){m+="<h2>Articles</h2><table><tr><th>Title</th><th>Type</th><th>Updated</th></tr>";for(let k of b.articles)m+=`<tr><td><a href="/article/${encodeURIComponent(k.path)}">${o(k.title)}</a></td><td><span class="tag">${(k.tags||[]).slice(0,3).join(", ")}</span></td><td>${k.lastUpdated||""}</td></tr>`;m+="</table>"}f=$(n,U(y,n),m)}else if(h.startsWith("/article/")){let b=h.slice(9),v=y.readArticle(b);if(v){let m=y.rebuildIndex(),k=new Map;for(let w of m.articles)k.set(w.title,w.path);let u=`<h1>${o(v.meta.title)}</h1>`;u+='<dl class="meta">',u+=`<dt>Tags</dt><dd>${(v.meta.tags||[]).map(w=>`<span class="tag">${w}</span>`).join(" ")}</dd>`,u+=`<dt>Updated</dt><dd>${v.meta.lastUpdated}</dd>`,v.meta.sources?.length&&(u+=`<dt>Sources</dt><dd>${v.meta.sources.length} entries</dd>`),u+="</dl>",u+=H(v.content,k),f=$(v.meta.title,U(y,n,b),u)}}else if(h==="/lint"){let b=y.lint(),v="<h1>Health Check</h1>";if(b.length===0)v+='<p style="color:green;">No issues.</p>';else{v+="<table><tr><th>Type</th><th>Article</th><th>Issue</th></tr>";for(let m of b)v+=`<tr><td><span class="tag">${m.type}</span></td><td>${o(m.article)}</td><td>${o(m.message)}</td></tr>`;v+="</table>"}f=$("Health Check",U(y,n),v)}else if(h==="/search"){let b=x.searchParams.get("q")||"",v=await y.findRelevantReranked(b,void 0,20),m=`<h1>Search: "${o(b)}"</h1>`;for(let k of v)m+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent(k.path)}">${o(k.meta.title)}</a></h3><p>${o(k.content.slice(0,200))}...</p></div>`;v.length===0&&(m+="<p>No results.</p>"),f=$(`Search: ${b}`,U(y,n),m)}else if(h.startsWith("/tag/")){let b=decodeURIComponent(h.slice(5)),v=y.findByTags([b],void 0,100),m=`<h1>Tag: <a class="tag" href="#">${o(b)}</a></h1>`;m+=`<p>${v.length} article${v.length===1?"":"s"} tagged <code>${o(b)}</code></p>`;for(let k of v)m+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent(k.path)}">${o(k.meta.title)}</a></h3><div class="meta-line">${P((k.meta.tags||[]).slice(0,6))}</div></div>`;v.length===0&&(m+="<p>No articles with this tag.</p>"),f=$(`Tag: ${b}`,U(y,n),m)}}else{let y=s?await s.getRemoteAgents():[],b=p.summary(),v=new Map(b.map(u=>[u.agentId,u])),m=[],k=new Set;for(let u of b){let w=y.find(z=>z.agentId===u.agentId);w&&w.totalArticles>u.totalArticles?m.push({...w,totalEntries:Math.max(u.totalEntries,w.totalEntries),unabsorbed:Math.max(u.unabsorbed,w.unabsorbed)}):m.push(u),k.add(u.agentId)}for(let u of y)k.has(u.agentId)||(m.push(u),k.add(u.agentId));if(h==="/"||h==="")f=Ke(p,m,y);else if(h==="/entries")f=Ge(p,m);else if(h==="/search")f=Ve(p,x.searchParams.get("q")||"",m);else if(h.startsWith("/tag/"))f=Qe(p,decodeURIComponent(h.slice(5)),m);else if(h.match(/^\/agent\/[^/]+\/tag\/.+/)){let u=h.match(/^\/agent\/([^/]+)\/tag\/(.+)$/);f=Ze(p,decodeURIComponent(u[1]),decodeURIComponent(u[2]),m)}else if(h.startsWith("/agent/")){let u=h.slice(7),w=u.indexOf("/article/");if(w===-1)f=Ye(p,u,m);else{let z=u.slice(0,w),N=u.slice(w+9);if(f=Xe(p,z,N,m),!f&&s){let A=y.find(E=>E.agentId===z);if(A){let E=await s.getRemoteArticle(A.peerUrl,z,N);if(E){let S=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote @ ${o(A.nodeId)}</span> / ${o(z)}</div>`;S+=`<h1>${o(E.meta.title)}</h1>`,S+='<dl class="meta">',S+=`<dt>Tags</dt><dd>${(E.meta.tags||[]).map(xe=>`<span class="tag">${xe}</span>`).join(" ")}</dd>`,S+=`<dt>Source</dt><dd><span class="tag">remote</span> ${o(A.nodeId)}</dd>`,S+=`<dt>Updated</dt><dd>${E.meta.lastUpdated}</dd>`,S+="</dl>",S+=H(E.content,new Map),f=$(E.meta.title,C(m),S)}}}}}}if(!f){T=404;let y=n?U(p.getAgentWiki(n),n):C(p.summary());f=$("Not Found",y,"<h1>Page not found</h1>")}}catch(y){T=500,f=$("Error","",`<h1>Error</h1><pre>${o(y.message)}</pre>`)}g.writeHead(T,{"Content-Type":"text/html; charset=utf-8"}),g.end(l?tt(f,l):f)}}function tt(e,t){e=e.replace(/(\s(?:href|action)=")\/(?!\/)/g,`$1${t}/`),e=e.replace(new RegExp(`(${t})${t}/`,"g"),`${t}/`);let n=`<a href="/admin" style="position:fixed;top:10px;right:14px;z-index:9999;padding:5px 11px;background:rgba(0,0,0,0.55);color:#fff;font:12px/1.2 'IBM Plex Sans',system-ui,sans-serif;text-decoration:none;border-radius:6px;border:1px solid rgba(255,255,255,0.18);backdrop-filter:blur(6px)">\u2190 Dashboard</a>`;return e=e.replace(/<body([^>]*)>/,`<body$1>${n}`),e}function Wt(e,t=4200,n,a=[],r="graph"){let i=et({wikiDir:e,agentFilter:n,peerUrls:a,mode:r});Fe((p,s)=>{i(p,s)}).listen(t)}import{existsSync as nt,readFileSync as at}from"fs";M();function Ht(e){let t=G(e),n={};if(nt(t))try{n=Y(JSON.parse(at(t,"utf-8")))}catch{n={}}let a=O.safeParse(n?.approvals);return a.success?a.data:O.parse(void 0)}function Ot(e){let t=e.indexOf(":");return t<=0||t===e.length-1?null:{channel:e.slice(0,t).trim(),chatId:e.slice(t+1).trim()}}async function Mt(e,t={}){return V(n=>{let a=n.approvals??={};e.defaultExpiryDays!==void 0&&(a.defaultExpiryDays=e.defaultExpiryDays),e.maxExpiryDays!==void 0&&(a.maxExpiryDays=e.maxExpiryDays),e.laterHours!==void 0&&(a.laterHours=e.laterHours),e.notifyAgent!==void 0&&(a.notifyAgent=e.notifyAgent);let r=a.digest??={};e.digestEnabled!==void 0&&(r.enabled=e.digestEnabled),e.digestTime!==void 0&&(r.time=e.digestTime),e.digestTimezone===null?delete r.timezone:e.digestTimezone!==void 0&&(r.timezone=e.digestTimezone),e.destination===null?delete r.destination:e.destination!==void 0&&(r.destination=e.destination);let i=a.defaultExpiryDays??3,l=a.maxExpiryDays??30;if(i>l)throw new Error(`defaultExpiryDays (${i}) can't be more than maxExpiryDays (${l})`)},{configPath:t.configPath,reload:t.reload})}var rt="https://ntfy.sh";function jt(e){return{enabled:!!e?.enabled,server:e?.server||rt,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Lt(e,t){let n={...e??{}};if("enabled"in t&&(n.enabled=!!t.enabled),"server"in t){let a=String(t.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(a))throw new Error("ntfy server must be an http(s) URL");n.server=a}if("topic"in t){let a=String(t.topic).trim();if(!a)throw new Error("ntfy topic cannot be empty");n.topic=a}if("token"in t){let a=String(t.token??"").trim();a?n.token=a:delete n.token}if(n.enabled&&!n.topic)throw new Error("set a topic before enabling ntfy");return n}export{re as a,ce as b,bt as c,yt as d,kt as e,he as f,It as g,Ct as h,Ht as i,Ot as j,Mt as k,jt as l,Lt as m,et as n,Wt as o};
|
|
740
|
+
//# sourceMappingURL=chunk-2GSEEKQK.js.map
|