agentix-cli 0.20.0 → 0.21.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/{agent-57MG4LBM.js → agent-I3ILI3MO.js} +2 -2
- package/dist/{board-dashboard-HXDOYGIG.js → board-dashboard-ASI6MDKX.js} +339 -97
- package/dist/board-dashboard-ASI6MDKX.js.map +1 -0
- package/dist/{chunk-WFHIIVLL.js → chunk-2B2DIQKD.js} +75 -51
- package/dist/chunk-2B2DIQKD.js.map +1 -0
- package/dist/{chunk-MBOLXKA2.js → chunk-5GDCJ2SF.js} +13 -6
- package/dist/chunk-5GDCJ2SF.js.map +1 -0
- package/dist/{chunk-23AUU4S2.js → chunk-5XZ73VM4.js} +38 -38
- package/dist/chunk-5XZ73VM4.js.map +1 -0
- package/dist/{chunk-DLVOHCTA.js → chunk-AANSVC5A.js} +2 -2
- package/dist/{chunk-TC3BSUP7.js → chunk-AGINLNAW.js} +2 -2
- package/dist/{chunk-6B74TO2J.js → chunk-BLRLUF2H.js} +2 -2
- package/dist/chunk-EQNM3TOF.js +15 -0
- package/dist/chunk-EQNM3TOF.js.map +1 -0
- package/dist/{chunk-WPPUOTY6.js → chunk-FUYZUGNQ.js} +2 -2
- package/dist/chunk-GSX4NK2N.js +2 -0
- package/dist/chunk-GSX4NK2N.js.map +1 -0
- package/dist/chunk-GV7S5BAX.js +2 -0
- package/dist/chunk-GV7S5BAX.js.map +1 -0
- package/dist/{chunk-7GVXCOLO.js → chunk-IFQQVDM6.js} +85 -83
- package/dist/chunk-IFQQVDM6.js.map +1 -0
- package/dist/{chunk-QW2OYR3N.js → chunk-K6MC66D6.js} +2 -2
- package/dist/chunk-SZDACK6O.js +2 -0
- package/dist/chunk-SZDACK6O.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/{config-QXWKEQON.js → config-RWHSEE4N.js} +2 -2
- package/dist/config-mutator-JKCNCY2F.js +2 -0
- package/dist/doctor-KWN7NUFQ.js +2 -0
- package/dist/index.js +1 -1
- package/dist/program-JEKM7SCS.js +2 -0
- package/dist/{registry-HM4ELSXS.js → registry-EGKDMVSP.js} +2 -2
- package/dist/runner-BFYDWPUO.js +2 -0
- package/dist/scheduler-ED4FCI2Y.js +2 -0
- package/dist/scheduler-ED4FCI2Y.js.map +1 -0
- package/dist/store-I3HEWVLQ.js +2 -0
- package/dist/store-I3HEWVLQ.js.map +1 -0
- package/dist/types-Y6ZCZ52Z.js +2 -0
- package/dist/types-Y6ZCZ52Z.js.map +1 -0
- package/dist/web/workflow-editor.global.js +12 -10
- package/dist/web/workflow-editor.global.js.map +1 -1
- package/package.json +1 -1
- package/dist/board-dashboard-HXDOYGIG.js.map +0 -1
- package/dist/chunk-23AUU4S2.js.map +0 -1
- package/dist/chunk-7GVXCOLO.js.map +0 -1
- package/dist/chunk-E4ZZILAK.js +0 -15
- package/dist/chunk-E4ZZILAK.js.map +0 -1
- package/dist/chunk-MBOLXKA2.js.map +0 -1
- package/dist/chunk-WFHIIVLL.js.map +0 -1
- package/dist/config-mutator-53XGR2NT.js +0 -2
- package/dist/doctor-SEOUFHSL.js +0 -2
- package/dist/program-WWCXMRU2.js +0 -2
- package/dist/scheduler-XVFIK4XH.js +0 -2
- /package/dist/{agent-57MG4LBM.js.map → agent-I3ILI3MO.js.map} +0 -0
- /package/dist/{chunk-DLVOHCTA.js.map → chunk-AANSVC5A.js.map} +0 -0
- /package/dist/{chunk-TC3BSUP7.js.map → chunk-AGINLNAW.js.map} +0 -0
- /package/dist/{chunk-6B74TO2J.js.map → chunk-BLRLUF2H.js.map} +0 -0
- /package/dist/{chunk-WPPUOTY6.js.map → chunk-FUYZUGNQ.js.map} +0 -0
- /package/dist/{chunk-QW2OYR3N.js.map → chunk-K6MC66D6.js.map} +0 -0
- /package/dist/{config-QXWKEQON.js.map → config-RWHSEE4N.js.map} +0 -0
- /package/dist/{config-mutator-53XGR2NT.js.map → config-mutator-JKCNCY2F.js.map} +0 -0
- /package/dist/{doctor-SEOUFHSL.js.map → doctor-KWN7NUFQ.js.map} +0 -0
- /package/dist/{program-WWCXMRU2.js.map → program-JEKM7SCS.js.map} +0 -0
- /package/dist/{registry-HM4ELSXS.js.map → registry-EGKDMVSP.js.map} +0 -0
- /package/dist/{scheduler-XVFIK4XH.js.map → runner-BFYDWPUO.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{e as $}from"./chunk-
|
|
1
|
+
import{e as $}from"./chunk-5GDCJ2SF.js";import{Command as C}from"commander";import f from"chalk";import{execFileSync as w}from"child_process";import{existsSync as y,readFileSync as k,readdirSync as j,statSync as A}from"fs";import{resolve as m}from"path";async function S(s={}){let t=[];await R(t);let e=O(t);return e&&I(t,e),e&&W(t,e),e&&N(t,e),e&&E(t,e),s.running!==!1&&e&&await T(t,e),{checks:t,summary:x(t)}}var H=new C().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 s=>{let{checks:t,summary:e}=await S({running:s.running!==!1});s.json?process.stdout.write(JSON.stringify({checks:t,summary:e},null,2)+`
|
|
2
2
|
`):P(t),process.exit(e.errors>0?1:0)});async function R(s){let t=Number(process.versions.node.split(".")[0]);s.push({severity:t>=20?"ok":"fail",group:"Environment",title:`Node.js ${process.versions.node}`,detail:t>=20?void 0:"AgentX needs Node 20 or newer.",fix:t>=20?void 0:"Install a newer Node (nvm install 20 && nvm use 20)"});let e=o=>{try{return w(process.platform==="win32"?"where":"which",[o],{encoding:"utf-8"}).trim().split(`
|
|
3
3
|
`)[0]}catch{return null}},i=e("npm");s.push({severity:i?"ok":"fail",group:"Environment",title:i?"npm on PATH":"npm not found",detail:i||void 0});let r=e("claude");if(r){let o;try{o=w("claude",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}s.push({severity:"ok",group:"Environment",title:`claude CLI ${o||"installed"}`,detail:r})}else s.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"})}function O(s){let t=m(process.cwd(),"agentx.json");if(!y(t))return s.push({severity:"fail",group:"Config",title:"agentx.json not found",detail:`Looked in ${t}`,fix:"Run `agentx setup` to create one via the web wizard."}),null;let e;try{e=JSON.parse(k(t,"utf-8"))}catch(r){return s.push({severity:"fail",group:"Config",title:"agentx.json is not valid JSON",detail:r.message}),null}try{$(t),s.push({severity:"ok",group:"Config",title:`agentx.json valid (${Object.keys(e.agents||{}).length} agents, ${Object.keys(e.crons||{}).length} schedules)`})}catch(r){s.push({severity:"fail",group:"Config",title:"agentx.json failed schema validation",detail:r.message,fix:"Open /admin \u2192 Advanced tab to edit and re-save."})}let i=Object.entries(e.agents||{}).filter(([,r])=>r.tier==="claude-code");return i.length>0&&((()=>{try{return w(process.platform==="win32"?"where":"which",["claude"],{stdio:"ignore"}),!0}catch{return!1}})()||s.push({severity:"fail",group:"Config",title:`${i.length} agent(s) use claude-code tier but claude CLI is missing`,detail:i.map(([o])=>o).join(", "),fix:"Install Claude Code (https://docs.anthropic.com/en/docs/claude-code) or switch these agents to tier=sdk."})),e}function I(s,t){let e=new Set;if(v(t,e),e.size===0){s.push({severity:"ok",group:"Secrets",title:"No ${VAR} references in agentx.json"});return}let i=m(process.cwd(),".env"),r={};if(y(i))for(let a of k(i,"utf-8").split(/\r?\n/)){let c=a.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/i);c&&(r[c[1]]=c[2])}let o=[],l=[];for(let a of e){let c=process.env[a]??r[a];c===void 0?o.push(a):(!c.trim()||/^["']?\s*["']?$/.test(c))&&l.push(a)}o.length===0&&l.length===0?s.push({severity:"ok",group:"Secrets",title:`${e.size} env reference(s) resolved`}):(o.length>0&&s.push({severity:"fail",group:"Secrets",title:`${o.length} env var(s) referenced in agentx.json but missing`,detail:o.join(", "),fix:`Add to .env \u2014 e.g. ${o[0]}=<value>`}),l.length>0&&s.push({severity:"warn",group:"Secrets",title:`${l.length} env var(s) set but empty`,detail:l.join(", ")}))}function v(s,t){if(typeof s=="string")for(let e of s.matchAll(/\$\{([A-Z_][A-Z0-9_]*)\}/g))t.add(e[1]);else if(Array.isArray(s))for(let e of s)v(e,t);else if(s&&typeof s=="object")for(let e of Object.values(s))v(e,t)}function W(s,t){let e=[];for(let[i,r]of Object.entries(t.agents||{})){if(!r.workspace)continue;let o=r.workspace.startsWith("/")?r.workspace:m(process.cwd(),r.workspace);try{A(o).isDirectory()||e.push(`${i}: ${o} (exists but not a directory)`)}catch{e.push(`${i}: ${o}`)}}e.length===0?s.push({severity:"ok",group:"Workspaces",title:"All agent workspace folders exist"}):s.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 N(s,t){let e=/\$\{[A-Za-z_][A-Za-z0-9_]*\}/g,i=[];for(let[r,o]of Object.entries(t.agents||{})){if(!o.workspace)continue;let l=o.workspace.startsWith("/")?o.workspace:m(process.cwd(),o.workspace);for(let a of["settings.json","settings.local.json"]){let c=m(l,".claude",a);if(!y(c))continue;let h;try{h=JSON.parse(k(c,"utf-8"))}catch(u){i.push({severity:"fail",agent:r,msg:`${a}: JSON parse error \u2014 ${u.message}`});continue}let n=h.env||{};for(let[u,p]of Object.entries(n)){if(typeof p!="string")continue;let b=p.match(e);b&&i.push({severity:"fail",agent:r,msg:`${a} env.${u} contains unexpanded ${[...new Set(b)].join(",")} \u2014 Claude Code does NOT expand \${VAR} in settings.json (use a fully-literal value)`})}let g=n.PATH;if(typeof g=="string"){let u=g.split(":").filter(Boolean);u.includes("/usr/bin")||i.push({severity:"fail",agent:r,msg:`${a} env.PATH missing /usr/bin \u2014 cat/head/sh/which will fail`}),u.includes("/bin")||i.push({severity:"fail",agent:r,msg:`${a} env.PATH missing /bin \u2014 ls/cp/mv will fail`})}let d=h.permissions;if(d&&typeof d=="object"&&"allow"in d){let u=d.allow,p=d.deny;Array.isArray(u)&&u.length===0&&Array.isArray(p)&&p.length>0&&i.push({severity:"warn",agent:r,msg:`${a} permissions.allow is explicitly [] with ${p.length} deny rules \u2014 agent may be locked out (omit the key to use defaults instead)`})}}}if(i.length===0){s.push({severity:"ok",group:"Workspace settings",title:`All ${Object.keys(t.agents||{}).length} agent .claude/settings.json files clean`});return}for(let r of i)s.push({severity:r.severity,group:"Workspace settings",title:`${r.agent}: ${r.msg}`,fix:r.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 E(s,t){let e=t.webhooks??[],i=[],r=m(process.cwd(),t.workflows?.dir||".agentx/workflows"),o=new Set;try{if(y(r))for(let n of j(r))n.endsWith(".json")&&!n.startsWith("_")&&!n.endsWith(".disabled.json")&&o.add(n.replace(/\.json$/,""))}catch{}let l=new Set(["github","gitlab"]);for(let n of e){if(!n.enabled||!l.has(n.source))continue;!(n.triggers&&Object.keys(n.triggers).length>0)&&!n.defaultWorkflow&&i.push({severity:"warn",title:`webhook "${n.id}" (${n.source} -> ${n.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 n of e)if(!(!n.enabled||!n.triggers)){for(let[g,d]of Object.entries(n.triggers))o.size>0&&!o.has(d)&&i.push({severity:"fail",title:`webhook "${n.id}".triggers["${g}"] -> "${d}" \u2014 no such workflow under ${t.workflows?.dir||".agentx/workflows"}`,fix:"Create the workflow file or fix the id in agentx.json"});n.defaultWorkflow&&o.size>0&&!o.has(n.defaultWorkflow)&&i.push({severity:"fail",title:`webhook "${n.id}".defaultWorkflow -> "${n.defaultWorkflow}" \u2014 no such workflow`,fix:"Create the workflow file or fix the id in agentx.json"})}let a=new Set((t.mesh?.peers??[]).map(n=>n.name));for(let n of e)!n.enabled||!n.node||a.has(n.node)||i.push({severity:"fail",title:`webhook "${n.id}" routes to mesh peer "${n.node}" which is not in mesh.peers`,fix:"Add the peer to mesh.peers or remove the node field on the webhook."});let c=new Map;for(let n of e){if(!n.enabled)continue;let g=`${n.source}:${n.agentId}`,d=c.get(g);d?i.push({severity:"warn",title:`webhook entries "${d}" and "${n.id}" both enabled for ${n.source} -> ${n.agentId}; only the first is dispatched`,fix:"Disable one entry, or merge their triggers maps into a single entry."}):c.set(g,n.id)}let h=new Set(Object.keys(t.agents??{}));for(let n of t.channels?.gitlab?.agentMappings??[])if(n?.agentId){if(n.node){a.has(n.node)||i.push({severity:"fail",title:`gitlab.agentMappings entry agentId="${n.agentId}" routes to mesh peer "${n.node}" which is not in mesh.peers`,fix:"Add the peer to mesh.peers or drop the node field on the mapping."});continue}h.has(n.agentId)||i.push({severity:"warn",title:`gitlab.agentMappings entry agentId="${n.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[n,g]of Object.entries(t.channels?.telegram?.accounts??{}))g.agentBinding?h.has(g.agentBinding)||i.push({severity:"fail",title:`telegram account "${n}".agentBinding -> "${g.agentBinding}" \u2014 no such agent in agents.*`,fix:"Fix the agentBinding or define the agent in agents.*."}):i.push({severity:"fail",title:`telegram account "${n}" has no agentBinding; every DM to this bot will drop`,fix:"Set agentBinding to a valid agent id."});if(i.length===0){s.push({severity:"ok",group:"Routing",title:`${e.length} webhook(s), ${Object.keys(t.channels?.telegram?.accounts??{}).length} telegram account(s) \u2014 all routing references resolve`});return}for(let n of i)s.push({severity:n.severity,group:"Routing",title:n.title,fix:n.fix})}async function T(s,t){let e=t.dashboard?.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800",i={};t.dashboard?.token&&(i.Authorization=`Bearer ${t.dashboard.token}`);try{let r=new AbortController,o=setTimeout(()=>r.abort(),2e3),l=await fetch(e+"/health",{headers:i,signal:r.signal});if(clearTimeout(o),!l.ok){s.push({severity:"warn",group:"Runtime",title:`Daemon responded ${l.status}`,detail:e});return}let a=await l.json();s.push({severity:"ok",group:"Runtime",title:`Daemon healthy \u2014 ${a.agents?.length??0} agents live, uptime ${Math.round((a.uptime??0)/60)}m`,detail:e})}catch{s.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 x(s){return{errors:s.filter(t=>t.severity==="fail").length,warnings:s.filter(t=>t.severity==="warn").length,ok:s.filter(t=>t.severity==="ok").length}}function P(s){console.log(),console.log(f.bold(" agentx doctor")),console.log();let t=new Map;for(let i of s)t.has(i.group)||t.set(i.group,[]),t.get(i.group).push(i);for(let[i,r]of t){console.log(f.bold(" "+i));for(let o of r){let l=o.severity==="ok"?f.green("\u2713"):o.severity==="warn"?f.yellow("!"):f.red("\u2717");console.log(` ${l} ${o.title}`),o.detail&&console.log(f.dim(" "+o.detail.replace(/\n/g,`
|
|
5
5
|
`))),o.fix&&console.log(f.dim(" \u2192 "+o.fix))}console.log()}let e=x(s);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{S as a,H as b};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-FUYZUGNQ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{z as t}from"zod";var n=t.enum(["string","number","boolean"]),o=t.object({name:t.string().regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/,"input name must be identifier-safe"),type:n.default("string"),required:t.boolean().default(!1),defaultValue:t.union([t.string(),t.number(),t.boolean()]).optional(),description:t.string().optional()}),e=t.object({id:t.string().regex(/^[a-z][a-z0-9_-]*$/,"id must be lowercase slug (alnum, '-', '_')"),title:t.string().min(1),description:t.string().optional(),inputs:t.array(o).default([]),timeoutMs:t.number().int().min(100).max(6e5).default(3e4),createdAt:t.string().optional(),updatedAt:t.string().optional()}),i=e.extend({kind:t.literal("shell"),command:t.string().min(1),cwd:t.string().optional(),env:t.record(t.string(),t.string()).optional()}),r=e.extend({kind:t.literal("http"),url:t.string().url(),method:t.enum(["GET","POST","PUT","PATCH","DELETE"]).default("POST"),headers:t.record(t.string(),t.string()).optional(),body:t.string().optional()}),p=t.discriminatedUnion("kind",[i,r]);export{n as a,o as b,i as c,r as d,p as e};
|
|
2
|
+
//# sourceMappingURL=chunk-GSX4NK2N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/types.ts"],"sourcesContent":["import { z } from \"zod\"\n\n// --- Action registry types ---\n//\n// Actions are reusable, parameterized invocations operators register\n// once and call from workflows, CLI, or the dashboard. Two kinds for v1:\n//\n// kind = \"shell\" — exec a shell command. Most flexible.\n// kind = \"http\" — POST/GET/PUT/DELETE/PATCH to a URL.\n//\n// Inputs are typed and templated into the command/url/body via {{name}}\n// markers. Env-var refs ($VAR) are resolved against process.env at run\n// time.\n//\n// On disk: .agentx/actions/<id>.json (one file per action).\n\nexport const actionInputTypeSchema = z.enum([\"string\", \"number\", \"boolean\"])\nexport type ActionInputType = z.infer<typeof actionInputTypeSchema>\n\nexport const actionInputSchema = z.object({\n name: z.string().regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/, \"input name must be identifier-safe\"),\n type: actionInputTypeSchema.default(\"string\"),\n required: z.boolean().default(false),\n defaultValue: z.union([z.string(), z.number(), z.boolean()]).optional(),\n description: z.string().optional(),\n})\nexport type ActionInput = z.infer<typeof actionInputSchema>\n\nconst baseActionSchema = z.object({\n id: z.string().regex(/^[a-z][a-z0-9_-]*$/, \"id must be lowercase slug (alnum, '-', '_')\"),\n title: z.string().min(1),\n description: z.string().optional(),\n inputs: z.array(actionInputSchema).default([]),\n timeoutMs: z.number().int().min(100).max(600_000).default(30_000),\n createdAt: z.string().optional(),\n updatedAt: z.string().optional(),\n})\n\nexport const shellActionSchema = baseActionSchema.extend({\n kind: z.literal(\"shell\"),\n /** Templated shell command. {{name}} and ${ENV_VAR} are interpolated. */\n command: z.string().min(1),\n /** When set, the working directory the command runs in. Defaults to the\n * daemon's cwd. Useful when the action's a script in a subproject. */\n cwd: z.string().optional(),\n /** Extra env vars merged with process.env at invocation. Values may\n * reference {{input}} or other env vars. */\n env: z.record(z.string(), z.string()).optional(),\n})\nexport type ShellAction = z.infer<typeof shellActionSchema>\n\nexport const httpActionSchema = baseActionSchema.extend({\n kind: z.literal(\"http\"),\n /** URL with optional {{name}} substitutions. */\n url: z.string().url(),\n method: z.enum([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]).default(\"POST\"),\n headers: z.record(z.string(), z.string()).optional(),\n /** Body template (string). For JSON, the operator types JSON; we don't\n * pretty-print. Skipped on GET / DELETE. */\n body: z.string().optional(),\n})\nexport type HttpAction = z.infer<typeof httpActionSchema>\n\nexport const actionSchema = z.discriminatedUnion(\"kind\", [shellActionSchema, httpActionSchema])\nexport type Action = z.infer<typeof actionSchema>\n\nexport interface ActionRunResult {\n ok: boolean\n /** stdout for shell, response body for http. Capped at ~32KB. */\n output: string\n /** stderr for shell, status text + headers summary for http. */\n errors?: string\n /** Exit code (shell) or HTTP status (http). */\n status?: number\n durationMs: number\n}\n"],"mappings":"AAAA,OAAS,KAAAA,MAAS,MAgBX,IAAMC,EAAwBD,EAAE,KAAK,CAAC,SAAU,SAAU,SAAS,CAAC,EAG9DE,EAAoBF,EAAE,OAAO,CACxC,KAAMA,EAAE,OAAO,EAAE,MAAM,2BAA4B,oCAAoC,EACvF,KAAMC,EAAsB,QAAQ,QAAQ,EAC5C,SAAUD,EAAE,QAAQ,EAAE,QAAQ,EAAK,EACnC,aAAcA,EAAE,MAAM,CAACA,EAAE,OAAO,EAAGA,EAAE,OAAO,EAAGA,EAAE,QAAQ,CAAC,CAAC,EAAE,SAAS,EACtE,YAAaA,EAAE,OAAO,EAAE,SAAS,CACnC,CAAC,EAGKG,EAAmBH,EAAE,OAAO,CAChC,GAAIA,EAAE,OAAO,EAAE,MAAM,qBAAsB,6CAA6C,EACxF,MAAOA,EAAE,OAAO,EAAE,IAAI,CAAC,EACvB,YAAaA,EAAE,OAAO,EAAE,SAAS,EACjC,OAAQA,EAAE,MAAME,CAAiB,EAAE,QAAQ,CAAC,CAAC,EAC7C,UAAWF,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,IAAI,GAAO,EAAE,QAAQ,GAAM,EAChE,UAAWA,EAAE,OAAO,EAAE,SAAS,EAC/B,UAAWA,EAAE,OAAO,EAAE,SAAS,CACjC,CAAC,EAEYI,EAAoBD,EAAiB,OAAO,CACvD,KAAMH,EAAE,QAAQ,OAAO,EAEvB,QAASA,EAAE,OAAO,EAAE,IAAI,CAAC,EAGzB,IAAKA,EAAE,OAAO,EAAE,SAAS,EAGzB,IAAKA,EAAE,OAAOA,EAAE,OAAO,EAAGA,EAAE,OAAO,CAAC,EAAE,SAAS,CACjD,CAAC,EAGYK,EAAmBF,EAAiB,OAAO,CACtD,KAAMH,EAAE,QAAQ,MAAM,EAEtB,IAAKA,EAAE,OAAO,EAAE,IAAI,EACpB,OAAQA,EAAE,KAAK,CAAC,MAAO,OAAQ,MAAO,QAAS,QAAQ,CAAC,EAAE,QAAQ,MAAM,EACxE,QAASA,EAAE,OAAOA,EAAE,OAAO,EAAGA,EAAE,OAAO,CAAC,EAAE,SAAS,EAGnD,KAAMA,EAAE,OAAO,EAAE,SAAS,CAC5B,CAAC,EAGYM,EAAeN,EAAE,mBAAmB,OAAQ,CAACI,EAAmBC,CAAgB,CAAC","names":["z","actionInputTypeSchema","actionInputSchema","baseActionSchema","shellActionSchema","httpActionSchema","actionSchema"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as n}from"./chunk-GSX4NK2N.js";import{existsSync as o,mkdirSync as u,readdirSync as d,readFileSync as a,unlinkSync as l,writeFileSync as p}from"fs";import{resolve as s}from"path";var c=class{dir;constructor(r={}){let t=r.baseDir??s(process.cwd(),".agentx");this.dir=s(t,"actions"),u(this.dir,{recursive:!0})}pathFor(r){return s(this.dir,`${r}.json`)}list(){if(!o(this.dir))return[];let r=[];for(let t of d(this.dir,{withFileTypes:!0}))if(!(!t.isFile()||!t.name.endsWith(".json")))try{let e=JSON.parse(a(s(this.dir,t.name),"utf-8")),i=n.safeParse(e);i.success&&r.push(i.data)}catch{}return r.sort((t,e)=>t.id.localeCompare(e.id))}get(r){let t=this.pathFor(r);if(!o(t))return null;try{let e=JSON.parse(a(t,"utf-8")),i=n.safeParse(e);return i.success?i.data:null}catch{return null}}save(r){let t=n.parse({...r,createdAt:r.createdAt??new Date().toISOString(),updatedAt:new Date().toISOString()});return p(this.pathFor(t.id),JSON.stringify(t,null,2)),t}delete(r){let t=this.pathFor(r);return o(t)?(l(t),!0):!1}};export{c as a};
|
|
2
|
+
//# sourceMappingURL=chunk-GV7S5BAX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/store.ts"],"sourcesContent":["import { existsSync, mkdirSync, readdirSync, readFileSync, unlinkSync, writeFileSync } from \"fs\"\nimport { resolve } from \"path\"\nimport { actionSchema, type Action } from \"./types\"\n\n// --- Action registry filesystem store ---\n//\n// One JSON file per action under .agentx/actions/<id>.json. Schema-\n// validated on read; malformed files are skipped (the operator will\n// notice via `agentx actions list`).\n\nexport interface ActionStoreOptions {\n baseDir?: string\n}\n\nexport class ActionStore {\n readonly dir: string\n\n constructor(opts: ActionStoreOptions = {}) {\n const root = opts.baseDir ?? resolve(process.cwd(), \".agentx\")\n this.dir = resolve(root, \"actions\")\n mkdirSync(this.dir, { recursive: true })\n }\n\n private pathFor(id: string): string {\n return resolve(this.dir, `${id}.json`)\n }\n\n list(): Action[] {\n if (!existsSync(this.dir)) return []\n const out: Action[] = []\n for (const entry of readdirSync(this.dir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith(\".json\")) continue\n try {\n const raw = JSON.parse(readFileSync(resolve(this.dir, entry.name), \"utf-8\"))\n const parsed = actionSchema.safeParse(raw)\n if (parsed.success) out.push(parsed.data)\n } catch { /* skip malformed */ }\n }\n return out.sort((a, b) => a.id.localeCompare(b.id))\n }\n\n get(id: string): Action | null {\n const file = this.pathFor(id)\n if (!existsSync(file)) return null\n try {\n const raw = JSON.parse(readFileSync(file, \"utf-8\"))\n const parsed = actionSchema.safeParse(raw)\n return parsed.success ? parsed.data : null\n } catch { return null }\n }\n\n save(action: Action): Action {\n const parsed = actionSchema.parse({\n ...action,\n createdAt: action.createdAt ?? new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n })\n writeFileSync(this.pathFor(parsed.id), JSON.stringify(parsed, null, 2))\n return parsed\n }\n\n delete(id: string): boolean {\n const file = this.pathFor(id)\n if (!existsSync(file)) return false\n unlinkSync(file)\n return true\n }\n}\n"],"mappings":"wCAAA,OAAS,cAAAA,EAAY,aAAAC,EAAW,eAAAC,EAAa,gBAAAC,EAAc,cAAAC,EAAY,iBAAAC,MAAqB,KAC5F,OAAS,WAAAC,MAAe,OAajB,IAAMC,EAAN,KAAkB,CACd,IAET,YAAYC,EAA2B,CAAC,EAAG,CACzC,IAAMC,EAAOD,EAAK,SAAWE,EAAQ,QAAQ,IAAI,EAAG,SAAS,EAC7D,KAAK,IAAMA,EAAQD,EAAM,SAAS,EAClCE,EAAU,KAAK,IAAK,CAAE,UAAW,EAAK,CAAC,CACzC,CAEQ,QAAQC,EAAoB,CAClC,OAAOF,EAAQ,KAAK,IAAK,GAAGE,QAAS,CACvC,CAEA,MAAiB,CACf,GAAI,CAACC,EAAW,KAAK,GAAG,EAAG,MAAO,CAAC,EACnC,IAAMC,EAAgB,CAAC,EACvB,QAAWC,KAASC,EAAY,KAAK,IAAK,CAAE,cAAe,EAAK,CAAC,EAC/D,GAAI,GAACD,EAAM,OAAO,GAAK,CAACA,EAAM,KAAK,SAAS,OAAO,GACnD,GAAI,CACF,IAAME,EAAM,KAAK,MAAMC,EAAaR,EAAQ,KAAK,IAAKK,EAAM,IAAI,EAAG,OAAO,CAAC,EACrEI,EAASC,EAAa,UAAUH,CAAG,EACrCE,EAAO,SAASL,EAAI,KAAKK,EAAO,IAAI,CAC1C,MAAE,CAA6B,CAEjC,OAAOL,EAAI,KAAK,CAACO,EAAGC,IAAMD,EAAE,GAAG,cAAcC,EAAE,EAAE,CAAC,CACpD,CAEA,IAAIV,EAA2B,CAC7B,IAAMW,EAAO,KAAK,QAAQX,CAAE,EAC5B,GAAI,CAACC,EAAWU,CAAI,EAAG,OAAO,KAC9B,GAAI,CACF,IAAMN,EAAM,KAAK,MAAMC,EAAaK,EAAM,OAAO,CAAC,EAC5CJ,EAASC,EAAa,UAAUH,CAAG,EACzC,OAAOE,EAAO,QAAUA,EAAO,KAAO,IACxC,MAAE,CAAQ,OAAO,IAAK,CACxB,CAEA,KAAKK,EAAwB,CAC3B,IAAML,EAASC,EAAa,MAAM,CAChC,GAAGI,EACH,UAAWA,EAAO,WAAa,IAAI,KAAK,EAAE,YAAY,EACtD,UAAW,IAAI,KAAK,EAAE,YAAY,CACpC,CAAC,EACD,OAAAC,EAAc,KAAK,QAAQN,EAAO,EAAE,EAAG,KAAK,UAAUA,EAAQ,KAAM,CAAC,CAAC,EAC/DA,CACT,CAEA,OAAOP,EAAqB,CAC1B,IAAMW,EAAO,KAAK,QAAQX,CAAE,EAC5B,OAAKC,EAAWU,CAAI,GACpBG,EAAWH,CAAI,EACR,IAFuB,EAGhC,CACF","names":["existsSync","mkdirSync","readdirSync","readFileSync","unlinkSync","writeFileSync","resolve","ActionStore","opts","root","resolve","mkdirSync","id","existsSync","out","entry","readdirSync","raw","readFileSync","parsed","actionSchema","a","b","file","action","writeFileSync","unlinkSync"]}
|