agentix-cli 0.203.0 → 0.204.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{board-dashboard-MHZJRW3Z.js → board-dashboard-AVUFPO5X.js} +476 -370
- package/dist/board-dashboard-AVUFPO5X.js.map +1 -0
- package/dist/chunk-B6VASQHD.js +2 -0
- package/dist/chunk-B6VASQHD.js.map +1 -0
- package/dist/{chunk-WK54XQAJ.js → chunk-EANSYWBQ.js} +236 -236
- package/dist/{chunk-WK54XQAJ.js.map → chunk-EANSYWBQ.js.map} +1 -1
- package/dist/{chunk-SY7R5N7U.js → chunk-Y4YOYOCG.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/connect-AJKMRKXC.js +2 -0
- package/dist/connect-AJKMRKXC.js.map +1 -0
- package/dist/daemon-api-OVCXY4QC.js +2 -0
- package/dist/daemon-api-OVCXY4QC.js.map +1 -0
- package/dist/{doctor-QASDCIQ5.js → doctor-EDZO7BUJ.js} +2 -2
- package/dist/index.d.ts +14 -14
- package/dist/index.js +1 -1
- package/dist/{program-3DRLVXOO.js → program-OFN6YQRH.js} +7 -7
- package/dist/program-OFN6YQRH.js.map +1 -0
- package/dist/providers-AHLCB6R5.js +2 -0
- package/package.json +1 -1
- package/dist/board-dashboard-MHZJRW3Z.js.map +0 -1
- package/dist/chunk-U2WAIDSM.js +0 -2
- package/dist/chunk-U2WAIDSM.js.map +0 -1
- package/dist/connect-JIWRIGVI.js +0 -2
- package/dist/connect-JIWRIGVI.js.map +0 -1
- package/dist/daemon-api-JBXTSPB6.js +0 -2
- package/dist/daemon-api-JBXTSPB6.js.map +0 -1
- package/dist/program-3DRLVXOO.js.map +0 -1
- package/dist/providers-P76CWTGQ.js +0 -2
- /package/dist/{chunk-SY7R5N7U.js.map → chunk-Y4YOYOCG.js.map} +0 -0
- /package/dist/{doctor-QASDCIQ5.js.map → doctor-EDZO7BUJ.js.map} +0 -0
- /package/dist/{providers-P76CWTGQ.js.map → providers-AHLCB6R5.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as q}from"./chunk-FOWRNDMJ.js";import{a as D,b as F}from"./chunk-
|
|
1
|
+
import{a as q}from"./chunk-FOWRNDMJ.js";import{a as D,b as F}from"./chunk-B6VASQHD.js";import{A as S,G as H,I as b,K as _,N as M,q as A,x as W}from"./chunk-5VD2J4JN.js";import{c as P}from"./chunk-36X7D4JA.js";import{a as L}from"./chunk-OSH2PEBH.js";import{Hb as T,Rb as K,mb as E}from"./chunk-RIBANO2H.js";K();import{Command as V}from"commander";import f from"chalk";import{execFileSync as m}from"child_process";import{accessSync as z,constants as G,existsSync as k,readFileSync as $,readdirSync as N,statSync as Q}from"fs";import{join as B,resolve as w}from"path";import{homedir as Y}from"os";import{createRequire as ee}from"module";var C='run agentx notify "Hello" --title "Test"';function U(t,n){return t==="windows"?{fallback:"Windows PowerShell, and show its name",settings:"Open Settings \u203A System \u203A Notifications, turn notifications on, then turn on AgentX Helper and its banners.",missingFix:`${A(n)} Then ${C}.`,updateFix:`${A(n).replace(/^Put /,"Put a newer ")}`,osName:"Windows"}:{fallback:"Script Editor and show its icon",settings:"Open System Settings \u203A Notifications \u203A AgentX Helper, turn on Allow notifications and choose Banners.",missingFix:`Run agentx desktop install, then ${C} and click Allow.`,updateFix:"Run agentx desktop install to update it.",osName:"macOS"}}async function X(t={}){let n=t.platform??process.platform,e=t.helper===void 0?H():t.helper,i=b({},{platform:n,io:{capture:t.run,helper:e}}),s=i.banner;if(!s)return{state:"unsupported",message:"Desktop banners are only shown on macOS and Windows."};let o=U(i.os,n),a=await s.status();return a==="missing"?{state:"missing",message:`AgentX Helper is not installed, so banners come from ${o.fallback}.`,fix:o.missingFix}:a==="outdated"?{state:"outdated",path:e,message:"AgentX Helper is too old to report whether it may notify.",fix:o.updateFix}:a==="not-asked"?{state:"not-asked",path:e,message:`${o.osName} has not asked yet whether AgentX Helper may notify; banners come from ${o.fallback} until it does.`,fix:`${C[0].toUpperCase()}${C.slice(1)} and click Allow when ${o.osName} asks.`}:a==="not-allowed"?{state:"not-allowed",path:e,message:`${o.osName} does not allow AgentX Helper to notify, so banners come from ${o.fallback}.`,fix:o.settings}:a==="hidden"?{state:"hidden",path:e,message:"AgentX Helper may notify, but its banner style is None, so nothing appears on screen.",fix:o.settings}:{state:"ready",path:e,message:"AgentX Helper posts banners with the AgentX icon."}}async function te(t={}){let n=[];await re(n),ae(n);let e=le(n);return e&&ce(n,e),e&&fe(n,e),e&&he(n,e),e&&me(n,e),e&&ue(n,e),e&&n.push(...ge(e)),e&&we(n,e),e&&await ne(n,e),e&&oe(n,e),e&&await ie(n,e),e&&se(n,e),t.running!==!1&&e&&await ve(n,e),{checks:n,summary:J(n)}}var qe=new V().name("doctor").description("pre-flight health check: Node, config, credentials, daemon").option("--no-running","skip the live daemon probe").option("--json","emit machine-readable JSON (stable shape for CI)").action(async t=>{let{checks:n,summary:e}=await te({running:t.running!==!1});t.json?process.stdout.write(JSON.stringify({checks:n,summary:e},null,2)+`
|
|
2
2
|
`):ke(n),process.exit(e.errors>0?1:0)});async function ne(t,n,e=X){if(!_(n.notifications?.local).banner)return;let i=await e();i.state!=="unsupported"&&t.push({severity:i.state==="ready"?"ok":"warn",group:"Notifications",title:i.message,detail:i.path,fix:i.fix})}async function ie(t,n,e){let i;try{i=await(e??b(n)).describe()}catch(o){t.push({severity:"warn",group:"Native",title:"Native apps: could not be read",detail:o?.message??String(o)});return}let s=["tasks","notes","banner","sound","focus"].filter(o=>i[o]);t.push({severity:"ok",group:"Native",title:i.os==="none"?"Native apps: none on this machine":`Native apps (${i.os}): ${s.join(", ")||"nothing available"}`,detail:i.problems.join(" ")||void 0})}function se(t,n,e=process.cwd(),i=b(n)){let s=n.native?.mirror;if(!s?.enabled)return;if(!i.tasks){t.push({severity:"warn",group:"Native",title:"Reminders mirror is on, but this machine has no task app",detail:"native.mirror.enabled is set; nothing is mirrored here.",fix:"Turn it on on the machine that holds the owner's cards (the Mac), or set native.mirror.enabled to false here."});return}let o=M(e),a=Object.values(o.items),l=a.filter(g=>g.state==="open").length,p=a.filter(g=>g.state==="failed").length;t.push({severity:o.lastError||p?"warn":"ok",group:"Native",title:`Reminders mirror: ${l} open in "${s.list}"${p?`, ${p} could not be added`:""}`,detail:o.lastError?`Last error ${o.lastError.at}: ${o.lastError.message}`:void 0,fix:o.lastError?"Run remindctl status, and allow Reminders for the app that runs the daemon in System Settings \u203A Privacy & Security \u203A Reminders.":void 0})}function oe(t,n,e=process.platform,i=s=>{try{return z(s,G.X_OK),!0}catch{return!1}}){let s=n.reminders;if(!s?.enabled)return;if(e!=="darwin"){t.push({severity:"warn",group:"Reminders",title:"Reminders hand-back unavailable on this machine",detail:"reminders.enabled is set, but Apple Reminders exists only on macOS. The daemon starts without it.",fix:"Set reminders.enabled to false here, or enable it on the Mac node instead."});return}let o=s.command||"remindctl",a=o.includes("/")?i(o)?o:null:S(o,process.env.PATH||"",i);t.push(a?{severity:"ok",group:"Reminders",title:`Watching ${(s.lists||[]).join(", ")} for due reminders`,detail:a}:{severity:"fail",group:"Reminders",title:`${o} not found`,detail:"The daemon reads Apple Reminders through remindctl.",fix:"brew install steipete/tap/remindctl, or set reminders.command to its full path."})}async function re(t){let n=L(process.versions.node);t.push({severity:n?"ok":"fail",group:"Environment",title:`Node.js ${process.versions.node}`,detail:n?void 0:"AgentX requires Node 22.19 or newer, up to Node 26.",fix:n?void 0:"Install Node 22 (nvm install 22 && nvm use 22)"});let e=l=>{try{return m(process.platform==="win32"?"where":"which",[l],{encoding:"utf-8"}).trim().split(`
|
|
3
3
|
`)[0]}catch{return null}},i=e("npm");t.push({severity:i?"ok":"fail",group:"Environment",title:i?"npm on PATH":"npm not found",detail:i||void 0});let s=e("claude");if(s){let l;try{l=m("claude",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`claude CLI ${l||"installed"}`,detail:s})}else t.push({severity:"warn",group:"Environment",title:"claude CLI not on PATH",detail:"Only required for agents on the claude-code tier.",fix:"See https://docs.anthropic.com/en/docs/claude-code"});let o=e("codex");if(o){let l;try{l=m("codex",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`codex CLI ${l||"installed"}`,detail:o})}else t.push({severity:"warn",group:"Environment",title:"codex CLI not on PATH",detail:"Only required for agents on the codex-cli tier.",fix:"Install with `npm i -g @openai/codex`."});let a=e("opencode");if(a){let l;try{l=m("opencode",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`opencode CLI ${l||"installed"}`,detail:a})}else t.push({severity:"warn",group:"Environment",title:"opencode CLI not on PATH",detail:"Only required for agents on the opencode tier.",fix:"Install from https://opencode.ai/docs/."});try{ee(import.meta.url)("better-sqlite3"),t.push({severity:"ok",group:"Environment",title:`better-sqlite3 loads for Node ${process.version}`,detail:`NODE_MODULE_VERSION ${process.versions.modules}`})}catch(l){t.push({severity:"fail",group:"Environment",title:"better-sqlite3 native binding does not load",detail:l?.message??String(l),fix:`Run "pnpm rebuild better-sqlite3" with the same Node used by the daemon (${process.version}, modules ${process.versions.modules}).`})}}function ae(t){if(process.platform!=="darwin")return;let n=B(Y(),"Library/LaunchAgents"),e=[];try{e=N(n).filter(s=>/agentx\.voice.*\.plist$/.test(s))}catch{return}let i=s=>{try{return z(s,G.X_OK),!0}catch{return!1}};for(let s of e){let o=W($(B(n,s),"utf-8")),a=S("ffmpeg",o,i);t.push(a?{severity:"ok",group:"Desktop",title:"ffmpeg reachable by the desktop app",detail:`${a} (${s})`}:{severity:"warn",group:"Desktop",title:"ffmpeg not reachable by the desktop app",detail:`Local Whisper transcription fails without it. ${s} sets PATH to ${o}.`,fix:"Install ffmpeg (brew install ffmpeg), then rerun agentx desktop install."})}}function le(t){let n=w(process.cwd(),"agentx.json");if(!k(n))return t.push({severity:"fail",group:"Config",title:"agentx.json not found",detail:`Looked in ${n}`,fix:"Run `agentx setup` to create one via the web wizard."}),null;let e;try{e=JSON.parse($(n,"utf-8"))}catch(a){return t.push({severity:"fail",group:"Config",title:"agentx.json is not valid JSON",detail:a.message}),null}try{T(n),t.push({severity:"ok",group:"Config",title:`agentx.json valid (${Object.keys(e.agents||{}).length} agents, ${Object.keys(e.crons||{}).length} schedules)`})}catch(a){t.push({severity:"fail",group:"Config",title:"agentx.json failed schema validation",detail:a.message,fix:"Open /admin \u2192 Advanced tab to edit and re-save."})}let i=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="claude-code");i.length>0&&((()=>{try{return m(process.platform==="win32"?"where":"which",["claude"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${i.length} agent(s) use claude-code tier but claude CLI is missing`,detail:i.map(([l])=>l).join(", "),fix:"Install Claude Code (https://docs.anthropic.com/en/docs/claude-code) or switch these agents to tier=sdk."}));let s=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="codex-cli");s.length>0&&((()=>{try{return m(process.platform==="win32"?"where":"which",["codex"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${s.length} agent(s) use codex-cli tier but codex CLI is missing`,detail:s.map(([l])=>l).join(", "),fix:"Install Codex CLI with `npm i -g @openai/codex` or switch these agents to tier=claude-code."}));let o=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="opencode");return o.length>0&&((()=>{try{return m(process.platform==="win32"?"where":"which",["opencode"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${o.length} agent(s) use opencode tier but OpenCode CLI is missing`,detail:o.map(([l])=>l).join(", "),fix:"Install OpenCode from https://opencode.ai/docs/ or switch these agents to another tier."})),e}function ce(t,n){let e=new Set;if(j(n,e),e.size===0){t.push({severity:"ok",group:"Secrets",title:"No ${VAR} references in agentx.json"});return}let i=R(),s=[],o=[];for(let a of e){let l=process.env[a]??i[a];l===void 0?s.push(a):(!l.trim()||/^["']?\s*["']?$/.test(l))&&o.push(a)}s.length===0&&o.length===0?t.push({severity:"ok",group:"Secrets",title:`${e.size} env reference(s) resolved`}):(s.length>0&&t.push({severity:"fail",group:"Secrets",title:`${s.length} env var(s) referenced in agentx.json but missing`,detail:s.join(", "),fix:`Add to .env \u2014 e.g. ${s[0]}=<value>`}),o.length>0&&t.push({severity:"warn",group:"Secrets",title:`${o.length} env var(s) set but empty`,detail:o.join(", ")}))}function R(){let t=w(process.cwd(),".env"),n={};if(k(t))for(let e of $(t,"utf-8").split(/\r?\n/)){let i=e.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/i);i&&(n[i[1]]=i[2])}return n}function de(t,n){let e="With a shared token this node cannot tell which peer is calling. For example, closing an approval card forwarded from that peer is refused, and its stop/resume signals are judged as the owner's.",i="Give this pair a token of its own: set the same new value as mesh.peers[].token here and on the peer.",s=[];for(let o of t){let a=(o.token??"").trim();a?n&&a===n&&s.push({severity:"warn",group:"Mesh",title:`mesh peer "${o.name}" uses this node's own MESH_TOKEN`,detail:e,fix:i}):s.push({severity:"warn",group:"Mesh",title:`mesh peer "${o.name}" has no token; calls to it use the shared MESH_TOKEN`,detail:e,fix:i})}return t.length>0&&s.length===0&&s.push({severity:"ok",group:"Mesh",title:`${t.length} mesh peer(s), each with a token of its own`}),s}function ue(t,n){t.push(...pe(n))}function pe(t,n=process.env,e=R()){let i=a=>(n[a]||e[a]||"").trim(),s=a=>typeof a=="string"?a.replace(/\$\{([A-Z_][A-Z0-9_]*)\}/gi,(l,p)=>i(p)):void 0,o=(t.mesh?.peers??[]).filter(a=>typeof a?.name=="string").map(a=>({name:a.name,token:s(a.token)}));return de(o,i("MESH_TOKEN")||void 0)}function ge(t,n=process.env,e=R()){let i=[],s=0;for(let[o,a]of Object.entries(t.agents||{}))for(let[l,p]of Object.entries(a?.mcp||{})){let g=P(p??{});if(g.length===0)continue;s++;let y=g.filter(r=>!(n[r]||e[r]||"").trim());y.length>0&&i.push({severity:"fail",group:"Secrets",title:`MCP server "${l}" of ${o}: header variable(s) not set`,detail:y.join(", "),fix:`Add to .env \u2014 e.g. ${y[0]}=<value>, then restart the daemon`})}return s>0&&i.length===0&&i.push({severity:"ok",group:"Secrets",title:`${s} MCP server(s) with header variables, all set`}),i}function j(t,n){if(typeof t=="string")for(let e of t.matchAll(/\$\{([A-Z_][A-Z0-9_]*)\}/g))n.add(e[1]);else if(Array.isArray(t))for(let e of t)j(e,n);else if(t&&typeof t=="object")for(let e of Object.values(t))j(e,n)}function fe(t,n){let e=[];for(let[i,s]of Object.entries(n.agents||{})){if(!s.workspace)continue;let o=s.workspace.startsWith("/")?s.workspace:w(process.cwd(),s.workspace);try{Q(o).isDirectory()||e.push(`${i}: ${o} (exists but not a directory)`)}catch{e.push(`${i}: ${o}`)}}e.length===0?t.push({severity:"ok",group:"Workspaces",title:"All agent workspace folders exist"}):t.push({severity:"warn",group:"Workspaces",title:`${e.length} agent workspace(s) missing`,detail:e.join(`
|
|
4
4
|
`),fix:"The daemon will create missing folders on first task, but you won't see CLAUDE.md / skills until you populate them."})}function he(t,n){let e=/\$\{[A-Za-z_][A-Za-z0-9_]*\}/g,i=[];for(let[s,o]of Object.entries(n.agents||{})){if(!o.workspace)continue;let a=o.workspace.startsWith("/")?o.workspace:w(process.cwd(),o.workspace);for(let l of["settings.json","settings.local.json"]){let p=w(a,".claude",l);if(!k(p))continue;let g;try{g=JSON.parse($(p,"utf-8"))}catch(u){i.push({severity:"fail",agent:s,msg:`${l}: JSON parse error \u2014 ${u.message}`});continue}let y=g.env||{};for(let[u,h]of Object.entries(y)){if(typeof h!="string")continue;let c=h.match(e);c&&i.push({severity:"fail",agent:s,msg:`${l} env.${u} contains unexpanded ${[...new Set(c)].join(",")} \u2014 Claude Code does NOT expand \${VAR} in settings.json (use a fully-literal value)`})}let r=y.PATH;if(typeof r=="string"){let u=r.split(":").filter(Boolean);u.includes("/usr/bin")||i.push({severity:"fail",agent:s,msg:`${l} env.PATH missing /usr/bin \u2014 cat/head/sh/which will fail`}),u.includes("/bin")||i.push({severity:"fail",agent:s,msg:`${l} env.PATH missing /bin \u2014 ls/cp/mv will fail`})}let d=g.permissions;if(d&&typeof d=="object"&&"allow"in d){let u=d.allow,h=d.deny;Array.isArray(u)&&u.length===0&&Array.isArray(h)&&h.length>0&&i.push({severity:"warn",agent:s,msg:`${l} permissions.allow is explicitly [] with ${h.length} deny rules \u2014 agent may be locked out (omit the key to use defaults instead)`})}}}if(i.length===0){t.push({severity:"ok",group:"Workspace settings",title:`All ${Object.keys(n.agents||{}).length} agent .claude/settings.json files clean`});return}for(let s of i)t.push({severity:s.severity,group:"Workspace settings",title:`${s.agent}: ${s.msg}`,fix:s.severity==="fail"?"Edit .claude/settings.json \u2014 replace ${VAR} with the literal value or omit the key to inherit.":"Either remove the empty allow list or populate it."})}function me(t,n){let e=n.webhooks??[],i=[],s=w(process.cwd(),n.workflows?.dir||".agentx/workflows"),o=new Set;try{if(k(s))for(let r of N(s))r.endsWith(".json")&&!r.startsWith("_")&&!r.endsWith(".disabled.json")&&o.add(r.replace(/\.json$/,""))}catch{}let a=new Set(["github","gitlab"]);for(let r of e){if(!r.enabled||!a.has(r.source))continue;!(r.triggers&&Object.keys(r.triggers).length>0)&&!r.defaultWorkflow&&i.push({severity:"warn",title:`webhook "${r.id}" (${r.source} -> ${r.agentId}) has no triggers map; every event-type collapses to the bound agent`,fix:'Add a triggers map: { "issues.opened": "wf-id", "pull_request.synchronize": "wf-id" } \u2014 or set defaultWorkflow.'})}for(let r of e)if(!(!r.enabled||!r.triggers)){for(let[d,u]of Object.entries(r.triggers))o.size>0&&!o.has(u)&&i.push({severity:"fail",title:`webhook "${r.id}".triggers["${d}"] -> "${u}" \u2014 no such workflow under ${n.workflows?.dir||".agentx/workflows"}`,fix:"Create the workflow file or fix the id in agentx.json"});r.defaultWorkflow&&o.size>0&&!o.has(r.defaultWorkflow)&&i.push({severity:"fail",title:`webhook "${r.id}".defaultWorkflow -> "${r.defaultWorkflow}" \u2014 no such workflow`,fix:"Create the workflow file or fix the id in agentx.json"})}try{if(k(s)){for(let r of N(s))if(!(!r.endsWith(".json")||r.startsWith("_")||r.endsWith(".disabled.json")))try{let d=JSON.parse($(w(s,r),"utf-8"));d?.status==="active"&&d?.state==="quarantined"&&i.push({severity:"warn",title:`workflow "${d.id??r}" is status=active but state=quarantined \u2014 it looks live but will never dispatch`,fix:'Resolve the conflict the detector flagged, then set state back to "active" (or set status to "review" while parked).'})}catch{}}}catch{}let l=new Set((n.mesh?.peers??[]).map(r=>r.name));for(let r of e)!r.enabled||!r.node||l.has(r.node)||i.push({severity:"fail",title:`webhook "${r.id}" routes to mesh peer "${r.node}" which is not in mesh.peers`,fix:"Add the peer to mesh.peers or remove the node field on the webhook."});let p=new Map;for(let r of e){if(!r.enabled)continue;let d=`${r.source}:${r.agentId}`,u=p.get(d);u?i.push({severity:"warn",title:`webhook entries "${u}" and "${r.id}" both enabled for ${r.source} -> ${r.agentId}; only the first is dispatched`,fix:"Disable one entry, or merge their triggers maps into a single entry."}):p.set(d,r.id)}let g=new Set(Object.keys(n.agents??{}));for(let r of n.channels?.gitlab?.agentMappings??[])if(r?.agentId){if(r.node){l.has(r.node)||i.push({severity:"fail",title:`gitlab.agentMappings entry agentId="${r.agentId}" routes to mesh peer "${r.node}" which is not in mesh.peers`,fix:"Add the peer to mesh.peers or drop the node field on the mapping."});continue}g.has(r.agentId)||i.push({severity:"warn",title:`gitlab.agentMappings entry agentId="${r.agentId}" \u2014 no such agent in agents.* (and no node field, so it's not a cross-mesh route)`,fix:'Add the agent to agents.*, set node:"<peer>" if the agent lives remotely, or remove the mapping.'})}for(let[r,d]of Object.entries(n.channels?.telegram?.accounts??{}))d.agentBinding?g.has(d.agentBinding)||i.push({severity:"fail",title:`telegram account "${r}".agentBinding -> "${d.agentBinding}" \u2014 no such agent in agents.*`,fix:"Fix the agentBinding or define the agent in agents.*."}):i.push({severity:"fail",title:`telegram account "${r}" has no agentBinding; every DM to this bot will drop`,fix:"Set agentBinding to a valid agent id."});let y=new Set(["telegram-bot","whatsapp","slack-bot","discord-bot","gitlab-user","github-user","gmail","hotmail","smtp","hubspot","salesforce","pipedrive","odoo","trello","linear","asana","jira","notion","stripe","sentry","vercel","twilio","custom",...E,...Object.keys(D)]);for(let[r,d]of Object.entries(n.agents??{})){let u=d.integrations??[];if(!u.length)continue;let h=new Set;for(let c of u){let O=`${c.kind}::${c.label}`;h.has(O)&&i.push({severity:"warn",title:`agents.${r}.integrations: duplicate (${c.kind}, ${c.label})`,fix:"Remove the duplicate or rename one. (kind, label) must be unique per agent."}),h.add(O),y.has(c.kind)||i.push({severity:"warn",title:`agents.${r}.integrations: unknown kind "${c.kind}" on integration "${c.label}"`,fix:'Use a canonical kind from INTEGRATION_KINDS, or "custom" for ad-hoc services.'});let Z=c.credentials||{};for(let[x,v]of Object.entries(Z))typeof v=="string"&&/^[A-Z][A-Z0-9_]*$/.test(v)&&!process.env[v]&&i.push({severity:"warn",title:`agents.${r}.integrations[${c.kind}/${c.label}].${x} -> $${v} but env var is unset (in this shell)`,fix:`Set ${v} on the daemon environment. The daemon's process.env is what matters; this warning fires from your local shell.`});let I=c.enabled===!1?null:F(c.kind);if(I){let x=q(r,c,I);for(let v of x.problems)/env var .* is unset/.test(v)||i.push({severity:"warn",title:`agents.${r}.integrations[${c.kind}/${c.label}]: ${v}`,fix:x.connected?`Run agentx agent integrations status ${r} for details.`:`Run agentx agent integrations connect ${r} ${c.kind}${c.label!==c.kind?` --label "${c.label}"`:""}.`})}}}if(i.length===0){t.push({severity:"ok",group:"Routing",title:`${e.length} webhook(s), ${Object.keys(n.channels?.telegram?.accounts??{}).length} telegram account(s) \u2014 all routing references resolve`});return}for(let r of i)t.push({severity:r.severity,group:"Routing",title:r.title,fix:r.fix})}function ye(t){return typeof t?.canMeasure!="boolean"?null:t.canMeasure?{severity:"ok",group:"Runtime",title:"Daemon finds ffmpeg to measure phone recordings"}:{severity:"warn",group:"Runtime",title:t.allowUnmeasured?"Daemon can't find ffmpeg: phone recordings go unmeasured (voice.allowUnmeasured)":"Daemon can't find ffmpeg: phone voice input is refused",fix:"Install ffmpeg (brew install ffmpeg / sudo apt install ffmpeg), or set AGENTX_FFMPEG in the service's environment. The daemon's PATH is shorter than your shell's."}}async function ve(t,n){let e=n.dashboard?.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800",i={};n.dashboard?.token&&(i.Authorization=`Bearer ${n.dashboard.token}`);try{let s=new AbortController,o=setTimeout(()=>s.abort(),2e3),a=await fetch(e+"/health",{headers:i,signal:s.signal});if(clearTimeout(o),!a.ok){t.push({severity:"warn",group:"Runtime",title:`Daemon responded ${a.status}`,detail:e});return}let l=await a.json();t.push({severity:"ok",group:"Runtime",title:`Daemon healthy \u2014 ${l.agents?.length??0} agents live, uptime ${Math.round((l.uptime??0)/60)}m`,detail:e});let p=ye(l.voice);p&&t.push(p)}catch{t.push({severity:"warn",group:"Runtime",title:"Daemon not reachable (not running?)",detail:e,fix:"Run `agentx daemon start`. Skip this check with `agentx doctor --no-running`."})}}function we(t,n){let e=Object.entries(n.agents||{}).filter(([,s])=>s?.codegraph===!0&&(s.tier==="claude-code"||s.tier==="codex-cli"));if(e.length===0)return;let i=null;try{i=m(process.platform==="win32"?"where":"which",["codegraph"],{encoding:"utf-8"}).trim().split(`
|
|
5
5
|
`)[0]||null}catch{i=null}if(i){let s;try{s=m("codegraph",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"CodeGraph",title:`codegraph CLI ${s||"installed"}`,detail:i})}else t.push({severity:"fail",group:"CodeGraph",title:"codegraph CLI not on PATH",detail:`${e.length} agent(s) have codegraph:true but the binary isn't available.`,fix:"Install with `npm i -g @colbymchenry/codegraph`."});for(let[s,o]of e){if(!o.workspace||!k(o.workspace)){t.push({severity:"warn",group:"CodeGraph",title:`${s}: workspace missing`,detail:`Workspace path ${o.workspace} does not exist \u2014 codegraph will skip this agent.`});continue}let a=w(o.workspace,".codegraph","codegraph.db");k(a)?t.push({severity:"ok",group:"CodeGraph",title:`${s}: index present`,detail:a}):t.push({severity:"warn",group:"CodeGraph",title:`${s}: index not built yet`,detail:".codegraph/ missing \u2014 daemon will background-index this workspace on next boot.",fix:`Run \`codegraph init --index ${o.workspace}\` to build it now.`})}}function J(t){return{errors:t.filter(n=>n.severity==="fail").length,warnings:t.filter(n=>n.severity==="warn").length,ok:t.filter(n=>n.severity==="ok").length}}function ke(t){console.log(),console.log(f.bold(" agentx doctor")),console.log();let n=new Map;for(let i of t)n.has(i.group)||n.set(i.group,[]),n.get(i.group).push(i);for(let[i,s]of n){console.log(f.bold(" "+i));for(let o of s){let a=o.severity==="ok"?f.green("\u2713"):o.severity==="warn"?f.yellow("!"):f.red("\u2717");console.log(` ${a} ${o.title}`),o.detail&&console.log(f.dim(" "+o.detail.replace(/\n/g,`
|
|
6
6
|
`))),o.fix&&console.log(f.dim(" \u2192 "+o.fix))}console.log()}let e=J(t);e.errors>0?console.log(f.red.bold(` ${e.errors} error${e.errors===1?"":"s"}`)+(e.warnings?f.yellow(`, ${e.warnings} warning${e.warnings===1?"":"s"}`):"")+`. Fix the error${e.errors===1?"":"s"} and rerun.`):e.warnings>0?console.log(f.yellow.bold(` ${e.warnings} warning${e.warnings===1?"":"s"}.`)+f.dim(" Review but not blocking.")):console.log(f.green.bold(` All checks passed (${e.ok}).`)),console.log()}export{X as a,te as b,qe as c,ne as d,ie as e,se as f,oe as g,de as h,pe as i,ge as j,ye as k};
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
//# sourceMappingURL=chunk-Y4YOYOCG.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-
|
|
2
|
+
import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-OFN6YQRH.js"),{installCliSignalExit:r}=await import("./signal-exit-C5EUGHKI.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
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as l}from"./chunk-Q3A5P373.js";import{a as g,b as h,d}from"./chunk-JLBRNYKY.js";import"./chunk-QIJLFPWE.js";function k(t){let e;try{e=new URL(t)}catch{return null}return e.hash?null:e.protocol==="https:"||e.protocol==="http:"&&e.hostname==="localhost"?e.toString():null}async function v(t){let{scopes:e,unknown:r}=g(t.spec.oauth,t.extras);if(r.length){let o=Object.keys(t.spec.oauth.optionalScopes??{});throw new Error(`unknown --with ${r.join(", ")}. ${o.length?`Available: ${o.join(", ")}`:`${t.spec.title} has no optional scopes`}`)}let i=h(t.spec,t.clientId,t.redirectUri,e),n=await t.getCallback(i.url,i.state);if("error"in n)throw new Error(n.error);return d(t.spec,i,n.code,{fetch:t.fetch??fetch,clientId:t.clientId,clientSecret:t.clientSecret,now:(t.now??Date.now)(),warn:t.warn})}function p(t,e,r){let i=n=>n.replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase();return`${i(e)}_${i(t)}_${r?"REFRESH_TOKEN":"ACCESS_TOKEN"}`}function m(t,e,r,i,n){let o={...e.credentials??{}},s={...e.metadata??{}};delete s.oauthExpiresAt;let c;if(i==="keyring")n.keyring.set(l(t,e.kind,e.label),JSON.stringify(r)),o.auth="keyring",c="the OS keyring";else if(delete o.auth,r.refreshToken){let a=o.refreshTokenEnv??p(t,e.kind,!0);n.writeEnv(a,r.refreshToken),o.refreshTokenEnv=a,c=`.env as ${a}`}else{let a=o.tokenEnv??p(t,e.kind,!1);n.writeEnv(a,r.accessToken),o.tokenEnv=a,r.expiresAt&&(s.oauthExpiresAt=r.expiresAt),c=`.env as ${a}`}return s.oauthScopes=r.scopes.join(" "),s.oauthConnectedAt=r.connectedAt,{integration:{...e,credentials:o,metadata:s},where:c}}function y(t,e,r){let i=e.credentials?.auth==="keyring"?r.delete(l(t,e.kind,e.label)):!1,n={...e.credentials??{}},o=[n.refreshTokenEnv,n.tokenEnv].filter(c=>!!c);delete n.auth,delete n.refreshTokenEnv,delete n.tokenEnv;let s={...e.metadata??{}};return delete s.oauthScopes,delete s.oauthConnectedAt,delete s.oauthExpiresAt,{integration:{...e,credentials:n,metadata:s},removedFromKeyring:i,envLeft:o}}export{k as checkRedirectUri,y as forgetGrant,v as signIn,m as storeGrant,p as tokenEnvName};
|
|
2
|
+
//# sourceMappingURL=connect-AJKMRKXC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/integrations/connect.ts"],"sourcesContent":["import type { Integration } from \"@/daemon/config\"\nimport { buildAuthorizeRequest, exchangeCode, scopesFor, type CallbackResult } from \"./oauth\"\nimport { integrationAccount, type KeyringStore } from \"./keyring\"\nimport type { OAuthGrant, ProviderSpec } from \"./providers/types\"\n\n// --- `agentx agent integrations connect`: sign in once, store the grant ---\n//\n// The CLI wires this to a browser, a loopback callback (or a pasted\n// address) and agentx.json. Kept apart so the whole flow runs in tests\n// against a fake provider.\n\nexport interface ConnectInput {\n agentId: string\n spec: ProviderSpec\n integration: Integration\n clientId: string\n clientSecret: string\n redirectUri: string\n /** Names from spec.oauth.optionalScopes (e.g. \"revenue\"). */\n extras?: string[]\n /** Shows the sign-in address and resolves with what the redirect carried. */\n getCallback: (authorizeUrl: string, state: string) => Promise<CallbackResult>\n fetch?: typeof fetch\n now?: () => number\n /** Non-fatal problems found while connecting (e.g. a check that could not run). */\n warn?: (message: string) => void\n}\n\n/** A return address given with `--redirect-uri`, normalised, or null when it\n * is not https (or http on localhost) or carries a #fragment. */\nexport function checkRedirectUri(raw: string): string | null {\n let u: URL\n try { u = new URL(raw) } catch { return null }\n if (u.hash) return null\n if (u.protocol === \"https:\") return u.toString()\n if (u.protocol === \"http:\" && u.hostname === \"localhost\") return u.toString()\n return null\n}\n\nexport async function signIn(input: ConnectInput): Promise<OAuthGrant> {\n const { scopes, unknown } = scopesFor(input.spec.oauth, input.extras)\n if (unknown.length) {\n const known = Object.keys(input.spec.oauth.optionalScopes ?? {})\n throw new Error(`unknown --with ${unknown.join(\", \")}. ${known.length ? `Available: ${known.join(\", \")}` : `${input.spec.title} has no optional scopes`}`)\n }\n const req = buildAuthorizeRequest(input.spec, input.clientId, input.redirectUri, scopes)\n const cb = await input.getCallback(req.url, req.state)\n if (\"error\" in cb) throw new Error(cb.error)\n return exchangeCode(input.spec, req, cb.code, {\n fetch: input.fetch ?? fetch,\n clientId: input.clientId,\n clientSecret: input.clientSecret,\n now: (input.now ?? Date.now)(),\n warn: input.warn,\n })\n}\n\nexport type StoreMode = \"keyring\" | \"env\"\n\nexport interface StoreDeps {\n keyring: KeyringStore\n /** Writes KEY=value to .env, replacing an older value. */\n writeEnv: (key: string, value: string) => void\n}\n\n/** The env var a connect writes to, e.g. YOUTUBE_HELPER_REFRESH_TOKEN. */\nexport function tokenEnvName(agentId: string, kind: string, refresh: boolean): string {\n const up = (s: string) => s.replace(/[^A-Za-z0-9]+/g, \"_\").replace(/^_+|_+$/g, \"\").toUpperCase()\n return `${up(kind)}_${up(agentId)}_${refresh ? \"REFRESH_TOKEN\" : \"ACCESS_TOKEN\"}`\n}\n\n/** Store the grant and return the integration as it should be saved:\n * where the token lives (credentials) and non-secret facts about it\n * (metadata: scopes, connect time, expiry when it cannot refresh). */\nexport function storeGrant(agentId: string, i: Integration, grant: OAuthGrant, mode: StoreMode, deps: StoreDeps): { integration: Integration; where: string } {\n const credentials = { ...(i.credentials ?? {}) }\n const metadata: Record<string, string | number | boolean> = { ...(i.metadata ?? {}) }\n delete metadata.oauthExpiresAt\n let where: string\n if (mode === \"keyring\") {\n deps.keyring.set(integrationAccount(agentId, i.kind, i.label), JSON.stringify(grant))\n credentials.auth = \"keyring\"\n where = \"the OS keyring\"\n } else {\n delete credentials.auth\n if (grant.refreshToken) {\n const name = credentials.refreshTokenEnv ?? tokenEnvName(agentId, i.kind, true)\n deps.writeEnv(name, grant.refreshToken)\n credentials.refreshTokenEnv = name\n where = `.env as ${name}`\n } else {\n const name = credentials.tokenEnv ?? tokenEnvName(agentId, i.kind, false)\n deps.writeEnv(name, grant.accessToken)\n credentials.tokenEnv = name\n if (grant.expiresAt) metadata.oauthExpiresAt = grant.expiresAt\n where = `.env as ${name}`\n }\n }\n metadata.oauthScopes = grant.scopes.join(\" \")\n metadata.oauthConnectedAt = grant.connectedAt\n return { integration: { ...i, credentials, metadata }, where }\n}\n\n/** Remove the stored grant: the keyring entry, the env references (the\n * .env values themselves are left for the owner to delete) and the facts\n * about it. The integration entry and its client stay. */\nexport function forgetGrant(agentId: string, i: Integration, keyring: KeyringStore):\n { integration: Integration; removedFromKeyring: boolean; envLeft: string[] } {\n const removedFromKeyring = i.credentials?.auth === \"keyring\" ? keyring.delete(integrationAccount(agentId, i.kind, i.label)) : false\n const credentials = { ...(i.credentials ?? {}) }\n const envLeft = [credentials.refreshTokenEnv, credentials.tokenEnv].filter((v): v is string => !!v)\n delete credentials.auth\n delete credentials.refreshTokenEnv\n delete credentials.tokenEnv\n const metadata = { ...(i.metadata ?? {}) }\n delete metadata.oauthScopes\n delete metadata.oauthConnectedAt\n delete metadata.oauthExpiresAt\n return { integration: { ...i, credentials, metadata }, removedFromKeyring, envLeft }\n}\n"],"mappings":"qHA8BO,SAASA,EAAiBC,EAA4B,CAC3D,IAAIC,EACJ,GAAI,CAAEA,EAAI,IAAI,IAAID,CAAG,CAAE,MAAE,CAAQ,OAAO,IAAK,CAC7C,OAAIC,EAAE,KAAa,KACfA,EAAE,WAAa,UACfA,EAAE,WAAa,SAAWA,EA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AAAC,CAAQ,CACrF","names":["checkRedirectUri","raw","u","signIn","input","scopes","unknown","scopesFor","known","req","buildAuthorizeRequest","cb","exchangeCode","tokenEnvName","agentId","kind","refresh","up","s","storeGrant","i","grant","mode","deps","credentials","metadata","where","integrationAccount","name","forgetGrant","keyring","removedFromKeyring","envLeft","v"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as $,b as w}from"./chunk-B6VASQHD.js";import{a as j,e as I,j as A}from"./chunk-7QW4RECS.js";import"./chunk-BYEL7KKR.js";import"./chunk-Q3A5P373.js";import{c as R}from"./chunk-JLBRNYKY.js";import"./chunk-QUFIUXMQ.js";import"./chunk-QIJLFPWE.js";var P=16e3,O=/^[A-Za-z0-9_.:@-]{1,200}$/;function v(c,e){let i=Object.keys(e.reads),f=c.metadata?.reads;if(typeof f!="string"||!f.trim())return i;let n=new Set(f.split(",").map(u=>u.trim()).filter(Boolean));return i.filter(u=>n.has(u))}function D(c,e,i,f){for(let t of Object.keys(i))if(!e.params[t])return{ok:!1,error:`unknown parameter "${t}". Allowed: ${Object.keys(e.params).join(", ")||"none"}`};let n={};for(let[t,r]of Object.entries(e.params)){let a=i[t];if((a==null||a==="")&&r.fromMetadata&&(a=f[t]),(a==null||a==="")&&r.default!==void 0&&(a=r.default),a==null||a===""){if(r.required)return{ok:!1,error:`parameter "${t}" is required: ${r.description}`};continue}let s=Array.isArray(a)?a.map(String).join(","):String(a);if(s.length>1e3)return{ok:!1,error:`parameter "${t}" is too long`};let g=r.list?s.split(",").map(m=>m.trim()).filter(Boolean):[s];for(let m of g){if(r.enum&&!r.enum.includes(m))return{ok:!1,error:`"${m}" is not allowed for "${t}". Allowed: ${r.enum.join(", ")}`};if(r.pattern&&!new RegExp(`^(?:${r.pattern.source})$`,r.pattern.flags).test(m))return{ok:!1,error:`"${m}" is not a valid value for "${t}"`}}n[t]=r.list?g.join(","):s}let u=new Set,l="",p=e.path.replace(/\{([A-Za-z0-9_]+)\}/g,(t,r)=>{let a=n[r];return a?!O.test(a)||/^\.+$/.test(a)?(l||=`"${r}" must be a plain id`,""):(u.add(r),encodeURIComponent(a)):(l||=`parameter "${r}" is required for the path`,"")});if(l)return{ok:!1,error:l};let d=new URL(c.baseUrl),o=new URL(c.baseUrl+p);if(o.origin!==d.origin)return{ok:!1,error:"the read left the provider's address"};if(p.split("/").some(t=>t==="."||t==="..")||!o.pathname.startsWith(d.pathname))return{ok:!1,error:"the read left the provider's address"};for(let[t,r]of Object.entries(n))u.has(t)||o.searchParams.set(t,r);for(let[t,r]of Object.entries(e.fixedQuery??{}))o.searchParams.set(t,r);return{ok:!0,url:o,values:n}}async function S(c,e,i={}){let f=i.providers??$,n=w(e.kind,f);if(!n)return{ok:!1,status:400,error:`no provider for kind "${e.kind}". Known: ${Object.keys(f).join(", ")||"none yet"}`};let u=j(c,e.agentId,e.kind,e.label);if(!u)return{ok:!1,status:404,error:`agent "${e.agentId}" has no enabled ${e.kind} integration${e.label?` labelled "${e.label}"`:""}`};let l=u.integration,p=Object.prototype.hasOwnProperty.call(n.reads,e.read)?n.reads[e.read]:void 0;if(!p)return{ok:!1,status:400,error:`unknown read "${e.read}". Allowed: ${v(l,n).join(", ")}`};if(!v(l,n).includes(e.read))return{ok:!1,status:403,error:`read "${e.read}" is not allowed for ${e.kind} "${l.label}" (metadata.reads)`};let d=D(n,p,e.params??{},l.metadata??{});if(!d.ok)return{ok:!1,status:400,error:d.error};let o=await A(e.agentId,l,n,i);if(o.status!=="ok")return{ok:!1,status:409,error:o.reason};let t=i.fetch??fetch,r=o.token;if(n.readToken)try{r=await n.readToken({read:e.read,values:d.values,token:o.token,fetch:t,now:(i.now??Date.now)()})}catch(k){let b=R(String(k?.message??k)).split(o.token).join("[redacted]");return{ok:!1,status:403,error:`${n.title}: ${b}`}}let a={Accept:"application/json"};(n.tokenIn??"header")==="header"?a.Authorization=`Bearer ${r}`:d.url.searchParams.set(n.tokenParam??"access_token",r);let s;try{s=await t(d.url.toString(),{method:"GET",headers:a,signal:AbortSignal.timeout(2e4),redirect:"error"})}catch(k){return{ok:!1,status:502,error:`couldn't reach ${n.title}: ${R(String(k?.message??k))}`}}let g=(await s.text().catch(()=>"")).split(o.token).join("[redacted]");if(r!==o.token&&(g=g.split(r).join("[redacted]")),!s.ok){let k=g;try{let h=JSON.parse(g);k=h?.error?.message||h?.error_description||h?.error||g}catch{}let b=s.status===401?` Connect again: ${I(e.agentId,l)}.`:s.status===403?" The account or app may lack a permission or scope this read needs.":"";return{ok:!1,status:s.status,error:`${n.title} said ${s.status}: ${R(String(k))}.${b}`}}let m=g.length>P;return{ok:!0,status:s.status,body:m?g.slice(0,P):g,truncated:m}}function x(c,e,i=$){let f=c.agents?.[e]?.integrations??[],n=[];for(let u of f){if(u.enabled===!1)continue;let l=w(u.kind,i);l&&n.push({kind:u.kind,label:u.label,title:l.title,reads:v(u,l).map(p=>{let d=l.reads[p];return{name:p,description:d.description,params:Object.fromEntries(Object.entries(d.params).map(([o,t])=>[o,{description:t.description,required:!!t.required&&!(t.fromMetadata&&u.metadata?.[o]!==void 0)&&t.default===void 0,...t.enum?{allowed:t.enum}:{}}]))}})})}return n}var y=c=>typeof c=="string"?c.trim():"";async function L(c,e,i,f,n,u={}){let l=c.toUpperCase(),p=d=>d?n.agents?.[d]?null:{status:400,body:{error:`unknown agent "${d}": it must be an agent on this node`}}:{status:400,body:{error:"agent is required: your agent id"}};if(e==="/integrations/reads"&&l==="GET"){let d=y(f.get("agent")),o=p(d);return o||{status:200,body:{integrations:x(n,d,u.providers)}}}if(e==="/integrations/read"&&l==="POST"){let d=y(i?.agent),o=p(d);if(o)return o;let t=y(i?.kind),r=y(i?.read);if(!t||!r)return{status:400,body:{error:"kind and read are required"}};let a=i?.params&&typeof i.params=="object"&&!Array.isArray(i.params)?i.params:{},s=await S(n,{agentId:d,kind:t,label:y(i?.label)||void 0,read:r,params:a},u);return s.ok?{status:200,body:{status:s.status,body:s.body,truncated:s.truncated}}:{status:s.status>=400&&s.status<600?s.status:502,body:{error:s.error}}}return e==="/integrations/read"||e==="/integrations/reads"?{status:405,body:{error:"method not allowed"}}:{status:404,body:{error:"not found"}}}export{L as handleIntegrationsApi};
|
|
2
|
+
//# sourceMappingURL=daemon-api-OVCXY4QC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/integrations/read.ts","../src/integrations/daemon-api.ts"],"sourcesContent":["import type { DaemonConfig, Integration } from \"@/daemon/config\"\nimport { getIntegration } from \"./resolve\"\nimport { connectCommand, resolveAccessToken, type TokenDeps } from \"./resolve\"\nimport { safeProviderText } from \"./oauth\"\nimport { BUILTIN_PROVIDERS, providerFor, type ProviderRegistry } from \"./providers\"\nimport type { ProviderSpec, ReadSpec } from \"./providers/types\"\n\n// --- Named, read-only calls to an outside API (`agentx_integration_read`) ---\n//\n// An agent names an integration kind, a read from that provider's spec and\n// a few parameters. This module checks every parameter against the spec,\n// builds the URL itself and sends a GET with the integration's token. There\n// is no way to send another method, another path or a parameter the spec\n// does not list. An integration can narrow its reads further with\n// metadata.reads (\"read_a,read_b\").\n//\n// The answer is bounded (MAX_BODY characters) and never carries the token.\n\nexport const MAX_BODY = 16_000\n\nexport interface ReadDeps extends TokenDeps {\n providers?: ProviderRegistry\n}\n\nexport interface ReadRequest {\n agentId: string\n kind: string\n label?: string\n read: string\n params?: Record<string, unknown>\n}\n\nexport type ReadResult =\n | { ok: true; status: number; body: string; truncated: boolean }\n | { ok: false; status: number; error: string }\n\nconst ID_PARAM = /^[A-Za-z0-9_.:@-]{1,200}$/\n\n/** The reads an integration allows: the spec's, narrowed by metadata.reads. */\nexport function allowedReads(i: Integration, spec: ProviderSpec): string[] {\n const all = Object.keys(spec.reads)\n const only = i.metadata?.reads\n if (typeof only !== \"string\" || !only.trim()) return all\n const pick = new Set(only.split(\",\").map((s) => s.trim()).filter(Boolean))\n return all.filter((r) => pick.has(r))\n}\n\n/** Check the agent's params against a read spec. Returns the path and query\n * to send, or the first problem found. Exported for tests. */\nexport function buildReadUrl(\n spec: ProviderSpec,\n read: ReadSpec,\n params: Record<string, unknown>,\n metadata: Record<string, unknown>,\n): { ok: true; url: URL; values: Record<string, string> } | { ok: false; error: string } {\n for (const k of Object.keys(params)) {\n if (!read.params[k]) return { ok: false, error: `unknown parameter \"${k}\". Allowed: ${Object.keys(read.params).join(\", \") || \"none\"}` }\n }\n const values: Record<string, string> = {}\n for (const [name, p] of Object.entries(read.params)) {\n let raw = params[name]\n if ((raw === undefined || raw === null || raw === \"\") && p.fromMetadata) raw = metadata[name]\n if ((raw === undefined || raw === null || raw === \"\") && p.default !== undefined) raw = p.default\n if (raw === undefined || raw === null || raw === \"\") {\n if (p.required) return { ok: false, error: `parameter \"${name}\" is required: ${p.description}` }\n continue\n }\n const value = Array.isArray(raw) ? raw.map(String).join(\",\") : String(raw)\n if (value.length > 1000) return { ok: false, error: `parameter \"${name}\" is too long` }\n const items = p.list ? value.split(\",\").map((s) => s.trim()).filter(Boolean) : [value]\n for (const item of items) {\n if (p.enum && !p.enum.includes(item)) return { ok: false, error: `\"${item}\" is not allowed for \"${name}\". Allowed: ${p.enum.join(\", \")}` }\n if (p.pattern && !new RegExp(`^(?:${p.pattern.source})$`, p.pattern.flags).test(item)) return { ok: false, error: `\"${item}\" is not a valid value for \"${name}\"` }\n }\n values[name] = p.list ? items.join(\",\") : value\n }\n const used = new Set<string>()\n let pathError = \"\"\n const path = read.path.replace(/\\{([A-Za-z0-9_]+)\\}/g, (_m, name: string) => {\n const v = values[name]\n if (!v) { pathError ||= `parameter \"${name}\" is required for the path`; return \"\" }\n // \".\" and \"..\" are dot segments: the URL parser would climb out of the path.\n if (!ID_PARAM.test(v) || /^\\.+$/.test(v)) { pathError ||= `\"${name}\" must be a plain id`; return \"\" }\n used.add(name)\n return encodeURIComponent(v)\n })\n if (pathError) return { ok: false, error: pathError }\n const base = new URL(spec.baseUrl)\n const url = new URL(spec.baseUrl + path)\n if (url.origin !== base.origin) return { ok: false, error: \"the read left the provider's address\" }\n // Belt and braces: no dot segment in the read's own path, and the parsed\n // path still sits under the base path, so nothing climbed out.\n if (path.split(\"/\").some((s) => s === \".\" || s === \"..\") || !url.pathname.startsWith(base.pathname)) {\n return { ok: false, error: \"the read left the provider's address\" }\n }\n for (const [k, v] of Object.entries(values)) if (!used.has(k)) url.searchParams.set(k, v)\n for (const [k, v] of Object.entries(read.fixedQuery ?? {})) url.searchParams.set(k, v)\n return { ok: true, url, values }\n}\n\n/** Run one named read for an agent. */\nexport async function runIntegrationRead(config: DaemonConfig, req: ReadRequest, deps: ReadDeps = {}): Promise<ReadResult> {\n const providers = deps.providers ?? BUILTIN_PROVIDERS\n const spec = providerFor(req.kind, providers)\n if (!spec) return { ok: false, status: 400, error: `no provider for kind \"${req.kind}\". Known: ${Object.keys(providers).join(\", \") || \"none yet\"}` }\n const found = getIntegration(config, req.agentId, req.kind, req.label)\n if (!found) return { ok: false, status: 404, error: `agent \"${req.agentId}\" has no enabled ${req.kind} integration${req.label ? ` labelled \"${req.label}\"` : \"\"}` }\n const i = found.integration\n const read = Object.prototype.hasOwnProperty.call(spec.reads, req.read) ? spec.reads[req.read] : undefined\n if (!read) return { ok: false, status: 400, error: `unknown read \"${req.read}\". Allowed: ${allowedReads(i, spec).join(\", \")}` }\n if (!allowedReads(i, spec).includes(req.read)) return { ok: false, status: 403, error: `read \"${req.read}\" is not allowed for ${req.kind} \"${i.label}\" (metadata.reads)` }\n\n const built = buildReadUrl(spec, read, req.params ?? {}, i.metadata ?? {})\n if (!built.ok) return { ok: false, status: 400, error: built.error }\n\n const token = await resolveAccessToken(req.agentId, i, spec, deps)\n if (token.status !== \"ok\") return { ok: false, status: 409, error: token.reason }\n\n const f = deps.fetch ?? fetch\n let sendToken = token.token\n if (spec.readToken) {\n try {\n sendToken = await spec.readToken({ read: req.read, values: built.values, token: token.token, fetch: f, now: (deps.now ?? Date.now)() })\n } catch (e: any) {\n const why = safeProviderText(String(e?.message ?? e)).split(token.token).join(\"[redacted]\")\n return { ok: false, status: 403, error: `${spec.title}: ${why}` }\n }\n }\n const headers: Record<string, string> = { Accept: \"application/json\" }\n if ((spec.tokenIn ?? \"header\") === \"header\") headers.Authorization = `Bearer ${sendToken}`\n else built.url.searchParams.set(spec.tokenParam ?? \"access_token\", sendToken)\n\n let res: Response\n try {\n res = await f(built.url.toString(), { method: \"GET\", headers, signal: AbortSignal.timeout(20_000), redirect: \"error\" })\n } catch (e: any) {\n return { ok: false, status: 502, error: `couldn't reach ${spec.title}: ${safeProviderText(String(e?.message ?? e))}` }\n }\n let text = (await res.text().catch(() => \"\")).split(token.token).join(\"[redacted]\")\n if (sendToken !== token.token) text = text.split(sendToken).join(\"[redacted]\")\n if (!res.ok) {\n let why = text\n try { const j = JSON.parse(text); why = j?.error?.message || j?.error_description || j?.error || text } catch {}\n const hint = res.status === 401\n ? ` Connect again: ${connectCommand(req.agentId, i)}.`\n : res.status === 403 ? \" The account or app may lack a permission or scope this read needs.\" : \"\"\n return { ok: false, status: res.status, error: `${spec.title} said ${res.status}: ${safeProviderText(String(why))}.${hint}` }\n }\n const truncated = text.length > MAX_BODY\n return { ok: true, status: res.status, body: truncated ? text.slice(0, MAX_BODY) : text, truncated }\n}\n\nexport interface ReadCatalogEntry {\n kind: string\n label: string\n title: string\n reads: Array<{ name: string; description: string; params: Record<string, { description: string; required: boolean; allowed?: readonly string[] }> }>\n}\n\n/** The reads an agent can run, for the tool's list action. */\nexport function readCatalog(config: DaemonConfig, agentId: string, providers: ProviderRegistry = BUILTIN_PROVIDERS): ReadCatalogEntry[] {\n const list = ((config.agents?.[agentId] as any)?.integrations ?? []) as Integration[]\n const out: ReadCatalogEntry[] = []\n for (const i of list) {\n if (i.enabled === false) continue\n const spec = providerFor(i.kind, providers)\n if (!spec) continue\n out.push({\n kind: i.kind,\n label: i.label,\n title: spec.title,\n reads: allowedReads(i, spec).map((name) => {\n const r = spec.reads[name]\n return {\n name,\n description: r.description,\n params: Object.fromEntries(Object.entries(r.params).map(([k, p]) => [k, {\n description: p.description,\n required: !!p.required && !(p.fromMetadata && i.metadata?.[k] !== undefined) && p.default === undefined,\n ...(p.enum ? { allowed: p.enum } : {}),\n }])),\n }\n }),\n })\n }\n return out\n}\n","import type { DaemonConfig } from \"@/daemon/config\"\nimport { readCatalog, runIntegrationRead, type ReadDeps } from \"./read\"\n\n// --- The daemon's /integrations endpoints, for agents (#1696) ---\n//\n// GET /integrations/reads?agent= the named reads the agent can run\n// POST /integrations/read {agent, kind, label?, read, params?}\n//\n// Only reads: nothing here writes to an outside service, and no endpoint\n// returns a token. Gated by isMeshGatedPath: loopback, or a mesh token.\n\nexport interface IntegrationsApiReply {\n status: number\n body: unknown\n}\n\nconst str = (v: unknown): string => (typeof v === \"string\" ? v.trim() : \"\")\n\nexport async function handleIntegrationsApi(\n method: string,\n path: string,\n body: Record<string, unknown> | undefined,\n query: URLSearchParams,\n config: DaemonConfig,\n deps: ReadDeps = {},\n): Promise<IntegrationsApiReply> {\n const m = method.toUpperCase()\n const agentOk = (id: string): IntegrationsApiReply | null => {\n if (!id) return { status: 400, body: { error: \"agent is required: your agent id\" } }\n if (!config.agents?.[id]) return { status: 400, body: { error: `unknown agent \"${id}\": it must be an agent on this node` } }\n return null\n }\n\n if (path === \"/integrations/reads\" && m === \"GET\") {\n const agent = str(query.get(\"agent\"))\n const bad = agentOk(agent)\n if (bad) return bad\n return { status: 200, body: { integrations: readCatalog(config, agent, deps.providers) } }\n }\n\n if (path === \"/integrations/read\" && m === \"POST\") {\n const agent = str(body?.agent)\n const bad = agentOk(agent)\n if (bad) return bad\n const kind = str(body?.kind)\n const read = str(body?.read)\n if (!kind || !read) return { status: 400, body: { error: \"kind and read are required\" } }\n const params = body?.params && typeof body.params === \"object\" && !Array.isArray(body.params)\n ? (body.params as Record<string, unknown>)\n : {}\n const r = await runIntegrationRead(config, { agentId: agent, kind, label: str(body?.label) || undefined, read, params }, deps)\n if (!r.ok) return { status: r.status >= 400 && r.status < 600 ? r.status : 502, body: { error: r.error } }\n return { status: 200, body: { status: r.status, body: r.body, truncated: r.truncated } }\n }\n\n if (path === \"/integrations/read\" || path === \"/integrations/reads\") return { status: 405, body: { error: \"method not allowed\" } }\n return { status: 404, body: { error: \"not found\" } }\n}\n"],"mappings":"6PAkBO,IAAMA,EAAW,KAkBlBC,EAAW,4BAGV,SAASC,EAAaC,EAAgBC,EAA8B,CACzE,IAAMC,EAAM,OAAO,KAAKD,EAAK,KAAK,EAC5BE,EAAOH,EAAE,UAAU,MACzB,GAAI,OAAOG,GAAS,UAAY,CAACA,EAAK,KAAK,EAAG,OAAOD,EACrD,IAAME,EAAO,IAAI,IAAID,EAAK,MAAM,GAAG,EAAE,IAAKE,GAAMA,EAAE,KAAK,CAAC,EAAE,OAAO,OAAO,CAAC,EACzE,OAAOH,EAAI,OAAQI,GAAMF,EAAK,IAAIE,CAAC,CAAC,CACtC,CAIO,SAASC,EACdN,EACAO,EACAC,EACAC,EACuF,CACvF,QAAWC,KAAK,OAAO,KAAKF,CAAM,EAChC,GAAI,CAACD,EAAK,OAAOG,CAAC,EAAG,MAAO,CAAE,GAAI,GAAO,MAAO,sBAAsBA,gBAAgB,OAAO,KAAKH,EAAK,MAAM,EAAE,KAAK,IAAI,GAAK,QAAS,EAExI,IAAMI,EAAiC,CAAC,EACxC,OAAW,CAACC,EAAMC,CAAC,IAAK,OAAO,QAAQN,EAAK,MAAM,EAAG,CACnD,IAAIO,EAAMN,EAAOI,CAAI,EAGrB,IAF0BE,GAAQ,MAAQA,IAAQ,KAAOD,EAAE,eAAcC,EAAML,EAASG,CAAI,IAClEE,GAAQ,MAAQA,IAAQ,KAAOD,EAAE,UAAY,SAAWC,EAAMD,EAAE,SACjEC,GAAQ,MAAQA,IAAQ,GAAI,CACnD,GAAID,EAAE,SAAU,MAAO,CAAE,GAAI,GAAO,MAAO,cAAcD,mBAAsBC,EAAE,aAAc,EAC/F,SAEF,IAAME,EAAQ,MAAM,QAAQD,CAAG,EAAIA,EAAI,IAAI,MAAM,EAAE,KAAK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AIC,EAAK,OAAOA,EAChB,IAAME,EAAOf,EAAIK,GAAM,IAAI,EACrBW,EAAOhB,EAAIK,GAAM,IAAI,EAC3B,GAAI,CAACU,GAAQ,CAACC,EAAM,MAAO,CAAE,OAAQ,IAAK,KAAM,CAAE,MAAO,4BAA6B,CAAE,EACxF,IAAMC,EAASZ,GAAM,QAAU,OAAOA,EAAK,QAAW,UAAY,CAAC,MAAM,QAAQA,EAAK,MAAM,EACvFA,EAAK,OACN,CAAC,EACCa,EAAI,MAAMC,EAAmBZ,EAAQ,CAAE,QAASK,EAAO,KAAAG,EAAM,MAAOf,EAAIK,GAAM,KAAK,GAAK,OAAW,KAAAW,EAAM,OAAAC,CAAO,EAAGT,CAAI,EAC7H,OAAKU,EAAE,GACA,CAAE,OAAQ,IAAK,KAAM,CAAE,OAAQA,EAAE,OAAQ,KAAMA,EAAE,KAAM,UAAWA,EAAE,SAAU,CAAE,EADrE,CAAE,OAAQA,EAAE,QAAU,KAAOA,EAAE,OAAS,IAAMA,EAAE,OAAS,IAAK,KAAM,CAAE,MAAOA,EAAE,KAAM,CAAE,EAI3G,OAAId,IAAS,sBAAwBA,IAAS,sBAA8B,CAAE,OAAQ,IAAK,KAAM,CAAE,MAAO,oBAAqB,CAAE,EAC1H,CAAE,OAAQ,IAAK,KAAM,CAAE,MAAO,WAAY,CAAE,CACrD","names":["MAX_BODY","ID_PARAM","allowedReads","i","spec","all","only","pick","s","r","buildReadUrl","read","params","metadata","k","values","name","p","raw","value","items","item","used","pathError","path","_m","v","base","url","runIntegrationRead","config","req","deps","providers","BUILTIN_PROVIDERS","providerFor","found","getIntegration","built","token","resolveAccessToken","f","sendToken","e","why","safeProviderText","headers","res","text","j","hint","connectCommand","truncated","readCatalog","agentId","list","out","str","v","handleIntegrationsApi","method","path","body","query","config","deps","m","agentOk","id","agent","bad","readCatalog","kind","read","params","r","runIntegrationRead"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=doctor-
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j}from"./chunk-Y4YOYOCG.js";import"./chunk-FOWRNDMJ.js";import"./chunk-B6VASQHD.js";import"./chunk-5VD2J4JN.js";import"./chunk-IMLAPB7G.js";import"./chunk-7QW4RECS.js";import"./chunk-BYEL7KKR.js";import"./chunk-XPZSEDE3.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-MNG2AMKZ.js";import"./chunk-QPABR72X.js";import"./chunk-KP7KDLZ2.js";import"./chunk-QUFIUXMQ.js";import"./chunk-36X7D4JA.js";import"./chunk-OSH2PEBH.js";import"./chunk-7I7IEX4S.js";import"./chunk-RIBANO2H.js";import"./chunk-VJ5HC63R.js";import"./chunk-UEEB3UTU.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{j as daemonVoiceCheck,b as doctor,i as mcpHeaderEnvChecks,g as meshPeerTokenChecks,h as meshTokenChecksFromConfig,a as runDoctorChecks,e as runMirrorChecks,d as runNativeChecks,c as runNotificationChecks,f as runReminderChecks};
|
|
2
|
+
//# sourceMappingURL=doctor-EDZO7BUJ.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -9028,11 +9028,11 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
9028
9028
|
provider: "system" | "elevenlabs";
|
|
9029
9029
|
fallback: "system" | "none";
|
|
9030
9030
|
palette: string;
|
|
9031
|
-
answers: "wait" | "play";
|
|
9032
9031
|
card: {
|
|
9033
9032
|
timeout: number;
|
|
9034
9033
|
maxHeight: number;
|
|
9035
9034
|
};
|
|
9035
|
+
answers: "wait" | "play";
|
|
9036
9036
|
locale: string;
|
|
9037
9037
|
pronunciations: {
|
|
9038
9038
|
written: string;
|
|
@@ -9072,11 +9072,11 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
9072
9072
|
provider?: "system" | "elevenlabs" | undefined;
|
|
9073
9073
|
fallback?: "system" | "none" | undefined;
|
|
9074
9074
|
palette?: string | undefined;
|
|
9075
|
-
answers?: "wait" | "play" | undefined;
|
|
9076
9075
|
card?: {
|
|
9077
9076
|
timeout?: number | undefined;
|
|
9078
9077
|
maxHeight?: number | undefined;
|
|
9079
9078
|
} | undefined;
|
|
9079
|
+
answers?: "wait" | "play" | undefined;
|
|
9080
9080
|
locale?: string | undefined;
|
|
9081
9081
|
listener?: string | undefined;
|
|
9082
9082
|
pronunciations?: {
|
|
@@ -11493,11 +11493,11 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
11493
11493
|
provider: "system" | "elevenlabs";
|
|
11494
11494
|
fallback: "system" | "none";
|
|
11495
11495
|
palette: string;
|
|
11496
|
-
answers: "wait" | "play";
|
|
11497
11496
|
card: {
|
|
11498
11497
|
timeout: number;
|
|
11499
11498
|
maxHeight: number;
|
|
11500
11499
|
};
|
|
11500
|
+
answers: "wait" | "play";
|
|
11501
11501
|
locale: string;
|
|
11502
11502
|
pronunciations: {
|
|
11503
11503
|
written: string;
|
|
@@ -12979,11 +12979,11 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
12979
12979
|
provider?: "system" | "elevenlabs" | undefined;
|
|
12980
12980
|
fallback?: "system" | "none" | undefined;
|
|
12981
12981
|
palette?: string | undefined;
|
|
12982
|
-
answers?: "wait" | "play" | undefined;
|
|
12983
12982
|
card?: {
|
|
12984
12983
|
timeout?: number | undefined;
|
|
12985
12984
|
maxHeight?: number | undefined;
|
|
12986
12985
|
} | undefined;
|
|
12986
|
+
answers?: "wait" | "play" | undefined;
|
|
12987
12987
|
locale?: string | undefined;
|
|
12988
12988
|
listener?: string | undefined;
|
|
12989
12989
|
pronunciations?: {
|
|
@@ -17248,15 +17248,15 @@ declare const graphNodeSchema: z.ZodObject<{
|
|
|
17248
17248
|
createdBy: z.ZodOptional<z.ZodString>;
|
|
17249
17249
|
}, "strip", z.ZodTypeAny, {
|
|
17250
17250
|
id: string;
|
|
17251
|
-
parentId: string | null;
|
|
17252
17251
|
createdAt: string;
|
|
17252
|
+
parentId: string | null;
|
|
17253
17253
|
axes: Record<string, string>;
|
|
17254
17254
|
level: string;
|
|
17255
17255
|
createdBy?: string | undefined;
|
|
17256
17256
|
}, {
|
|
17257
17257
|
id: string;
|
|
17258
|
-
parentId: string | null;
|
|
17259
17258
|
createdAt: string;
|
|
17259
|
+
parentId: string | null;
|
|
17260
17260
|
axes: Record<string, string>;
|
|
17261
17261
|
level: string;
|
|
17262
17262
|
createdBy?: string | undefined;
|
|
@@ -17384,15 +17384,15 @@ declare const nodesFileSchema: z.ZodObject<{
|
|
|
17384
17384
|
createdBy: z.ZodOptional<z.ZodString>;
|
|
17385
17385
|
}, "strip", z.ZodTypeAny, {
|
|
17386
17386
|
id: string;
|
|
17387
|
-
parentId: string | null;
|
|
17388
17387
|
createdAt: string;
|
|
17388
|
+
parentId: string | null;
|
|
17389
17389
|
axes: Record<string, string>;
|
|
17390
17390
|
level: string;
|
|
17391
17391
|
createdBy?: string | undefined;
|
|
17392
17392
|
}, {
|
|
17393
17393
|
id: string;
|
|
17394
|
-
parentId: string | null;
|
|
17395
17394
|
createdAt: string;
|
|
17395
|
+
parentId: string | null;
|
|
17396
17396
|
axes: Record<string, string>;
|
|
17397
17397
|
level: string;
|
|
17398
17398
|
createdBy?: string | undefined;
|
|
@@ -17401,8 +17401,8 @@ declare const nodesFileSchema: z.ZodObject<{
|
|
|
17401
17401
|
version: number;
|
|
17402
17402
|
nodes: {
|
|
17403
17403
|
id: string;
|
|
17404
|
-
parentId: string | null;
|
|
17405
17404
|
createdAt: string;
|
|
17405
|
+
parentId: string | null;
|
|
17406
17406
|
axes: Record<string, string>;
|
|
17407
17407
|
level: string;
|
|
17408
17408
|
createdBy?: string | undefined;
|
|
@@ -17411,8 +17411,8 @@ declare const nodesFileSchema: z.ZodObject<{
|
|
|
17411
17411
|
version?: number | undefined;
|
|
17412
17412
|
nodes?: {
|
|
17413
17413
|
id: string;
|
|
17414
|
-
parentId: string | null;
|
|
17415
17414
|
createdAt: string;
|
|
17415
|
+
parentId: string | null;
|
|
17416
17416
|
axes: Record<string, string>;
|
|
17417
17417
|
level: string;
|
|
17418
17418
|
createdBy?: string | undefined;
|
|
@@ -18752,8 +18752,9 @@ declare const workflowRunSchema: z.ZodObject<{
|
|
|
18752
18752
|
status: "failed" | "completed" | "running" | "canceled" | "paused";
|
|
18753
18753
|
id: string;
|
|
18754
18754
|
context: Record<string, Record<string, unknown>>;
|
|
18755
|
-
|
|
18755
|
+
pending: string[];
|
|
18756
18756
|
createdAt: string;
|
|
18757
|
+
updatedAt: string;
|
|
18757
18758
|
history: {
|
|
18758
18759
|
at: string;
|
|
18759
18760
|
status: "timeout" | "ok" | "failed" | "skipped" | "resumed" | "paused";
|
|
@@ -18765,7 +18766,6 @@ declare const workflowRunSchema: z.ZodObject<{
|
|
|
18765
18766
|
note?: string | undefined;
|
|
18766
18767
|
startedAt?: string | undefined;
|
|
18767
18768
|
}[];
|
|
18768
|
-
pending: string[];
|
|
18769
18769
|
workflowVersion: 2;
|
|
18770
18770
|
workflowId: string;
|
|
18771
18771
|
homeNode: string;
|
|
@@ -18881,8 +18881,8 @@ declare const workflowRunSchema: z.ZodObject<{
|
|
|
18881
18881
|
}, {
|
|
18882
18882
|
status: "failed" | "completed" | "running" | "canceled" | "paused";
|
|
18883
18883
|
id: string;
|
|
18884
|
-
updatedAt: string;
|
|
18885
18884
|
createdAt: string;
|
|
18885
|
+
updatedAt: string;
|
|
18886
18886
|
workflowVersion: 2;
|
|
18887
18887
|
workflowId: string;
|
|
18888
18888
|
homeNode: string;
|
|
@@ -18891,6 +18891,7 @@ declare const workflowRunSchema: z.ZodObject<{
|
|
|
18891
18891
|
backend: string;
|
|
18892
18892
|
};
|
|
18893
18893
|
context?: Record<string, Record<string, unknown>> | undefined;
|
|
18894
|
+
pending?: string[] | undefined;
|
|
18894
18895
|
history?: {
|
|
18895
18896
|
at: string;
|
|
18896
18897
|
status: "timeout" | "ok" | "failed" | "skipped" | "resumed" | "paused";
|
|
@@ -18902,7 +18903,6 @@ declare const workflowRunSchema: z.ZodObject<{
|
|
|
18902
18903
|
startedAt?: string | undefined;
|
|
18903
18904
|
inputKeys?: string[] | undefined;
|
|
18904
18905
|
}[] | undefined;
|
|
18905
|
-
pending?: string[] | undefined;
|
|
18906
18906
|
meta?: {
|
|
18907
18907
|
followUp?: boolean | undefined;
|
|
18908
18908
|
tags?: string[] | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Ma as Tt,Na as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-
|
|
1
|
+
import{Ma as Tt,Na as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-EANSYWBQ.js";import"./chunk-FCDMB2JA.js";import"./chunk-GTJIKXDB.js";import"./chunk-N6NZBAWR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-5VD2J4JN.js";import"./chunk-IMLAPB7G.js";import"./chunk-7QW4RECS.js";import"./chunk-BYEL7KKR.js";import"./chunk-MRIVENBY.js";import"./chunk-BIYEGA7Q.js";import"./chunk-XPZSEDE3.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-RB7M2NPU.js";import"./chunk-3Q6MRG3P.js";import"./chunk-2VDO2HEK.js";import"./chunk-JWDJMFU6.js";import"./chunk-2P5NP4H6.js";import"./chunk-B4KQC3DG.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-A5GYG56I.js";import"./chunk-M4VYHPDS.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-UKUH662W.js";import"./chunk-6TTGRTDO.js";import"./chunk-MNG2AMKZ.js";import"./chunk-RX5O5637.js";import"./chunk-5ELIX7BQ.js";import"./chunk-X7UQY7CH.js";import"./chunk-JKT5EFXT.js";import"./chunk-QPABR72X.js";import"./chunk-EQPMQSJE.js";import"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-XVV7ZZ77.js";import{Ca as yt,m as lt,n as ct,o as dt,p as mt,q as pt}from"./chunk-T7WY5BSJ.js";import"./chunk-RUNCUVAH.js";import"./chunk-MEFPXHQJ.js";import"./chunk-7AB3QUGH.js";import{a as L}from"./chunk-BAXGL6TY.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-PSOE356C.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-GV7S5BAX.js";import"./chunk-SZDACK6O.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-VJVXEVZ7.js";import{u as ut}from"./chunk-IAR5F3T5.js";import"./chunk-P65XGEB7.js";import"./chunk-3UOTLMXD.js";import"./chunk-VWTBHLMX.js";import"./chunk-BE64IJWM.js";import"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GSX4NK2N.js";import"./chunk-HPRLRD4P.js";import"./chunk-TV5BDCQA.js";import{a as ht}from"./chunk-ZPCSPEGO.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-CJI26AJC.js";import"./chunk-JTFCU5LH.js";import{f as gt,g as ft}from"./chunk-QOEO27LF.js";import"./chunk-WPNRDEHW.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-V3FSKTDF.js";import{j as it,k as rt,l as at}from"./chunk-WKR2OSCH.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-QUFIUXMQ.js";import"./chunk-GDHSJH3T.js";import"./chunk-36X7D4JA.js";import"./chunk-2HBEZV7L.js";import"./chunk-A7JSRDJL.js";import"./chunk-BERWTVG2.js";import"./chunk-AHWWJ7AF.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-DCIYOPJF.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{Fb as tt,Hb as st,Kb as ot,Rb as nt}from"./chunk-RIBANO2H.js";import"./chunk-VJ5HC63R.js";import"./chunk-UEEB3UTU.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.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).
|