@xenosystem/agent-sdk 0.9.10 → 0.9.11

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.
Files changed (87) hide show
  1. package/dist/agents/index.cjs +9 -9
  2. package/dist/agents/index.d.cts +12 -2
  3. package/dist/agents/index.d.ts +12 -2
  4. package/dist/agents/index.js +16 -16
  5. package/dist/agents/metafile-cjs.json +1 -1
  6. package/dist/agents/metafile-esm.json +1 -1
  7. package/dist/artifacts/browser.cjs +1 -1
  8. package/dist/artifacts/browser.d.cts +2 -2
  9. package/dist/artifacts/browser.d.ts +2 -2
  10. package/dist/artifacts/browser.js +1 -1
  11. package/dist/artifacts/{diff-artifact-C2tQZWcs.d.cts → diff-artifact-CmhmeSu5.d.cts} +87 -7
  12. package/dist/artifacts/{diff-artifact-C2tQZWcs.d.ts → diff-artifact-CmhmeSu5.d.ts} +87 -7
  13. package/dist/artifacts/index.cjs +8 -8
  14. package/dist/artifacts/index.d.cts +22 -5
  15. package/dist/artifacts/index.d.ts +22 -5
  16. package/dist/artifacts/index.js +8 -8
  17. package/dist/artifacts/metafile-cjs.json +1 -1
  18. package/dist/artifacts/metafile-esm.json +1 -1
  19. package/dist/automation/index.cjs +2 -2
  20. package/dist/automation/index.d.cts +97 -7
  21. package/dist/automation/index.d.ts +97 -7
  22. package/dist/automation/index.js +2 -2
  23. package/dist/automation/metafile-cjs.json +1 -1
  24. package/dist/automation/metafile-esm.json +1 -1
  25. package/dist/control-plane/index.cjs +7 -7
  26. package/dist/control-plane/index.d.cts +19 -2
  27. package/dist/control-plane/index.d.ts +19 -2
  28. package/dist/control-plane/index.js +7 -7
  29. package/dist/control-plane/metafile-cjs.json +1 -1
  30. package/dist/control-plane/metafile-esm.json +1 -1
  31. package/dist/electron/index.cjs +142 -142
  32. package/dist/electron/index.d.cts +24 -4
  33. package/dist/electron/index.d.ts +24 -4
  34. package/dist/electron/index.js +140 -140
  35. package/dist/electron/metafile-cjs.json +1 -1
  36. package/dist/electron/metafile-esm.json +1 -1
  37. package/dist/hooks/index.d.cts +10 -1
  38. package/dist/hooks/index.d.ts +10 -1
  39. package/dist/hosted/index.cjs +1 -1
  40. package/dist/hosted/index.js +1 -1
  41. package/dist/hosted/metafile-cjs.json +1 -1
  42. package/dist/hosted/metafile-esm.json +1 -1
  43. package/dist/index.cjs +327 -327
  44. package/dist/index.d.cts +192 -24
  45. package/dist/index.d.ts +192 -24
  46. package/dist/index.js +328 -328
  47. package/dist/mcp/index.cjs +17 -17
  48. package/dist/mcp/index.js +17 -17
  49. package/dist/mcp/metafile-cjs.json +1 -1
  50. package/dist/mcp/metafile-esm.json +1 -1
  51. package/dist/metafile-cjs.json +1 -1
  52. package/dist/metafile-esm.json +1 -1
  53. package/dist/oracle/index.cjs +1 -1
  54. package/dist/oracle/index.d.cts +86 -6
  55. package/dist/oracle/index.d.ts +86 -6
  56. package/dist/oracle/index.js +1 -1
  57. package/dist/oracle/metafile-cjs.json +1 -1
  58. package/dist/oracle/metafile-esm.json +1 -1
  59. package/dist/providers/index.cjs +10 -10
  60. package/dist/providers/index.d.cts +1 -0
  61. package/dist/providers/index.d.ts +1 -0
  62. package/dist/providers/index.js +10 -10
  63. package/dist/providers/metafile-cjs.json +1 -1
  64. package/dist/providers/metafile-esm.json +1 -1
  65. package/dist/recipes/index.cjs +2 -2
  66. package/dist/recipes/index.d.cts +10 -1
  67. package/dist/recipes/index.d.ts +10 -1
  68. package/dist/recipes/index.js +2 -2
  69. package/dist/recipes/metafile-cjs.json +1 -1
  70. package/dist/recipes/metafile-esm.json +1 -1
  71. package/dist/research/index.cjs +3 -3
  72. package/dist/research/index.d.cts +86 -6
  73. package/dist/research/index.d.ts +86 -6
  74. package/dist/research/index.js +3 -3
  75. package/dist/research/metafile-cjs.json +1 -1
  76. package/dist/research/metafile-esm.json +1 -1
  77. package/dist/session/index.cjs +20 -20
  78. package/dist/session/index.js +21 -21
  79. package/dist/session/metafile-cjs.json +1 -1
  80. package/dist/session/metafile-esm.json +1 -1
  81. package/dist/utils/index.cjs +20 -20
  82. package/dist/utils/index.d.cts +3 -1
  83. package/dist/utils/index.d.ts +3 -1
  84. package/dist/utils/index.js +17 -17
  85. package/dist/utils/metafile-cjs.json +1 -1
  86. package/dist/utils/metafile-esm.json +1 -1
  87. package/package.json +23 -22
