@superglue/cli 1.1.103 → 1.1.104

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "superglue",
3
3
  "description": "Build, test, and manage superglue tools via the sg CLI. Use when working with superglue tools, systems, APIs, SDKs, or the sg command.",
4
- "version": "1.1.103",
4
+ "version": "1.1.104",
5
5
  "author": {
6
6
  "name": "superglue",
7
7
  "email": "hello@superglue.cloud"
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ attempted value: ${n}
10
10
  return {};
11
11
  }`;if(e==="$")return`(sourceData) => {
12
12
  return sourceData;
13
- }`;if(vC(e))return e;throw e.startsWith("//")?new Error(`Found comment in code: ${e}.`):new Error(`Invalid arrow function: ${e}. Expected a valid arrow function.`)}var $J=["accesstoken","refreshtoken","apikey","apisecret","bearertoken","token","clientsecret","secretaccesskey","secretkey","password","pass","secret","privatekey","oauthkey","oauthcert"];function wC(o){return o.toLowerCase().replace(/[_\-\s]/g,"")}B.CREDENTIAL_KEY_PATTERN=/^[A-Za-z_][A-Za-z0-9_]*$/;B.CREDENTIAL_KEY_VALIDATION_DESCRIPTION="Credential keys must start with a letter or underscore and contain only letters, numbers, and underscores.";function xC(o){return B.CREDENTIAL_KEY_PATTERN.test(o)}function zC(o){return o.trim()?xC(o)?null:B.CREDENTIAL_KEY_VALIDATION_DESCRIPTION:"Credential key is required."}function HJ(o){return[...o].filter(e=>!!zC(e))}var GJ=o=>{let e=wC(o);return $J.some(t=>e===t||e.endsWith(t))};B.isSensitiveCredentialKey=GJ;var VJ=(o,e)=>e==null||e===""?"":B.FULLY_MASKED_CREDENTIAL_VALUE;B.maskCredentialValue=VJ;B.FULLY_MASKED_CREDENTIAL_VALUE="****";function qC(o){return o==null?!1:typeof o=="string"?o.trim().length>0:!0}function YJ(o,e){return!!o?.some(t=>t.key===e&&t.hasValue)}function JJ(o){return Object.entries(o||{}).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:e,hasValue:qC(t)}))}function WJ(o,e){let t=new Set(e.filter(a=>a.hasValue).map(a=>a.key));return[...new Set(o||[])].filter(a=>!t.has(a))}function EC(o){return o===B.FULLY_MASKED_CREDENTIAL_VALUE}function ZJ(o){return o?Object.fromEntries(Object.entries(o).filter(([,e])=>e!=null&&e!=="").map(([e])=>[e,B.FULLY_MASKED_CREDENTIAL_VALUE])):{}}function KJ({incoming:o,existing:e}){if(!o)return{};let t={};for(let[a,i]of Object.entries(o)){if(EC(i)){let r=e?.[a];r!=null&&r!==""&&(t[a]=r);continue}t[a]=i}return t}function EA(o){if(typeof o!="string")return!1;let e=o.trim();return!!(e.startsWith("<<")&&e.endsWith(">>")||e.startsWith("{masked_")&&e.endsWith("}"))}function XJ(o,e){if(!o||Object.keys(o).length===0)return e||{};if(!e||Object.keys(e).length===0)return Object.fromEntries(Object.entries(o).filter(([a,i])=>!EA(i)&&i!==!0));let t={...e};for(let[a,i]of Object.entries(o))EA(i)||i!==!0&&(t[a]=i);return t}function IC(o,e){if(!e)return o;let t=o,a=[],i=0;Object.entries(e).sort(([,r],[,n])=>String(n).length-String(r).length).forEach(([r,n])=>{let s=String(n);if(n&&s){let c=`\0MASK_${i++}\0`;a.push([c,`{masked_${r}}`]);let m=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");t=t.replace(m,c)}});for(let[r,n]of a)t=t.split(r).join(n);return t}function eW(o){let e={};for(let t of o)for(let[a,i]of Object.entries(t.credentials||{}))(0,B.isSensitiveCredentialKey)(a)&&i!==null&&i!==void 0&&i!==""&&(e[`${t.id}_${a}`]=String(i));return e}function IA(o,e){if(o==null)return o;if(typeof o=="string")return IC(o,e);if(typeof o!="object")return o;if(Array.isArray(o))return o.map(a=>IA(a,e));let t={};for(let[a,i]of Object.entries(o))t[a]=IA(i,e);return t}B.MAX_INLINE_RESULT_PREVIEW_BYTES=5*1024*1024;B.MAX_STRING_PREVIEW_LENGTH=3e3;B.MAX_ARRAY_PREVIEW_ITEMS=10;B.MAX_TRUNCATION_DEPTH=10;B.MAX_OBJECT_PREVIEW_KEYS=100;var oW=8,tW=100,aW=100;function iW(o){let e=new WeakSet,t=(a,i)=>{if(a==null)return 0;if(typeof a=="string")return new TextEncoder().encode(a).byteLength;if(typeof a=="number"||typeof a=="boolean")return 8;if(typeof a=="bigint")return String(a).length;if(typeof a=="function"||typeof a=="symbol")return 0;if(a instanceof Date)return 24;if(a instanceof Error)return(a.message?.length||0)+(a.stack?.length||0);if(typeof a!="object"||e.has(a)||(e.add(a),i>oW))return 0;if(Array.isArray(a)){let m=a.length*2,l=Math.min(a.length,tW),u=0;for(let d=0;d<l;d++)u+=t(a[d],i+1);return l===0||l===a.length?m+u:m+Math.round(u/l*a.length)}let r=2,n=Object.keys(a),s=Math.min(n.length,aW),c=0;for(let m=0;m<s;m++){let l=n[m];c+=l.length+t(a[l],i+1)}return s===0||s===n.length?r+c:r+Math.round(c/s*n.length)};try{return t(o,0)}catch{return 0}}function Hg(o,e=0){if(e>B.MAX_TRUNCATION_DEPTH)return Array.isArray(o)?"[...]":typeof o=="object"&&o!==null?"{...}":"...";if(typeof o=="function")return"[FUNCTION]";if(typeof o=="string")return o.length>B.MAX_STRING_PREVIEW_LENGTH?o.substring(0,B.MAX_STRING_PREVIEW_LENGTH)+`... [${o.length.toLocaleString()} chars total]`:o;if(Array.isArray(o))return o.length>B.MAX_ARRAY_PREVIEW_ITEMS?[...o.slice(0,B.MAX_ARRAY_PREVIEW_ITEMS).map(t=>Hg(t,e+1)),`... ${o.length-B.MAX_ARRAY_PREVIEW_ITEMS} more items`]:o.map(t=>Hg(t,e+1));if(typeof o=="object"&&o!==null){let t={},a=Object.keys(o);for(let i of a.slice(0,B.MAX_OBJECT_PREVIEW_KEYS))t[i]=Hg(o[i],e+1);return a.length>B.MAX_OBJECT_PREVIEW_KEYS&&(t["..."]=`${(a.length-B.MAX_OBJECT_PREVIEW_KEYS).toLocaleString()} more keys`),t}return o}function Ec(o,e,t){if(o==null||typeof o!="object")return o;if(t.includes(o))return"[Circular]";if(o instanceof Date)return o.toISOString();if(o instanceof RegExp)return o.toString();if(o instanceof Error)return{name:o.name,message:o.message};t.push(o);try{if(Array.isArray(o)){let a=o.length;if(a<=e)return o.map(r=>Ec(r,e,t));let i=o.slice(0,e).map(r=>Ec(r,e,t));return i.push(`sampled from ${a} items`),i}return o instanceof Map?Object.fromEntries(Array.from(o.entries()).map(([a,i])=>[a,Ec(i,e,t)])):o instanceof Set?Ec(Array.from(o),e,t):Nl(o)?Object.entries(o).reduce((a,[i,r])=>({...a,[i]:Ec(r,e,t)}),{}):String(o)}finally{t.pop()}}function jC(o,e=10){return Ec(o,e,[])}function jA(o,e=2){let t=[];try{return JSON.stringify(o,function(a,i){if(typeof i=="bigint")return i.toString();if(typeof i=="function")return"[Function]";if(typeof i!="object"||i===null)return i;for(;t.length>0&&t[t.length-1]!==this;)t.pop();return t.includes(i)?"[Circular]":(t.push(i),i)},e)}catch(a){return JSON.stringify(`[unserializable ${typeof o}: ${a instanceof Error?a.message:String(a)}]`)}}function Gg(o,e=new Date){if(o instanceof Date&&!Number.isNaN(o.getTime()))return o;if(typeof o!="string"&&typeof o!="number")return e;let t=new Date(o);return Number.isNaN(t.getTime())?e:t}function CA(o){let{output:e,...t}=o;return{...t,frontendOutput:t.frontendOutput??e,startTime:t.startTime?Gg(t.startTime):void 0,endTime:t.endTime?Gg(t.endTime):void 0}}function SA(o){let{context:e,...t}=o;return{...t,...o.stale||e?.stale?{stale:!0}:{},timestamp:Gg(o.timestamp),parts:o.parts?.map(a=>a.type==="tool"&&a.tool?{...a,tool:CA(a.tool)}:a),tools:o.tools?.map(CA)}}function rW(o){return o.map(SA)}function nW(o,e){let t=e.memoryMessage?SA(e.memoryMessage):null,a=new Set(e.staleMessageIds);if(!t||a.size===0)return o;let i=o.map(s=>a.has(s.id)?{...s,stale:!0}:s);if(i.some(s=>s.id===t.id))return i;let r=i.findIndex(s=>s.role!=="system"),n=r===-1?i.length:r;return[...i.slice(0,n),t,...i.slice(n)]}function BA(o){return o.content.trim()?o.content.trim():o.parts?.filter(e=>e.type==="content"||e.type==="error").map(e=>e.content||"").join("").trim()||""}function CC(o){return BA(o)?!0:!!(o.tools?.length||o.parts?.some(e=>e.type==="tool"&&e.tool))}function QA(o){return o.role==="assistant"&&!o.isStreaming&&!CC(o)}function sW(o){return o.role==="system"||o.isHidden?!1:!QA(o)}function cW(o){return o.filter(e=>!QA(e))}function mW(o){return o.filter(e=>{let t=BA(e),a=!!(e.parts?.some(i=>i.type==="tool"&&i.tool)||e.tools?.length);return(t||a)&&!(e.id==="1"&&!t)})}function lW(o,e=5e3,t=10){if(o==null)return"null";if(typeof o=="string")return o.length<=e?o:o.slice(0,e)+"... [truncated]";let a=jA(o);if(a.length<=e)return a;let i=jC(o,t),r=jA(i);return r.length<=e?r:r.slice(0,e)+"... [truncated]"}function uW(o,e){if(o.length<=e)return o;let t=Math.ceil(e/2),a=Math.floor(e/2),i=o.length-t-a;return`${o.slice(0,t)}
13
+ }`;if(vC(e))return e;throw e.startsWith("//")?new Error(`Found comment in code: ${e}.`):new Error(`Invalid arrow function: ${e}. Expected a valid arrow function.`)}var $J=["accesstoken","refreshtoken","apikey","apisecret","bearertoken","token","clientsecret","secretaccesskey","secretkey","password","pass","secret","privatekey","oauthkey","oauthcert"];function wC(o){return o.toLowerCase().replace(/[_\-\s]/g,"")}B.CREDENTIAL_KEY_PATTERN=/^[A-Za-z_][A-Za-z0-9_]*$/;B.CREDENTIAL_KEY_VALIDATION_DESCRIPTION="Credential keys must start with a letter or underscore and contain only letters, numbers, and underscores.";function xC(o){return B.CREDENTIAL_KEY_PATTERN.test(o)}function zC(o){return o.trim()?xC(o)?null:B.CREDENTIAL_KEY_VALIDATION_DESCRIPTION:"Credential key is required."}function HJ(o){return[...o].filter(e=>!!zC(e))}var GJ=o=>{let e=wC(o);return $J.some(t=>e===t||e.endsWith(t))};B.isSensitiveCredentialKey=GJ;var VJ=(o,e)=>e==null||e===""?"":B.FULLY_MASKED_CREDENTIAL_VALUE;B.maskCredentialValue=VJ;B.FULLY_MASKED_CREDENTIAL_VALUE="****";function qC(o){return o==null?!1:typeof o=="string"?o.trim().length>0:!0}function YJ(o,e){return!!o?.some(t=>t.key===e&&t.hasValue)}function JJ(o){return Object.entries(o||{}).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:e,hasValue:qC(t)}))}function WJ(o,e){let t=new Set(e.filter(a=>a.hasValue).map(a=>a.key));return[...new Set(o||[])].filter(a=>!t.has(a))}function EC(o){return o===B.FULLY_MASKED_CREDENTIAL_VALUE}function ZJ(o){return o?Object.fromEntries(Object.entries(o).filter(([,e])=>e!=null&&e!=="").map(([e])=>[e,B.FULLY_MASKED_CREDENTIAL_VALUE])):{}}function KJ({incoming:o,existing:e}){if(!o)return{};let t={};for(let[a,i]of Object.entries(o)){if(EC(i)){let r=e?.[a];r!=null&&r!==""&&(t[a]=r);continue}t[a]=i}return t}function EA(o){if(typeof o!="string")return!1;let e=o.trim();return!!(e.startsWith("<<")&&e.endsWith(">>")||e.startsWith("{masked_")&&e.endsWith("}"))}function XJ(o,e){if(!o||Object.keys(o).length===0)return e||{};if(!e||Object.keys(e).length===0)return Object.fromEntries(Object.entries(o).filter(([a,i])=>!EA(i)&&i!==!0));let t={...e};for(let[a,i]of Object.entries(o))EA(i)||i!==!0&&(t[a]=i);return t}function IC(o,e){if(!e)return o;let t=o,a=[],i=0;Object.entries(e).sort(([,r],[,n])=>String(n).length-String(r).length).forEach(([r,n])=>{let s=String(n);if(n&&s){let c=`\0MASK_${i++}\0`;a.push([c,`{masked_${r}}`]);let m=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");t=t.replace(m,c)}});for(let[r,n]of a)t=t.split(r).join(n);return t}function eW(o){let e={};for(let t of o)for(let[a,i]of Object.entries(t.credentials||{}))(0,B.isSensitiveCredentialKey)(a)&&i!==null&&i!==void 0&&i!==""&&(e[`${t.id}_${a}`]=String(i));return e}function IA(o,e){if(o==null)return o;if(typeof o=="string")return IC(o,e);if(typeof o!="object"||o instanceof Date)return o;if(Array.isArray(o))return o.map(a=>IA(a,e));let t={};for(let[a,i]of Object.entries(o))t[a]=IA(i,e);return t}B.MAX_INLINE_RESULT_PREVIEW_BYTES=5*1024*1024;B.MAX_STRING_PREVIEW_LENGTH=3e3;B.MAX_ARRAY_PREVIEW_ITEMS=10;B.MAX_TRUNCATION_DEPTH=10;B.MAX_OBJECT_PREVIEW_KEYS=100;var oW=8,tW=100,aW=100;function iW(o){let e=new WeakSet,t=(a,i)=>{if(a==null)return 0;if(typeof a=="string")return new TextEncoder().encode(a).byteLength;if(typeof a=="number"||typeof a=="boolean")return 8;if(typeof a=="bigint")return String(a).length;if(typeof a=="function"||typeof a=="symbol")return 0;if(a instanceof Date)return 24;if(a instanceof Error)return(a.message?.length||0)+(a.stack?.length||0);if(typeof a!="object"||e.has(a)||(e.add(a),i>oW))return 0;if(Array.isArray(a)){let m=a.length*2,l=Math.min(a.length,tW),u=0;for(let d=0;d<l;d++)u+=t(a[d],i+1);return l===0||l===a.length?m+u:m+Math.round(u/l*a.length)}let r=2,n=Object.keys(a),s=Math.min(n.length,aW),c=0;for(let m=0;m<s;m++){let l=n[m];c+=l.length+t(a[l],i+1)}return s===0||s===n.length?r+c:r+Math.round(c/s*n.length)};try{return t(o,0)}catch{return 0}}function Hg(o,e=0){if(e>B.MAX_TRUNCATION_DEPTH)return Array.isArray(o)?"[...]":typeof o=="object"&&o!==null?"{...}":"...";if(typeof o=="function")return"[FUNCTION]";if(typeof o=="string")return o.length>B.MAX_STRING_PREVIEW_LENGTH?o.substring(0,B.MAX_STRING_PREVIEW_LENGTH)+`... [${o.length.toLocaleString()} chars total]`:o;if(Array.isArray(o))return o.length>B.MAX_ARRAY_PREVIEW_ITEMS?[...o.slice(0,B.MAX_ARRAY_PREVIEW_ITEMS).map(t=>Hg(t,e+1)),`... ${o.length-B.MAX_ARRAY_PREVIEW_ITEMS} more items`]:o.map(t=>Hg(t,e+1));if(typeof o=="object"&&o!==null){let t={},a=Object.keys(o);for(let i of a.slice(0,B.MAX_OBJECT_PREVIEW_KEYS))t[i]=Hg(o[i],e+1);return a.length>B.MAX_OBJECT_PREVIEW_KEYS&&(t["..."]=`${(a.length-B.MAX_OBJECT_PREVIEW_KEYS).toLocaleString()} more keys`),t}return o}function Ec(o,e,t){if(o==null||typeof o!="object")return o;if(t.includes(o))return"[Circular]";if(o instanceof Date)return o.toISOString();if(o instanceof RegExp)return o.toString();if(o instanceof Error)return{name:o.name,message:o.message};t.push(o);try{if(Array.isArray(o)){let a=o.length;if(a<=e)return o.map(r=>Ec(r,e,t));let i=o.slice(0,e).map(r=>Ec(r,e,t));return i.push(`sampled from ${a} items`),i}return o instanceof Map?Object.fromEntries(Array.from(o.entries()).map(([a,i])=>[a,Ec(i,e,t)])):o instanceof Set?Ec(Array.from(o),e,t):Nl(o)?Object.entries(o).reduce((a,[i,r])=>({...a,[i]:Ec(r,e,t)}),{}):String(o)}finally{t.pop()}}function jC(o,e=10){return Ec(o,e,[])}function jA(o,e=2){let t=[];try{return JSON.stringify(o,function(a,i){if(typeof i=="bigint")return i.toString();if(typeof i=="function")return"[Function]";if(typeof i!="object"||i===null)return i;for(;t.length>0&&t[t.length-1]!==this;)t.pop();return t.includes(i)?"[Circular]":(t.push(i),i)},e)}catch(a){return JSON.stringify(`[unserializable ${typeof o}: ${a instanceof Error?a.message:String(a)}]`)}}function Gg(o,e=new Date){if(o instanceof Date&&!Number.isNaN(o.getTime()))return o;if(typeof o!="string"&&typeof o!="number")return e;let t=new Date(o);return Number.isNaN(t.getTime())?e:t}function CA(o){let{output:e,...t}=o;return{...t,frontendOutput:t.frontendOutput??e,startTime:t.startTime?Gg(t.startTime):void 0,endTime:t.endTime?Gg(t.endTime):void 0}}function SA(o){let{context:e,...t}=o;return{...t,...o.stale||e?.stale?{stale:!0}:{},timestamp:Gg(o.timestamp),parts:o.parts?.map(a=>a.type==="tool"&&a.tool?{...a,tool:CA(a.tool)}:a),tools:o.tools?.map(CA)}}function rW(o){return o.map(SA)}function nW(o,e){let t=e.memoryMessage?SA(e.memoryMessage):null,a=new Set(e.staleMessageIds);if(!t||a.size===0)return o;let i=o.map(s=>a.has(s.id)?{...s,stale:!0}:s);if(i.some(s=>s.id===t.id))return i;let r=i.findIndex(s=>s.role!=="system"),n=r===-1?i.length:r;return[...i.slice(0,n),t,...i.slice(n)]}function BA(o){return o.content.trim()?o.content.trim():o.parts?.filter(e=>e.type==="content"||e.type==="error").map(e=>e.content||"").join("").trim()||""}function CC(o){return BA(o)?!0:!!(o.tools?.length||o.parts?.some(e=>e.type==="tool"&&e.tool))}function QA(o){return o.role==="assistant"&&!o.isStreaming&&!CC(o)}function sW(o){return o.role==="system"||o.isHidden?!1:!QA(o)}function cW(o){return o.filter(e=>!QA(e))}function mW(o){return o.filter(e=>{let t=BA(e),a=!!(e.parts?.some(i=>i.type==="tool"&&i.tool)||e.tools?.length);return(t||a)&&!(e.id==="1"&&!t)})}function lW(o,e=5e3,t=10){if(o==null)return"null";if(typeof o=="string")return o.length<=e?o:o.slice(0,e)+"... [truncated]";let a=jA(o);if(a.length<=e)return a;let i=jC(o,t),r=jA(i);return r.length<=e?r:r.slice(0,e)+"... [truncated]"}function uW(o,e){if(o.length<=e)return o;let t=Math.ceil(e/2),a=Math.floor(e/2),i=o.length-t-a;return`${o.slice(0,t)}
14
14
  ... [${i} characters omitted] ...
