jaz-clio 9.9.0 → 9.9.1

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.
@@ -13,7 +13,7 @@ description: >-
13
13
  license: MIT
14
14
  compatibility: Uses Jaz OAuth by default; organization API keys remain supported. Works with Claude Code, Google Antigravity, OpenAI Codex, GitHub Copilot, Cursor, and any agent that reads markdown.
15
15
  metadata:
16
- version: "9.9.0"
16
+ version: "9.9.1"
17
17
  ---
18
18
 
19
19
  # Jaz API Skill
@@ -11,7 +11,7 @@ description: >-
11
11
  license: MIT
12
12
  compatibility: Requires Node.js >= 18.0.0. Install via npm install -g jaz-clio.
13
13
  metadata:
14
- version: "9.9.0"
14
+ version: "9.9.1"
15
15
  ---
16
16
 
17
17
  # Clio CLI Skill
@@ -9,7 +9,7 @@ description: >-
9
9
  import, or switching accounting software, whenever a customer's prior system
10
10
  is Xero, QuickBooks, Sage, MYOB, or an Excel-based ledger.
11
11
  metadata:
12
- version: "9.9.0"
12
+ version: "9.9.1"
13
13
  ---
14
14
 
15
15
  # Jaz Conversion Skill
@@ -15,7 +15,7 @@ description: >-
15
15
  license: MIT
16
16
  compatibility: Uses Jaz OAuth by default; organization API keys remain supported. Works with Claude Code, Google Antigravity, OpenAI Codex, GitHub Copilot, Cursor, and any agent that reads markdown. Load the jaz-api skill alongside this one.
17
17
  metadata:
18
- version: "9.9.0"
18
+ version: "9.9.1"
19
19
  ---
20
20
 
21
21
  # Jaz API Reference Skill
@@ -10,7 +10,7 @@ description: >-
10
10
  license: MIT
11
11
  compatibility: Works with Claude Code, Codex CLI, Cursor, Copilot, Claude Cowork, Claude.ai, and any agent that reads markdown. Multi-organization workflows need the `clio` CLI (`npm i -g jaz-clio`); a single organization works through MCP tools alone. Load alongside jaz-jobs for close playbooks, jaz-recipes for IFRS patterns, jaz-api for payload shapes, jaz-conversion for migrations.
12
12
  metadata:
13
- version: "9.9.0"
13
+ version: "9.9.1"
14
14
  ---
15
15
 
16
16
  # Jaz Kit
@@ -13,7 +13,7 @@ description: >-
13
13
  license: MIT
14
14
  compatibility: Works with Claude Code, Claude Cowork, Claude.ai, and any agent that reads markdown. For canonical report types and the standard analytics surface, load the jaz-api skill alongside this one.
15
15
  metadata:
16
- version: "9.9.0"
16
+ version: "9.9.1"
17
17
  ---
18
18
 
19
19
  # Jaz Pseudo-SQL Skill
@@ -10,7 +10,7 @@ description: >-
10
10
  license: MIT
11
11
  compatibility: Works with Claude Code, Claude Cowork, Claude.ai, and any agent that reads markdown. For API payloads, load the jaz-api skill. For individual transaction patterns, load the jaz-recipes skill.
12
12
  metadata:
13
- version: "9.9.0"
13
+ version: "9.9.1"
14
14
  ---
15
15
 
16
16
  # Jobs Skill
@@ -13,7 +13,7 @@ description: >-
13
13
  license: MIT
14
14
  compatibility: Works with Claude Code, Claude Cowork, Claude.ai, and any agent that reads markdown. For API payloads, load the jaz-api skill alongside this one. For the operational close workflows these recipes plug into (month-end close, GST/VAT filing, year-end close), load the jaz-jobs skill.
15
15
  metadata:
16
- version: "9.9.0"
16
+ version: "9.9.1"
17
17
  ---
18
18
 
19
19
  # Transaction Recipes Skill