@@ -1,12 +1,12 @@
1
- "use strict";var N=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var ye=(e,n)=>{for(var r in n)N(e,r,{get:n[r],enumerable:!0})},he=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of ge(n))!me.call(e,t)&&t!==r&&N(e,t,{get:()=>n[t],enumerable:!(o=pe(n,t))||o.enumerable});return e};var Ae=e=>he(N({},"__esModule",{value:!0}),e);var en={};ye(en,{AgentDefinitionLoader:()=>E,AgentDefinitionResolver:()=>j,AgentProfileValidationError:()=>P,XENO_AGENT_PROFILE_SCHEMA_VERSION:()=>R,agentDefinitionFromProfile:()=>Qe,agentProfileFromDefinition:()=>ae,compileAgentProfile:()=>ie,createAgentDefinitionFile:()=>Ve,createAgentDefinitionPromptSection:()=>Le,getProjectAgentDefinitionDirs:()=>Z,getProjectAgentDefinitionsDir:()=>ee,getUserAgentDefinitionsDir:()=>O,isValidAgentDefinitionName:()=>q,listBuiltInAgentProfiles:()=>Xe,renderAgentDefinition:()=>_e,renderAgentDefinitions:()=>Fe,resolveAgentDefinition:()=>je,resolveAgentProfile:()=>Ze,resolveAgentToolPolicy:()=>T,resolveBuiltInAgentProfile:()=>le,scanAgentDefinitions:()=>L,toAgentDefinitionMetadata:()=>Be,validateAgentDefinition:()=>ne});module.exports=Ae(en);var y=require("node:fs"),X=require("node:os"),p=require("node:path");function G(e){let n=Pe(e);return{frontmatter:n.frontmatter,content:n.content.trim()}}function Pe(e){let n=e.replace(/^\uFEFF/,"");if(!n.startsWith("---"))return{frontmatter:{},content:e};let r=n.search(/\r?\n/);if(r<0||n.slice(0,r).trim()!=="---")return{frontmatter:{},content:e};let o=n.slice(r+(n[r]==="\r"?2:1)),t=o.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!t||t.index===void 0)throw new Error("YAML frontmatter is not closed.");let i=o.slice(0,t.index),l=t[0],s=t.index+l.length;return{frontmatter:Y(i),content:o.slice(s)}}function Y(e){let n={},r=e.split(/\r?\n/);for(let o=0;o<r.length;o+=1){let t=r[o];if(!t.trim()||t.trimStart().startsWith("#"))continue;if(/^\s/.test(t))throw new Error(`Unexpected indentation at line ${o+1}.`);let i=be(t,o+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){n[i.key]=K(i.value,o+1);continue}let l=we(r,o+1);n[i.key]=l.value,o=l.nextIndex-1}return n}function we(e,n){let r=[],o=n;for(;o<e.length;o+=1){let i=e[o];if(!i.trim()){r.push(i);continue}if(!/^\s/.test(i))break;r.push(i.replace(/^ {2}/,""))}let t=r.filter(i=>i.trim()&&!i.trimStart().startsWith("#"));return t.length===0?{value:{},nextIndex:o}:t.every(i=>i.trimStart().startsWith("- "))?{value:t.map((i,l)=>K(i.trimStart().slice(2),n+l+1)),nextIndex:o}:{value:Y(r.join(`
2
- `)),nextIndex:o}}function be(e,n){let r=e.indexOf(":");if(r<=0)throw new Error(`Invalid YAML line ${n}.`);let o=e.slice(0,r).trim(),t=e.slice(r+1).trim();if(!o)throw new Error(`Invalid YAML key at line ${n}.`);return{key:o,value:t}}function K(e,n){if(e==="")return"";if(e==="[]")return[];if(e==="{}")return{};if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(e))return Number(e);if(e.startsWith('"'))return z(e,n);if(e.startsWith("'")){if(!e.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${n}.`);return e.slice(1,-1).replace(/''/g,"'")}if(e.startsWith("[")||e.startsWith("{"))return z(e,n);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${n}.`);return e}function z(e,n){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${n}.`)}}var ke=/^[a-z][a-z0-9_-]{0,63}$/;function xe(){return process.env.XENO_AGENT_HOME?.trim()||(0,p.join)((0,X.homedir)(),".xeno-agent")}function O(e=xe()){return(0,p.join)(e,"agents")}function Q(e){return(0,p.resolve)(e)}function ve(e){let n=(0,p.dirname)(e);return n===e?e:n}function Z(e=process.cwd()){let n=Q(e),r=[],o=n;for(;;){let t=(0,p.join)(o,".xeno","agents");(0,y.existsSync)(t)&&r.push(t);let i=ve(o);if(i===o)break;o=i}return r.reverse()}function ee(e=process.cwd()){return(0,p.join)(Q(e),".xeno","agents")}function Se(e){return(0,y.existsSync)(e)?(0,y.readdirSync)(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.toLowerCase().endsWith(".md")).map(n=>(0,p.join)(e,n.name)).sort((n,r)=>n.localeCompare(r)):[]}function k(e){if(typeof e!="string")return;let n=e.trim();return n.length>0?n:void 0}function x(e){return Array.isArray(e)?e.map(n=>String(n).trim()).filter(Boolean):typeof e=="string"?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function De(e){if(typeof e=="boolean")return e;if(typeof e!="string")return;let n=e.trim().toLowerCase();if(["1","true","yes","on"].includes(n))return!0;if(["0","false","no","off"].includes(n))return!1}function $e(e){return(0,p.parse)((0,p.basename)(e)).name.toLowerCase()}function q(e){return ke.test(e)}function Ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Te(e){if(typeof e!="string")return;let n=e.trim().toLowerCase();if(n==="inherit")return"inherit";if(n==="none"||n==="off"||n==="disabled")return"none";if(n==="read"||n==="readonly"||n==="read-only")return"readOnly";if(n==="default"||n==="standard")return"default";if(n==="full"||n==="fullaccess"||n==="full-access")return"fullAccess"}function Ce(e){if(e===void 0)return;if(typeof e=="string"||Array.isArray(e)){let i=x(e);return i.length>0?{allow:i}:void 0}if(!Ee(e))return;let n=x(e.allow),r=x(e.deny),o=Te(e.mode),t={};return o&&(t.mode=o),n.length>0&&(t.allow=n),r.length>0&&(t.deny=r),Object.keys(t).length>0?t:void 0}function Ie(e){let n=De(e.worktree??e.defaultWorktreeIsolation);if(n===!0)return"worktree";if(n===!1)return"none";let r=k(e.isolation)?.toLowerCase();if(r==="worktree")return"worktree";if(r==="none"||r==="off"||r==="disabled")return"none"}function ne(e){let n=[];return q(e.name)||n.push(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`),e.prompt.trim().length===0&&n.push("Agent definition body is empty."),n}function Re(e,n,r){let o=(0,y.readFileSync)(e,"utf8"),t=G(o),i=t.frontmatter,l=$e(e),s=k(i.name)?.toLowerCase()??l,d=t.content.trim(),g=ne({name:s,prompt:d});if(g.length>0)throw new Error(g.join(" "));let u=k(i.description),c=k(i.model),f=k(i.color),A=k(i.memory??i.memoryScope),w=Ie(i),S=Ce(i.tools);return{name:s,scope:n,path:e,...u?{description:u}:{},...c?{model:c}:{},...f?{color:f}:{},...A?{memory:A}:{},...w?{isolation:w}:{},tags:x(i.tags),skills:x(i.skills),hooks:x(i.hooks),prompt:d,active:!0,priority:r,...S?{toolPolicy:S}:{}}}function D(e,n,r,o,t){for(let i of Se(e))try{o.push(Re(i,n,r))}catch(l){t.push({path:i,scope:n,message:l instanceof Error?l.message:String(l)})}}function Me(e){let n=new Map;for(let r of e){let o=n.get(r.name);(!o||r.priority>o.priority)&&n.set(r.name,r)}return n}function Ne(e,n){let r=n.get(e.name),o=r?.path===e.path;return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,prompt:e.prompt,active:o,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...!o&&r?{shadowedBy:{name:r.name,scope:r.scope,path:r.path}}:{}}}function L(e=process.cwd(),n={}){let r=n.cwd??e,o=n.userDir??O(n.agentHome),t=n.projectDirs??Z(r),i=n.pluginDirs??[],l=n.builtInDirs??[],s=[],d=[];n.includeUser!==!1&&D(o,"user",0,s,d),n.includeProject!==!1&&t.forEach((c,f)=>D(c,"project",100+f,s,d)),n.includePlugins&&i.forEach((c,f)=>D(c,"plugin",1e3+f,s,d)),n.includeBuiltIns&&l.forEach((c,f)=>D(c,"built-in",2e3+f,s,d));let g=Me(s),u=s.map(c=>Ne(c,g));return u.sort((c,f)=>{if(c.active!==f.active)return c.active?-1:1;let A=c.name.localeCompare(f.name);return A!==0?A:c.path.localeCompare(f.path)}),{definitions:u,issues:d,searchPaths:{...n.includeUser!==!1?{user:o}:{},project:n.includeProject===!1?[]:t,plugin:n.includePlugins?i:[],builtIn:n.includeBuiltIns?l:[]}}}function je(e,n=process.cwd(),r={}){let o=e.trim().toLowerCase(),t=L(n,r);return{definition:t.definitions.find(i=>i.active&&i.name===o)??null,scan:t}}var E=class{constructor(n={}){this.options=n}options;scan(n=this.options.cwd??process.cwd()){return L(n,this.options)}},j=class{constructor(n=new E){this.loader=n}loader;resolve(n,r=process.cwd()){let o=this.loader.scan(r),t=n.trim().toLowerCase();return{definition:o.definitions.find(i=>i.active&&i.name===t)??null,scan:o}}};function $(e){if(!e||e.length===0)return;let n=Array.from(new Set(e.map(r=>r.trim()).filter(Boolean)));return n.length>0?n:void 0}function Oe(e,n){if(!e&&!n)return;if(!e)return $(n);if(!n)return $(e);let r=new Set(n);return $(e.filter(o=>r.has(o)))}function qe(e,n){let r={none:0,readOnly:1,default:2,fullAccess:3,inherit:4},o=n??"inherit",t=e??"inherit";return r[o]<=r[t]?o:t}function T(e,n={}){let r=e.toolPolicy??{},o={mode:qe(r.mode,n.mode)},t=Oe(n.allow,r.allow),i=$([...n.deny??[],...r.deny??[]]);return t&&(o.allow=t),i&&(o.deny=i),o}function Le(e){return{name:`custom-agent:${e.name}`,order:20,provide(){let n=["","","# Custom Agent",`Active agent: ${e.name}`,`Definition scope: ${e.scope}`,`Definition path: ${e.path}`];return e.description&&n.push(`Description: ${e.description}`),n.push("",e.prompt),n.join(`
3
- `)}}}function Be(e){return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,active:e.active,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...e.shadowedBy?{shadowedBy:e.shadowedBy}:{}}}function b(e,n){return e.length>=n?e:e+" ".repeat(n-e.length)}function Fe(e,n){let r=[];if(e.length===0)r.push("No custom agent definitions found.");else{r.push(`${b("name",22)} ${b("scope",8)} ${b("status",9)} description`),r.push(`${"-".repeat(22)} ${"-".repeat(8)} ${"-".repeat(9)} ${"-".repeat(32)}`);for(let o of e){let t=o.active?"active":"shadowed";r.push(`${b(o.name,22)} ${b(o.scope,8)} ${b(t,9)} ${o.description??""}`)}}if(n.length>0){r.push("","Invalid definitions:");for(let o of n)r.push(`- ${o.path}: ${o.message}`)}return r.join(`
1
+ "use strict";var M=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var Pe=(e,n)=>{for(var r in n)M(e,r,{get:n[r],enumerable:!0})},we=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of he(n))!Ae.call(e,t)&&t!==r&&M(e,t,{get:()=>n[t],enumerable:!(o=ye(n,t))||o.enumerable});return e};var xe=e=>we(M({},"__esModule",{value:!0}),e);var on={};Pe(on,{AGENT_PROFILE_EXTERNAL_ACTIONS:()=>W,AgentDefinitionLoader:()=>T,AgentDefinitionResolver:()=>q,AgentProfileValidationError:()=>P,XENO_AGENT_PROFILE_SCHEMA_VERSION:()=>N,agentDefinitionFromProfile:()=>nn,agentProfileFromDefinition:()=>ue,compileAgentProfile:()=>ae,createAgentDefinitionFile:()=>Ue,createAgentDefinitionPromptSection:()=>Be,getProjectAgentDefinitionDirs:()=>re,getProjectAgentDefinitionsDir:()=>oe,getUserAgentDefinitionsDir:()=>L,isValidAgentDefinitionName:()=>_,listBuiltInAgentProfiles:()=>en,renderAgentDefinition:()=>He,renderAgentDefinitions:()=>We,resolveAgentDefinition:()=>Le,resolveAgentProfile:()=>rn,resolveAgentToolPolicy:()=>I,resolveBuiltInAgentProfile:()=>de,scanAgentDefinitions:()=>F,toAgentDefinitionMetadata:()=>Ve,validateAgentDefinition:()=>te});module.exports=xe(on);var y=require("node:fs"),m=require("node:path");function K(e){let n=be(e);return{frontmatter:n.frontmatter,content:n.content.trim()}}function be(e){let n=e.replace(/^\uFEFF/,"");if(!n.startsWith("---"))return{frontmatter:{},content:e};let r=n.search(/\r?\n/);if(r<0||n.slice(0,r).trim()!=="---")return{frontmatter:{},content:e};let o=n.slice(r+(n[r]==="\r"?2:1)),t=o.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!t||t.index===void 0)throw new Error("YAML frontmatter is not closed.");let i=o.slice(0,t.index),l=t[0],s=t.index+l.length;return{frontmatter:Q(i),content:o.slice(s)}}function Q(e){let n={},r=e.split(/\r?\n/);for(let o=0;o<r.length;o+=1){let t=r[o];if(!t.trim()||t.trimStart().startsWith("#"))continue;if(/^\s/.test(t))throw new Error(`Unexpected indentation at line ${o+1}.`);let i=ve(t,o+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){n[i.key]=Z(i.value,o+1);continue}let l=ke(r,o+1);n[i.key]=l.value,o=l.nextIndex-1}return n}function ke(e,n){let r=[],o=n;for(;o<e.length;o+=1){let i=e[o];if(!i.trim()){r.push(i);continue}if(!/^\s/.test(i))break;r.push(i.replace(/^ {2}/,""))}let t=r.filter(i=>i.trim()&&!i.trimStart().startsWith("#"));return t.length===0?{value:{},nextIndex:o}:t.every(i=>i.trimStart().startsWith("- "))?{value:t.map((i,l)=>Z(i.trimStart().slice(2),n+l+1)),nextIndex:o}:{value:Q(r.join(`
2
+ `)),nextIndex:o}}function ve(e,n){let r=e.indexOf(":");if(r<=0)throw new Error(`Invalid YAML line ${n}.`);let o=e.slice(0,r).trim(),t=e.slice(r+1).trim();if(!o)throw new Error(`Invalid YAML key at line ${n}.`);return{key:o,value:t}}function Z(e,n){if(e==="")return"";if(e==="[]")return[];if(e==="{}")return{};if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(e))return Number(e);if(e.startsWith('"'))return Y(e,n);if(e.startsWith("'")){if(!e.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${n}.`);return e.slice(1,-1).replace(/''/g,"'")}if(e.startsWith("[")||e.startsWith("{"))return Y(e,n);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${n}.`);return e}function Y(e,n){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${n}.`)}}var w=require("node:os");var j=require("node:path"),ln=(0,w.platform)();var an=(0,w.release)(),cn=(0,w.homedir)();function ee(){let e=process.env.XENO_AGENT_HOME?.trim();return e?(0,j.resolve)(e):(0,j.resolve)((0,w.homedir)(),".xeno-agent")}var Se=/^[a-z][a-z0-9_-]{0,63}$/;function De(){return ee()}function L(e=De()){return(0,m.join)(e,"agents")}function ne(e){return(0,m.resolve)(e)}function Ee(e){let n=(0,m.dirname)(e);return n===e?e:n}function re(e=process.cwd()){let n=ne(e),r=[],o=n;for(;;){let t=(0,m.join)(o,".xeno","agents");(0,y.existsSync)(t)&&r.push(t);let i=Ee(o);if(i===o)break;o=i}return r.reverse()}function oe(e=process.cwd()){return(0,m.join)(ne(e),".xeno","agents")}function $e(e){return(0,y.existsSync)(e)?(0,y.readdirSync)(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.toLowerCase().endsWith(".md")).map(n=>(0,m.join)(e,n.name)).sort((n,r)=>n.localeCompare(r)):[]}function k(e){if(typeof e!="string")return;let n=e.trim();return n.length>0?n:void 0}function v(e){return Array.isArray(e)?e.map(n=>String(n).trim()).filter(Boolean):typeof e=="string"?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function Te(e){if(typeof e=="boolean")return e;if(typeof e!="string")return;let n=e.trim().toLowerCase();if(["1","true","yes","on"].includes(n))return!0;if(["0","false","no","off"].includes(n))return!1}function Ie(e){return(0,m.parse)((0,m.basename)(e)).name.toLowerCase()}function _(e){return Se.test(e)}function Ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Re(e){if(typeof e!="string")return;let n=e.trim().toLowerCase();if(n==="inherit")return"inherit";if(n==="none"||n==="off"||n==="disabled")return"none";if(n==="read"||n==="readonly"||n==="read-only")return"readOnly";if(n==="default"||n==="standard")return"default";if(n==="full"||n==="fullaccess"||n==="full-access")return"fullAccess"}function Ne(e){if(e===void 0)return;if(typeof e=="string"||Array.isArray(e)){let i=v(e);return i.length>0?{allow:i}:void 0}if(!Ce(e))return;let n=v(e.allow),r=v(e.deny),o=Re(e.mode),t={};return o&&(t.mode=o),n.length>0&&(t.allow=n),r.length>0&&(t.deny=r),Object.keys(t).length>0?t:void 0}function Oe(e){let n=Te(e.worktree??e.defaultWorktreeIsolation);if(n===!0)return"worktree";if(n===!1)return"none";let r=k(e.isolation)?.toLowerCase();if(r==="worktree")return"worktree";if(r==="none"||r==="off"||r==="disabled")return"none"}function te(e){let n=[];return _(e.name)||n.push(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`),e.prompt.trim().length===0&&n.push("Agent definition body is empty."),n}function Me(e,n,r){let o=(0,y.readFileSync)(e,"utf8"),t=K(o),i=t.frontmatter,l=Ie(e),s=k(i.name)?.toLowerCase()??l,d=t.content.trim(),p=te({name:s,prompt:d});if(p.length>0)throw new Error(p.join(" "));let u=k(i.description),c=k(i.model),f=k(i.color),A=k(i.memory??i.memoryScope),x=Oe(i),D=Ne(i.tools);return{name:s,scope:n,path:e,...u?{description:u}:{},...c?{model:c}:{},...f?{color:f}:{},...A?{memory:A}:{},...x?{isolation:x}:{},tags:v(i.tags),skills:v(i.skills),hooks:v(i.hooks),prompt:d,active:!0,priority:r,...D?{toolPolicy:D}:{}}}function E(e,n,r,o,t){for(let i of $e(e))try{o.push(Me(i,n,r))}catch(l){t.push({path:i,scope:n,message:l instanceof Error?l.message:String(l)})}}function je(e){let n=new Map;for(let r of e){let o=n.get(r.name);(!o||r.priority>o.priority)&&n.set(r.name,r)}return n}function qe(e,n){let r=n.get(e.name),o=r?.path===e.path;return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,prompt:e.prompt,active:o,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...!o&&r?{shadowedBy:{name:r.name,scope:r.scope,path:r.path}}:{}}}function F(e=process.cwd(),n={}){let r=n.cwd??e,o=n.userDir??L(n.agentHome),t=n.projectDirs??re(r),i=n.pluginDirs??[],l=n.builtInDirs??[],s=[],d=[];n.includeUser!==!1&&E(o,"user",0,s,d),n.includeProject!==!1&&t.forEach((c,f)=>E(c,"project",100+f,s,d)),n.includePlugins&&i.forEach((c,f)=>E(c,"plugin",1e3+f,s,d)),n.includeBuiltIns&&l.forEach((c,f)=>E(c,"built-in",2e3+f,s,d));let p=je(s),u=s.map(c=>qe(c,p));return u.sort((c,f)=>{if(c.active!==f.active)return c.active?-1:1;let A=c.name.localeCompare(f.name);return A!==0?A:c.path.localeCompare(f.path)}),{definitions:u,issues:d,searchPaths:{...n.includeUser!==!1?{user:o}:{},project:n.includeProject===!1?[]:t,plugin:n.includePlugins?i:[],builtIn:n.includeBuiltIns?l:[]}}}function Le(e,n=process.cwd(),r={}){let o=e.trim().toLowerCase(),t=F(n,r);return{definition:t.definitions.find(i=>i.active&&i.name===o)??null,scan:t}}var T=class{constructor(n={}){this.options=n}options;scan(n=this.options.cwd??process.cwd()){return F(n,this.options)}},q=class{constructor(n=new T){this.loader=n}loader;resolve(n,r=process.cwd()){let o=this.loader.scan(r),t=n.trim().toLowerCase();return{definition:o.definitions.find(i=>i.active&&i.name===t)??null,scan:o}}};function $(e){if(!e||e.length===0)return;let n=Array.from(new Set(e.map(r=>r.trim()).filter(Boolean)));return n.length>0?n:void 0}function _e(e,n){if(!e&&!n)return;if(!e)return $(n);if(!n)return $(e);let r=new Set(n);return $(e.filter(o=>r.has(o)))}function Fe(e,n){let r={none:0,readOnly:1,default:2,fullAccess:3,inherit:4},o=n??"inherit",t=e??"inherit";return r[o]<=r[t]?o:t}function I(e,n={}){let r=e.toolPolicy??{},o={mode:Fe(r.mode,n.mode)},t=_e(n.allow,r.allow),i=$([...n.deny??[],...r.deny??[]]);return t&&(o.allow=t),i&&(o.deny=i),o}function Be(e){return{name:`custom-agent:${e.name}`,order:20,provide(){let n=["","","# Custom Agent",`Active agent: ${e.name}`,`Definition scope: ${e.scope}`,`Definition path: ${e.path}`];return e.description&&n.push(`Description: ${e.description}`),n.push("",e.prompt),n.join(`
3
+ `)}}}function Ve(e){return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,active:e.active,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...e.shadowedBy?{shadowedBy:e.shadowedBy}:{}}}function b(e,n){return e.length>=n?e:e+" ".repeat(n-e.length)}function We(e,n){let r=[];if(e.length===0)r.push("No custom agent definitions found.");else{r.push(`${b("name",22)} ${b("scope",8)} ${b("status",9)} description`),r.push(`${"-".repeat(22)} ${"-".repeat(8)} ${"-".repeat(9)} ${"-".repeat(32)}`);for(let o of e){let t=o.active?"active":"shadowed";r.push(`${b(o.name,22)} ${b(o.scope,8)} ${b(t,9)} ${o.description??""}`)}}if(n.length>0){r.push("","Invalid definitions:");for(let o of n)r.push(`- ${o.path}: ${o.message}`)}return r.join(`
4
4
  `)+`
5
- `}function _e(e){let n=[`Agent: ${e.name}`,`Scope: ${e.scope}`,`Path: ${e.path}`,`Status: ${e.active?"active":"shadowed"}`];return e.description&&n.push(`Description: ${e.description}`),e.model&&n.push(`Model: ${e.model}`),e.color&&n.push(`Color: ${e.color}`),e.memory&&n.push(`Memory: ${e.memory}`),e.isolation&&n.push(`Isolation: ${e.isolation}`),e.tags.length>0&&n.push(`Tags: ${e.tags.join(", ")}`),e.skills.length>0&&n.push(`Skills: ${e.skills.join(", ")}`),e.hooks.length>0&&n.push(`Hooks: ${e.hooks.join(", ")}`),e.toolPolicy&&n.push(`Tools: ${JSON.stringify(e.toolPolicy)}`),e.shadowedBy&&n.push(`Shadowed by: ${e.shadowedBy.scope} ${e.shadowedBy.path}`),n.push("",e.prompt,""),n.join(`
6
- `)}function Ve(e){let n=e.name.trim().toLowerCase();if(!q(n))throw new Error(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`);let r=e.scope==="user"?O(e.agentHome):ee(e.cwd??process.cwd());(0,y.mkdirSync)(r,{recursive:!0});let o=(0,p.join)(r,`${n}.md`);if((0,y.existsSync)(o)&&!e.force)throw new Error(`Agent definition already exists: ${o}`);let t=e.description?.trim()||`${n} custom agent`,i=e.prompt?.trim()||`You are ${n}. Replace this paragraph with precise operating instructions, constraints, tools policy, verification expectations, and the kind of work this agent should own.`,s=[...["---",`name: ${n}`,`description: ${JSON.stringify(t)}`,...e.model?.trim()?[`model: ${JSON.stringify(e.model.trim())}`]:[],...e.color?.trim()?[`color: ${JSON.stringify(e.color.trim())}`]:[],...e.memory?.trim()?[`memory: ${JSON.stringify(e.memory.trim())}`]:[],...e.isolation?[`isolation: ${e.isolation}`]:[],"tags: []",...e.skills&&e.skills.length>0?[`skills: ${JSON.stringify(e.skills)}`]:[],...e.hooks&&e.hooks.length>0?[`hooks: ${JSON.stringify(e.hooks)}`]:[],...e.toolPolicy?["tools:",...e.toolPolicy.mode?[` mode: ${e.toolPolicy.mode}`]:[],...e.toolPolicy.allow&&e.toolPolicy.allow.length>0?[` allow: ${JSON.stringify(e.toolPolicy.allow)}`]:[],...e.toolPolicy.deny&&e.toolPolicy.deny.length>0?[` deny: ${JSON.stringify(e.toolPolicy.deny)}`]:[]]:[],"---"],"",i,""].join(`
7
- `);return(0,y.writeFileSync)(o,s,"utf8"),o}var re=require("node:crypto");var R=2,P=class extends Error{constructor(n){super(n),this.name="AgentProfileValidationError"}},We=/^[a-z][a-z0-9_-]{0,63}$/,C=["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"];function m(e){return Array.from(new Set((e??[]).map(n=>n.trim()).filter(Boolean)))}function Ue(e,n){if(e===void 0)return n===void 0?void 0:m(n);if(n===void 0)return m(e);let r=new Set(n);return m(e.filter(o=>r.has(o)))}function He(e,n){if(e===void 0)return;let r=new Set(n);return e.filter(o=>!r.has(o))}function B(e,n,r){let o=n===void 0?null:new Set(n),t=new Set(r??[]);return e===void 0?n===void 0?void 0:m(n).filter(i=>!t.has(i)):m(e).filter(i=>(o===null||o.has(i))&&!t.has(i))}function I(e,n,r){return r[e]<=r[n]?e:n}function Je(e,n,r){return r[e]>=r[n]?e:n}function F(e){return Array.isArray(e)?e.map(F):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,F(r)]))}function ze(e){return(0,re.createHash)("sha256").update(JSON.stringify(F(e))).digest("hex")}function v(e){return structuredClone(e)}function oe(e,n){return e.overrides?.[n]??e.default}function Ge(e,n){let r={deny:0,ask:1,allow:2},o=new Set(e.requireCurrentTurnApproval),t=Object.fromEntries(C.map(d=>[d,oe(e,d)]));for(let d of n){let g=d.externalActions;if(g){for(let u of C){let c=g.overrides?.[u]??g.default;c&&(t[u]=I(t[u],c,r))}for(let u of g.requireCurrentTurnApproval??[])o.add(u)}}let l=new Set(Object.values(t)).size===1?t.publish:"deny",s={};for(let d of C)t[d]!==l&&(s[d]=t[d]);return{default:l,...Object.keys(s).length>0?{overrides:s}:{},requireCurrentTurnApproval:[...o].filter(d=>t[d]!=="deny").sort()}}function te(e){if(e.schemaVersion!==R)throw new P(`Unsupported agent profile schema: ${String(e.schemaVersion)}.`);if(!We.test(e.id))throw new P(`Invalid agent profile id: ${e.id}.`);if(!e.version.trim())throw new P(`Agent profile ${e.id} has no version.`);if(!e.displayName.trim()||!e.description.trim()||!e.prompt.trim())throw new P(`Agent profile ${e.id} requires displayName, description, and prompt.`);if(e.execution.allowedModes.length===0)throw new P(`Agent profile ${e.id} allows no collaboration modes.`);if(!e.execution.allowedModes.includes(e.execution.defaultMode))throw new P(`Agent profile ${e.id} default mode must be included in allowedModes.`)}function Ye(e,n,r,o,t,i){return{name:`agent-profile:${e.id}`,order:20,provide(){let l=C.map(s=>`${s}=${oe(n.externalActions,s)}`).join(", ");return["","","# XENO Agent Profile",`Profile: ${e.displayName} (${e.id}@${e.version})`,`Profile fingerprint: ${i}`,`Role: ${e.description}`,`Collaboration mode: ${o.defaultMode}`,`Isolation: ${o.isolation}`,`Memory: ${r.scope}; soul=${r.soul}`,`Permission profile ceiling: ${n.permissionProfile}`,`External actions: ${l}`,n.externalActions.requireCurrentTurnApproval.length>0?`Current-turn approval required for: ${n.externalActions.requireCurrentTurnApproval.join(", ")}`:"Current-turn approval required for: none",t.evidence.length>0?`Completion evidence: ${t.evidence.join(", ")}`:"Completion evidence: task-dependent",t.requirePrimarySources?"Use primary sources for factual claims and cite them near the claim.":"",t.requireCurrentInformation?"Verify time-sensitive claims against current authoritative information.":"",t.requireHumanReview?"Do not represent the result as professional approval; require human review before consequential use.":"",o.defaultDryRun?"Default to preview or dry-run. Do not perform external state changes without the required approval.":"","",e.prompt,"","Stop conditions:",...t.stopConditions.map(s=>`- ${s}`)].filter(s=>s!=="").join(`
8
- `)}}}function ie(e,n={}){te(e);let r=v(e),o=n.boundaries??[],t=v(r.capabilities.tools),i=r.capabilities.skills.allow?m(r.capabilities.skills.allow):void 0,l=new Set(m(r.capabilities.skills.deny)),s=m(r.capabilities.hooks),d=new Set,g=r.capabilities.mcpServers?m(r.capabilities.mcpServers):void 0,u=r.capabilities.delegatedAgents?m(r.capabilities.delegatedAgents):void 0,c=r.capabilities.permissionProfile,f=r.memory.scope,A=r.memory.soul,w=r.execution.isolation,S={"read-only":0,default:1,"trusted-dev":2},ce={none:0,session:1,project:2,user:3},de={disabled:0,read:1,learn:2},ue={none:0,worktree:1,container:2};for(let a of o){a.tools&&(t=T({toolPolicy:t},a.tools)),i=Ue(i,a.skills?.allow);for(let M of a.skills?.deny??[])l.add(M);s=B(s,a.hooks?.allow,void 0)??[];for(let M of a.hooks?.require??[])d.add(M);g=B(g,a.mcpServers?.allow,a.mcpServers?.deny),u=B(u,a.delegatedAgents?.allow,a.delegatedAgents?.deny),a.permissionProfile&&(c=I(c,a.permissionProfile,S)),a.maximumMemoryScope&&(f=I(f,a.maximumMemoryScope,ce)),a.maximumSoulMode&&(A=I(A,a.maximumSoulMode,de)),a.requiredIsolation&&(w=Je(w,a.requiredIsolation,ue))}let _=[...l].sort();c==="read-only"&&(t=T({toolPolicy:t},{mode:"readOnly",deny:["WebSearch","WebFetch"]})),i=He(i,_);let fe=m(r.capabilities.skills.preload).filter(a=>!l.has(a)).filter(a=>i===void 0||i.includes(a));s=m([...s,...d]);let V={tools:t,skills:{preload:fe,...i!==void 0?{allow:i}:{},deny:_},hooks:s,...g!==void 0?{mcpServers:g}:{},...u!==void 0?{delegatedAgents:u}:{},permissionProfile:c,externalActions:Ge(r.capabilities.externalActions,o)},W={...r.memory,scope:f,soul:A},U={...r.execution,isolation:w},H={schemaVersion:R,profile:r,boundarySources:o.map(a=>a.source),capabilities:V,memory:W,execution:U,completion:r.completion},J=ze(H);return{...H,fingerprint:J,promptSection:Ye(r,V,W,U,r.completion,J)}}function h(e){return{schemaVersion:R,id:e.id,version:"1.0.0",displayName:e.displayName,description:e.description,kind:e.kind??"primary",prompt:e.prompt,capabilities:{tools:e.toolPolicy??{mode:"inherit"},skills:{preload:e.skills??[],...e.skillAllow?{allow:e.skillAllow}:{},deny:[]},hooks:[],permissionProfile:e.permissionProfile??"default",externalActions:{default:e.externalDefault??"ask",...e.externalOverrides?{overrides:e.externalOverrides}:{},requireCurrentTurnApproval:e.currentTurnApproval??[]}},memory:{scope:e.memoryScope??"project",role:e.id,soul:e.soul??"read"},execution:{defaultMode:e.defaultMode??"chat",allowedModes:e.allowedModes??["chat","plan","execute","review"],isolation:e.isolation??"none",allowBackground:e.allowBackground??!0,planForComplexTasks:e.planForComplexTasks??!0,defaultDryRun:e.defaultDryRun??!1},completion:{evidence:e.evidence??[],requirePrimarySources:e.primarySources??!1,requireCurrentInformation:e.currentInformation??!1,requireHumanReview:e.humanReview??!1,stopConditions:e.stopConditions??["The requested outcome is complete and required evidence has been reported.","A real authorization, information, or external-state blocker prevents safe progress."]},presentation:{label:e.displayName,color:e.color,glyph:e.glyph},tags:m(e.tags)}}var se=[h({id:"assistant",displayName:"Assistant",description:"General-purpose XENO collaborator for mixed research, planning, and implementation work.",prompt:["Work as a thoughtful generalist. Establish the user's actual outcome, inspect relevant context, and take scoped action.","Escalate into a narrower specialist profile when domain risk or task depth warrants it."].join(`
9
- `),toolPolicy:{mode:"inherit"},skills:[],memoryScope:"user",evidence:["file-references"],currentTurnApproval:["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"],color:"cyan",glyph:"\u25A0",tags:["general","primary"]}),h({id:"swe",displayName:"Software Engineer",description:"Repository-aware software engineer for careful implementation, debugging, refactoring, and verification.",prompt:["Inspect the repository before editing. Follow project instructions and preserve unrelated work.","Trace the smallest root cause, implement the narrowest coherent change, and verify from focused checks outward.","Do not claim completion without concrete test, typecheck, build, or runtime evidence appropriate to the risk."].join(`
5
+ `}function He(e){let n=[`Agent: ${e.name}`,`Scope: ${e.scope}`,`Path: ${e.path}`,`Status: ${e.active?"active":"shadowed"}`];return e.description&&n.push(`Description: ${e.description}`),e.model&&n.push(`Model: ${e.model}`),e.color&&n.push(`Color: ${e.color}`),e.memory&&n.push(`Memory: ${e.memory}`),e.isolation&&n.push(`Isolation: ${e.isolation}`),e.tags.length>0&&n.push(`Tags: ${e.tags.join(", ")}`),e.skills.length>0&&n.push(`Skills: ${e.skills.join(", ")}`),e.hooks.length>0&&n.push(`Hooks: ${e.hooks.join(", ")}`),e.toolPolicy&&n.push(`Tools: ${JSON.stringify(e.toolPolicy)}`),e.shadowedBy&&n.push(`Shadowed by: ${e.shadowedBy.scope} ${e.shadowedBy.path}`),n.push("",e.prompt,""),n.join(`
6
+ `)}function Ue(e){let n=e.name.trim().toLowerCase();if(!_(n))throw new Error(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`);let r=e.scope==="user"?L(e.agentHome):oe(e.cwd??process.cwd());(0,y.mkdirSync)(r,{recursive:!0});let o=(0,m.join)(r,`${n}.md`);if((0,y.existsSync)(o)&&!e.force)throw new Error(`Agent definition already exists: ${o}`);let t=e.description?.trim()||`${n} custom agent`,i=e.prompt?.trim()||`You are ${n}. Replace this paragraph with precise operating instructions, constraints, tools policy, verification expectations, and the kind of work this agent should own.`,s=[...["---",`name: ${n}`,`description: ${JSON.stringify(t)}`,...e.model?.trim()?[`model: ${JSON.stringify(e.model.trim())}`]:[],...e.color?.trim()?[`color: ${JSON.stringify(e.color.trim())}`]:[],...e.memory?.trim()?[`memory: ${JSON.stringify(e.memory.trim())}`]:[],...e.isolation?[`isolation: ${e.isolation}`]:[],"tags: []",...e.skills&&e.skills.length>0?[`skills: ${JSON.stringify(e.skills)}`]:[],...e.hooks&&e.hooks.length>0?[`hooks: ${JSON.stringify(e.hooks)}`]:[],...e.toolPolicy?["tools:",...e.toolPolicy.mode?[` mode: ${e.toolPolicy.mode}`]:[],...e.toolPolicy.allow&&e.toolPolicy.allow.length>0?[` allow: ${JSON.stringify(e.toolPolicy.allow)}`]:[],...e.toolPolicy.deny&&e.toolPolicy.deny.length>0?[` deny: ${JSON.stringify(e.toolPolicy.deny)}`]:[]]:[],"---"],"",i,""].join(`
7
+ `);return(0,y.writeFileSync)(o,s,"utf8"),o}var ie=require("node:crypto");var N=2,W=["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"],P=class extends Error{constructor(n){super(n),this.name="AgentProfileValidationError"}},Ge=/^[a-z][a-z0-9_-]{0,63}$/,C=W;function g(e){return Array.from(new Set((e??[]).map(n=>n.trim()).filter(Boolean)))}function Je(e,n){if(e===void 0)return n===void 0?void 0:g(n);if(n===void 0)return g(e);let r=new Set(n);return g(e.filter(o=>r.has(o)))}function ze(e,n){if(e===void 0)return;let r=new Set(n);return e.filter(o=>!r.has(o))}function B(e,n,r){let o=n===void 0?null:new Set(n),t=new Set(r??[]);return e===void 0?n===void 0?void 0:g(n).filter(i=>!t.has(i)):g(e).filter(i=>(o===null||o.has(i))&&!t.has(i))}function R(e,n,r){return r[e]<=r[n]?e:n}function Xe(e,n,r){return r[e]>=r[n]?e:n}function V(e){return Array.isArray(e)?e.map(V):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,V(r)]))}function Ye(e){return(0,ie.createHash)("sha256").update(JSON.stringify(V(e))).digest("hex")}function S(e){return structuredClone(e)}function se(e,n){return e.overrides?.[n]??e.default}function Ke(e,n){let r={deny:0,ask:1,allow:2},o=new Set(e.requireCurrentTurnApproval),t=Object.fromEntries(C.map(d=>[d,se(e,d)]));for(let d of n){let p=d.externalActions;if(p){for(let u of C){let c=p.overrides?.[u]??p.default;c&&(t[u]=R(t[u],c,r))}for(let u of p.requireCurrentTurnApproval??[])o.add(u)}}let l=new Set(Object.values(t)).size===1?t.publish:"deny",s={};for(let d of C)t[d]!==l&&(s[d]=t[d]);return{default:l,...Object.keys(s).length>0?{overrides:s}:{},requireCurrentTurnApproval:[...o].filter(d=>t[d]!=="deny").sort()}}function le(e){if(e.schemaVersion!==N)throw new P(`Unsupported agent profile schema: ${String(e.schemaVersion)}.`);if(!Ge.test(e.id))throw new P(`Invalid agent profile id: ${e.id}.`);if(!e.version.trim())throw new P(`Agent profile ${e.id} has no version.`);if(!e.displayName.trim()||!e.description.trim()||!e.prompt.trim())throw new P(`Agent profile ${e.id} requires displayName, description, and prompt.`);if(e.execution.allowedModes.length===0)throw new P(`Agent profile ${e.id} allows no collaboration modes.`);if(!e.execution.allowedModes.includes(e.execution.defaultMode))throw new P(`Agent profile ${e.id} default mode must be included in allowedModes.`)}function Qe(e,n,r,o,t,i){return{name:`agent-profile:${e.id}`,order:20,provide(){let l=C.map(s=>`${s}=${se(n.externalActions,s)}`).join(", ");return["","","# XENO Agent Profile",`Profile: ${e.displayName} (${e.id}@${e.version})`,`Profile fingerprint: ${i}`,`Role: ${e.description}`,`Collaboration mode: ${o.defaultMode}`,`Isolation: ${o.isolation}`,`Memory: ${r.scope}; soul=${r.soul}`,`Permission profile ceiling: ${n.permissionProfile}`,`External actions: ${l}`,n.externalActions.requireCurrentTurnApproval.length>0?`Current-turn approval required for: ${n.externalActions.requireCurrentTurnApproval.join(", ")}`:"Current-turn approval required for: none",t.evidence.length>0?`Completion evidence: ${t.evidence.join(", ")}`:"Completion evidence: task-dependent",t.requirePrimarySources?"Use primary sources for factual claims and cite them near the claim.":"",t.requireCurrentInformation?"Verify time-sensitive claims against current authoritative information.":"",t.requireHumanReview?"Do not represent the result as professional approval; require human review before consequential use.":"",o.defaultDryRun?"Default to preview or dry-run. Do not perform external state changes without the required approval.":"","",e.prompt,"","Stop conditions:",...t.stopConditions.map(s=>`- ${s}`)].filter(s=>s!=="").join(`
8
+ `)}}}function ae(e,n={}){le(e);let r=S(e),o=n.boundaries??[],t=S(r.capabilities.tools),i=r.capabilities.skills.allow?g(r.capabilities.skills.allow):void 0,l=new Set(g(r.capabilities.skills.deny)),s=g(r.capabilities.hooks),d=new Set,p=r.capabilities.mcpServers?g(r.capabilities.mcpServers):void 0,u=r.capabilities.delegatedAgents?g(r.capabilities.delegatedAgents):void 0,c=r.capabilities.permissionProfile,f=r.memory.scope,A=r.memory.soul,x=r.execution.isolation,D={"read-only":0,default:1,"trusted-dev":2},fe={none:0,session:1,project:2,user:3},pe={disabled:0,read:1,learn:2},me={none:0,worktree:1,container:2};for(let a of o){a.tools&&(t=I({toolPolicy:t},a.tools)),i=Je(i,a.skills?.allow);for(let O of a.skills?.deny??[])l.add(O);s=B(s,a.hooks?.allow,void 0)??[];for(let O of a.hooks?.require??[])d.add(O);p=B(p,a.mcpServers?.allow,a.mcpServers?.deny),u=B(u,a.delegatedAgents?.allow,a.delegatedAgents?.deny),a.permissionProfile&&(c=R(c,a.permissionProfile,D)),a.maximumMemoryScope&&(f=R(f,a.maximumMemoryScope,fe)),a.maximumSoulMode&&(A=R(A,a.maximumSoulMode,pe)),a.requiredIsolation&&(x=Xe(x,a.requiredIsolation,me))}let H=[...l].sort();c==="read-only"&&(t=I({toolPolicy:t},{mode:"readOnly",deny:["WebSearch","WebFetch"]})),i=ze(i,H);let ge=g(r.capabilities.skills.preload).filter(a=>!l.has(a)).filter(a=>i===void 0||i.includes(a));s=g([...s,...d]);let U={tools:t,skills:{preload:ge,...i!==void 0?{allow:i}:{},deny:H},hooks:s,...p!==void 0?{mcpServers:p}:{},...u!==void 0?{delegatedAgents:u}:{},permissionProfile:c,externalActions:Ke(r.capabilities.externalActions,o)},G={...r.memory,scope:f,soul:A},J={...r.execution,isolation:x},z={schemaVersion:N,profile:r,boundarySources:o.map(a=>a.source),capabilities:U,memory:G,execution:J,completion:r.completion},X=Ye(z);return{...z,fingerprint:X,promptSection:Qe(r,U,G,J,r.completion,X)}}function h(e){return{schemaVersion:N,id:e.id,version:"1.0.0",displayName:e.displayName,description:e.description,kind:e.kind??"primary",prompt:e.prompt,capabilities:{tools:e.toolPolicy??{mode:"inherit"},skills:{preload:e.skills??[],...e.skillAllow?{allow:e.skillAllow}:{},deny:[]},hooks:[],permissionProfile:e.permissionProfile??"default",externalActions:{default:e.externalDefault??"ask",...e.externalOverrides?{overrides:e.externalOverrides}:{},requireCurrentTurnApproval:e.currentTurnApproval??[]}},memory:{scope:e.memoryScope??"project",role:e.id,soul:e.soul??"read"},execution:{defaultMode:e.defaultMode??"chat",allowedModes:e.allowedModes??["chat","plan","execute","review"],isolation:e.isolation??"none",allowBackground:e.allowBackground??!0,planForComplexTasks:e.planForComplexTasks??!0,defaultDryRun:e.defaultDryRun??!1},completion:{evidence:e.evidence??[],requirePrimarySources:e.primarySources??!1,requireCurrentInformation:e.currentInformation??!1,requireHumanReview:e.humanReview??!1,stopConditions:e.stopConditions??["The requested outcome is complete and required evidence has been reported.","A real authorization, information, or external-state blocker prevents safe progress."]},presentation:{label:e.displayName,color:e.color,glyph:e.glyph},tags:g(e.tags)}}var ce=[h({id:"assistant",displayName:"Assistant",description:"General-purpose XENO collaborator for mixed research, planning, and implementation work.",prompt:["Work as a thoughtful generalist. Establish the user's actual outcome, inspect relevant context, and take scoped action.","Escalate into a narrower specialist profile when domain risk or task depth warrants it."].join(`
9
+ `),toolPolicy:{mode:"inherit"},skills:[],memoryScope:"user",evidence:["file-references"],currentTurnApproval:[...W],color:"cyan",glyph:"\u25A0",tags:["general","primary"]}),h({id:"swe",displayName:"Software Engineer",description:"Repository-aware software engineer for careful implementation, debugging, refactoring, and verification.",prompt:["Inspect the repository before editing. Follow project instructions and preserve unrelated work.","Trace the smallest root cause, implement the narrowest coherent change, and verify from focused checks outward.","Do not claim completion without concrete test, typecheck, build, or runtime evidence appropriate to the risk."].join(`
10
10
  `),toolPolicy:{mode:"default"},skills:["debug","run","verify"],permissionProfile:"trusted-dev",soul:"learn",evidence:["file-references","tests","typecheck","build","diff"],currentTurnApproval:["publish","deploy","push","change-infrastructure"],color:"green",glyph:"\u25C6",tags:["engineering","implementation"]}),h({id:"reviewer",displayName:"Code Reviewer",description:"Read-only reviewer focused on correctness, regressions, safety, tests, and maintainability.",prompt:["Lead with concrete findings ordered by severity. Cite exact file locations and explain impact.","Do not edit code. Distinguish confirmed defects from risks and questions. State when no material finding is present."].join(`
11
11
  `),kind:"subagent",toolPolicy:{mode:"readOnly"},skills:["code-review","verify"],permissionProfile:"read-only",memoryScope:"session",soul:"read",allowedModes:["chat","review"],defaultMode:"review",evidence:["file-references","diff"],externalDefault:"deny",color:"yellow",glyph:"\u25C7",tags:["engineering","review","read-only"]}),h({id:"writer",displayName:"Writer",description:"Audience-aware writer and editor for clear, accurate, structurally coherent content.",prompt:["Determine audience, purpose, voice, format, and source constraints before drafting.","Preserve factual meaning, avoid invented claims, and revise for clarity, rhythm, consistency, and usefulness."].join(`
12
12
  `),toolPolicy:{mode:"default",allow:["Read","Glob","Grep","LS","Write","Edit","WebSearch","WebFetch","Think","AskUser","Skill"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish"],color:"magenta",glyph:"\u2726",tags:["writing","editing"]}),h({id:"research",displayName:"Researcher",description:"Evidence-first researcher for questions, comparisons, synthesis, and source-backed analysis.",prompt:["Break the question into verifiable claims. Prefer primary and authoritative sources, compare dates, and cite near each claim.","Separate sourced fact, inference, uncertainty, and recommendation. Do not make changes unless the user explicitly expands scope."].join(`
@@ -14,4 +14,4 @@
14
14
  `),toolPolicy:{mode:"default",allow:["Read","Glob","Grep","LS","Write","Edit","WebSearch","WebFetch","Think","AskUser","Skill"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish","change-infrastructure"],color:"cyan",glyph:"\u25A3",tags:["product","planning"]}),h({id:"ci",displayName:"CI Engineer",description:"Continuous-integration specialist for reproducing, repairing, and hardening automated gates.",prompt:["Identify the exact failing job and command. Reproduce it locally or in an equivalent immutable environment before patching.","Fix only the underlying failure, retain logs as evidence, and rerun the matching gate before broader validation."].join(`
15
15
  `),toolPolicy:{mode:"default"},skills:["ci-repair","debug","run","verify"],permissionProfile:"trusted-dev",soul:"learn",evidence:["tests","typecheck","build","diff"],currentTurnApproval:["push","deploy","change-infrastructure"],color:"green",glyph:"\u25A4",tags:["engineering","ci","automation"]}),h({id:"devops",displayName:"DevOps and Release",description:"Dry-run-first infrastructure and release specialist with explicit external-action gates.",prompt:["Inspect the release or infrastructure contract first. Build an immutable candidate and produce reproducible evidence.","Default to plan, preview, dry-run, and local verification. Never publish, deploy, push, sign, purchase, or mutate infrastructure unless the current user turn explicitly authorizes that exact action and target.","For releases, preserve SDK-before-CLI dependency order and verify the public artifact after publication."].join(`
16
16
  `),toolPolicy:{mode:"default"},skills:["release","run","verify"],permissionProfile:"default",memoryScope:"project",soul:"learn",isolation:"worktree",defaultMode:"plan",defaultDryRun:!0,evidence:["tests","build","diff","deployment-proof","human-review"],humanReview:!0,currentTurnApproval:["publish","deploy","push","purchase","sign","change-infrastructure"],color:"yellow",glyph:"\u2B22",tags:["devops","release","infrastructure"]}),h({id:"legal-research",displayName:"Legal Research",description:"Restricted legal-information researcher that produces sourced analysis for qualified human review.",prompt:["Identify jurisdiction, effective date, parties, and the precise legal question before analyzing it.","Use current primary legal sources wherever possible. Cite each material proposition and distinguish law, interpretation, uncertainty, and practical next steps.","Provide legal information, not professional representation. Never sign, file, submit, contact a party, accept terms, or make a payment."].join(`
17
- `),toolPolicy:{mode:"readOnly"},skills:["verify"],permissionProfile:"default",memoryScope:"session",soul:"disabled",allowedModes:["chat","plan","review"],defaultMode:"review",evidence:["sources","human-review"],primarySources:!0,currentInformation:!0,humanReview:!0,externalDefault:"deny",color:"red",glyph:"\xA7",tags:["legal","research","restricted","read-only"],stopConditions:["The jurisdiction or effective date is unknown and materially changes the answer.","The task requires legal representation, filing, signature, payment, or contact with a third party.","The sourced analysis is complete and clearly marked for qualified human review."]})],Ke={general:"assistant",software:"swe",engineer:"swe","software-engineer":"swe",review:"reviewer","code-reviewer":"reviewer",qa:"research","q-and-a":"research",researcher:"research","product-manager":"product","ci-cd":"ci",cicd:"ci",release:"devops","devops-release":"devops",legal:"legal-research"};function Xe(){return se.map(v)}function le(e){let n=e.trim().toLowerCase(),r=Ke[n]??n,o=se.find(t=>t.id===r);return o?v(o):null}function ae(e){let n=e.memory?.trim().toLowerCase(),r=n==="none"||n==="session"||n==="project"||n==="user"?n:"project",o=h({id:e.name,displayName:e.name,description:e.description??`Custom XENO agent ${e.name}.`,prompt:e.prompt,toolPolicy:e.toolPolicy??{mode:"inherit"},skills:e.skills,memoryScope:r,isolation:e.isolation??"none",color:e.color??"cyan",glyph:"\u25A0",tags:["custom",...e.tags]});return e.model&&(o.model={preferred:e.model}),o.capabilities.hooks=[...e.hooks],o}function Qe(e){return te(e),{name:e.id,scope:"built-in",path:`builtin:xeno-agent-profile/${e.id}@${e.version}`,description:e.description,...e.model?.preferred?{model:e.model.preferred}:{},color:e.presentation.color,memory:e.memory.scope,isolation:e.execution.isolation==="container"?"worktree":e.execution.isolation,tags:[...e.tags],skills:[...e.capabilities.skills.preload],hooks:[...e.capabilities.hooks],active:!0,toolPolicy:v(e.capabilities.tools),prompt:e.prompt}}function Ze(e){let n=e.definition?ae(e.definition):le(e.name);return n?ie(n,{boundaries:e.boundaries}):null}0&&(module.exports={AgentDefinitionLoader,AgentDefinitionResolver,AgentProfileValidationError,XENO_AGENT_PROFILE_SCHEMA_VERSION,agentDefinitionFromProfile,agentProfileFromDefinition,compileAgentProfile,createAgentDefinitionFile,createAgentDefinitionPromptSection,getProjectAgentDefinitionDirs,getProjectAgentDefinitionsDir,getUserAgentDefinitionsDir,isValidAgentDefinitionName,listBuiltInAgentProfiles,renderAgentDefinition,renderAgentDefinitions,resolveAgentDefinition,resolveAgentProfile,resolveAgentToolPolicy,resolveBuiltInAgentProfile,scanAgentDefinitions,toAgentDefinitionMetadata,validateAgentDefinition});
17
+ `),toolPolicy:{mode:"readOnly"},skills:["verify"],permissionProfile:"default",memoryScope:"session",soul:"disabled",allowedModes:["chat","plan","review"],defaultMode:"review",evidence:["sources","human-review"],primarySources:!0,currentInformation:!0,humanReview:!0,externalDefault:"deny",color:"red",glyph:"\xA7",tags:["legal","research","restricted","read-only"],stopConditions:["The jurisdiction or effective date is unknown and materially changes the answer.","The task requires legal representation, filing, signature, payment, or contact with a third party.","The sourced analysis is complete and clearly marked for qualified human review."]})],Ze={general:"assistant",software:"swe",engineer:"swe","software-engineer":"swe",review:"reviewer","code-reviewer":"reviewer",qa:"research","q-and-a":"research",researcher:"research","product-manager":"product","ci-cd":"ci",cicd:"ci",release:"devops","devops-release":"devops",legal:"legal-research"};function en(){return ce.map(S)}function de(e){let n=e.trim().toLowerCase(),r=Ze[n]??n,o=ce.find(t=>t.id===r);return o?S(o):null}function ue(e){let n=e.memory?.trim().toLowerCase(),r=n==="none"||n==="session"||n==="project"||n==="user"?n:"project",o=h({id:e.name,displayName:e.name,description:e.description??`Custom XENO agent ${e.name}.`,prompt:e.prompt,toolPolicy:e.toolPolicy??{mode:"inherit"},skills:e.skills,memoryScope:r,isolation:e.isolation??"none",color:e.color??"cyan",glyph:"\u25A0",tags:["custom",...e.tags]});return e.model&&(o.model={preferred:e.model}),o.capabilities.hooks=[...e.hooks],o}function nn(e){return le(e),{name:e.id,scope:"built-in",path:`builtin:xeno-agent-profile/${e.id}@${e.version}`,description:e.description,...e.model?.preferred?{model:e.model.preferred}:{},color:e.presentation.color,memory:e.memory.scope,isolation:e.execution.isolation==="container"?"worktree":e.execution.isolation,tags:[...e.tags],skills:[...e.capabilities.skills.preload],hooks:[...e.capabilities.hooks],active:!0,toolPolicy:S(e.capabilities.tools),prompt:e.prompt}}function rn(e){let n=e.definition?ue(e.definition):de(e.name);return n?ae(n,{boundaries:e.boundaries}):null}0&&(module.exports={AGENT_PROFILE_EXTERNAL_ACTIONS,AgentDefinitionLoader,AgentDefinitionResolver,AgentProfileValidationError,XENO_AGENT_PROFILE_SCHEMA_VERSION,agentDefinitionFromProfile,agentProfileFromDefinition,compileAgentProfile,createAgentDefinitionFile,createAgentDefinitionPromptSection,getProjectAgentDefinitionDirs,getProjectAgentDefinitionsDir,getUserAgentDefinitionsDir,isValidAgentDefinitionName,listBuiltInAgentProfiles,renderAgentDefinition,renderAgentDefinitions,resolveAgentDefinition,resolveAgentProfile,resolveAgentToolPolicy,resolveBuiltInAgentProfile,scanAgentDefinitions,toAgentDefinitionMetadata,validateAgentDefinition});
@@ -118,7 +118,17 @@ type AgentProfileCollaborationMode = "chat" | "plan" | "execute" | "review";
118
118
  type AgentProfileMemoryScope = "none" | "session" | "project" | "user";
119
119
  type AgentProfileSoulMode = "disabled" | "read" | "learn";
120
120
  type AgentProfileIsolation = AgentDefinitionIsolation | "container";
121
- type AgentProfileExternalAction = "publish" | "deploy" | "push" | "send" | "purchase" | "sign" | "file-legal" | "change-infrastructure";
121
+ declare const AGENT_PROFILE_EXTERNAL_ACTIONS: readonly [
122
+ "publish",
123
+ "deploy",
124
+ "push",
125
+ "send",
126
+ "purchase",
127
+ "sign",
128
+ "file-legal",
129
+ "change-infrastructure"
130
+ ];
131
+ type AgentProfileExternalAction = (typeof AGENT_PROFILE_EXTERNAL_ACTIONS)[number];
122
132
  type AgentProfileActionDecision = "allow" | "ask" | "deny";
123
133
  type AgentProfileEvidenceKind = "sources" | "file-references" | "tests" | "typecheck" | "build" | "diff" | "deployment-proof" | "human-review";
124
134
  interface AgentProfileSkillPolicy {
@@ -241,4 +251,4 @@ declare function resolveAgentProfile(input: {
241
251
  definition?: AgentDefinition | null;
242
252
  boundaries?: AgentProfileCapabilityBoundary[];
243
253
  }): CompiledAgentProfile | null;
244
- export { type AgentDefinition, type AgentDefinitionIsolation, type AgentDefinitionIssue, AgentDefinitionLoader, type AgentDefinitionLoaderOptions, type AgentDefinitionMetadata, AgentDefinitionResolver, type AgentDefinitionScanResult, type AgentDefinitionScope, type AgentDefinitionShadowRef, type AgentProfileActionDecision, type AgentProfileCapabilities, type AgentProfileCapabilityBoundary, type AgentProfileCollaborationMode, type AgentProfileCompletionPolicy, type AgentProfileEvidenceKind, type AgentProfileExecutionPolicy, type AgentProfileExternalAction, type AgentProfileExternalActionPolicy, type AgentProfileIsolation, type AgentProfileKind, type AgentProfileMemoryPolicy, type AgentProfileMemoryScope, type AgentProfilePresentation, type AgentProfileSkillPolicy, type AgentProfileSoulMode, type AgentProfileV2, AgentProfileValidationError, type AgentToolPolicy, type CompileAgentProfileOptions, type CompiledAgentProfile, XENO_AGENT_PROFILE_SCHEMA_VERSION, agentDefinitionFromProfile, agentProfileFromDefinition, compileAgentProfile, createAgentDefinitionFile, createAgentDefinitionPromptSection, getProjectAgentDefinitionDirs, getProjectAgentDefinitionsDir, getUserAgentDefinitionsDir, isValidAgentDefinitionName, listBuiltInAgentProfiles, renderAgentDefinition, renderAgentDefinitions, resolveAgentDefinition, resolveAgentProfile, resolveAgentToolPolicy, resolveBuiltInAgentProfile, scanAgentDefinitions, toAgentDefinitionMetadata, validateAgentDefinition };
254
+ export { AGENT_PROFILE_EXTERNAL_ACTIONS, type AgentDefinition, type AgentDefinitionIsolation, type AgentDefinitionIssue, AgentDefinitionLoader, type AgentDefinitionLoaderOptions, type AgentDefinitionMetadata, AgentDefinitionResolver, type AgentDefinitionScanResult, type AgentDefinitionScope, type AgentDefinitionShadowRef, type AgentProfileActionDecision, type AgentProfileCapabilities, type AgentProfileCapabilityBoundary, type AgentProfileCollaborationMode, type AgentProfileCompletionPolicy, type AgentProfileEvidenceKind, type AgentProfileExecutionPolicy, type AgentProfileExternalAction, type AgentProfileExternalActionPolicy, type AgentProfileIsolation, type AgentProfileKind, type AgentProfileMemoryPolicy, type AgentProfileMemoryScope, type AgentProfilePresentation, type AgentProfileSkillPolicy, type AgentProfileSoulMode, type AgentProfileV2, AgentProfileValidationError, type AgentToolPolicy, type CompileAgentProfileOptions, type CompiledAgentProfile, XENO_AGENT_PROFILE_SCHEMA_VERSION, agentDefinitionFromProfile, agentProfileFromDefinition, compileAgentProfile, createAgentDefinitionFile, createAgentDefinitionPromptSection, getProjectAgentDefinitionDirs, getProjectAgentDefinitionsDir, getUserAgentDefinitionsDir, isValidAgentDefinitionName, listBuiltInAgentProfiles, renderAgentDefinition, renderAgentDefinitions, resolveAgentDefinition, resolveAgentProfile, resolveAgentToolPolicy, resolveBuiltInAgentProfile, scanAgentDefinitions, toAgentDefinitionMetadata, validateAgentDefinition };
@@ -118,7 +118,17 @@ type AgentProfileCollaborationMode = "chat" | "plan" | "execute" | "review";
118
118
  type AgentProfileMemoryScope = "none" | "session" | "project" | "user";
119
119
  type AgentProfileSoulMode = "disabled" | "read" | "learn";
120
120
  type AgentProfileIsolation = AgentDefinitionIsolation | "container";
121
- type AgentProfileExternalAction = "publish" | "deploy" | "push" | "send" | "purchase" | "sign" | "file-legal" | "change-infrastructure";
121
+ declare const AGENT_PROFILE_EXTERNAL_ACTIONS: readonly [
122
+ "publish",
123
+ "deploy",
124
+ "push",
125
+ "send",
126
+ "purchase",
127
+ "sign",
128
+ "file-legal",
129
+ "change-infrastructure"
130
+ ];
131
+ type AgentProfileExternalAction = (typeof AGENT_PROFILE_EXTERNAL_ACTIONS)[number];
122
132
  type AgentProfileActionDecision = "allow" | "ask" | "deny";
123
133
  type AgentProfileEvidenceKind = "sources" | "file-references" | "tests" | "typecheck" | "build" | "diff" | "deployment-proof" | "human-review";
124
134
  interface AgentProfileSkillPolicy {
@@ -241,4 +251,4 @@ declare function resolveAgentProfile(input: {
241
251
  definition?: AgentDefinition | null;
242
252
  boundaries?: AgentProfileCapabilityBoundary[];
243
253
  }): CompiledAgentProfile | null;
244
- export { type AgentDefinition, type AgentDefinitionIsolation, type AgentDefinitionIssue, AgentDefinitionLoader, type AgentDefinitionLoaderOptions, type AgentDefinitionMetadata, AgentDefinitionResolver, type AgentDefinitionScanResult, type AgentDefinitionScope, type AgentDefinitionShadowRef, type AgentProfileActionDecision, type AgentProfileCapabilities, type AgentProfileCapabilityBoundary, type AgentProfileCollaborationMode, type AgentProfileCompletionPolicy, type AgentProfileEvidenceKind, type AgentProfileExecutionPolicy, type AgentProfileExternalAction, type AgentProfileExternalActionPolicy, type AgentProfileIsolation, type AgentProfileKind, type AgentProfileMemoryPolicy, type AgentProfileMemoryScope, type AgentProfilePresentation, type AgentProfileSkillPolicy, type AgentProfileSoulMode, type AgentProfileV2, AgentProfileValidationError, type AgentToolPolicy, type CompileAgentProfileOptions, type CompiledAgentProfile, XENO_AGENT_PROFILE_SCHEMA_VERSION, agentDefinitionFromProfile, agentProfileFromDefinition, compileAgentProfile, createAgentDefinitionFile, createAgentDefinitionPromptSection, getProjectAgentDefinitionDirs, getProjectAgentDefinitionsDir, getUserAgentDefinitionsDir, isValidAgentDefinitionName, listBuiltInAgentProfiles, renderAgentDefinition, renderAgentDefinitions, resolveAgentDefinition, resolveAgentProfile, resolveAgentToolPolicy, resolveBuiltInAgentProfile, scanAgentDefinitions, toAgentDefinitionMetadata, validateAgentDefinition };
254
+ export { AGENT_PROFILE_EXTERNAL_ACTIONS, type AgentDefinition, type AgentDefinitionIsolation, type AgentDefinitionIssue, AgentDefinitionLoader, type AgentDefinitionLoaderOptions, type AgentDefinitionMetadata, AgentDefinitionResolver, type AgentDefinitionScanResult, type AgentDefinitionScope, type AgentDefinitionShadowRef, type AgentProfileActionDecision, type AgentProfileCapabilities, type AgentProfileCapabilityBoundary, type AgentProfileCollaborationMode, type AgentProfileCompletionPolicy, type AgentProfileEvidenceKind, type AgentProfileExecutionPolicy, type AgentProfileExternalAction, type AgentProfileExternalActionPolicy, type AgentProfileIsolation, type AgentProfileKind, type AgentProfileMemoryPolicy, type AgentProfileMemoryScope, type AgentProfilePresentation, type AgentProfileSkillPolicy, type AgentProfileSoulMode, type AgentProfileV2, AgentProfileValidationError, type AgentToolPolicy, type CompileAgentProfileOptions, type CompiledAgentProfile, XENO_AGENT_PROFILE_SCHEMA_VERSION, agentDefinitionFromProfile, agentProfileFromDefinition, compileAgentProfile, createAgentDefinitionFile, createAgentDefinitionPromptSection, getProjectAgentDefinitionDirs, getProjectAgentDefinitionsDir, getUserAgentDefinitionsDir, isValidAgentDefinitionName, listBuiltInAgentProfiles, renderAgentDefinition, renderAgentDefinitions, resolveAgentDefinition, resolveAgentProfile, resolveAgentToolPolicy, resolveBuiltInAgentProfile, scanAgentDefinitions, toAgentDefinitionMetadata, validateAgentDefinition };
@@ -1,17 +1,17 @@
1
- import{existsSync as I,mkdirSync as le,readFileSync as ae,readdirSync as ce,writeFileSync as de}from"node:fs";import{homedir as ue}from"node:os";import{basename as fe,dirname as pe,join as k,parse as ge,resolve as me}from"node:path";function W(e){let n=te(e);return{frontmatter:n.frontmatter,content:n.content.trim()}}function te(e){let n=e.replace(/^\uFEFF/,"");if(!n.startsWith("---"))return{frontmatter:{},content:e};let r=n.search(/\r?\n/);if(r<0||n.slice(0,r).trim()!=="---")return{frontmatter:{},content:e};let o=n.slice(r+(n[r]==="\r"?2:1)),t=o.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!t||t.index===void 0)throw new Error("YAML frontmatter is not closed.");let i=o.slice(0,t.index),l=t[0],s=t.index+l.length;return{frontmatter:U(i),content:o.slice(s)}}function U(e){let n={},r=e.split(/\r?\n/);for(let o=0;o<r.length;o+=1){let t=r[o];if(!t.trim()||t.trimStart().startsWith("#"))continue;if(/^\s/.test(t))throw new Error(`Unexpected indentation at line ${o+1}.`);let i=se(t,o+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){n[i.key]=H(i.value,o+1);continue}let l=ie(r,o+1);n[i.key]=l.value,o=l.nextIndex-1}return n}function ie(e,n){let r=[],o=n;for(;o<e.length;o+=1){let i=e[o];if(!i.trim()){r.push(i);continue}if(!/^\s/.test(i))break;r.push(i.replace(/^ {2}/,""))}let t=r.filter(i=>i.trim()&&!i.trimStart().startsWith("#"));return t.length===0?{value:{},nextIndex:o}:t.every(i=>i.trimStart().startsWith("- "))?{value:t.map((i,l)=>H(i.trimStart().slice(2),n+l+1)),nextIndex:o}:{value:U(r.join(`
2
- `)),nextIndex:o}}function se(e,n){let r=e.indexOf(":");if(r<=0)throw new Error(`Invalid YAML line ${n}.`);let o=e.slice(0,r).trim(),t=e.slice(r+1).trim();if(!o)throw new Error(`Invalid YAML key at line ${n}.`);return{key:o,value:t}}function H(e,n){if(e==="")return"";if(e==="[]")return[];if(e==="{}")return{};if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(e))return Number(e);if(e.startsWith('"'))return V(e,n);if(e.startsWith("'")){if(!e.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${n}.`);return e.slice(1,-1).replace(/''/g,"'")}if(e.startsWith("[")||e.startsWith("{"))return V(e,n);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${n}.`);return e}function V(e,n){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${n}.`)}}var ye=/^[a-z][a-z0-9_-]{0,63}$/;function he(){return process.env.XENO_AGENT_HOME?.trim()||k(ue(),".xeno-agent")}function z(e=he()){return k(e,"agents")}function G(e){return me(e)}function Ae(e){let n=pe(e);return n===e?e:n}function Pe(e=process.cwd()){let n=G(e),r=[],o=n;for(;;){let t=k(o,".xeno","agents");I(t)&&r.push(t);let i=Ae(o);if(i===o)break;o=i}return r.reverse()}function we(e=process.cwd()){return k(G(e),".xeno","agents")}function be(e){return I(e)?ce(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.toLowerCase().endsWith(".md")).map(n=>k(e,n.name)).sort((n,r)=>n.localeCompare(r)):[]}function w(e){if(typeof e!="string")return;let n=e.trim();return n.length>0?n:void 0}function b(e){return Array.isArray(e)?e.map(n=>String(n).trim()).filter(Boolean):typeof e=="string"?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function ke(e){if(typeof e=="boolean")return e;if(typeof e!="string")return;let n=e.trim().toLowerCase();if(["1","true","yes","on"].includes(n))return!0;if(["0","false","no","off"].includes(n))return!1}function xe(e){return ge(fe(e)).name.toLowerCase()}function Y(e){return ye.test(e)}function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Se(e){if(typeof e!="string")return;let n=e.trim().toLowerCase();if(n==="inherit")return"inherit";if(n==="none"||n==="off"||n==="disabled")return"none";if(n==="read"||n==="readonly"||n==="read-only")return"readOnly";if(n==="default"||n==="standard")return"default";if(n==="full"||n==="fullaccess"||n==="full-access")return"fullAccess"}function De(e){if(e===void 0)return;if(typeof e=="string"||Array.isArray(e)){let i=b(e);return i.length>0?{allow:i}:void 0}if(!ve(e))return;let n=b(e.allow),r=b(e.deny),o=Se(e.mode),t={};return o&&(t.mode=o),n.length>0&&(t.allow=n),r.length>0&&(t.deny=r),Object.keys(t).length>0?t:void 0}function $e(e){let n=ke(e.worktree??e.defaultWorktreeIsolation);if(n===!0)return"worktree";if(n===!1)return"none";let r=w(e.isolation)?.toLowerCase();if(r==="worktree")return"worktree";if(r==="none"||r==="off"||r==="disabled")return"none"}function Ee(e){let n=[];return Y(e.name)||n.push(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`),e.prompt.trim().length===0&&n.push("Agent definition body is empty."),n}function Te(e,n,r){let o=ae(e,"utf8"),t=W(o),i=t.frontmatter,l=xe(e),s=w(i.name)?.toLowerCase()??l,d=t.content.trim(),p=Ee({name:s,prompt:d});if(p.length>0)throw new Error(p.join(" "));let u=w(i.description),c=w(i.model),f=w(i.color),y=w(i.memory??i.memoryScope),A=$e(i),v=De(i.tools);return{name:s,scope:n,path:e,...u?{description:u}:{},...c?{model:c}:{},...f?{color:f}:{},...y?{memory:y}:{},...A?{isolation:A}:{},tags:b(i.tags),skills:b(i.skills),hooks:b(i.hooks),prompt:d,active:!0,priority:r,...v?{toolPolicy:v}:{}}}function S(e,n,r,o,t){for(let i of be(e))try{o.push(Te(i,n,r))}catch(l){t.push({path:i,scope:n,message:l instanceof Error?l.message:String(l)})}}function Ce(e){let n=new Map;for(let r of e){let o=n.get(r.name);(!o||r.priority>o.priority)&&n.set(r.name,r)}return n}function Ie(e,n){let r=n.get(e.name),o=r?.path===e.path;return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,prompt:e.prompt,active:o,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...!o&&r?{shadowedBy:{name:r.name,scope:r.scope,path:r.path}}:{}}}function K(e=process.cwd(),n={}){let r=n.cwd??e,o=n.userDir??z(n.agentHome),t=n.projectDirs??Pe(r),i=n.pluginDirs??[],l=n.builtInDirs??[],s=[],d=[];n.includeUser!==!1&&S(o,"user",0,s,d),n.includeProject!==!1&&t.forEach((c,f)=>S(c,"project",100+f,s,d)),n.includePlugins&&i.forEach((c,f)=>S(c,"plugin",1e3+f,s,d)),n.includeBuiltIns&&l.forEach((c,f)=>S(c,"built-in",2e3+f,s,d));let p=Ce(s),u=s.map(c=>Ie(c,p));return u.sort((c,f)=>{if(c.active!==f.active)return c.active?-1:1;let y=c.name.localeCompare(f.name);return y!==0?y:c.path.localeCompare(f.path)}),{definitions:u,issues:d,searchPaths:{...n.includeUser!==!1?{user:o}:{},project:n.includeProject===!1?[]:t,plugin:n.includePlugins?i:[],builtIn:n.includeBuiltIns?l:[]}}}function Xe(e,n=process.cwd(),r={}){let o=e.trim().toLowerCase(),t=K(n,r);return{definition:t.definitions.find(i=>i.active&&i.name===o)??null,scan:t}}var C=class{constructor(n={}){this.options=n}options;scan(n=this.options.cwd??process.cwd()){return K(n,this.options)}},J=class{constructor(n=new C){this.loader=n}loader;resolve(n,r=process.cwd()){let o=this.loader.scan(r),t=n.trim().toLowerCase();return{definition:o.definitions.find(i=>i.active&&i.name===t)??null,scan:o}}};function D(e){if(!e||e.length===0)return;let n=Array.from(new Set(e.map(r=>r.trim()).filter(Boolean)));return n.length>0?n:void 0}function Re(e,n){if(!e&&!n)return;if(!e)return D(n);if(!n)return D(e);let r=new Set(n);return D(e.filter(o=>r.has(o)))}function Me(e,n){let r={none:0,readOnly:1,default:2,fullAccess:3,inherit:4},o=n??"inherit",t=e??"inherit";return r[o]<=r[t]?o:t}function R(e,n={}){let r=e.toolPolicy??{},o={mode:Me(r.mode,n.mode)},t=Re(n.allow,r.allow),i=D([...n.deny??[],...r.deny??[]]);return t&&(o.allow=t),i&&(o.deny=i),o}function Qe(e){return{name:`custom-agent:${e.name}`,order:20,provide(){let n=["","","# Custom Agent",`Active agent: ${e.name}`,`Definition scope: ${e.scope}`,`Definition path: ${e.path}`];return e.description&&n.push(`Description: ${e.description}`),n.push("",e.prompt),n.join(`
3
- `)}}}function Ze(e){return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,active:e.active,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...e.shadowedBy?{shadowedBy:e.shadowedBy}:{}}}function P(e,n){return e.length>=n?e:e+" ".repeat(n-e.length)}function en(e,n){let r=[];if(e.length===0)r.push("No custom agent definitions found.");else{r.push(`${P("name",22)} ${P("scope",8)} ${P("status",9)} description`),r.push(`${"-".repeat(22)} ${"-".repeat(8)} ${"-".repeat(9)} ${"-".repeat(32)}`);for(let o of e){let t=o.active?"active":"shadowed";r.push(`${P(o.name,22)} ${P(o.scope,8)} ${P(t,9)} ${o.description??""}`)}}if(n.length>0){r.push("","Invalid definitions:");for(let o of n)r.push(`- ${o.path}: ${o.message}`)}return r.join(`
1
+ import{existsSync as C,mkdirSync as pe,readFileSync as me,readdirSync as ge,writeFileSync as ye}from"node:fs";import{basename as he,dirname as Ae,join as b,parse as Pe,resolve as we}from"node:path";function W(e){let n=ae(e);return{frontmatter:n.frontmatter,content:n.content.trim()}}function ae(e){let n=e.replace(/^\uFEFF/,"");if(!n.startsWith("---"))return{frontmatter:{},content:e};let r=n.search(/\r?\n/);if(r<0||n.slice(0,r).trim()!=="---")return{frontmatter:{},content:e};let o=n.slice(r+(n[r]==="\r"?2:1)),t=o.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!t||t.index===void 0)throw new Error("YAML frontmatter is not closed.");let i=o.slice(0,t.index),l=t[0],s=t.index+l.length;return{frontmatter:H(i),content:o.slice(s)}}function H(e){let n={},r=e.split(/\r?\n/);for(let o=0;o<r.length;o+=1){let t=r[o];if(!t.trim()||t.trimStart().startsWith("#"))continue;if(/^\s/.test(t))throw new Error(`Unexpected indentation at line ${o+1}.`);let i=de(t,o+1);if(i.key==="<<")throw new Error("YAML merge keys are not supported.");if(i.value!==""){n[i.key]=U(i.value,o+1);continue}let l=ce(r,o+1);n[i.key]=l.value,o=l.nextIndex-1}return n}function ce(e,n){let r=[],o=n;for(;o<e.length;o+=1){let i=e[o];if(!i.trim()){r.push(i);continue}if(!/^\s/.test(i))break;r.push(i.replace(/^ {2}/,""))}let t=r.filter(i=>i.trim()&&!i.trimStart().startsWith("#"));return t.length===0?{value:{},nextIndex:o}:t.every(i=>i.trimStart().startsWith("- "))?{value:t.map((i,l)=>U(i.trimStart().slice(2),n+l+1)),nextIndex:o}:{value:H(r.join(`
2
+ `)),nextIndex:o}}function de(e,n){let r=e.indexOf(":");if(r<=0)throw new Error(`Invalid YAML line ${n}.`);let o=e.slice(0,r).trim(),t=e.slice(r+1).trim();if(!o)throw new Error(`Invalid YAML key at line ${n}.`);return{key:o,value:t}}function U(e,n){if(e==="")return"";if(e==="[]")return[];if(e==="{}")return{};if(e==="true")return!0;if(e==="false")return!1;if(e==="null"||e==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(e))return Number(e);if(e.startsWith('"'))return V(e,n);if(e.startsWith("'")){if(!e.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${n}.`);return e.slice(1,-1).replace(/''/g,"'")}if(e.startsWith("[")||e.startsWith("{"))return V(e,n);if(e.includes("[")||e.includes("]")||e.includes("{")||e.includes("}"))throw new Error(`Unsupported YAML scalar at line ${n}.`);return e}function V(e,n){try{return JSON.parse(e)}catch{throw new Error(`Invalid YAML scalar at line ${n}.`)}}import{homedir as J,platform as ue,release as fe}from"node:os";import{resolve as G}from"node:path";var en=ue();var nn=fe(),rn=J();function z(){let e=process.env.XENO_AGENT_HOME?.trim();return e?G(e):G(J(),".xeno-agent")}var xe=/^[a-z][a-z0-9_-]{0,63}$/;function be(){return z()}function Y(e=be()){return b(e,"agents")}function K(e){return we(e)}function ke(e){let n=Ae(e);return n===e?e:n}function ve(e=process.cwd()){let n=K(e),r=[],o=n;for(;;){let t=b(o,".xeno","agents");C(t)&&r.push(t);let i=ke(o);if(i===o)break;o=i}return r.reverse()}function Se(e=process.cwd()){return b(K(e),".xeno","agents")}function De(e){return C(e)?ge(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.toLowerCase().endsWith(".md")).map(n=>b(e,n.name)).sort((n,r)=>n.localeCompare(r)):[]}function w(e){if(typeof e!="string")return;let n=e.trim();return n.length>0?n:void 0}function x(e){return Array.isArray(e)?e.map(n=>String(n).trim()).filter(Boolean):typeof e=="string"?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function Ee(e){if(typeof e=="boolean")return e;if(typeof e!="string")return;let n=e.trim().toLowerCase();if(["1","true","yes","on"].includes(n))return!0;if(["0","false","no","off"].includes(n))return!1}function $e(e){return Pe(he(e)).name.toLowerCase()}function Q(e){return xe.test(e)}function Te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ie(e){if(typeof e!="string")return;let n=e.trim().toLowerCase();if(n==="inherit")return"inherit";if(n==="none"||n==="off"||n==="disabled")return"none";if(n==="read"||n==="readonly"||n==="read-only")return"readOnly";if(n==="default"||n==="standard")return"default";if(n==="full"||n==="fullaccess"||n==="full-access")return"fullAccess"}function Ce(e){if(e===void 0)return;if(typeof e=="string"||Array.isArray(e)){let i=x(e);return i.length>0?{allow:i}:void 0}if(!Te(e))return;let n=x(e.allow),r=x(e.deny),o=Ie(e.mode),t={};return o&&(t.mode=o),n.length>0&&(t.allow=n),r.length>0&&(t.deny=r),Object.keys(t).length>0?t:void 0}function Re(e){let n=Ee(e.worktree??e.defaultWorktreeIsolation);if(n===!0)return"worktree";if(n===!1)return"none";let r=w(e.isolation)?.toLowerCase();if(r==="worktree")return"worktree";if(r==="none"||r==="off"||r==="disabled")return"none"}function Ne(e){let n=[];return Q(e.name)||n.push(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`),e.prompt.trim().length===0&&n.push("Agent definition body is empty."),n}function Oe(e,n,r){let o=me(e,"utf8"),t=W(o),i=t.frontmatter,l=$e(e),s=w(i.name)?.toLowerCase()??l,d=t.content.trim(),p=Ne({name:s,prompt:d});if(p.length>0)throw new Error(p.join(" "));let u=w(i.description),c=w(i.model),f=w(i.color),y=w(i.memory??i.memoryScope),A=Re(i),v=Ce(i.tools);return{name:s,scope:n,path:e,...u?{description:u}:{},...c?{model:c}:{},...f?{color:f}:{},...y?{memory:y}:{},...A?{isolation:A}:{},tags:x(i.tags),skills:x(i.skills),hooks:x(i.hooks),prompt:d,active:!0,priority:r,...v?{toolPolicy:v}:{}}}function S(e,n,r,o,t){for(let i of De(e))try{o.push(Oe(i,n,r))}catch(l){t.push({path:i,scope:n,message:l instanceof Error?l.message:String(l)})}}function Me(e){let n=new Map;for(let r of e){let o=n.get(r.name);(!o||r.priority>o.priority)&&n.set(r.name,r)}return n}function je(e,n){let r=n.get(e.name),o=r?.path===e.path;return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,prompt:e.prompt,active:o,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...!o&&r?{shadowedBy:{name:r.name,scope:r.scope,path:r.path}}:{}}}function Z(e=process.cwd(),n={}){let r=n.cwd??e,o=n.userDir??Y(n.agentHome),t=n.projectDirs??ve(r),i=n.pluginDirs??[],l=n.builtInDirs??[],s=[],d=[];n.includeUser!==!1&&S(o,"user",0,s,d),n.includeProject!==!1&&t.forEach((c,f)=>S(c,"project",100+f,s,d)),n.includePlugins&&i.forEach((c,f)=>S(c,"plugin",1e3+f,s,d)),n.includeBuiltIns&&l.forEach((c,f)=>S(c,"built-in",2e3+f,s,d));let p=Me(s),u=s.map(c=>je(c,p));return u.sort((c,f)=>{if(c.active!==f.active)return c.active?-1:1;let y=c.name.localeCompare(f.name);return y!==0?y:c.path.localeCompare(f.path)}),{definitions:u,issues:d,searchPaths:{...n.includeUser!==!1?{user:o}:{},project:n.includeProject===!1?[]:t,plugin:n.includePlugins?i:[],builtIn:n.includeBuiltIns?l:[]}}}function cn(e,n=process.cwd(),r={}){let o=e.trim().toLowerCase(),t=Z(n,r);return{definition:t.definitions.find(i=>i.active&&i.name===o)??null,scan:t}}var I=class{constructor(n={}){this.options=n}options;scan(n=this.options.cwd??process.cwd()){return Z(n,this.options)}},X=class{constructor(n=new I){this.loader=n}loader;resolve(n,r=process.cwd()){let o=this.loader.scan(r),t=n.trim().toLowerCase();return{definition:o.definitions.find(i=>i.active&&i.name===t)??null,scan:o}}};function D(e){if(!e||e.length===0)return;let n=Array.from(new Set(e.map(r=>r.trim()).filter(Boolean)));return n.length>0?n:void 0}function qe(e,n){if(!e&&!n)return;if(!e)return D(n);if(!n)return D(e);let r=new Set(n);return D(e.filter(o=>r.has(o)))}function Le(e,n){let r={none:0,readOnly:1,default:2,fullAccess:3,inherit:4},o=n??"inherit",t=e??"inherit";return r[o]<=r[t]?o:t}function R(e,n={}){let r=e.toolPolicy??{},o={mode:Le(r.mode,n.mode)},t=qe(n.allow,r.allow),i=D([...n.deny??[],...r.deny??[]]);return t&&(o.allow=t),i&&(o.deny=i),o}function dn(e){return{name:`custom-agent:${e.name}`,order:20,provide(){let n=["","","# Custom Agent",`Active agent: ${e.name}`,`Definition scope: ${e.scope}`,`Definition path: ${e.path}`];return e.description&&n.push(`Description: ${e.description}`),n.push("",e.prompt),n.join(`
3
+ `)}}}function un(e){return{name:e.name,scope:e.scope,path:e.path,...e.description?{description:e.description}:{},...e.model?{model:e.model}:{},...e.color?{color:e.color}:{},...e.memory?{memory:e.memory}:{},...e.isolation?{isolation:e.isolation}:{},tags:e.tags,skills:e.skills,hooks:e.hooks,active:e.active,...e.toolPolicy?{toolPolicy:e.toolPolicy}:{},...e.shadowedBy?{shadowedBy:e.shadowedBy}:{}}}function P(e,n){return e.length>=n?e:e+" ".repeat(n-e.length)}function fn(e,n){let r=[];if(e.length===0)r.push("No custom agent definitions found.");else{r.push(`${P("name",22)} ${P("scope",8)} ${P("status",9)} description`),r.push(`${"-".repeat(22)} ${"-".repeat(8)} ${"-".repeat(9)} ${"-".repeat(32)}`);for(let o of e){let t=o.active?"active":"shadowed";r.push(`${P(o.name,22)} ${P(o.scope,8)} ${P(t,9)} ${o.description??""}`)}}if(n.length>0){r.push("","Invalid definitions:");for(let o of n)r.push(`- ${o.path}: ${o.message}`)}return r.join(`
4
4
  `)+`
5
- `}function nn(e){let n=[`Agent: ${e.name}`,`Scope: ${e.scope}`,`Path: ${e.path}`,`Status: ${e.active?"active":"shadowed"}`];return e.description&&n.push(`Description: ${e.description}`),e.model&&n.push(`Model: ${e.model}`),e.color&&n.push(`Color: ${e.color}`),e.memory&&n.push(`Memory: ${e.memory}`),e.isolation&&n.push(`Isolation: ${e.isolation}`),e.tags.length>0&&n.push(`Tags: ${e.tags.join(", ")}`),e.skills.length>0&&n.push(`Skills: ${e.skills.join(", ")}`),e.hooks.length>0&&n.push(`Hooks: ${e.hooks.join(", ")}`),e.toolPolicy&&n.push(`Tools: ${JSON.stringify(e.toolPolicy)}`),e.shadowedBy&&n.push(`Shadowed by: ${e.shadowedBy.scope} ${e.shadowedBy.path}`),n.push("",e.prompt,""),n.join(`
6
- `)}function rn(e){let n=e.name.trim().toLowerCase();if(!Y(n))throw new Error(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`);let r=e.scope==="user"?z(e.agentHome):we(e.cwd??process.cwd());le(r,{recursive:!0});let o=k(r,`${n}.md`);if(I(o)&&!e.force)throw new Error(`Agent definition already exists: ${o}`);let t=e.description?.trim()||`${n} custom agent`,i=e.prompt?.trim()||`You are ${n}. Replace this paragraph with precise operating instructions, constraints, tools policy, verification expectations, and the kind of work this agent should own.`,s=[...["---",`name: ${n}`,`description: ${JSON.stringify(t)}`,...e.model?.trim()?[`model: ${JSON.stringify(e.model.trim())}`]:[],...e.color?.trim()?[`color: ${JSON.stringify(e.color.trim())}`]:[],...e.memory?.trim()?[`memory: ${JSON.stringify(e.memory.trim())}`]:[],...e.isolation?[`isolation: ${e.isolation}`]:[],"tags: []",...e.skills&&e.skills.length>0?[`skills: ${JSON.stringify(e.skills)}`]:[],...e.hooks&&e.hooks.length>0?[`hooks: ${JSON.stringify(e.hooks)}`]:[],...e.toolPolicy?["tools:",...e.toolPolicy.mode?[` mode: ${e.toolPolicy.mode}`]:[],...e.toolPolicy.allow&&e.toolPolicy.allow.length>0?[` allow: ${JSON.stringify(e.toolPolicy.allow)}`]:[],...e.toolPolicy.deny&&e.toolPolicy.deny.length>0?[` deny: ${JSON.stringify(e.toolPolicy.deny)}`]:[]]:[],"---"],"",i,""].join(`
7
- `);return de(o,s,"utf8"),o}import{createHash as Ne}from"node:crypto";var j=2,h=class extends Error{constructor(n){super(n),this.name="AgentProfileValidationError"}},je=/^[a-z][a-z0-9_-]{0,63}$/,$=["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"];function g(e){return Array.from(new Set((e??[]).map(n=>n.trim()).filter(Boolean)))}function Oe(e,n){if(e===void 0)return n===void 0?void 0:g(n);if(n===void 0)return g(e);let r=new Set(n);return g(e.filter(o=>r.has(o)))}function qe(e,n){if(e===void 0)return;let r=new Set(n);return e.filter(o=>!r.has(o))}function M(e,n,r){let o=n===void 0?null:new Set(n),t=new Set(r??[]);return e===void 0?n===void 0?void 0:g(n).filter(i=>!t.has(i)):g(e).filter(i=>(o===null||o.has(i))&&!t.has(i))}function E(e,n,r){return r[e]<=r[n]?e:n}function Le(e,n,r){return r[e]>=r[n]?e:n}function N(e){return Array.isArray(e)?e.map(N):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,N(r)]))}function Be(e){return Ne("sha256").update(JSON.stringify(N(e))).digest("hex")}function x(e){return structuredClone(e)}function X(e,n){return e.overrides?.[n]??e.default}function Fe(e,n){let r={deny:0,ask:1,allow:2},o=new Set(e.requireCurrentTurnApproval),t=Object.fromEntries($.map(d=>[d,X(e,d)]));for(let d of n){let p=d.externalActions;if(p){for(let u of $){let c=p.overrides?.[u]??p.default;c&&(t[u]=E(t[u],c,r))}for(let u of p.requireCurrentTurnApproval??[])o.add(u)}}let l=new Set(Object.values(t)).size===1?t.publish:"deny",s={};for(let d of $)t[d]!==l&&(s[d]=t[d]);return{default:l,...Object.keys(s).length>0?{overrides:s}:{},requireCurrentTurnApproval:[...o].filter(d=>t[d]!=="deny").sort()}}function Q(e){if(e.schemaVersion!==j)throw new h(`Unsupported agent profile schema: ${String(e.schemaVersion)}.`);if(!je.test(e.id))throw new h(`Invalid agent profile id: ${e.id}.`);if(!e.version.trim())throw new h(`Agent profile ${e.id} has no version.`);if(!e.displayName.trim()||!e.description.trim()||!e.prompt.trim())throw new h(`Agent profile ${e.id} requires displayName, description, and prompt.`);if(e.execution.allowedModes.length===0)throw new h(`Agent profile ${e.id} allows no collaboration modes.`);if(!e.execution.allowedModes.includes(e.execution.defaultMode))throw new h(`Agent profile ${e.id} default mode must be included in allowedModes.`)}function _e(e,n,r,o,t,i){return{name:`agent-profile:${e.id}`,order:20,provide(){let l=$.map(s=>`${s}=${X(n.externalActions,s)}`).join(", ");return["","","# XENO Agent Profile",`Profile: ${e.displayName} (${e.id}@${e.version})`,`Profile fingerprint: ${i}`,`Role: ${e.description}`,`Collaboration mode: ${o.defaultMode}`,`Isolation: ${o.isolation}`,`Memory: ${r.scope}; soul=${r.soul}`,`Permission profile ceiling: ${n.permissionProfile}`,`External actions: ${l}`,n.externalActions.requireCurrentTurnApproval.length>0?`Current-turn approval required for: ${n.externalActions.requireCurrentTurnApproval.join(", ")}`:"Current-turn approval required for: none",t.evidence.length>0?`Completion evidence: ${t.evidence.join(", ")}`:"Completion evidence: task-dependent",t.requirePrimarySources?"Use primary sources for factual claims and cite them near the claim.":"",t.requireCurrentInformation?"Verify time-sensitive claims against current authoritative information.":"",t.requireHumanReview?"Do not represent the result as professional approval; require human review before consequential use.":"",o.defaultDryRun?"Default to preview or dry-run. Do not perform external state changes without the required approval.":"","",e.prompt,"","Stop conditions:",...t.stopConditions.map(s=>`- ${s}`)].filter(s=>s!=="").join(`
8
- `)}}}function Ve(e,n={}){Q(e);let r=x(e),o=n.boundaries??[],t=x(r.capabilities.tools),i=r.capabilities.skills.allow?g(r.capabilities.skills.allow):void 0,l=new Set(g(r.capabilities.skills.deny)),s=g(r.capabilities.hooks),d=new Set,p=r.capabilities.mcpServers?g(r.capabilities.mcpServers):void 0,u=r.capabilities.delegatedAgents?g(r.capabilities.delegatedAgents):void 0,c=r.capabilities.permissionProfile,f=r.memory.scope,y=r.memory.soul,A=r.execution.isolation,v={"read-only":0,default:1,"trusted-dev":2},ee={none:0,session:1,project:2,user:3},ne={disabled:0,read:1,learn:2},re={none:0,worktree:1,container:2};for(let a of o){a.tools&&(t=R({toolPolicy:t},a.tools)),i=Oe(i,a.skills?.allow);for(let T of a.skills?.deny??[])l.add(T);s=M(s,a.hooks?.allow,void 0)??[];for(let T of a.hooks?.require??[])d.add(T);p=M(p,a.mcpServers?.allow,a.mcpServers?.deny),u=M(u,a.delegatedAgents?.allow,a.delegatedAgents?.deny),a.permissionProfile&&(c=E(c,a.permissionProfile,v)),a.maximumMemoryScope&&(f=E(f,a.maximumMemoryScope,ee)),a.maximumSoulMode&&(y=E(y,a.maximumSoulMode,ne)),a.requiredIsolation&&(A=Le(A,a.requiredIsolation,re))}let O=[...l].sort();c==="read-only"&&(t=R({toolPolicy:t},{mode:"readOnly",deny:["WebSearch","WebFetch"]})),i=qe(i,O);let oe=g(r.capabilities.skills.preload).filter(a=>!l.has(a)).filter(a=>i===void 0||i.includes(a));s=g([...s,...d]);let q={tools:t,skills:{preload:oe,...i!==void 0?{allow:i}:{},deny:O},hooks:s,...p!==void 0?{mcpServers:p}:{},...u!==void 0?{delegatedAgents:u}:{},permissionProfile:c,externalActions:Fe(r.capabilities.externalActions,o)},L={...r.memory,scope:f,soul:y},B={...r.execution,isolation:A},F={schemaVersion:j,profile:r,boundarySources:o.map(a=>a.source),capabilities:q,memory:L,execution:B,completion:r.completion},_=Be(F);return{...F,fingerprint:_,promptSection:_e(r,q,L,B,r.completion,_)}}function m(e){return{schemaVersion:j,id:e.id,version:"1.0.0",displayName:e.displayName,description:e.description,kind:e.kind??"primary",prompt:e.prompt,capabilities:{tools:e.toolPolicy??{mode:"inherit"},skills:{preload:e.skills??[],...e.skillAllow?{allow:e.skillAllow}:{},deny:[]},hooks:[],permissionProfile:e.permissionProfile??"default",externalActions:{default:e.externalDefault??"ask",...e.externalOverrides?{overrides:e.externalOverrides}:{},requireCurrentTurnApproval:e.currentTurnApproval??[]}},memory:{scope:e.memoryScope??"project",role:e.id,soul:e.soul??"read"},execution:{defaultMode:e.defaultMode??"chat",allowedModes:e.allowedModes??["chat","plan","execute","review"],isolation:e.isolation??"none",allowBackground:e.allowBackground??!0,planForComplexTasks:e.planForComplexTasks??!0,defaultDryRun:e.defaultDryRun??!1},completion:{evidence:e.evidence??[],requirePrimarySources:e.primarySources??!1,requireCurrentInformation:e.currentInformation??!1,requireHumanReview:e.humanReview??!1,stopConditions:e.stopConditions??["The requested outcome is complete and required evidence has been reported.","A real authorization, information, or external-state blocker prevents safe progress."]},presentation:{label:e.displayName,color:e.color,glyph:e.glyph},tags:g(e.tags)}}var Z=[m({id:"assistant",displayName:"Assistant",description:"General-purpose XENO collaborator for mixed research, planning, and implementation work.",prompt:["Work as a thoughtful generalist. Establish the user's actual outcome, inspect relevant context, and take scoped action.","Escalate into a narrower specialist profile when domain risk or task depth warrants it."].join(`
9
- `),toolPolicy:{mode:"inherit"},skills:[],memoryScope:"user",evidence:["file-references"],currentTurnApproval:["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"],color:"cyan",glyph:"\u25A0",tags:["general","primary"]}),m({id:"swe",displayName:"Software Engineer",description:"Repository-aware software engineer for careful implementation, debugging, refactoring, and verification.",prompt:["Inspect the repository before editing. Follow project instructions and preserve unrelated work.","Trace the smallest root cause, implement the narrowest coherent change, and verify from focused checks outward.","Do not claim completion without concrete test, typecheck, build, or runtime evidence appropriate to the risk."].join(`
10
- `),toolPolicy:{mode:"default"},skills:["debug","run","verify"],permissionProfile:"trusted-dev",soul:"learn",evidence:["file-references","tests","typecheck","build","diff"],currentTurnApproval:["publish","deploy","push","change-infrastructure"],color:"green",glyph:"\u25C6",tags:["engineering","implementation"]}),m({id:"reviewer",displayName:"Code Reviewer",description:"Read-only reviewer focused on correctness, regressions, safety, tests, and maintainability.",prompt:["Lead with concrete findings ordered by severity. Cite exact file locations and explain impact.","Do not edit code. Distinguish confirmed defects from risks and questions. State when no material finding is present."].join(`
11
- `),kind:"subagent",toolPolicy:{mode:"readOnly"},skills:["code-review","verify"],permissionProfile:"read-only",memoryScope:"session",soul:"read",allowedModes:["chat","review"],defaultMode:"review",evidence:["file-references","diff"],externalDefault:"deny",color:"yellow",glyph:"\u25C7",tags:["engineering","review","read-only"]}),m({id:"writer",displayName:"Writer",description:"Audience-aware writer and editor for clear, accurate, structurally coherent content.",prompt:["Determine audience, purpose, voice, format, and source constraints before drafting.","Preserve factual meaning, avoid invented claims, and revise for clarity, rhythm, consistency, and usefulness."].join(`
12
- `),toolPolicy:{mode:"default",allow:["Read","Glob","Grep","LS","Write","Edit","WebSearch","WebFetch","Think","AskUser","Skill"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish"],color:"magenta",glyph:"\u2726",tags:["writing","editing"]}),m({id:"research",displayName:"Researcher",description:"Evidence-first researcher for questions, comparisons, synthesis, and source-backed analysis.",prompt:["Break the question into verifiable claims. Prefer primary and authoritative sources, compare dates, and cite near each claim.","Separate sourced fact, inference, uncertainty, and recommendation. Do not make changes unless the user explicitly expands scope."].join(`
13
- `),toolPolicy:{mode:"readOnly"},skills:["verify"],permissionProfile:"default",memoryScope:"session",soul:"read",allowedModes:["chat","plan","review"],evidence:["sources","file-references"],primarySources:!0,currentInformation:!0,externalDefault:"deny",color:"blue",glyph:"\u25C8",tags:["research","qa","read-only"]}),m({id:"product",displayName:"Product",description:"Product strategist for problem framing, requirements, sequencing, metrics, and trade-off decisions.",prompt:["Start from the user problem and observable outcome. Distinguish evidence, assumptions, constraints, and open decisions.","Translate strategy into testable requirements, acceptance criteria, telemetry, risks, and a sequenced delivery path."].join(`
14
- `),toolPolicy:{mode:"default",allow:["Read","Glob","Grep","LS","Write","Edit","WebSearch","WebFetch","Think","AskUser","Skill"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish","change-infrastructure"],color:"cyan",glyph:"\u25A3",tags:["product","planning"]}),m({id:"ci",displayName:"CI Engineer",description:"Continuous-integration specialist for reproducing, repairing, and hardening automated gates.",prompt:["Identify the exact failing job and command. Reproduce it locally or in an equivalent immutable environment before patching.","Fix only the underlying failure, retain logs as evidence, and rerun the matching gate before broader validation."].join(`
15
- `),toolPolicy:{mode:"default"},skills:["ci-repair","debug","run","verify"],permissionProfile:"trusted-dev",soul:"learn",evidence:["tests","typecheck","build","diff"],currentTurnApproval:["push","deploy","change-infrastructure"],color:"green",glyph:"\u25A4",tags:["engineering","ci","automation"]}),m({id:"devops",displayName:"DevOps and Release",description:"Dry-run-first infrastructure and release specialist with explicit external-action gates.",prompt:["Inspect the release or infrastructure contract first. Build an immutable candidate and produce reproducible evidence.","Default to plan, preview, dry-run, and local verification. Never publish, deploy, push, sign, purchase, or mutate infrastructure unless the current user turn explicitly authorizes that exact action and target.","For releases, preserve SDK-before-CLI dependency order and verify the public artifact after publication."].join(`
16
- `),toolPolicy:{mode:"default"},skills:["release","run","verify"],permissionProfile:"default",memoryScope:"project",soul:"learn",isolation:"worktree",defaultMode:"plan",defaultDryRun:!0,evidence:["tests","build","diff","deployment-proof","human-review"],humanReview:!0,currentTurnApproval:["publish","deploy","push","purchase","sign","change-infrastructure"],color:"yellow",glyph:"\u2B22",tags:["devops","release","infrastructure"]}),m({id:"legal-research",displayName:"Legal Research",description:"Restricted legal-information researcher that produces sourced analysis for qualified human review.",prompt:["Identify jurisdiction, effective date, parties, and the precise legal question before analyzing it.","Use current primary legal sources wherever possible. Cite each material proposition and distinguish law, interpretation, uncertainty, and practical next steps.","Provide legal information, not professional representation. Never sign, file, submit, contact a party, accept terms, or make a payment."].join(`
17
- `),toolPolicy:{mode:"readOnly"},skills:["verify"],permissionProfile:"default",memoryScope:"session",soul:"disabled",allowedModes:["chat","plan","review"],defaultMode:"review",evidence:["sources","human-review"],primarySources:!0,currentInformation:!0,humanReview:!0,externalDefault:"deny",color:"red",glyph:"\xA7",tags:["legal","research","restricted","read-only"],stopConditions:["The jurisdiction or effective date is unknown and materially changes the answer.","The task requires legal representation, filing, signature, payment, or contact with a third party.","The sourced analysis is complete and clearly marked for qualified human review."]})],We={general:"assistant",software:"swe",engineer:"swe","software-engineer":"swe",review:"reviewer","code-reviewer":"reviewer",qa:"research","q-and-a":"research",researcher:"research","product-manager":"product","ci-cd":"ci",cicd:"ci",release:"devops","devops-release":"devops",legal:"legal-research"};function ln(){return Z.map(x)}function Ue(e){let n=e.trim().toLowerCase(),r=We[n]??n,o=Z.find(t=>t.id===r);return o?x(o):null}function He(e){let n=e.memory?.trim().toLowerCase(),r=n==="none"||n==="session"||n==="project"||n==="user"?n:"project",o=m({id:e.name,displayName:e.name,description:e.description??`Custom XENO agent ${e.name}.`,prompt:e.prompt,toolPolicy:e.toolPolicy??{mode:"inherit"},skills:e.skills,memoryScope:r,isolation:e.isolation??"none",color:e.color??"cyan",glyph:"\u25A0",tags:["custom",...e.tags]});return e.model&&(o.model={preferred:e.model}),o.capabilities.hooks=[...e.hooks],o}function an(e){return Q(e),{name:e.id,scope:"built-in",path:`builtin:xeno-agent-profile/${e.id}@${e.version}`,description:e.description,...e.model?.preferred?{model:e.model.preferred}:{},color:e.presentation.color,memory:e.memory.scope,isolation:e.execution.isolation==="container"?"worktree":e.execution.isolation,tags:[...e.tags],skills:[...e.capabilities.skills.preload],hooks:[...e.capabilities.hooks],active:!0,toolPolicy:x(e.capabilities.tools),prompt:e.prompt}}function cn(e){let n=e.definition?He(e.definition):Ue(e.name);return n?Ve(n,{boundaries:e.boundaries}):null}export{C as AgentDefinitionLoader,J as AgentDefinitionResolver,h as AgentProfileValidationError,j as XENO_AGENT_PROFILE_SCHEMA_VERSION,an as agentDefinitionFromProfile,He as agentProfileFromDefinition,Ve as compileAgentProfile,rn as createAgentDefinitionFile,Qe as createAgentDefinitionPromptSection,Pe as getProjectAgentDefinitionDirs,we as getProjectAgentDefinitionsDir,z as getUserAgentDefinitionsDir,Y as isValidAgentDefinitionName,ln as listBuiltInAgentProfiles,nn as renderAgentDefinition,en as renderAgentDefinitions,Xe as resolveAgentDefinition,cn as resolveAgentProfile,R as resolveAgentToolPolicy,Ue as resolveBuiltInAgentProfile,K as scanAgentDefinitions,Ze as toAgentDefinitionMetadata,Ee as validateAgentDefinition};
5
+ `}function pn(e){let n=[`Agent: ${e.name}`,`Scope: ${e.scope}`,`Path: ${e.path}`,`Status: ${e.active?"active":"shadowed"}`];return e.description&&n.push(`Description: ${e.description}`),e.model&&n.push(`Model: ${e.model}`),e.color&&n.push(`Color: ${e.color}`),e.memory&&n.push(`Memory: ${e.memory}`),e.isolation&&n.push(`Isolation: ${e.isolation}`),e.tags.length>0&&n.push(`Tags: ${e.tags.join(", ")}`),e.skills.length>0&&n.push(`Skills: ${e.skills.join(", ")}`),e.hooks.length>0&&n.push(`Hooks: ${e.hooks.join(", ")}`),e.toolPolicy&&n.push(`Tools: ${JSON.stringify(e.toolPolicy)}`),e.shadowedBy&&n.push(`Shadowed by: ${e.shadowedBy.scope} ${e.shadowedBy.path}`),n.push("",e.prompt,""),n.join(`
6
+ `)}function mn(e){let n=e.name.trim().toLowerCase();if(!Q(n))throw new Error(`Invalid agent name "${e.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`);let r=e.scope==="user"?Y(e.agentHome):Se(e.cwd??process.cwd());pe(r,{recursive:!0});let o=b(r,`${n}.md`);if(C(o)&&!e.force)throw new Error(`Agent definition already exists: ${o}`);let t=e.description?.trim()||`${n} custom agent`,i=e.prompt?.trim()||`You are ${n}. Replace this paragraph with precise operating instructions, constraints, tools policy, verification expectations, and the kind of work this agent should own.`,s=[...["---",`name: ${n}`,`description: ${JSON.stringify(t)}`,...e.model?.trim()?[`model: ${JSON.stringify(e.model.trim())}`]:[],...e.color?.trim()?[`color: ${JSON.stringify(e.color.trim())}`]:[],...e.memory?.trim()?[`memory: ${JSON.stringify(e.memory.trim())}`]:[],...e.isolation?[`isolation: ${e.isolation}`]:[],"tags: []",...e.skills&&e.skills.length>0?[`skills: ${JSON.stringify(e.skills)}`]:[],...e.hooks&&e.hooks.length>0?[`hooks: ${JSON.stringify(e.hooks)}`]:[],...e.toolPolicy?["tools:",...e.toolPolicy.mode?[` mode: ${e.toolPolicy.mode}`]:[],...e.toolPolicy.allow&&e.toolPolicy.allow.length>0?[` allow: ${JSON.stringify(e.toolPolicy.allow)}`]:[],...e.toolPolicy.deny&&e.toolPolicy.deny.length>0?[` deny: ${JSON.stringify(e.toolPolicy.deny)}`]:[]]:[],"---"],"",i,""].join(`
7
+ `);return ye(o,s,"utf8"),o}import{createHash as _e}from"node:crypto";var M=2,ee=["publish","deploy","push","send","purchase","sign","file-legal","change-infrastructure"],h=class extends Error{constructor(n){super(n),this.name="AgentProfileValidationError"}},Fe=/^[a-z][a-z0-9_-]{0,63}$/,E=ee;function m(e){return Array.from(new Set((e??[]).map(n=>n.trim()).filter(Boolean)))}function Be(e,n){if(e===void 0)return n===void 0?void 0:m(n);if(n===void 0)return m(e);let r=new Set(n);return m(e.filter(o=>r.has(o)))}function Ve(e,n){if(e===void 0)return;let r=new Set(n);return e.filter(o=>!r.has(o))}function N(e,n,r){let o=n===void 0?null:new Set(n),t=new Set(r??[]);return e===void 0?n===void 0?void 0:m(n).filter(i=>!t.has(i)):m(e).filter(i=>(o===null||o.has(i))&&!t.has(i))}function $(e,n,r){return r[e]<=r[n]?e:n}function We(e,n,r){return r[e]>=r[n]?e:n}function O(e){return Array.isArray(e)?e.map(O):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,O(r)]))}function He(e){return _e("sha256").update(JSON.stringify(O(e))).digest("hex")}function k(e){return structuredClone(e)}function ne(e,n){return e.overrides?.[n]??e.default}function Ue(e,n){let r={deny:0,ask:1,allow:2},o=new Set(e.requireCurrentTurnApproval),t=Object.fromEntries(E.map(d=>[d,ne(e,d)]));for(let d of n){let p=d.externalActions;if(p){for(let u of E){let c=p.overrides?.[u]??p.default;c&&(t[u]=$(t[u],c,r))}for(let u of p.requireCurrentTurnApproval??[])o.add(u)}}let l=new Set(Object.values(t)).size===1?t.publish:"deny",s={};for(let d of E)t[d]!==l&&(s[d]=t[d]);return{default:l,...Object.keys(s).length>0?{overrides:s}:{},requireCurrentTurnApproval:[...o].filter(d=>t[d]!=="deny").sort()}}function re(e){if(e.schemaVersion!==M)throw new h(`Unsupported agent profile schema: ${String(e.schemaVersion)}.`);if(!Fe.test(e.id))throw new h(`Invalid agent profile id: ${e.id}.`);if(!e.version.trim())throw new h(`Agent profile ${e.id} has no version.`);if(!e.displayName.trim()||!e.description.trim()||!e.prompt.trim())throw new h(`Agent profile ${e.id} requires displayName, description, and prompt.`);if(e.execution.allowedModes.length===0)throw new h(`Agent profile ${e.id} allows no collaboration modes.`);if(!e.execution.allowedModes.includes(e.execution.defaultMode))throw new h(`Agent profile ${e.id} default mode must be included in allowedModes.`)}function Ge(e,n,r,o,t,i){return{name:`agent-profile:${e.id}`,order:20,provide(){let l=E.map(s=>`${s}=${ne(n.externalActions,s)}`).join(", ");return["","","# XENO Agent Profile",`Profile: ${e.displayName} (${e.id}@${e.version})`,`Profile fingerprint: ${i}`,`Role: ${e.description}`,`Collaboration mode: ${o.defaultMode}`,`Isolation: ${o.isolation}`,`Memory: ${r.scope}; soul=${r.soul}`,`Permission profile ceiling: ${n.permissionProfile}`,`External actions: ${l}`,n.externalActions.requireCurrentTurnApproval.length>0?`Current-turn approval required for: ${n.externalActions.requireCurrentTurnApproval.join(", ")}`:"Current-turn approval required for: none",t.evidence.length>0?`Completion evidence: ${t.evidence.join(", ")}`:"Completion evidence: task-dependent",t.requirePrimarySources?"Use primary sources for factual claims and cite them near the claim.":"",t.requireCurrentInformation?"Verify time-sensitive claims against current authoritative information.":"",t.requireHumanReview?"Do not represent the result as professional approval; require human review before consequential use.":"",o.defaultDryRun?"Default to preview or dry-run. Do not perform external state changes without the required approval.":"","",e.prompt,"","Stop conditions:",...t.stopConditions.map(s=>`- ${s}`)].filter(s=>s!=="").join(`
8
+ `)}}}function Je(e,n={}){re(e);let r=k(e),o=n.boundaries??[],t=k(r.capabilities.tools),i=r.capabilities.skills.allow?m(r.capabilities.skills.allow):void 0,l=new Set(m(r.capabilities.skills.deny)),s=m(r.capabilities.hooks),d=new Set,p=r.capabilities.mcpServers?m(r.capabilities.mcpServers):void 0,u=r.capabilities.delegatedAgents?m(r.capabilities.delegatedAgents):void 0,c=r.capabilities.permissionProfile,f=r.memory.scope,y=r.memory.soul,A=r.execution.isolation,v={"read-only":0,default:1,"trusted-dev":2},te={none:0,session:1,project:2,user:3},ie={disabled:0,read:1,learn:2},se={none:0,worktree:1,container:2};for(let a of o){a.tools&&(t=R({toolPolicy:t},a.tools)),i=Be(i,a.skills?.allow);for(let T of a.skills?.deny??[])l.add(T);s=N(s,a.hooks?.allow,void 0)??[];for(let T of a.hooks?.require??[])d.add(T);p=N(p,a.mcpServers?.allow,a.mcpServers?.deny),u=N(u,a.delegatedAgents?.allow,a.delegatedAgents?.deny),a.permissionProfile&&(c=$(c,a.permissionProfile,v)),a.maximumMemoryScope&&(f=$(f,a.maximumMemoryScope,te)),a.maximumSoulMode&&(y=$(y,a.maximumSoulMode,ie)),a.requiredIsolation&&(A=We(A,a.requiredIsolation,se))}let j=[...l].sort();c==="read-only"&&(t=R({toolPolicy:t},{mode:"readOnly",deny:["WebSearch","WebFetch"]})),i=Ve(i,j);let le=m(r.capabilities.skills.preload).filter(a=>!l.has(a)).filter(a=>i===void 0||i.includes(a));s=m([...s,...d]);let q={tools:t,skills:{preload:le,...i!==void 0?{allow:i}:{},deny:j},hooks:s,...p!==void 0?{mcpServers:p}:{},...u!==void 0?{delegatedAgents:u}:{},permissionProfile:c,externalActions:Ue(r.capabilities.externalActions,o)},L={...r.memory,scope:f,soul:y},_={...r.execution,isolation:A},F={schemaVersion:M,profile:r,boundarySources:o.map(a=>a.source),capabilities:q,memory:L,execution:_,completion:r.completion},B=He(F);return{...F,fingerprint:B,promptSection:Ge(r,q,L,_,r.completion,B)}}function g(e){return{schemaVersion:M,id:e.id,version:"1.0.0",displayName:e.displayName,description:e.description,kind:e.kind??"primary",prompt:e.prompt,capabilities:{tools:e.toolPolicy??{mode:"inherit"},skills:{preload:e.skills??[],...e.skillAllow?{allow:e.skillAllow}:{},deny:[]},hooks:[],permissionProfile:e.permissionProfile??"default",externalActions:{default:e.externalDefault??"ask",...e.externalOverrides?{overrides:e.externalOverrides}:{},requireCurrentTurnApproval:e.currentTurnApproval??[]}},memory:{scope:e.memoryScope??"project",role:e.id,soul:e.soul??"read"},execution:{defaultMode:e.defaultMode??"chat",allowedModes:e.allowedModes??["chat","plan","execute","review"],isolation:e.isolation??"none",allowBackground:e.allowBackground??!0,planForComplexTasks:e.planForComplexTasks??!0,defaultDryRun:e.defaultDryRun??!1},completion:{evidence:e.evidence??[],requirePrimarySources:e.primarySources??!1,requireCurrentInformation:e.currentInformation??!1,requireHumanReview:e.humanReview??!1,stopConditions:e.stopConditions??["The requested outcome is complete and required evidence has been reported.","A real authorization, information, or external-state blocker prevents safe progress."]},presentation:{label:e.displayName,color:e.color,glyph:e.glyph},tags:m(e.tags)}}var oe=[g({id:"assistant",displayName:"Assistant",description:"General-purpose XENO collaborator for mixed research, planning, and implementation work.",prompt:["Work as a thoughtful generalist. Establish the user's actual outcome, inspect relevant context, and take scoped action.","Escalate into a narrower specialist profile when domain risk or task depth warrants it."].join(`
9
+ `),toolPolicy:{mode:"inherit"},skills:[],memoryScope:"user",evidence:["file-references"],currentTurnApproval:[...ee],color:"cyan",glyph:"\u25A0",tags:["general","primary"]}),g({id:"swe",displayName:"Software Engineer",description:"Repository-aware software engineer for careful implementation, debugging, refactoring, and verification.",prompt:["Inspect the repository before editing. Follow project instructions and preserve unrelated work.","Trace the smallest root cause, implement the narrowest coherent change, and verify from focused checks outward.","Do not claim completion without concrete test, typecheck, build, or runtime evidence appropriate to the risk."].join(`
10
+ `),toolPolicy:{mode:"default"},skills:["debug","run","verify"],permissionProfile:"trusted-dev",soul:"learn",evidence:["file-references","tests","typecheck","build","diff"],currentTurnApproval:["publish","deploy","push","change-infrastructure"],color:"green",glyph:"\u25C6",tags:["engineering","implementation"]}),g({id:"reviewer",displayName:"Code Reviewer",description:"Read-only reviewer focused on correctness, regressions, safety, tests, and maintainability.",prompt:["Lead with concrete findings ordered by severity. Cite exact file locations and explain impact.","Do not edit code. Distinguish confirmed defects from risks and questions. State when no material finding is present."].join(`
11
+ `),kind:"subagent",toolPolicy:{mode:"readOnly"},skills:["code-review","verify"],permissionProfile:"read-only",memoryScope:"session",soul:"read",allowedModes:["chat","review"],defaultMode:"review",evidence:["file-references","diff"],externalDefault:"deny",color:"yellow",glyph:"\u25C7",tags:["engineering","review","read-only"]}),g({id:"writer",displayName:"Writer",description:"Audience-aware writer and editor for clear, accurate, structurally coherent content.",prompt:["Determine audience, purpose, voice, format, and source constraints before drafting.","Preserve factual meaning, avoid invented claims, and revise for clarity, rhythm, consistency, and usefulness."].join(`
12
+ `),toolPolicy:{mode:"default",allow:["Read","Glob","Grep","LS","Write","Edit","WebSearch","WebFetch","Think","AskUser","Skill"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish"],color:"magenta",glyph:"\u2726",tags:["writing","editing"]}),g({id:"research",displayName:"Researcher",description:"Evidence-first researcher for questions, comparisons, synthesis, and source-backed analysis.",prompt:["Break the question into verifiable claims. Prefer primary and authoritative sources, compare dates, and cite near each claim.","Separate sourced fact, inference, uncertainty, and recommendation. Do not make changes unless the user explicitly expands scope."].join(`
13
+ `),toolPolicy:{mode:"readOnly"},skills:["verify"],permissionProfile:"default",memoryScope:"session",soul:"read",allowedModes:["chat","plan","review"],evidence:["sources","file-references"],primarySources:!0,currentInformation:!0,externalDefault:"deny",color:"blue",glyph:"\u25C8",tags:["research","qa","read-only"]}),g({id:"product",displayName:"Product",description:"Product strategist for problem framing, requirements, sequencing, metrics, and trade-off decisions.",prompt:["Start from the user problem and observable outcome. Distinguish evidence, assumptions, constraints, and open decisions.","Translate strategy into testable requirements, acceptance criteria, telemetry, risks, and a sequenced delivery path."].join(`
14
+ `),toolPolicy:{mode:"default",allow:["Read","Glob","Grep","LS","Write","Edit","WebSearch","WebFetch","Think","AskUser","Skill"]},skills:["verify"],evidence:["sources","file-references","diff"],currentTurnApproval:["send","publish","change-infrastructure"],color:"cyan",glyph:"\u25A3",tags:["product","planning"]}),g({id:"ci",displayName:"CI Engineer",description:"Continuous-integration specialist for reproducing, repairing, and hardening automated gates.",prompt:["Identify the exact failing job and command. Reproduce it locally or in an equivalent immutable environment before patching.","Fix only the underlying failure, retain logs as evidence, and rerun the matching gate before broader validation."].join(`
15
+ `),toolPolicy:{mode:"default"},skills:["ci-repair","debug","run","verify"],permissionProfile:"trusted-dev",soul:"learn",evidence:["tests","typecheck","build","diff"],currentTurnApproval:["push","deploy","change-infrastructure"],color:"green",glyph:"\u25A4",tags:["engineering","ci","automation"]}),g({id:"devops",displayName:"DevOps and Release",description:"Dry-run-first infrastructure and release specialist with explicit external-action gates.",prompt:["Inspect the release or infrastructure contract first. Build an immutable candidate and produce reproducible evidence.","Default to plan, preview, dry-run, and local verification. Never publish, deploy, push, sign, purchase, or mutate infrastructure unless the current user turn explicitly authorizes that exact action and target.","For releases, preserve SDK-before-CLI dependency order and verify the public artifact after publication."].join(`
16
+ `),toolPolicy:{mode:"default"},skills:["release","run","verify"],permissionProfile:"default",memoryScope:"project",soul:"learn",isolation:"worktree",defaultMode:"plan",defaultDryRun:!0,evidence:["tests","build","diff","deployment-proof","human-review"],humanReview:!0,currentTurnApproval:["publish","deploy","push","purchase","sign","change-infrastructure"],color:"yellow",glyph:"\u2B22",tags:["devops","release","infrastructure"]}),g({id:"legal-research",displayName:"Legal Research",description:"Restricted legal-information researcher that produces sourced analysis for qualified human review.",prompt:["Identify jurisdiction, effective date, parties, and the precise legal question before analyzing it.","Use current primary legal sources wherever possible. Cite each material proposition and distinguish law, interpretation, uncertainty, and practical next steps.","Provide legal information, not professional representation. Never sign, file, submit, contact a party, accept terms, or make a payment."].join(`
17
+ `),toolPolicy:{mode:"readOnly"},skills:["verify"],permissionProfile:"default",memoryScope:"session",soul:"disabled",allowedModes:["chat","plan","review"],defaultMode:"review",evidence:["sources","human-review"],primarySources:!0,currentInformation:!0,humanReview:!0,externalDefault:"deny",color:"red",glyph:"\xA7",tags:["legal","research","restricted","read-only"],stopConditions:["The jurisdiction or effective date is unknown and materially changes the answer.","The task requires legal representation, filing, signature, payment, or contact with a third party.","The sourced analysis is complete and clearly marked for qualified human review."]})],ze={general:"assistant",software:"swe",engineer:"swe","software-engineer":"swe",review:"reviewer","code-reviewer":"reviewer",qa:"research","q-and-a":"research",researcher:"research","product-manager":"product","ci-cd":"ci",cicd:"ci",release:"devops","devops-release":"devops",legal:"legal-research"};function An(){return oe.map(k)}function Xe(e){let n=e.trim().toLowerCase(),r=ze[n]??n,o=oe.find(t=>t.id===r);return o?k(o):null}function Ye(e){let n=e.memory?.trim().toLowerCase(),r=n==="none"||n==="session"||n==="project"||n==="user"?n:"project",o=g({id:e.name,displayName:e.name,description:e.description??`Custom XENO agent ${e.name}.`,prompt:e.prompt,toolPolicy:e.toolPolicy??{mode:"inherit"},skills:e.skills,memoryScope:r,isolation:e.isolation??"none",color:e.color??"cyan",glyph:"\u25A0",tags:["custom",...e.tags]});return e.model&&(o.model={preferred:e.model}),o.capabilities.hooks=[...e.hooks],o}function Pn(e){return re(e),{name:e.id,scope:"built-in",path:`builtin:xeno-agent-profile/${e.id}@${e.version}`,description:e.description,...e.model?.preferred?{model:e.model.preferred}:{},color:e.presentation.color,memory:e.memory.scope,isolation:e.execution.isolation==="container"?"worktree":e.execution.isolation,tags:[...e.tags],skills:[...e.capabilities.skills.preload],hooks:[...e.capabilities.hooks],active:!0,toolPolicy:k(e.capabilities.tools),prompt:e.prompt}}function wn(e){let n=e.definition?Ye(e.definition):Xe(e.name);return n?Je(n,{boundaries:e.boundaries}):null}export{ee as AGENT_PROFILE_EXTERNAL_ACTIONS,I as AgentDefinitionLoader,X as AgentDefinitionResolver,h as AgentProfileValidationError,M as XENO_AGENT_PROFILE_SCHEMA_VERSION,Pn as agentDefinitionFromProfile,Ye as agentProfileFromDefinition,Je as compileAgentProfile,mn as createAgentDefinitionFile,dn as createAgentDefinitionPromptSection,ve as getProjectAgentDefinitionDirs,Se as getProjectAgentDefinitionsDir,Y as getUserAgentDefinitionsDir,Q as isValidAgentDefinitionName,An as listBuiltInAgentProfiles,pn as renderAgentDefinition,fn as renderAgentDefinitions,cn as resolveAgentDefinition,wn as resolveAgentProfile,R as resolveAgentToolPolicy,Xe as resolveBuiltInAgentProfile,Z as scanAgentDefinitions,un as toAgentDefinitionMetadata,Ne as validateAgentDefinition};
@@ -1 +1 @@
1
- {"inputs":{"src/utils/yaml.ts":{"bytes":5668,"imports":[],"format":"esm"},"src/agents/definitions.ts":{"bytes":21209,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"../utils/yaml.js"}],"format":"esm"},"src/agents/profiles.ts":{"bytes":33353,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"}],"format":"esm"},"src/agents/index.ts":{"bytes":67,"imports":[{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"},{"path":"src/agents/profiles.ts","kind":"import-statement","original":"./profiles.js"}],"format":"esm"}},"outputs":{"dist/agents/index.cjs":{"imports":[{"path":"node:fs","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/agents/index.ts","inputs":{"src/agents/index.ts":{"bytesInOutput":784},"src/agents/definitions.ts":{"bytesInOutput":8917},"src/utils/yaml.ts":{"bytesInOutput":2217},"src/agents/profiles.ts":{"bytesInOutput":15500}},"bytes":28467}}}
1
+ {"inputs":{"src/utils/yaml.ts":{"bytes":5668,"imports":[],"format":"esm"},"src/utils/platform.ts":{"bytes":5600,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/agents/definitions.ts":{"bytes":20576,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"../utils/yaml.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/agents/profiles.ts":{"bytes":34533,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"}],"format":"esm"},"src/agents/index.ts":{"bytes":67,"imports":[{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"},{"path":"src/agents/profiles.ts","kind":"import-statement","original":"./profiles.js"}],"format":"esm"}},"outputs":{"dist/agents/index.cjs":{"imports":[{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/agents/index.ts","inputs":{"src/agents/index.ts":{"bytesInOutput":822},"src/agents/definitions.ts":{"bytesInOutput":8827},"src/utils/yaml.ts":{"bytesInOutput":2217},"src/utils/platform.ts":{"bytesInOutput":241},"src/agents/profiles.ts":{"bytesInOutput":15421}},"bytes":28608}}}
@@ -1 +1 @@
1
- {"inputs":{"src/utils/yaml.ts":{"bytes":5668,"imports":[],"format":"esm"},"src/agents/definitions.ts":{"bytes":21209,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"../utils/yaml.js"}],"format":"esm"},"src/agents/profiles.ts":{"bytes":33353,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"}],"format":"esm"},"src/agents/index.ts":{"bytes":67,"imports":[{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"},{"path":"src/agents/profiles.ts","kind":"import-statement","original":"./profiles.js"}],"format":"esm"}},"outputs":{"dist/agents/index.js":{"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true}],"exports":["AgentDefinitionLoader","AgentDefinitionResolver","AgentProfileValidationError","XENO_AGENT_PROFILE_SCHEMA_VERSION","agentDefinitionFromProfile","agentProfileFromDefinition","compileAgentProfile","createAgentDefinitionFile","createAgentDefinitionPromptSection","getProjectAgentDefinitionDirs","getProjectAgentDefinitionsDir","getUserAgentDefinitionsDir","isValidAgentDefinitionName","listBuiltInAgentProfiles","renderAgentDefinition","renderAgentDefinitions","resolveAgentDefinition","resolveAgentProfile","resolveAgentToolPolicy","resolveBuiltInAgentProfile","scanAgentDefinitions","toAgentDefinitionMetadata","validateAgentDefinition"],"entryPoint":"src/agents/index.ts","inputs":{"src/agents/definitions.ts":{"bytesInOutput":8875},"src/utils/yaml.ts":{"bytesInOutput":2217},"src/agents/index.ts":{"bytesInOutput":0},"src/agents/profiles.ts":{"bytesInOutput":15489}},"bytes":27311}}}
1
+ {"inputs":{"src/utils/yaml.ts":{"bytes":5668,"imports":[],"format":"esm"},"src/utils/platform.ts":{"bytes":5600,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/agents/definitions.ts":{"bytes":20576,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"../utils/yaml.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/agents/profiles.ts":{"bytes":34533,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"}],"format":"esm"},"src/agents/index.ts":{"bytes":67,"imports":[{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"},{"path":"src/agents/profiles.ts","kind":"import-statement","original":"./profiles.js"}],"format":"esm"}},"outputs":{"dist/agents/index.js":{"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true}],"exports":["AGENT_PROFILE_EXTERNAL_ACTIONS","AgentDefinitionLoader","AgentDefinitionResolver","AgentProfileValidationError","XENO_AGENT_PROFILE_SCHEMA_VERSION","agentDefinitionFromProfile","agentProfileFromDefinition","compileAgentProfile","createAgentDefinitionFile","createAgentDefinitionPromptSection","getProjectAgentDefinitionDirs","getProjectAgentDefinitionsDir","getUserAgentDefinitionsDir","isValidAgentDefinitionName","listBuiltInAgentProfiles","renderAgentDefinition","renderAgentDefinitions","resolveAgentDefinition","resolveAgentProfile","resolveAgentToolPolicy","resolveBuiltInAgentProfile","scanAgentDefinitions","toAgentDefinitionMetadata","validateAgentDefinition"],"entryPoint":"src/agents/index.ts","inputs":{"src/agents/definitions.ts":{"bytesInOutput":8785},"src/utils/yaml.ts":{"bytesInOutput":2217},"src/utils/platform.ts":{"bytesInOutput":220},"src/agents/index.ts":{"bytesInOutput":0},"src/agents/profiles.ts":{"bytesInOutput":15422}},"bytes":27411}}}
@@ -1 +1 @@
1
- "use strict";var X=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var r in t)X(e,r,{get:t[r],enumerable:!0})},S=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!R.call(e,o)&&o!==r&&X(e,o,{get:()=>t[o],enumerable:!(i=k(t,o))||i.enumerable});return e};var _=e=>S(X({},"__esModule",{value:!0}),e);var q={};x(q,{XENO_ARTIFACT_SCHEMA_VERSION:()=>M,XENO_EVIDENCE_GRAPH_SCHEMA_VERSION:()=>P,XenoBrowserDiffError:()=>m,xenoArtifactToDiffDocument:()=>O});module.exports=_(q);var M=1,P=1;var $=new Set(["working-tree","staged","turn","commit","preview"]),L=new Set(["added","modified","deleted","renamed","copied","binary"]),N=new Set(["context","addition","deletion","no-newline"]),u=16*1024*1024,h=5e3,w=1e5,b=1e6;function O(e){if(!e||typeof e!="object")throw new TypeError("Artifact is required");if(e.kind!=="diff"&&e.kind!=="patch")throw new TypeError("Artifact is not a diff or patch");let t=e.content?.storage;if(!t||t.type!=="inline"||typeof t.text!="string")throw new TypeError("Diff artifact content is not available inline");if(I(t.text)>u)throw new m(`Diff artifact exceeds ${u} bytes`);let r;try{r=JSON.parse(t.text)}catch{throw new m("Diff artifact JSON is malformed")}if(!y(r))throw new m("Diff artifact document is invalid");let i=C(r);return structuredClone(i)}var m=class extends Error{code="XENO_DIFF_INVALID";constructor(t){super(t),this.name="XenoBrowserDiffError"}};function C(e){e.schemaVersion!==1&&n("schemaVersion must be 1"),(typeof e.mode!="string"||!$.has(e.mode))&&n("mode is invalid"),typeof e.rawDiff!="string"&&n("rawDiff is required"),I(e.rawDiff)>u&&n(`rawDiff exceeds ${u} bytes`),(!Array.isArray(e.files)||e.files.length>h)&&n(`files must contain at most ${h} entries`);let t=e.files.map((c,f)=>V(c,f)),r=t.reduce((c,f)=>c+f.hunks.length,0),i=t.reduce((c,f)=>c+f.hunks.reduce((E,v)=>E+v.lines.length,0),0);r>w&&n(`diff exceeds ${w} hunks`),i>b&&n(`diff exceeds ${b} lines`);let o=g(e.additions,"additions"),p=g(e.deletions,"deletions"),d=t.reduce((c,f)=>c+f.additions,0),s=t.reduce((c,f)=>c+f.deletions,0);return(o!==d||p!==s)&&n("diff totals do not match file totals"),{schemaVersion:1,mode:e.mode,...a(e.repositoryId)?{repositoryId:a(e.repositoryId)}:{},...a(e.baseRef)?{baseRef:a(e.baseRef)}:{},...a(e.headRef)?{headRef:a(e.headRef)}:{},files:t,additions:o,deletions:p,rawDiff:e.rawDiff}}function V(e,t){y(e)||n(`files[${t}] is invalid`);let r=l(e.displayPath,`files[${t}].displayPath`,8192);(typeof e.status!="string"||!L.has(e.status))&&n(`files[${t}].status is invalid`),typeof e.binary!="boolean"&&n(`files[${t}].binary must be boolean`),(!Array.isArray(e.headerLines)||e.headerLines.some(d=>typeof d!="string"))&&n(`files[${t}].headerLines is invalid`),Array.isArray(e.hunks)||n(`files[${t}].hunks is invalid`);let i=e.hunks.map((d,s)=>T(d,t,s)),o=g(e.additions,`files[${t}].additions`),p=g(e.deletions,`files[${t}].deletions`);return(o!==i.reduce((d,s)=>d+s.additions,0)||p!==i.reduce((d,s)=>d+s.deletions,0))&&n(`files[${t}] totals do not match hunks`),{...a(e.oldPath)?{oldPath:a(e.oldPath)}:{},...a(e.newPath)?{newPath:a(e.newPath)}:{},displayPath:r,status:e.status,additions:o,deletions:p,binary:e.binary,headerLines:[...e.headerLines],hunks:i}}function T(e,t,r){y(e)||n(`files[${t}].hunks[${r}] is invalid`);let i=`files[${t}].hunks[${r}]`;Array.isArray(e.lines)||n(`${i}.lines is invalid`);let o=e.lines.map((s,c)=>F(s,`${i}.lines[${c}]`)),p=g(e.additions,`${i}.additions`),d=g(e.deletions,`${i}.deletions`);return(p!==o.filter(s=>s.kind==="addition").length||d!==o.filter(s=>s.kind==="deletion").length)&&n(`${i} totals do not match lines`),{hunkId:l(e.hunkId,`${i}.hunkId`,512),header:l(e.header,`${i}.header`,8192),...a(e.section)?{section:a(e.section)}:{},oldStart:A(e.oldStart,`${i}.oldStart`),oldLines:g(e.oldLines,`${i}.oldLines`),newStart:A(e.newStart,`${i}.newStart`),newLines:g(e.newLines,`${i}.newLines`),additions:p,deletions:d,lines:o}}function F(e,t){return y(e)||n(`${t} is invalid`),(typeof e.kind!="string"||!N.has(e.kind))&&n(`${t}.kind is invalid`),typeof e.text!="string"&&n(`${t}.text is required`),{kind:e.kind,text:e.text,...e.oldLine!==void 0?{oldLine:A(e.oldLine,`${t}.oldLine`)}:{},...e.newLine!==void 0?{newLine:A(e.newLine,`${t}.newLine`)}:{}}}function y(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function l(e,t,r){return(typeof e!="string"||e.length===0||e.length>r||e.includes("\0"))&&n(`${t} is invalid`),e}function a(e){return typeof e=="string"&&e.length>0&&e.length<=8192&&!e.includes("\0")?e:void 0}function g(e,t){return(!Number.isSafeInteger(e)||e<0)&&n(`${t} must be a non-negative integer`),e}function A(e,t){return(!Number.isSafeInteger(e)||e<1)&&n(`${t} must be a positive integer`),e}function I(e){return new TextEncoder().encode(e).byteLength}function n(e){throw new m(e)}0&&(module.exports={XENO_ARTIFACT_SCHEMA_VERSION,XENO_EVIDENCE_GRAPH_SCHEMA_VERSION,XenoBrowserDiffError,xenoArtifactToDiffDocument});
1
+ "use strict";var y=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var r in t)y(e,r,{get:t[r],enumerable:!0})},k=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of v(t))!D.call(e,o)&&o!==r&&y(e,o,{get:()=>t[o],enumerable:!(i=S(t,o))||i.enumerable});return e};var x=e=>k(y({},"__esModule",{value:!0}),e);var K={};R(K,{XENO_ARTIFACT_ACTOR_KINDS:()=>$,XENO_ARTIFACT_SCHEMA_VERSION:()=>G,XENO_ARTIFACT_SENSITIVITIES:()=>O,XENO_ARTIFACT_STATES:()=>T,XENO_BUILTIN_ARTIFACT_KINDS:()=>N,XENO_EVIDENCE_EDGE_TYPES:()=>C,XENO_EVIDENCE_GRAPH_SCHEMA_VERSION:()=>U,XENO_EVIDENCE_NODE_TYPES:()=>L,XenoBrowserDiffError:()=>m,xenoArtifactToDiffDocument:()=>q});module.exports=x(K);var G=1,U=1,N=["plan","requirements","design","task-graph","patch","diff","file","document","diagram","screenshot","recording","browser-snapshot","test-report","review-report","security-report","performance-report","release-report","sbom","provenance","attestation"],T=["draft","pending_review","approved","rejected","superseded","archived"],O=["public","internal","confidential","restricted"],$=["agent","tool","user","system","integration"],L=["requirement","design-decision","risk","task","agent","run","tool-call","edit","commit","test-case","test-run","finding","approval","artifact","release","claim"],C=["decomposes","depends_on","implements","changes","tests","verifies","finds","fixes","reviews","approves","rejects","supersedes","derived_from","produced_by","supports_claim","contradicts_claim","released_as"];var V=new Set(["working-tree","staged","turn","commit","preview"]),F=new Set(["added","modified","deleted","renamed","copied","binary"]),P=new Set(["context","addition","deletion","no-newline"]),A=16*1024*1024,l=5e3,I=1e5,h=1e6;function q(e){if(!e||typeof e!="object")throw new TypeError("Artifact is required");if(e.kind!=="diff"&&e.kind!=="patch")throw new TypeError("Artifact is not a diff or patch");let t=e.content?.storage;if(!t||t.type!=="inline"||typeof t.text!="string")throw new TypeError("Diff artifact content is not available inline");if(b(t.text)>A)throw new m(`Diff artifact exceeds ${A} bytes`);let r;try{r=JSON.parse(t.text)}catch{throw new m("Diff artifact JSON is malformed")}if(!X(r))throw new m("Diff artifact document is invalid");let i=H(r);return structuredClone(i)}var m=class extends Error{code="XENO_DIFF_INVALID";constructor(t){super(t),this.name="XenoBrowserDiffError"}};function H(e){e.schemaVersion!==1&&n("schemaVersion must be 1"),(typeof e.mode!="string"||!V.has(e.mode))&&n("mode is invalid"),typeof e.rawDiff!="string"&&n("rawDiff is required"),b(e.rawDiff)>A&&n(`rawDiff exceeds ${A} bytes`),(!Array.isArray(e.files)||e.files.length>l)&&n(`files must contain at most ${l} entries`);let t=e.files.map((a,f)=>M(a,f)),r=t.reduce((a,f)=>a+f.hunks.length,0),i=t.reduce((a,f)=>a+f.hunks.reduce((w,_)=>w+_.lines.length,0),0);r>I&&n(`diff exceeds ${I} hunks`),i>h&&n(`diff exceeds ${h} lines`);let o=g(e.additions,"additions"),p=g(e.deletions,"deletions"),c=t.reduce((a,f)=>a+f.additions,0),s=t.reduce((a,f)=>a+f.deletions,0);return(o!==c||p!==s)&&n("diff totals do not match file totals"),{schemaVersion:1,mode:e.mode,...d(e.repositoryId)?{repositoryId:d(e.repositoryId)}:{},...d(e.baseRef)?{baseRef:d(e.baseRef)}:{},...d(e.headRef)?{headRef:d(e.headRef)}:{},files:t,additions:o,deletions:p,rawDiff:e.rawDiff}}function M(e,t){X(e)||n(`files[${t}] is invalid`);let r=E(e.displayPath,`files[${t}].displayPath`,8192);(typeof e.status!="string"||!F.has(e.status))&&n(`files[${t}].status is invalid`),typeof e.binary!="boolean"&&n(`files[${t}].binary must be boolean`),(!Array.isArray(e.headerLines)||e.headerLines.some(c=>typeof c!="string"))&&n(`files[${t}].headerLines is invalid`),Array.isArray(e.hunks)||n(`files[${t}].hunks is invalid`);let i=e.hunks.map((c,s)=>j(c,t,s)),o=g(e.additions,`files[${t}].additions`),p=g(e.deletions,`files[${t}].deletions`);return(o!==i.reduce((c,s)=>c+s.additions,0)||p!==i.reduce((c,s)=>c+s.deletions,0))&&n(`files[${t}] totals do not match hunks`),{...d(e.oldPath)?{oldPath:d(e.oldPath)}:{},...d(e.newPath)?{newPath:d(e.newPath)}:{},displayPath:r,status:e.status,additions:o,deletions:p,binary:e.binary,headerLines:[...e.headerLines],hunks:i}}function j(e,t,r){X(e)||n(`files[${t}].hunks[${r}] is invalid`);let i=`files[${t}].hunks[${r}]`;Array.isArray(e.lines)||n(`${i}.lines is invalid`);let o=e.lines.map((s,a)=>J(s,`${i}.lines[${a}]`)),p=g(e.additions,`${i}.additions`),c=g(e.deletions,`${i}.deletions`);return(p!==o.filter(s=>s.kind==="addition").length||c!==o.filter(s=>s.kind==="deletion").length)&&n(`${i} totals do not match lines`),{hunkId:E(e.hunkId,`${i}.hunkId`,512),header:E(e.header,`${i}.header`,8192),...d(e.section)?{section:d(e.section)}:{},oldStart:u(e.oldStart,`${i}.oldStart`),oldLines:g(e.oldLines,`${i}.oldLines`),newStart:u(e.newStart,`${i}.newStart`),newLines:g(e.newLines,`${i}.newLines`),additions:p,deletions:c,lines:o}}function J(e,t){return X(e)||n(`${t} is invalid`),(typeof e.kind!="string"||!P.has(e.kind))&&n(`${t}.kind is invalid`),typeof e.text!="string"&&n(`${t}.text is required`),{kind:e.kind,text:e.text,...e.oldLine!==void 0?{oldLine:u(e.oldLine,`${t}.oldLine`)}:{},...e.newLine!==void 0?{newLine:u(e.newLine,`${t}.newLine`)}:{}}}function X(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function E(e,t,r){return(typeof e!="string"||e.length===0||e.length>r||e.includes("\0"))&&n(`${t} is invalid`),e}function d(e){return typeof e=="string"&&e.length>0&&e.length<=8192&&!e.includes("\0")?e:void 0}function g(e,t){return(!Number.isSafeInteger(e)||e<0)&&n(`${t} must be a non-negative integer`),e}function u(e,t){return(!Number.isSafeInteger(e)||e<1)&&n(`${t} must be a positive integer`),e}function b(e){return new TextEncoder().encode(e).byteLength}function n(e){throw new m(e)}0&&(module.exports={XENO_ARTIFACT_ACTOR_KINDS,XENO_ARTIFACT_SCHEMA_VERSION,XENO_ARTIFACT_SENSITIVITIES,XENO_ARTIFACT_STATES,XENO_BUILTIN_ARTIFACT_KINDS,XENO_EVIDENCE_EDGE_TYPES,XENO_EVIDENCE_GRAPH_SCHEMA_VERSION,XENO_EVIDENCE_NODE_TYPES,XenoBrowserDiffError,xenoArtifactToDiffDocument});
@@ -1,5 +1,5 @@
1
- import { X as XenoArtifactEnvelope, a as XenoDiffDocument } from "./diff-artifact-C2tQZWcs.cjs";
2
- export { b as XENO_ARTIFACT_SCHEMA_VERSION, c as XENO_EVIDENCE_GRAPH_SCHEMA_VERSION, d as XenoArtifactActor, e as XenoArtifactActorKind, f as XenoArtifactAnchor, g as XenoArtifactContent, h as XenoArtifactIdentity, i as XenoArtifactKind, j as XenoArtifactLifecycleEvent, k as XenoArtifactListQuery, l as XenoArtifactProvenance, m as XenoArtifactRecord, n as XenoArtifactRelationship, o as XenoArtifactRetention, p as XenoArtifactReviewDecision, q as XenoArtifactReviewEvent, r as XenoArtifactReviewEventInput, s as XenoArtifactReviewSummary, t as XenoArtifactSensitivity, u as XenoArtifactState, v as XenoArtifactStorageReference, w as XenoContentHash, x as XenoDiffFile, y as XenoDiffFileStatus, z as XenoDiffHunk, A as XenoDiffLine, B as XenoDiffLineKind, C as XenoDiffMode, D as XenoEvidenceEdge, E as XenoEvidenceEdgeType, F as XenoEvidenceGraph, G as XenoEvidenceNode, H as XenoEvidenceNodeType, I as XenoEvidenceReference, J as XenoJsonObject, K as XenoJsonPrimitive, L as XenoJsonValue } from "./diff-artifact-C2tQZWcs.cjs";
1
+ import { X as XenoArtifactEnvelope, a as XenoDiffDocument } from "./diff-artifact-CmhmeSu5.cjs";
2
+ export { b as XENO_ARTIFACT_ACTOR_KINDS, c as XENO_ARTIFACT_SCHEMA_VERSION, d as XENO_ARTIFACT_SENSITIVITIES, e as XENO_ARTIFACT_STATES, f as XENO_BUILTIN_ARTIFACT_KINDS, g as XENO_EVIDENCE_EDGE_TYPES, h as XENO_EVIDENCE_GRAPH_SCHEMA_VERSION, i as XENO_EVIDENCE_NODE_TYPES, j as XenoArtifactActor, k as XenoArtifactActorKind, l as XenoArtifactAnchor, m as XenoArtifactContent, n as XenoArtifactIdentity, o as XenoArtifactKind, p as XenoArtifactLifecycleEvent, q as XenoArtifactListQuery, r as XenoArtifactProvenance, s as XenoArtifactRecord, t as XenoArtifactRelationship, u as XenoArtifactRetention, v as XenoArtifactReviewDecision, w as XenoArtifactReviewEvent, x as XenoArtifactReviewEventInput, y as XenoArtifactReviewSummary, z as XenoArtifactSensitivity, A as XenoArtifactState, B as XenoArtifactStorageReference, C as XenoContentHash, D as XenoDiffFile, E as XenoDiffFileStatus, F as XenoDiffHunk, G as XenoDiffLine, H as XenoDiffLineKind, I as XenoDiffMode, J as XenoEvidenceEdge, K as XenoEvidenceEdgeType, L as XenoEvidenceGraph, M as XenoEvidenceNode, N as XenoEvidenceNodeType, O as XenoEvidenceReference, P as XenoJsonObject, Q as XenoJsonPrimitive, R as XenoJsonValue } from "./diff-artifact-CmhmeSu5.cjs";
3
3
  declare function xenoArtifactToDiffDocument(artifact: XenoArtifactEnvelope): XenoDiffDocument;
4
4
  declare class XenoBrowserDiffError extends Error {
5
5
  readonly code = "XENO_DIFF_INVALID";
@@ -1,5 +1,5 @@
1
- import { X as XenoArtifactEnvelope, a as XenoDiffDocument } from "./diff-artifact-C2tQZWcs.js";
2
- export { b as XENO_ARTIFACT_SCHEMA_VERSION, c as XENO_EVIDENCE_GRAPH_SCHEMA_VERSION, d as XenoArtifactActor, e as XenoArtifactActorKind, f as XenoArtifactAnchor, g as XenoArtifactContent, h as XenoArtifactIdentity, i as XenoArtifactKind, j as XenoArtifactLifecycleEvent, k as XenoArtifactListQuery, l as XenoArtifactProvenance, m as XenoArtifactRecord, n as XenoArtifactRelationship, o as XenoArtifactRetention, p as XenoArtifactReviewDecision, q as XenoArtifactReviewEvent, r as XenoArtifactReviewEventInput, s as XenoArtifactReviewSummary, t as XenoArtifactSensitivity, u as XenoArtifactState, v as XenoArtifactStorageReference, w as XenoContentHash, x as XenoDiffFile, y as XenoDiffFileStatus, z as XenoDiffHunk, A as XenoDiffLine, B as XenoDiffLineKind, C as XenoDiffMode, D as XenoEvidenceEdge, E as XenoEvidenceEdgeType, F as XenoEvidenceGraph, G as XenoEvidenceNode, H as XenoEvidenceNodeType, I as XenoEvidenceReference, J as XenoJsonObject, K as XenoJsonPrimitive, L as XenoJsonValue } from "./diff-artifact-C2tQZWcs.js";
1
+ import { X as XenoArtifactEnvelope, a as XenoDiffDocument } from "./diff-artifact-CmhmeSu5.js";
2
+ export { b as XENO_ARTIFACT_ACTOR_KINDS, c as XENO_ARTIFACT_SCHEMA_VERSION, d as XENO_ARTIFACT_SENSITIVITIES, e as XENO_ARTIFACT_STATES, f as XENO_BUILTIN_ARTIFACT_KINDS, g as XENO_EVIDENCE_EDGE_TYPES, h as XENO_EVIDENCE_GRAPH_SCHEMA_VERSION, i as XENO_EVIDENCE_NODE_TYPES, j as XenoArtifactActor, k as XenoArtifactActorKind, l as XenoArtifactAnchor, m as XenoArtifactContent, n as XenoArtifactIdentity, o as XenoArtifactKind, p as XenoArtifactLifecycleEvent, q as XenoArtifactListQuery, r as XenoArtifactProvenance, s as XenoArtifactRecord, t as XenoArtifactRelationship, u as XenoArtifactRetention, v as XenoArtifactReviewDecision, w as XenoArtifactReviewEvent, x as XenoArtifactReviewEventInput, y as XenoArtifactReviewSummary, z as XenoArtifactSensitivity, A as XenoArtifactState, B as XenoArtifactStorageReference, C as XenoContentHash, D as XenoDiffFile, E as XenoDiffFileStatus, F as XenoDiffHunk, G as XenoDiffLine, H as XenoDiffLineKind, I as XenoDiffMode, J as XenoEvidenceEdge, K as XenoEvidenceEdgeType, L as XenoEvidenceGraph, M as XenoEvidenceNode, N as XenoEvidenceNodeType, O as XenoEvidenceReference, P as XenoJsonObject, Q as XenoJsonPrimitive, R as XenoJsonValue } from "./diff-artifact-CmhmeSu5.js";
3
3
  declare function xenoArtifactToDiffDocument(artifact: XenoArtifactEnvelope): XenoDiffDocument;
4
4
  declare class XenoBrowserDiffError extends Error {
5
5
  readonly code = "XENO_DIFF_INVALID";
@@ -1 +1 @@
1
- var $=1,L=1;var v=new Set(["working-tree","staged","turn","commit","preview"]),k=new Set(["added","modified","deleted","renamed","copied","binary"]),D=new Set(["context","addition","deletion","no-newline"]),u=16*1024*1024,l=5e3,h=1e5,w=1e6;function O(e){if(!e||typeof e!="object")throw new TypeError("Artifact is required");if(e.kind!=="diff"&&e.kind!=="patch")throw new TypeError("Artifact is not a diff or patch");let t=e.content?.storage;if(!t||t.type!=="inline"||typeof t.text!="string")throw new TypeError("Diff artifact content is not available inline");if(b(t.text)>u)throw new m(`Diff artifact exceeds ${u} bytes`);let o;try{o=JSON.parse(t.text)}catch{throw new m("Diff artifact JSON is malformed")}if(!y(o))throw new m("Diff artifact document is invalid");let i=R(o);return structuredClone(i)}var m=class extends Error{code="XENO_DIFF_INVALID";constructor(t){super(t),this.name="XenoBrowserDiffError"}};function R(e){e.schemaVersion!==1&&n("schemaVersion must be 1"),(typeof e.mode!="string"||!v.has(e.mode))&&n("mode is invalid"),typeof e.rawDiff!="string"&&n("rawDiff is required"),b(e.rawDiff)>u&&n(`rawDiff exceeds ${u} bytes`),(!Array.isArray(e.files)||e.files.length>l)&&n(`files must contain at most ${l} entries`);let t=e.files.map((a,f)=>x(a,f)),o=t.reduce((a,f)=>a+f.hunks.length,0),i=t.reduce((a,f)=>a+f.hunks.reduce((I,E)=>I+E.lines.length,0),0);o>h&&n(`diff exceeds ${h} hunks`),i>w&&n(`diff exceeds ${w} lines`);let c=g(e.additions,"additions"),p=g(e.deletions,"deletions"),s=t.reduce((a,f)=>a+f.additions,0),r=t.reduce((a,f)=>a+f.deletions,0);return(c!==s||p!==r)&&n("diff totals do not match file totals"),{schemaVersion:1,mode:e.mode,...d(e.repositoryId)?{repositoryId:d(e.repositoryId)}:{},...d(e.baseRef)?{baseRef:d(e.baseRef)}:{},...d(e.headRef)?{headRef:d(e.headRef)}:{},files:t,additions:c,deletions:p,rawDiff:e.rawDiff}}function x(e,t){y(e)||n(`files[${t}] is invalid`);let o=X(e.displayPath,`files[${t}].displayPath`,8192);(typeof e.status!="string"||!k.has(e.status))&&n(`files[${t}].status is invalid`),typeof e.binary!="boolean"&&n(`files[${t}].binary must be boolean`),(!Array.isArray(e.headerLines)||e.headerLines.some(s=>typeof s!="string"))&&n(`files[${t}].headerLines is invalid`),Array.isArray(e.hunks)||n(`files[${t}].hunks is invalid`);let i=e.hunks.map((s,r)=>S(s,t,r)),c=g(e.additions,`files[${t}].additions`),p=g(e.deletions,`files[${t}].deletions`);return(c!==i.reduce((s,r)=>s+r.additions,0)||p!==i.reduce((s,r)=>s+r.deletions,0))&&n(`files[${t}] totals do not match hunks`),{...d(e.oldPath)?{oldPath:d(e.oldPath)}:{},...d(e.newPath)?{newPath:d(e.newPath)}:{},displayPath:o,status:e.status,additions:c,deletions:p,binary:e.binary,headerLines:[...e.headerLines],hunks:i}}function S(e,t,o){y(e)||n(`files[${t}].hunks[${o}] is invalid`);let i=`files[${t}].hunks[${o}]`;Array.isArray(e.lines)||n(`${i}.lines is invalid`);let c=e.lines.map((r,a)=>_(r,`${i}.lines[${a}]`)),p=g(e.additions,`${i}.additions`),s=g(e.deletions,`${i}.deletions`);return(p!==c.filter(r=>r.kind==="addition").length||s!==c.filter(r=>r.kind==="deletion").length)&&n(`${i} totals do not match lines`),{hunkId:X(e.hunkId,`${i}.hunkId`,512),header:X(e.header,`${i}.header`,8192),...d(e.section)?{section:d(e.section)}:{},oldStart:A(e.oldStart,`${i}.oldStart`),oldLines:g(e.oldLines,`${i}.oldLines`),newStart:A(e.newStart,`${i}.newStart`),newLines:g(e.newLines,`${i}.newLines`),additions:p,deletions:s,lines:c}}function _(e,t){return y(e)||n(`${t} is invalid`),(typeof e.kind!="string"||!D.has(e.kind))&&n(`${t}.kind is invalid`),typeof e.text!="string"&&n(`${t}.text is required`),{kind:e.kind,text:e.text,...e.oldLine!==void 0?{oldLine:A(e.oldLine,`${t}.oldLine`)}:{},...e.newLine!==void 0?{newLine:A(e.newLine,`${t}.newLine`)}:{}}}function y(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function X(e,t,o){return(typeof e!="string"||e.length===0||e.length>o||e.includes("\0"))&&n(`${t} is invalid`),e}function d(e){return typeof e=="string"&&e.length>0&&e.length<=8192&&!e.includes("\0")?e:void 0}function g(e,t){return(!Number.isSafeInteger(e)||e<0)&&n(`${t} must be a non-negative integer`),e}function A(e,t){return(!Number.isSafeInteger(e)||e<1)&&n(`${t} must be a positive integer`),e}function b(e){return new TextEncoder().encode(e).byteLength}function n(e){throw new m(e)}export{$ as XENO_ARTIFACT_SCHEMA_VERSION,L as XENO_EVIDENCE_GRAPH_SCHEMA_VERSION,m as XenoBrowserDiffError,O as xenoArtifactToDiffDocument};
1
+ var N=1,T=1,O=["plan","requirements","design","task-graph","patch","diff","file","document","diagram","screenshot","recording","browser-snapshot","test-report","review-report","security-report","performance-report","release-report","sbom","provenance","attestation"],$=["draft","pending_review","approved","rejected","superseded","archived"],L=["public","internal","confidential","restricted"],C=["agent","tool","user","system","integration"],V=["requirement","design-decision","risk","task","agent","run","tool-call","edit","commit","test-case","test-run","finding","approval","artifact","release","claim"],F=["decomposes","depends_on","implements","changes","tests","verifies","finds","fixes","reviews","approves","rejects","supersedes","derived_from","produced_by","supports_claim","contradicts_claim","released_as"];var _=new Set(["working-tree","staged","turn","commit","preview"]),S=new Set(["added","modified","deleted","renamed","copied","binary"]),v=new Set(["context","addition","deletion","no-newline"]),A=16*1024*1024,E=5e3,l=1e5,I=1e6;function q(e){if(!e||typeof e!="object")throw new TypeError("Artifact is required");if(e.kind!=="diff"&&e.kind!=="patch")throw new TypeError("Artifact is not a diff or patch");let t=e.content?.storage;if(!t||t.type!=="inline"||typeof t.text!="string")throw new TypeError("Diff artifact content is not available inline");if(h(t.text)>A)throw new m(`Diff artifact exceeds ${A} bytes`);let o;try{o=JSON.parse(t.text)}catch{throw new m("Diff artifact JSON is malformed")}if(!X(o))throw new m("Diff artifact document is invalid");let i=D(o);return structuredClone(i)}var m=class extends Error{code="XENO_DIFF_INVALID";constructor(t){super(t),this.name="XenoBrowserDiffError"}};function D(e){e.schemaVersion!==1&&n("schemaVersion must be 1"),(typeof e.mode!="string"||!_.has(e.mode))&&n("mode is invalid"),typeof e.rawDiff!="string"&&n("rawDiff is required"),h(e.rawDiff)>A&&n(`rawDiff exceeds ${A} bytes`),(!Array.isArray(e.files)||e.files.length>E)&&n(`files must contain at most ${E} entries`);let t=e.files.map((d,f)=>R(d,f)),o=t.reduce((d,f)=>d+f.hunks.length,0),i=t.reduce((d,f)=>d+f.hunks.reduce((b,w)=>b+w.lines.length,0),0);o>l&&n(`diff exceeds ${l} hunks`),i>I&&n(`diff exceeds ${I} lines`);let a=g(e.additions,"additions"),p=g(e.deletions,"deletions"),s=t.reduce((d,f)=>d+f.additions,0),r=t.reduce((d,f)=>d+f.deletions,0);return(a!==s||p!==r)&&n("diff totals do not match file totals"),{schemaVersion:1,mode:e.mode,...c(e.repositoryId)?{repositoryId:c(e.repositoryId)}:{},...c(e.baseRef)?{baseRef:c(e.baseRef)}:{},...c(e.headRef)?{headRef:c(e.headRef)}:{},files:t,additions:a,deletions:p,rawDiff:e.rawDiff}}function R(e,t){X(e)||n(`files[${t}] is invalid`);let o=y(e.displayPath,`files[${t}].displayPath`,8192);(typeof e.status!="string"||!S.has(e.status))&&n(`files[${t}].status is invalid`),typeof e.binary!="boolean"&&n(`files[${t}].binary must be boolean`),(!Array.isArray(e.headerLines)||e.headerLines.some(s=>typeof s!="string"))&&n(`files[${t}].headerLines is invalid`),Array.isArray(e.hunks)||n(`files[${t}].hunks is invalid`);let i=e.hunks.map((s,r)=>k(s,t,r)),a=g(e.additions,`files[${t}].additions`),p=g(e.deletions,`files[${t}].deletions`);return(a!==i.reduce((s,r)=>s+r.additions,0)||p!==i.reduce((s,r)=>s+r.deletions,0))&&n(`files[${t}] totals do not match hunks`),{...c(e.oldPath)?{oldPath:c(e.oldPath)}:{},...c(e.newPath)?{newPath:c(e.newPath)}:{},displayPath:o,status:e.status,additions:a,deletions:p,binary:e.binary,headerLines:[...e.headerLines],hunks:i}}function k(e,t,o){X(e)||n(`files[${t}].hunks[${o}] is invalid`);let i=`files[${t}].hunks[${o}]`;Array.isArray(e.lines)||n(`${i}.lines is invalid`);let a=e.lines.map((r,d)=>x(r,`${i}.lines[${d}]`)),p=g(e.additions,`${i}.additions`),s=g(e.deletions,`${i}.deletions`);return(p!==a.filter(r=>r.kind==="addition").length||s!==a.filter(r=>r.kind==="deletion").length)&&n(`${i} totals do not match lines`),{hunkId:y(e.hunkId,`${i}.hunkId`,512),header:y(e.header,`${i}.header`,8192),...c(e.section)?{section:c(e.section)}:{},oldStart:u(e.oldStart,`${i}.oldStart`),oldLines:g(e.oldLines,`${i}.oldLines`),newStart:u(e.newStart,`${i}.newStart`),newLines:g(e.newLines,`${i}.newLines`),additions:p,deletions:s,lines:a}}function x(e,t){return X(e)||n(`${t} is invalid`),(typeof e.kind!="string"||!v.has(e.kind))&&n(`${t}.kind is invalid`),typeof e.text!="string"&&n(`${t}.text is required`),{kind:e.kind,text:e.text,...e.oldLine!==void 0?{oldLine:u(e.oldLine,`${t}.oldLine`)}:{},...e.newLine!==void 0?{newLine:u(e.newLine,`${t}.newLine`)}:{}}}function X(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function y(e,t,o){return(typeof e!="string"||e.length===0||e.length>o||e.includes("\0"))&&n(`${t} is invalid`),e}function c(e){return typeof e=="string"&&e.length>0&&e.length<=8192&&!e.includes("\0")?e:void 0}function g(e,t){return(!Number.isSafeInteger(e)||e<0)&&n(`${t} must be a non-negative integer`),e}function u(e,t){return(!Number.isSafeInteger(e)||e<1)&&n(`${t} must be a positive integer`),e}function h(e){return new TextEncoder().encode(e).byteLength}function n(e){throw new m(e)}export{C as XENO_ARTIFACT_ACTOR_KINDS,N as XENO_ARTIFACT_SCHEMA_VERSION,L as XENO_ARTIFACT_SENSITIVITIES,$ as XENO_ARTIFACT_STATES,O as XENO_BUILTIN_ARTIFACT_KINDS,F as XENO_EVIDENCE_EDGE_TYPES,T as XENO_EVIDENCE_GRAPH_SCHEMA_VERSION,V as XENO_EVIDENCE_NODE_TYPES,m as XenoBrowserDiffError,q as xenoArtifactToDiffDocument};