15
15
  ${o.slice(o.length-a)}`}function dW(o){return o instanceof Error?o.message:typeof o=="string"?o:typeof o=="object"&&o!==null&&"message"in o?String(o.message):String(o)}function gW(o,e){if(!e||Object.keys(e).length===0)return{};let t=/file::([^,\s)}\]"']+)/g,a=typeof o=="string"?o:JSON.stringify(o||{}),i=[...new Set([...a.matchAll(t)].map(r=>{let n=r[1];return n.endsWith(".raw")?n=n.slice(0,-4):n.endsWith(".base64")?n=n.slice(0,-7):n.endsWith(".extracted")&&(n=n.slice(0,-10)),n}))];return Object.fromEntries(i.flatMap(r=>e[r]?[[r,e[r]]]:[]))}function pW(o){if(!o)return null;let e=o.indexOf(":");if(e===-1)return{source:"simpleicons",name:o};let t=o.substring(0,e),a=o.substring(e+1);return t!=="simpleicons"&&t!=="lucide"?{source:"simpleicons",name:o}:{source:t,name:a}}function hW(o){return o?typeof o=="string"?o.indexOf(":")!==-1?o:`simpleicons:${o}`:`${o.source}:${o.name}`:null}function SC(o){if(o.op==="remove"||o.value===void 0||typeof o.value!="string")return o;if(o.path==="/inputSchema"||o.path==="/outputSchema"||o.path.startsWith("/inputSchema/properties/")||o.path.startsWith("/outputSchema/properties/")||o.path.match(/^\/steps\/\d+\/config\/pagination$/)||o.path.match(/^\/steps\/\d+\/config\/headers$/)||o.path.match(/^\/steps\/\d+\/config\/queryParams$/))try{return{...o,value:JSON.parse(o.value)}}catch{return o}return o}function fW(o){return o.map(e=>SC(e))}function bW(o,e){o||(o=""),e||(e=""),/^(https?|postgres(ql)?|ftp(s)?|sftp|smb|file):\/\//i.test(o)||(o=`https://${o}`);let t=o.endsWith("/")?o.slice(0,-1):o,a=e.startsWith("/")?e.slice(1):e;return`${t}/${a}`}B.ALLOWED_PATCH_SYSTEM_FIELDS=["name","url","specificInstructions","icon","credentials","authentication","metadata","templateName","requiredCredentialKeys","documentationFiles","tunnel","tags"];var yW=new Set(["data","stepResults","toolPayload","rawData","transformedData"]),kW=8e4;function AW(o,e=kW){if(o==null)return o;let t=o;if(typeof o=="string"){if(o.length<=e)return o;try{t=JSON.parse(o)}catch{return{_truncated:!0,_message:"String result too large to parse",_size:o.length}}}if(typeof t!="object")return t;let a=0,i=0,r=(n,s=0)=>{if(s>20||n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(m=>r(m,s+1));let c={};for(let[m,l]of Object.entries(n))if(yW.has(m)&&l!==null&&typeof l=="object"){let u=JSON.stringify(l);if(u.length>e){i+=u.length;try{let{jsonString:d,truncatedProps:g}=(0,vJ.default)(u,e);c[m]=JSON.parse(d),a+=g.length}catch{c[m]=l}}else c[m]=l}else c[m]=r(l,s+1);return c};try{if(JSON.stringify(t).length<=e)return t;let s=r(t);return a>0&&typeof s=="object"&&s!==null&&(s._note=`Result truncated: ${a} items omitted (original ${i} characters)`),s}catch{return{_truncated:!0,_message:"Result too large to display"}}}function vW(o){if(!o.steps)return[];let e=new Set;for(let t of o.steps)t.config&&(0,yC.isRequestConfig)(t.config)&&t.config.systemId&&e.add(t.config.systemId);return Array.from(e)}function Vg(o,e,t=new WeakSet){if(typeof o=="string"){e.push(o);return}if(!(!o||typeof o!="object")&&!t.has(o)){if(t.add(o),Array.isArray(o)){for(let a of o)Vg(a,e,t);return}for(let a of Object.values(o))Vg(a,e,t)}}function wW(o){let e=[];for(let t of o.matchAll(/<<([\s\S]*?)>>/g)){let a=t[1].trim();a&&e.push(a)}for(let t of o.matchAll(/{{\s*([^{}\s]+)\s*}}/g)){let a=t[1].trim();a&&e.push(a)}return e}function BC(o,e){let t=[];Vg(o,t);let a=`${e}_`,i=new Set;for(let r of t)for(let n of wW(r)){if(!n.startsWith(a))continue;let s=n.slice(a.length);!s||s==="url"||!B.CREDENTIAL_KEY_PATTERN.test(s)||i.add(s)}return[...i]}var xW=/^\s*(async\s+)?(\([^)]*\)|[a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/,zW=new Set(["sg_auth_email","sg_auth_jwt"]);function qW({config:o,systemId:e}){let t=[];Vg(o,t);let a=e?`${e}_`:null,i=new Set;for(let m of t)for(let l of m.matchAll(/<<([\s\S]*?)>>/g)){let u=l[1].trim();u&&(a&&u.startsWith(a)||xW.test(u)||zW.has(u)||i.add(u))}if(i.size===0)return null;let r=[...i].map(m=>`<<${m}>>`).join(", "),n=`Unresolved placeholder${i.size===1?"":"s"} ${r}`;if(!a)return`${n}. Credential placeholders need systemId and the form <<systemId_secretName>>. Nothing was sent.`;let s=[...i].filter(m=>B.CREDENTIAL_KEY_PATTERN.test(m)).map(m=>`<<${a}${m}>>`),c=s.length>0?`Credential placeholders are namespaced by system: use ${s.join(", ")}.`:`Credential placeholders are namespaced by system as <<${a}secretName>>.`;return`${n}. ${c} Nothing was sent.`}function EW(o){let e={};if(!o.steps)return e;for(let t of o.steps){if(!t.config||!(0,yC.isRequestConfig)(t.config)||!t.config.systemId)continue;let a=BC(t.config,t.config.systemId);if(a.length===0)continue;let i=new Set(e[t.config.systemId]||[]);for(let r of a)i.add(r);e[t.config.systemId]=[...i]}return e}});var NC=f(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.AGENT_CONTEXT_MEMORY_MESSAGE_ID_PREFIX=void 0;ro.applyToolMutation=_A;ro.mutateToolCallInMessages=IW;ro.buildStreamingAssistantMessage=TC;ro.parseToolOutput=RC;ro.parseAgentStreamEventLine=CW;ro.extractLoadedSkillsFromMessages=SW;ro.stopActiveTool=DA;ro.appendContentToMessage=TA;ro.updateMessageWithData=Jg;ro.findAwaitingConfirmationToolCallIds=BW;ro.declineAwaitingConfirmationTools=QW;ro.findAndResumeMessageWithTool=_W;ro.serializeMessageForPersistence=DW;ro.normalizeAgentSessionForkMessages=TW;ro.normalizeAgentSessionImportMessages=RW;ro.createAgentTranscriptState=NW;ro.applyAgentStreamChunk=OW;var DC=Fa();function _A(o,e){let t=e.frontendOutput!==void 0?e.frontendOutput:o.frontendOutput;return{...o,...e.input!==void 0?{input:e.input}:{},...e.result!==void 0?{result:e.result}:{},...e.status!==void 0?{status:e.status}:{},...e.startTime!==void 0?{startTime:e.startTime}:{},...e.endTime!==void 0?{endTime:e.endTime}:{},...e.error!==void 0?{error:e.error||void 0}:{},...t!==void 0?{frontendOutput:t}:{},...e.llmOutput!==void 0?{llmOutput:e.llmOutput}:{},...e.resultMetadata!==void 0?{resultMetadata:e.resultMetadata}:{},...e.confirmationState!==void 0?{confirmationState:e.confirmationState===null?void 0:e.confirmationState}:{},...e.confirmationData!==void 0?{confirmationData:e.confirmationData===null?void 0:e.confirmationData}:{}}}function IW(o,e,t){return o.map(a=>{let i=!1,r=a.tools?.map(s=>s.id!==e?s:(i=!0,_A(s,t))),n=a.parts?.map(s=>s.type!=="tool"||!s.tool||s.tool.id!==e?s:(i=!0,{...s,tool:_A(s.tool,t)}));return i?{...a,...r?{tools:r}:{},...n?{parts:n}:{}}:a})}function TC(o){return{id:o,content:"",role:"assistant",timestamp:new Date,tools:[],parts:[{type:"content",content:"",id:"content-0"}],isStreaming:!0}}function jW(){return{status:"declined",endTime:new Date,confirmationState:"declined",confirmationData:{reason:"new_user_message",message:"Rejected: the user sent a new message instead of confirming this action. The proposed changes were NOT applied."}}}function RC(o){if(!o)return null;if(typeof o=="string")try{let e=JSON.parse(o);return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}return typeof o=="object"&&!Array.isArray(o)?o:null}function CW(o){if(!o.startsWith("data: "))return null;try{let e=JSON.parse(o.slice(6));return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}}function SW(o){let e=new Set;for(let t of o){let a=[...t.tools||[],...(t.parts||[]).flatMap(i=>i.type==="tool"&&i.tool?[i.tool]:[])];for(let i of a){if(i.name!=="load_skill"||i.status!=="completed")continue;let r=RC(i.frontendOutput),n=Array.isArray(r?.activeSkills)?r.activeSkills:[];for(let s of n)typeof s=="string"&&e.add(s)}}return[...e].sort((t,a)=>t.localeCompare(a))}function DA(o){return o.status==="running"||o.status==="pending"||o.status==="awaiting_confirmation"?{...o,status:"stopped",endTime:new Date,confirmationState:void 0,confirmationData:void 0}:o}function TA(o,e){if(!e)return o;let t=[...o.parts||[]],a=t[t.length-1];return a?.type==="content"?t[t.length-1]={...a,content:(a.content||"")+e}:t.push({type:"content",content:e,id:`content-${t.length}`}),{...o,parts:t,content:""}}function Jg(o,e,t){if(o.id!==t.id)return o;switch(e.type){case"content":return TA(o,e.content||"");case"tool_call_start":{let a=o.tools?.findIndex(u=>u.id===e.toolCall.id),i=a!==void 0&&a>=0?o.tools?.[a]:o.parts?.find(u=>u.type==="tool"&&u.tool?.id===e.toolCall.id)?.tool,r=e.toolCall.input??i?.input,n=e.executionMode==="confirm"?"awaiting_confirmation":r?"running":"pending",s={...i,id:e.toolCall.id,name:e.toolCall.name,input:r,status:n,startTime:i?.startTime||new Date,...i?.confirmationState!==void 0?{confirmationState:i.confirmationState}:{},...i?.confirmationData!==void 0?{confirmationData:i.confirmationData}:{}},c;a!==void 0&&a>=0?(c=[...o.tools||[]],c[a]=s):c=[...o.tools||[],s];let m=[...o.parts||[]],l=m.findIndex(u=>u.type==="tool"&&u.tool?.id===e.toolCall.id);return l===-1?m.push({type:"tool",tool:s,id:`tool-${e.toolCall.id}`}):m[l]={...m[l],tool:s},{...o,tools:c,parts:m,content:""}}case"tool_call_input":{let a=i=>i.id===e.toolCall.id&&e.toolCall.input!==void 0?{...i,input:e.toolCall.input}:i;return{...o,tools:o.tools?.map(a),parts:o.parts?.map(i=>i.type==="tool"&&i.tool?{...i,tool:a(i.tool)}:i)}}case"tool_call_update":{let a=o.tools?.map(r=>r.id!==e.toolCall.id?r:{...r,status:r.status==="pending"?"running":r.status,executionTraceId:e.toolCall.executionTraceId??r.executionTraceId})||[],i=o.parts?.map(r=>r.type==="tool"&&r.tool?.id===e.toolCall.id?{...r,tool:{...r.tool,buildResult:a.find(n=>n.id===e.toolCall.id)?.buildResult,executionTraceId:e.toolCall.executionTraceId??a.find(n=>n.id===e.toolCall.id)?.executionTraceId??r.tool.executionTraceId,status:r.tool.status==="pending"?"running":r.tool.status}}:r)||[];return{...o,tools:a,parts:i}}case"tool_call_complete":{let a=o.tools?.find(k=>k.id===e.toolCall.id),i=a?.status==="completed"||a?.status==="declined",r=e.toolCall.result!==void 0||e.toolCall.frontendOutput!==void 0||e.toolCall.status!==void 0||e.toolCall.confirmationState!==void 0||e.toolCall.confirmationData!==void 0;if(i&&!r)return o;let n=null;try{n=typeof e.toolCall.frontendOutput=="string"?JSON.parse(e.toolCall.frontendOutput):e.toolCall.frontendOutput}catch{}let s=n?.success===!1&&n?.error,c=e.toolCall.result?.outcome,m=c==="failure"?"error":c==="rejected"?"declined":c==="aborted"?"stopped":c==="success"?"completed":void 0,l=e.toolCall.status||m||"completed";s&&l==="completed"&&(l="error");let u=l==="awaiting_confirmation",d={...e.toolCall.input!==void 0?{input:e.toolCall.input}:{},...e.toolCall.result!==void 0?{result:e.toolCall.result}:{},status:l,frontendOutput:e.toolCall.frontendOutput,llmOutput:e.toolCall.llmOutput,resultMetadata:e.toolCall.resultMetadata,error:c==="failure"?e.toolCall.result.error.message:s?n.error:null,endTime:u?void 0:new Date,...e.toolCall.confirmationState!==void 0?{confirmationState:e.toolCall.confirmationState}:{},...e.toolCall.confirmationData!==void 0?{confirmationData:e.toolCall.confirmationData}:{}},g=o.tools?.map(k=>k.id===e.toolCall.id?{...k,...d}:k)||[],h=o.parts?.map(k=>k.type==="tool"&&k.tool?.id===e.toolCall.id?{...k,tool:{...k.tool,...d}}:k)||[];return{...o,tools:g,parts:h}}case"done":{if(!o.isStreaming)return o;let a=o.tools?.map(r=>r.status==="awaiting_confirmation"?r:DA(r))||[],i=(o.parts||[]).map(r=>r.type==="tool"&&r.tool&&r.tool.status!=="awaiting_confirmation"?{...r,tool:DA(r.tool)}:r);return{...o,isStreaming:!1,tools:a,parts:i,content:""}}default:return o}}function BW(o){let e=new Set;for(let t of o){for(let a of t.tools||[])a.status==="awaiting_confirmation"&&e.add(a.id);for(let a of t.parts||[])a.type==="tool"&&a.tool?.status==="awaiting_confirmation"&&e.add(a.tool.id)}return[...e]}function QW(o){let e=jW();return o.map(t=>({...t,tools:t.tools?.map(a=>a.status==="awaiting_confirmation"?{...a,...e}:a),parts:t.parts?.map(a=>a.type==="tool"&&a.tool?.status==="awaiting_confirmation"?{...a,tool:{...a.tool,...e}}:a)}))}function _W(o,e){let t=o.find(i=>i.parts?.some(r=>r.type==="tool"&&r.tool?.id===e));return t?{messages:o.map(i=>i.id===t.id?{...i,isStreaming:!0}:i),targetMessage:{...t,isStreaming:!0}}:{messages:o,targetMessage:null}}function QC(o){return{id:o.id,name:o.name,status:o.status,input:o.input,result:o.result,frontendOutput:o.frontendOutput,llmOutput:o.llmOutput,resultMetadata:o.resultMetadata,error:o.error,startTime:o.startTime,endTime:o.endTime,confirmationState:o.confirmationState,confirmationData:o.confirmationData}}function DW(o){let{isStreaming:e,...t}=o;return JSON.parse((0,DC.safeStringify)({...t,...o.tools?{tools:o.tools.map(QC)}:{},...o.parts?{parts:o.parts.map(a=>a.type==="tool"&&a.tool?{...a,tool:QC(a.tool)}:a)}:{}},0))}ro.AGENT_CONTEXT_MEMORY_MESSAGE_ID_PREFIX="context-memory-";function TW(o){return o.filter(e=>e.role!=="system"&&!e.id.startsWith(ro.AGENT_CONTEXT_MEMORY_MESSAGE_ID_PREFIX)).map(e=>({...e,stale:void 0,isStreaming:void 0}))}function RW(o){return o.filter(e=>!e.stale&&!e.isStreaming&&!!e.id)}function NW(o=[],e=null){return{messages:o,assistantMessageId:e,outcome:"streaming"}}function _C(o,e){return!!(o.tools?.some(t=>t.id===e)||o.parts?.some(t=>t.type==="tool"&&t.tool?.id===e))}function Ic(o,e){let t=o.assistantMessageId?o.messages.find(i=>i.id===o.assistantMessageId):void 0;if(t)return{state:o,target:t};let a=TC(o.assistantMessageId??e.createAssistantMessageId());return{state:{...o,messages:[...o.messages,a],assistantMessageId:a.id},target:a}}function OW(o,e,t){switch(e.type){case"system_message":{if(!e.systemMessage)return o;let a={id:e.systemMessage.id,role:"system",content:e.systemMessage.content,timestamp:new Date};return{...o,messages:[a,...o.messages]}}case"assistant_message_start":{if(!e.assistantMessageId)return o;let a=o.assistantMessageId?o.messages.find(r=>r.id===o.assistantMessageId):void 0;return o.messages.find(r=>r.id===e.assistantMessageId)?{...o,assistantMessageId:e.assistantMessageId,messages:o.messages.filter(r=>!a||a.id===e.assistantMessageId||r.id!==a.id).map(r=>r.id===e.assistantMessageId?{...r,isStreaming:!0}:r)}:a?{...o,assistantMessageId:e.assistantMessageId,messages:o.messages.map(r=>r.id===a.id?{...r,id:e.assistantMessageId,isStreaming:!0}:r)}:{...o,assistantMessageId:e.assistantMessageId}}case"context_usage":case"compaction_start":return o;case"compaction_complete":return e.compaction?{...o,messages:(0,DC.applyAgentCompactionToMessages)(o.messages,e.compaction)}:o;case"content":{let a=Ic(o,t);return{...a.state,messages:a.state.messages.map(i=>i.id===a.target.id?TA(i,e.content||""):i)}}case"error":{let a=Ic(o,t);return{...a.state,outcome:"failed",messages:a.state.messages.map(i=>i.id!==a.target.id?i:{...i,parts:[...i.parts||[],{type:"error",content:e.content,errorDetails:e.errorDetails,id:`error-${i.parts?.length??0}`}],isStreaming:!1})}}case"tool_call_start":case"tool_call_update":{if(!e.toolCall)return o;let a=e.type==="tool_call_start"?null:o.messages.find(r=>_C(r,e.toolCall.id))??null,i=a?{state:o,target:a}:Ic(o,t);return{...i.state,messages:i.state.messages.map(r=>Jg(r,e,i.target))}}case"tool_call_complete":{if(!e.toolCall)return o;let a=o.messages.find(r=>_C(r,e.toolCall.id)),i=a?{state:o,target:a}:Ic(o,t);return{...i.state,messages:i.state.messages.map(r=>Jg(r,e,i.target))}}case"paused":{let a=Ic(o,t);return{...a.state,outcome:"paused",messages:a.state.messages.map(i=>i.id===a.target.id?{...i,isStreaming:!1}:i)}}case"done":{let a=Ic(o,t);return{...a.state,outcome:o.outcome==="failed"?"failed":"completed",messages:a.state.messages.map(i=>Jg(i,e,a.target))}}default:return o}}});var VC=f(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.AgentRequestValidationError=we.AGENT_TOOL_CONTINUATION_ACTION_BY_CONFIRMATION_STATE=we.AGENT_TOOL_CONTINUATION_ACTIONS=we.AGENT_IDENTIFIER_PATTERN=we.AGENT_REQUEST_LIMITS=void 0;we.validateAgentRequestPayload=FC;we.validateResourceBinding=$C;we.validateAgentSessionIdentity=HC;we.validateAgentSessionTarget=GC;we.validateAgentRequestSubmission=HW;we.isAgentMessagePayload=GW;we.isAgentToolContinuationPayload=VW;var fr=Ht();we.AGENT_REQUEST_LIMITS={messageContentChars:5e4,identifierChars:256,attachedFiles:20,toolContinuations:20,continuationInputChars:1e5,frontendDraftsChars:2e6,accessRulesContextChars:2e6};we.AGENT_IDENTIFIER_PATTERN=/^[A-Za-z0-9._-]+$/;we.AGENT_TOOL_CONTINUATION_ACTIONS=["approve","reject","oauth_success","oauth_failure"];we.AGENT_TOOL_CONTINUATION_ACTION_BY_CONFIRMATION_STATE={[fr.ConfirmationAction.CONFIRMED]:"approve",[fr.ConfirmationAction.DECLINED]:"reject",[fr.ConfirmationAction.OAUTH_SUCCESS]:"oauth_success",[fr.ConfirmationAction.OAUTH_FAILURE]:"oauth_failure"};var Wg=class extends Error{constructor(e){super(e),this.name="AgentRequestValidationError"}};we.AgentRequestValidationError=Wg;function Ge(o){throw new Wg(o)}function $a(o,e){return(!o||typeof o!="object"||Array.isArray(o))&&Ge(`${e} must be an object`),o}function jc(o,e){(typeof o!="string"||!o.trim())&&Ge(`${e} must be a non-empty string`);let t=o.trim();return t.length>we.AGENT_REQUEST_LIMITS.identifierChars&&Ge(`${e} exceeds ${we.AGENT_REQUEST_LIMITS.identifierChars} characters`),we.AGENT_IDENTIFIER_PATTERN.test(t)||Ge(`${e} may only contain letters, numbers, dots, underscores, and hyphens`),t}function UW(o,e){return typeof o!="boolean"&&Ge(`${e} must be a boolean`),o}function RA(o,e){try{return JSON.stringify(o).length}catch{return Ge(`${e} must be JSON-serializable`)}}function MW(o,e){if(o!==void 0)return Array.isArray(o)||Ge(`${e} must be an array`),o.length>we.AGENT_REQUEST_LIMITS.attachedFiles&&Ge(`${e} exceeds ${we.AGENT_REQUEST_LIMITS.attachedFiles} entries`),o.map((t,a)=>{let i=$a(t,`${e}[${a}]`);return{...i,key:jc(i.key,`${e}[${a}].key`)}})}function OC({value:o,label:e,requireHidden:t}){let a=$a(o,e),i=jc(a.id,`${e}.id`);typeof a.content!="string"&&Ge(`${e}.content must be a string`);let r=a.content;r.length>we.AGENT_REQUEST_LIMITS.messageContentChars&&Ge(`${e}.content exceeds ${we.AGENT_REQUEST_LIMITS.messageContentChars} characters`);let n=UW(a.isHidden,`${e}.isHidden`);t&&!n&&Ge(`${e}.isHidden must be true`);let s=MW(a.attachedFiles,`${e}.attachedFiles`);return!r.trim()&&!s?.length&&Ge(`${e}.content may only be empty when an attachment is present`),{id:i,content:r,isHidden:n,...s?{attachedFiles:s}:{}}}function UC(o){if(o===void 0)return;let e=$a(o,"frontendDrafts");return RA(e,"frontendDrafts")>we.AGENT_REQUEST_LIMITS.frontendDraftsChars&&Ge(`frontendDrafts exceeds ${we.AGENT_REQUEST_LIMITS.frontendDraftsChars} characters`),e}function MC(o){if(o===void 0)return;let e=$a(o,"accessRulesContext");return RA(e,"accessRulesContext")>we.AGENT_REQUEST_LIMITS.accessRulesContextChars&&Ge(`accessRulesContext exceeds ${we.AGENT_REQUEST_LIMITS.accessRulesContextChars} characters`),e}function LC(o){if(o!==void 0)return(typeof o!="string"||!fr.AGENT_APPROVAL_MODES.includes(o))&&Ge(`request.approvalMode must be one of: ${fr.AGENT_APPROVAL_MODES.join(", ")}`),o}function PC(o,e){let t=$a(o,e),a=jc(t.toolCallId,`${e}.toolCallId`);return(typeof t.action!="string"||!we.AGENT_TOOL_CONTINUATION_ACTIONS.includes(t.action))&&Ge(`${e}.action must be one of: ${we.AGENT_TOOL_CONTINUATION_ACTIONS.join(", ")}`),t.input!==void 0&&RA(t.input,`${e}.input`)>we.AGENT_REQUEST_LIMITS.continuationInputChars&&Ge(`${e}.input exceeds ${we.AGENT_REQUEST_LIMITS.continuationInputChars} characters`),{toolCallId:a,action:t.action,...t.input!==void 0?{input:t.input}:{}}}function LW(o){if(o===void 0)return;(!Array.isArray(o)||o.length===0)&&Ge("request.toolContinuations must be a non-empty array"),o.length>we.AGENT_REQUEST_LIMITS.toolContinuations&&Ge(`request.toolContinuations exceeds ${we.AGENT_REQUEST_LIMITS.toolContinuations} entries`);let e=o.map((t,a)=>PC(t,`request.toolContinuations[${a}]`));return new Set(e.map(({toolCallId:t})=>t)).size!==e.length&&Ge("request.toolContinuations must not contain duplicate toolCallId values"),e}function PW(o){if(o===void 0)return;(typeof o!="string"||!o.trim())&&Ge("request.titleInput must be a non-empty string");let e=o.trim();return e.length>we.AGENT_REQUEST_LIMITS.messageContentChars&&Ge(`request.titleInput exceeds ${we.AGENT_REQUEST_LIMITS.messageContentChars} characters`),e}function FW(o){let e=OC({value:o.message,label:"request.message"}),t=PW(o.titleInput),a=o.hiddenSteeringMessage===void 0?void 0:OC({value:o.hiddenSteeringMessage,label:"request.hiddenSteeringMessage",requireHidden:!0});a&&a.id===e.id&&Ge("request.hiddenSteeringMessage.id must differ from request.message.id");let i=LW(o.toolContinuations),r=LC(o.approvalMode),n=UC(o.frontendDrafts),s=MC(o.accessRulesContext);return{kind:"message",message:e,...a?{hiddenSteeringMessage:a}:{},...t?{titleInput:t}:{},...i?{toolContinuations:i}:{},...r?{approvalMode:r}:{},...n?{frontendDrafts:n}:{},...s?{accessRulesContext:s}:{}}}function $W(o){let e=PC(o,"request"),t=LC(o.approvalMode),a=UC(o.frontendDrafts),i=MC(o.accessRulesContext);return{kind:"tool_continuation",...e,...t?{approvalMode:t}:{},...a?{frontendDrafts:a}:{},...i?{accessRulesContext:i}:{}}}function FC(o){let e=$a(o,"request");return e.kind==="message"?FW(e):e.kind==="tool_continuation"?$W(e):Ge('request.kind must be "message" or "tool_continuation"')}function $C(o,e){let t=$a(o,e);return(typeof t.kind!="string"||!fr.AGENT_SESSION_RESOURCE_KINDS.includes(t.kind))&&Ge(`${e}.kind must be one of: ${fr.AGENT_SESSION_RESOURCE_KINDS.join(", ")}`),{kind:t.kind,id:jc(t.id,`${e}.id`)}}function HC(o,e="session.createIfMissing"){let t=$a(o,e),a=t.projectId===void 0?void 0:jc(t.projectId,`${e}.projectId`),i=Object.values(fr.AgentType);(typeof t.agentId!="string"||!i.includes(t.agentId))&&Ge(`${e}.agentId must be one of: ${i.join(", ")}`);let r=t.resourceBinding===void 0?void 0:$C(t.resourceBinding,`${e}.resourceBinding`);return{agentId:t.agentId,...a?{projectId:a}:{},...r?{resourceBinding:r}:{}}}function GC(o){let e=$a(o,"session"),t=e.createIfMissing===void 0?void 0:HC(e.createIfMissing);return{id:jc(e.id,"session.id"),...t?{createIfMissing:t}:{}}}function HW(o){let e=$a(o,"body");return{session:GC(e.session),request:FC(e.request)}}function GW(o){return o.kind==="message"}function VW(o){return o.kind==="tool_continuation"}});var ls=f(Uo=>{"use strict";var YC;Object.defineProperty(Uo,"__esModule",{value:!0});Uo.globalConfig=Uo.$ZodEncodeError=Uo.$ZodAsyncError=Uo.$brand=Uo.NEVER=void 0;Uo.$constructor=YW;Uo.config=JW;Uo.NEVER=Object.freeze({status:"aborted"});function YW(o,e,t){function a(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:n,traits:new Set},enumerable:!1}),s._zod.traits.has(o))return;s._zod.traits.add(o),e(s,c);let m=n.prototype,l=Object.keys(m);for(let u=0;u<l.length;u++){let d=l[u];d in s||(s[d]=m[d].bind(s))}}let i=t?.Parent??Object;class r extends i{}Object.defineProperty(r,"name",{value:o});function n(s){var c;let m=t?.Parent?new r:this;a(m,s),(c=m._zod).deferred??(c.deferred=[]);for(let l of m._zod.deferred)l();return m}return Object.defineProperty(n,"init",{value:a}),Object.defineProperty(n,Symbol.hasInstance,{value:s=>t?.Parent&&s instanceof t.Parent?!0:s?._zod?.traits?.has(o)}),Object.defineProperty(n,"name",{value:o}),n}Uo.$brand=Symbol("zod_brand");var NA=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};Uo.$ZodAsyncError=NA;var OA=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};Uo.$ZodEncodeError=OA;(YC=globalThis).__zod_globalConfig??(YC.__zod_globalConfig={});Uo.globalConfig=globalThis.__zod_globalConfig;function JW(o){return o&&Object.assign(Uo.globalConfig,o),Uo.globalConfig}});var W=f(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.Class=F.BIGINT_FORMAT_RANGES=F.NUMBER_FORMAT_RANGES=F.primitiveTypes=F.propertyKeyTypes=F.getParsedType=F.allowsEval=F.captureStackTrace=void 0;F.assertEqual=ZW;F.assertNotEqual=KW;F.assertIs=XW;F.assertNever=eZ;F.assert=oZ;F.getEnumValues=tZ;F.joinValues=aZ;F.jsonStringifyReplacer=iZ;F.cached=WC;F.nullish=rZ;F.cleanRegex=nZ;F.floatSafeRemainder=sZ;F.defineLazy=cZ;F.objectClone=mZ;F.assignProp=nn;F.mergeDefs=br;F.cloneDef=lZ;F.getElementAtPath=uZ;F.promiseAllObject=dZ;F.randomString=gZ;F.esc=pZ;F.slugify=hZ;F.isObject=UA;F.isPlainObject=Zg;F.shallowClone=fZ;F.numKeys=bZ;F.escapeRegex=kZ;F.clone=sn;F.normalizeParams=AZ;F.createTransparentProxy=vZ;F.stringifyPrimitive=ZC;F.optionalKeys=wZ;F.pick=xZ;F.omit=zZ;F.extend=qZ;F.safeExtend=EZ;F.merge=IZ;F.partial=jZ;F.required=CZ;F.aborted=SZ;F.explicitlyAborted=BZ;F.prefixIssues=QZ;F.unwrapMessage=Ol;F.finalizeIssue=_Z;F.getSizableOrigin=DZ;F.getLengthableOrigin=TZ;F.parsedType=RZ;F.issue=NZ;F.cleanEnum=OZ;F.base64ToUint8Array=KC;F.uint8ArrayToBase64=XC;F.base64urlToUint8Array=UZ;F.uint8ArrayToBase64url=MZ;F.hexToUint8Array=LZ;F.uint8ArrayToHex=PZ;var WW=ls();function ZW(o){return o}function KW(o){return o}function XW(o){}function eZ(o){throw new Error("Unexpected value in exhaustive check")}function oZ(o){}function tZ(o){let e=Object.values(o).filter(a=>typeof a=="number");return Object.entries(o).filter(([a,i])=>e.indexOf(+a)===-1).map(([a,i])=>i)}function aZ(o,e="|"){return o.map(t=>ZC(t)).join(e)}function iZ(o,e){return typeof e=="bigint"?e.toString():e}function WC(o){return{get value(){{let t=o();return Object.defineProperty(this,"value",{value:t}),t}throw new Error("cached value already set")}}}function rZ(o){return o==null}function nZ(o){let e=o.startsWith("^")?1:0,t=o.endsWith("$")?o.length-1:o.length;return o.slice(e,t)}function sZ(o,e){let t=o/e,a=Math.round(t),i=Number.EPSILON*Math.max(Math.abs(t),1);return Math.abs(t-a)<i?0:t-a}var JC=Symbol("evaluating");function cZ(o,e,t){let a;Object.defineProperty(o,e,{get(){if(a!==JC)return a===void 0&&(a=JC,a=t()),a},set(i){Object.defineProperty(o,e,{value:i})},configurable:!0})}function mZ(o){return Object.create(Object.getPrototypeOf(o),Object.getOwnPropertyDescriptors(o))}function nn(o,e,t){Object.defineProperty(o,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function br(...o){let e={};for(let t of o){let a=Object.getOwnPropertyDescriptors(t);Object.assign(e,a)}return Object.defineProperties({},e)}function lZ(o){return br(o._zod.def)}function uZ(o,e){return e?e.reduce((t,a)=>t?.[a],o):o}function dZ(o){let e=Object.keys(o),t=e.map(a=>o[a]);return Promise.all(t).then(a=>{let i={};for(let r=0;r<e.length;r++)i[e[r]]=a[r];return i})}function gZ(o=10){let e="abcdefghijklmnopqrstuvwxyz",t="";for(let a=0;a<o;a++)t+=e[Math.floor(Math.random()*e.length)];return t}function pZ(o){return JSON.stringify(o)}function hZ(o){return o.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}F.captureStackTrace="captureStackTrace"in Error?Error.captureStackTrace:(...o)=>{};function UA(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}F.allowsEval=WC(()=>{if(WW.globalConfig.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let o=Function;return new o(""),!0}catch{return!1}});function Zg(o){if(UA(o)===!1)return!1;let e=o.constructor;if(e===void 0||typeof e!="function")return!0;let t=e.prototype;return!(UA(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function fZ(o){return Zg(o)?{...o}:Array.isArray(o)?[...o]:o instanceof Map?new Map(o):o instanceof Set?new Set(o):o}function bZ(o){let e=0;for(let t in o)Object.prototype.hasOwnProperty.call(o,t)&&e++;return e}var yZ=o=>{let e=typeof o;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(o)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(o)?"array":o===null?"null":o.then&&typeof o.then=="function"&&o.catch&&typeof o.catch=="function"?"promise":typeof Map<"u"&&o instanceof Map?"map":typeof Set<"u"&&o instanceof Set?"set":typeof Date<"u"&&o instanceof Date?"date":typeof File<"u"&&o instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}};F.getParsedType=yZ;F.propertyKeyTypes=new Set(["string","number","symbol"]);F.primitiveTypes=new Set(["string","number","bigint","boolean","symbol","undefined"]);function kZ(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sn(o,e,t){let a=new o._zod.constr(e??o._zod.def);return(!e||t?.parent)&&(a._zod.parent=o),a}function AZ(o){let e=o;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function vZ(o){let e;return new Proxy({},{get(t,a,i){return e??(e=o()),Reflect.get(e,a,i)},set(t,a,i,r){return e??(e=o()),Reflect.set(e,a,i,r)},has(t,a){return e??(e=o()),Reflect.has(e,a)},deleteProperty(t,a){return e??(e=o()),Reflect.deleteProperty(e,a)},ownKeys(t){return e??(e=o()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(t,a){return e??(e=o()),Reflect.getOwnPropertyDescriptor(e,a)},defineProperty(t,a,i){return e??(e=o()),Reflect.defineProperty(e,a,i)}})}function ZC(o){return typeof o=="bigint"?o.toString()+"n":typeof o=="string"?`"${o}"`:`${o}`}function wZ(o){return Object.keys(o).filter(e=>o[e]._zod.optin==="optional"&&o[e]._zod.optout==="optional")}F.NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};F.BIGINT_FORMAT_RANGES={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function xZ(o,e){let t=o._zod.def,a=t.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let r=br(o._zod.def,{get shape(){let n={};for(let s in e){if(!(s in t.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(n[s]=t.shape[s])}return nn(this,"shape",n),n},checks:[]});return sn(o,r)}function zZ(o,e){let t=o._zod.def,a=t.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let r=br(o._zod.def,{get shape(){let n={...o._zod.def.shape};for(let s in e){if(!(s in t.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete n[s]}return nn(this,"shape",n),n},checks:[]});return sn(o,r)}function qZ(o,e){if(!Zg(e))throw new Error("Invalid input to extend: expected a plain object");let t=o._zod.def.checks;if(t&&t.length>0){let r=o._zod.def.shape;for(let n in e)if(Object.getOwnPropertyDescriptor(r,n)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=br(o._zod.def,{get shape(){let r={...o._zod.def.shape,...e};return nn(this,"shape",r),r}});return sn(o,i)}function EZ(o,e){if(!Zg(e))throw new Error("Invalid input to safeExtend: expected a plain object");let t=br(o._zod.def,{get shape(){let a={...o._zod.def.shape,...e};return nn(this,"shape",a),a}});return sn(o,t)}function IZ(o,e){if(o._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let t=br(o._zod.def,{get shape(){let a={...o._zod.def.shape,...e._zod.def.shape};return nn(this,"shape",a),a},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return sn(o,t)}function jZ(o,e,t){let i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let n=br(e._zod.def,{get shape(){let s=e._zod.def.shape,c={...s};if(t)for(let m in t){if(!(m in s))throw new Error(`Unrecognized key: "${m}"`);t[m]&&(c[m]=o?new o({type:"optional",innerType:s[m]}):s[m])}else for(let m in s)c[m]=o?new o({type:"optional",innerType:s[m]}):s[m];return nn(this,"shape",c),c},checks:[]});return sn(e,n)}function CZ(o,e,t){let a=br(e._zod.def,{get shape(){let i=e._zod.def.shape,r={...i};if(t)for(let n in t){if(!(n in r))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(r[n]=new o({type:"nonoptional",innerType:i[n]}))}else for(let n in i)r[n]=new o({type:"nonoptional",innerType:i[n]});return nn(this,"shape",r),r}});return sn(e,a)}function SZ(o,e=0){if(o.aborted===!0)return!0;for(let t=e;t<o.issues.length;t++)if(o.issues[t]?.continue!==!0)return!0;return!1}function BZ(o,e=0){if(o.aborted===!0)return!0;for(let t=e;t<o.issues.length;t++)if(o.issues[t]?.continue===!1)return!0;return!1}function QZ(o,e){return e.map(t=>{var a;return(a=t).path??(a.path=[]),t.path.unshift(o),t})}function Ol(o){return typeof o=="string"?o:o?.message}function _Z(o,e,t){let a=o.message?o.message:Ol(o.inst?._zod.def?.error?.(o))??Ol(e?.error?.(o))??Ol(t.customError?.(o))??Ol(t.localeError?.(o))??"Invalid input",{inst:i,continue:r,input:n,...s}=o;return s.path??(s.path=[]),s.message=a,e?.reportInput&&(s.input=n),s}function DZ(o){return o instanceof Set?"set":o instanceof Map?"map":o instanceof File?"file":"unknown"}function TZ(o){return Array.isArray(o)?"array":typeof o=="string"?"string":"unknown"}function RZ(o){let e=typeof o;switch(e){case"number":return Number.isNaN(o)?"nan":"number";case"object":{if(o===null)return"null";if(Array.isArray(o))return"array";let t=o;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return e}function NZ(...o){let[e,t,a]=o;return typeof e=="string"?{message:e,code:"custom",input:t,inst:a}:{...e}}function OZ(o){return Object.entries(o).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function KC(o){let e=atob(o),t=new Uint8Array(e.length);for(let a=0;a<e.length;a++)t[a]=e.charCodeAt(a);return t}function XC(o){let e="";for(let t=0;t<o.length;t++)e+=String.fromCharCode(o[t]);return btoa(e)}function UZ(o){let e=o.replace(/-/g,"+").replace(/_/g,"/"),t="=".repeat((4-e.length%4)%4);return KC(e+t)}function MZ(o){return XC(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function LZ(o){let e=o.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let t=new Uint8Array(e.length/2);for(let a=0;a<e.length;a+=2)t[a/2]=Number.parseInt(e.slice(a,a+2),16);return t}function PZ(o){return Array.from(o).map(e=>e.toString(16).padStart(2,"0")).join("")}var MA=class{constructor(...e){}};F.Class=MA});var LA=f(_o=>{"use strict";var FZ=_o&&_o.__createBinding||(Object.create?(function(o,e,t,a){a===void 0&&(a=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(o,a,i)}):(function(o,e,t,a){a===void 0&&(a=t),o[a]=e[t]})),$Z=_o&&_o.__setModuleDefault||(Object.create?(function(o,e){Object.defineProperty(o,"default",{enumerable:!0,value:e})}):function(o,e){o.default=e}),HZ=_o&&_o.__importStar||function(o){if(o&&o.__esModule)return o;var e={};if(o!=null)for(var t in o)t!=="default"&&Object.prototype.hasOwnProperty.call(o,t)&&FZ(e,o,t);return $Z(e,o),e};Object.defineProperty(_o,"__esModule",{value:!0});_o.$ZodRealError=_o.$ZodError=void 0;_o.flattenError=VZ;_o.formatError=YZ;_o.treeifyError=JZ;_o.toDotPath=t4;_o.prettifyError=WZ;var e4=ls(),GZ=HZ(W()),o4=(o,e)=>{o.name="$ZodError",Object.defineProperty(o,"_zod",{value:o._zod,enumerable:!1}),Object.defineProperty(o,"issues",{value:e,enumerable:!1}),o.message=JSON.stringify(e,GZ.jsonStringifyReplacer,2),Object.defineProperty(o,"toString",{value:()=>o.message,enumerable:!1})};_o.$ZodError=(0,e4.$constructor)("$ZodError",o4);_o.$ZodRealError=(0,e4.$constructor)("$ZodError",o4,{Parent:Error});function VZ(o,e=t=>t.message){let t={},a=[];for(let i of o.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):a.push(e(i));return{formErrors:a,fieldErrors:t}}function YZ(o,e=t=>t.message){let t={_errors:[]},a=(i,r=[])=>{for(let n of i.issues)if(n.code==="invalid_union"&&n.errors.length)n.errors.map(s=>a({issues:s},[...r,...n.path]));else if(n.code==="invalid_key")a({issues:n.issues},[...r,...n.path]);else if(n.code==="invalid_element")a({issues:n.issues},[...r,...n.path]);else{let s=[...r,...n.path];if(s.length===0)t._errors.push(e(n));else{let c=t,m=0;for(;m<s.length;){let l=s[m];m===s.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(e(n))):c[l]=c[l]||{_errors:[]},c=c[l],m++}}}};return a(o),t}function JZ(o,e=t=>t.message){let t={errors:[]},a=(i,r=[])=>{var n,s;for(let c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(m=>a({issues:m},[...r,...c.path]));else if(c.code==="invalid_key")a({issues:c.issues},[...r,...c.path]);else if(c.code==="invalid_element")a({issues:c.issues},[...r,...c.path]);else{let m=[...r,...c.path];if(m.length===0){t.errors.push(e(c));continue}let l=t,u=0;for(;u<m.length;){let d=m[u],g=u===m.length-1;typeof d=="string"?(l.properties??(l.properties={}),(n=l.properties)[d]??(n[d]={errors:[]}),l=l.properties[d]):(l.items??(l.items=[]),(s=l.items)[d]??(s[d]={errors:[]}),l=l.items[d]),g&&l.errors.push(e(c)),u++}}};return a(o),t}function t4(o){let e=[],t=o.map(a=>typeof a=="object"?a.key:a);for(let a of t)typeof a=="number"?e.push(`[${a}]`):typeof a=="symbol"?e.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?e.push(`[${JSON.stringify(a)}]`):(e.length&&e.push("."),e.push(a));return e.join("")}function WZ(o){let e=[],t=[...o.issues].sort((a,i)=>(a.path??[]).length-(i.path??[]).length);for(let a of t)e.push(`\u2716 ${a.message}`),a.path?.length&&e.push(` \u2192 at ${t4(a.path)}`);return e.join(`
