@agentage/extension-probe 2026.1128.3 → 2026.1128.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentage-container.json +5 -5
- package/dist/agentage-extension.json +9 -9
- package/dist/ui/harness.html +2 -2
- package/dist/ui/harness.js +1 -1
- package/dist/ui/probe.js +1 -1
- package/dist/ui/widgets.json +1 -1
- package/openapi.json +1 -1
- package/package.json +5 -5
- package/probe.mcpc.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "probe",
|
|
3
|
-
"version": "2026.1128.
|
|
4
|
-
"commit": "
|
|
5
|
-
"buildTime": "2026-11-
|
|
3
|
+
"version": "2026.1128.4",
|
|
4
|
+
"commit": "111c44cb37dfa0a738499f6ed2f7b0ff2d21839c",
|
|
5
|
+
"buildTime": "2026-11-28T16:10:49Z",
|
|
6
6
|
"parts": {
|
|
7
7
|
"store": {
|
|
8
8
|
"kind": "postgres",
|
|
9
9
|
"migrations": 1
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
|
-
"image": "ghcr.io/agentage/probe@sha256:
|
|
12
|
+
"image": "ghcr.io/agentage/probe@sha256:66af2c6b845fb4998e826a28889f286c0c1b780b380d913b3d0874b18d5d0c04",
|
|
13
13
|
"openapi": "/api/probe/openapi.json",
|
|
14
14
|
"tools": [
|
|
15
15
|
{
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
{
|
|
22
22
|
"name": "echo",
|
|
23
23
|
"element": "probe-echo",
|
|
24
|
-
"module": "/ui/2026.1128.
|
|
24
|
+
"module": "/ui/2026.1128.4/probe.js"
|
|
25
25
|
}
|
|
26
26
|
],
|
|
27
27
|
"commands": [
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "probe",
|
|
3
|
-
"version": "2026.1128.
|
|
4
|
-
"commit": "
|
|
5
|
-
"buildTime": "2026-11-
|
|
3
|
+
"version": "2026.1128.4",
|
|
4
|
+
"commit": "111c44cb37dfa0a738499f6ed2f7b0ff2d21839c",
|
|
5
|
+
"buildTime": "2026-11-28T16:10:15Z",
|
|
6
6
|
"parts": {
|
|
7
7
|
"pages": {
|
|
8
|
-
"image": "ghcr.io/agentage/probe-pages@sha256:
|
|
8
|
+
"image": "ghcr.io/agentage/probe-pages@sha256:93dd4885da3a974fdfec543fced3cea048ba13e476ded77c784862032fab7413"
|
|
9
9
|
},
|
|
10
10
|
"ui": {
|
|
11
|
-
"image": "ghcr.io/agentage/probe-ui@sha256:
|
|
11
|
+
"image": "ghcr.io/agentage/probe-ui@sha256:7f5058505b9070cb14ca58cfd9e911c88efc7cba1f445d13061dfda47e4078ed"
|
|
12
12
|
},
|
|
13
13
|
"api": {
|
|
14
|
-
"image": "ghcr.io/agentage/probe-api@sha256:
|
|
14
|
+
"image": "ghcr.io/agentage/probe-api@sha256:c8d9512f91904ae4bd0e4db82abfd6f423184852eb79b6fc5edb5feb9b07623b"
|
|
15
15
|
},
|
|
16
16
|
"mcp": {
|
|
17
|
-
"image": "ghcr.io/agentage/probe-mcp@sha256:
|
|
17
|
+
"image": "ghcr.io/agentage/probe-mcp@sha256:64eace54dd4845557d27f36f7b46a0ed33ddd29e8f2174027c251eb92d1085aa"
|
|
18
18
|
},
|
|
19
19
|
"worker": {
|
|
20
|
-
"image": "ghcr.io/agentage/probe-worker@sha256:
|
|
20
|
+
"image": "ghcr.io/agentage/probe-worker@sha256:742635e22f257d61a81f3e022b7cfc79c9d2f44d1ef2431e8ec4b97ca2be6096"
|
|
21
21
|
},
|
|
22
22
|
"store": {
|
|
23
23
|
"kind": "postgres",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
{
|
|
36
36
|
"name": "echo",
|
|
37
37
|
"element": "probe-echo",
|
|
38
|
-
"module": "/ui/2026.1128.
|
|
38
|
+
"module": "/ui/2026.1128.4/probe.js"
|
|
39
39
|
}
|
|
40
40
|
],
|
|
41
41
|
"commands": [
|
package/dist/ui/harness.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<meta name="agentage-extension" content="probe" />
|
|
7
|
-
<meta name="agentage-version" content="2026.1128.
|
|
8
|
-
<title>probe 2026.1128.
|
|
7
|
+
<meta name="agentage-version" content="2026.1128.4" />
|
|
8
|
+
<title>probe 2026.1128.4 widgets</title>
|
|
9
9
|
<style>
|
|
10
10
|
:root {
|
|
11
11
|
color-scheme: dark;
|
package/dist/ui/harness.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var $=(e,t)=>Object.assign(new Error(t),{name:"HostError",code:e});function se(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Pe(e,t){return typeof t=="bigint"?t.toString():t}var ie=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function ce(e){return new ie(e)}function Ae(e){return e==null}function ue(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ae(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Se(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}var le="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function U(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ee(e){if(U(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(U(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}var Ce=new Set(["string","number","symbol"]);function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function G(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function x(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ie(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}function P(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Me(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function I(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function N(e){return typeof e=="string"?e:e?.message}function pe(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;o>=0&&t.push([o,r])}return t}function X(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function A(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:N(e.inst?._zod.def?.error?.(e))??N(i?.(e))??N(t?.error?.(e))??N(r.customError?.(e))??N(r.localeError?.(e))??"Invalid input",s={};for(let u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(s[u]=e[u]);return s.path??(s.path=[]),s.message=a,t?.reportInput&&(s.input=e.input),s}var Jt=/[\uD800-\uDBFF]/;function fe(e){let t=e.length;if(!Jt.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function de(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Oe(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):qt(e,r,n.value)}}function O(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function me(e,t,r){return O(e,t,r,!1)}function qt(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:O(this,t,r.bind(this))},set(n){O(this,t,n)}})}function Yt(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var oe,C=!1,Qt={configurable:!0,get(){C=!0}};function y(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&oe!==e._zod){oe=void 0;return}oe=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Qt);let o=C;C=!1;try{let i=r(this);return C?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),C=C||o,i}catch(i){throw delete this[t],C=C||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Te(e,t,r,n){let o=Yt(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:i})}})}var Re;var he={value:void 0,enumerable:!1},je="captureStackTrace"in Error?Error:null;function er(e){let t=je;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return je=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function m(e,t,r,n){let o={};function i(p){this.def=p,this.constr=f,this.traits=new Set}i.prototype=o;let a=r,s=a&&new WeakSet;function u(p,h){if(p._zod){if(p._zod.traits.has(e))return}else{he.value=new i(h);try{Object.defineProperty(p,"_zod",he)}finally{he.value=void 0}}if(p._zod.traits.add(e),t(p,h),s){let g=Object.getPrototypeOf(p),Z=p._zod.constr.prototype,k=g;for(;k&&k!==Z;)k=Object.getPrototypeOf(k);let j=k??g;s.has(j)||(s.add(j),Oe(j,a))}let d=f.prototype;for(let g in d)Object.prototype.hasOwnProperty.call(d,g)&&(g in p||(p[g]=d[g].bind(p)))}let c=n?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:e});function f(p){let h=n?.Parent?er(l):this;u(h,p);let d=h._zod.deferred;if(d){for(let Z of d)Z();h._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;return g&&g(h),h}return Object.defineProperty(f,"init",{value:u}),Object.defineProperty(f,Symbol.hasInstance,{value:p=>n?.Parent&&p instanceof n.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(f,"name",{value:e}),f}var S=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Re=globalThis).__zod_globalConfig??(Re.__zod_globalConfig={});var L=globalThis.__zod_globalConfig;function E(e){return e&&Object.assign(L,e),L}function tr(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Pe,2)),e.message}function rr(e){this._zod.message=e}var nr={get:tr,set:rr,enumerable:!0,configurable:!0},_e={value:void 0,enumerable:!1},Le=new WeakSet([Object.prototype,Error.prototype]),De=(e,t)=>{e.name="$ZodError",_e.value=t,Object.defineProperty(e,"issues",_e),_e.value=void 0,Object.defineProperty(e,"message",nr);let r=Object.getPrototypeOf(e);Le.has(r)||(Le.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},dn=m("$ZodError",De),B=m("$ZodError",De,void 0,{Parent:Error});var ir=e=>{let t=(r,n,o,i)=>{let a=o?{...o,async:!1}:{async:!1},s=r._zod.run({value:n,issues:[]},a);if(s instanceof Promise)throw new S;if(s.issues.length){let u=new(i?.Err??e)(s.issues.map(c=>A(c,a,E())));throw le(u,i?.callee??t),u}return s.value};return t},xe=ir(B),sr=e=>{let t=async(r,n,o,i)=>{let a=o?{...o,async:!0}:{async:!0},s=r._zod.run({value:n,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let u=new(i?.Err??e)(s.issues.map(c=>A(c,a,E())));throw le(u,i?.callee??t),u}return s.value};return t},$e=sr(B),cr=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new S;return i.issues.length?Ne(e,i.issues,o):{success:!0,data:i.value}},ze=cr(B);function Ne(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>A(o,r,E()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var ur=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?Ne(e,i.issues,o):{success:!0,data:i.value}},ve=ur(B);var Ue=/^[\s\S]{0,}$/;var be=/^-?\d+(?:\.\d+)?$/,Fe=/^(?:true|false)$/i,Be=/^null$/i;var K=m("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ve=e=>{let t=e.value;return!Ae(t)&&t.length!==void 0};var We=m("$ZodCheckMaxLength",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Ve),e._zod.check=n=>{let o=n.value,i=o.length;if((typeof o=="string"&&i>t.maximum?fe(o):i)<=t.maximum)return;let s=de(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ge=m("$ZodCheckMinLength",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Ve),e._zod.check=n=>{let o=n.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?fe(o):i)>=t.minimum)return;let s=de(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}});var ar=m("$ZodCheckStringFormat",(e,t)=>{var r,n;K.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Xe=m("$ZodCheckRegex",(e,t)=>{ar.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var He={major:4,minor:6,patch:7};var b=m("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=He;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let i of o)for(let a of i._zod.onattach)a(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(s,u,c)=>{if(s.memo)return s;let l=P(s),f;for(let p of u){if(p._zod.def.when){if(Me(s)||!p._zod.def.when(s))continue}else if(l)continue;let h=s.issues.length,d=p._zod.check(s);if(d instanceof Promise&&c?.async===!1)throw new S;if(f||d instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await d,s.issues.length!==h&&(X(s.issues,h,e),l||(l=P(s,h)))});else{if(s.issues.length===h)continue;X(s.issues,h,e),l||(l=P(s,h))}}return f?f.then(()=>s):s},a=(s,u,c)=>{if(P(s))return s.aborted=!0,s;let l=i(u,o,c);if(l instanceof Promise){if(c.async===!1)throw new S;return l.then(f=>e._zod.parse(f,c))}return e._zod.parse(l,c)};e._zod.run=(s,u)=>{if(u.skipChecks)return e._zod.parse(s,u);if(u.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...u,skipChecks:!0});return l instanceof Promise?l.then(f=>a(f,s,u)):a(l,s,u)}let c=e._zod.parse(s,u);if(c instanceof Promise){if(u.async===!1)throw new S;return c.then(l=>i(l,o,u))}return i(c,o,u)}}},{get"~standard"(){return me(this,"~standard",dr(this))},set"~standard"(e){O(this,"~standard",e)}}),Qe=(e,t)=>e.issues.length?{issues:e.issues.map(r=>A(r,t,E()))}:{value:e.value};async function fr(e,t){let r={async:!0};return Qe(await e._zod.run({value:t,issues:[]},r),r)}function dr(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Qe(n,r)}catch{}return fr(e,t)},vendor:"zod",version:1}}var et=m("$ZodString",(e,t)=>{b.init(e,t),e._zod.pattern=t.pattern??Ue,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var tt=m("$ZodNumber",(e,t)=>{b.init(e,t),e._zod.pattern=be,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}});var rt=m("$ZodBoolean",(e,t)=>{b.init(e,t),e._zod.pattern=Fe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var nt=m("$ZodNull",(e,t)=>{b.init(e,t),e._zod.pattern=Be,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var ot=m("$ZodUnknown",(e,t)=>{b.init(e,t),e._zod.parse=r=>r});function mr(e,t){let r=pe(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map(i=>i[0])),o=e._zod.parse;e._zod.parse=(i,a)=>{let s=t(i.value);if(s>n&&!a?.skipChecks&&a?.direction!=="backward"){for(let[u,c]of pe(e._zod.def.checks))if(s>u&&c._zod.def.when(i)){let l=i.issues.length;return c._zod.check(i),i.issues[l].continue=!1,X(i.issues,l,e),i}}return o(i,a)}}var hr=e=>Array.isArray(e)?e.length:-1;function Je(e,t,r){e.issues.length&&t.issues.push(...I(r,e.issues)),t.value[r]=e.value}var it=m("$ZodArray",(e,t)=>{b.init(e,t);let r=L.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=r?r.alloc(e,n,Array(i.length),o):Array(i.length);let a=[],s=o?.abortEarly;for(let u=0;u<i.length;u++){let c=i[u],l=t.element._zod.run({value:c,issues:[]},o);if(l instanceof Promise)a.push(l.then(f=>Je(f,n,u)));else if(Je(l,n,u),s&&l.issues.length!==0&&P(l))break}return a.length?Promise.all(a).then(()=>n):n},mr(e,hr)});function H(e,t,r,n,o,i){let a=r in n,s=i==="optional";if(!(!a&&s&&o==="optional")){if(e.issues.length){if(o!==void 0&&s&&!a)return;t.issues.push(...I(r,e.issues))}if(!a&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(a||o==="defaulted"&&!s)&&(t.value[r]=void 0):t.value[r]=e.value}}var gr=[];function _r(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:gr,o=n.length?[...t,...n]:t;for(let a of o)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let i=Ie(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function xr(e,t,r,n,o,i,a){let s=[],u=o.keySet,c=o.catchall._zod,l=c.def.type,f=c.optin,p=c.optout,h=0;for(let d in t){if(a&&r.issues.length!==h){if(P(r,h))break;h=r.issues.length}if(u.has(d))continue;if(d==="__proto__"){l==="never"&&s.push(d);continue}if(l==="never"){s.push(d);continue}let g=c.run({value:t[d],issues:[]},n);g instanceof Promise?e.push(g.then(Z=>H(Z,r,d,t,f,p))):H(g,r,d,t,f,p)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var st=m("$ZodObject",(e,t)=>{b.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let c=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),c.raw=l,l};c.raw=n,Object.defineProperty(t,"shape",{get:c})}let o=ce(()=>_r(t));y(e,"propValues",c=>{let l=c.def.shape,f={};for(let p in l){let h=l[p]._zod;if(h.values){Object.prototype.hasOwnProperty.call(f,p)||ae(f,p,new Set);for(let d of h.values)f[p].add(d);h.optin!==void 0&&f[p].add(void 0)}}return f});let i=U,a=t.catchall,s,u=L.memoizer;u?.attach(e),e._zod.parse=(c,l)=>{s??(s=o.value);let f=c.value;if(!i(f))return c.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),c;c.value=u?u.alloc(e,c,{},l):{};let p=[],h=s.shape,d=l?.abortEarly,g=c.issues.length;for(let Z of s.allKeys){if(d&&c.issues.length!==g){if(P(c,g))break;g=c.issues.length}if(Z==="__proto__")continue;let k=h[Z],j=k._zod.optin,ke=k._zod.optout,ne=k._zod.run({value:f[Z],issues:[]},l);ne instanceof Promise?p.push(ne.then(Ht=>H(Ht,c,Z,f,j,ke))):H(ne,c,Z,f,j,ke)}return a?xr(p,f,c,l,o.value,e,d===!0):p.length?Promise.all(p).then(()=>c):c}});function qe(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!P(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>A(a,n,E())))}),t)}var we=m("$ZodUnion",(e,t)=>{b.init(e,t),y(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),y(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),y(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),y(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>ue(i.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let i=!1,a=[];for(let s of t.options){let u=s._zod.run({value:n.value,issues:[]},o);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(s=>qe(s,n,e,o)):qe(a,n,e,o)}});function $r(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var ct=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,we.init(e,t);let r=e._zod.parse;y(e,"propValues",o=>{let i={},a=0;for(let s of o.def.options){let u=s._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(s)}"`);u[o.def.discriminator]?.has(void 0)&&a++;for(let[c,l]of Object.entries(u)){Object.prototype.hasOwnProperty.call(i,c)||ae(i,c,new Set);for(let f of l)i[c].add(f)}}return!o.def.unionFallback&&a>1&&i[o.def.discriminator]?.delete(void 0),i}),t.options.forEach((o,i)=>{let a=Se(o._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});let n=ce(()=>$r(t));e._zod.parse=(o,i)=>{let a=o.value;if(!U(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;let s=a?.[t.discriminator],u=n.value.get(s);return u&&(s!==void 0||i.direction!=="backward")?u._zod.run(o,i):t.unionFallback||i.direction==="backward"?r(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(c=>n.value.get(c)!==null),input:a,path:[t.discriminator],inst:e}),o)}});var ut=m("$ZodRecord",(e,t)=>{b.init(e,t);let r=L.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Ee(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let a=[],s=t.keyType._zod.values;if(s&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let u=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(u.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let f=t.keyType._zod.run({value:l,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(d=>A(d,o,E())),input:l,path:[l],inst:e});continue}let p=f.value;if(p==="__proto__")continue;let h=t.valueType._zod.run({value:i[l],issues:[]},o);h instanceof Promise?a.push(h.then(d=>{d.issues.length&&n.issues.push(...I(l,d.issues)),n.value[p]=d.value})):(h.issues.length&&n.issues.push(...I(l,h.issues)),n.value[p]=h.value)}let c;for(let l in i)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=i[l]}else c=c??[],c.push(l);c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let u;for(let c of Reflect.ownKeys(i)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&be.test(c)&&l.issues.length){let d=t.keyType._zod.run({value:Number(c),issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){t.mode==="loose"?n.value[c]=i[c]:s?(u=u??[],u.push(c)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>A(d,o,E())),input:c,path:[c],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let h=t.valueType._zod.run({value:i[c],issues:[]},o);h instanceof Promise?a.push(h.then(d=>{d.issues.length&&n.issues.push(...I(c,d.issues)),n.value[p]=d.value})):(h.issues.length&&n.issues.push(...I(c,h.issues)),n.value[p]=h.value)}u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}return a.length?Promise.all(a).then(()=>n):n}});var at=m("$ZodEnum",(e,t)=>{b.init(e,t);let r=se(t.entries),n=new Set(r);e._zod.values=n,y(e,"pattern",o=>{let i=se(o.def.entries).filter(a=>Ce.has(typeof a));return new RegExp(i.length?`^(${i.map(a=>F(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),lt=m("$ZodLiteral",(e,t)=>{b.init(e,t);let r=new Set(t.values);e._zod.values=r,y(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?F(i):i?F(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}});function Ye(e,t){return e.value=t.issues.length?void 0:t.value,e}var pt=m("$ZodOptional",(e,t)=>{b.init(e,t),y(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",y(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),y(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${ue(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(i=>Ye(r,i)):Ye(r,o)}return t.innerType._zod.run(r,n)}});function ft(e){return e.checks&&(e.checks=[...e.checks]),e}function dt(e,t){return new e(ft({type:"string",...x(t)}))}function mt(e,t){return new e(ft({type:"number",checks:[],...x(t)}))}function ht(e,t){return new e({type:"boolean",...x(t)})}function gt(e,t){return new e({type:"null",...x(t)})}function _t(e){return new e({type:"unknown"})}function R(e,t){return new We({check:"max_length",...x(t),maximum:e})}function D(e,t){return new Ge({check:"min_length",...x(t),minimum:e})}function M(e,t){return new Xe({check:"string_format",format:"regex",...x(t),pattern:e})}var w=m("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");b.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){O(this,"with",e)},parse(e,t){return xe(this,e,t,{callee:this.parse})},parseAsync(e,t){return $e(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return ze(this,e,t)},safeParseAsync(e,t){return ve(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0})},clone(e,t){return G(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),br=m("ZodMiniString",(e,t)=>{et.init(e,t),w.init(e,t)});function _(e){return dt(br,e)}var wr=m("ZodMiniNumber",(e,t)=>{tt.init(e,t),w.init(e,t)});function ye(e){return mt(wr,e)}var yr=m("ZodMiniBoolean",(e,t)=>{rt.init(e,t),w.init(e,t)});function $t(e){return ht(yr,e)}var Zr=m("ZodMiniNull",(e,t)=>{nt.init(e,t),w.init(e,t)});function zt(e){return gt(Zr,e)}var kr=m("ZodMiniUnknown",(e,t)=>{ot.init(e,t),w.init(e,t)});function V(){return _t(kr)}var Pr=m("ZodMiniArray",(e,t)=>{it.init(e,t),w.init(e,t)});function J(e,t){return new Pr({type:"array",element:e,...x(t)})}var Ar=m("ZodMiniObject",(e,t)=>{st.init(e,t),w.init(e,t),Te(e,"shape",r=>r._zod.def.shape,!1)});function z(e,t){let r={type:"object",shape:e??{},...x(t)};return new Ar(r)}var Sr=m("ZodMiniUnion",(e,t)=>{we.init(e,t),w.init(e,t)});function vt(e,t){return new Sr({type:"union",options:e,...x(t)})}var Er=m("ZodMiniDiscriminatedUnion",(e,t)=>{ct.init(e,t),w.init(e,t)});function bt(e,t,r){return new Er({type:"union",options:t,discriminator:e,...x(r)})}var xt=m("ZodMiniRecord",(e,t)=>{ut.init(e,t),w.init(e,t)});function wt(e,t,r){return!t||!t._zod?new xt({type:"record",keyType:_(),valueType:e,...x(t)}):new xt({type:"record",keyType:e,valueType:t,...x(r)})}var Cr=m("ZodMiniEnum",(e,t)=>{at.init(e,t),w.init(e,t),e.options=[...e._zod.values]});function yt(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Cr({type:"enum",entries:r,...x(t)})}var Ir=m("ZodMiniLiteral",(e,t)=>{lt.init(e,t),w.init(e,t)});function W(e,t){return new Ir({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}var Mr=m("ZodMiniOptional",(e,t)=>{pt.init(e,t),w.init(e,t)});function v(e){return new Mr({type:"optional",innerType:e})}var Zt=z({code:_(),message:_(),agcid:v(_())}),Ze=z({jsonrpc:v(W("2.0")),id:v(vt([_(),ye(),zt()])),result:v(V()),error:v(z({code:ye(),message:_()}))}),kt=z({content:v(J(V())),structuredContent:v(wt(_(),V())),isError:v($t())}),Pt=z({error:Zt}),At=z({type:W("text"),text:_()}),Y=bt("success",[z({success:W(!0),data:v(V())}),z({success:W(!1),error:Zt})]);var St=3e4,Q=(e={},t=St)=>{let r=AbortSignal.timeout(t);return{...e,signal:e.signal?AbortSignal.any([e.signal,r]):r}},ee=e=>t=>{throw t?.name!=="TimeoutError"?t:$("TIMEOUT",`${e} did not answer in ${St/1e3} s`)};var Rr=(e,t)=>{let r=new Headers(e?.headers);return r.has("Accept")||r.set("Accept","application/json"),t&&r.set("Authorization",`Bearer ${t}`),{...e,headers:r}},jr=async e=>{try{return await e.json()}catch{return}},Lr=(e,t,r)=>e.fetch(t,Q(r)).then(async n=>({res:n,body:await jr(n)})).catch(ee(t)),Et=async(e,t,r)=>{if(!t.startsWith("/"))throw $("BAD_PATH",`api path must start with /: ${t}`);let{res:n,body:o}=await Lr(e,`/api/${e.id}${t}`,Rr(r,await e.token())),i=Y.safeParse(o);if(!i.success)throw $(`HTTP_${n.status}`,`api answered ${n.status}`);if(!i.data.success)throw $(i.data.error.code,i.data.error.message);return i.data.data};var Ct=e=>{let t=e?.getAttribute("data-theme");return t==="light"||t==="dark"?t:globalThis.matchMedia?.("(prefers-color-scheme: light)").matches?"light":"dark"};var Dr=e=>(e.headers.get("content-type")??"").includes("text/event-stream"),It=e=>{try{return JSON.parse(e)}catch{return}},Nr=(e,t)=>{let r=e.split(/\r?\n/).filter(n=>n.startsWith("data:")).map(n=>It(n.slice(5).trim())).map(n=>Ze.safeParse(n)).flatMap(n=>n.success?[n.data]:[]);return r.find(n=>n.id===t)??r.at(-1)},Ur=(e,t)=>{let r=Y.safeParse(e);return r.success&&!r.data.success?$(r.data.error.code,r.data.error.message):$(`HTTP_${t}`,`MCP answered ${t} without a JSON-RPC message`)},Mt=async(e,t)=>{let r=await e.text(),n=Dr(e)?Nr(r,t):It(r),o=Ze.safeParse(n);if(o.success&&(o.data.result!==void 0||o.data.error))return o.data;throw Ur(n,e.status)};var Ot="2026-07-28",Fr=(e,t)=>{let r=new Headers({"Content-Type":"application/json",Accept:"application/json, text/event-stream","MCP-Protocol-Version":Ot,"Mcp-Method":"tools/call","Mcp-Name":e});return t&&r.set("Authorization",`Bearer ${t}`),r},Br=(e,t,r,n)=>({jsonrpc:"2.0",id:e,method:"tools/call",params:{name:t,arguments:r,_meta:{"io.modelcontextprotocol/protocolVersion":Ot,"io.modelcontextprotocol/clientInfo":n.clientInfo,"io.modelcontextprotocol/clientCapabilities":{}}}}),Kr=e=>e.content?.map(t=>At.safeParse(t)).find(t=>t.success)?.data?.text,Vr=e=>{let t=Pt.safeParse(e.structuredContent);return t.success?$(t.data.error.code,t.data.error.message):$("TOOL_ERROR",Kr(e)??"the tool reported an error")},Tt=async(e,t,r)=>{let n=e.nextId(),o=Fr(t,await e.token()),i=JSON.stringify(Br(n,t,r,e)),a=await e.fetch("/mcp",Q({method:"POST",headers:o,body:i})).then(u=>Mt(u,n)).catch(ee(t));if(a.error)throw $(String(a.error.code),a.error.message);let s=kt.safeParse(a.result);if(!s.success)throw $("BAD_RESULT","the tool answered an invalid result");if(s.data.isError)throw Vr(s.data);return s.data.structuredContent??{}};var Rt="0.6.0";var Wr=e=>$("FOREIGN_TOOL",`a ${e} widget calls only ${e}_ tools`),Gr=/^__?[a-z][a-z0-9_-]*$/,Xr=(e,t)=>t.startsWith(e)&&Gr.test(t.slice(e.length)),Hr=()=>Promise.resolve(void 0),Jr=e=>({extension:e.id,version:e.version??"",path:globalThis.location?.pathname??"/",theme:Ct(),props:e.props??{}}),jt=e=>{let t=(e.baseUrl??"").replace(/\/+$/,""),r=(u,c)=>(e.fetch??fetch)(`${t}${u}`,c),n=e.token??Hr,o=0,i={name:e.clientName??"agentage-widget",version:Rt},a={fetch:r,token:n,clientInfo:i,nextId:()=>++o},s={fetch:r,token:n,id:e.id};return{tool:(u,c={})=>Xr(e.id,u)?Tt(a,u,c):Promise.reject(Wr(e.id)),api:(u,c)=>Et(s,u,c),context:Jr(e)}};var Lt=/^[a-z][a-z0-9-]*$/,te=_().check(R(32),M(Lt,"a widget name is lowercase kebab-case")),Dt=_().check(R(32),M(Lt,"an extension id is lowercase kebab-case"));var qr=z({widget:v(te),token:v(_().check(D(1),R(4096))),scope:v(_().check(M(/^[a-z][a-z0-9:_ -]{0,255}$/))),theme:v(yt(["light","dark"]))}),Yr=z({id:Dt,version:_().check(D(1),R(64))}),Nt=(e,t)=>e.querySelector(`meta[name="${t}"]`)?.content,re=(e,t)=>e.get(t)??void 0,Ut=(e,t)=>{let r=Yr.parse({id:Nt(e,"agentage-extension"),version:Nt(e,"agentage-version")}),n=new URLSearchParams(t),o=qr.parse({widget:re(n,"widget"),token:re(n,"token"),scope:re(n,"scope"),theme:re(n,"theme")});return{...r,...o}};var Qr=J(z({name:te,element:_().check(M(/^[a-z][a-z0-9]*(-[a-z0-9-]+)+$/)),module:_()})),Ft=async(e,t)=>{let r=await e(t);if(!r.ok)throw new Error(`widgets.json answered ${r.status}`);return Qr.parse(await r.json())},Bt=(e,t)=>{if(!t)return e;let r=e.filter(n=>n.name===t);if(r.length===0)throw new Error(`no widget named ${t}`);return r},en=(e,t,r)=>{let n=e.createElement(t);return r&&n.setAttribute("data-theme",r),n},Kt=(e,t,r)=>t.map(n=>e.appendChild(en(e.ownerDocument,n.element,r))),Vt=(e,t)=>{let r=e.ownerDocument.createElement("p");r.setAttribute("role","alert"),r.textContent=t,e.append(r)};var tn="http://localhost:4281/token",rn=new Set(["localhost","127.0.0.1"]),nn=z({token:_().check(D(1))}),on=5e3,sn=async e=>{let t=await e.fetch(tn,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:e.scope??`${e.id}:read`}),signal:AbortSignal.timeout(on)});if(!t.ok)throw new Error(`dev issuer answered ${t.status}`);let r=nn.safeParse(await t.json());if(!r.success)throw new Error("dev issuer answered without a token");return r.data.token},Wt=async e=>{if(e.token)return e.token;if(rn.has(e.hostname))try{return await sn(e)}catch(t){e.warn(`agentage harness: no dev token (${t.message}), calling anonymously`);return}};var Gt=(e,t)=>fetch(e,t),cn=()=>{let e=new URL(location.href);e.searchParams.has("token")&&(e.searchParams.delete("token"),history.replaceState(null,"",e))},un=async e=>{let t=Ut(document,location.search);cn();let r=s=>console.warn(s),n={id:t.id,hostname:location.hostname,fetch:Gt,warn:r},o=Wt({...n,token:t.token,scope:t.scope}),i={id:t.id,version:t.version,clientName:"agentage-harness"};globalThis.__agentageHost=()=>jt({...i,token:()=>o}),await import(new URL(`./${t.id}.js`,document.baseURI).href);let a=await Ft(Gt,new URL("./widgets.json",document.baseURI).href);t.theme&&(document.documentElement.dataset.theme=t.theme),Kt(e,Bt(a,t.widget),t.theme)},Xt=document.getElementById("widgets")??document.body;un(Xt).catch(e=>Vt(Xt,`harness: ${e.message}`));
|
|
1
|
+
var $=(e,t)=>Object.assign(new Error(t),{name:"HostError",code:e});function se(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Pe(e,t){return typeof t=="bigint"?t.toString():t}var ie=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function ce(e){return new ie(e)}function Ae(e){return e==null}function ue(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ae(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Se(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}var le="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function U(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ee(e){if(U(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(U(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}var Ce=new Set(["string","number","symbol"]);function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function G(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function x(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ie(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}function P(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Me(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function I(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function N(e){return typeof e=="string"?e:e?.message}function pe(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;o>=0&&t.push([o,r])}return t}function X(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function A(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:N(e.inst?._zod.def?.error?.(e))??N(i?.(e))??N(t?.error?.(e))??N(r.customError?.(e))??N(r.localeError?.(e))??"Invalid input",s={};for(let u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(s[u]=e[u]);return s.path??(s.path=[]),s.message=a,t?.reportInput&&(s.input=e.input),s}var Jt=/[\uD800-\uDBFF]/;function fe(e){let t=e.length;if(!Jt.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function de(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Oe(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):qt(e,r,n.value)}}function O(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function me(e,t,r){return O(e,t,r,!1)}function qt(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:O(this,t,r.bind(this))},set(n){O(this,t,n)}})}function Yt(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var oe,C=!1,Qt={configurable:!0,get(){C=!0}};function y(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&oe!==e._zod){oe=void 0;return}oe=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Qt);let o=C;C=!1;try{let i=r(this);return C?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),C=C||o,i}catch(i){throw delete this[t],C=C||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Te(e,t,r,n){let o=Yt(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:i})}})}var Re;var he={value:void 0,enumerable:!1},je="captureStackTrace"in Error?Error:null;function er(e){let t=je;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return je=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function m(e,t,r,n){let o={};function i(p){this.def=p,this.constr=f,this.traits=new Set}i.prototype=o;let a=r,s=a&&new WeakSet;function u(p,h){if(p._zod){if(p._zod.traits.has(e))return}else{he.value=new i(h);try{Object.defineProperty(p,"_zod",he)}finally{he.value=void 0}}if(p._zod.traits.add(e),t(p,h),s){let g=Object.getPrototypeOf(p),Z=p._zod.constr.prototype,k=g;for(;k&&k!==Z;)k=Object.getPrototypeOf(k);let j=k??g;s.has(j)||(s.add(j),Oe(j,a))}let d=f.prototype;for(let g in d)Object.prototype.hasOwnProperty.call(d,g)&&(g in p||(p[g]=d[g].bind(p)))}let c=n?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:e});function f(p){let h=n?.Parent?er(l):this;u(h,p);let d=h._zod.deferred;if(d){for(let Z of d)Z();h._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;return g&&g(h),h}return Object.defineProperty(f,"init",{value:u}),Object.defineProperty(f,Symbol.hasInstance,{value:p=>n?.Parent&&p instanceof n.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(f,"name",{value:e}),f}var S=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Re=globalThis).__zod_globalConfig??(Re.__zod_globalConfig={});var L=globalThis.__zod_globalConfig;function E(e){return e&&Object.assign(L,e),L}function tr(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Pe,2)),e.message}function rr(e){this._zod.message=e}var nr={get:tr,set:rr,enumerable:!0,configurable:!0},_e={value:void 0,enumerable:!1},Le=new WeakSet([Object.prototype,Error.prototype]),De=(e,t)=>{e.name="$ZodError",_e.value=t,Object.defineProperty(e,"issues",_e),_e.value=void 0,Object.defineProperty(e,"message",nr);let r=Object.getPrototypeOf(e);Le.has(r)||(Le.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},dn=m("$ZodError",De),B=m("$ZodError",De,void 0,{Parent:Error});var ir=e=>{let t=(r,n,o,i)=>{let a=o?{...o,async:!1}:{async:!1},s=r._zod.run({value:n,issues:[]},a);if(s instanceof Promise)throw new S;if(s.issues.length){let u=new(i?.Err??e)(s.issues.map(c=>A(c,a,E())));throw le(u,i?.callee??t),u}return s.value};return t},xe=ir(B),sr=e=>{let t=async(r,n,o,i)=>{let a=o?{...o,async:!0}:{async:!0},s=r._zod.run({value:n,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let u=new(i?.Err??e)(s.issues.map(c=>A(c,a,E())));throw le(u,i?.callee??t),u}return s.value};return t},$e=sr(B),cr=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new S;return i.issues.length?Ne(e,i.issues,o):{success:!0,data:i.value}},ze=cr(B);function Ne(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>A(o,r,E()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var ur=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?Ne(e,i.issues,o):{success:!0,data:i.value}},ve=ur(B);var Ue=/^[\s\S]{0,}$/;var be=/^-?\d+(?:\.\d+)?$/,Fe=/^(?:true|false)$/i,Be=/^null$/i;var K=m("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ve=e=>{let t=e.value;return!Ae(t)&&t.length!==void 0};var We=m("$ZodCheckMaxLength",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Ve),e._zod.check=n=>{let o=n.value,i=o.length;if((typeof o=="string"&&i>t.maximum?fe(o):i)<=t.maximum)return;let s=de(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ge=m("$ZodCheckMinLength",(e,t)=>{var r;K.init(e,t),(r=e._zod.def).when??(r.when=Ve),e._zod.check=n=>{let o=n.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?fe(o):i)>=t.minimum)return;let s=de(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}});var ar=m("$ZodCheckStringFormat",(e,t)=>{var r,n;K.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Xe=m("$ZodCheckRegex",(e,t)=>{ar.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var He={major:4,minor:6,patch:7};var b=m("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=He;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let i of o)for(let a of i._zod.onattach)a(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(s,u,c)=>{if(s.memo)return s;let l=P(s),f;for(let p of u){if(p._zod.def.when){if(Me(s)||!p._zod.def.when(s))continue}else if(l)continue;let h=s.issues.length,d=p._zod.check(s);if(d instanceof Promise&&c?.async===!1)throw new S;if(f||d instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await d,s.issues.length!==h&&(X(s.issues,h,e),l||(l=P(s,h)))});else{if(s.issues.length===h)continue;X(s.issues,h,e),l||(l=P(s,h))}}return f?f.then(()=>s):s},a=(s,u,c)=>{if(P(s))return s.aborted=!0,s;let l=i(u,o,c);if(l instanceof Promise){if(c.async===!1)throw new S;return l.then(f=>e._zod.parse(f,c))}return e._zod.parse(l,c)};e._zod.run=(s,u)=>{if(u.skipChecks)return e._zod.parse(s,u);if(u.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...u,skipChecks:!0});return l instanceof Promise?l.then(f=>a(f,s,u)):a(l,s,u)}let c=e._zod.parse(s,u);if(c instanceof Promise){if(u.async===!1)throw new S;return c.then(l=>i(l,o,u))}return i(c,o,u)}}},{get"~standard"(){return me(this,"~standard",dr(this))},set"~standard"(e){O(this,"~standard",e)}}),Qe=(e,t)=>e.issues.length?{issues:e.issues.map(r=>A(r,t,E()))}:{value:e.value};async function fr(e,t){let r={async:!0};return Qe(await e._zod.run({value:t,issues:[]},r),r)}function dr(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Qe(n,r)}catch{}return fr(e,t)},vendor:"zod",version:1}}var et=m("$ZodString",(e,t)=>{b.init(e,t),e._zod.pattern=t.pattern??Ue,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var tt=m("$ZodNumber",(e,t)=>{b.init(e,t),e._zod.pattern=be,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}});var rt=m("$ZodBoolean",(e,t)=>{b.init(e,t),e._zod.pattern=Fe,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var nt=m("$ZodNull",(e,t)=>{b.init(e,t),e._zod.pattern=Be,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var ot=m("$ZodUnknown",(e,t)=>{b.init(e,t),e._zod.parse=r=>r});function mr(e,t){let r=pe(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map(i=>i[0])),o=e._zod.parse;e._zod.parse=(i,a)=>{let s=t(i.value);if(s>n&&!a?.skipChecks&&a?.direction!=="backward"){for(let[u,c]of pe(e._zod.def.checks))if(s>u&&c._zod.def.when(i)){let l=i.issues.length;return c._zod.check(i),i.issues[l].continue=!1,X(i.issues,l,e),i}}return o(i,a)}}var hr=e=>Array.isArray(e)?e.length:-1;function Je(e,t,r){e.issues.length&&t.issues.push(...I(r,e.issues)),t.value[r]=e.value}var it=m("$ZodArray",(e,t)=>{b.init(e,t);let r=L.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=r?r.alloc(e,n,Array(i.length),o):Array(i.length);let a=[],s=o?.abortEarly;for(let u=0;u<i.length;u++){let c=i[u],l=t.element._zod.run({value:c,issues:[]},o);if(l instanceof Promise)a.push(l.then(f=>Je(f,n,u)));else if(Je(l,n,u),s&&l.issues.length!==0&&P(l))break}return a.length?Promise.all(a).then(()=>n):n},mr(e,hr)});function H(e,t,r,n,o,i){let a=r in n,s=i==="optional";if(!(!a&&s&&o==="optional")){if(e.issues.length){if(o!==void 0&&s&&!a)return;t.issues.push(...I(r,e.issues))}if(!a&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(a||o==="defaulted"&&!s)&&(t.value[r]=void 0):t.value[r]=e.value}}var gr=[];function _r(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:gr,o=n.length?[...t,...n]:t;for(let a of o)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let i=Ie(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function xr(e,t,r,n,o,i,a){let s=[],u=o.keySet,c=o.catchall._zod,l=c.def.type,f=c.optin,p=c.optout,h=0;for(let d in t){if(a&&r.issues.length!==h){if(P(r,h))break;h=r.issues.length}if(u.has(d))continue;if(d==="__proto__"){l==="never"&&s.push(d);continue}if(l==="never"){s.push(d);continue}let g=c.run({value:t[d],issues:[]},n);g instanceof Promise?e.push(g.then(Z=>H(Z,r,d,t,f,p))):H(g,r,d,t,f,p)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var st=m("$ZodObject",(e,t)=>{b.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let c=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),c.raw=l,l};c.raw=n,Object.defineProperty(t,"shape",{get:c})}let o=ce(()=>_r(t));y(e,"propValues",c=>{let l=c.def.shape,f={};for(let p in l){let h=l[p]._zod;if(h.values){Object.prototype.hasOwnProperty.call(f,p)||ae(f,p,new Set);for(let d of h.values)f[p].add(d);h.optin!==void 0&&f[p].add(void 0)}}return f});let i=U,a=t.catchall,s,u=L.memoizer;u?.attach(e),e._zod.parse=(c,l)=>{s??(s=o.value);let f=c.value;if(!i(f))return c.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),c;c.value=u?u.alloc(e,c,{},l):{};let p=[],h=s.shape,d=l?.abortEarly,g=c.issues.length;for(let Z of s.allKeys){if(d&&c.issues.length!==g){if(P(c,g))break;g=c.issues.length}if(Z==="__proto__")continue;let k=h[Z],j=k._zod.optin,ke=k._zod.optout,ne=k._zod.run({value:f[Z],issues:[]},l);ne instanceof Promise?p.push(ne.then(Ht=>H(Ht,c,Z,f,j,ke))):H(ne,c,Z,f,j,ke)}return a?xr(p,f,c,l,o.value,e,d===!0):p.length?Promise.all(p).then(()=>c):c}});function qe(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!P(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>A(a,n,E())))}),t)}var we=m("$ZodUnion",(e,t)=>{b.init(e,t),y(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),y(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),y(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),y(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>ue(i.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let i=!1,a=[];for(let s of t.options){let u=s._zod.run({value:n.value,issues:[]},o);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(s=>qe(s,n,e,o)):qe(a,n,e,o)}});function $r(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var ct=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,we.init(e,t);let r=e._zod.parse;y(e,"propValues",o=>{let i={},a=0;for(let s of o.def.options){let u=s._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(s)}"`);u[o.def.discriminator]?.has(void 0)&&a++;for(let[c,l]of Object.entries(u)){Object.prototype.hasOwnProperty.call(i,c)||ae(i,c,new Set);for(let f of l)i[c].add(f)}}return!o.def.unionFallback&&a>1&&i[o.def.discriminator]?.delete(void 0),i}),t.options.forEach((o,i)=>{let a=Se(o._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});let n=ce(()=>$r(t));e._zod.parse=(o,i)=>{let a=o.value;if(!U(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;let s=a?.[t.discriminator],u=n.value.get(s);return u&&(s!==void 0||i.direction!=="backward")?u._zod.run(o,i):t.unionFallback||i.direction==="backward"?r(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(c=>n.value.get(c)!==null),input:a,path:[t.discriminator],inst:e}),o)}});var ut=m("$ZodRecord",(e,t)=>{b.init(e,t);let r=L.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Ee(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let a=[],s=t.keyType._zod.values;if(s&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let u=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(u.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let f=t.keyType._zod.run({value:l,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(d=>A(d,o,E())),input:l,path:[l],inst:e});continue}let p=f.value;if(p==="__proto__")continue;let h=t.valueType._zod.run({value:i[l],issues:[]},o);h instanceof Promise?a.push(h.then(d=>{d.issues.length&&n.issues.push(...I(l,d.issues)),n.value[p]=d.value})):(h.issues.length&&n.issues.push(...I(l,h.issues)),n.value[p]=h.value)}let c;for(let l in i)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=i[l]}else c=c??[],c.push(l);c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let u;for(let c of Reflect.ownKeys(i)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&be.test(c)&&l.issues.length){let d=t.keyType._zod.run({value:Number(c),issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){t.mode==="loose"?n.value[c]=i[c]:s?(u=u??[],u.push(c)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>A(d,o,E())),input:c,path:[c],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let h=t.valueType._zod.run({value:i[c],issues:[]},o);h instanceof Promise?a.push(h.then(d=>{d.issues.length&&n.issues.push(...I(c,d.issues)),n.value[p]=d.value})):(h.issues.length&&n.issues.push(...I(c,h.issues)),n.value[p]=h.value)}u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}return a.length?Promise.all(a).then(()=>n):n}});var at=m("$ZodEnum",(e,t)=>{b.init(e,t);let r=se(t.entries),n=new Set(r);e._zod.values=n,y(e,"pattern",o=>{let i=se(o.def.entries).filter(a=>Ce.has(typeof a));return new RegExp(i.length?`^(${i.map(a=>F(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),lt=m("$ZodLiteral",(e,t)=>{b.init(e,t);let r=new Set(t.values);e._zod.values=r,y(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?F(i):i?F(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}});function Ye(e,t){return e.value=t.issues.length?void 0:t.value,e}var pt=m("$ZodOptional",(e,t)=>{b.init(e,t),y(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",y(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),y(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${ue(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(i=>Ye(r,i)):Ye(r,o)}return t.innerType._zod.run(r,n)}});function ft(e){return e.checks&&(e.checks=[...e.checks]),e}function dt(e,t){return new e(ft({type:"string",...x(t)}))}function mt(e,t){return new e(ft({type:"number",checks:[],...x(t)}))}function ht(e,t){return new e({type:"boolean",...x(t)})}function gt(e,t){return new e({type:"null",...x(t)})}function _t(e){return new e({type:"unknown"})}function R(e,t){return new We({check:"max_length",...x(t),maximum:e})}function D(e,t){return new Ge({check:"min_length",...x(t),minimum:e})}function M(e,t){return new Xe({check:"string_format",format:"regex",...x(t),pattern:e})}var w=m("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");b.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){O(this,"with",e)},parse(e,t){return xe(this,e,t,{callee:this.parse})},parseAsync(e,t){return $e(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return ze(this,e,t)},safeParseAsync(e,t){return ve(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0})},clone(e,t){return G(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),br=m("ZodMiniString",(e,t)=>{et.init(e,t),w.init(e,t)});function _(e){return dt(br,e)}var wr=m("ZodMiniNumber",(e,t)=>{tt.init(e,t),w.init(e,t)});function ye(e){return mt(wr,e)}var yr=m("ZodMiniBoolean",(e,t)=>{rt.init(e,t),w.init(e,t)});function $t(e){return ht(yr,e)}var Zr=m("ZodMiniNull",(e,t)=>{nt.init(e,t),w.init(e,t)});function zt(e){return gt(Zr,e)}var kr=m("ZodMiniUnknown",(e,t)=>{ot.init(e,t),w.init(e,t)});function V(){return _t(kr)}var Pr=m("ZodMiniArray",(e,t)=>{it.init(e,t),w.init(e,t)});function J(e,t){return new Pr({type:"array",element:e,...x(t)})}var Ar=m("ZodMiniObject",(e,t)=>{st.init(e,t),w.init(e,t),Te(e,"shape",r=>r._zod.def.shape,!1)});function z(e,t){let r={type:"object",shape:e??{},...x(t)};return new Ar(r)}var Sr=m("ZodMiniUnion",(e,t)=>{we.init(e,t),w.init(e,t)});function vt(e,t){return new Sr({type:"union",options:e,...x(t)})}var Er=m("ZodMiniDiscriminatedUnion",(e,t)=>{ct.init(e,t),w.init(e,t)});function bt(e,t,r){return new Er({type:"union",options:t,discriminator:e,...x(r)})}var xt=m("ZodMiniRecord",(e,t)=>{ut.init(e,t),w.init(e,t)});function wt(e,t,r){return!t||!t._zod?new xt({type:"record",keyType:_(),valueType:e,...x(t)}):new xt({type:"record",keyType:e,valueType:t,...x(r)})}var Cr=m("ZodMiniEnum",(e,t)=>{at.init(e,t),w.init(e,t),e.options=[...e._zod.values]});function yt(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Cr({type:"enum",entries:r,...x(t)})}var Ir=m("ZodMiniLiteral",(e,t)=>{lt.init(e,t),w.init(e,t)});function W(e,t){return new Ir({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}var Mr=m("ZodMiniOptional",(e,t)=>{pt.init(e,t),w.init(e,t)});function v(e){return new Mr({type:"optional",innerType:e})}var Zt=z({code:_(),message:_(),agcid:v(_())}),Ze=z({jsonrpc:v(W("2.0")),id:v(vt([_(),ye(),zt()])),result:v(V()),error:v(z({code:ye(),message:_()}))}),kt=z({content:v(J(V())),structuredContent:v(wt(_(),V())),isError:v($t())}),Pt=z({error:Zt}),At=z({type:W("text"),text:_()}),Y=bt("success",[z({success:W(!0),data:v(V())}),z({success:W(!1),error:Zt})]);var St=3e4,Q=(e={},t=St)=>{let r=AbortSignal.timeout(t);return{...e,signal:e.signal?AbortSignal.any([e.signal,r]):r}},ee=e=>t=>{throw t?.name!=="TimeoutError"?t:$("TIMEOUT",`${e} did not answer in ${St/1e3} s`)};var Rr=(e,t)=>{let r=new Headers(e?.headers);return r.has("Accept")||r.set("Accept","application/json"),t&&r.set("Authorization",`Bearer ${t}`),{...e,headers:r}},jr=async e=>{try{return await e.json()}catch{return}},Lr=(e,t,r)=>e.fetch(t,Q(r)).then(async n=>({res:n,body:await jr(n)})).catch(ee(t)),Et=async(e,t,r)=>{if(!t.startsWith("/"))throw $("BAD_PATH",`api path must start with /: ${t}`);let{res:n,body:o}=await Lr(e,`/api/${e.id}${t}`,Rr(r,await e.token())),i=Y.safeParse(o);if(!i.success)throw $(`HTTP_${n.status}`,`api answered ${n.status}`);if(!i.data.success)throw $(i.data.error.code,i.data.error.message);return i.data.data};var Ct=e=>{let t=e?.getAttribute("data-theme");return t==="light"||t==="dark"?t:globalThis.matchMedia?.("(prefers-color-scheme: light)").matches?"light":"dark"};var Dr=e=>(e.headers.get("content-type")??"").includes("text/event-stream"),It=e=>{try{return JSON.parse(e)}catch{return}},Nr=(e,t)=>{let r=e.split(/\r?\n/).filter(n=>n.startsWith("data:")).map(n=>It(n.slice(5).trim())).map(n=>Ze.safeParse(n)).flatMap(n=>n.success?[n.data]:[]);return r.find(n=>n.id===t)??r.at(-1)},Ur=(e,t)=>{let r=Y.safeParse(e);return r.success&&!r.data.success?$(r.data.error.code,r.data.error.message):$(`HTTP_${t}`,`MCP answered ${t} without a JSON-RPC message`)},Mt=async(e,t)=>{let r=await e.text(),n=Dr(e)?Nr(r,t):It(r),o=Ze.safeParse(n);if(o.success&&(o.data.result!==void 0||o.data.error))return o.data;throw Ur(n,e.status)};var Ot="2026-07-28",Fr=(e,t)=>{let r=new Headers({"Content-Type":"application/json",Accept:"application/json, text/event-stream","MCP-Protocol-Version":Ot,"Mcp-Method":"tools/call","Mcp-Name":e});return t&&r.set("Authorization",`Bearer ${t}`),r},Br=(e,t,r,n)=>({jsonrpc:"2.0",id:e,method:"tools/call",params:{name:t,arguments:r,_meta:{"io.modelcontextprotocol/protocolVersion":Ot,"io.modelcontextprotocol/clientInfo":n.clientInfo,"io.modelcontextprotocol/clientCapabilities":{}}}}),Kr=e=>e.content?.map(t=>At.safeParse(t)).find(t=>t.success)?.data?.text,Vr=e=>{let t=Pt.safeParse(e.structuredContent);return t.success?$(t.data.error.code,t.data.error.message):$("TOOL_ERROR",Kr(e)??"the tool reported an error")},Tt=async(e,t,r)=>{let n=e.nextId(),o=Fr(t,await e.token()),i=JSON.stringify(Br(n,t,r,e)),a=await e.fetch("/mcp",Q({method:"POST",headers:o,body:i})).then(u=>Mt(u,n)).catch(ee(t));if(a.error)throw $(String(a.error.code),a.error.message);let s=kt.safeParse(a.result);if(!s.success)throw $("BAD_RESULT","the tool answered an invalid result");if(s.data.isError)throw Vr(s.data);return s.data.structuredContent??{}};var Rt="0.7.0";var Wr=e=>$("FOREIGN_TOOL",`a ${e} widget calls only ${e}_ tools`),Gr=/^_[a-z][a-z0-9_-]*$/,Xr=(e,t)=>t.startsWith(e)&&Gr.test(t.slice(e.length)),Hr=()=>Promise.resolve(void 0),Jr=e=>({extension:e.id,version:e.version??"",path:globalThis.location?.pathname??"/",theme:Ct(),props:e.props??{}}),jt=e=>{let t=(e.baseUrl??"").replace(/\/+$/,""),r=(u,c)=>(e.fetch??fetch)(`${t}${u}`,c),n=e.token??Hr,o=0,i={name:e.clientName??"agentage-widget",version:Rt},a={fetch:r,token:n,clientInfo:i,nextId:()=>++o},s={fetch:r,token:n,id:e.id};return{tool:(u,c={})=>Xr(e.id,u)?Tt(a,u,c):Promise.reject(Wr(e.id)),api:(u,c)=>Et(s,u,c),context:Jr(e)}};var Lt=/^[a-z][a-z0-9-]*$/,te=_().check(R(32),M(Lt,"a widget name is lowercase kebab-case")),Dt=_().check(R(32),M(Lt,"an extension id is lowercase kebab-case"));var qr=z({widget:v(te),token:v(_().check(D(1),R(4096))),scope:v(_().check(M(/^[a-z][a-z0-9:_ -]{0,255}$/))),theme:v(yt(["light","dark"]))}),Yr=z({id:Dt,version:_().check(D(1),R(64))}),Nt=(e,t)=>e.querySelector(`meta[name="${t}"]`)?.content,re=(e,t)=>e.get(t)??void 0,Ut=(e,t)=>{let r=Yr.parse({id:Nt(e,"agentage-extension"),version:Nt(e,"agentage-version")}),n=new URLSearchParams(t),o=qr.parse({widget:re(n,"widget"),token:re(n,"token"),scope:re(n,"scope"),theme:re(n,"theme")});return{...r,...o}};var Qr=J(z({name:te,element:_().check(M(/^[a-z][a-z0-9]*(-[a-z0-9-]+)+$/)),module:_()})),Ft=async(e,t)=>{let r=await e(t);if(!r.ok)throw new Error(`widgets.json answered ${r.status}`);return Qr.parse(await r.json())},Bt=(e,t)=>{if(!t)return e;let r=e.filter(n=>n.name===t);if(r.length===0)throw new Error(`no widget named ${t}`);return r},en=(e,t,r)=>{let n=e.createElement(t);return r&&n.setAttribute("data-theme",r),n},Kt=(e,t,r)=>t.map(n=>e.appendChild(en(e.ownerDocument,n.element,r))),Vt=(e,t)=>{let r=e.ownerDocument.createElement("p");r.setAttribute("role","alert"),r.textContent=t,e.append(r)};var tn="http://localhost:4281/token",rn=new Set(["localhost","127.0.0.1"]),nn=z({token:_().check(D(1))}),on=5e3,sn=async e=>{let t=await e.fetch(tn,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:e.scope??`${e.id}:read`}),signal:AbortSignal.timeout(on)});if(!t.ok)throw new Error(`dev issuer answered ${t.status}`);let r=nn.safeParse(await t.json());if(!r.success)throw new Error("dev issuer answered without a token");return r.data.token},Wt=async e=>{if(e.token)return e.token;if(rn.has(e.hostname))try{return await sn(e)}catch(t){e.warn(`agentage harness: no dev token (${t.message}), calling anonymously`);return}};var Gt=(e,t)=>fetch(e,t),cn=()=>{let e=new URL(location.href);e.searchParams.has("token")&&(e.searchParams.delete("token"),history.replaceState(null,"",e))},un=async e=>{let t=Ut(document,location.search);cn();let r=s=>console.warn(s),n={id:t.id,hostname:location.hostname,fetch:Gt,warn:r},o=Wt({...n,token:t.token,scope:t.scope}),i={id:t.id,version:t.version,clientName:"agentage-harness"};globalThis.__agentageHost=()=>jt({...i,token:()=>o}),await import(new URL(`./${t.id}.js`,document.baseURI).href);let a=await Ft(Gt,new URL("./widgets.json",document.baseURI).href);t.theme&&(document.documentElement.dataset.theme=t.theme),Kt(e,Bt(a,t.widget),t.theme)},Xt=document.getElementById("widgets")??document.body;un(Xt).catch(e=>Vt(Xt,`harness: ${e.message}`));
|