package/cli.mjs CHANGED
@@ -999,9 +999,9 @@ clio() {
999
999
  path: iss.path ? [${fI(I)}, ...iss.path] : [${fI(I)}]
1000
1000
  })));`),p.write(`newResult[${fI(I)}] = ${E}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");let y=p.compile();return(I,E)=>y(f,I,E)},i,o=s0,s=!t6.jitless,c=s&&cIe.value,u=t.catchall,d;e._zod.parse=(f,p)=>{d??(d=r.value);let h=f.value;if(!o(h))return f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f;let m=[];if(s&&c&&p?.async===!1&&p.jitless!==!0)i||(i=n(t.shape)),f=i(f,p);else{f.value={};let E=d.shape;for(let C of d.keys){let w=E[C],T=w._zod.run({value:h[C],issues:[]},p),D=w._zod.optin==="optional"&&w._zod.optout==="optional";T instanceof Promise?m.push(T.then(N=>D?Jht(N,f,C,h):c6(N,f,C))):D?Jht(T,f,C,h):c6(T,f,C)}}if(!u)return m.length?Promise.all(m).then(()=>f):f;let A=[],g=d.keySet,y=u._zod,I=y.def.type;for(let E of Object.keys(h)){if(g.has(E))continue;if(I==="never"){A.push(E);continue}let C=y.run({value:h[E],issues:[]},p);C instanceof Promise?m.push(C.then(w=>c6(w,f,E))):c6(C,f,E)}return A.length&&f.issues.push({code:"unrecognized_keys",keys:A,input:h,inst:e}),m.length?Promise.all(m).then(()=>f):f}});function Ght(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>wu(o,n,pl())))}),t}var CIe=_e("$ZodUnion",(e,t)=>{Fn.init(e,t),Bn(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Bn(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Bn(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Bn(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>jF(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let i=!1,o=[];for(let s of t.options){let a=s._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),i=!0;else{if(a.issues.length===0)return a;o.push(a)}}return i?Promise.all(o).then(s=>Ght(s,r,e,n)):Ght(o,r,e,n)}}),Nmt=_e("$ZodDiscriminatedUnion",(e,t)=>{CIe.init(e,t);let r=e._zod.parse;Bn(e._zod,"propValues",()=>{let i={};for(let o of t.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,c]of Object.entries(s)){i[a]||(i[a]=new Set);for(let u of c)i[a].add(u)}}return i});let n=$F(()=>{let i=t.options,o=new Map;for(let s of i){let a=s._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,s)}}return o});e._zod.parse=(i,o)=>{let s=i.value;if(!s0(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;let a=n.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:s,path:[t.discriminator],inst:e}),i)}}),Omt=_e("$ZodIntersection",(e,t)=>{Fn.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),s=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([c,u])=>Vht(r,c,u)):Vht(r,o,s)}});function bIe(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(a0(e)&&a0(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let s=bIe(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],s=bIe(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Vht(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),pI(e))return e;let n=bIe(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var Bmt=_e("$ZodRecord",(e,t)=>{Fn.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!a0(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[];if(t.keyType._zod.values){let s=t.keyType._zod.values;r.value={};for(let c of s)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=t.valueType._zod.run({value:i[c],issues:[]},n);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&r.issues.push(...Md(c,d.issues)),r.value[c]=d.value})):(u.issues.length&&r.issues.push(...Md(c,u.issues)),r.value[c]=u.value)}let a;for(let c in i)s.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let a=t.keyType._zod.run({value:s,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>wu(u,n,pl())),input:s,path:[s],inst:e}),r.value[a.value]=a.value;continue}let c=t.valueType._zod.run({value:i[s],issues:[]},n);c instanceof Promise?o.push(c.then(u=>{u.issues.length&&r.issues.push(...Md(s,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...Md(s,c.issues)),r.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}});var Fmt=_e("$ZodEnum",(e,t)=>{Fn.init(e,t);let r=iIe(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>lIe.has(typeof n)).map(n=>typeof n=="string"?TA(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),Lmt=_e("$ZodLiteral",(e,t)=>{Fn.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?TA(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;return e._zod.values.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var Pmt=_e("$ZodTransform",(e,t)=>{Fn.init(e,t),e._zod.parse=(r,n)=>{let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r));if(i instanceof Promise)throw new wp;return r.value=i,r}}),Mmt=_e("$ZodOptional",(e,t)=>{Fn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Bn(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Bn(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${jF(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),Qmt=_e("$ZodNullable",(e,t)=>{Fn.init(e,t),Bn(e._zod,"optin",()=>t.innerType._zod.optin),Bn(e._zod,"optout",()=>t.innerType._zod.optout),Bn(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${jF(r.source)}|null)$`):void 0}),Bn(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Umt=_e("$ZodDefault",(e,t)=>{Fn.init(e,t),e._zod.optin="optional",Bn(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Wht(o,t)):Wht(i,t)}});function Wht(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var $mt=_e("$ZodPrefault",(e,t)=>{Fn.init(e,t),e._zod.optin="optional",Bn(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),qmt=_e("$ZodNonOptional",(e,t)=>{Fn.init(e,t),Bn(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Kht(o,e)):Kht(i,e)}});function Kht(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var jmt=_e("$ZodCatch",(e,t)=>{Fn.init(e,t),e._zod.optin="optional",Bn(e._zod,"optout",()=>t.innerType._zod.optout),Bn(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>wu(s,n,pl()))},input:r.value}),r.issues=[]),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>wu(o,n,pl()))},input:r.value}),r.issues=[]),r)}});var Ymt=_e("$ZodPipe",(e,t)=>{Fn.init(e,t),Bn(e._zod,"values",()=>t.in._zod.values),Bn(e._zod,"optin",()=>t.in._zod.optin),Bn(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Xht(o,t,n)):Xht(i,t,n)}});function Xht(e,t,r){return pI(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Hmt=_e("$ZodReadonly",(e,t)=>{Fn.init(e,t),Bn(e._zod,"propValues",()=>t.innerType._zod.propValues),Bn(e._zod,"values",()=>t.innerType._zod.values),Bn(e._zod,"optin",()=>t.innerType._zod.optin),Bn(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(Zht):Zht(i)}});function Zht(e){return e.value=Object.freeze(e.value),e}var zmt=_e("$ZodCustom",(e,t)=>{Qs.init(e,t),Fn.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>emt(o,r,n,e));emt(i,r,n,e)}});function emt(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(fIe(i))}}var xNr=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},kNr=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${xNr(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${i6(n.values[0])}`:`Invalid option: expected one of ${r6(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",o=t(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",o=t(n.origin);return o?`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${r6(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Jmt(){return{localeError:kNr()}}var wIe=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function NNr(){return new wIe}var JF=NNr();function Gmt(e,t){return new e({type:"string",...xt(t)})}function Vmt(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...xt(t)})}function vIe(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...xt(t)})}function Wmt(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...xt(t)})}function Kmt(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...xt(t)})}function Xmt(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...xt(t)})}function Zmt(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...xt(t)})}function eAt(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...xt(t)})}function tAt(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...xt(t)})}function rAt(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...xt(t)})}function nAt(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...xt(t)})}function iAt(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...xt(t)})}function oAt(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...xt(t)})}function sAt(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...xt(t)})}function aAt(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...xt(t)})}function cAt(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...xt(t)})}function lAt(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...xt(t)})}function uAt(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...xt(t)})}function dAt(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...xt(t)})}function fAt(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...xt(t)})}function pAt(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...xt(t)})}function hAt(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...xt(t)})}function mAt(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...xt(t)})}function AAt(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...xt(t)})}function gAt(e,t){return new e({type:"string",format:"date",check:"string_format",...xt(t)})}function yAt(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...xt(t)})}function EAt(e,t){return new e({type:"string",format:"duration",check:"string_format",...xt(t)})}function IAt(e,t){return new e({type:"number",checks:[],...xt(t)})}function bAt(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...xt(t)})}function _At(e,t){return new e({type:"boolean",...xt(t)})}function CAt(e,t){return new e({type:"null",...xt(t)})}function wAt(e){return new e({type:"unknown"})}function vAt(e,t){return new e({type:"never",...xt(t)})}function u6(e,t){return new EIe({check:"less_than",...xt(t),value:e,inclusive:!1})}function GF(e,t){return new EIe({check:"less_than",...xt(t),value:e,inclusive:!0})}function d6(e,t){return new IIe({check:"greater_than",...xt(t),value:e,inclusive:!1})}function VF(e,t){return new IIe({check:"greater_than",...xt(t),value:e,inclusive:!0})}function f6(e,t){return new Nht({check:"multiple_of",...xt(t),value:e})}function p6(e,t){return new Bht({check:"max_length",...xt(t),maximum:e})}function c0(e,t){return new Fht({check:"min_length",...xt(t),minimum:e})}function h6(e,t){return new Lht({check:"length_equals",...xt(t),length:e})}function SIe(e,t){return new Pht({check:"string_format",format:"regex",...xt(t),pattern:e})}function DIe(e){return new Mht({check:"string_format",format:"lowercase",...xt(e)})}function RIe(e){return new Qht({check:"string_format",format:"uppercase",...xt(e)})}function TIe(e,t){return new Uht({check:"string_format",format:"includes",...xt(t),includes:e})}function xIe(e,t){return new $ht({check:"string_format",format:"starts_with",...xt(t),prefix:e})}function kIe(e,t){return new qht({check:"string_format",format:"ends_with",...xt(t),suffix:e})}function hI(e){return new jht({check:"overwrite",tx:e})}function NIe(e){return hI(t=>t.normalize(e))}function OIe(){return hI(e=>e.trim())}function BIe(){return hI(e=>e.toLowerCase())}function FIe(){return hI(e=>e.toUpperCase())}function SAt(e,t,r){return new e({type:"array",element:t,...xt(r)})}function DAt(e,t,r){let n=xt(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function RAt(e,t,r){return new e({type:"custom",check:"custom",fn:t,...xt(r)})}function l0(e){return!!e._zod}function xA(e,t){return l0(e)?HF(e,t):e.safeParse(t)}function m6(e){if(!e)return;let t;if(l0(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function TAt(e){if(l0(e)){let o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var KF={};qo(KF,{ZodISODate:()=>kAt,ZodISODateTime:()=>xAt,ZodISODuration:()=>OAt,ZodISOTime:()=>NAt,date:()=>PIe,datetime:()=>LIe,duration:()=>QIe,time:()=>MIe});var xAt=_e("ZodISODateTime",(e,t)=>{fmt.init(e,t),oi.init(e,t)});function LIe(e){return AAt(xAt,e)}var kAt=_e("ZodISODate",(e,t)=>{pmt.init(e,t),oi.init(e,t)});function PIe(e){return gAt(kAt,e)}var NAt=_e("ZodISOTime",(e,t)=>{hmt.init(e,t),oi.init(e,t)});function MIe(e){return yAt(NAt,e)}var OAt=_e("ZodISODuration",(e,t)=>{mmt.init(e,t),oi.init(e,t)});function QIe(e){return EAt(OAt,e)}var BAt=(e,t)=>{o6.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Zpt(e,r)},flatten:{value:r=>Xpt(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Ngn=_e("ZodError",BAt),XF=_e("ZodError",BAt,{Parent:Error});var FAt=eht(XF),LAt=tht(XF),PAt=hIe(XF),MAt=mIe(XF);var bi=_e("ZodType",(e,t)=>(Fn.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>Pd(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>FAt(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>PAt(e,r,n),e.parseAsync=async(r,n)=>LAt(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>MAt(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(TOr(r,n)),e.superRefine=r=>e.check(xOr(r)),e.overwrite=r=>e.check(hI(r)),e.optional=()=>Ii(e),e.nullable=()=>$At(e),e.nullish=()=>Ii($At(e)),e.nonoptional=r=>_Or(e,r),e.array=()=>wr(e),e.or=r=>Ln([e,r]),e.and=r=>g6(e,r),e.transform=r=>$Ie(e,zAt(r)),e.default=r=>EOr(e,r),e.prefault=r=>bOr(e,r),e.catch=r=>wOr(e,r),e.pipe=r=>$Ie(e,r),e.readonly=()=>DOr(e),e.describe=r=>{let n=e.clone();return JF.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return JF.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return JF.get(e);let n=e.clone();return JF.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),qAt=_e("_ZodString",(e,t)=>{l6.init(e,t),bi.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(SIe(...n)),e.includes=(...n)=>e.check(TIe(...n)),e.startsWith=(...n)=>e.check(xIe(...n)),e.endsWith=(...n)=>e.check(kIe(...n)),e.min=(...n)=>e.check(c0(...n)),e.max=(...n)=>e.check(p6(...n)),e.length=(...n)=>e.check(h6(...n)),e.nonempty=(...n)=>e.check(c0(1,...n)),e.lowercase=n=>e.check(DIe(n)),e.uppercase=n=>e.check(RIe(n)),e.trim=()=>e.check(OIe()),e.normalize=(...n)=>e.check(NIe(...n)),e.toLowerCase=()=>e.check(BIe()),e.toUpperCase=()=>e.check(FIe())}),$Nr=_e("ZodString",(e,t)=>{l6.init(e,t),qAt.init(e,t),e.email=r=>e.check(Vmt(qNr,r)),e.url=r=>e.check(eAt(jNr,r)),e.jwt=r=>e.check(mAt(iOr,r)),e.emoji=r=>e.check(tAt(YNr,r)),e.guid=r=>e.check(vIe(QAt,r)),e.uuid=r=>e.check(Wmt(A6,r)),e.uuidv4=r=>e.check(Kmt(A6,r)),e.uuidv6=r=>e.check(Xmt(A6,r)),e.uuidv7=r=>e.check(Zmt(A6,r)),e.nanoid=r=>e.check(rAt(HNr,r)),e.guid=r=>e.check(vIe(QAt,r)),e.cuid=r=>e.check(nAt(zNr,r)),e.cuid2=r=>e.check(iAt(JNr,r)),e.ulid=r=>e.check(oAt(GNr,r)),e.base64=r=>e.check(fAt(tOr,r)),e.base64url=r=>e.check(pAt(rOr,r)),e.xid=r=>e.check(sAt(VNr,r)),e.ksuid=r=>e.check(aAt(WNr,r)),e.ipv4=r=>e.check(cAt(KNr,r)),e.ipv6=r=>e.check(lAt(XNr,r)),e.cidrv4=r=>e.check(uAt(ZNr,r)),e.cidrv6=r=>e.check(dAt(eOr,r)),e.e164=r=>e.check(hAt(nOr,r)),e.datetime=r=>e.check(LIe(r)),e.date=r=>e.check(PIe(r)),e.time=r=>e.check(MIe(r)),e.duration=r=>e.check(QIe(r))});function Ie(e){return Gmt($Nr,e)}var oi=_e("ZodStringFormat",(e,t)=>{qn.init(e,t),qAt.init(e,t)}),qNr=_e("ZodEmail",(e,t)=>{nmt.init(e,t),oi.init(e,t)});var QAt=_e("ZodGUID",(e,t)=>{tmt.init(e,t),oi.init(e,t)});var A6=_e("ZodUUID",(e,t)=>{rmt.init(e,t),oi.init(e,t)});var jNr=_e("ZodURL",(e,t)=>{imt.init(e,t),oi.init(e,t)});var YNr=_e("ZodEmoji",(e,t)=>{omt.init(e,t),oi.init(e,t)});var HNr=_e("ZodNanoID",(e,t)=>{smt.init(e,t),oi.init(e,t)});var zNr=_e("ZodCUID",(e,t)=>{amt.init(e,t),oi.init(e,t)});var JNr=_e("ZodCUID2",(e,t)=>{cmt.init(e,t),oi.init(e,t)});var GNr=_e("ZodULID",(e,t)=>{lmt.init(e,t),oi.init(e,t)});var VNr=_e("ZodXID",(e,t)=>{umt.init(e,t),oi.init(e,t)});var WNr=_e("ZodKSUID",(e,t)=>{dmt.init(e,t),oi.init(e,t)});var KNr=_e("ZodIPv4",(e,t)=>{Amt.init(e,t),oi.init(e,t)});var XNr=_e("ZodIPv6",(e,t)=>{gmt.init(e,t),oi.init(e,t)});var ZNr=_e("ZodCIDRv4",(e,t)=>{ymt.init(e,t),oi.init(e,t)});var eOr=_e("ZodCIDRv6",(e,t)=>{Emt.init(e,t),oi.init(e,t)});var tOr=_e("ZodBase64",(e,t)=>{bmt.init(e,t),oi.init(e,t)});var rOr=_e("ZodBase64URL",(e,t)=>{_mt.init(e,t),oi.init(e,t)});var nOr=_e("ZodE164",(e,t)=>{Cmt.init(e,t),oi.init(e,t)});var iOr=_e("ZodJWT",(e,t)=>{wmt.init(e,t),oi.init(e,t)});var jAt=_e("ZodNumber",(e,t)=>{_Ie.init(e,t),bi.init(e,t),e.gt=(n,i)=>e.check(d6(n,i)),e.gte=(n,i)=>e.check(VF(n,i)),e.min=(n,i)=>e.check(VF(n,i)),e.lt=(n,i)=>e.check(u6(n,i)),e.lte=(n,i)=>e.check(GF(n,i)),e.max=(n,i)=>e.check(GF(n,i)),e.int=n=>e.check(UAt(n)),e.safe=n=>e.check(UAt(n)),e.positive=n=>e.check(d6(0,n)),e.nonnegative=n=>e.check(VF(0,n)),e.negative=n=>e.check(u6(0,n)),e.nonpositive=n=>e.check(GF(0,n)),e.multipleOf=(n,i)=>e.check(f6(n,i)),e.step=(n,i)=>e.check(f6(n,i)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function fn(e){return IAt(jAt,e)}var oOr=_e("ZodNumberFormat",(e,t)=>{vmt.init(e,t),jAt.init(e,t)});function UAt(e){return bAt(oOr,e)}var sOr=_e("ZodBoolean",(e,t)=>{Smt.init(e,t),bi.init(e,t)});function $o(e){return _At(sOr,e)}var aOr=_e("ZodNull",(e,t)=>{Dmt.init(e,t),bi.init(e,t)});function qIe(e){return CAt(aOr,e)}var cOr=_e("ZodUnknown",(e,t)=>{Rmt.init(e,t),bi.init(e,t)});function si(){return wAt(cOr)}var lOr=_e("ZodNever",(e,t)=>{Tmt.init(e,t),bi.init(e,t)});function uOr(e){return vAt(lOr,e)}var dOr=_e("ZodArray",(e,t)=>{xmt.init(e,t),bi.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(c0(r,n)),e.nonempty=r=>e.check(c0(1,r)),e.max=(r,n)=>e.check(p6(r,n)),e.length=(r,n)=>e.check(h6(r,n)),e.unwrap=()=>e.element});function wr(e,t){return SAt(dOr,e,t)}var YAt=_e("ZodObject",(e,t)=>{kmt.init(e,t),bi.init(e,t),Vr.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Ma(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:si()}),e.loose=()=>e.clone({...e._zod.def,catchall:si()}),e.strict=()=>e.clone({...e._zod.def,catchall:uOr()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Vr.extend(e,r),e.merge=r=>Vr.merge(e,r),e.pick=r=>Vr.pick(e,r),e.omit=r=>Vr.omit(e,r),e.partial=(...r)=>Vr.partial(JAt,e,r[0]),e.required=(...r)=>Vr.required(GAt,e,r[0])});function We(e,t){let r={type:"object",get shape(){return Vr.assignProp(this,"shape",{...e}),this.shape},...Vr.normalizeParams(t)};return new YAt(r)}function ha(e,t){return new YAt({type:"object",get shape(){return Vr.assignProp(this,"shape",{...e}),this.shape},catchall:si(),...Vr.normalizeParams(t)})}var HAt=_e("ZodUnion",(e,t)=>{CIe.init(e,t),bi.init(e,t),e.options=t.options});function Ln(e,t){return new HAt({type:"union",options:e,...Vr.normalizeParams(t)})}var fOr=_e("ZodDiscriminatedUnion",(e,t)=>{HAt.init(e,t),Nmt.init(e,t)});function jIe(e,t,r){return new fOr({type:"union",options:t,discriminator:e,...Vr.normalizeParams(r)})}var pOr=_e("ZodIntersection",(e,t)=>{Omt.init(e,t),bi.init(e,t)});function g6(e,t){return new pOr({type:"intersection",left:e,right:t})}var hOr=_e("ZodRecord",(e,t)=>{Bmt.init(e,t),bi.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ai(e,t,r){return new hOr({type:"record",keyType:e,valueType:t,...Vr.normalizeParams(r)})}var UIe=_e("ZodEnum",(e,t)=>{Fmt.init(e,t),bi.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let s of n)if(r.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new UIe({...t,checks:[],...Vr.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new UIe({...t,checks:[],...Vr.normalizeParams(i),entries:o})}});function Ma(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new UIe({type:"enum",entries:r,...Vr.normalizeParams(t)})}var mOr=_e("ZodLiteral",(e,t)=>{Lmt.init(e,t),bi.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ht(e,t){return new mOr({type:"literal",values:Array.isArray(e)?e:[e],...Vr.normalizeParams(t)})}var AOr=_e("ZodTransform",(e,t)=>{Pmt.init(e,t),bi.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(Vr.issue(o,r.value,t));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!0),r.issues.push(Vr.issue(s))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function zAt(e){return new AOr({type:"transform",transform:e})}var JAt=_e("ZodOptional",(e,t)=>{Mmt.init(e,t),bi.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ii(e){return new JAt({type:"optional",innerType:e})}var gOr=_e("ZodNullable",(e,t)=>{Qmt.init(e,t),bi.init(e,t),e.unwrap=()=>e._zod.def.innerType});function $At(e){return new gOr({type:"nullable",innerType:e})}var yOr=_e("ZodDefault",(e,t)=>{Umt.init(e,t),bi.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function EOr(e,t){return new yOr({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var IOr=_e("ZodPrefault",(e,t)=>{$mt.init(e,t),bi.init(e,t),e.unwrap=()=>e._zod.def.innerType});function bOr(e,t){return new IOr({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var GAt=_e("ZodNonOptional",(e,t)=>{qmt.init(e,t),bi.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _Or(e,t){return new GAt({type:"nonoptional",innerType:e,...Vr.normalizeParams(t)})}var COr=_e("ZodCatch",(e,t)=>{jmt.init(e,t),bi.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wOr(e,t){return new COr({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var vOr=_e("ZodPipe",(e,t)=>{Ymt.init(e,t),bi.init(e,t),e.in=t.in,e.out=t.out});function $Ie(e,t){return new vOr({type:"pipe",in:e,out:t})}var SOr=_e("ZodReadonly",(e,t)=>{Hmt.init(e,t),bi.init(e,t)});function DOr(e){return new SOr({type:"readonly",innerType:e})}var VAt=_e("ZodCustom",(e,t)=>{zmt.init(e,t),bi.init(e,t)});function ROr(e){let t=new Qs({check:"custom"});return t._zod.check=e,t}function WAt(e,t){return DAt(VAt,e??(()=>!0),t)}function TOr(e,t={}){return RAt(VAt,e,t)}function xOr(e){let t=ROr(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Vr.issue(n,r.value,t._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(Vr.issue(i))}},e(r.value,r)));return t}function YIe(e,t){return $Ie(zAt(e),t)}pl(Jmt());var zIe="2025-11-25";var KAt=[zIe,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],kA="io.modelcontextprotocol/related-task",E6="2.0",is=WAt(e=>e!==null&&(typeof e=="object"||typeof e=="function")),XAt=Ln([Ie(),fn().int()]),ZAt=Ie(),vyn=ha({ttl:Ln([fn(),qIe()]).optional(),pollInterval:fn().optional()}),kOr=We({ttl:fn().optional()}),NOr=We({taskId:Ie()}),JIe=ha({progressToken:XAt.optional(),[kA]:NOr.optional()}),pc=We({_meta:JIe.optional()}),ZF=pc.extend({task:kOr.optional()}),egt=e=>ZF.safeParse(e).success,os=We({method:Ie(),params:pc.loose().optional()}),hl=We({_meta:JIe.optional()}),ml=We({method:Ie(),params:hl.loose().optional()}),ss=ha({_meta:JIe.optional()}),I6=Ln([Ie(),fn().int()]),tgt=We({jsonrpc:ht(E6),id:I6,...os.shape}).strict(),GIe=e=>tgt.safeParse(e).success,rgt=We({jsonrpc:ht(E6),...ml.shape}).strict(),ngt=e=>rgt.safeParse(e).success,VIe=We({jsonrpc:ht(E6),id:I6,result:ss}).strict(),eL=e=>VIe.safeParse(e).success;var Yt;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Yt||(Yt={}));var WIe=We({jsonrpc:ht(E6),id:I6.optional(),error:We({code:fn().int(),message:Ie(),data:si().optional()})}).strict();var igt=e=>WIe.safeParse(e).success;var ogt=Ln([tgt,rgt,VIe,WIe]),Syn=Ln([VIe,WIe]),b6=ss.strict(),OOr=hl.extend({requestId:I6.optional(),reason:Ie().optional()}),_6=ml.extend({method:ht("notifications/cancelled"),params:OOr}),BOr=We({src:Ie(),mimeType:Ie().optional(),sizes:wr(Ie()).optional(),theme:Ma(["light","dark"]).optional()}),tL=We({icons:wr(BOr).optional()}),u0=We({name:Ie(),title:Ie().optional()}),sgt=u0.extend({...u0.shape,...tL.shape,version:Ie(),websiteUrl:Ie().optional(),description:Ie().optional()}),FOr=g6(We({applyDefaults:$o().optional()}),ai(Ie(),si())),LOr=YIe(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,g6(We({form:FOr.optional(),url:is.optional()}),ai(Ie(),si()).optional())),POr=ha({list:is.optional(),cancel:is.optional(),requests:ha({sampling:ha({createMessage:is.optional()}).optional(),elicitation:ha({create:is.optional()}).optional()}).optional()}),MOr=ha({list:is.optional(),cancel:is.optional(),requests:ha({tools:ha({call:is.optional()}).optional()}).optional()}),QOr=We({experimental:ai(Ie(),is).optional(),sampling:We({context:is.optional(),tools:is.optional()}).optional(),elicitation:LOr.optional(),roots:We({listChanged:$o().optional()}).optional(),tasks:POr.optional()}),UOr=pc.extend({protocolVersion:Ie(),capabilities:QOr,clientInfo:sgt}),KIe=os.extend({method:ht("initialize"),params:UOr});var $Or=We({experimental:ai(Ie(),is).optional(),logging:is.optional(),completions:is.optional(),prompts:We({listChanged:$o().optional()}).optional(),resources:We({subscribe:$o().optional(),listChanged:$o().optional()}).optional(),tools:We({listChanged:$o().optional()}).optional(),tasks:MOr.optional()}),qOr=ss.extend({protocolVersion:Ie(),capabilities:$Or,serverInfo:sgt,instructions:Ie().optional()}),XIe=ml.extend({method:ht("notifications/initialized"),params:hl.optional()});var C6=os.extend({method:ht("ping"),params:pc.optional()}),jOr=We({progress:fn(),total:Ii(fn()),message:Ii(Ie())}),YOr=We({...hl.shape,...jOr.shape,progressToken:XAt}),w6=ml.extend({method:ht("notifications/progress"),params:YOr}),HOr=pc.extend({cursor:ZAt.optional()}),rL=os.extend({params:HOr.optional()}),nL=ss.extend({nextCursor:ZAt.optional()}),zOr=Ma(["working","input_required","completed","failed","cancelled"]),iL=We({taskId:Ie(),status:zOr,ttl:Ln([fn(),qIe()]),createdAt:Ie(),lastUpdatedAt:Ie(),pollInterval:Ii(fn()),statusMessage:Ii(Ie())}),d0=ss.extend({task:iL}),JOr=hl.merge(iL),oL=ml.extend({method:ht("notifications/tasks/status"),params:JOr}),v6=os.extend({method:ht("tasks/get"),params:pc.extend({taskId:Ie()})}),S6=ss.merge(iL),D6=os.extend({method:ht("tasks/result"),params:pc.extend({taskId:Ie()})}),Dyn=ss.loose(),R6=rL.extend({method:ht("tasks/list")}),T6=nL.extend({tasks:wr(iL)}),x6=os.extend({method:ht("tasks/cancel"),params:pc.extend({taskId:Ie()})}),agt=ss.merge(iL),cgt=We({uri:Ie(),mimeType:Ii(Ie()),_meta:ai(Ie(),si()).optional()}),lgt=cgt.extend({text:Ie()}),ZIe=Ie().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ugt=cgt.extend({blob:ZIe}),sL=Ma(["user","assistant"]),f0=We({audience:wr(sL).optional(),priority:fn().min(0).max(1).optional(),lastModified:KF.datetime({offset:!0}).optional()}),dgt=We({...u0.shape,...tL.shape,uri:Ie(),description:Ii(Ie()),mimeType:Ii(Ie()),annotations:f0.optional(),_meta:Ii(ha({}))}),GOr=We({...u0.shape,...tL.shape,uriTemplate:Ie(),description:Ii(Ie()),mimeType:Ii(Ie()),annotations:f0.optional(),_meta:Ii(ha({}))}),ebe=rL.extend({method:ht("resources/list")}),VOr=nL.extend({resources:wr(dgt)}),WOr=rL.extend({method:ht("resources/templates/list")}),KOr=nL.extend({resourceTemplates:wr(GOr)}),tbe=pc.extend({uri:Ie()}),XOr=tbe,rbe=os.extend({method:ht("resources/read"),params:XOr}),ZOr=ss.extend({contents:wr(Ln([lgt,ugt]))}),eBr=ml.extend({method:ht("notifications/resources/list_changed"),params:hl.optional()}),tBr=tbe,rBr=os.extend({method:ht("resources/subscribe"),params:tBr}),nBr=tbe,iBr=os.extend({method:ht("resources/unsubscribe"),params:nBr}),oBr=hl.extend({uri:Ie()}),sBr=ml.extend({method:ht("notifications/resources/updated"),params:oBr}),aBr=We({name:Ie(),description:Ii(Ie()),required:Ii($o())}),cBr=We({...u0.shape,...tL.shape,description:Ii(Ie()),arguments:Ii(wr(aBr)),_meta:Ii(ha({}))}),lBr=rL.extend({method:ht("prompts/list")}),uBr=nL.extend({prompts:wr(cBr)}),dBr=pc.extend({name:Ie(),arguments:ai(Ie(),Ie()).optional()}),fBr=os.extend({method:ht("prompts/get"),params:dBr}),nbe=We({type:ht("text"),text:Ie(),annotations:f0.optional(),_meta:ai(Ie(),si()).optional()}),ibe=We({type:ht("image"),data:ZIe,mimeType:Ie(),annotations:f0.optional(),_meta:ai(Ie(),si()).optional()}),obe=We({type:ht("audio"),data:ZIe,mimeType:Ie(),annotations:f0.optional(),_meta:ai(Ie(),si()).optional()}),pBr=We({type:ht("tool_use"),name:Ie(),id:Ie(),input:ai(Ie(),si()),_meta:ai(Ie(),si()).optional()}),hBr=We({type:ht("resource"),resource:Ln([lgt,ugt]),annotations:f0.optional(),_meta:ai(Ie(),si()).optional()}),mBr=dgt.extend({type:ht("resource_link")}),sbe=Ln([nbe,ibe,obe,mBr,hBr]),ABr=We({role:sL,content:sbe}),gBr=ss.extend({description:Ie().optional(),messages:wr(ABr)}),yBr=ml.extend({method:ht("notifications/prompts/list_changed"),params:hl.optional()}),EBr=We({title:Ie().optional(),readOnlyHint:$o().optional(),destructiveHint:$o().optional(),idempotentHint:$o().optional(),openWorldHint:$o().optional()}),IBr=We({taskSupport:Ma(["required","optional","forbidden"]).optional()}),fgt=We({...u0.shape,...tL.shape,description:Ie().optional(),inputSchema:We({type:ht("object"),properties:ai(Ie(),is).optional(),required:wr(Ie()).optional()}).catchall(si()),outputSchema:We({type:ht("object"),properties:ai(Ie(),is).optional(),required:wr(Ie()).optional()}).catchall(si()).optional(),annotations:EBr.optional(),execution:IBr.optional(),_meta:ai(Ie(),si()).optional()}),abe=rL.extend({method:ht("tools/list")}),bBr=nL.extend({tools:wr(fgt)}),k6=ss.extend({content:wr(sbe).default([]),structuredContent:ai(Ie(),si()).optional(),isError:$o().optional()}),Ryn=k6.or(ss.extend({toolResult:si()})),_Br=ZF.extend({name:Ie(),arguments:ai(Ie(),si()).optional()}),aL=os.extend({method:ht("tools/call"),params:_Br}),CBr=ml.extend({method:ht("notifications/tools/list_changed"),params:hl.optional()}),Tyn=We({autoRefresh:$o().default(!0),debounceMs:fn().int().nonnegative().default(300)}),cL=Ma(["debug","info","notice","warning","error","critical","alert","emergency"]),wBr=pc.extend({level:cL}),cbe=os.extend({method:ht("logging/setLevel"),params:wBr}),vBr=hl.extend({level:cL,logger:Ie().optional(),data:si()}),SBr=ml.extend({method:ht("notifications/message"),params:vBr}),DBr=We({name:Ie().optional()}),RBr=We({hints:wr(DBr).optional(),costPriority:fn().min(0).max(1).optional(),speedPriority:fn().min(0).max(1).optional(),intelligencePriority:fn().min(0).max(1).optional()}),TBr=We({mode:Ma(["auto","required","none"]).optional()}),xBr=We({type:ht("tool_result"),toolUseId:Ie().describe("The unique identifier for the corresponding tool call."),content:wr(sbe).default([]),structuredContent:We({}).loose().optional(),isError:$o().optional(),_meta:ai(Ie(),si()).optional()}),kBr=jIe("type",[nbe,ibe,obe]),y6=jIe("type",[nbe,ibe,obe,pBr,xBr]),NBr=We({role:sL,content:Ln([y6,wr(y6)]),_meta:ai(Ie(),si()).optional()}),OBr=ZF.extend({messages:wr(NBr),modelPreferences:RBr.optional(),systemPrompt:Ie().optional(),includeContext:Ma(["none","thisServer","allServers"]).optional(),temperature:fn().optional(),maxTokens:fn().int(),stopSequences:wr(Ie()).optional(),metadata:is.optional(),tools:wr(fgt).optional(),toolChoice:TBr.optional()}),BBr=os.extend({method:ht("sampling/createMessage"),params:OBr}),lL=ss.extend({model:Ie(),stopReason:Ii(Ma(["endTurn","stopSequence","maxTokens"]).or(Ie())),role:sL,content:kBr}),lbe=ss.extend({model:Ie(),stopReason:Ii(Ma(["endTurn","stopSequence","maxTokens","toolUse"]).or(Ie())),role:sL,content:Ln([y6,wr(y6)])}),FBr=We({type:ht("boolean"),title:Ie().optional(),description:Ie().optional(),default:$o().optional()}),LBr=We({type:ht("string"),title:Ie().optional(),description:Ie().optional(),minLength:fn().optional(),maxLength:fn().optional(),format:Ma(["email","uri","date","date-time"]).optional(),default:Ie().optional()}),PBr=We({type:Ma(["number","integer"]),title:Ie().optional(),description:Ie().optional(),minimum:fn().optional(),maximum:fn().optional(),default:fn().optional()}),MBr=We({type:ht("string"),title:Ie().optional(),description:Ie().optional(),enum:wr(Ie()),default:Ie().optional()}),QBr=We({type:ht("string"),title:Ie().optional(),description:Ie().optional(),oneOf:wr(We({const:Ie(),title:Ie()})),default:Ie().optional()}),UBr=We({type:ht("string"),title:Ie().optional(),description:Ie().optional(),enum:wr(Ie()),enumNames:wr(Ie()).optional(),default:Ie().optional()}),$Br=Ln([MBr,QBr]),qBr=We({type:ht("array"),title:Ie().optional(),description:Ie().optional(),minItems:fn().optional(),maxItems:fn().optional(),items:We({type:ht("string"),enum:wr(Ie())}),default:wr(Ie()).optional()}),jBr=We({type:ht("array"),title:Ie().optional(),description:Ie().optional(),minItems:fn().optional(),maxItems:fn().optional(),items:We({anyOf:wr(We({const:Ie(),title:Ie()}))}),default:wr(Ie()).optional()}),YBr=Ln([qBr,jBr]),HBr=Ln([UBr,$Br,YBr]),zBr=Ln([HBr,FBr,LBr,PBr]),JBr=ZF.extend({mode:ht("form").optional(),message:Ie(),requestedSchema:We({type:ht("object"),properties:ai(Ie(),zBr),required:wr(Ie()).optional()})}),GBr=ZF.extend({mode:ht("url"),message:Ie(),elicitationId:Ie(),url:Ie().url()}),VBr=Ln([JBr,GBr]),WBr=os.extend({method:ht("elicitation/create"),params:VBr}),KBr=hl.extend({elicitationId:Ie()}),XBr=ml.extend({method:ht("notifications/elicitation/complete"),params:KBr}),p0=ss.extend({action:Ma(["accept","decline","cancel"]),content:YIe(e=>e===null?void 0:e,ai(Ie(),Ln([Ie(),fn(),$o(),wr(Ie())])).optional())}),ZBr=We({type:ht("ref/resource"),uri:Ie()});var eFr=We({type:ht("ref/prompt"),name:Ie()}),tFr=pc.extend({ref:Ln([eFr,ZBr]),argument:We({name:Ie(),value:Ie()}),context:We({arguments:ai(Ie(),Ie()).optional()}).optional()}),rFr=os.extend({method:ht("completion/complete"),params:tFr});var nFr=ss.extend({completion:ha({values:wr(Ie()).max(100),total:Ii(fn().int()),hasMore:Ii($o())})}),iFr=We({uri:Ie().startsWith("file://"),name:Ie().optional(),_meta:ai(Ie(),si()).optional()}),oFr=os.extend({method:ht("roots/list"),params:pc.optional()}),ube=ss.extend({roots:wr(iFr)}),sFr=ml.extend({method:ht("notifications/roots/list_changed"),params:hl.optional()}),xyn=Ln([C6,KIe,rFr,cbe,fBr,lBr,ebe,WOr,rbe,rBr,iBr,aL,abe,v6,D6,R6,x6]),kyn=Ln([_6,w6,XIe,sFr,oL]),Nyn=Ln([b6,lL,lbe,p0,ube,S6,T6,d0]),Oyn=Ln([C6,BBr,WBr,oFr,v6,D6,R6,x6]),Byn=Ln([_6,w6,SBr,sBr,eBr,CBr,yBr,oL,XBr]),Fyn=Ln([b6,qOr,nFr,gBr,uBr,VOr,KOr,ZOr,k6,bBr,S6,T6,d0]),Bt=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===Yt.UrlElicitationRequired&&n){let i=n;if(i.elicitations)return new HIe(i.elicitations,r)}return new e(t,r,n)}},HIe=class extends Bt{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(Yt.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function NA(e){return e==="completed"||e==="failed"||e==="cancelled"}var hEn=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function dbe(e){let r=m6(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=TAt(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function fbe(e,t){let r=xA(e,t);if(!r.success)throw r.error;return r.data}var fFr=6e4,N6=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(_6,r=>{this._oncancel(r)}),this.setNotificationHandler(w6,r=>{this._onprogress(r)}),this.setRequestHandler(C6,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(v6,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new Bt(Yt.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(D6,async(r,n)=>{let i=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,d=this._requestResolvers.get(u);if(d)if(this._requestResolvers.delete(u),a.type==="response")d(c);else{let f=c,p=new Bt(f.error.code,f.error.message,f.error.data);d(p)}else{let f=a.type==="response"?"Response":"Error";this._onerror(new Error(`${f} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let s=await this._taskStore.getTask(o,n.sessionId);if(!s)throw new Bt(Yt.InvalidParams,`Task not found: ${o}`);if(!NA(s.status))return await this._waitForTaskUpdate(o,n.signal),await i();if(NA(s.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[kA]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(R6,async(r,n)=>{try{let{tasks:i,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new Bt(Yt.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(x6,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new Bt(Yt.InvalidParams,`Task not found: ${r.params.taskId}`);if(NA(i.status))throw new Bt(Yt.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new Bt(Yt.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof Bt?i:new Bt(Yt.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),Bt.fromError(Yt.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};let i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),eL(o)||igt(o)?this._onresponse(o):GIe(o)?this._onrequest(o,s):ngt(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=Bt.fromError(Yt.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=t.params?._meta?.[kA]?.taskId;if(n===void 0){let d={jsonrpc:"2.0",id:t.id,error:{code:Yt.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},i?.sessionId).catch(f=>this._onerror(new Error(`Failed to enqueue error response: ${f}`))):i?.send(d).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(t.id,s);let a=egt(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,u={signal:s.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async d=>{if(s.signal.aborted)return;let f={relatedRequestId:t.id};o&&(f.relatedTask={taskId:o}),await this.notification(d,f)},sendRequest:async(d,f,p)=>{if(s.signal.aborted)throw new Bt(Yt.ConnectionClosed,"Request was cancelled");let h={...p,relatedRequestId:t.id};o&&!h.relatedTask&&(h.relatedTask={taskId:o});let m=h.relatedTask?.taskId??o;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(d,f,h)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async d=>{if(s.signal.aborted)return;let f={result:d,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:f,timestamp:Date.now()},i?.sessionId):await i?.send(f)},async d=>{if(s.signal.aborted)return;let f={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(d.code)?d.code:Yt.InternalError,message:d.message??"Internal error",...d.data!==void 0&&{data:d.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:f,timestamp:Date.now()},i?.sessionId):await i?.send(f)}).catch(d=>this._onerror(new Error(`Failed to send response: ${d}`))).finally(()=>{this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,i=Number(r),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(c){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(c);return}o(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),eL(t))n(t);else{let s=new Bt(t.error.code,t.error.message,t.error.data);n(s)}return}let i=this._responseHandlers.get(r);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(eL(t)&&t.result&&typeof t.result=="object"){let s=t.result;if(s.task&&typeof s.task=="object"){let a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),eL(t))i(t);else{let s=Bt.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:i}=n??{};if(!i){try{yield{type:"result",result:await this.request(t,r,n)}}catch(s){yield{type:"error",error:s instanceof Bt?s:new Bt(Yt.InternalError,String(s))}}return}let o;try{let s=await this.request(t,d0,n);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new Bt(Yt.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},NA(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new Bt(Yt.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Bt(Yt.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof Bt?s:new Bt(Yt.InternalError,String(s))}}}request(t,r,n){let{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:c}=n??{};return new Promise((u,d)=>{let f=I=>{d(I)};if(!this._transport){f(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(I){f(I);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,h={...t,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),h.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),a&&(h.params={...h.params,task:a}),c&&(h.params={...h.params,_meta:{...h.params?._meta||{},[kA]:c}});let m=I=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(I)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(C=>this._onerror(new Error(`Failed to send cancellation: ${C}`)));let E=I instanceof Bt?I:new Bt(Yt.RequestTimeout,String(I));d(E)};this._responseHandlers.set(p,I=>{if(!n?.signal?.aborted){if(I instanceof Error)return d(I);try{let E=xA(r,I.result);E.success?u(E.data):d(E.error)}catch(E){d(E)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let A=n?.timeout??fFr,g=()=>m(Bt.fromError(Yt.RequestTimeout,"Request timed out",{timeout:A}));this._setupTimeout(p,A,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let I=E=>{let C=this._responseHandlers.get(p);C?C(E):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,I),this._enqueueTaskMessage(y,{type:"request",message:h,timestamp:Date.now()}).catch(E=>{this._cleanupTimeout(p),d(E)})}else this._transport.send(h,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(I=>{this._cleanupTimeout(p),d(I)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},S6,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},T6,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},agt,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[kA]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[kA]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[kA]:r.relatedTask}}}),await this._transport.send(s,r)}setRequestHandler(t,r){let n=dbe(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,o)=>{let s=fbe(t,i);return Promise.resolve(r(s,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=dbe(t);this._notificationHandlers.set(n,i=>{let o=fbe(t,i);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,i)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let i of n)if(i.type==="request"&&GIe(i.message)){let o=i.message.id,s=this._requestResolvers.get(o);s?(s(new Bt(Yt.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(t);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,o)=>{if(r.aborted){o(new Bt(Yt.InvalidRequest,"Request cancelled"));return}let s=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(s),o(new Bt(Yt.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await n.createTask(i,t.id,{method:t.method,params:t.params},r)},getTask:async i=>{let o=await n.getTask(i,r);if(!o)throw new Bt(Yt.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await n.storeTaskResult(i,o,s,r);let a=await n.getTask(i,r);if(a){let c=oL.parse({method:"notifications/tasks/status",params:a});await this.notification(c),NA(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>n.getTaskResult(i,r),updateTaskStatus:async(i,o,s)=>{let a=await n.getTask(i,r);if(!a)throw new Bt(Yt.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(NA(a.status))throw new Bt(Yt.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(i,o,s,r);let c=await n.getTask(i,r);if(c){let u=oL.parse({method:"notifications/tasks/status",params:c});await this.notification(u),NA(c.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function pgt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function hgt(e,t){let r={...e};for(let n in t){let i=n,o=t[i];if(o===void 0)continue;let s=r[i];pgt(s)&&pgt(o)?r[i]={...s,...o}:r[i]=o}return r}var eIt=Vi(K_e(),1),tIt=Vi(ZEt(),1);function nUr(){let e=new eIt.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,tIt.default)(e),e}var h5=class{constructor(t){this._ajv=t??nUr()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var m5=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],o=Array.isArray(i.content)?i.content:[i.content],s=o.some(d=>d.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(d=>d.type==="tool_use");if(s){if(o.some(d=>d.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let d=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),f=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(d.size!==f.size||![...d].every(p=>f.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},lL,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),i=t.mode??"form";switch(i){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=i==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:o},p0,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function rIt(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function nIt(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var A5=class extends N6{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(cL.options.map((n,i)=>[n,i])),this.isMessageIgnored=(n,i)=>{let o=this._loggingLevels.get(i);return o?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new h5,this.setRequestHandler(KIe,n=>this._oninitialize(n)),this.setNotificationHandler(XIe,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(cbe,async(n,i)=>{let o=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=cL.safeParse(s);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new m5(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=hgt(this._capabilities,t)}setRequestHandler(t,r){let i=m6(t)?.method;if(!i)throw new Error("Schema is missing a method literal");let o;if(l0(i)){let a=i;o=a._zod?.def?.value??a.value}else{let a=i;o=a._def?.value??a.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(c,u)=>{let d=xA(aL,c);if(!d.success){let m=d.error instanceof Error?d.error.message:String(d.error);throw new Bt(Yt.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:f}=d.data,p=await Promise.resolve(r(c,u));if(f.task){let m=xA(d0,p);if(!m.success){let A=m.error instanceof Error?m.error.message:String(m.error);throw new Bt(Yt.InvalidParams,`Invalid task creation result: ${A}`)}return m.data}let h=xA(k6,p);if(!h.success){let m=h.error instanceof Error?h.error.message:String(h.error);throw new Bt(Yt.InvalidParams,`Invalid tools/call result: ${m}`)}return h.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){nIt(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&rIt(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:KAt.includes(r)?r:zIe,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},b6)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],o=i.some(u=>u.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],c=a.some(u=>u.type==="tool_use");if(o){if(i.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(i.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(u.size!==d.size||![...u].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},lbe,r):this.request({method:"sampling/createMessage",params:t},lL,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=t;return this.request({method:"elicitation/create",params:i},p0,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=t.mode==="form"?t:{...t,mode:"form"},o=await this.request({method:"elicitation/create",params:i},p0,r);if(o.action==="accept"&&o.content&&i.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(i.requestedSchema)(o.content);if(!a.valid)throw new Bt(Yt.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof Bt?s:new Bt(Yt.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},ube,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};Au();A$();Au();z9();kd();rI();YU();function vI(){return _A(void 0).length}function g5(e,t=!1){return(e==="flat"?vI():e==="namespace"?Pi.length:CA.length)+(t?1:0)}function iIt(){return Pi.length}Yv();$v();rI();Au();pF();Yv();T9();function oCe(e,t){let r=gu(e.params,e.required),n=r.properties;t.jotRider&&fF(e)&&(n[Pa]=S9());let i=e.acceptsHostFile===!0&&!e.params[_p];return i&&(n[_p]=D9()),t.multiOrg&&!e.params[nI]&&(n[nI]=v9()),{name:e.name,description:e.description,inputSchema:r,annotations:{title:t.title??R9(e.name),...b9(e)},...i?{_meta:{...w9}}:{}}}function oIt(e,t){return e.tools.map(r=>oCe(r,{multiOrg:t,jotRider:!0,title:e.titles.get(r.name)}))}function sIt(e,t){return e.tools.find(r=>r.name===t)}T9();kd();Df();zu();var iUr=10*1024*1024,oUr=2e4;function sUr(e){return e[0]===37&&e[1]===80&&e[2]===68&&e[3]===70?"application/pdf":e[0]===255&&e[1]===216?"image/jpeg":e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"image/png":e[0]===80&&e[1]===75?"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":null}function aUr(e,t){let r=e?.trim()||cUr(t);return XU(r,"attachment")}function cUr(e){let t=e.pathname.split("/").pop()??"";try{return decodeURIComponent(t)}catch{return t}}async function aIt(e,t=kc){if(typeof e!="object"||e===null||Array.isArray(e))return{error:{error:"The file was passed as a reference this server cannot fetch \u2014 some clients (notably mobile apps) cannot deliver conversation files yet.",hint:"Ask the user to retry from the web/desktop client, or to share the file as a link (Dropbox / Google Drive / OneDrive or any https URL) and pass that link instead."}};let r=e,n;try{if(n=new URL(String(r.download_url??"")),n.protocol!=="https:")throw new Error("not https")}catch{return{error:{error:"The file reference has no fetchable https download_url. `file` is populated by the HOST from a file the user attached \u2014 it is not a field to fill in, and a path inside your own sandbox is not reachable from the Jaz server.",hint:"If the user attached no file, omit `file` entirely and pass a link the Jaz server can fetch as the source."}}}try{let i=await t(n,{timeoutMs:oUr,maxBytes:iUr});if(!i.ok)return{error:{error:`Downloading the provided file failed (${i.status} ${i.statusText}) \u2014 the link may have expired.`,hint:"Ask the user to re-attach the file and retry."}};let o=await i.arrayBuffer(),s=(i.headers.get("content-type")??"").split(";")[0].trim(),a=typeof r.mime_type=="string"&&r.mime_type||(s&&s!=="application/octet-stream"?s:null)||sUr(new Uint8Array(o.slice(0,8)))||"application/octet-stream";return{file:{data:new Blob([o],{type:a}),fileName:aUr(typeof r.file_name=="string"?r.file_name:void 0,n)}}}catch(i){return{error:{error:`Downloading the provided file failed: ${i instanceof Error?i.message:String(i)}`,hint:"Ask the user to re-attach the file and retry. Files over 10MB cannot be ingested this way."}}}}pF();sEe();yp();var E5;function AUr(){if(E5)return E5;if(process.env.CLIO_DAEMON==="1")return E5}process.env.CLIO_DAEMON==="1"&&Promise.resolve().then(()=>(lIt(),cIt)).then(e=>{E5=e}).catch(()=>{});function k0(e){let t=AUr();if(!t)return;let r=t.normalizeClioPath(e.path),n=String(e.statusCode);if(t.clioRequestsTotal.labels(e.method,r,n).inc(),t.clioRequestDuration.labels(e.method,r).observe(e.durationMs/1e3),e.retried&&t.clioRetriesTotal.labels(e.method,r).inc(),e.error){let i=e.statusCode===429?"rate_limit":e.statusCode>=500?"server_error":e.statusCode===0?"network_error":"client_error";t.clioErrorsTotal.labels(e.method,r,i).inc()}}T$();rI();qi();mf();E9();kd();Yv();import{readFileSync as SUr}from"node:fs";import{join as DUr}from"node:path";var pIt=Vi(bie(),1);Tge();import{createHash as gUr}from"node:crypto";import{readFileSync as dIt,readdirSync as fIt,statSync as yUr}from"node:fs";import{dirname as EUr,join as SI,relative as IUr}from"node:path";import{fileURLToPath as bUr}from"node:url";function sCe(){let e=EUr(bUr(import.meta.url));return Hct([SI(e,"..","..","..","assets","skills"),SI(e,"..","..","..","..","assets","skills"),SI(e,"skills")])}function aCe(e,t=()=>!0){try{if(!yUr(e).isDirectory())return[]}catch{return[]}let r=[],n=20,i=(o,s)=>{if(s>n)return;let a;try{a=fIt(o,{withFileTypes:!0})}catch{return}for(let c of a){let u=SI(o,c.name);if(c.isDirectory())i(u,s+1);else if(c.isFile()){let d=IUr(e,u).split(/[\\/]/).join("/");t(d)&&r.push(d)}}};return i(e,0),r.sort()}var N0="SKILL.md";function _Ur(e){return!e.split("/").some(t=>t.startsWith(".")||t==="help-center-mirror")}function CUr(e){let t=e.replace(/^/,"").replace(/\r\n/g,`
1001
1001
  `);if(!t.startsWith(`---
1002
- `))throw new Error('must begin with a "---" line');let r=t.slice(4),n=/^---[\t ]*$/m.exec(r);if(!n)throw new Error('frontmatter has no closing "---" line');let i=(0,pIt.parse)(r.slice(0,n.index));if(typeof i!="object"||i===null||Array.isArray(i))throw new Error("frontmatter must be a YAML mapping");return i}function uIt(e,t){return`skill://${e}/${t.split("/").map(encodeURIComponent).join("/")}`}function wUr(){let e={skills:[],byUri:new Map,files:new Map},t=sCe();if(!t)return e;for(let r of fIt(t,{withFileTypes:!0})){if(!r.isDirectory())continue;let n=SI(t,r.name),i=aCe(n,_Ur);if(!i.includes(N0))continue;let o=new Map(i.map(p=>[p,dIt(SI(n,p))])),s;try{s=CUr(o.get(N0).toString("utf-8"))}catch(p){throw new Error(`${r.name}/${N0}: ${p instanceof Error?p.message:String(p)}`)}let{name:a,description:c}=s;if(typeof a!="string"||typeof c!="string")throw new Error(`${r.name}/${N0}: frontmatter needs a string "name" and "description"`);let u=uIt(a,N0);if(e.byUri.has(u))throw new Error(`${r.name}/${N0}: another skill folder is already named "${a}"`);let d=i.map(p=>{let h=o.get(p),m=uIt(a,p);return e.files.set(m,{filePath:SI(n,p),mimeType:p.endsWith(".md")?"text/markdown":"text/plain"}),{uri:m,digest:`sha256:${gUr("sha256").update(h).digest("hex")}`,size:h.length}}),f={uri:u,frontmatter:s,resources:d};e.skills.push(f),e.byUri.set(u,f)}return e.skills.sort((r,n)=>r.uri.localeCompare(n.uri)),e}var vUr=null;function cCe(){return vUr??=wUr()}function hIt(){return cCe().skills}function mIt(e){return cCe().byUri.get(e)}function AIt(e){let t=cCe().files.get(e);return t&&{mimeType:t.mimeType,text:dIt(t.filePath,"utf-8")}}function RUr(e){let t=e.fileFilter??(()=>!0);return aCe(e.rootDir,n=>n.endsWith(".md")&&t(n)).map(n=>{let i=e.uriPathBuilder?e.uriPathBuilder(n):n.replace(/\.md$/,"");return{uri:`${e.uriPrefix}/${i}`,name:e.nameBuilder(n),description:e.descriptionBuilder?.(n),mimeType:"text/markdown",filePath:DUr(e.rootDir,n)}})}var TUr=["api","jaz-api-reference","cli","conversion","jobs","transaction-recipes","jaz-pseudo-sql","jaz-kit"],xUr={api:"Jaz REST API rules: field names, error codes, production gotchas.","jaz-api-reference":"Jaz REST API reference: request/response examples per endpoint, endpoint catalog, search filters and enums.",cli:"Jaz CLI commands, auth, calculators, jobs.",conversion:"Migration from Xero, QuickBooks, Sage, MYOB, or Excel exports into Jaz.",jobs:"12 recurring accounting workflow playbooks (close, reconciliation, GST/VAT, etc.).","transaction-recipes":"16 IFRS-compliant transaction recipes plus 13 financial calculators.","jaz-pseudo-sql":"Read-only pseudo-SQL over the curated reporting schema for ad-hoc questions.","jaz-kit":"Multi-organization operator workspace: per-org context, resumable closes, review queue."};function kUr(e){if(e.includes("/help-center-mirror/"))return!1;let t=e.split("/")[0];return TUr.includes(t)}function NUr(e){let t=e.split("/"),r=t[0];if(t.length===2&&t[1]==="SKILL.md")return`Jaz ${r} skill`;if(t[1]==="references"){let n=t.slice(2).join("/").replace(/\.md$/,"");return`Jaz ${r} reference: ${n}`}return`Jaz ${r}: ${e}`}function OUr(e){let t=e.split("/")[0];return xUr[t]}var lCe=null,uCe=null;function BUr(){let e=bA();return JSON.stringify({...e,map:cF().map(t=>({...t,operation_list:Uv(Pi.find(r=>r.name===t.namespace).groups).map(jv)}))},null,2)}function dCe(){if(lCe)return lCe;let e=sCe(),t=[{uri:"jaz://capabilities",name:"Jaz capability map",description:'The full catalogue behind this connector \u2014 every namespace, every operation, each with its kind (read / write / destructive) and parameters. Attach this to answer "what can Jaz do".',mimeType:"application/json",filePath:"",render:()=>({mimeType:"application/json",text:BUr()})}];return e&&t.push(...RUr({rootDir:e,uriPrefix:"jaz://skill",fileFilter:kUr,nameBuilder:NUr,descriptionBuilder:OUr,uriPathBuilder:r=>{let n=r.split("/");return n.length===2&&n[1]==="SKILL.md"?n[0]:r.replace(/\.md$/,"")}})),lCe=t,uCe=new Map(t.map(r=>[r.uri,r])),t}function gIt(e){if(e.startsWith("skill://")){let n=AIt(e);if(!n)throw new Error(`Resource not found: ${e}`);return n}uCe||dCe();let t=uCe.get(e);if(!t)throw new Error(`Resource not found: ${e}`);if(t.render)return t.render();let r=SUr(t.filePath,"utf-8");return{mimeType:t.mimeType,text:r}}kI();Dg();var FUr=new Set(["help_center","capabilities","calculators"]),fCe="The capability map, calculators, and help center search work without an account.",pCe="Get an API key or token from jaz.ai";function UL(e,t){return FUr.has(e)}function LUr(e,t,r){return new Xn({mode:"pat",token:e,orgId:t,tokenProvider:r},"mcp",{onRequest:k0})}function I5(e,t){let r=new Map;for(let n of e)n.resourceId&&r.set(n.resourceId,{name:n.name,resourceId:n.resourceId,currency:n.currency,client:t});return r}async function yIt(e){return I5(await LBe(e),e)}async function hCe(e,t=5e3){let r=new Map,n=[],i=async a=>{let c,u=new Promise(d=>{c=setTimeout(()=>d(null),t)});try{return await Promise.race([a,u])}finally{c&&clearTimeout(c)}},o=e.map(a=>({auth:a,client:new Xn(a,"mcp",{onRequest:k0})})),s=o[0]?.client??null;return await Promise.all(o.map(async({auth:a,client:c})=>{try{let u=await i(As(c));if(u)r.set(u.resourceId,{name:u.name,resourceId:u.resourceId,currency:u.currency,client:c});else{let d=a.mode==="direct"?"api-key":a.mode;n.push(`Org lookup returned empty (${d}).`)}}catch(u){let d=a.mode==="direct"?"api-key":a.mode;n.push(`Org lookup failed (${d}): ${u instanceof Error?u.message:"unknown"}`)}})),{orgMap:r,primaryClient:s,errors:n}}function mCe(){return{name:qv.name,description:qv.description,inputSchema:qv.inputSchema,annotations:{title:"List Organizations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}}function PUr(e){return[...e?[mCe()]:[],...hF(e)]}function MUr(e,t){return[...t?[mCe()]:[],...oIt(e,t),...e.listsRouters?hF(t):[]]}function EIt(e){let t=new A5({name:"jaz-ai",version:e.version},{capabilities:{tools:{},resources:{}},instructions:e.instructions});t.setRequestHandler(abe,async()=>{let s=e.isMultiOrg&&e.orgMap.size>0;if(e.flatMode){let u=_A(void 0).reduce((d,f)=>{try{d.push(oCe(f,{multiOrg:s,jotRider:!1}))}catch(p){let h=p instanceof Error?p.message:String(p);process.stderr.write(`[jaz-mcp] flat-mode: skipping malformed tool '${f.name}': ${h}
1002
+ `))throw new Error('must begin with a "---" line');let r=t.slice(4),n=/^---[\t ]*$/m.exec(r);if(!n)throw new Error('frontmatter has no closing "---" line');let i=(0,pIt.parse)(r.slice(0,n.index));if(typeof i!="object"||i===null||Array.isArray(i))throw new Error("frontmatter must be a YAML mapping");return i}function uIt(e,t){return`skill://${e}/${t.split("/").map(encodeURIComponent).join("/")}`}function wUr(){let e={skills:[],byUri:new Map,files:new Map},t=sCe();if(!t)return e;for(let r of fIt(t,{withFileTypes:!0})){if(!r.isDirectory())continue;let n=SI(t,r.name),i=aCe(n,_Ur);if(!i.includes(N0))continue;let o=new Map(i.map(p=>[p,dIt(SI(n,p))])),s;try{s=CUr(o.get(N0).toString("utf-8"))}catch(p){throw new Error(`${r.name}/${N0}: ${p instanceof Error?p.message:String(p)}`)}let{name:a,description:c}=s;if(typeof a!="string"||typeof c!="string")throw new Error(`${r.name}/${N0}: frontmatter needs a string "name" and "description"`);let u=uIt(a,N0);if(e.byUri.has(u))throw new Error(`${r.name}/${N0}: another skill folder is already named "${a}"`);let d=i.map(p=>{let h=o.get(p),m=uIt(a,p);return e.files.set(m,{filePath:SI(n,p),mimeType:p.endsWith(".md")?"text/markdown":"text/plain"}),{uri:m,digest:`sha256:${gUr("sha256").update(h).digest("hex")}`,size:h.length}}),f={uri:u,frontmatter:s,resources:d};e.skills.push(f),e.byUri.set(u,f)}return e.skills.sort((r,n)=>r.uri.localeCompare(n.uri)),e}var vUr=null;function cCe(){return vUr??=wUr()}function hIt(){return cCe().skills}function mIt(e){return cCe().byUri.get(e)}function AIt(e){let t=cCe().files.get(e);return t&&{mimeType:t.mimeType,text:dIt(t.filePath,"utf-8")}}function RUr(e){let t=e.fileFilter??(()=>!0);return aCe(e.rootDir,n=>n.endsWith(".md")&&t(n)).map(n=>{let i=e.uriPathBuilder?e.uriPathBuilder(n):n.replace(/\.md$/,"");return{uri:`${e.uriPrefix}/${i}`,name:e.nameBuilder(n),description:e.descriptionBuilder?.(n),mimeType:"text/markdown",filePath:DUr(e.rootDir,n)}})}var TUr=["api","jaz-api-reference","cli","conversion","jobs","transaction-recipes","jaz-pseudo-sql","jaz-kit"],xUr={api:"Jaz REST API rules: field names, error codes, production gotchas.","jaz-api-reference":"Jaz REST API reference: request/response examples per endpoint, endpoint catalog, search filters and enums.",cli:"Jaz CLI commands, auth, calculators, jobs.",conversion:"Migration from Xero, QuickBooks, Sage, MYOB, or Excel exports into Jaz.",jobs:"12 recurring accounting workflow playbooks (close, reconciliation, GST/VAT, etc.).","transaction-recipes":"16 IFRS-compliant transaction recipes plus 13 financial calculators.","jaz-pseudo-sql":"Read-only pseudo-SQL over the curated reporting schema for ad-hoc questions.","jaz-kit":"Multi-organization operator workspace: per-org context, resumable closes, review queue."};function kUr(e){if(e.includes("/help-center-mirror/"))return!1;let t=e.split("/")[0];return TUr.includes(t)}function NUr(e){let t=e.split("/"),r=t[0];if(t.length===2&&t[1]==="SKILL.md")return`Jaz ${r} skill`;if(t[1]==="references"){let n=t.slice(2).join("/").replace(/\.md$/,"");return`Jaz ${r} reference: ${n}`}return`Jaz ${r}: ${e}`}function OUr(e){let t=e.split("/")[0];return xUr[t]}var lCe=null,uCe=null;function BUr(){let e=bA();return JSON.stringify({...e,map:cF().map(t=>({...t,operation_list:Uv(Pi.find(r=>r.name===t.namespace).groups).map(jv)}))},null,2)}function dCe(){if(lCe)return lCe;let e=sCe(),t=[{uri:"jaz://capabilities",name:"Jaz capability map",description:'The full catalogue behind this connector \u2014 every namespace, every operation, each with its kind (read / write / destructive) and parameters. Attach this to answer "what can Jaz do".',mimeType:"application/json",filePath:"",render:()=>({mimeType:"application/json",text:BUr()})}];return e&&t.push(...RUr({rootDir:e,uriPrefix:"jaz://skill",fileFilter:kUr,nameBuilder:NUr,descriptionBuilder:OUr,uriPathBuilder:r=>{let n=r.split("/");return n.length===2&&n[1]==="SKILL.md"?n[0]:r.replace(/\.md$/,"")}})),lCe=t,uCe=new Map(t.map(r=>[r.uri,r])),t}function gIt(e){if(e.startsWith("skill://")){let n=AIt(e);if(!n)throw new Error(`Resource not found: ${e}`);return n}uCe||dCe();let t=uCe.get(e);if(!t)throw new Error(`Resource not found: ${e}`);if(t.render)return t.render();let r=SUr(t.filePath,"utf-8");return{mimeType:t.mimeType,text:r}}kI();Dg();var FUr=new Set(["help_center","capabilities","calculators"]),fCe="The capability map, calculators, and help center search work without an account.",pCe="Get an API key or token from jaz.ai";function UL(e,t){return FUr.has(e)}function LUr(e,t,r,n){return new Xn({mode:"pat",token:e,orgId:t,tokenProvider:r},"mcp",{baseUrl:n,onRequest:k0})}function I5(e,t){let r=new Map;for(let n of e)n.resourceId&&r.set(n.resourceId,{name:n.name,resourceId:n.resourceId,currency:n.currency,client:t});return r}async function yIt(e){return I5(await LBe(e),e)}async function hCe(e,t=5e3){let r=new Map,n=[],i=async a=>{let c,u=new Promise(d=>{c=setTimeout(()=>d(null),t)});try{return await Promise.race([a,u])}finally{c&&clearTimeout(c)}},o=e.map(a=>({auth:a,client:new Xn(a,"mcp",{onRequest:k0})})),s=o[0]?.client??null;return await Promise.all(o.map(async({auth:a,client:c})=>{try{let u=await i(As(c));if(u)r.set(u.resourceId,{name:u.name,resourceId:u.resourceId,currency:u.currency,client:c});else{let d=a.mode==="direct"?"api-key":a.mode;n.push(`Org lookup returned empty (${d}).`)}}catch(u){let d=a.mode==="direct"?"api-key":a.mode;n.push(`Org lookup failed (${d}): ${u instanceof Error?u.message:"unknown"}`)}})),{orgMap:r,primaryClient:s,errors:n}}function mCe(){return{name:qv.name,description:qv.description,inputSchema:qv.inputSchema,annotations:{title:"List Organizations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}}function PUr(e){return[...e?[mCe()]:[],...hF(e)]}function MUr(e,t){return[...t?[mCe()]:[],...oIt(e,t),...e.listsRouters?hF(t):[]]}function EIt(e){let t=new A5({name:"jaz-ai",version:e.version},{capabilities:{tools:{},resources:{}},instructions:e.instructions});t.setRequestHandler(abe,async()=>{let s=e.isMultiOrg&&e.orgMap.size>0;if(e.flatMode){let u=_A(void 0).reduce((d,f)=>{try{d.push(oCe(f,{multiOrg:s,jotRider:!1}))}catch(p){let h=p instanceof Error?p.message:String(p);process.stderr.write(`[jaz-mcp] flat-mode: skipping malformed tool '${f.name}': ${h}
1003
1003
  `)}return d},[]);return{tools:s?[mCe(),...u]:u}}if(e.operationSurface)return{tools:MUr(e.operationSurface,s)};if(e.namespaceMode)return{tools:PUr(s)};let a=s?[...CA,qv]:CA,c={search_tools:`Find Jaz Operations \xB7 ${vI()} available`,describe_tools:"Get Operation Parameters",execute_tool:"Run a Jaz Operation",[qv.name]:"List Organizations"};return{tools:a.map(u=>({name:u.name,description:u.description,inputSchema:u.inputSchema,annotations:{...c[u.name]?{title:c[u.name]}:{},readOnlyHint:u.name!=="execute_tool",openWorldHint:!1}}))}}),t.setRequestHandler(ebe,async()=>({resources:dCe().map(({uri:s,name:a,description:c,mimeType:u})=>({uri:s,name:a,...c?{description:c}:{},mimeType:u}))})),t.setRequestHandler(rbe,async s=>{let a=s.params.uri;try{let{mimeType:c,text:u}=gIt(a);return{contents:[{uri:a,mimeType:c,text:u}]}}catch(c){throw new Bt(Yt.InvalidParams,c instanceof Error?c.message:`Resource not found: ${a}`,{uri:a})}});let r=()=>Object.assign(new Error("Method not found"),{code:Yt.MethodNotFound});t.fallbackRequestHandler=async s=>{let a=s.params??{};switch(s.method){case"skills/list":if(a.cursor!==void 0)throw new Bt(Yt.InvalidParams,"Invalid cursor: skills/list returns every skill in one page");return{skills:hIt()};case"skills/get":{let c=a.uri;if(typeof c!="string")throw new Bt(Yt.InvalidParams,"skills/get needs params.uri, the URI of a SKILL.md");let u=mIt(c);if(!u)throw new Bt(Yt.InvalidParams,`No skill is served at ${c}`,{uri:c});return{skill:u}}default:throw r()}};let n=(s,a=!1)=>({content:[{type:"text",text:QF(s,2)}],...a?{isError:!0}:{}}),i=(s,a)=>{let c=QF(a,2),u=nW(a)?{isError:!0}:{},d=s.maxResultSizeChars??Hpt;return c.length<=d?{content:[{type:"text",text:c}],...u}:(process.stderr.write(`[jaz-mcp] truncating oversized result from ${s.name}: ${c.length} chars > cap ${d}
1004
- `),{content:[{type:"text",text:Jpt(c,d,s.truncationHint)}],...u})};async function o(s,a,c,u,d){let{jotText:f,cleanedInput:p}=Qdt(s,a);if(!e.primaryClient&&!UL(s.group,s.name)){if(e.refreshAuth)try{let E=await e.refreshAuth();e.primaryClient=E.primaryClient,e.authConfigs=E.authConfigs,E.isMultiOrg!==void 0&&(e.isMultiOrg=E.isMultiOrg),E.orgMap&&(e.orgMap=E.orgMap),E.refreshOrgs&&(e.refreshOrgs=E.refreshOrgs),E.primaryClient&&t.sendToolListChanged().catch(()=>{})}catch(E){if(E?.code===bl)return n({error:"The Jaz sign-in file (oauth.json) on this computer is unreadable or damaged.",hint:`Sign in again with ${kp}, which replaces it, or remove it with ${Awe}. Then retry the call.`},!0)}if(!e.primaryClient)return n({error:"No Jaz authentication configured.",hint:`Sign in on this computer with ${kp}, then retry the call. Optional key-based access: ${pCe}. ${fCe}`},!0)}let h=e.primaryClient,m;if(e.isMultiOrg&&!UL(s.group,s.name)){if(e.orgMap.size===0)return n({error:"Organization discovery is unavailable, so this tenant-scoped tool cannot be run safely.",hint:"Retry once organizations resolve, or call list_organizations to refresh."},!0);let E=c;if(!E)if(e.orgMap.size===1)E=e.orgMap.keys().next().value;else return n({error:"Missing org_id. Multiple organizations are accessible; specify which one.",hint:"Call list_organizations to see available orgs, then include org_id.",organizations:[...e.orgMap.values()].map(({name:T,resourceId:D})=>({name:T,resourceId:D}))},!0);let C=e.orgMap.get(E);if(!C)return n({error:`Unknown org_id: "${E}".`,hint:"Call list_organizations to refresh the org list.",available:[...e.orgMap.values()].map(({name:T,resourceId:D})=>({name:T,resourceId:D}))},!0);m=C;let w=e.authConfigs[0];h=w?.mode==="pat"?LUr(w.token,E,w.tokenProvider):C.client}let{input:A,coercions:g}=Odt(s,p),y=x1e(s,A);if(!y.valid){let E=d??(e.operationSurface?void 0:Rdt(s.group)),C=e.flatMode||e.operationSurface&&!d?`The full parameter schema for ${s.name} is its inputSchema in tools/list.`:e.namespaceMode&&E?`Call ${E} { operation: "${s.name}" } with the corrected arguments; that namespace tool's schema lists this operation's parameters.`:`Call describe_tools { tools: ["${s.name}"] } for this operation's full parameter schema.`;return n({error:T1e(s,y.errors),errors:y.errors,hint:C},!0)}let I;if(u!=null){let E=await aIt(u);if(E.error)return n(E.error,!0);I=E.file}try{if(!h&&!UL(s.group,s.name))return n({error:"No API client available.",hint:`Sign in on this computer with ${kp}, then retry the call. Optional key-based access: JAZ_API_KEY or --api-key.`},!0);let E=e.flatMode?"flat":e.operationSurface?"operations":e.namespaceMode?"namespace":"meta",C={client:h,org:m?{resourceId:m.resourceId}:void 0,file_blob:I,mcpSurface:E,...e.transport?{mcpTransport:e.transport}:{}},w=N1e(await s.execute(C,A),[...Bdt(g),...k1e(s,A)]);return f&&h&&!m$(s,A)&&C9(h,s.name,f,w),m&&w&&typeof w=="object"&&!Array.isArray(w)?i(s,{...w,_organization:{name:m.name,resourceId:m.resourceId,currency:m.currency}}):i(s,w)}catch(E){return n(qB(E,{toolName:s.name,input:A,readOnly:s.readOnly||m$(s,A)}),!0)}}return t.setRequestHandler(aL,async s=>{let a=s.params.name,c=s.params.arguments??{};if(e.operationSurface&&(a==="search_tools"||a==="describe_tools"||a==="execute_tool"))throw new Bt(Yt.MethodNotFound,`Unknown tool: ${a}. Call a tool from your tool list.`);if(a==="search_tools"){let f=c.query;if(f!==void 0&&typeof f!="string")return{content:[{type:"text",text:JSON.stringify({error:"Invalid `query` parameter. Expected string."})}],isError:!0};let p=_9(f??"");return{content:[{type:"text",text:JSON.stringify(p,null,2)}]}}if(a==="describe_tools"){let f=Ldt(c.tools);return{content:[{type:"text",text:JSON.stringify(f,null,2)}]}}if(a==="list_organizations"){if(!e.isMultiOrg||e.orgMap.size===0&&!e.refreshOrgs)return{content:[{type:"text",text:JSON.stringify({error:"list_organizations is only available in multi-org mode (PAT or multiple API keys)."})}],isError:!0};let f=e.refreshOrgs;if(f)try{let p=await f();if(p.size>0){e.orgMap.clear();for(let[h,m]of p)e.orgMap.set(h,m)}}catch(p){process.stderr.write(`warning: org refresh failed, using cached list: ${p instanceof Error?p.message:"unknown"}
1004
+ `),{content:[{type:"text",text:Jpt(c,d,s.truncationHint)}],...u})};async function o(s,a,c,u,d){let{jotText:f,cleanedInput:p}=Qdt(s,a);if(!e.primaryClient&&!UL(s.group,s.name)){if(e.refreshAuth)try{let E=await e.refreshAuth();e.primaryClient=E.primaryClient,e.authConfigs=E.authConfigs,E.isMultiOrg!==void 0&&(e.isMultiOrg=E.isMultiOrg),E.orgMap&&(e.orgMap=E.orgMap),E.refreshOrgs&&(e.refreshOrgs=E.refreshOrgs),E.primaryClient&&t.sendToolListChanged().catch(()=>{})}catch(E){if(E?.code===bl)return n({error:"The Jaz sign-in file (oauth.json) on this computer is unreadable or damaged.",hint:`Sign in again with ${kp}, which replaces it, or remove it with ${Awe}. Then retry the call.`},!0)}if(!e.primaryClient)return n({error:"No Jaz authentication configured.",hint:`Sign in on this computer with ${kp}, then retry the call. Optional key-based access: ${pCe}. ${fCe}`},!0)}let h=e.primaryClient,m;if(e.isMultiOrg&&!UL(s.group,s.name)){if(e.orgMap.size===0)return n({error:"Organization discovery is unavailable, so this tenant-scoped tool cannot be run safely.",hint:"Retry once organizations resolve, or call list_organizations to refresh."},!0);let E=c;if(!E)if(e.orgMap.size===1)E=e.orgMap.keys().next().value;else return n({error:"Missing org_id. Multiple organizations are accessible; specify which one.",hint:"Call list_organizations to see available orgs, then include org_id.",organizations:[...e.orgMap.values()].map(({name:T,resourceId:D})=>({name:T,resourceId:D}))},!0);let C=e.orgMap.get(E);if(!C)return n({error:`Unknown org_id: "${E}".`,hint:"Call list_organizations to refresh the org list.",available:[...e.orgMap.values()].map(({name:T,resourceId:D})=>({name:T,resourceId:D}))},!0);m=C;let w=e.authConfigs[0];h=w?.mode==="pat"?LUr(w.token,E,w.tokenProvider,C.client.baseUrl):C.client}let{input:A,coercions:g}=Odt(s,p),y=x1e(s,A);if(!y.valid){let E=d??(e.operationSurface?void 0:Rdt(s.group)),C=e.flatMode||e.operationSurface&&!d?`The full parameter schema for ${s.name} is its inputSchema in tools/list.`:e.namespaceMode&&E?`Call ${E} { operation: "${s.name}" } with the corrected arguments; that namespace tool's schema lists this operation's parameters.`:`Call describe_tools { tools: ["${s.name}"] } for this operation's full parameter schema.`;return n({error:T1e(s,y.errors),errors:y.errors,hint:C},!0)}let I;if(u!=null){let E=await aIt(u);if(E.error)return n(E.error,!0);I=E.file}try{if(!h&&!UL(s.group,s.name))return n({error:"No API client available.",hint:`Sign in on this computer with ${kp}, then retry the call. Optional key-based access: JAZ_API_KEY or --api-key.`},!0);let E=e.flatMode?"flat":e.operationSurface?"operations":e.namespaceMode?"namespace":"meta",C={client:h,org:m?{resourceId:m.resourceId}:void 0,file_blob:I,mcpSurface:E,...e.transport?{mcpTransport:e.transport}:{}},w=N1e(await s.execute(C,A),[...Bdt(g),...k1e(s,A)]);return f&&h&&!m$(s,A)&&C9(h,s.name,f,w),m&&w&&typeof w=="object"&&!Array.isArray(w)?i(s,{...w,_organization:{name:m.name,resourceId:m.resourceId,currency:m.currency}}):i(s,w)}catch(E){return n(qB(E,{toolName:s.name,input:A,readOnly:s.readOnly||m$(s,A)}),!0)}}return t.setRequestHandler(aL,async s=>{let a=s.params.name,c=s.params.arguments??{};if(e.operationSurface&&(a==="search_tools"||a==="describe_tools"||a==="execute_tool"))throw new Bt(Yt.MethodNotFound,`Unknown tool: ${a}. Call a tool from your tool list.`);if(a==="search_tools"){let f=c.query;if(f!==void 0&&typeof f!="string")return{content:[{type:"text",text:JSON.stringify({error:"Invalid `query` parameter. Expected string."})}],isError:!0};let p=_9(f??"");return{content:[{type:"text",text:JSON.stringify(p,null,2)}]}}if(a==="describe_tools"){let f=Ldt(c.tools);return{content:[{type:"text",text:JSON.stringify(f,null,2)}]}}if(a==="list_organizations"){if(!e.isMultiOrg||e.orgMap.size===0&&!e.refreshOrgs)return{content:[{type:"text",text:JSON.stringify({error:"list_organizations is only available in multi-org mode (PAT or multiple API keys)."})}],isError:!0};let f=e.refreshOrgs;if(f)try{let p=await f();if(p.size>0){e.orgMap.clear();for(let[h,m]of p)e.orgMap.set(h,m)}}catch(p){process.stderr.write(`warning: org refresh failed, using cached list: ${p instanceof Error?p.message:"unknown"}
1005
1005
  `)}return{content:[{type:"text",text:JSON.stringify({organizations:[...e.orgMap.values()].map(({name:p,resourceId:h,currency:m})=>({name:p,resourceId:h,currency:m}))},null,2)}]}}if(a==="execute_tool"){let f=c.tool;if(!f)return n({error:"Missing `tool` parameter.",hint:'Call search_tools first, then describe_tools, then execute_tool with { tool: "tool_name", arguments: {...} }.'},!0);let p=Zv(f);if(!p)throw new Bt(Yt.MethodNotFound,Ml(f)??`Unknown tool: ${f}. Use search_tools to find available tools.`);return o(p,c.arguments??{},c.org_id)}if(e.namespaceMode&&dEe(a)){let f=c.operation;if(!f)return n({error:`Missing \`operation\` for the ${a} tool.`,operations:fEe(a,"").operations},!0);let p=fEe(a,f);if(!p.tool)return n({error:p.error,operations:p.operations},!0);if(c.file!==void 0&&c.file!==null&&!p.tool.acceptsHostFile)return n({error:`Operation "${f}" does not ingest files.`,hint:"Pick a file-capable operation (the tool description marks them), or omit `file`."},!0);let h={...c.arguments??{},...typeof c[Pa]=="string"&&fF(p.tool)?{[Pa]:c[Pa]}:{}};return o(p.tool,h,c.org_id,c.file,a)}let u=e.operationSurface?sIt(e.operationSurface,a):Zv(a);if(u){let{[nI]:f,...p}=c,h=u.acceptsHostFile===!0&&!u.params[_p],{[_p]:m,...A}=p;return h?o(u,A,f,m):o(u,p,f)}if(e.operationSurface||e.flatMode||e.namespaceMode)throw new Bt(Yt.MethodNotFound,Ml(a)??`Unknown tool: ${a}. Call a tool from your tool list.`);let d=e.isMultiOrg&&e.orgMap.size>0?"search_tools, describe_tools, execute_tool, list_organizations":"search_tools, describe_tools, execute_tool";throw new Bt(Yt.MethodNotFound,Ml(a)??`Unknown tool: ${a}. Available tools: ${d}.`)}),t}Dg();function IIt(e){e.command("mcp-call <tool>").description("Invoke an MCP tool directly (debug + smoke helper for tools without a CLI shadow). Always emits JSON.").option("--args <json>","JSON-encoded args object passed to the tool","{}").option("--api-key <key>","API key (overrides stored / env)").action(async(t,r)=>{try{if(r.apiKey&&r.org)throw new nr("Cannot use both --api-key and --org. Use one or the other.");let n=Zv(t);if(!n){let a=Ml(t);process.stdout.write(JSON.stringify({error:{kind:"unknown_tool",tool:t,...a?{message:a}:{}}})+`
1006
1006
  `),process.exitCode=1;return}let i;try{i=JSON.parse(r.args??"{}")}catch(a){process.stdout.write(JSON.stringify({error:{kind:"invalid_args_json",message:a.message}})+`
1007
1007
  `),process.exitCode=1;return}let o=zb(i);if(o.length>0){process.stdout.write(JSON.stringify({error:{kind:"validation",message:o.join("; ")}})+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaz-clio",
3
- "version": "9.9.0",
3
+ "version": "9.9.1",
4
4
  "description": "Fastest ledger for agents. Jaz accounting CLI and MCP server: invoicing, bills, payments, quotes & orders, bank reconciliation, fixed assets, inventory, expense claims, tax, reports, and period close.",
5
5
  "type": "module",
6
6
  "bin": {