16
16
  `)}});var FA=f(M=>{"use strict";var ZZ=M&&M.__createBinding||(Object.create?(function(o,e,t,a){a===void 0&&(a=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(o,a,i)}):(function(o,e,t,a){a===void 0&&(a=t),o[a]=e[t]})),KZ=M&&M.__setModuleDefault||(Object.create?(function(o,e){Object.defineProperty(o,"default",{enumerable:!0,value:e})}):function(o,e){o.default=e}),PA=M&&M.__importStar||function(o){if(o&&o.__esModule)return o;var e={};if(o!=null)for(var t in o)t!=="default"&&Object.prototype.hasOwnProperty.call(o,t)&&ZZ(e,o,t);return KZ(e,o),e};Object.defineProperty(M,"__esModule",{value:!0});M.safeDecodeAsync=M._safeDecodeAsync=M.safeEncodeAsync=M._safeEncodeAsync=M.safeDecode=M._safeDecode=M.safeEncode=M._safeEncode=M.decodeAsync=M._decodeAsync=M.encodeAsync=M._encodeAsync=M.decode=M._decode=M.encode=M._encode=M.safeParseAsync=M._safeParseAsync=M.safeParse=M._safeParse=M.parseAsync=M._parseAsync=M.parse=M._parse=void 0;var Cc=PA(ls()),Et=PA(LA()),Sc=PA(W()),XZ=o=>(e,t,a,i)=>{let r=a?{...a,async:!1}:{async:!1},n=e._zod.run({value:t,issues:[]},r);if(n instanceof Promise)throw new Cc.$ZodAsyncError;if(n.issues.length){let s=new(i?.Err??o)(n.issues.map(c=>Sc.finalizeIssue(c,r,Cc.config())));throw Sc.captureStackTrace(s,i?.callee),s}return n.value};M._parse=XZ;M.parse=(0,M._parse)(Et.$ZodRealError);var eK=o=>async(e,t,a,i)=>{let r=a?{...a,async:!0}:{async:!0},n=e._zod.run({value:t,issues:[]},r);if(n instanceof Promise&&(n=await n),n.issues.length){let s=new(i?.Err??o)(n.issues.map(c=>Sc.finalizeIssue(c,r,Cc.config())));throw Sc.captureStackTrace(s,i?.callee),s}return n.value};M._parseAsync=eK;M.parseAsync=(0,M._parseAsync)(Et.$ZodRealError);var oK=o=>(e,t,a)=>{let i=a?{...a,async:!1}:{async:!1},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)throw new Cc.$ZodAsyncError;return r.issues.length?{success:!1,error:new(o??Et.$ZodError)(r.issues.map(n=>Sc.finalizeIssue(n,i,Cc.config())))}:{success:!0,data:r.value}};M._safeParse=oK;M.safeParse=(0,M._safeParse)(Et.$ZodRealError);var tK=o=>async(e,t,a)=>{let i=a?{...a,async:!0}:{async:!0},r=e._zod.run({value:t,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new o(r.issues.map(n=>Sc.finalizeIssue(n,i,Cc.config())))}:{success:!0,data:r.value}};M._safeParseAsync=tK;M.safeParseAsync=(0,M._safeParseAsync)(Et.$ZodRealError);var aK=o=>(e,t,a)=>{let i=a?{...a,direction:"backward"}:{direction:"backward"};return(0,M._parse)(o)(e,t,i)};M._encode=aK;M.encode=(0,M._encode)(Et.$ZodRealError);var iK=o=>(e,t,a)=>(0,M._parse)(o)(e,t,a);M._decode=iK;M.decode=(0,M._decode)(Et.$ZodRealError);var rK=o=>async(e,t,a)=>{let i=a?{...a,direction:"backward"}:{direction:"backward"};return(0,M._parseAsync)(o)(e,t,i)};M._encodeAsync=rK;M.encodeAsync=(0,M._encodeAsync)(Et.$ZodRealError);var nK=o=>async(e,t,a)=>(0,M._parseAsync)(o)(e,t,a);M._decodeAsync=nK;M.decodeAsync=(0,M._decodeAsync)(Et.$ZodRealError);var sK=o=>(e,t,a)=>{let i=a?{...a,direction:"backward"}:{direction:"backward"};return(0,M._safeParse)(o)(e,t,i)};M._safeEncode=sK;M.safeEncode=(0,M._safeEncode)(Et.$ZodRealError);var cK=o=>(e,t,a)=>(0,M._safeParse)(o)(e,t,a);M._safeDecode=cK;M.safeDecode=(0,M._safeDecode)(Et.$ZodRealError);var mK=o=>async(e,t,a)=>{let i=a?{...a,direction:"backward"}:{direction:"backward"};return(0,M._safeParseAsync)(o)(e,t,i)};M._safeEncodeAsync=mK;M.safeEncodeAsync=(0,M._safeEncodeAsync)(Et.$ZodRealError);var lK=o=>async(e,t,a)=>(0,M._safeParseAsync)(o)(e,t,a);M._safeDecodeAsync=lK;M.safeDecodeAsync=(0,M._safeDecodeAsync)(Et.$ZodRealError)});var Kg=f(C=>{"use strict";var uK=C&&C.__createBinding||(Object.create?(function(o,e,t,a){a===void 0&&(a=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(o,a,i)}):(function(o,e,t,a){a===void 0&&(a=t),o[a]=e[t]})),dK=C&&C.__setModuleDefault||(Object.create?(function(o,e){Object.defineProperty(o,"default",{enumerable:!0,value:e})}):function(o,e){o.default=e}),gK=C&&C.__importStar||function(o){if(o&&o.__esModule)return o;var e={};if(o!=null)for(var t in o)t!=="default"&&Object.prototype.hasOwnProperty.call(o,t)&&uK(e,o,t);return dK(e,o),e};Object.defineProperty(C,"__esModule",{value:!0});C.sha256_base64url=C.sha256_base64=C.sha256_hex=C.sha1_base64url=C.sha1_base64=C.sha1_hex=C.md5_base64url=C.md5_base64=C.md5_hex=C.hex=C.uppercase=C.lowercase=C.undefined=C.null=C.boolean=C.number=C.integer=C.bigint=C.string=C.date=C.e164=C.httpProtocol=C.domain=C.hostname=C.base64url=C.base64=C.cidrv6=C.cidrv4=C.mac=C.ipv6=C.ipv4=C.browserEmail=C.idnEmail=C.unicodeEmail=C.rfc5322Email=C.html5Email=C.email=C.uuid7=C.uuid6=C.uuid4=C.uuid=C.guid=C.extendedDuration=C.duration=C.nanoid=C.ksuid=C.xid=C.ulid=C.cuid2=C.cuid=void 0;C.sha512_base64url=C.sha512_base64=C.sha512_hex=C.sha384_base64url=C.sha384_base64=C.sha384_hex=void 0;C.emoji=bK;C.time=kK;C.datetime=AK;var pK=gK(W());C.cuid=/^[cC][0-9a-z]{6,}$/;C.cuid2=/^[0-9a-z]+$/;C.ulid=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;C.xid=/^[0-9a-vA-V]{20}$/;C.ksuid=/^[A-Za-z0-9]{27}$/;C.nanoid=/^[a-zA-Z0-9_-]{21}$/;C.duration=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;C.extendedDuration=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;C.guid=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;var hK=o=>o?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${o}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;C.uuid=hK;C.uuid4=(0,C.uuid)(4);C.uuid6=(0,C.uuid)(6);C.uuid7=(0,C.uuid)(7);C.email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;C.html5Email=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;C.rfc5322Email=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;C.unicodeEmail=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u;C.idnEmail=C.unicodeEmail;C.browserEmail=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;var fK="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function bK(){return new RegExp(fK,"u")}C.ipv4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;C.ipv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var yK=o=>{let e=pK.escapeRegex(o??":");return new RegExp(`^(?:[0-9A-F]{2}${e}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${e}){5}[0-9a-f]{2}$`)};C.mac=yK;C.cidrv4=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;C.cidrv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;C.base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;C.base64url=/^[A-Za-z0-9_-]*$/;C.hostname=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;C.domain=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;C.httpProtocol=/^https?$/;C.e164=/^\+[1-9]\d{6,14}$/;var a4="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";C.date=new RegExp(`^${a4}$`);function i4(o){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof o.precision=="number"?o.precision===-1?`${e}`:o.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${o.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function kK(o){return new RegExp(`^${i4(o)}$`)}function AK(o){let e=i4({precision:o.precision}),t=["Z"];o.local&&t.push(""),o.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let a=`${e}(?:${t.join("|")})`;return new RegExp(`^${a4}T(?:${a})$`)}var vK=o=>{let e=o?`[\\s\\S]{${o?.minimum??0},${o?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};C.string=vK;C.bigint=/^-?\d+n?$/;C.integer=/^-?\d+$/;C.number=/^-?\d+(?:\.\d+)?$/;C.boolean=/^(?:true|false)$/i;var wK=/^null$/i;C.null=wK;var xK=/^undefined$/i;C.undefined=xK;C.lowercase=/^[^A-Z]*$/;C.uppercase=/^[^a-z]*$/;C.hex=/^[0-9a-fA-F]*$/;function Ul(o,e){return new RegExp(`^[A-Za-z0-9+/]{${o}}${e}$`)}function Ml(o){return new RegExp(`^[A-Za-z0-9_-]{${o}}$`)}C.md5_hex=/^[0-9a-fA-F]{32}$/;C.md5_base64=Ul(22,"==");C.md5_base64url=Ml(22);C.sha1_hex=/^[0-9a-fA-F]{40}$/;C.sha1_base64=Ul(27,"=");C.sha1_base64url=Ml(27);C.sha256_hex=/^[0-9a-fA-F]{64}$/;C.sha256_base64=Ul(43,"=");C.sha256_base64url=Ml(43);C.sha384_hex=/^[0-9a-fA-F]{96}$/;C.sha384_base64=Ul(64,"");C.sha384_base64url=Ml(64);C.sha512_hex=/^[0-9a-fA-F]{128}$/;C.sha512_base64=Ul(86,"==");C.sha512_base64url=Ml(86)});var Xg=f($=>{"use strict";var zK=$&&$.__createBinding||(Object.create?(function(o,e,t,a){a===void 0&&(a=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(o,a,i)}):(function(o,e,t,a){a===void 0&&(a=t),o[a]=e[t]})),qK=$&&$.__setModuleDefault||(Object.create?(function(o,e){Object.defineProperty(o,"default",{enumerable:!0,value:e})}):function(o,e){o.default=e}),$A=$&&$.__importStar||function(o){if(o&&o.__esModule)return o;var e={};if(o!=null)for(var t in o)t!=="default"&&Object.prototype.hasOwnProperty.call(o,t)&&zK(e,o,t);return qK(e,o),e};Object.defineProperty($,"__esModule",{value:!0});$.$ZodCheckOverwrite=$.$ZodCheckMimeType=$.$ZodCheckProperty=$.$ZodCheckEndsWith=$.$ZodCheckStartsWith=$.$ZodCheckIncludes=$.$ZodCheckUpperCase=$.$ZodCheckLowerCase=$.$ZodCheckRegex=$.$ZodCheckStringFormat=$.$ZodCheckLengthEquals=$.$ZodCheckMinLength=$.$ZodCheckMaxLength=$.$ZodCheckSizeEquals=$.$ZodCheckMinSize=$.$ZodCheckMaxSize=$.$ZodCheckBigIntFormat=$.$ZodCheckNumberFormat=$.$ZodCheckMultipleOf=$.$ZodCheckGreaterThan=$.$ZodCheckLessThan=$.$ZodCheck=void 0;var no=$A(ls()),HA=$A(Kg()),xo=$A(W());$.$ZodCheck=no.$constructor("$ZodCheck",(o,e)=>{var t;o._zod??(o._zod={}),o._zod.def=e,(t=o._zod).onattach??(t.onattach=[])});var n4={number:"number",bigint:"bigint",object:"date"};$.$ZodCheckLessThan=no.$constructor("$ZodCheckLessThan",(o,e)=>{$.$ZodCheck.init(o,e);let t=n4[typeof e.value];o._zod.onattach.push(a=>{let i=a._zod.bag,r=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<r&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),o._zod.check=a=>{(e.inclusive?a.value<=e.value:a.value<e.value)||a.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:a.value,inclusive:e.inclusive,inst:o,continue:!e.abort})}});$.$ZodCheckGreaterThan=no.$constructor("$ZodCheckGreaterThan",(o,e)=>{$.$ZodCheck.init(o,e);let t=n4[typeof e.value];o._zod.onattach.push(a=>{let i=a._zod.bag,r=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>r&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),o._zod.check=a=>{(e.inclusive?a.value>=e.value:a.value>e.value)||a.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:a.value,inclusive:e.inclusive,inst:o,continue:!e.abort})}});$.$ZodCheckMultipleOf=no.$constructor("$ZodCheckMultipleOf",(o,e)=>{$.$ZodCheck.init(o,e),o._zod.onattach.push(t=>{var a;(a=t._zod.bag).multipleOf??(a.multipleOf=e.value)}),o._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):xo.floatSafeRemainder(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:o,continue:!e.abort})}});$.$ZodCheckNumberFormat=no.$constructor("$ZodCheckNumberFormat",(o,e)=>{$.$ZodCheck.init(o,e),e.format=e.format||"float64";let t=e.format?.includes("int"),a=t?"int":"number",[i,r]=xo.NUMBER_FORMAT_RANGES[e.format];o._zod.onattach.push(n=>{let s=n._zod.bag;s.format=e.format,s.minimum=i,s.maximum=r,t&&(s.pattern=HA.integer)}),o._zod.check=n=>{let s=n.value;if(t){if(!Number.isInteger(s)){n.issues.push({expected:a,format:e.format,code:"invalid_type",continue:!1,input:s,inst:o});return}if(!Number.isSafeInteger(s)){s>0?n.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:o,origin:a,inclusive:!0,continue:!e.abort}):n.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:o,origin:a,inclusive:!0,continue:!e.abort});return}}s<i&&n.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:o,continue:!e.abort}),s>r&&n.issues.push({origin:"number",input:s,code:"too_big",maximum:r,inclusive:!0,inst:o,continue:!e.abort})}});$.$ZodCheckBigIntFormat=no.$constructor("$ZodCheckBigIntFormat",(o,e)=>{$.$ZodCheck.init(o,e);let[t,a]=xo.BIGINT_FORMAT_RANGES[e.format];o._zod.onattach.push(i=>{let r=i._zod.bag;r.format=e.format,r.minimum=t,r.maximum=a}),o._zod.check=i=>{let r=i.value;r<t&&i.issues.push({origin:"bigint",input:r,code:"too_small",minimum:t,inclusive:!0,inst:o,continue:!e.abort}),r>a&&i.issues.push({origin:"bigint",input:r,code:"too_big",maximum:a,inclusive:!0,inst:o,continue:!e.abort})}});$.$ZodCheckMaxSize=no.$constructor("$ZodCheckMaxSize",(o,e)=>{var t;$.$ZodCheck.init(o,e),(t=o._zod.def).when??(t.when=a=>{let i=a.value;return!xo.nullish(i)&&i.size!==void 0}),o._zod.onattach.push(a=>{let i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(a._zod.bag.maximum=e.maximum)}),o._zod.check=a=>{let i=a.value;i.size<=e.maximum||a.issues.push({origin:xo.getSizableOrigin(i),code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:o,continue:!e.abort})}});$.$ZodCheckMinSize=no.$constructor("$ZodCheckMinSize",(o,e)=>{var t;$.$ZodCheck.init(o,e),(t=o._zod.def).when??(t.when=a=>{let i=a.value;return!xo.nullish(i)&&i.size!==void 0}),o._zod.onattach.push(a=>{let i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(a._zod.bag.minimum=e.minimum)}),o._zod.check=a=>{let i=a.value;i.size>=e.minimum||a.issues.push({origin:xo.getSizableOrigin(i),code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:o,continue:!e.abort})}});$.$ZodCheckSizeEquals=no.$constructor("$ZodCheckSizeEquals",(o,e)=>{var t;$.$ZodCheck.init(o,e),(t=o._zod.def).when??(t.when=a=>{let i=a.value;return!xo.nullish(i)&&i.size!==void 0}),o._zod.onattach.push(a=>{let i=a._zod.bag;i.minimum=e.size,i.maximum=e.size,i.size=e.size}),o._zod.check=a=>{let i=a.value,r=i.size;if(r===e.size)return;let n=r>e.size;a.issues.push({origin:xo.getSizableOrigin(i),...n?{code:"too_big",maximum:e.size}:{code:"too_small",minimum:e.size},inclusive:!0,exact:!0,input:a.value,inst:o,continue:!e.abort})}});$.$ZodCheckMaxLength=no.$constructor("$ZodCheckMaxLength",(o,e)=>{var t;$.$ZodCheck.init(o,e),(t=o._zod.def).when??(t.when=a=>{let i=a.value;return!xo.nullish(i)&&i.length!==void 0}),o._zod.onattach.push(a=>{let i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(a._zod.bag.maximum=e.maximum)}),o._zod.check=a=>{let i=a.value;if(i.length<=e.maximum)return;let n=xo.getLengthableOrigin(i);a.issues.push({origin:n,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:o,continue:!e.abort})}});$.$ZodCheckMinLength=no.$constructor("$ZodCheckMinLength",(o,e)=>{var t;$.$ZodCheck.init(o,e),(t=o._zod.def).when??(t.when=a=>{let i=a.value;return!xo.nullish(i)&&i.length!==void 0}),o._zod.onattach.push(a=>{let i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(a._zod.bag.minimum=e.minimum)}),o._zod.check=a=>{let i=a.value;if(i.length>=e.minimum)return;let n=xo.getLengthableOrigin(i);a.issues.push({origin:n,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:o,continue:!e.abort})}});$.$ZodCheckLengthEquals=no.$constructor("$ZodCheckLengthEquals",(o,e)=>{var t;$.$ZodCheck.init(o,e),(t=o._zod.def).when??(t.when=a=>{let i=a.value;return!xo.nullish(i)&&i.length!==void 0}),o._zod.onattach.push(a=>{let i=a._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),o._zod.check=a=>{let i=a.value,r=i.length;if(r===e.length)return;let n=xo.getLengthableOrigin(i),s=r>e.length;a.issues.push({origin:n,...s?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:a.value,inst:o,continue:!e.abort})}});$.$ZodCheckStringFormat=no.$constructor("$ZodCheckStringFormat",(o,e)=>{var t,a;$.$ZodCheck.init(o,e),o._zod.onattach.push(i=>{let r=i._zod.bag;r.format=e.format,e.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(e.pattern))}),e.pattern?(t=o._zod).check??(t.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:o,continue:!e.abort})}):(a=o._zod).check??(a.check=()=>{})});$.$ZodCheckRegex=no.$constructor("$ZodCheckRegex",(o,e)=>{$.$ZodCheckStringFormat.init(o,e),o._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:o,continue:!e.abort})}});$.$ZodCheckLowerCase=no.$constructor("$ZodCheckLowerCase",(o,e)=>{e.pattern??(e.pattern=HA.lowercase),$.$ZodCheckStringFormat.init(o,e)});$.$ZodCheckUpperCase=no.$constructor("$ZodCheckUpperCase",(o,e)=>{e.pattern??(e.pattern=HA.uppercase),$.$ZodCheckStringFormat.init(o,e)});$.$ZodCheckIncludes=no.$constructor("$ZodCheckIncludes",(o,e)=>{$.$ZodCheck.init(o,e);let t=xo.escapeRegex(e.includes),a=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=a,o._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(a)}),o._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:o,continue:!e.abort})}});$.$ZodCheckStartsWith=no.$constructor("$ZodCheckStartsWith",(o,e)=>{$.$ZodCheck.init(o,e);let t=new RegExp(`^${xo.escapeRegex(e.prefix)}.*`);e.pattern??(e.pattern=t),o._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),o._zod.check=a=>{a.value.startsWith(e.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:a.value,inst:o,continue:!e.abort})}});$.$ZodCheckEndsWith=no.$constructor("$ZodCheckEndsWith",(o,e)=>{$.$ZodCheck.init(o,e);let t=new RegExp(`.*${xo.escapeRegex(e.suffix)}$`);e.pattern??(e.pattern=t),o._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(t)}),o._zod.check=a=>{a.value.endsWith(e.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:a.value,inst:o,continue:!e.abort})}});function r4(o,e,t){o.issues.length&&e.issues.push(...xo.prefixIssues(t,o.issues))}$.$ZodCheckProperty=no.$constructor("$ZodCheckProperty",(o,e)=>{$.$ZodCheck.init(o,e),o._zod.check=t=>{let a=e.schema._zod.run({value:t.value[e.property],issues:[]},{});if(a instanceof Promise)return a.then(i=>r4(i,t,e.property));r4(a,t,e.property)}});$.$ZodCheckMimeType=no.$constructor("$ZodCheckMimeType",(o,e)=>{$.$ZodCheck.init(o,e);let t=new Set(e.mime);o._zod.onattach.push(a=>{a._zod.bag.mime=e.mime}),o._zod.check=a=>{t.has(a.value.type)||a.issues.push({code:"invalid_value",values:e.mime,input:a.value.type,inst:o,continue:!e.abort})}});$.$ZodCheckOverwrite=no.$constructor("$ZodCheckOverwrite",(o,e)=>{$.$ZodCheck.init(o,e),o._zod.check=t=>{t.value=e.tx(t.value)}})});var VA=f(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});ep.Doc=void 0;var GA=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let a=e.split(`
@@ -1663,7 +1663,7 @@ ${r}`;break;case"retry":CN(r)&&(t[i]=r);break;case"id":SN(r)&&(t[i]=r);break;cas
1663
1663
  `);o.stack=t?`${t}
1664
1664
  ${r}`:i.stack}G.exports.fetch=function(e,t=void 0){return RIe(e,t).catch(a=>{throw LN?HN(a,LN):a&&typeof a=="object"&&Error.captureStackTrace(a,G.exports.fetch),a})};G.exports.Headers=Hs().Headers;G.exports.Response=cd().Response;G.exports.Request=xm().Request;G.exports.FormData=mf().FormData;var{setGlobalOrigin:NIe,getGlobalOrigin:OIe}=ix();G.exports.setGlobalOrigin=NIe;G.exports.getGlobalOrigin=OIe;var{CacheStorage:UIe}=IR(),{kConstruct:MIe}=Ue();G.exports.caches=new UIe(MIe);var{deleteCookie:LIe,getCookies:PIe,getSetCookies:FIe,setCookie:$Ie,parseCookie:HIe}=UR();G.exports.deleteCookie=LIe;G.exports.getCookies=PIe;G.exports.getSetCookies=FIe;G.exports.setCookie=$Ie;G.exports.parseCookie=HIe;var{parseMIMEType:GIe,serializeAMimeType:VIe}=ma();G.exports.parseMIMEType=GIe;G.exports.serializeAMimeType=VIe;var{CloseEvent:YIe,ErrorEvent:JIe,MessageEvent:WIe}=jb(),{WebSocket:ZIe,ping:KIe}=yN();G.exports.WebSocket=ZIe;G.exports.CloseEvent=YIe;G.exports.ErrorEvent=JIe;G.exports.MessageEvent=WIe;G.exports.ping=KIe;G.exports.WebSocketStream=EN().WebSocketStream;G.exports.WebSocketError=Dq().WebSocketError;G.exports.request=Ad(Dm.request);G.exports.stream=Ad(Dm.stream);G.exports.pipeline=Ad(Dm.pipeline);G.exports.connect=Ad(Dm.connect);G.exports.upgrade=Ad(Dm.upgrade);G.exports.MockClient=zIe;G.exports.MockCallHistory=qIe;G.exports.MockCallHistoryLog=EIe;G.exports.MockPool=jIe;G.exports.MockAgent=IIe;G.exports.SnapshotAgent=CIe;G.exports.mockErrors=SIe;var{EventSource:XIe}=MN();G.exports.EventSource=XIe;function e2e(){globalThis.fetch=G.exports.fetch,globalThis.Headers=G.exports.Headers,globalThis.Response=G.exports.Response,globalThis.Request=G.exports.Request,globalThis.FormData=G.exports.FormData,globalThis.WebSocket=G.exports.WebSocket,globalThis.CloseEvent=G.exports.CloseEvent,globalThis.ErrorEvent=G.exports.ErrorEvent,globalThis.MessageEvent=G.exports.MessageEvent,globalThis.EventSource=G.exports.EventSource}G.exports.install=e2e});var YN=f(Rm=>{"use strict";Object.defineProperty(Rm,"__esModule",{value:!0});Rm.SuperglueClient=Rm.SuperglueHttpError=void 0;var Tm=Ht(),Mr=xv(),o2e=ew(),t2e=rQ(),a2e=Fa(),Lr=zc(),i2e=Lg(),wd=14400*1e3,vd;if(typeof globalThis.process<"u"&&globalThis.process.versions?.node)try{let{Agent:o}=GN();vd=new o({headersTimeout:wd,bodyTimeout:wd})}catch{}function VN(o){if(o?.aborted)throw o.reason??new DOMException("Aborted","AbortError")}var Pb=class extends Error{constructor(e,t,a,i){super(e),this.status=t,this.code=a,this.details=i,this.name="SuperglueHttpError"}};Rm.SuperglueHttpError=Pb;var Mq=class{constructor({apiKey:e,apiEndpoint:t,onInfrastructureError:a,refreshToken:i,sseTokenProvider:r,tokenProvider:n}){if(!e&&!n)throw new Error("SuperglueClient requires either apiKey or tokenProvider");this.tokenProvider=n??(async()=>e),this.apiEndpoint=t??"https://api.superglue.cloud",this.sseManager=new o2e.SSELogSubscriptionManager(this.apiEndpoint,r??this.tokenProvider,i),this.onInfrastructureError=a,this.refreshToken=i}async getApiKey(){return this.tokenProvider()}async fetchWithAuthRetry(e,t){let a=await this.getApiKey(),i=await e(a);if(i.status!==401||!this.refreshToken)return i;VN(t);let r=await this.refreshToken();return VN(t),!r||r===a?i:(i.body?.cancel(),e(r))}isInfrastructureError(e){return(0,a2e.isAbortError)(e)?!1:!!(e instanceof TypeError&&e.message.toLowerCase().includes("fetch")||e instanceof Error&&e.name==="TimeoutError")}async restRequest(e,t,a,i,r){let s=await(await this.restResponse({method:e,path:t,body:a,extraHeaders:i,requestInit:r})).text();if(s)return JSON.parse(s)}async restResponse({method:e,path:t,body:a,extraHeaders:i,requestInit:r}){let n=`${this.apiEndpoint.replace(/\/$/,"")}${t}`,s=a!=null,c=typeof FormData<"u"&&a instanceof FormData,m=u=>{let d={Authorization:`Bearer ${u}`,...i};return s&&!c&&e!=="GET"&&(d["Content-Type"]="application/json"),fetch(n,{...r,method:e,headers:d,body:s?c?a:JSON.stringify(a):void 0,signal:r?.signal??AbortSignal.timeout(wd),...vd?{dispatcher:vd}:{}})},l;try{l=await this.fetchWithAuthRetry(m,r?.signal)}catch(u){throw this.isInfrastructureError(u)&&this.onInfrastructureError?.(),u}if(!l.ok)throw await this.buildHttpError(l);return l}async uploadFiles(e,t){if(typeof t?.process!="boolean")throw new Error("process must be a boolean");if(e.length===0)return[];let a=e.map(l=>({...l,contentLength:l.contentLength??this.getUploadContentLength(l.content)})),r=(await this.restRequest("POST","/v1/files/uploads",{process:t.process,files:a.map(({fileName:l,contentType:u,contentLength:d})=>({fileName:l,contentLength:d,...u?{contentType:u}:{}}))})).data.files;if(r.length!==a.length)throw await Promise.all(r.map(l=>this.deleteFileUpload(l.id).catch(()=>{}))),new Error("Upload response did not match the selected files");let n=await Promise.allSettled(r.map(async(l,u)=>{let d=a[u],g=await fetch(l.uploadUrl,{method:"PUT",body:d.content,headers:d.contentType?{"Content-Type":d.contentType}:void 0,signal:AbortSignal.timeout(Math.min(wd,l.expiresIn*1e3))});if(!g.ok)throw new Error(`Upload failed for ${d.fileName}: ${g.status} ${g.statusText}`);return l.id})),s=n.flatMap(l=>l.status==="fulfilled"?[l.value]:[]),c=new Map;if(s.length>0)try{let l=await this.restRequest("POST","/v1/files/uploads/complete",{fileIds:s});c=new Map(l.data.files.map(u=>[u.id,u]))}catch(l){c=new Map(s.map(u=>[u,{id:u,fileName:a[r.findIndex(d=>d.id===u)]?.fileName||u,contentLength:a[r.findIndex(d=>d.id===u)]?.contentLength||0,status:"failed",error:l instanceof Error?l.message:String(l)}]))}let m=r.map((l,u)=>{let d=n[u],g=a[u];return d.status==="rejected"?{id:l.id,fileName:g.fileName,contentLength:g.contentLength,status:"failed",error:d.reason instanceof Error?d.reason.message:String(d.reason)}:c.get(l.id)||{id:l.id,fileName:g.fileName,contentLength:g.contentLength,status:"failed",error:"Upload completion returned no result"}});return await Promise.all(m.filter(l=>l.status==="failed").map(l=>this.deleteFileUpload(l.id).catch(()=>{}))),m}async deleteFileUpload(e){await this.restRequest("DELETE",`/v1/files/uploads/${encodeURIComponent(e)}`)}getUploadContentLength(e){return typeof e=="string"?new TextEncoder().encode(e).byteLength:e instanceof Uint8Array?e.byteLength:e.size}async buildHttpError(e){e.status>=500&&this.onInfrastructureError?.();let t=await e.text(),a=`HTTP ${e.status}: ${t}`,i,r;try{let n=JSON.parse(t);n&&typeof n=="object"&&!Array.isArray(n)&&(r=n),typeof n?.code=="string"&&(i=n.code);let s=n.error;typeof s=="string"?a=s:s&&typeof s=="object"&&(a=s.message||JSON.stringify(s))}catch{}return new Pb(a,e.status,i,r)}async streamRequest(e,t,a){let i=e.includes("?")?"&":"?",r=`${this.apiEndpoint.replace(/\/$/,"")}${e}${i}stream=true`,n=m=>fetch(r,{method:"POST",headers:{Authorization:`Bearer ${m}`,Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify(t),signal:a??AbortSignal.timeout(wd),...vd?{dispatcher:vd}:{}}),s;try{s=await this.fetchWithAuthRetry(n,a)}catch(m){throw this.isInfrastructureError(m)&&this.onInfrastructureError?.(),m}if(!s.ok)throw await this.buildHttpError(s);if(!(s.headers.get("content-type")||"").includes("text/event-stream")){let m=await s.text();return m?JSON.parse(m):void 0}try{return await(0,t2e.consumeEventStreamResult)(s)}catch(m){throw this.isInfrastructureError(m)&&this.onInfrastructureError?.(),m}}async subscribeToLogsSSE(e={}){return this.sseManager.subscribeToLogs(e)}async disconnect(){await this.sseManager.disconnect()}async getMe(){return this.restRequest("GET","/v1/me")}async completeOnboarding(){return this.restRequest("POST","/v1/me/onboarding/complete")}async runTool(e){let t=await this.restRequest("POST",`/v1/tools/${encodeURIComponent(e.toolId)}/run`,{inputs:e.payload,files:e.files,credentials:e.credentials,includeStepResultData:e.includeStepResultData,options:e.options,runId:e.runId,stateFixture:e.stateFixture},void 0,e.signal?{signal:e.signal}:void 0);return{success:t.status==="success",data:t.data,error:t.error,tool:t.tool,stepResults:t.stepResults?.map(a=>({...a}))||[],...t.fileArtifacts&&t.fileArtifacts.length>0?{fileArtifacts:t.fileArtifacts}:{},...t.metadata?.warnings?.length?{warnings:t.metadata.warnings}:{}}}async runToolConfig(e){let t=e.createRun?"/v1/tools/run?createRun=true":"/v1/tools/run",a=await this.restRequest("POST",t,{tool:e.tool,payload:e.payload,files:e.files,credentials:e.credentials,includeStepResultData:e.includeStepResultData,options:e.options,runId:e.runId,stateFixture:e.stateFixture,executionKind:e.executionKind,parentToolId:e.parentToolId,draftId:e.draftId},e.traceId?{"X-Trace-Id":e.traceId}:void 0,e.signal?{signal:e.signal}:void 0);return{success:a.status?a.status==="success":a.success??!1,data:a.data,error:a.error,tool:a.tool||e.tool,stepResults:a.stepResults?.map(r=>({...r}))||[],...a.fileArtifacts&&a.fileArtifacts.length>0?{fileArtifacts:a.fileArtifacts}:{},...a.metadata?.warnings?.length?{warnings:a.metadata.warnings}:{}}}async abortToolExecution(e){return{success:!0,runId:(await this.restRequest("POST",`/v1/runs/${encodeURIComponent(e)}/cancel`)).runId}}async executeStep({step:e,payload:t,files:a,previousResults:i,credentials:r,options:n,runId:s,systemIds:c,createRun:m,parentToolId:l,stepIndex:u,stepId:d,signal:g,stream:h}){let k={step:e,payload:t,files:a,previousResults:i,credentials:r,options:n,runId:s,systemIds:c,createRun:m,parentToolId:l,stepIndex:u,stepId:d};return h?this.streamRequest("/v1/tools/step/run",k,g):this.restRequest("POST","/v1/tools/step/run",k,void 0,g?{signal:g}:void 0)}async abortStep(e){return this.restRequest("POST","/v1/tools/step/abort",{runId:e})}async executeTransformOnly({outputTransform:e,outputSchema:t,inputSchema:a,payload:i,files:r,stepResults:n,options:s,runId:c,createRun:m,parentToolId:l,stepId:u,signal:d,stream:g}){let h={outputTransform:e,outputSchema:t,inputSchema:a,payload:i,files:r,stepResults:n,options:s,runId:c,createRun:m,parentToolId:l,stepId:u};return g?this.streamRequest("/v1/tools/transform/run",h,d):this.restRequest("POST","/v1/tools/transform/run",h,void 0,d?{signal:d}:void 0)}async createRun({toolId:e,toolConfig:t,toolResult:a,stepResults:i,toolPayload:r,status:n,error:s,startedAt:c,completedAt:m,executionKind:l,parentToolId:u,draftId:d}){return this.restRequest("POST","/v1/runs",{toolId:e,toolConfig:t,toolResult:a,stepResults:i,toolPayload:r,status:n,error:s,startedAt:(0,Lr.toUTCISOString)(c,"run.startedAt"),completedAt:(0,Lr.toUTCISOString)(m,"run.completedAt"),executionKind:l,parentToolId:u,draftId:d})}async checkRunLimit(){return(await this.restRequest("POST","/v1/runs/check-limit")).data}async extract({file:e,envelope:t}){if(!e)throw new Error("File must be provided for extract.");let a=new FormData;a.append("file",e);let i=t?"/v1/extract?envelope=true":"/v1/extract";return this.restRequest("POST",i,a)}mapOpenAPIRunToRun(e){let t={running:Tm.RunStatus.RUNNING,success:Tm.RunStatus.SUCCESS,failed:Tm.RunStatus.FAILED,aborted:Tm.RunStatus.ABORTED};return{runId:e.runId??e.id,toolId:e.toolId,tool:e.tool,systemIds:e.systemIds,status:t[e.status]??Tm.RunStatus.FAILED,toolPayload:e.toolPayload,data:e.data,toolResult:e.data,error:e.error,stepResults:e.stepResults,options:e.options,requestSource:e.requestSource,traceId:e.traceId,resultStorageUri:e.resultStorageUri,userId:e.userId,userEmail:e.userEmail,userName:e.userName,metadata:{...e.metadata,executionKind:e.metadata?.executionKind??Tm.RunExecutionKind.FULL},fileArtifacts:e.fileArtifacts}}mapOpenAPIScheduleToToolSchedule(e){return{...e,lastRunAt:e.lastRunAt?(0,Lr.requireUTCDate)(e.lastRunAt,"schedule.lastRunAt"):void 0,nextRunAt:(0,Lr.requireUTCDate)(e.nextRunAt,"schedule.nextRunAt"),createdAt:(0,Lr.requireUTCDate)(e.createdAt,"schedule.createdAt"),updatedAt:(0,Lr.requireUTCDate)(e.updatedAt,"schedule.updatedAt")}}async listRuns(e={}){let t=(0,Mr.createSearchListQueryParams)(e);e.toolId!==void 0&&t.set("toolId",e.toolId),e.searchUserIds?.length&&t.set("searchUserIds",e.searchUserIds.join(",")),e.includeTotal!==void 0&&t.set("includeTotal",String(e.includeTotal)),e.startedAfter!==void 0&&t.set("startedAfter",e.startedAfter instanceof Date?(0,Lr.toUTCISOString)(e.startedAfter,"run.startedAfter"):e.startedAfter),e.statuses!==void 0?t.set("status",e.statuses.join(",")):e.status!==void 0&&t.set("status",e.status),e.requestSources!==void 0&&t.set("requestSources",e.requestSources.join(",")),e.executionKinds!==void 0&&t.set("executionKinds",e.executionKinds.join(",")),e.userId!==void 0&&t.set("userId",e.userId),e.systemId!==void 0&&t.set("systemId",e.systemId),e.systemIds!==void 0&&t.set("systemIds",e.systemIds.join(","));let a=t.size>0?`?${t.toString()}`:"",i=await this.restRequest("GET",`/v1/runs${a}`,void 0,void 0,{signal:e.signal});return{data:i.data.map(r=>this.mapOpenAPIRunToRun(r)),total:i.total,page:i.page,limit:i.limit,hasMore:i.hasMore}}async getActivityCounts(e){let t=new URLSearchParams;e?.from&&t.set("from",e.from instanceof Date?(0,Lr.toUTCISOString)(e.from,"activity.from"):e.from),e?.to&&t.set("to",e.to instanceof Date?(0,Lr.toUTCISOString)(e.to,"activity.to"):e.to);let a=t.toString();return(await this.restRequest("GET",`/v1/activity/counts${a?`?${a}`:""}`,void 0,void 0,{signal:e?.signal})).counts}async getRun(e){try{let t=await this.restRequest("GET",`/v1/runs/${encodeURIComponent(e)}`);return this.mapOpenAPIRunToRun(t)}catch(t){if(t.message?.includes("404")||t.message?.includes("not found"))return null;throw t}}async getTool(e){try{return await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}`)}catch(t){if(t.message?.includes("404")||t.message?.includes("not found")||t.message?.includes("403")||t.message?.includes("not allowed"))return null;throw t}}async getToolState(e){return(await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/state`)).state}async setToolState(e,t){await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/state`,{state:t})}async deleteToolState(e){return(await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/state`)).deletedKeys}async archiveTool(e,t=!0){return this.updateTool(e,{archived:t})}async bulkArchiveTools(e,t=!0){return this.restRequest("POST","/v1/tools/bulk/archive",{ids:e,archived:t})}async bulkDeleteTools(e){return this.restRequest("POST","/v1/tools/bulk/delete",{ids:e})}async listTools(e={}){let t=(0,Mr.createListQueryParams)(e);e.includeArchived!==void 0&&t.set("includeArchived",String(e.includeArchived));let a=t.size>0?`?${t.toString()}`:"";return this.restRequest("GET",`/v1/tools${a}`)}async listAllTools(e={}){return(0,Mr.listAllPages)((t,a)=>this.listTools({...e,page:t,limit:a}))}async createTool(e,t){return this.restRequest("POST","/v1/tools",{...t,id:e})}async updateTool(e,t){return this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}`,t)}async deleteTool(e){try{return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}`),!0}catch(t){if(t.message?.includes("404"))return!1;throw t}}async renameTool(e,t){return this.restRequest("POST",`/v1/tools/${encodeURIComponent(e)}/rename`,{newId:t})}async getWorkflow(e){return this.getTool(e)}async archiveWorkflow(e,t=!0){return this.upsertWorkflow(e,{archived:t})}async createWorkflow(e,t){return this.createTool(e,t)}async updateWorkflow(e,t){return this.updateTool(e,t)}async upsertWorkflow(e,t){return await this.getTool(e)?this.updateTool(e,t):this.createTool(e,t)}async deleteWorkflow(e){return this.deleteTool(e)}async renameWorkflow(e,t){return this.renameTool(e,t)}async listSchedules(e={}){let t=(0,Mr.createListQueryParams)(e),a=t.size>0?`?${t.toString()}`:"",i=e.toolId?`/v1/tools/${encodeURIComponent(e.toolId)}/schedules${a}`:`/v1/schedules${a}`,r=await this.restRequest("GET",i);return{...r,data:r.data.map(n=>this.mapOpenAPIScheduleToToolSchedule(n))}}async listAllSchedules(e={}){return(0,Mr.listAllPages)((t,a)=>this.listSchedules({...e,page:t,limit:a}))}async getToolSchedule(e,t){try{let a=await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t)}`);return this.mapOpenAPIScheduleToToolSchedule(a)}catch(a){if(a.message?.includes("404")||a.message?.includes("not found"))return null;throw a}}async createToolSchedule(e,t){let a=await this.restRequest("POST",`/v1/tools/${encodeURIComponent(e)}/schedules`,{...t,timezone:t.timezone||(0,i2e.getRuntimeTimezone)()});return this.mapOpenAPIScheduleToToolSchedule(a)}async updateToolSchedule(e,t,a){let i=await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t)}`,a);return this.mapOpenAPIScheduleToToolSchedule(i)}async deleteToolSchedule(e,t){return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(t)}`),!0}async bulkSetSchedulesEnabled(e,t){return this.restRequest("POST","/v1/schedules/bulk/enable",{ids:e,enabled:t})}async bulkDeleteSchedules(e){return this.restRequest("POST","/v1/schedules/bulk/delete",{ids:e})}async listCredentials(e={}){let t=(0,Mr.createListQueryParams)(e);e.systemId!==void 0&&t.set("systemId",e.systemId);let a=t.size>0?`?${t.toString()}`:"";return this.restRequest("GET",`/v1/credentials${a}`)}async listAllCredentials(e={}){return(0,Mr.listAllPages)((t,a)=>this.listCredentials({...e,page:t,limit:a}))}async createCredentials(e){return(await this.restRequest("POST","/v1/credentials",e)).data}async replaceCredentials(e,t){return(await this.restRequest("PUT",`/v1/credentials/${encodeURIComponent(e)}`,{credentials:t})).data}async updateCredentials(e,t){return(await this.restRequest("PATCH",`/v1/credentials/${encodeURIComponent(e)}`,t)).data}async deleteCredentials(e){await this.restRequest("DELETE",`/v1/credentials/${encodeURIComponent(e)}`)}async setDefaultCredentials(e){await this.restRequest("POST",`/v1/credentials/${encodeURIComponent(e)}/default`)}async listSystems(e={}){let t=(0,Mr.createListQueryParams)(e),a=t.size>0?`?${t.toString()}`:"";return this.restRequest("GET",`/v1/systems${a}`)}async listAllSystems(e={}){return(0,Mr.listAllPages)((t,a)=>this.listSystems({...e,page:t,limit:a}))}async getSystem(e){return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}`)).data}async createSystem(e){return(await this.restRequest("POST","/v1/systems",e)).data}async updateSystem(e,t){return(await this.restRequest("PATCH",`/v1/systems/${encodeURIComponent(e)}`,t)).data}async deleteSystem(e){return await this.restRequest("DELETE",`/v1/systems/${encodeURIComponent(e)}`),!0}async bulkDeleteSystems(e){return this.restRequest("POST","/v1/systems/bulk/delete",{ids:e})}async createOAuthExchange(e){return(await this.restRequest("POST","/v1/oauth/exchanges",e)).data}async completeOAuthExchange(e,t){return(await this.restRequest("POST",`/v1/oauth/exchanges/${encodeURIComponent(e)}/complete`,t)).data}async searchSystemDocumentation(e,t){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/search`,{keywords:t})).data}async triggerSystemDocumentationScrapeJob(e,t){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/scrape`,t)).data}async fetchOpenApiSpec(e,t,a){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/openapi`,{url:t,link:a?.link})).data}async uploadSystemDocumentationFiles(e,t,a){let i=await this.uploadFiles(t,{process:!0}),r=i.flatMap(n=>n.status==="uploaded"?[n.id]:[]);if(r.length>0)try{await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/files`,{fileIds:r,link:a?.link!==!1})}catch(n){throw await Promise.all(r.map(s=>this.deleteFileUpload(s).catch(()=>{}))),n}if(!a?.settle){let n=i.filter(s=>s.status==="failed");if(n.length>0)throw new Error(n.map(s=>s.error).join("; "))}return i}async listSystemDocumentationFiles(e,t){let a=new URLSearchParams;t?.length&&a.set("fileIds",t.join(","));let i=a.size>0?`?${a.toString()}`:"";return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/documentation/files${i}`)).data}async getSystemDocumentationFileContent(e,t,a){return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/documentation/files/${encodeURIComponent(t)}/content?processed=${a.processed}`)).data}async deleteSystemDocumentationFile(e,t){await this.restRequest("DELETE",`/v1/systems/${encodeURIComponent(e)}/documentation/files/${encodeURIComponent(t)}`)}async generateCredentialsLink(e){try{return{success:!0,credentialsUrl:(await this.restRequest("POST","/v1/authenticate",e||{})).data.credentialsUrl}}catch(t){return{success:!1,error:t.message}}}};Rm.SuperglueClient=Mq});var WN=f(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.UnquotedKeyStrategy=ao.TripleQuoteStrategy=ao.TrailingCommaStrategy=ao.SingleQuoteStrategy=ao.PythonLiteralStrategy=ao.CommentStrategy=ao.ResilientJsonParser=ao.RepairStrategy=void 0;ao.parseJsonResilient=r2e;ao.parseJSON=n2e;ao.isValidJson=s2e;ao.prettyPrintJson=c2e;ao.minifyJson=m2e;var Ra=class{validate(e){try{return JSON.parse(e),!0}catch{return!1}}};ao.RepairStrategy=Ra;var Fb=class extends Ra{constructor(){super(...arguments),this.name="TripleQuoteRepair",this.description="Converts triple-quoted strings to proper JSON, parsing nested JSON content"}canApply(e){return/"""/.test(e)}apply(e){return e.replace(/"""([\s\S]*?)"""/g,(t,a)=>{let i=a.trim();if(i.startsWith("{")&&i.endsWith("}")||i.startsWith("[")&&i.endsWith("]"))try{let n=JSON.parse(i);return JSON.stringify(n)}catch{return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`})}};ao.TripleQuoteStrategy=Fb;var $b=class extends Ra{constructor(){super(...arguments),this.name="PythonLiteralRepair",this.description="Converts Python literals to JavaScript equivalents"}canApply(e){return/\b(None|True|False)\b/.test(e)}apply(e){return e.replace(/\bNone\b/g,"null").replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false")}};ao.PythonLiteralStrategy=$b;var Hb=class extends Ra{constructor(){super(...arguments),this.name="TrailingCommaRepair",this.description="Removes trailing commas from objects and arrays"}canApply(e){return/,\s*[}\]]/.test(e)}apply(e){return e.replace(/,(\s*[}\]])/g,"$1")}};ao.TrailingCommaStrategy=Hb;var Gb=class extends Ra{constructor(){super(...arguments),this.name="SingleQuoteRepair",this.description="Converts single quotes to double quotes"}canApply(e){return/[{,]\s*'[^']*'\s*:/.test(e)||/:\s*'[^']*'/.test(e)}apply(e){let t=e.replace(/([{,]\s*)'([^']+)'(\s*:)/g,'$1"$2"$3');return t=t.replace(/(:\s*)'([^']+)'(\s*[,}])/g,'$1"$2"$3'),t}};ao.SingleQuoteStrategy=Gb;var Vb=class extends Ra{constructor(){super(...arguments),this.name="UnquotedKeyRepair",this.description="Adds quotes to unquoted object keys"}canApply(e){return/[{,]\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*:/.test(e)}apply(e){return e.replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)(\s*:)/g,'$1"$2"$3')}};ao.UnquotedKeyStrategy=Vb;var Yb=class extends Ra{constructor(){super(...arguments),this.name="CommentRemoval",this.description="Removes JavaScript-style comments"}canApply(e){return/\/\/.*$|\/\*[\s\S]*?\*\//m.test(e)}apply(e){let t=e.replace(/\/\/.*$/gm,"");return t=t.replace(/\/\*[\s\S]*?\*\//g,""),t}};ao.CommentStrategy=Yb;var Lq=class extends Ra{constructor(){super(...arguments),this.name="UnescapedControlCharactersRepair",this.description="Escapes unescaped control characters (newlines, tabs, etc.) in JSON strings"}canApply(e){try{return JSON.parse(e),!1}catch(t){let a=t.message||"";return a.includes("control character")||a.includes("Bad control")||a.includes("Unexpected token")&&/[\n\r\t]/.test(e)}}apply(e){let t="",a=!1,i=!1;for(let r=0;r<e.length;r++){let n=e[r],s=r>0?e[r-1]:"";if(i){t+=n,i=!1;continue}if(n==="\\"&&a){t+=n,i=!0;continue}if(n==='"'&&s!=="\\"){a=!a,t+=n;continue}if(a)switch(n){case`
1665
1665
  `:t+="\\n";break;case"\r":t+="\\r";break;case" ":t+="\\t";break;case"\b":t+="\\b";break;case"\f":t+="\\f";break;default:let c=n.charCodeAt(0);c<32?t+="\\u"+("0000"+c.toString(16)).slice(-4):t+=n}else t+=n}return t}},Pq=class extends Ra{constructor(){super(...arguments),this.name="TrailingCharactersRepair",this.description="Removes trailing characters after valid JSON structure"}canApply(e){let t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return!1;let a=0,i=0,r=!1,n=!1;for(let s=0;s<t.length;s++){let c=t[s];if(r)n?n=!1:c==="\\"?n=!0:c==='"'&&(r=!1);else if(c==='"')r=!0;else if(c==="{")a++;else if(c==="}"){if(a--,a===0&&i===0&&s>0&&s<t.length-1)return!0}else if(c==="[")i++;else if(c==="]"&&(i--,i===0&&a===0&&s>0&&s<t.length-1))return!0}return!1}apply(e){let t=e.trim(),a=0,i=0,r=!1,n=!1,s=-1;for(let c=0;c<t.length;c++){let m=t[c];if(r)n?n=!1:m==="\\"?n=!0:m==='"'&&(r=!1);else if(m==='"')r=!0;else if(m==="{")a++;else if(m==="}"){if(a--,a===0&&i===0&&c>0){s=c;break}}else if(m==="[")i++;else if(m==="]"&&(i--,i===0&&a===0&&c>0)){s=c;break}}return s>0&&s<t.length-1?t.substring(0,s+1):e}},Nm=class{constructor(e={}){this.strategies=[],this.repairLog=[],this.options={attemptRepair:!0,maxDepth:10,preserveStringsOnFailure:!1,logRepairs:!1,...e},this.initializeDefaultStrategies(),e.customStrategies&&this.strategies.push(...e.customStrategies)}initializeDefaultStrategies(){this.strategies=[new Fb,new Gb,new Lq,new Pq,new $b,new Hb,new Vb,new Yb]}parse(e){let t=Date.now();this.repairLog=[];let a=e instanceof Buffer?e.toString("utf8"):String(e);try{return{success:!0,data:JSON.parse(a),metadata:{parseTime:Date.now()-t,strategiesApplied:[]}}}catch(n){if(!this.options.attemptRepair)return{success:!1,error:`JSON parse error: ${n}`,metadata:{parseTime:Date.now()-t}}}let i=a,r=[];for(let n of this.strategies)if(n.canApply(i)){let s=i;if(i=n.apply(i),s!==i){r.push(n.name),this.repairLog.push(n.description),this.options.logRepairs&&console.log(`Applied ${n.name}: ${n.description}`);try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:r}}}catch{}}}try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:r}}}catch(n){let s=this.aggressiveFallback(i);return s.success?{...s,repairs:[...this.repairLog,"Applied aggressive fallback"],metadata:{parseTime:Date.now()-t,strategiesApplied:[...r,"AggressiveFallback"]}}:{success:!1,error:`Failed to parse JSON after applying ${r.length} strategies: ${n}`,repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:r}}}}aggressiveFallback(e){try{let t=e.indexOf("{"),a=e.indexOf("[");if(t===-1&&a===-1)return{success:!1,error:"No JSON-like structure found"};let i=t===-1?a:a===-1?t:Math.min(t,a),r=e.substring(i);for(let s of this.strategies)s.canApply(r)&&(r=s.apply(r));return{success:!0,data:JSON.parse(r)}}catch(t){return{success:!1,error:`Aggressive fallback failed: ${t}`}}}addStrategy(e){this.strategies.push(e)}removeStrategy(e){this.strategies=this.strategies.filter(t=>t.name!==e)}getStrategies(){return this.strategies.map(e=>e.name)}};ao.ResilientJsonParser=Nm;var JN=new Nm;function r2e(o,e){return(e?new Nm(e):JN).parse(o)}function n2e(o){let e=JN.parse(o);if(e.success)return e.repairs&&e.repairs.length>0&&console.log("JSON parsed with repairs:",e.repairs),e.data;throw new Error(`Failed to parse JSON: ${e.error}`)}function s2e(o){try{return JSON.parse(o),!0}catch{return!1}}function c2e(o,e=2){return JSON.stringify(o,null,e)}function m2e(o){let t=new Nm().parse(o);if(t.success)return JSON.stringify(t.data);throw new Error("Cannot minify invalid JSON")}});var Pt=f(oe=>{"use strict";var l2e=oe&&oe.__createBinding||(Object.create?(function(o,e,t,a){a===void 0&&(a=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(o,a,i)}):(function(o,e,t,a){a===void 0&&(a=t),o[a]=e[t]})),he=oe&&oe.__exportStar||function(o,e){for(var t in o)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&l2e(e,o,t)};Object.defineProperty(oe,"__esModule",{value:!0});oe.SSELogSubscriptionManager=oe.SuperglueHttpError=oe.SuperglueClient=void 0;he(NC(),oe);he(VC(),oe);he(u8(),oe);he(f8(),oe);he(A8(),oe);he(iu(),oe);he(M8(),oe);he(L8(),oe);he(P8(),oe);he(F8(),oe);he(xv(),oe);he(H8(),oe);he(G8(),oe);he(V8(),oe);he(Ev(),oe);he(W8(),oe);he(K8(),oe);he(X8(),oe);he(o3(),oe);he(Md(),oe);he(a3(),oe);he(i3(),oe);he(n3(),oe);he(m3(),oe);he(Cv(),oe);he(h3(),oe);he(b3(),oe);he(k3(),oe);he(A3(),oe);he(B3(),oe);he(_3(),oe);he(Fv(),oe);he(G3(),oe);he(Zv(),oe);he(W3(),oe);he(eQ(),oe);he(tQ(),oe);he(Ht(),oe);he(Fa(),oe);he(aQ(),oe);he(iQ(),oe);he(jh(),oe);he(zc(),oe);he(Lg(),oe);var ZN=YN();Object.defineProperty(oe,"SuperglueClient",{enumerable:!0,get:function(){return ZN.SuperglueClient}});Object.defineProperty(oe,"SuperglueHttpError",{enumerable:!0,get:function(){return ZN.SuperglueHttpError}});var u2e=ew();Object.defineProperty(oe,"SSELogSubscriptionManager",{enumerable:!0,get:function(){return u2e.SSELogSubscriptionManager}});he(WN(),oe)});var Cy=require("commander");var kt=pe(require("fs")),eO=pe(require("os")),Pr=pe(require("path")),xd=pe(Pt()),KN=new Set(["runner","builder","admin"]),XN={output:{mode:"stdout",directory:".superglue/output"},preset:"admin"};function Fr(o){let e=Pr.join(process.cwd(),".superglue"),t=eO.homedir();if(!t)return e;let a=Pr.join(t,".superglue");return o===!0?e:o===!1?a:kt.existsSync(Pr.join(e,"config.json"))?e:a}function Fq(o){return Pr.join(Fr(o),"config.json")}function Jb(o){let e=Fq(o);if(!kt.existsSync(e))return{};try{return JSON.parse(kt.readFileSync(e,"utf-8"))}catch{return{}}}function Om(o){let e=Jb(),t=o.apiKey||(0,xd.readProcessEnvironmentValue)("SUPERGLUE_API_KEY")||e.apiKey||"",a=o.endpoint||(0,xd.readProcessEnvironmentValue)("SUPERGLUE_API_ENDPOINT")||e.endpoint||"https://api.superglue.cloud",i=(0,xd.readProcessEnvironmentValue)("SUPERGLUE_WEB_ENDPOINT")||e.webEndpoint||a.replace(/:3002\b/,":3001").replace(/api\.superglue/,"app.superglue"),r=(0,xd.readProcessEnvironmentValue)("SUPERGLUE_CLI_PRESET"),n=r&&KN.has(r)?r:e.preset&&KN.has(e.preset)?e.preset:"admin";return{...XN,...e,apiKey:t,endpoint:a,webEndpoint:i,preset:n,output:{...XN.output,...e.output}}}function Wb(o,e){let t=Fr(e);kt.existsSync(t)||kt.mkdirSync(t,{recursive:!0}),kt.writeFileSync(Pr.join(t,"config.json"),JSON.stringify(o,null,2)+`
1666
- `,{mode:384})}function Zb(o,e){let t=Pr.join(Fr(e),"drafts");if(kt.existsSync(t)||kt.mkdirSync(t,{recursive:!0}),o.output.mode==="stdout+file"){let a=Pr.resolve(o.output.directory);kt.existsSync(a)||kt.mkdirSync(a,{recursive:!0})}}var Wq=pe(Pt());var $q=pe(require("readline"));var aO=require("child_process"),iO=require("util");var oO={name:"@superglue/cli",version:"1.1.103",bin:{sg:"./dist/cli.js"},files:[".claude-plugin/","dist/","skills/","LICENSE"],dependencies:{commander:"15.0.0-0","fast-json-patch":"3.1.1"},devDependencies:{"@superglue/shared":"file:../shared","@types/node":"25.5.0",tsup:"8.5.1",typescript:"5.8.3"},scripts:{build:"tsup && (cp -r skills dist/ 2>/dev/null || true)",dev:"tsup --watch","type-check":"tsc --noEmit",prepublishOnly:"npm run build"},publishConfig:{access:"public"}};var g2e=(0,iO.promisify)(aO.exec),rt=oO.version;function tO(o){let e=o.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:o}}function Xb(o,e){let t=o.split("."),a=e.split("."),i=Math.max(t.length,a.length);for(let r=0;r<i;r++){let n=tO(t[r]||"0"),s=tO(a[r]||"0");if(n.numeric<s.numeric)return-1;if(n.numeric>s.numeric||n.prerelease===null&&s.prerelease!==null)return 1;if(n.prerelease!==null&&s.prerelease===null)return-1;if(n.prerelease!==null&&s.prerelease!==null){if(n.prerelease<s.prerelease)return-1;if(n.prerelease>s.prerelease)return 1}}return 0}async function ey(){try{let o=await fetch("https://registry.npmjs.org/@superglue/cli/latest",{signal:AbortSignal.timeout(5e3)});return o.ok&&(await o.json()).version||null}catch{return null}}var Kb=null;function rO(){me()&&(Kb=ey())}async function nO(){if(!(!me()||!Kb)){try{let o=new Promise(t=>{setTimeout(()=>t(null),2e3).unref()}),e=await Promise.race([Kb,o]);e&&Xb(rt,e)<0&&(console.error(""),console.error(`${b.cyan}${b.bold} Update available: ${rt} \u2192 ${e}${b.reset}`),console.error(`${b.cyan} Run ${b.bold}sg update${b.reset}${b.cyan} to upgrade${b.reset}`),console.error(""))}catch{}Kb=null}}async function sO(){let o=await ey();if(!o)return{success:!1,message:"Could not fetch latest version from npm"};if(Xb(rt,o)>=0)return{success:!0,message:`Already on latest version (${rt})`};try{return await g2e("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${rt} to ${o}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var me=()=>process.argv.includes("--table")&&process.stdout.isTTY,ya=()=>process.argv.includes("--full"),b={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m"};function cO(o,e){let t=e||o;return`\x1B]8;;${o}\x07${b.underline}${b.cyan}${t}${b.reset}\x1B]8;;\x07`}function mO(){if(!me())return;let o=b.reset,e=b.dim,t="\x1B[47;30m",a=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),a.forEach(i=>{let r=i.search(/\S/),n=i.length-[...i].reverse().join("").search(/\S/)-1;if(r===-1)return console.log(" "+i);let s=i.slice(0,r),c=i.slice(r,n+1).split("").map(l=>l===" "?" ":"\u2588").join(""),m=i.slice(n+1);console.log(` ${s}${t}${c}${o}${m}`)}),console.log(` ${e} CLI v${rt}${o}`),console.log("")}function eo(o){if(!me())return{stop:()=>{},update:()=>{},log:()=>{}};let e=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],t=0,a=o,i=()=>process.stdout.write("\r\x1B[2K"),r=()=>{process.stdout.write(`\r ${b.cyan}${e[t++%e.length]}${b.reset} ${a}`)},n=setInterval(r,80);return{update:s=>{a=s},log:s=>{i(),console.log(` ${b.dim}\u2502${b.reset} ${s}`),r()},stop:s=>{clearInterval(n),i(),s&&console.log(` ${s}`)}}}function te(o){me()?oy(o):console.log(JSON.stringify(o,null,2))}function qe(o,e){me()?(console.log(` ${b.green}\u2713${b.reset} ${o}`),e&&oy(e,4)):console.log(JSON.stringify({success:!0,message:o,...e&&typeof e=="object"?e:{data:e}}))}function I(o,e){me()?(console.error(` ${b.red}\u2717${b.reset} ${o}`),e&&oy(e,4)):console.error(JSON.stringify({success:!1,error:o,details:e}))}function lO(o){me()&&console.log(` ${b.yellow}\u26A0${b.reset} ${o}`)}function Yo(o){me()&&console.log(` ${b.dim}${o}${b.reset}`)}function $r(o){me()&&(console.log(`
1666
+ `,{mode:384})}function Zb(o,e){let t=Pr.join(Fr(e),"drafts");if(kt.existsSync(t)||kt.mkdirSync(t,{recursive:!0}),o.output.mode==="stdout+file"){let a=Pr.resolve(o.output.directory);kt.existsSync(a)||kt.mkdirSync(a,{recursive:!0})}}var Wq=pe(Pt());var $q=pe(require("readline"));var aO=require("child_process"),iO=require("util");var oO={name:"@superglue/cli",version:"1.1.104",bin:{sg:"./dist/cli.js"},files:[".claude-plugin/","dist/","skills/","LICENSE"],dependencies:{commander:"15.0.0-0","fast-json-patch":"3.1.1"},devDependencies:{"@superglue/shared":"file:../shared","@types/node":"25.5.0",tsup:"8.5.1",typescript:"5.8.3"},scripts:{build:"tsup && (cp -r skills dist/ 2>/dev/null || true)",dev:"tsup --watch","type-check":"tsc --noEmit",prepublishOnly:"npm run build"},publishConfig:{access:"public"}};var g2e=(0,iO.promisify)(aO.exec),rt=oO.version;function tO(o){let e=o.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:o}}function Xb(o,e){let t=o.split("."),a=e.split("."),i=Math.max(t.length,a.length);for(let r=0;r<i;r++){let n=tO(t[r]||"0"),s=tO(a[r]||"0");if(n.numeric<s.numeric)return-1;if(n.numeric>s.numeric||n.prerelease===null&&s.prerelease!==null)return 1;if(n.prerelease!==null&&s.prerelease===null)return-1;if(n.prerelease!==null&&s.prerelease!==null){if(n.prerelease<s.prerelease)return-1;if(n.prerelease>s.prerelease)return 1}}return 0}async function ey(){try{let o=await fetch("https://registry.npmjs.org/@superglue/cli/latest",{signal:AbortSignal.timeout(5e3)});return o.ok&&(await o.json()).version||null}catch{return null}}var Kb=null;function rO(){me()&&(Kb=ey())}async function nO(){if(!(!me()||!Kb)){try{let o=new Promise(t=>{setTimeout(()=>t(null),2e3).unref()}),e=await Promise.race([Kb,o]);e&&Xb(rt,e)<0&&(console.error(""),console.error(`${b.cyan}${b.bold} Update available: ${rt} \u2192 ${e}${b.reset}`),console.error(`${b.cyan} Run ${b.bold}sg update${b.reset}${b.cyan} to upgrade${b.reset}`),console.error(""))}catch{}Kb=null}}async function sO(){let o=await ey();if(!o)return{success:!1,message:"Could not fetch latest version from npm"};if(Xb(rt,o)>=0)return{success:!0,message:`Already on latest version (${rt})`};try{return await g2e("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${rt} to ${o}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var me=()=>process.argv.includes("--table")&&process.stdout.isTTY,ya=()=>process.argv.includes("--full"),b={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m"};function cO(o,e){let t=e||o;return`\x1B]8;;${o}\x07${b.underline}${b.cyan}${t}${b.reset}\x1B]8;;\x07`}function mO(){if(!me())return;let o=b.reset,e=b.dim,t="\x1B[47;30m",a=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),a.forEach(i=>{let r=i.search(/\S/),n=i.length-[...i].reverse().join("").search(/\S/)-1;if(r===-1)return console.log(" "+i);let s=i.slice(0,r),c=i.slice(r,n+1).split("").map(l=>l===" "?" ":"\u2588").join(""),m=i.slice(n+1);console.log(` ${s}${t}${c}${o}${m}`)}),console.log(` ${e} CLI v${rt}${o}`),console.log("")}function eo(o){if(!me())return{stop:()=>{},update:()=>{},log:()=>{}};let e=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],t=0,a=o,i=()=>process.stdout.write("\r\x1B[2K"),r=()=>{process.stdout.write(`\r ${b.cyan}${e[t++%e.length]}${b.reset} ${a}`)},n=setInterval(r,80);return{update:s=>{a=s},log:s=>{i(),console.log(` ${b.dim}\u2502${b.reset} ${s}`),r()},stop:s=>{clearInterval(n),i(),s&&console.log(` ${s}`)}}}function te(o){me()?oy(o):console.log(JSON.stringify(o,null,2))}function qe(o,e){me()?(console.log(` ${b.green}\u2713${b.reset} ${o}`),e&&oy(e,4)):console.log(JSON.stringify({success:!0,message:o,...e&&typeof e=="object"?e:{data:e}}))}function I(o,e){me()?(console.error(` ${b.red}\u2717${b.reset} ${o}`),e&&oy(e,4)):console.error(JSON.stringify({success:!1,error:o,details:e}))}function lO(o){me()&&console.log(` ${b.yellow}\u26A0${b.reset} ${o}`)}function Yo(o){me()&&console.log(` ${b.dim}${o}${b.reset}`)}function $r(o){me()&&(console.log(`
1667
1667
  ${b.bold}${b.cyan}${o}${b.reset}`),console.log(` ${b.dim}${"\u2500".repeat(o.length)}${b.reset}`))}function ir(o,e,t){if(!me()){console.log(JSON.stringify({success:!0,total:t?.total??o.length,items:o}));return}if(o.length===0){console.log(`
