agentix-cli 0.137.1 → 0.137.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{board-dashboard-VXQYQY22.js → board-dashboard-2A6VSQ7V.js} +2 -2
- package/dist/{chunk-BWXRAPTX.js → chunk-5HLD66CW.js} +2 -2
- package/dist/chunk-A5GYG56I.js +2 -0
- package/dist/chunk-A5GYG56I.js.map +1 -0
- package/dist/{chunk-ADQUFEPJ.js → chunk-ID4DCD2T.js} +67 -67
- package/dist/chunk-ID4DCD2T.js.map +1 -0
- package/dist/chunk-IS2IWRP7.js +4 -0
- package/dist/chunk-IS2IWRP7.js.map +1 -0
- package/dist/{chunk-LK4YO2FE.js → chunk-PNITKKDR.js} +2 -2
- package/dist/{chunk-K6UV4A2T.js → chunk-QY5YUHGW.js} +2 -2
- package/dist/{chunk-Z5OD225A.js → chunk-TEM7IIDC.js} +2 -2
- package/dist/{chunk-36HFRKIH.js → chunk-VDG6Y5L3.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/net-family-X2P3OVDP.js +2 -0
- package/dist/ntfy-Q4YHFKWW.js +2 -0
- package/dist/{program-MJ6S6X6T.js → program-3TO4YAY7.js} +5 -5
- package/dist/{program-MJ6S6X6T.js.map → program-3TO4YAY7.js.map} +1 -1
- package/dist/push-PRFZMCIK.js +2 -0
- package/dist/push-bridge-HNQG2TOI.js +2 -0
- package/dist/wiki-enrich-6776OMUB.js +2 -0
- package/dist/wiki-enrich-6776OMUB.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-ADQUFEPJ.js.map +0 -1
- package/dist/chunk-KQ7KWFZY.js +0 -4
- package/dist/chunk-KQ7KWFZY.js.map +0 -1
- package/dist/ntfy-ZDNBUEIX.js +0 -2
- package/dist/push-HVGOC4VN.js +0 -2
- package/dist/push-bridge-NAQ7WQJX.js +0 -2
- package/dist/wiki-enrich-6CSUPULH.js +0 -2
- /package/dist/{board-dashboard-VXQYQY22.js.map → board-dashboard-2A6VSQ7V.js.map} +0 -0
- /package/dist/{chunk-BWXRAPTX.js.map → chunk-5HLD66CW.js.map} +0 -0
- /package/dist/{chunk-LK4YO2FE.js.map → chunk-PNITKKDR.js.map} +0 -0
- /package/dist/{chunk-K6UV4A2T.js.map → chunk-QY5YUHGW.js.map} +0 -0
- /package/dist/{chunk-Z5OD225A.js.map → chunk-TEM7IIDC.js.map} +0 -0
- /package/dist/{chunk-36HFRKIH.js.map → chunk-VDG6Y5L3.js.map} +0 -0
- /package/dist/{ntfy-ZDNBUEIX.js.map → net-family-X2P3OVDP.js.map} +0 -0
- /package/dist/{push-HVGOC4VN.js.map → ntfy-Q4YHFKWW.js.map} +0 -0
- /package/dist/{push-bridge-NAQ7WQJX.js.map → push-PRFZMCIK.js.map} +0 -0
- /package/dist/{wiki-enrich-6CSUPULH.js.map → push-bridge-HNQG2TOI.js.map} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var w=[1e3,3e3,8e3],b=2e4;function M(e){let t=e,n=t?.message??String(e),s=t?.cause;return s?.code?`${n} code=${s.code}`:s?.message&&s.message!==n?`${n} (${s.message})`:n}var A=new Set(["ECONNREFUSED","ETIMEDOUT","ENETUNREACH","EHOSTUNREACH","EADDRNOTAVAIL","ENOTFOUND","EAI_AGAIN","UND_ERR_CONNECT_TIMEOUT"]);function N(e){let t=e?.cause?.code;return!!t&&A.has(t)}function D(e){return e===429||e===503}function y(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,"utf8").toString("base64")}?=`}function U(e){let t=e.split(`
|
|
2
|
+
`),n=(t[0]??"").trim(),s=t.slice(1).join(`
|
|
3
|
+
`).trim();return s?n.length===0||n.length>80?{body:e.trim()}:{title:n,body:s}:{body:e.trim()}}var p=class{name="ntfy";config;log;constructor(t,n=console.error.bind(console,"[ntfy]")){this.config=t,this.log=n}async start(){this.log(`ntfy: ready (${this.serverUrl()}/${this.config.topic})`)}async stop(){}onMessage(t){}serverUrl(){return(this.config.server||"https://ntfy.sh").replace(/\/+$/,"")}async send(t){let n=(t.chatId||"").trim(),s=n&&n!=="default"?n:this.config.topic;if(!s)throw new Error("ntfy: no topic (pass chatId, or set channels.ntfy.topic)");let f=U(t.text||""),E=f.title||this.config.defaultTitle||"AgentX",c={"Content-Type":"text/plain; charset=utf-8",Title:y(E),Priority:String(this.config.defaultPriority??3)};if(this.config.token&&(c.Authorization=`Bearer ${this.config.token}`),t.parseMode==="markdown"&&(c.Markdown="yes"),t.buttons?.length){let o=t.buttons.slice(0,3).map(i=>`view, ${i.label.replace(/[,;]/g," ")}, ${i.url}`).join("; ");c.Actions=y(o)}let T=`${this.serverUrl()}/${encodeURIComponent(s)}`,$=f.body||t.text||"",d=this.config.retryDelaysMs??w,u=d.length+1,m=this.config.sendTimeoutMs??b,h=Date.now()+m;for(let o=1;;o++){let i,a,l=!1;try{let r=AbortSignal.timeout(Math.max(1,h-Date.now()));i=await fetch(T,{method:"POST",headers:c,body:$,signal:r})}catch(r){a=r?.name==="TimeoutError"?new Error(`ntfy: send time limit of ${m} ms reached`,{cause:r}):new Error(`ntfy: ${M(r)}`,{cause:r}),l=N(r)}if(i){if(i.ok)return(await i.json().catch(()=>null))?.id;let r=await i.text().catch(()=>"");a=new Error(`ntfy: ${i.status} ${r.slice(0,200)}`),l=D(i.status)}let g=d[o-1];if(!l||o>=u||Date.now()+g>=h)throw this.log(`ntfy: send failed after ${o} attempt(s): ${a.message}`),a;this.log(`ntfy: attempt ${o}/${u} failed (${a.message}); retrying in ${g} ms`),await new Promise(r=>setTimeout(r,g))}}};export{M as a,U as b,p as c};
|
|
4
|
+
//# sourceMappingURL=chunk-IS2IWRP7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/channels/ntfy.ts"],"sourcesContent":["import type { ChannelAdapter, IncomingMessage, OutgoingMessage } from \"./types\"\n\n// --- ntfy channel — push notifications to the operator's phone ---\n//\n// Outbound only. ntfy has an inbound side (SSE subscribe), but nothing here\n// wants it: a push notification is a one-way tap on the shoulder, and replies\n// come back through the channels that already carry conversation (Telegram,\n// WhatsApp) or through POST /ask when Siri asks a follow-up.\n//\n// Registering it as a ChannelAdapter rather than a bespoke notifier is what\n// makes it free everywhere: notifications.destination, POST /send, cron\n// failure pings, and the agent-facing `channel` action all funnel through\n// router.sendOutbound() and already know how to address a channel + chatId.\n//\n// Addressing: `chatId` is the ntfy topic. The literal `\"default\"` (and an\n// empty string) resolve to the configured topic instead. That indirection\n// exists so agents never have to carry the topic in their prompts — on the\n// public ntfy.sh the topic IS the credential, and every caller that funnels\n// through the router (POST /send, channel.reply) requires a non-empty chatId.\n\nexport interface NtfyConfig {\n /** Base URL of the ntfy server. Default is the public ntfy.sh. */\n server?: string\n /** Default topic when an OutgoingMessage carries no chatId. */\n topic: string\n /** Access token for protected topics (ntfy `Authorization: Bearer`). */\n token?: string\n /** 1 (min) .. 5 (max). ntfy's default is 3. */\n defaultPriority?: number\n /** Notification title. Per-message titles override it. */\n defaultTitle?: string\n /** Test hook, not in the config schema: waits between attempts when a\n * publish is safe to repeat. One attempt more than there are entries. */\n retryDelaysMs?: number[]\n /** Test hook, not in the config schema: time limit for one send, all\n * attempts and waits included. */\n sendTimeoutMs?: number\n}\n\nconst DEFAULT_RETRY_DELAYS_MS = [1000, 3000, 8000]\nconst DEFAULT_SEND_TIMEOUT_MS = 20_000\n\n/** `fetch failed` hides the reason in `cause`; surface its code so a log\n * line says ETIMEDOUT or ECONNREFUSED rather than nothing useful (#930). */\nexport function describeFetchError(e: unknown): string {\n const err = e as { message?: string; cause?: { code?: string; message?: string } }\n const message = err?.message ?? String(e)\n const cause = err?.cause\n if (cause?.code) return `${message} code=${cause.code}`\n if (cause?.message && cause.message !== message) return `${message} (${cause.message})`\n return message\n}\n\n// A publish is retried only when the server cannot have stored it: ntfy has\n// no key to drop a repeat, so re-posting after a 500 or a reset mid-response\n// could put the same notification on the phone twice.\n\n/** The connection never opened, so the request never reached the server.\n * ETIMEDOUT can also, rarely, mean an open connection went silent; then a\n * repeat is possible. Telling the two apart would need to know whether the\n * body was written, which fetch does not expose. */\nconst CONNECT_FAILURE_CODES = new Set([\n \"ECONNREFUSED\", \"ETIMEDOUT\", \"ENETUNREACH\", \"EHOSTUNREACH\", \"EADDRNOTAVAIL\",\n \"ENOTFOUND\", \"EAI_AGAIN\", \"UND_ERR_CONNECT_TIMEOUT\",\n])\n\nfunction isRetryableFetchError(e: unknown): boolean {\n const code = (e as { cause?: { code?: string } })?.cause?.code\n return !!code && CONNECT_FAILURE_CODES.has(code)\n}\n\n/** 429 and 503 say the server turned the request away without handling it. */\nfunction isRetryableStatus(status: number): boolean {\n return status === 429 || status === 503\n}\n\n/**\n * ntfy requires header values to be ASCII. Titles and tags routinely aren't\n * (French accents, Arabic), so non-ASCII values go out as RFC 2047 encoded\n * words, which ntfy decodes. Pure-ASCII values are passed through untouched\n * so the common case stays readable in logs.\n */\nfunction encodeHeader(value: string): string {\n // eslint-disable-next-line no-control-regex\n if (/^[\\x20-\\x7E]*$/.test(value)) return value\n return `=?UTF-8?B?${Buffer.from(value, \"utf8\").toString(\"base64\")}?=`\n}\n\n/** First line of the body, when it reads like a title (short, no trailing\n * punctuation that implies a sentence continues). Lets an agent write a\n * single blob and still get a well-formed notification. */\nexport function splitTitle(text: string): { title?: string; body: string } {\n const lines = text.split(\"\\n\")\n const first = (lines[0] ?? \"\").trim()\n const rest = lines.slice(1).join(\"\\n\").trim()\n if (!rest) return { body: text.trim() }\n if (first.length === 0 || first.length > 80) return { body: text.trim() }\n return { title: first, body: rest }\n}\n\nexport class NtfyAdapter implements ChannelAdapter {\n readonly name = \"ntfy\"\n private config: NtfyConfig\n private log: (...args: unknown[]) => void\n\n constructor(config: NtfyConfig, log: (...args: unknown[]) => void = console.error.bind(console, \"[ntfy]\")) {\n this.config = config\n this.log = log\n }\n\n async start(): Promise<void> {\n this.log(`ntfy: ready (${this.serverUrl()}/${this.config.topic})`)\n }\n\n async stop(): Promise<void> {}\n\n /** No inbound side — the handler is accepted and never invoked, which\n * satisfies router.addChannel() without pretending to poll. */\n onMessage(_handler: (msg: IncomingMessage) => Promise<void>): void {}\n\n private serverUrl(): string {\n return (this.config.server || \"https://ntfy.sh\").replace(/\\/+$/, \"\")\n }\n\n async send(msg: OutgoingMessage): Promise<string | void> {\n const requested = (msg.chatId || \"\").trim()\n const topic = requested && requested !== \"default\" ? requested : this.config.topic\n if (!topic) throw new Error(\"ntfy: no topic (pass chatId, or set channels.ntfy.topic)\")\n\n const split = splitTitle(msg.text || \"\")\n const title = split.title || this.config.defaultTitle || \"AgentX\"\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"text/plain; charset=utf-8\",\n \"Title\": encodeHeader(title),\n \"Priority\": String(this.config.defaultPriority ?? 3),\n }\n if (this.config.token) headers[\"Authorization\"] = `Bearer ${this.config.token}`\n if (msg.parseMode === \"markdown\") headers[\"Markdown\"] = \"yes\"\n\n // URL buttons map onto ntfy's view actions, so an alert can carry\n // \"open the MR\" without the operator hunting for it.\n if (msg.buttons?.length) {\n const actions = msg.buttons\n .slice(0, 3) // ntfy caps at 3\n .map(b => `view, ${b.label.replace(/[,;]/g, \" \")}, ${b.url}`)\n .join(\"; \")\n headers[\"Actions\"] = encodeHeader(actions)\n }\n\n const url = `${this.serverUrl()}/${encodeURIComponent(topic)}`\n const body = split.body || msg.text || \"\"\n const delays = this.config.retryDelaysMs ?? DEFAULT_RETRY_DELAYS_MS\n const attempts = delays.length + 1\n // Each try can spend several seconds per address on a dead link, so the\n // whole send gets one time limit and callers never wait much past it.\n const limitMs = this.config.sendTimeoutMs ?? DEFAULT_SEND_TIMEOUT_MS\n const deadline = Date.now() + limitMs\n\n // A slow or flapping link loses pushes that a few seconds later would\n // go through. Retry only what cannot have been stored (see above).\n for (let attempt = 1; ; attempt++) {\n let res: Response | undefined\n let failure!: Error\n let retryable = false\n try {\n const signal = AbortSignal.timeout(Math.max(1, deadline - Date.now()))\n res = await fetch(url, { method: \"POST\", headers, body, signal })\n } catch (e) {\n // The abort only says \"aborted due to timeout\"; name the send limit.\n failure = (e as { name?: string })?.name === \"TimeoutError\"\n ? new Error(`ntfy: send time limit of ${limitMs} ms reached`, { cause: e })\n : new Error(`ntfy: ${describeFetchError(e)}`, { cause: e })\n retryable = isRetryableFetchError(e)\n }\n if (res) {\n if (res.ok) {\n const json = await res.json().catch(() => null) as { id?: string } | null\n return json?.id\n }\n const detail = await res.text().catch(() => \"\")\n failure = new Error(`ntfy: ${res.status} ${detail.slice(0, 200)}`)\n retryable = isRetryableStatus(res.status)\n }\n const wait = delays[attempt - 1]\n if (!retryable || attempt >= attempts || Date.now() + wait >= deadline) {\n this.log(`ntfy: send failed after ${attempt} attempt(s): ${failure.message}`)\n throw failure\n }\n this.log(`ntfy: attempt ${attempt}/${attempts} failed (${failure.message}); retrying in ${wait} ms`)\n await new Promise(r => setTimeout(r, wait))\n }\n }\n}\n"],"mappings":"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","names":["DEFAULT_RETRY_DELAYS_MS","DEFAULT_SEND_TIMEOUT_MS","describeFetchError","err","message","cause","CONNECT_FAILURE_CODES","isRetryableFetchError","code","isRetryableStatus","status","encodeHeader","value","splitTitle","text","lines","first","rest","NtfyAdapter","config","log","_handler","msg","requested","topic","split","title","headers","actions","b","url","body","delays","attempts","limitMs","deadline","attempt","res","failure","retryable","signal","e","detail","wait"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Re}from"./chunk-GTJIKXDB.js";import{a as w}from"./chunk-7LN4VKDU.js";import{a as ne}from"./chunk-IMLAPB7G.js";import{q as Kt}from"./chunk-S2GAEH2F.js";import{
|
|
1
|
+
import{a as Re}from"./chunk-GTJIKXDB.js";import{a as w}from"./chunk-7LN4VKDU.js";import{a as ne}from"./chunk-IMLAPB7G.js";import{q as Kt}from"./chunk-S2GAEH2F.js";import{f as Yt,g as Ae,i as V,j as q,l as Zt}from"./chunk-AKWBDCMU.js";import{b as Jt}from"./chunk-WCXXXAHV.js";import{t as Xt,u as Gt}from"./chunk-635B6SXI.js";import{d as Ht,e as zt}from"./chunk-AQASR6KR.js";import{X as Nt,Z as te,_ as ve,aa as $e,b as Se}from"./chunk-3K3LRLZX.js";import{a as Vt,b as qt,d as Bt}from"./chunk-Y4CYQV7G.js";import{a as Lt,b as Ot}from"./chunk-SHEUCITK.js";import{g as Mt,h as jt,i as Wt,k as Ft,l as Ut}from"./chunk-5RHCM3L7.js";import{q as Pt}from"./chunk-23LWLYOK.js";import{a as Ct,b as Dt}from"./chunk-BXXP6DTB.js";import{Aa as Tt,B as $t,C as At,D as Rt,E as _t,ka as xe,n as ee,o as St,p as vt,q as Jr,ra as It,sa as Et}from"./chunk-KHYF6KTY.js";import{a as we,h as Yr}from"./chunk-BRK6M6LA.js";import{f as ke,n as Zr}from"./chunk-UIBUZ2N3.js";import{existsSync as Qr,readdirSync as ei,readFileSync as ti,statSync as ni}from"fs";import{resolve as ri}from"path";function Qt(t,e,n=Date.now(),i=7){let r=i*864e5,s=new Map;for(let o of e){let a=s.get(o.workflowId);a?a.push(o):s.set(o.workflowId,[o])}return t.map(o=>{let a=s.get(o.id)??[],l=a.filter(f=>n-f.at<=r),c=a.filter(f=>n-f.at>r&&n-f.at<=r*2),u=l.filter(f=>f.status==="failed").length,d=a.filter(f=>f.status==="paused").length,p=a.length?Math.max(...a.map(f=>f.at)):null,g=a.length?c.length>0&&l.length===0?"dormant":l.length>0&&u*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:o.id,name:o.name||o.id,state:g,lastRunAt:p,recent:l.length,prior:c.length,failed:u,paused:d}}).sort((o,a)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[o.state]-l[a.state]||(a.lastRunAt??0)-(o.lastRunAt??0)})}var re=new Map;function Ea(t,e=1e3){if(!Qr(t))return[];let n=ei(t).filter(s=>s.endsWith(".jsonl")).map(s=>{let o=ri(t,s);return{path:o,mtime:ni(o).mtimeMs}}).sort((s,o)=>o.mtime-s.mtime).slice(0,e),i=new Set(n.map(s=>s.path));for(let s of re.keys())i.has(s)||re.delete(s);let r=[];for(let{path:s,mtime:o}of n){let a=re.get(s);if(a&&a.mtime===o){a.summary&&r.push(a.summary);continue}let l=ii(s,o);re.set(s,{mtime:o,summary:l}),l&&r.push(l)}return r}function ii(t,e){try{let n=ti(t,"utf-8").split(`
|
|
2
2
|
`).filter(Boolean);if(!n.length)return null;let i=JSON.parse(n[0]),r=i.run?.workflowId;if(!r)return null;let s=i.run?.status??"unknown";for(let o=n.length-1;o>=0;o--){let a=JSON.parse(n[o]),l=a.status??a.run?.status;if(l){s=l;break}}return{workflowId:r,status:s,at:e}}catch{return null}}var si={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},k={routines:200,summary:160,filters:6,filterValue:60,text:120},oi=(t,e,n)=>{try{return Pt(t,e,n)}catch{return null}},en=864e5;function Pa(t){let e=t.now??Date.now(),n={...si,...t.thresholds},i=t.nextFire??oi,r=[];for(let a of t.crons){let l=t.cronRuns.get(a.id)??[],c=a.timezone||"UTC",u=l.map(g=>({at:Date.parse(g.startedAt),status:g.status})),d=l[0],p={id:`cron:${a.id}`,source:"cron",kind:"schedule",name:$(a.id,k.text),trigger:{schedule:$(a.schedule,k.text),timezone:c},agent:a.agent||null,enabled:a.enabled,state:a.enabled?"enabled":"disabled",nextRunAt:a.enabled?_e(a.nextRun)??_e(i(a.schedule,new Date(e),c)):null,lastRun:d?{at:d.startedAt,status:d.status,summary:pi(d.status==="success"?void 0:d.errorSummary,k.summary)}:null,lastSuccessAt:l.find(g=>g.status==="success")?.startedAt??null,consecutiveFailures:tn(u),sampledRuns:l.length,flags:[],attention:null};p.flags=nn(p,u,a.schedule,c,null,e,n,i),r.push(rn(p))}let s=new Map(Qt(t.workflows.map(a=>({id:a.id,name:a.title})),t.workflowRuns,e).map(a=>[a.id,a])),o=new Map;for(let a of t.workflowRuns){let l=o.get(a.workflowId);l?l.push(a):o.set(a.workflowId,[a])}for(let a of t.workflows){let l=a.nodes.find(I=>I.type.startsWith("trigger."));if(!l||l.type!=="trigger.cron"&&l.type!=="trigger.hook")continue;let c=l.config??{},u=a.state||"active",d=u==="active",p=(o.get(a.id)??[]).slice().sort((I,ye)=>ye.at-I.at),g=p.map(I=>({at:I.at,status:ci(I.status)})),f=g[0],h=l.type==="trigger.cron",b=typeof c.spec=="string"?c.spec:"",C=typeof c.timezone=="string"?c.timezone:"UTC",M={id:`workflow:${a.id}`,source:"workflow",kind:h?"schedule":"event",name:$(a.title||a.id,k.text),trigger:h?{schedule:$(b,k.text),timezone:C}:{event:$(typeof c.event=="string"?c.event:"",k.text),filters:di(c.filter,a)},agent:ui(a),enabled:d,state:u,nextRunAt:h&&d&&b?_e(i(b,new Date(e),C)):null,lastRun:f?{at:new Date(f.at).toISOString(),status:f.status}:null,lastSuccessAt:(()=>{let I=g.find(ye=>ye.status==="success");return I?new Date(I.at).toISOString():null})(),consecutiveFailures:tn(g),sampledRuns:p.length,flags:[],attention:null},Q=Date.parse(a.updated||a.created||"");M.flags=h?nn(M,g,b,C,Number.isFinite(Q)?Q:null,e,n,i):ai(M,s.get(a.id)?.state==="dormant",Number.isFinite(Q)?Q:null,e,n),r.push(rn(M))}return r.sort(li).slice(0,k.routines)}function tn(t){let e=0;for(let n of t)if(!(n.status==="running"||n.status==="paused"||n.status==="unknown"))if(n.status==="failed"||n.status==="timeout")e++;else break;return e}function nn(t,e,n,i,r,s,o,a){let l=[],c=e.length?e[0].at:null;if(!t.enabled){let p=on(c,r,s,o);return p&&l.push(p),l}if(t.consecutiveFailures>=o.failStreak&&l.push({reason:"failing",detail:`${t.consecutiveFailures} failed attempts in a row`}),c===null)return l.push({reason:"never-ran",detail:"No persisted attempt"}),l;let u=new Date(c),d=null;for(let p=0;p<o.missedFires&&(d=a(n,u,i),!!d);p++)u=d;return d&&s>d.getTime()+o.graceMs&&l.push({reason:"overdue",detail:`No attempt since ${new Date(c).toISOString()}; ${o.missedFires} scheduled fires missed`}),l}function ai(t,e,n,i,r){let s=[],o=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let a=on(o,n,i,r);return a&&s.push(a),s}return t.consecutiveFailures>=r.failStreak&&s.push({reason:"failing",detail:`${t.consecutiveFailures} failed runs in a row`}),o===null?s.push({reason:"never-ran",detail:"No run recorded for this trigger"}):e&&s.push({reason:"dormant",detail:"Fired in the prior week, silent in the last one"}),s}function on(t,e,n,i){let r=Math.max(t??0,e??0);return r&&n-r<i.disabledDays*en?null:{reason:"disabled-long",detail:r?`Disabled; no activity for ${Math.floor((n-r)/en)} days`:"Disabled and never ran"}}function rn(t){let e=new Set(t.flags.map(n=>n.reason));return t.attention=e.has("failing")?"critical":e.has("overdue")||e.has("dormant")||e.has("never-ran")?"warning":e.has("disabled-long")?"info":null,t}var sn={critical:0,warning:1,info:2};function li(t,e){let n=t.attention?sn[t.attention]:3,i=e.attention?sn[e.attention]:3;return n-i||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function ci(t){switch(t){case"completed":case"ok":return"success";case"failed":return"failed";case"timeout":return"timeout";case"canceled":return"canceled";case"running":return"running";case"paused":return"paused";default:return"unknown"}}function ui(t){if(t.ownerAgent)return $(t.ownerAgent,k.text);let e=t.nodes.find(n=>n.type==="agent"&&typeof n.config?.agentId=="string"&&n.config.agentId);return e?$(String(e.config.agentId),k.text):null}function di(t,e){let n=[],i=e?.project;if(i&&n.push($(`project=${i}`,k.filterValue)),t&&typeof t=="object"&&!Array.isArray(t))for(let[r,s]of Object.entries(t)){let o=Array.isArray(s)?s.map(String):s==null?[]:[String(s)];o.length&&n.push($(`${r}=${o.join(",")}`,k.filterValue))}return n.slice(0,k.filters)}function _e(t){if(!t)return null;let e=t instanceof Date?t:new Date(t);return Number.isFinite(e.getTime())?e.toISOString():null}function $(t,e){return t.length<=e?t:t.slice(0,e-3)+"..."}function pi(t,e){return t===void 0?void 0:$(t,e)}import{existsSync as H,readdirSync as Pi,readFileSync as Ni}from"fs";import{resolve as R}from"path";import{randomBytes as cn}from"crypto";import{existsSync as fi,mkdirSync as mi,readdirSync as hi,readFileSync as bi,renameSync as un,unlinkSync as yi,writeFileSync as wi}from"fs";import{resolve as dn}from"path";function an(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var gi=t=>t.trim().split(`
|
|
3
3
|
`).pop()?.slice(0,300)||"no output";async function ln(t,e,n,i=Re){let r=await i(t.bin,[...an(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return r.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${gi(r.stderr||r.stdout)}`}}async function Oa(t,e,n,i,r=Re){return(await r(t.bin,[...an(t),"--read-only","media","download","--chat",e,"--id",n,"--output",i],{timeoutMs:12e4})).code===0}var ki=2e3,xi=t=>ln(t.wacli,t.to,t.text);function Ie(t){return dn(t,".agentx","whatsapp-triage","drafts")}var Si=t=>/^[a-z0-9-]{8,64}$/.test(t),ie=(t,e)=>dn(Ie(t),`${e}.json`);function pn(t,e){mi(Ie(t),{recursive:!0});let n=ie(t,e.id),i=`${n}.${process.pid}.tmp`;wi(i,JSON.stringify(e,null,2)+`
|
|
4
4
|
`,{mode:384}),un(i,n)}function Va(t,e,n=Date.now()){let i=e.text.trim().slice(0,ki);if(!i)throw new Error("empty draft");let r={...e,text:i,id:`${n.toString(36)}-${cn(4).toString("hex")}`,status:"pending",created_at:new Date(n).toISOString()};return pn(t,r),r}function se(t,e){if(!Si(e))return null;try{return JSON.parse(bi(ie(t,e),"utf-8"))}catch{return null}}function gn(t,e){let n=Ie(t);return fi(n)?hi(n).filter(i=>i.endsWith(".json")).map(i=>se(t,i.slice(0,-5))).filter(i=>!!i&&(!e||i.status===e)).sort((i,r)=>i.created_at.localeCompare(r.created_at)):[]}async function fn(t,e,n,i={}){let r=se(t,e);if(!r||r.status!=="pending")return{ok:!1,error:`no reply draft "${e}" is waiting`};let s=`${ie(t,e)}.${process.pid}.${cn(3).toString("hex")}.claim`;try{un(ie(t,e),s)}catch{return{ok:!1,error:`reply draft "${e}" is already being decided`}}let o={...r,decided_by:i.by??"operator",decided_at:new Date(i.now??Date.now()).toISOString()};if(n==="no")o.status="rejected";else{let a=await(i.send??xi)(r).catch(l=>({ok:!1,error:String(l?.message??l)}));a.ok?o.status="sent":(o.status="failed",o.error=a.error)}pn(t,o);try{yi(s)}catch{}return o.status==="failed"?{ok:!1,error:o.error??"send failed"}:{ok:!0,draft:o}}import{mkdirSync as vi,readFileSync as $i,renameSync as Ai,writeFileSync as Ri}from"fs";import{resolve as _i}from"path";function mn(t){return _i(Ae(t),"_state.json")}function A(t){try{let e=JSON.parse($i(mn(t),"utf-8"));return{snoozed:e&&typeof e.snoozed=="object"&&e.snoozed?e.snoozed:{},...typeof e?.lastDigest=="string"?{lastDigest:e.lastDigest}:{},...e?.popped&&typeof e.popped=="object"?{popped:e.popped}:{},...typeof e?.passAt=="string"?{passAt:e.passAt}:{},...Array.isArray(e?.wanted)?{wanted:e.wanted.filter(n=>typeof n=="string")}:{}}}catch{return{snoozed:{}}}}function B(t,e){vi(Ae(t),{recursive:!0});let n=mn(t),i=`${n}.${process.pid}.tmp`;Ri(i,JSON.stringify(e,null,2)+`
|
|
@@ -529,4 +529,4 @@ Document the arguments, commands, or files the skill expects. Example:
|
|
|
529
529
|
claude-code ${xt(t)} --arg value
|
|
530
530
|
\`\`\`
|
|
531
531
|
`}Tt();var zr={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function Xr(t){return{...zr,...t??{},regions:{...t?.regions??{}},buffer:{...zr.buffer,...t?.buffer??{}}}}function td(t){try{return Xr(Et(t).screen)}catch{return Xr(void 0)}}var Ra=/^[a-z][\w-]*$/,Gr=["window","screen","menubar","notifications"];function Z(t,e,n,i){let r=Number(t);if(t===""||t===null||!Number.isFinite(r)||!n(r))throw new Error(`${e} must be ${i}`);return r}var be=(t,e)=>Z(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function Kr(t){let e=typeof t=="string"?t.split(",").map(Number):[t?.x,t?.y,t?.width,t?.height].map(Number);if(e.length!==4||!e.every(Number.isFinite)||e[2]<=0||e[3]<=0)throw new Error("a region is x,y,width,height in screen points, with width and height above 0");return{x:e[0],y:e[1],width:e[2],height:e[3]}}function nd(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=be(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=be(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=be(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=Z(e.stableMs,"stableMs",r=>Number.isInteger(r)&&r>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=Z(e.changeThreshold,"changeThreshold",r=>r>=0&&r<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let r={...n.regions??{}};for(let[s,o]of Object.entries(e.regions)){if(!Ra.test(s))throw new Error(`region name "${s}" must be lowercase letters, digits, - or _`);o===null?delete r[s]:r[s]=Kr(o)}n.regions=r}if(e.buffer&&typeof e.buffer=="object"){let r=e.buffer,s={...n.buffer??{}};"enabled"in r&&(s.enabled=!!r.enabled),"seconds"in r&&(s.seconds=Z(r.seconds,"buffer.seconds",o=>o>0&&o<=120,"above 0 and at most 120")),"fps"in r&&(s.fps=Z(r.fps,"buffer.fps",o=>o>0&&o<=10,"above 0 and at most 10")),"maxPixels"in r&&(s.maxPixels=be(r.maxPixels,"buffer.maxPixels")),"region"in r&&(s.region=String(r.region).trim()),n.buffer=s}let i=n.buffer?.region;if(i!==void 0&&!Gr.includes(i)&&!n.regions?.[i])try{Kr(i)}catch{throw new Error(`buffer.region "${i}" is not a region \u2014 use ${[...Gr,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{Qt as a,Ea as b,tt as c,Ks as d,Js as e,mc as f,hc as g,bc as h,ar as i,wc as j,xc as k,D as l,lr as m,k as n,Pa as o,Oa as p,xi as q,Va as r,fn as s,A as t,Xa as u,Ga as v,Ya as w,oe as x,Za as y,xn as z,il as A,z as B,wl as C,kl as D,_n as E,cr as F,$c as G,_c as H,vr as I,eu as J,tu as K,au as L,qo as M,lu as N,Sl as O,vl as P,$l as Q,Al as R,Rl as S,_l as T,El as U,Tl as V,Wl as W,Me as X,Fl as Y,Ul as Z,X as _,G as $,Ko as aa,bu as ba,yu as ca,wu as da,ku as ea,ct as fa,xu as ga,Fe as ha,Ue as ia,pe as ja,ms as ka,bs as la,zl as ma,qe as na,Be as oa,ys as pa,ws as qa,Xn as ra,Yn as sa,Xl as ta,Ss as ua,Gl as va,Ts as wa,Ps as xa,He as ya,Ls as za,Zn as Aa,P as Ba,Lr as Ca,Or as Da,Mr as Ea,_u as Fa,ia as Ga,Wr as Ha,Fr as Ia,ju as Ja,Wu as Ka,ka as La,Fu as Ma,Vr as Na,ge as Oa,oc as Pa,ir as Qa,ze as Ra,Qe as Sa,gc as Ta,Bu as Ua,Hu as Va,zu as Wa,Xu as Xa,Gu as Ya,Ku as Za,Ju as _a,Yu as $a,Zu as ab,zr as bb,Xr as cb,td as db,Gr as eb,nd as fb};
|
|
532
|
-
//# sourceMappingURL=chunk-
|
|
532
|
+
//# sourceMappingURL=chunk-PNITKKDR.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Re,b as w,c as z,d as Pe,e as ie,f as se,g as M,h as le,i as N,j as O,n as De,o as ze,p as _e,q as We}from"./chunk-H4NSB54D.js";import{b as oe}from"./chunk-MTX4UPNB.js";import{e as Ee,i as Te}from"./chunk-QAWKN2N4.js";import{c as Ie,d as ae,e as T,f as re,g as B}from"./chunk-B2QYMUTD.js";import{a as G,b as Ce}from"./chunk-GIQKQD2B.js";import{a as Se}from"./chunk-7LN4VKDU.js";import{a as Ae}from"./chunk-IMLAPB7G.js";import{b as xe}from"./chunk-WCXXXAHV.js";import{c as ye,e as we}from"./chunk-LQE73AZR.js";import{b as $e}from"./chunk-MRIVENBY.js";import{
|
|
1
|
+
import{a as Re,b as w,c as z,d as Pe,e as ie,f as se,g as M,h as le,i as N,j as O,n as De,o as ze,p as _e,q as We}from"./chunk-H4NSB54D.js";import{b as oe}from"./chunk-MTX4UPNB.js";import{e as Ee,i as Te}from"./chunk-QAWKN2N4.js";import{c as Ie,d as ae,e as T,f as re,g as B}from"./chunk-B2QYMUTD.js";import{a as G,b as Ce}from"./chunk-GIQKQD2B.js";import{a as Se}from"./chunk-7LN4VKDU.js";import{a as Ae}from"./chunk-IMLAPB7G.js";import{i as ne,k as ke}from"./chunk-AKWBDCMU.js";import{b as xe}from"./chunk-WCXXXAHV.js";import{c as ye,e as we}from"./chunk-LQE73AZR.js";import{b as $e}from"./chunk-MRIVENBY.js";import{G as K}from"./chunk-3K3LRLZX.js";import{a as L,b as F}from"./chunk-BXXP6DTB.js";import{a as ve}from"./chunk-RWMDDMYX.js";import{a as be}from"./chunk-ROLSSYXE.js";import{A as me,Aa as te,E as dt,V as fe,aa as ct,pa as ee,ra as H,sa as he,z as Z}from"./chunk-KHYF6KTY.js";import{existsSync as j,readFileSync as Oe,writeFileSync as Ue,appendFileSync as ut,mkdirSync as mt}from"fs";import{dirname as ft,resolve as _}from"path";import{fileURLToPath as ht}from"url";import{hostname as bt}from"os";import{spawn as vt}from"child_process";function Me(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">
|
|
2
2
|
<div class="ax-topbar__left">
|
|
3
3
|
<div class="ax-brand">
|
|
4
4
|
<span class="ax-brand__mark">AX</span>
|
|
@@ -858,4 +858,4 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
858
858
|
WHERE person = ? AND state IN (${n.map(()=>"?").join(",")})
|
|
859
859
|
${a}`).all(t,...n,...o).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function ga(e,t){return et(e,t,Z,"ORDER BY created_at")}function ua(e,t,n=50){return et(e,t,[...Z,...me],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(n,500)))}ct();var ue="member:",Yt=90,Vt="members",Xt="tailscale-user-login",Qt=400,Zt=60*60*1e3;function en(e){let t=e.scopes.find(n=>n.startsWith(ue));return t?t.slice(ue.length):null}function nt(e,t){if(!e)return null;let n=t.verify(e),a=n?en(n):null;return n&&a?{rec:n,personId:a}:null}function ya(e,t){let n=e.people().find(s=>s.id===t);if(!n)return{ok:!1,error:`No person "${t}". Add them first: agentx people add ${t} --name "\u2026"`};let{token:a,record:o}=e.tokens.create({name:`${n.name} (machine not paired yet)`,scopes:[`${ue}${n.id}`],expiresInDays:Yt}),{code:r,expiresAt:i}=e.codes.create({token:a,tokenId:o.id,name:n.id});return e.members.log({person:n.id,device:o.id,event:"invited"}),{ok:!0,code:r,expiresAt:i,tokenId:o.id,person:n}}var tn=Math.round(ye/6e4);function nn(e){return e==="client"?"Your project":"My work"}function wa(e){let t=nn(e.person.role),n=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${t}": what you asked us for, and where each request stands.`:`I use AgentX to give our AI agents their jobs. It has a page for you, "${t}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",n,"","To open it:","1. Accept the Tailscale share I sent you. Tailscale is a small program that connects your computer to mine, privately.",`2. Open ${e.origin.replace(/\/+$/,"")}/member in Edge or Chrome, give your computer a name and type this code: ${we(e.code)}`,` The code works once, for ${tn} minutes. If it has stopped working, tell me and I will send you a new one.`,"","I then approve your machine, and the page opens by itself."].join(`
|
|
860
860
|
`)}var an="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",rn="Too many machines are waiting for the owner's answer. Try again later.",tt="That code didn't work. Check it, or ask the person who invited you for a new one.",at=(e,t)=>{let n=e.headers[t];return(Array.isArray(n)?n[0]:n||"").trim()};function rt(e){let t=e.socket?.remoteAddress||"";return t==="127.0.0.1"||t==="::1"||t==="::ffff:127.0.0.1"}function on(e){if(!rt(e))return null;let t=at(e,Xt).toLowerCase();return t?t.slice(0,80):null}function sn(e){let t=e.socket?.remoteAddress||"unknown";if(!rt(e))return t;let n=at(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(n)?n:t}function ln(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function dn(e){return e.identities.map(fe).filter(t=>!!t&&t.channel==="tailscale").map(t=>t.value)}async function ka(e,t){let n=Date.now(),a=t.now??Date.now,o=t.log??(b=>console.log(b)),r=sn(e),i=t.limiter.retryAfter(r);if(i>0)return o(`[member] pair-code refused from ${r}: locked out for ${i}s more`),{status:429,body:{error:"too many attempts",retryAfter:i},retryAfter:i};let s=null,l="";try{let b=await xe(e,2048);s=b.code,l=ln(b.machine)}catch{}let c=t.codes.redeem(s),d=c?nt(c.token,t.tokens):null;if(await pn(n,t.minMs??Qt),!c||!d)return t.limiter.fail(r),o(`[member] pair-code failed from ${r}`),{status:401,body:{error:tt}};t.limiter.succeed(r);let{rec:m,personId:p}=d,k=t.people().find(b=>b.id===p);if(!k)return t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:"person no longer listed"}),o(`[member] pair-code for ${p} refused from ${r}: person no longer listed`),{status:403,body:{error:tt}};let u=on(e),f=dn(k);if(f.length&&(!u||!f.includes(u)))return t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:`network login ${u??"missing"}; expected ${f.join(" or ")}`}),o(`[member] ${p}: pairing from ${r} refused: the network says "${u??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:an}};let I=l||"Unnamed machine",x=k.name.slice(0,40),v=ke(t.root,{title:`New machine for ${x}`,ask:`From ${r}, ${u?`network login ${u}`:"no network login reported"}. Machine name, as typed there: "${I}". Let it see ${x}'s own work?`,recommend:`Yes if ${x} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:Vt},{now:a()});return v.ok?(t.members.add({tokenId:m.id,personId:p,name:I,state:"pending",cardId:v.card.id,address:r,...u?{network:u}:{},createdAt:new Date(a()).toISOString()}),t.members.log({person:p,device:m.id,event:"paired",address:r,detail:I}),o(`[member] ${p} paired "${I}" from ${r}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:p,name:I,state:"pending"},token:c.token}):(t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:v.error}),o(`[member] ${p}: pairing from ${r} refused: ${v.error}`),{status:503,body:{error:rn}})}var Q="this machine is not paired",cn="waiting for the owner to approve this machine";function ot(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function $a(e,t){return t.state==="pending"&&t.cardId?ot(ne(e,t.cardId)):null}function Aa(e,t,n){let a=t.now??Date.now,o=t.log??(d=>console.log(d)),r=nt(e,t.tokens);if(!r)return{ok:!1,status:401,error:Q};let{rec:i,personId:s}=r,l=t.members.byToken(i.id);if(!l||l.state==="removed"||l.personId!==s)return{ok:!1,status:401,error:Q};if(t.people&&!t.people().some(d=>d.id===s))return it(t,i.id,"person no longer listed"),o(`[member] ${s}: "${l.name}" ended: person no longer listed`),{ok:!1,status:401,error:Q};if(l.state==="pending"){let d=l.cardId?ne(t.root,l.cardId):null,m=ot(d);if(m==="yes")l=t.members.update(i.id,{state:"active",approvedAt:new Date(a()).toISOString()})??l,t.members.log({person:s,device:i.id,event:"approved",detail:d?.decided_by}),o(`[member] ${s}: "${l.name}" approved`);else if(m==="no"){let p=d?.status==="expired"?"the owner did not answer in time":"the owner said no";return t.tokens.revoke(i.id),t.members.update(i.id,{state:"removed",removedAt:new Date(a()).toISOString(),removedReason:p}),t.members.log({person:s,device:i.id,event:"refused",detail:p}),o(`[member] ${s}: "${l.name}" refused: ${p}`),{ok:!1,status:401,error:Q}}else return{ok:!1,status:403,error:cn,waiting:!0}}let c=l.lastSeenAt?Date.parse(l.lastSeenAt):0;return n&&(a()-c>=Zt||l.lastAddress!==n)&&(l=t.members.update(i.id,{lastSeenAt:new Date(a()).toISOString(),lastAddress:n})??l,t.members.log({person:s,device:i.id,event:"signed-in",address:n})),{ok:!0,device:l,personId:s,rec:i}}function it(e,t,n="removed by the owner"){let a=e.members.byToken(t);if(!a)return null;e.tokens.revoke(t);let o=e.members.update(t,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:n});return e.members.log({person:a.personId,device:t,event:"removed",detail:n}),o}function Sa(e,t){return e.members.devices(t).filter(n=>n.state!=="removed").map(n=>it(e,n.tokenId,"person removed by the owner")).filter(n=>!!n)}async function pn(e,t){let n=e+t-Date.now();n>0&&await new Promise(a=>setTimeout(a,n))}var st=["gitlab","github"];function gn(e,t,n){let a=String(t||"").trim().toLowerCase();if(!st.includes(a))throw new Error(`Request status works on ${st.join(" and ")}, not on "${t}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let o=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(r=>String(r).toLowerCase()):[];return e.requestStatus.channels=n?[...new Set([...o,a])]:o.filter(r=>r!==a),`request status on ${a} is ${n?"on":"off"}`}function Ea(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(t=>String(t).toLowerCase()):[]}function Ta(e){let{summary:t}=G(n=>gn(n,e?.channel,!!e?.enabled));return{summary:t}}function Pa(e){return new Set(Object.entries(e).filter(([,t])=>t?.wiki?.absorb?.enabled===!1).map(([t])=>t))}function Da(e,t){return t.only?{agents:[t.only],skipped:[]}:{agents:e.filter(n=>!t.off.has(n)),skipped:e.filter(n=>t.off.has(n))}}function za(e,t){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===t?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function _a(e,t){if(t){if(!e.wiki?.absorb)return;delete e.wiki.absorb.enabled,Object.keys(e.wiki.absorb).length===0&&delete e.wiki.absorb,Object.keys(e.wiki).length===0&&delete e.wiki;return}e.wiki??={},e.wiki.absorb??={},e.wiki.absorb.enabled=!1}var un="https://ntfy.sh";function Ma(e){return{enabled:!!e?.enabled,server:e?.server||un,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Na(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{Be as a,An as b,Sn as c,In as d,Pn as e,Dn as f,zn as g,pa as h,ga as i,ua as j,Yt as k,ya as l,tn as m,nn as n,wa as o,sn as p,ka as q,$a as r,Aa as s,it as t,Sa as u,st as v,gn as w,Ea as x,Ta as y,Pa as z,Da as A,za as B,_a as C,Ma as D,Na as E,Ht as F,ta as G,sa as H,la as I};
|
|
861
|
-
//# sourceMappingURL=chunk-
|
|
861
|
+
//# sourceMappingURL=chunk-QY5YUHGW.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as d,g}from"./chunk-WCXXXAHV.js";import{a as f}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as d,g}from"./chunk-WCXXXAHV.js";import{a as f}from"./chunk-5HLD66CW.js";var k=/^[A-Za-z0-9._-]{1,64}$/,m=/^[A-Za-z0-9_-]{1,64}$/,A=100,w=1e3,E=6e4,P=15*6e4;function p(r){return(r.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"node").slice(0,64)}function _(r,t,n){let i=/^bearer /i.test(r)?r.slice(7).trim():"",e="Phones paired with another computer need that computer's own peer token: give it a token in mesh.peers on both computers.";if(!i||n&&i===n)return{error:e};let a=new Set(t.filter(s=>s.token===i).map(s=>p(s.name)));if(a.size===0)return{error:e};if(a.size>1)return{error:`Several mesh.peers entries share this token (${[...a].join(", ")}). Give each computer its own token.`};let[o]=a,u=t.filter(s=>s.token!==i&&p(s.name)===o).map(s=>s.name);return u.length?{error:`mesh.peers names ${u.map(s=>`"${s}"`).join(", ")} too close to this computer's name: rename one so they differ in letters or digits.`}:{origin:o}}function C(r,t){let n=r.indexOf(":");return n<0?{ok:!0}:"error"in t?{error:t.error}:r.slice(0,n)!==t.origin?{error:`${r} is a phone paired with another computer; only that computer can send to it.`}:{ok:!0}}function x(r,t,n){let i=r.toLowerCase(),e=t.find(a=>a.name.toLowerCase()===i);return e?e.token?n&&e.token===n?`mesh.peers "${e.name}" uses the shared MESH_TOKEN, so phones paired here can't turn notifications on. Give this pair a token of its own on both computers.`:null:`mesh.peers "${e.name}" has no token, so phones paired here can't turn notifications on. Give it a token of its own on both computers.`:null}function O(r){return new Set(r.map(t=>p(t.name)))}function j(r,t,n,i){let e=r&&typeof r=="object"?r:{};if("error"in t)return{status:403,body:{error:t.error}};let a=t.origin;if(!k.test(a))return{status:403,body:{error:"this peer's name can't be used as a notification origin"}};if(!n)return{status:503,body:{error:i??"Notifications are not set up on the computer that sends them."}};if(e.op==="roster"){if(!Array.isArray(e.active)||e.active.length>w||!e.active.every(l=>typeof l=="string"&&m.test(l)))return{status:400,body:{error:"active must be a list of device ids"}};let h=n.store();return h?{status:200,body:{ok:!0,removed:h.pruneOrigin(a,e.active)}}:{status:503,body:{error:n.reason??"the database is unavailable"}}}if(e.op!=="app")return{status:400,body:{error:"op must be app or roster"}};let o=e.call&&typeof e.call=="object"?e.call:{},u=o.device&&typeof o.device=="object"?o.device:{},s=typeof o.path=="string"?o.path:"",c=o.method==="GET"||o.method==="POST"?o.method:"";if(!d(s)||!c)return{status:404,body:{error:"not found"}};if(typeof u.id!="string"||!m.test(u.id))return{status:400,body:{error:"device.id is required"}};let b=typeof u.name=="string"&&u.name.trim()?u.name.trim():u.id,v=o.body&&typeof o.body=="object"&&!Array.isArray(o.body)?o.body:{};return g({path:s,method:c,body:v,device:{id:f(a,u.id),name:S(`${b} (${a})`,A)}},n)}var y=class{constructor(t){this.deps=t}lastKey=null;lastSentAt=0;failing=!1;async tick(){let t=(this.deps.now??Date.now)(),n;try{n=[...new Set(this.deps.active())].sort()}catch(e){return this.deps.log?.(`push: phone list not read, not sent this time: ${e?.message??e}`),!1}let i=n.join(",");if(i===this.lastKey&&t-this.lastSentAt<P)return!1;try{let e=await this.deps.send(n);if(e&&typeof e=="object"&&typeof e.status=="number"&&e.status!==200)throw new Error(`${e.status} ${typeof e.body?.error=="string"?e.body.error:"refused"}`);return this.lastKey=i,this.lastSentAt=t,this.failing&&this.deps.log?.("push: phone list sent to the push host again"),this.failing=!1,!0}catch(e){return this.failing||this.deps.log?.(`push: phone list not sent to the push host, retrying every minute: ${e?.message??e}`),this.failing=!0,!1}}};function S(r,t){let n=[...r];return n.length>t?n.slice(0,t-1).join("")+"\u2026":r}export{E as a,P as b,p as c,_ as d,C as e,x as f,O as g,j as h,y as i};
|
|
2
|
+
//# sourceMappingURL=chunk-TEM7IIDC.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import t from"chalk";import{spawn as S}from"child_process";import{resolve as j}from"path";var E=l=>l||j(process.cwd(),".agentx/wiki");function N(l){return async d=>{let{claudeCliEnv:e}=await import("./workspace-env-ROH45HXN.js"),h=["-p","-","--output-format","json","--max-turns","1","--model",l,"--tools","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--settings",'{"disableAllHooks":true}',"--setting-sources","","--no-session-persistence"],y=await new Promise(($,a)=>{let s=S("claude",h,{env:e(),stdio:["pipe","pipe","pipe"]}),p="",g="",i=setTimeout(()=>s.kill("SIGTERM"),24e4);s.stdout.on("data",r=>{p+=r}),s.stderr.on("data",r=>{g+=r}),s.on("error",r=>{clearTimeout(i),a(r)}),s.on("close",r=>{clearTimeout(i),r===0?$(p):a(new Error(`claude exited ${r}: ${g.trim().slice(0,200)}`))}),s.stdin.end(d)}),c=JSON.parse(y);if(c.is_error)throw new Error(`model error: ${String(c.result).slice(0,200)}`);return{text:String(c.result??""),costUsd:Number(c.total_cost_usd)||0}}}function I(l){l.command("enrich [entities...]").description("write a full overview, sourced typed facts and linked history on entity pages (person, organization, project, place, assets)").option("--dir <path>","wiki directory (default .agentx/wiki)").option("--types <list>","comma-separated entity types","person,organization,project,place,device,server,app,domain,account").option("--max <n>","most entities per run","10").option("--max-cost <usd>","stop before the next call once the run spent this much","1").option("--model <m>","model","sonnet").option("--force","redo entities whose sources did not change").option("--dry-run","show what would be written, write nothing").option("--create <title>","first create a page for a thing other pages only name, then enrich it (needs --as and --owner)").option("--as <type>","type of the page --create makes, e.g. organization").option("--owner <agent>","agent whose wiki gets the page --create makes").option("--json","print the run as JSON").action(async(d,e)=>{let{WikiHub:h}=await import("./hub-N5ADP3LO.js"),{GraphCache:y}=await import("./graph-ZVKV3JBD.js"),{loadOntology:c}=await import("./load-LQ2I2PQI.js"),{loadRoster:$}=await import("./roster-BZGKG2ZA.js"),{ENRICH_TYPES:a,loadEnrichState:s,runEnrich:p,saveEnrichState:g}=await import("./enrich-R2LIDLPZ.js"),i=E(e.dir),r=e.types.split(",").map(o=>o.trim()).filter(Boolean),b=r.filter(o=>!a.includes(o));if(b.length){console.error(t.red(` not an entity type this job handles: ${b.join(", ")} (use ${a.join(", ")})`)),process.exitCode=1;return}let x=Number(e.max);if(!Number.isInteger(x)||x<1){console.error(t.red(" --max must be a whole number of entities, 1 or more")),process.exitCode=1;return}let w=Number(e.maxCost);if(!Number.isFinite(w)||w<=0){console.error(t.red(" --max-cost must be a positive number of dollars")),process.exitCode=1;return}let m=new h(i,()=>{});if(e.create){let{createEntityPage:o}=await import("./enrich-R2LIDLPZ.js");if(!e.as||!a.includes(e.as)||!e.owner){console.error(t.red(` --create needs --as <${a.join("|")}> and --owner <agent>`)),process.exitCode=1;return}if(m.syncedFrom(e.owner)){console.error(t.red(` ${e.owner}'s pages are copied from another node; pick an agent that runs here`)),process.exitCode=1;return}if(e.dryRun)console.log(t.dim(` --dry-run: would create "${e.create}" (${e.as}) in ${e.owner}'s wiki`));else{let f=o(m,e.create,e.as,e.owner,new Date().toISOString().slice(0,10));console.log(f?t.green(` created ${e.owner}/${f}`):t.dim(` ${e.owner} already has a page titled "${e.create}"`))}d=[...d,e.create],r.includes(e.as)||r.push(e.as)}let{ontology:v}=c(i),k=new y().get(m,v,$(i,m.listAgents([]),v.agent_names)),C=s(i),u=await p(m,k,N(e.model),{types:r,only:d,max:x,maxCostUsd:w,dryRun:!!e.dryRun,force:!!e.force,today:new Date().toISOString().slice(0,10),save:o=>g(i,o)},C);if(e.json){console.log(JSON.stringify(u,null,2));return}for(let o of u.outcomes){let f=o.status==="written"?t.green("\u2713"):o.status==="dry-run"?t.cyan("~"):t.yellow("\xB7");console.log(` ${f} ${o.title} ${t.dim(`${o.status} \xB7 ${o.page??"no page"} \xB7 overview ${o.overview?"yes":"no"} \xB7 ${o.statements} facts \xB7 ${o.links} links \xB7 $${o.costUsd.toFixed(3)}`)}`);for(let n of o.facts??[])console.log(t.dim(` fact: ${n.property} \u2192 ${n.value}${n.role?` (${n.role})`:""} \xB7 source ${n.source}`));for(let n of o.dropped.slice(0,6))console.log(t.dim(` dropped: ${n}`));o.preview&&console.log(t.dim(o.preview.split(`
|
|
2
2
|
`).slice(0,12).map(n=>` | ${n}`).join(`
|
|
3
3
|
`)))}u.outcomes.length===0&&console.log(t.dim(" nothing to do: no entity of these types changed since the last run (--force redoes them)")),console.log(t.dim(` spent $${u.costUsd.toFixed(3)} of $${w}${u.capped?" \xB7 stopped at the cap":""}`))})}export{N as a,I as b};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-VDG6Y5L3.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var
|
|
2
|
+
import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-3TO4YAY7.js"),{installCliSignalExit:r}=await import("./signal-exit-WL7G3EEZ.js"),{applyConnectAttemptTimeout:i,configPathFromArgv:a,readConnectAttemptTimeout:n}=await import("./net-family-X2P3OVDP.js");r();i(n(process.cwd(),a(process.argv.slice(2))));var t=await s();process.argv.slice(2).length===0?t.outputHelp():t.parse();
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { unsupportedNodeMessage } from \"@/utils/node-version\"\n\n// Static imports load before any code here runs, and a dependency fails to\n// load on an old Node. So the check comes first and the rest is imported after.\nconst refusal = unsupportedNodeMessage(process.versions.node)\nif (refusal) {\n console.error(refusal)\n process.exit(1)\n}\n\nconst { buildProgram } = await import(\"@/program\")\nconst { installCliSignalExit } = await import(\"@/utils/signal-exit\")\n\ninstallCliSignalExit()\n\nconst program = await buildProgram()\n\nif (process.argv.slice(2).length === 0) {\n program.outputHelp()\n} else {\n program.parse()\n}\n"],"mappings":";oEAKA,IAAMA,EAAUC,EAAuB,QAAQ,SAAS,IAAI,EACxDD,IACF,QAAQ,MAAMA,CAAO,EACrB,QAAQ,KAAK,CAAC,GAGhB,GAAM,CAAE,aAAAE,CAAa,EAAI,KAAM,QAAO,uBAAW,EAC3C,CAAE,qBAAAC,CAAqB,EAAI,KAAM,QAAO,2BAAqB,
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { unsupportedNodeMessage } from \"@/utils/node-version\"\n\n// Static imports load before any code here runs, and a dependency fails to\n// load on an old Node. So the check comes first and the rest is imported after.\nconst refusal = unsupportedNodeMessage(process.versions.node)\nif (refusal) {\n console.error(refusal)\n process.exit(1)\n}\n\nconst { buildProgram } = await import(\"@/program\")\nconst { installCliSignalExit } = await import(\"@/utils/signal-exit\")\nconst { applyConnectAttemptTimeout, configPathFromArgv, readConnectAttemptTimeout } = await import(\"@/daemon/net-family\")\n\ninstallCliSignalExit()\n// CLI commands that call out on their own need the same connect attempt\n// timeout as the daemon, or they fail on a slow dual-stack link (#930).\n// Read the file the command was pointed at, so a daemon started with\n// --config gets its own value and not the default first.\napplyConnectAttemptTimeout(readConnectAttemptTimeout(process.cwd(), configPathFromArgv(process.argv.slice(2))))\n\nconst program = await buildProgram()\n\nif (process.argv.slice(2).length === 0) {\n program.outputHelp()\n} else {\n program.parse()\n}\n"],"mappings":";oEAKA,IAAMA,EAAUC,EAAuB,QAAQ,SAAS,IAAI,EACxDD,IACF,QAAQ,MAAMA,CAAO,EACrB,QAAQ,KAAK,CAAC,GAGhB,GAAM,CAAE,aAAAE,CAAa,EAAI,KAAM,QAAO,uBAAW,EAC3C,CAAE,qBAAAC,CAAqB,EAAI,KAAM,QAAO,2BAAqB,EAC7D,CAAE,2BAAAC,EAA4B,mBAAAC,EAAoB,0BAAAC,CAA0B,EAAI,KAAM,QAAO,0BAAqB,EAExHH,EAAqB,EAKrBC,EAA2BE,EAA0B,QAAQ,IAAI,EAAGD,EAAmB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,EAE9G,IAAME,EAAU,MAAML,EAAa,EAE/B,QAAQ,KAAK,MAAM,CAAC,EAAE,SAAW,EACnCK,EAAQ,WAAW,EAEnBA,EAAQ,MAAM","names":["refusal","unsupportedNodeMessage","buildProgram","installCliSignalExit","applyConnectAttemptTimeout","configPathFromArgv","readConnectAttemptTimeout","program"]}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt,la as Tt,ma as Mt}from"./chunk-
|
|
1
|
+
import{a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt,la as Tt,ma as Mt}from"./chunk-ID4DCD2T.js";import"./chunk-PNITKKDR.js";import"./chunk-GTJIKXDB.js";import"./chunk-Z2QOQBUS.js";import"./chunk-7LN4VKDU.js";import"./chunk-IMLAPB7G.js";import"./chunk-ZVP6GB4G.js";import"./chunk-S2GAEH2F.js";import"./chunk-UNIXYV3U.js";import"./chunk-AKWBDCMU.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-EMGB23H5.js";import"./chunk-TEM7IIDC.js";import"./chunk-WCXXXAHV.js";import"./chunk-JWDJMFU6.js";import"./chunk-5HLD66CW.js";import"./chunk-IS2IWRP7.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-MRIVENBY.js";import"./chunk-A5GYG56I.js";import"./chunk-635B6SXI.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import{ca as yt,m as lt,n as ct,o as dt,p as mt,q as pt}from"./chunk-5ADXRVYT.js";import"./chunk-3K3LRLZX.js";import"./chunk-QSKG754X.js";import"./chunk-MEFPXHQJ.js";import{a as L}from"./chunk-UG2OF2EI.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-ZYUVKFX2.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-Y4CYQV7G.js";import"./chunk-LLNPKE7H.js";import"./chunk-SHEUCITK.js";import"./chunk-5RHCM3L7.js";import"./chunk-SZDACK6O.js";import"./chunk-HF5EF335.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-23LWLYOK.js";import"./chunk-BXXP6DTB.js";import"./chunk-3UOTLMXD.js";import"./chunk-36AXN6ZB.js";import"./chunk-PE5V2LI7.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-VWTBHLMX.js";import"./chunk-RWMDDMYX.js";import{a as ht}from"./chunk-MXDWLBIA.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-PNYBZPPB.js";import"./chunk-SKSYII3K.js";import{f as gt,g as ft}from"./chunk-E3AEOQMK.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-7JUISIE7.js";import{j as it,k as rt,l as at}from"./chunk-SQ37I2MD.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-6TURWSMN.js";import"./chunk-AV7T3SYT.js";import"./chunk-Y5MFVVTM.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-2PJKGZWP.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{Aa as nt,qa as tt,sa as st,ta as ot}from"./chunk-KHYF6KTY.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
|
|
2
2
|
`)}
|
|
3
3
|
|
|
4
4
|
${t}`}async function It(o){let{loadLocalSkills:e}=await import("./loader-YFVSSYSL.js");return e(o)}async function Ot(o,e,t,s,i){let a=[{role:"system",content:`You are a skill author for the Agent Skills ecosystem (skills.sh).
|