1668
1668
  ${b.dim}0 results${b.reset}
1669
1669
  `);return}let a=e||Object.keys(o[0]),i=ya()?1/0:60,r=a.map(l=>Math.min(i,Math.max(l.length,...o.map(u=>String(u[l]??"").replace(/[\n\r]+/g," ").trim().length))));console.log("");let n=a.map((l,u)=>`${b.bold}${b.cyan}${l.toUpperCase().padEnd(r[u])}${b.reset}`).join(" ");console.log(` ${n}`);let s=r.map(l=>`${b.dim}${"\u2500".repeat(l)}${b.reset}`).join(`${b.dim}\u2500\u2500${b.reset}`);console.log(` ${s}`);for(let l of o){let u=a.map((d,g)=>{let h=String(l[d]??"").replace(/[\n\r]+/g," ").trim();if(h.length>i){let w=`\u2026 (${h.length})`;h=h.slice(0,Math.max(0,i-w.length))+`${b.dim}${w}${b.reset}`}return d==="status"?`${{success:b.green,running:b.yellow,failed:b.red,aborted:b.red,error:b.red,pending:b.dim}[h.toLowerCase()]||""}${h.padEnd(r[g])}${b.reset}`:h.padEnd(r[g])}).join(" ");console.log(` ${u}`)}let c=t?.total??o.length,m=c===o.length?`${o.length} result${o.length===1?"":"s"}`:`${o.length} of ${c} result${c===1?"":"s"}`;console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superglue/cli",
3
- "version": "1.1.103",
3
+ "version": "1.1.104",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },