@superglue/cli 1.1.99 → 1.1.101

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.99",
4
+ "version": "1.1.101",
5
5
  "author": {
6
6
  "name": "superglue",
7
7
  "email": "hello@superglue.cloud"
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ attempted value: ${n}
12
12
  return sourceData;
13
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)}
14
14
  ... [${i} characters omitted] ...
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,logs:[...r.logs||[],...e.toolCall.logs||[]],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,logs:[...r.tool.logs||[],...e.toolCall.logs||[]],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(`
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(`
17
17
  `).filter(n=>n),i=Math.min(...a.map(n=>n.length-n.trimStart().length)),r=a.map(n=>n.slice(i)).map(n=>" ".repeat(this.indent*2)+n);for(let n of r)this.content.push(n)}compile(){let e=Function,t=this?.args,i=[...(this?.content??[""]).map(r=>` ${r}`)];return new e(...t,i.join(`
18
18
  `))}};ep.Doc=GA});var YA=f(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});op.version=void 0;op.version={major:4,minor:4,patch:3}});var ZA=f(v=>{"use strict";var EK=v&&v.__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]})),IK=v&&v.__setModuleDefault||(Object.create?(function(o,e){Object.defineProperty(o,"default",{enumerable:!0,value:e})}):function(o,e){o.default=e}),np=v&&v.__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)&&EK(e,o,t);return IK(e,o),e};Object.defineProperty(v,"__esModule",{value:!0});v.$ZodTuple=v.$ZodIntersection=v.$ZodDiscriminatedUnion=v.$ZodXor=v.$ZodUnion=v.$ZodObjectJIT=v.$ZodObject=v.$ZodArray=v.$ZodDate=v.$ZodVoid=v.$ZodNever=v.$ZodUnknown=v.$ZodAny=v.$ZodNull=v.$ZodUndefined=v.$ZodSymbol=v.$ZodBigIntFormat=v.$ZodBigInt=v.$ZodBoolean=v.$ZodNumberFormat=v.$ZodNumber=v.$ZodCustomStringFormat=v.$ZodJWT=v.$ZodE164=v.$ZodBase64URL=v.$ZodBase64=v.$ZodCIDRv6=v.$ZodCIDRv4=v.$ZodMAC=v.$ZodIPv6=v.$ZodIPv4=v.$ZodISODuration=v.$ZodISOTime=v.$ZodISODate=v.$ZodISODateTime=v.$ZodKSUID=v.$ZodXID=v.$ZodULID=v.$ZodCUID2=v.$ZodCUID=v.$ZodNanoID=v.$ZodEmoji=v.$ZodURL=v.$ZodEmail=v.$ZodUUID=v.$ZodGUID=v.$ZodStringFormat=v.$ZodString=v.clone=v.$ZodType=void 0;v.$ZodCustom=v.$ZodLazy=v.$ZodPromise=v.$ZodFunction=v.$ZodTemplateLiteral=v.$ZodReadonly=v.$ZodPreprocess=v.$ZodCodec=v.$ZodPipe=v.$ZodNaN=v.$ZodCatch=v.$ZodSuccess=v.$ZodNonOptional=v.$ZodPrefault=v.$ZodDefault=v.$ZodNullable=v.$ZodExactOptional=v.$ZodOptional=v.$ZodTransform=v.$ZodFile=v.$ZodLiteral=v.$ZodEnum=v.$ZodSet=v.$ZodMap=v.$ZodRecord=void 0;v.isValidBase64=WA;v.isValidBase64URL=v4;v.isValidJWT=w4;var sp=np(Xg()),R=np(ls()),jK=VA(),Bc=FA(),Ce=np(Kg()),O=np(W()),CK=YA();v.$ZodType=R.$constructor("$ZodType",(o,e)=>{var t;o??(o={}),o._zod.def=e,o._zod.bag=o._zod.bag||{},o._zod.version=CK.version;let a=[...o._zod.def.checks??[]];o._zod.traits.has("$ZodCheck")&&a.unshift(o);for(let i of a)for(let r of i._zod.onattach)r(o);if(a.length===0)(t=o._zod).deferred??(t.deferred=[]),o._zod.deferred?.push(()=>{o._zod.run=o._zod.parse});else{let i=(n,s,c)=>{let m=O.aborted(n),l;for(let u of s){if(u._zod.def.when){if(O.explicitlyAborted(n)||!u._zod.def.when(n))continue}else if(m)continue;let d=n.issues.length,g=u._zod.check(n);if(g instanceof Promise&&c?.async===!1)throw new R.$ZodAsyncError;if(l||g instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await g,n.issues.length!==d&&(m||(m=O.aborted(n,d)))});else{if(n.issues.length===d)continue;m||(m=O.aborted(n,d))}}return l?l.then(()=>n):n},r=(n,s,c)=>{if(O.aborted(n))return n.aborted=!0,n;let m=i(s,a,c);if(m instanceof Promise){if(c.async===!1)throw new R.$ZodAsyncError;return m.then(l=>o._zod.parse(l,c))}return o._zod.parse(m,c)};o._zod.run=(n,s)=>{if(s.skipChecks)return o._zod.parse(n,s);if(s.direction==="backward"){let m=o._zod.parse({value:n.value,issues:[]},{...s,skipChecks:!0});return m instanceof Promise?m.then(l=>r(l,n,s)):r(m,n,s)}let c=o._zod.parse(n,s);if(c instanceof Promise){if(s.async===!1)throw new R.$ZodAsyncError;return c.then(m=>i(m,a,s))}return i(c,a,s)}}O.defineLazy(o,"~standard",()=>({validate:i=>{try{let r=(0,Bc.safeParse)(o,i);return r.success?{value:r.data}:{issues:r.error?.issues}}catch{return(0,Bc.safeParseAsync)(o,i).then(n=>n.success?{value:n.data}:{issues:n.error?.issues})}},vendor:"zod",version:1}))});var SK=W();Object.defineProperty(v,"clone",{enumerable:!0,get:function(){return SK.clone}});v.$ZodString=R.$constructor("$ZodString",(o,e)=>{v.$ZodType.init(o,e),o._zod.pattern=[...o?._zod.bag?.patterns??[]].pop()??Ce.string(o._zod.bag),o._zod.parse=(t,a)=>{if(e.coerce)try{t.value=String(t.value)}catch{}return typeof t.value=="string"||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:o}),t}});v.$ZodStringFormat=R.$constructor("$ZodStringFormat",(o,e)=>{sp.$ZodCheckStringFormat.init(o,e),v.$ZodString.init(o,e)});v.$ZodGUID=R.$constructor("$ZodGUID",(o,e)=>{e.pattern??(e.pattern=Ce.guid),v.$ZodStringFormat.init(o,e)});v.$ZodUUID=R.$constructor("$ZodUUID",(o,e)=>{if(e.version){let a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(a===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Ce.uuid(a))}else e.pattern??(e.pattern=Ce.uuid());v.$ZodStringFormat.init(o,e)});v.$ZodEmail=R.$constructor("$ZodEmail",(o,e)=>{e.pattern??(e.pattern=Ce.email),v.$ZodStringFormat.init(o,e)});v.$ZodURL=R.$constructor("$ZodURL",(o,e)=>{v.$ZodStringFormat.init(o,e),o._zod.check=t=>{try{let a=t.value.trim();if(!e.normalize&&e.protocol?.source===Ce.httpProtocol.source&&!/^https?:\/\//i.test(a)){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:o,continue:!e.abort});return}let i=new URL(a);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:o,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:o,continue:!e.abort})),e.normalize?t.value=i.href:t.value=a;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:o,continue:!e.abort})}}});v.$ZodEmoji=R.$constructor("$ZodEmoji",(o,e)=>{e.pattern??(e.pattern=Ce.emoji()),v.$ZodStringFormat.init(o,e)});v.$ZodNanoID=R.$constructor("$ZodNanoID",(o,e)=>{e.pattern??(e.pattern=Ce.nanoid),v.$ZodStringFormat.init(o,e)});v.$ZodCUID=R.$constructor("$ZodCUID",(o,e)=>{e.pattern??(e.pattern=Ce.cuid),v.$ZodStringFormat.init(o,e)});v.$ZodCUID2=R.$constructor("$ZodCUID2",(o,e)=>{e.pattern??(e.pattern=Ce.cuid2),v.$ZodStringFormat.init(o,e)});v.$ZodULID=R.$constructor("$ZodULID",(o,e)=>{e.pattern??(e.pattern=Ce.ulid),v.$ZodStringFormat.init(o,e)});v.$ZodXID=R.$constructor("$ZodXID",(o,e)=>{e.pattern??(e.pattern=Ce.xid),v.$ZodStringFormat.init(o,e)});v.$ZodKSUID=R.$constructor("$ZodKSUID",(o,e)=>{e.pattern??(e.pattern=Ce.ksuid),v.$ZodStringFormat.init(o,e)});v.$ZodISODateTime=R.$constructor("$ZodISODateTime",(o,e)=>{e.pattern??(e.pattern=Ce.datetime(e)),v.$ZodStringFormat.init(o,e)});v.$ZodISODate=R.$constructor("$ZodISODate",(o,e)=>{e.pattern??(e.pattern=Ce.date),v.$ZodStringFormat.init(o,e)});v.$ZodISOTime=R.$constructor("$ZodISOTime",(o,e)=>{e.pattern??(e.pattern=Ce.time(e)),v.$ZodStringFormat.init(o,e)});v.$ZodISODuration=R.$constructor("$ZodISODuration",(o,e)=>{e.pattern??(e.pattern=Ce.duration),v.$ZodStringFormat.init(o,e)});v.$ZodIPv4=R.$constructor("$ZodIPv4",(o,e)=>{e.pattern??(e.pattern=Ce.ipv4),v.$ZodStringFormat.init(o,e),o._zod.bag.format="ipv4"});v.$ZodIPv6=R.$constructor("$ZodIPv6",(o,e)=>{e.pattern??(e.pattern=Ce.ipv6),v.$ZodStringFormat.init(o,e),o._zod.bag.format="ipv6",o._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:o,continue:!e.abort})}}});v.$ZodMAC=R.$constructor("$ZodMAC",(o,e)=>{e.pattern??(e.pattern=Ce.mac(e.delimiter)),v.$ZodStringFormat.init(o,e),o._zod.bag.format="mac"});v.$ZodCIDRv4=R.$constructor("$ZodCIDRv4",(o,e)=>{e.pattern??(e.pattern=Ce.cidrv4),v.$ZodStringFormat.init(o,e)});v.$ZodCIDRv6=R.$constructor("$ZodCIDRv6",(o,e)=>{e.pattern??(e.pattern=Ce.cidrv6),v.$ZodStringFormat.init(o,e),o._zod.check=t=>{let a=t.value.split("/");try{if(a.length!==2)throw new Error;let[i,r]=a;if(!r)throw new Error;let n=Number(r);if(`${n}`!==r)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${i}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:o,continue:!e.abort})}}});function WA(o){if(o==="")return!0;if(/\s/.test(o)||o.length%4!==0)return!1;try{return atob(o),!0}catch{return!1}}v.$ZodBase64=R.$constructor("$ZodBase64",(o,e)=>{e.pattern??(e.pattern=Ce.base64),v.$ZodStringFormat.init(o,e),o._zod.bag.contentEncoding="base64",o._zod.check=t=>{WA(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:o,continue:!e.abort})}});function v4(o){if(!Ce.base64url.test(o))return!1;let e=o.replace(/[-_]/g,a=>a==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return WA(t)}v.$ZodBase64URL=R.$constructor("$ZodBase64URL",(o,e)=>{e.pattern??(e.pattern=Ce.base64url),v.$ZodStringFormat.init(o,e),o._zod.bag.contentEncoding="base64url",o._zod.check=t=>{v4(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:o,continue:!e.abort})}});v.$ZodE164=R.$constructor("$ZodE164",(o,e)=>{e.pattern??(e.pattern=Ce.e164),v.$ZodStringFormat.init(o,e)});function w4(o,e=null){try{let t=o.split(".");if(t.length!==3)return!1;let[a]=t;if(!a)return!1;let i=JSON.parse(atob(a));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}v.$ZodJWT=R.$constructor("$ZodJWT",(o,e)=>{v.$ZodStringFormat.init(o,e),o._zod.check=t=>{w4(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:o,continue:!e.abort})}});v.$ZodCustomStringFormat=R.$constructor("$ZodCustomStringFormat",(o,e)=>{v.$ZodStringFormat.init(o,e),o._zod.check=t=>{e.fn(t.value)||t.issues.push({code:"invalid_format",format:e.format,input:t.value,inst:o,continue:!e.abort})}});v.$ZodNumber=R.$constructor("$ZodNumber",(o,e)=>{v.$ZodType.init(o,e),o._zod.pattern=o._zod.bag.pattern??Ce.number,o._zod.parse=(t,a)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}let i=t.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return t;let r=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:i,inst:o,...r?{received:r}:{}}),t}});v.$ZodNumberFormat=R.$constructor("$ZodNumberFormat",(o,e)=>{sp.$ZodCheckNumberFormat.init(o,e),v.$ZodNumber.init(o,e)});v.$ZodBoolean=R.$constructor("$ZodBoolean",(o,e)=>{v.$ZodType.init(o,e),o._zod.pattern=Ce.boolean,o._zod.parse=(t,a)=>{if(e.coerce)try{t.value=!!t.value}catch{}let i=t.value;return typeof i=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:o}),t}});v.$ZodBigInt=R.$constructor("$ZodBigInt",(o,e)=>{v.$ZodType.init(o,e),o._zod.pattern=Ce.bigint,o._zod.parse=(t,a)=>{if(e.coerce)try{t.value=BigInt(t.value)}catch{}return typeof t.value=="bigint"||t.issues.push({expected:"bigint",code:"invalid_type",input:t.value,inst:o}),t}});v.$ZodBigIntFormat=R.$constructor("$ZodBigIntFormat",(o,e)=>{sp.$ZodCheckBigIntFormat.init(o,e),v.$ZodBigInt.init(o,e)});v.$ZodSymbol=R.$constructor("$ZodSymbol",(o,e)=>{v.$ZodType.init(o,e),o._zod.parse=(t,a)=>{let i=t.value;return typeof i=="symbol"||t.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:o}),t}});v.$ZodUndefined=R.$constructor("$ZodUndefined",(o,e)=>{v.$ZodType.init(o,e),o._zod.pattern=Ce.undefined,o._zod.values=new Set([void 0]),o._zod.parse=(t,a)=>{let i=t.value;return typeof i>"u"||t.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:o}),t}});v.$ZodNull=R.$constructor("$ZodNull",(o,e)=>{v.$ZodType.init(o,e),o._zod.pattern=Ce.null,o._zod.values=new Set([null]),o._zod.parse=(t,a)=>{let i=t.value;return i===null||t.issues.push({expected:"null",code:"invalid_type",input:i,inst:o}),t}});v.$ZodAny=R.$constructor("$ZodAny",(o,e)=>{v.$ZodType.init(o,e),o._zod.parse=t=>t});v.$ZodUnknown=R.$constructor("$ZodUnknown",(o,e)=>{v.$ZodType.init(o,e),o._zod.parse=t=>t});v.$ZodNever=R.$constructor("$ZodNever",(o,e)=>{v.$ZodType.init(o,e),o._zod.parse=(t,a)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:o}),t)});v.$ZodVoid=R.$constructor("$ZodVoid",(o,e)=>{v.$ZodType.init(o,e),o._zod.parse=(t,a)=>{let i=t.value;return typeof i>"u"||t.issues.push({expected:"void",code:"invalid_type",input:i,inst:o}),t}});v.$ZodDate=R.$constructor("$ZodDate",(o,e)=>{v.$ZodType.init(o,e),o._zod.parse=(t,a)=>{if(e.coerce)try{t.value=new Date(t.value)}catch{}let i=t.value,r=i instanceof Date;return r&&!Number.isNaN(i.getTime())||t.issues.push({expected:"date",code:"invalid_type",input:i,...r?{received:"Invalid Date"}:{},inst:o}),t}});function s4(o,e,t){o.issues.length&&e.issues.push(...O.prefixIssues(t,o.issues)),e.value[t]=o.value}v.$ZodArray=R.$constructor("$ZodArray",(o,e)=>{v.$ZodType.init(o,e),o._zod.parse=(t,a)=>{let i=t.value;if(!Array.isArray(i))return t.issues.push({expected:"array",code:"invalid_type",input:i,inst:o}),t;t.value=Array(i.length);let r=[];for(let n=0;n<i.length;n++){let s=i[n],c=e.element._zod.run({value:s,issues:[]},a);c instanceof Promise?r.push(c.then(m=>s4(m,t,n))):s4(c,t,n)}return r.length?Promise.all(r).then(()=>t):t}});function rp(o,e,t,a,i,r){let n=t in a;if(o.issues.length){if(i&&r&&!n)return;e.issues.push(...O.prefixIssues(t,o.issues))}if(!n&&!i){o.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}o.value===void 0?n&&(e.value[t]=void 0):e.value[t]=o.value}function x4(o){let e=Object.keys(o.shape);for(let a of e)if(!o.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);let t=O.optionalKeys(o.shape);return{...o,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function z4(o,e,t,a,i,r){let n=[],s=i.keySet,c=i.catchall._zod,m=c.def.type,l=c.optin==="optional",u=c.optout==="optional";for(let d in e){if(d==="__proto__"||s.has(d))continue;if(m==="never"){n.push(d);continue}let g=c.run({value:e[d],issues:[]},a);g instanceof Promise?o.push(g.then(h=>rp(h,t,d,e,l,u))):rp(g,t,d,e,l,u)}return n.length&&t.issues.push({code:"unrecognized_keys",keys:n,input:e,inst:r}),o.length?Promise.all(o).then(()=>t):t}v.$ZodObject=R.$constructor("$ZodObject",(o,e)=>{if(v.$ZodType.init(o,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let s=e.shape;Object.defineProperty(e,"shape",{get:()=>{let c={...s};return Object.defineProperty(e,"shape",{value:c}),c}})}let a=O.cached(()=>x4(e));O.defineLazy(o._zod,"propValues",()=>{let s=e.shape,c={};for(let m in s){let l=s[m]._zod;if(l.values){c[m]??(c[m]=new Set);for(let u of l.values)c[m].add(u)}}return c});let i=O.isObject,r=e.catchall,n;o._zod.parse=(s,c)=>{n??(n=a.value);let m=s.value;if(!i(m))return s.issues.push({expected:"object",code:"invalid_type",input:m,inst:o}),s;s.value={};let l=[],u=n.shape;for(let d of n.keys){let g=u[d],h=g._zod.optin==="optional",k=g._zod.optout==="optional",w=g._zod.run({value:m[d],issues:[]},c);w instanceof Promise?l.push(w.then(x=>rp(x,s,d,m,h,k))):rp(w,s,d,m,h,k)}return r?z4(l,m,s,c,a.value,o):l.length?Promise.all(l).then(()=>s):s}});v.$ZodObjectJIT=R.$constructor("$ZodObjectJIT",(o,e)=>{v.$ZodObject.init(o,e);let t=o._zod.parse,a=O.cached(()=>x4(e)),i=d=>{let g=new jK.Doc(["shape","payload","ctx"]),h=a.value,k=q=>{let _=O.esc(q);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`};g.write("const input = payload.value;");let w=Object.create(null),x=0;for(let q of h.keys)w[q]=`key_${x++}`;g.write("const newResult = {};");for(let q of h.keys){let _=w[q],D=O.esc(q),H=d[q],J=H?._zod?.optin==="optional",X=H?._zod?.optout==="optional";g.write(`const ${_} = ${k(q)};`),J&&X?g.write(`
@@ -601,7 +601,7 @@ ${e.map(t=>`- ${t.path}: ${t.message}`).join(`
601
601
  `).map(a=>`${e}${a}`)].join(`
602
602
  `)}function dn(o,e){return o.includes(`
603
603
  `)?mde(o,e):JSON.stringify(o)}function lde(o){let e=["---"];if(e.push(`name: ${dn(o.id," ")}`),e.push(`title: ${dn(o.name," ")}`),e.push(`when_to_run: ${dn(o.whenToRun," ")}`),o.systemRefs.length>0){e.push("systems:");for(let a of o.systemRefs)e.push(` - id: ${dn(a.id," ")}`)}if(o.toolRefs.length>0){e.push("tools:");for(let a of o.toolRefs)e.push(` - id: ${dn(a.id," ")}`)}if(o.credentialRefs.length>0){e.push("credentials:");for(let a of o.credentialRefs)e.push(` - id: ${dn(a.id," ")}`)}if(o.fileRefs.length>0){e.push("files:");for(let a of o.fileRefs)e.push(` - ${dn(a.name," ")}`);e.push(`# read attachments at /org/playbooks/${o.id}/files/<name>.json (.raw for original bytes)`)}e.push(`completion_criteria: ${dn(o.completionCriteria," ")}`),e.push("---"),e.push(""),o.inputs.trim()&&(e.push("## Required inputs"),e.push(""),e.push(o.inputs.trim()),e.push("")),e.push("## Instructions"),e.push(""),e.push(o.instructions.trim()),e.push("");let t=e.join(`
604
- `);if(t.length>y3.PLAYBOOK_LIMITS.compiledRender)throw new Error(`Compiled playbook render for '${o.id}' exceeds ${y3.PLAYBOOK_LIMITS.compiledRender} chars (${t.length})`);return t}});var A3=f(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.PROJECT_LIMITS=xr.PROJECT_TASK_STATUSES=xr.PROJECT_RESOURCE_TYPES=void 0;xr.projectResourceKey=ude;xr.PROJECT_RESOURCE_TYPES=["system","playbook","artifact","file","tool"];xr.PROJECT_TASK_STATUSES=["not_started","in_progress","waiting","done"];xr.PROJECT_LIMITS={name:80,description:500,taskName:120,taskDescription:5e3,taskResources:100};function ude(o){return`${o.type}:${o.id}`}});var Fv=f(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.RESOURCE_KINDS=ja.RESOURCE_DEFINITIONS=void 0;ja.isResourceKind=dde;ja.getResourceDefinition=gde;ja.RESOURCE_DEFINITIONS={tool:{label:"Tool",pluralLabel:"Tools",collectionKey:"tools",memberDefaultPermission:"editor",pickerDefaultPermission:"editor"},system:{label:"System",pluralLabel:"Systems",collectionKey:"systems",memberDefaultPermission:"editor",pickerDefaultPermission:"editor"},credential:{label:"Credential",pluralLabel:"Credentials",collectionKey:"credentials",pickerDefaultPermission:"viewer"},playbook:{label:"Playbook",pluralLabel:"Playbooks",collectionKey:"playbooks",pickerDefaultPermission:"editor"},artifact:{label:"Artifact",pluralLabel:"Artifacts",collectionKey:"artifacts",pickerDefaultPermission:"editor"},file:{label:"File",pluralLabel:"Files",collectionKey:"files",pickerDefaultPermission:"viewer"},project:{label:"Project",pluralLabel:"Projects",collectionKey:"projects",pickerDefaultPermission:"viewer"}};ja.RESOURCE_KINDS=Object.keys(ja.RESOURCE_DEFINITIONS);function dde(o){return typeof o=="string"&&Object.prototype.hasOwnProperty.call(ja.RESOURCE_DEFINITIONS,o)}function gde(o){return ja.RESOURCE_DEFINITIONS[o]}});var B3=f(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.RESERVED_ROLE_NAMES=ae.RESERVED_ROLE_IDS=ae.PREDEFINED_ROLE_IDS=void 0;ae.toResourceRef=su;ae.toWildcardResourceRef=cu;ae.getDefaultMemberResourceGrants=pde;ae.parseResourceRef=Qh;ae.getWildcardResourceRef=v3;ae.normalizeResourcePermissions=gn;ae.permissionSatisfies=_h;ae.highestResourcePermission=Dh;ae.grantHasPermission=Gv;ae.grantMatchesResource=Pc;ae.getEffectiveResourcePermissions=Vv;ae.hasResourcePermission=hde;ae.getRoleResourceGrants=Th;ae.getAllowedResourceIds=w3;ae.getAllowedResourceIdsForRoles=Rh;ae.getEffectiveResourcePermissionsForRoles=Fc;ae.getAllowedToolIds=x3;ae.getAllowedSystemIds=z3;ae.pickLongestHeldResource=bde;ae.getAllowedCredentialsIds=yde;ae.getEffectiveCredentialsPermissions=kde;ae.getEffectiveToolPermissions=Ade;ae.getEffectiveSystemPermissions=vde;ae.checkResourcePermission=Nh;ae.isToolAllowed=wde;ae.isSystemVisible=xde;ae.isPlaybookVisible=zde;ae.hasAllSystems=qde;ae.hasAllTools=Ede;ae.getResourceGrantSources=q3;ae.getSharePermissionForResource=E3;ae.getAccessRulePermissionForResource=I3;ae.hasAdminBaseRole=Yv;ae.resolveResourceAccessForRoles=Ide;ae.normalizeResourceGrantInput=j3;ae.normalizeRoleResourceGrantInput=jde;ae.isPredefinedRole=Cde;ae.isReservedRoleId=Sde;ae.isReservedRoleName=Bde;ae.hasRole=Qde;ae.getRoleIds=_de;ae.getBaseRole=C3;ae.getBaseRoleId=Dde;ae.getPersonalRole=S3;ae.getPersonalRoleId=Tde;var Sh=Fv(),Bh="*";function su(o,e){if(!e||e===Bh)throw new Error("Resource id is required");return`${o}:${encodeURIComponent(e)}`}function cu(o){return`${o}:${Bh}`}function pde(){return Sh.RESOURCE_KINDS.flatMap(o=>{let e=(0,Sh.getResourceDefinition)(o).memberDefaultPermission;return e?[{resourceRef:cu(o),permissions:[e]}]:[]})}function Qh(o){let e=o.indexOf(":");if(e<=0)return null;let t=o.slice(0,e);if(!(0,Sh.isResourceKind)(t))return null;let a=o.slice(e+1);if(!a)return null;if(a===Bh)return{kind:t,id:Bh,isWildcard:!0};try{return{kind:t,id:decodeURIComponent(a),isWildcard:!1}}catch{return null}}function v3(o){let e=Qh(o);return e?cu(e.kind):null}function gn(o){let e=new Set;for(let t of o||[])(t==="viewer"||t==="editor")&&e.add(t);return e.has("editor")&&e.add("viewer"),Array.from(e)}function _h(o,e){return o===e||o==="editor"&&e==="viewer"}function Dh(o){let e=gn(o);if(e.includes("editor"))return"editor";if(e.includes("viewer"))return"viewer"}function Gv(o,e){return o.revokedAt?!1:gn(o.permissions).some(t=>_h(t,e))}function Pc(o,e){return o.revokedAt?!1:o.resourceRef===e||o.resourceRef===v3(e)}function Vv(o,e){let t=new Set;for(let a of o)if(Pc(a,e))for(let i of gn(a.permissions))t.add(i);return Array.from(t)}function hde(o,e,t){return Vv(o,e).some(a=>_h(a,t))}function Th(o){return o.flatMap(e=>e.isBaseRole&&e.id==="admin"?[]:e.resourceGrants||[])}function w3(o,e,t){let a=cu(e),i=new Set;for(let r of o){if(!Gv(r,t))continue;if(r.resourceRef===a)return;let n=Qh(r.resourceRef);n?.kind===e&&!n.isWildcard&&i.add(n.id)}return Array.from(i)}function Rh(o,e,t){if(!Yv(o))return w3(Th(o),e,t)}function Fc(o,e,t){return Yv(o)?["editor","viewer"]:Vv(Th(o),su(e,t))}function fde(o){return(0,Sh.getResourceDefinition)(o).label}function x3(o,e="viewer"){return Rh(o,"tool",e)}function z3(o,e="viewer"){return Rh(o,"system",e)}var Hv=Number.MAX_SAFE_INTEGER;function $v(o){if(!o)return Hv;let e=new Date(o).getTime();return Number.isNaN(e)?Hv:e}function bde(o,e,t){if(o.length<=1)return o[0];let a=i=>{let r=su(t,i.id),n=Hv;for(let s of e)Pc(s,r)&&(n=Math.min(n,$v(s.createdAt)));return n};return[...o].sort((i,r)=>{let n=a(i)-a(r);return n!==0?n:$v(i.createdAt)-$v(r.createdAt)})[0]}function yde(o,e="viewer"){return Rh(o,"credential",e)}function kde(o,e){return Fc(o,"credential",e)}function Ade(o,e){return Fc(o,"tool",e)}function vde(o,e){return Fc(o,"system",e)}function Nh(o,e,t,a){return Fc(o,e,t).some(r=>_h(r,a))?{allowed:!0}:{allowed:!1,error:`${fde(e)} '${t}' requires a '${a}' grant`}}function wde(o,e,t="viewer"){return Nh(o,"tool",e,t)}function xde(o,e,t="viewer"){return Nh(o,"system",e,t)}function zde(o,e,t="viewer"){return Nh(o,"playbook",e,t)}function qde(o,e="viewer"){return z3(o,e)===void 0}function Ede(o,e="viewer"){return x3(o,e)===void 0}function q3(o,e,t="viewer"){let a=new Set;for(let i of o)Pc(i,e)&&Gv(i,t)&&a.add(i.source);return Array.from(a)}function E3(o,e){let t=o.filter(a=>a.source==="share"&&Pc(a,e)).flatMap(a=>gn(a.permissions));return Dh(t)}function I3(o,e){let t=o.filter(a=>a.source==="access_rule"&&Pc(a,e)).flatMap(a=>gn(a.permissions));return Dh(t)}function Yv(o){return o.some(e=>e.isBaseRole&&e.id==="admin")}function Ide({roles:o,resource:e,userId:t}){let a=su(e.kind,e.id),i=Th(o),r=new Set(Fc(o,e.kind,e.id)),n=new Set(q3(i,a));e.ownerUserId&&e.ownerUserId===t&&(r.add("editor"),r.add("viewer"),n.add("ownership"));let s=gn(Array.from(r));return{permissions:s,sources:Array.from(n),sharePermission:E3(i,a),accessRulePermission:I3(i,a),maxPermission:Dh(s)}}function j3(o){let e=Qh(o.resourceRef);if(!e)throw new Error(`Invalid resource ref '${o.resourceRef}'`);return{...o,resourceRef:e.isWildcard?cu(e.kind):su(e.kind,e.id),permissions:gn(o.permissions||["viewer"]),source:o.source||"access_rule"}}function jde(o){let e=j3({resourceRef:o.resourceRef,permissions:o.permissions,source:"access_rule"});return{resourceRef:e.resourceRef,permissions:e.permissions,source:"access_rule"}}ae.PREDEFINED_ROLE_IDS=["admin","member"];ae.RESERVED_ROLE_IDS=["admin","member","__admin__"];ae.RESERVED_ROLE_NAMES=["member","admin"];function Cde(o){return ae.PREDEFINED_ROLE_IDS.includes(o)}function Sde(o){return ae.RESERVED_ROLE_IDS.includes(o)}function Bde(o){return ae.RESERVED_ROLE_NAMES.includes(o.toLowerCase().trim())}function Qde(o,e){return o.some(t=>t.id===e)}function _de(o){return o.map(e=>e.id)}function C3(o){let e=o.filter(t=>t.isBaseRole);return e.length===1?e[0]:null}function Dde(o){let e=C3(o);return e?e.id:null}function S3(o){return o.find(e=>e.isPersonalRole)||null}function Tde(o){let e=S3(o);return e?e.id:null}});var _3=f(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.NOTIFICATION_EXCLUDED_REQUEST_SOURCES=St.CLIENT_REQUEST_SOURCES=St.REQUEST_SOURCES=void 0;St.isRequestSource=Q3;St.isClientRequestSource=Ode;St.parseRequestSource=Ude;var et=Ht();St.REQUEST_SOURCES=[et.RequestSource.API,et.RequestSource.FRONTEND,et.RequestSource.AGENT,et.RequestSource.SCHEDULER,et.RequestSource.MCP,et.RequestSource.TOOL_CHAIN,et.RequestSource.WEBHOOK,et.RequestSource.CLI];St.CLIENT_REQUEST_SOURCES=[et.RequestSource.FRONTEND,et.RequestSource.AGENT,et.RequestSource.MCP,et.RequestSource.CLI];St.NOTIFICATION_EXCLUDED_REQUEST_SOURCES=[et.RequestSource.FRONTEND,et.RequestSource.AGENT,et.RequestSource.MCP];var Rde=new Set(St.REQUEST_SOURCES),Nde=new Set(St.CLIENT_REQUEST_SOURCES);function Q3(o){return Rde.has(o)}function Ode(o){return Nde.has(o)}function Ude(o){let e=o.toLowerCase();return Q3(e)?e:void 0}});var D3=f(Oh=>{"use strict";Object.defineProperty(Oh,"__esModule",{value:!0});Oh.contextSourceTemplates=void 0;var Mde={slack:{category:"workspace",systemId:"slack",onboardingOrder:7,onboardingDescription:"Connect joined public channels so superglue can use relevant workspace context."},gmail:{category:"email",systemId:"gmail",onboardingOrder:9,onboardingDescription:"Let superglue access your gmail inbox. superglue will never send emails on your behalf."},fathomMcp:{category:"meetings",systemId:"fathomMcp",onboardingOrder:4,onboardingDescription:"Let superglue use meeting notes and transcripts. superglue will never join or record meetings."},granolaMcp:{category:"meetings",systemId:"granolaMcp",onboardingOrder:2,onboardingDescription:"Let superglue use notes and transcripts. superglue will never join or record meetings."},googleDrive:{category:"workspace",systemId:"google-drive",onboardingOrder:9,onboardingDescription:"Connect accessible Drive files for relevant workspace context."},box:{category:"workspace",systemId:"box",onboardingOrder:11,onboardingDescription:"Connect accessible Box files for relevant workspace context."},notion:{category:"workspace",systemId:"notion",onboardingOrder:8,onboardingDescription:"Connect selected Notion pages for relevant workspace context."},sharepoint:{category:"workspace",systemId:"sharepoint",onboardingOrder:10,onboardingDescription:"Connect accessible SharePoint sites and files for workspace context."},microsoftTeams:{category:"workspace",systemId:"microsoft-teams",onboardingOrder:6,onboardingDescription:"Connect Microsoft Teams channels and meetings for workspace context."},outlookMail:{category:"email",systemId:"outlook-mail",onboardingOrder:8,onboardingDescription:"Let superglue access your outlook inbox. superglue will never send emails on your behalf."},circleback:{category:"meetings",systemId:"circleback",onboardingOrder:1,onboardingDescription:"Let superglue use notes and transcripts. superglue will never join or record meetings.",endpointAliases:["https://app.circleback.ai/api/mcp"]},fireflies:{category:"meetings",systemId:"fireflies",onboardingOrder:3,onboardingDescription:"Let superglue use transcripts and summaries. superglue will never join or record meetings."},fellowMcp:{category:"meetings",systemId:"fellow",onboardingOrder:5,onboardingDescription:"Let superglue use meeting notes and transcripts. superglue will never join or record meetings."}};Oh.contextSourceTemplates=Mde});var Zv=f(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.systemOptions=Oe.systems=void 0;Oe.getSystemTemplateOAuthClientMode=Pde;Oe.getSystemTemplateAuthentication=O3;Oe.mergeSystemTemplateAuthentication=U3;Oe.resolveSystemAuthentication=Wv;Oe.getContextSourceTemplates=M3;Oe.resolveContextSourceSetup=Yde;Oe.findTemplateForSystem=Mh;Oe.uniqueKeywords=Jde;Oe.getOAuthConfig=Wde;Oe.getOAuthTokenExchangeConfig=Zde;Oe.getOAuthTokenUrl=Kde;var Jv=iu(),Lde=D3(),Uh=jh();function Pde(o){let e=o?.oauth;if(e)return e.registrationUrl?"dynamic":e.client_id?"managed":"custom"}function Fde(o){let e=o?.split(/[,\s]+/).filter(Boolean);return e?.length?e:void 0}function O3(o){if(!o?.preferredAuthType)return;if(o.preferredAuthType!=="oauth2")return{type:o.preferredAuthType};let e=o.oauth;if(!e)return{type:"oauth2"};let t={};e.tokenAuthMethod&&(t.tokenAuthMethod=e.tokenAuthMethod),e.tokenContentType&&(t.tokenContentType=e.tokenContentType),e.extraHeaders&&(t.extraHeaders=e.extraHeaders),e.extraBodyParams&&(t.extraBodyParams=e.extraBodyParams),e.usePKCE!==void 0&&(t.usePKCE=e.usePKCE),e.resource&&(t.resource=e.resource);let a=Fde(e.scopes);return{type:"oauth2",...e.registrationUrl?{oauthClientMode:"dynamic"}:{},...e.authUrl?{authUrl:e.authUrl}:{},...e.tokenUrl?{tokenUrl:e.tokenUrl}:{},...e.client_id?{clientId:e.client_id}:{},...e.grant_type?{grantType:e.grant_type}:{},...a?{scopes:a}:{},...Object.keys(t).length?{config:t}:{}}}function $de(o){return!o.config||Object.keys(o.config).length===0}function T3(o,e){let t={...o||{},...e||{}};return Object.keys(t).length>0?t:void 0}function R3(o,e){if(e)return{...o,config:e};let{config:t,...a}=o;return a}function U3({authentication:o,template:e}){let t=O3(e),a=(0,Jv.normalizeSystemAuthentication)(o);if(!a)return t;if(!t)return a;if(a.type==="none"&&$de(a))return t;if(a.type!==t.type)return a;if(a.type==="oauth2"&&t.type==="oauth2"){let i={...t};a.oauthClientMode==="custom"&&(delete i.clientId,delete i.clientSecret);let r={...i,...a};return(0,Jv.resolveOAuthClientMode)({authentication:a,templateClientId:t.clientId,templateRegistrationUrl:e.oauth?.registrationUrl})==="managed"&&t.clientId&&(r.clientId=t.clientId),R3(r,T3(t.config,a.config))}return R3({...t,...a},T3(t.config,a.config))}function Wv(o){let e=(0,Jv.normalizeSystemAuthentication)(o.authentication)||{type:"none"};return U3({authentication:e,template:Mh(o)?.template})||e}var Hde={postgres:{name:"postgres",apiUrl:"postgres://<<username>>:<<password>>@<<host>>:<<port>>/<<database>>",regex:"^.*(postgres|postgresql).*$",icon:"postgresql",docsUrl:"",preferredAuthType:"connection_string",connectionFields:[{key:"host",label:"Host",placeholder:"db.example.com",required:!0},{key:"port",label:"Port",type:"number",defaultValue:"5432",placeholder:"5432"},{key:"database",label:"Database",placeholder:"mydb",required:!0},{key:"username",label:"Username",placeholder:"postgres",required:!0},{key:"password",label:"Password",type:"password",required:!0}],keywords:["database","sql","postgres","postgresql","api key","tables"]},mssql:{name:"mssql",apiUrl:"mssql://<<username>>:<<password>>@<<host>>:<<port>>/<<database>>",regex:"^.*\\b(mssql|sql[\\s._-]?server).*$",icon:"lucide:database",docsUrl:"https://learn.microsoft.com/en-us/sql/sql-server/connect-to-database-engine",preferredAuthType:"connection_string",connectionFields:[{key:"host",label:"Host",placeholder:"sql.example.com",required:!0},{key:"port",label:"Port",type:"number",defaultValue:"1433",placeholder:"1433"},{key:"database",label:"Database",placeholder:"mydb",required:!0},{key:"username",label:"Username",required:!0},{key:"password",label:"Password",type:"password",required:!0}],systemSpecificInstructions:`TCP/IP must be enabled on SQL Server. SQL Server logins require mixed-mode authentication.
604
+ `);if(t.length>y3.PLAYBOOK_LIMITS.compiledRender)throw new Error(`Compiled playbook render for '${o.id}' exceeds ${y3.PLAYBOOK_LIMITS.compiledRender} chars (${t.length})`);return t}});var A3=f(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.PROJECT_LIMITS=xr.PROJECT_TASK_STATUSES=xr.PROJECT_RESOURCE_TYPES=void 0;xr.projectResourceKey=ude;xr.PROJECT_RESOURCE_TYPES=["system","playbook","artifact","file","tool"];xr.PROJECT_TASK_STATUSES=["not_started","in_progress","waiting","done"];xr.PROJECT_LIMITS={name:80,description:500,taskName:120,taskDescription:5e3,taskResources:100};function ude(o){return`${o.type}:${o.id}`}});var Fv=f(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.RESOURCE_KINDS=ja.RESOURCE_DEFINITIONS=void 0;ja.isResourceKind=dde;ja.getResourceDefinition=gde;ja.RESOURCE_DEFINITIONS={tool:{label:"Tool",pluralLabel:"Tools",collectionKey:"tools",memberDefaultPermission:"editor",pickerDefaultPermission:"editor"},system:{label:"System",pluralLabel:"Systems",collectionKey:"systems",memberDefaultPermission:"editor",pickerDefaultPermission:"editor"},credential:{label:"Credential",pluralLabel:"Credentials",collectionKey:"credentials",pickerDefaultPermission:"viewer"},playbook:{label:"Playbook",pluralLabel:"Playbooks",collectionKey:"playbooks",pickerDefaultPermission:"editor"},artifact:{label:"Artifact",pluralLabel:"Artifacts",collectionKey:"artifacts",pickerDefaultPermission:"editor"},file:{label:"File",pluralLabel:"Files",collectionKey:"files",pickerDefaultPermission:"viewer"},project:{label:"Project",pluralLabel:"Projects",collectionKey:"projects",pickerDefaultPermission:"viewer"}};ja.RESOURCE_KINDS=Object.keys(ja.RESOURCE_DEFINITIONS);function dde(o){return typeof o=="string"&&Object.prototype.hasOwnProperty.call(ja.RESOURCE_DEFINITIONS,o)}function gde(o){return ja.RESOURCE_DEFINITIONS[o]}});var B3=f(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.RESERVED_ROLE_NAMES=ae.RESERVED_ROLE_IDS=ae.PREDEFINED_ROLE_IDS=void 0;ae.toResourceRef=su;ae.toWildcardResourceRef=cu;ae.getDefaultMemberResourceGrants=pde;ae.parseResourceRef=Qh;ae.getWildcardResourceRef=v3;ae.normalizeResourcePermissions=gn;ae.permissionSatisfies=_h;ae.highestResourcePermission=Dh;ae.grantHasPermission=Gv;ae.grantMatchesResource=Pc;ae.getEffectiveResourcePermissions=Vv;ae.hasResourcePermission=hde;ae.getRoleResourceGrants=Th;ae.getAllowedResourceIds=w3;ae.getAllowedResourceIdsForRoles=Rh;ae.getEffectiveResourcePermissionsForRoles=Fc;ae.getAllowedToolIds=x3;ae.getAllowedSystemIds=z3;ae.pickLongestHeldResource=bde;ae.getAllowedCredentialsIds=yde;ae.getEffectiveCredentialsPermissions=kde;ae.getEffectiveToolPermissions=Ade;ae.getEffectiveSystemPermissions=vde;ae.checkResourcePermission=Nh;ae.isToolAllowed=wde;ae.isSystemVisible=xde;ae.isPlaybookVisible=zde;ae.hasAllSystems=qde;ae.hasAllTools=Ede;ae.getResourceGrantSources=q3;ae.getSharePermissionForResource=E3;ae.getAccessRulePermissionForResource=I3;ae.hasAdminBaseRole=Yv;ae.resolveResourceAccessForRoles=Ide;ae.normalizeResourceGrantInput=j3;ae.normalizeRoleResourceGrantInput=jde;ae.isPredefinedRole=Cde;ae.isReservedRoleId=Sde;ae.isReservedRoleName=Bde;ae.hasRole=Qde;ae.getRoleIds=_de;ae.getBaseRole=C3;ae.getBaseRoleId=Dde;ae.getPersonalRole=S3;ae.getPersonalRoleId=Tde;var Sh=Fv(),Bh="*";function su(o,e){if(!e||e===Bh)throw new Error("Resource id is required");return`${o}:${encodeURIComponent(e)}`}function cu(o){return`${o}:${Bh}`}function pde(){return Sh.RESOURCE_KINDS.flatMap(o=>{let e=(0,Sh.getResourceDefinition)(o).memberDefaultPermission;return e?[{resourceRef:cu(o),permissions:[e]}]:[]})}function Qh(o){let e=o.indexOf(":");if(e<=0)return null;let t=o.slice(0,e);if(!(0,Sh.isResourceKind)(t))return null;let a=o.slice(e+1);if(!a)return null;if(a===Bh)return{kind:t,id:Bh,isWildcard:!0};try{return{kind:t,id:decodeURIComponent(a),isWildcard:!1}}catch{return null}}function v3(o){let e=Qh(o);return e?cu(e.kind):null}function gn(o){let e=new Set;for(let t of o||[])(t==="viewer"||t==="editor")&&e.add(t);return e.has("editor")&&e.add("viewer"),Array.from(e)}function _h(o,e){return o===e||o==="editor"&&e==="viewer"}function Dh(o){let e=gn(o);if(e.includes("editor"))return"editor";if(e.includes("viewer"))return"viewer"}function Gv(o,e){return o.revokedAt?!1:gn(o.permissions).some(t=>_h(t,e))}function Pc(o,e){return o.revokedAt?!1:o.resourceRef===e||o.resourceRef===v3(e)}function Vv(o,e){let t=new Set;for(let a of o)if(Pc(a,e))for(let i of gn(a.permissions))t.add(i);return Array.from(t)}function hde(o,e,t){return Vv(o,e).some(a=>_h(a,t))}function Th(o){return o.flatMap(e=>e.isBaseRole&&e.id==="admin"?[]:e.resourceGrants||[])}function w3(o,e,t){let a=cu(e),i=new Set;for(let r of o){if(!Gv(r,t))continue;if(r.resourceRef===a)return;let n=Qh(r.resourceRef);n?.kind===e&&!n.isWildcard&&i.add(n.id)}return Array.from(i)}function Rh(o,e,t){if(!Yv(o))return w3(Th(o),e,t)}function Fc(o,e,t){return Yv(o)?["editor","viewer"]:Vv(Th(o),su(e,t))}function fde(o){return(0,Sh.getResourceDefinition)(o).label}function x3(o,e="viewer"){return Rh(o,"tool",e)}function z3(o,e="viewer"){return Rh(o,"system",e)}var Hv=Number.MAX_SAFE_INTEGER;function $v(o){if(!o)return Hv;let e=new Date(o).getTime();return Number.isNaN(e)?Hv:e}function bde(o,e,t){if(o.length<=1)return o[0];let a=i=>{let r=su(t,i.id),n=Hv;for(let s of e)Pc(s,r)&&(n=Math.min(n,$v(s.createdAt)));return n};return[...o].sort((i,r)=>{let n=a(i)-a(r);return n!==0?n:$v(i.createdAt)-$v(r.createdAt)})[0]}function yde(o,e="viewer"){return Rh(o,"credential",e)}function kde(o,e){return Fc(o,"credential",e)}function Ade(o,e){return Fc(o,"tool",e)}function vde(o,e){return Fc(o,"system",e)}function Nh(o,e,t,a){return Fc(o,e,t).some(r=>_h(r,a))?{allowed:!0}:{allowed:!1,error:`${fde(e)} '${t}' requires a '${a}' grant`}}function wde(o,e,t="viewer"){return Nh(o,"tool",e,t)}function xde(o,e,t="viewer"){return Nh(o,"system",e,t)}function zde(o,e,t="viewer"){return Nh(o,"playbook",e,t)}function qde(o,e="viewer"){return z3(o,e)===void 0}function Ede(o,e="viewer"){return x3(o,e)===void 0}function q3(o,e,t="viewer"){let a=new Set;for(let i of o)Pc(i,e)&&Gv(i,t)&&a.add(i.source);return Array.from(a)}function E3(o,e){let t=o.filter(a=>a.source==="share"&&Pc(a,e)).flatMap(a=>gn(a.permissions));return Dh(t)}function I3(o,e){let t=o.filter(a=>a.source==="access_rule"&&Pc(a,e)).flatMap(a=>gn(a.permissions));return Dh(t)}function Yv(o){return o.some(e=>e.isBaseRole&&e.id==="admin")}function Ide({roles:o,resource:e,userId:t}){let a=su(e.kind,e.id),i=Th(o),r=new Set(Fc(o,e.kind,e.id)),n=new Set(q3(i,a));e.ownerUserId&&e.ownerUserId===t&&(r.add("editor"),r.add("viewer"),n.add("ownership"));let s=gn(Array.from(r));return{permissions:s,sources:Array.from(n),sharePermission:E3(i,a),accessRulePermission:I3(i,a),maxPermission:Dh(s)}}function j3(o){let e=Qh(o.resourceRef);if(!e)throw new Error(`Invalid resource ref '${o.resourceRef}'`);return{...o,resourceRef:e.isWildcard?cu(e.kind):su(e.kind,e.id),permissions:gn(o.permissions||["viewer"]),source:o.source||"access_rule"}}function jde(o){let e=j3({resourceRef:o.resourceRef,permissions:o.permissions,source:"access_rule"});return{resourceRef:e.resourceRef,permissions:e.permissions,source:"access_rule"}}ae.PREDEFINED_ROLE_IDS=["admin","member"];ae.RESERVED_ROLE_IDS=["admin","member","__admin__"];ae.RESERVED_ROLE_NAMES=["member","admin"];function Cde(o){return ae.PREDEFINED_ROLE_IDS.includes(o)}function Sde(o){return ae.RESERVED_ROLE_IDS.includes(o)}function Bde(o){return ae.RESERVED_ROLE_NAMES.includes(o.toLowerCase().trim())}function Qde(o,e){return o.some(t=>t.id===e)}function _de(o){return o.map(e=>e.id)}function C3(o){let e=o.filter(t=>t.isBaseRole);return e.length===1?e[0]:null}function Dde(o){let e=C3(o);return e?e.id:null}function S3(o){return o.find(e=>e.isPersonalRole)||null}function Tde(o){let e=S3(o);return e?e.id:null}});var _3=f(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.NOTIFICATION_EXCLUDED_REQUEST_SOURCES=St.CLIENT_REQUEST_SOURCES=St.REQUEST_SOURCES=void 0;St.isRequestSource=Q3;St.isClientRequestSource=Ode;St.parseRequestSource=Ude;var et=Ht();St.REQUEST_SOURCES=[et.RequestSource.API,et.RequestSource.FRONTEND,et.RequestSource.AGENT,et.RequestSource.SCHEDULER,et.RequestSource.MCP,et.RequestSource.TOOL_CHAIN,et.RequestSource.WEBHOOK,et.RequestSource.CLI];St.CLIENT_REQUEST_SOURCES=[et.RequestSource.FRONTEND,et.RequestSource.AGENT,et.RequestSource.MCP,et.RequestSource.CLI];St.NOTIFICATION_EXCLUDED_REQUEST_SOURCES=[et.RequestSource.FRONTEND,et.RequestSource.AGENT,et.RequestSource.MCP];var Rde=new Set(St.REQUEST_SOURCES),Nde=new Set(St.CLIENT_REQUEST_SOURCES);function Q3(o){return Rde.has(o)}function Ode(o){return Nde.has(o)}function Ude(o){let e=o.toLowerCase();return Q3(e)?e:void 0}});var D3=f(Oh=>{"use strict";Object.defineProperty(Oh,"__esModule",{value:!0});Oh.contextSourceTemplates=void 0;var Mde={slack:{category:"workspace",systemId:"slack",onboardingOrder:7,onboardingDescription:"Connect joined public channels so superglue can use relevant workspace context."},gmail:{category:"email",systemId:"gmail",onboardingOrder:9,onboardingDescription:"Let superglue access your gmail inbox. superglue will never send emails on your behalf."},fathomMcp:{category:"meetings",systemId:"fathomMcp",onboardingOrder:4,onboardingDescription:"Let superglue use meeting notes and transcripts. superglue will never join or record meetings."},granolaMcp:{category:"meetings",systemId:"granolaMcp",onboardingOrder:2,onboardingDescription:"Let superglue use notes and transcripts. superglue will never join or record meetings."},readAiMcp:{category:"meetings",systemId:"read-ai",onboardingOrder:6,onboardingDescription:"Let superglue use meeting summaries and transcripts. superglue will never join or record meetings."},googleDrive:{category:"workspace",systemId:"google-drive",onboardingOrder:9,onboardingDescription:"Connect accessible Drive files for relevant workspace context."},box:{category:"workspace",systemId:"box",onboardingOrder:11,onboardingDescription:"Connect accessible Box files for relevant workspace context."},notion:{category:"workspace",systemId:"notion",onboardingOrder:8,onboardingDescription:"Connect selected Notion pages for relevant workspace context."},sharepoint:{category:"workspace",systemId:"sharepoint",onboardingOrder:10,onboardingDescription:"Connect accessible SharePoint sites and files for workspace context."},microsoftTeams:{category:"workspace",systemId:"microsoft-teams",onboardingOrder:6,onboardingDescription:"Connect Microsoft Teams channels and meetings for workspace context."},outlookMail:{category:"email",systemId:"outlook-mail",onboardingOrder:8,onboardingDescription:"Let superglue access your outlook inbox. superglue will never send emails on your behalf."},circleback:{category:"meetings",systemId:"circleback",onboardingOrder:1,onboardingDescription:"Let superglue use notes and transcripts. superglue will never join or record meetings.",endpointAliases:["https://app.circleback.ai/api/mcp"]},fireflies:{category:"meetings",systemId:"fireflies",onboardingOrder:3,onboardingDescription:"Let superglue use transcripts and summaries. superglue will never join or record meetings."},fellowMcp:{category:"meetings",systemId:"fellow",onboardingOrder:5,onboardingDescription:"Let superglue use meeting notes and transcripts. superglue will never join or record meetings."}};Oh.contextSourceTemplates=Mde});var Zv=f(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.systemOptions=Oe.systems=void 0;Oe.getSystemTemplateOAuthClientMode=Pde;Oe.getSystemTemplateAuthentication=O3;Oe.mergeSystemTemplateAuthentication=U3;Oe.resolveSystemAuthentication=Wv;Oe.getContextSourceTemplates=M3;Oe.resolveContextSourceSetup=Yde;Oe.findTemplateForSystem=Mh;Oe.uniqueKeywords=Jde;Oe.getOAuthConfig=Wde;Oe.getOAuthTokenExchangeConfig=Zde;Oe.getOAuthTokenUrl=Kde;var Jv=iu(),Lde=D3(),Uh=jh();function Pde(o){let e=o?.oauth;if(e)return e.registrationUrl?"dynamic":e.client_id?"managed":"custom"}function Fde(o){let e=o?.split(/[,\s]+/).filter(Boolean);return e?.length?e:void 0}function O3(o){if(!o?.preferredAuthType)return;if(o.preferredAuthType!=="oauth2")return{type:o.preferredAuthType};let e=o.oauth;if(!e)return{type:"oauth2"};let t={};e.tokenAuthMethod&&(t.tokenAuthMethod=e.tokenAuthMethod),e.tokenContentType&&(t.tokenContentType=e.tokenContentType),e.extraHeaders&&(t.extraHeaders=e.extraHeaders),e.extraBodyParams&&(t.extraBodyParams=e.extraBodyParams),e.usePKCE!==void 0&&(t.usePKCE=e.usePKCE),e.resource&&(t.resource=e.resource);let a=Fde(e.scopes);return{type:"oauth2",...e.registrationUrl?{oauthClientMode:"dynamic"}:{},...e.authUrl?{authUrl:e.authUrl}:{},...e.tokenUrl?{tokenUrl:e.tokenUrl}:{},...e.client_id?{clientId:e.client_id}:{},...e.grant_type?{grantType:e.grant_type}:{},...a?{scopes:a}:{},...Object.keys(t).length?{config:t}:{}}}function $de(o){return!o.config||Object.keys(o.config).length===0}function T3(o,e){let t={...o||{},...e||{}};return Object.keys(t).length>0?t:void 0}function R3(o,e){if(e)return{...o,config:e};let{config:t,...a}=o;return a}function U3({authentication:o,template:e}){let t=O3(e),a=(0,Jv.normalizeSystemAuthentication)(o);if(!a)return t;if(!t)return a;if(a.type==="none"&&$de(a))return t;if(a.type!==t.type)return a;if(a.type==="oauth2"&&t.type==="oauth2"){let i={...t};a.oauthClientMode==="custom"&&(delete i.clientId,delete i.clientSecret);let r={...i,...a};return(0,Jv.resolveOAuthClientMode)({authentication:a,templateClientId:t.clientId,templateRegistrationUrl:e.oauth?.registrationUrl})==="managed"&&t.clientId&&(r.clientId=t.clientId),R3(r,T3(t.config,a.config))}return R3({...t,...a},T3(t.config,a.config))}function Wv(o){let e=(0,Jv.normalizeSystemAuthentication)(o.authentication)||{type:"none"};return U3({authentication:e,template:Mh(o)?.template})||e}var Hde={postgres:{name:"postgres",apiUrl:"postgres://<<username>>:<<password>>@<<host>>:<<port>>/<<database>>",regex:"^.*(postgres|postgresql).*$",icon:"postgresql",docsUrl:"",preferredAuthType:"connection_string",connectionFields:[{key:"host",label:"Host",placeholder:"db.example.com",required:!0},{key:"port",label:"Port",type:"number",defaultValue:"5432",placeholder:"5432"},{key:"database",label:"Database",placeholder:"mydb",required:!0},{key:"username",label:"Username",placeholder:"postgres",required:!0},{key:"password",label:"Password",type:"password",required:!0}],keywords:["database","sql","postgres","postgresql","api key","tables"]},mssql:{name:"mssql",apiUrl:"mssql://<<username>>:<<password>>@<<host>>:<<port>>/<<database>>",regex:"^.*\\b(mssql|sql[\\s._-]?server).*$",icon:"lucide:database",docsUrl:"https://learn.microsoft.com/en-us/sql/sql-server/connect-to-database-engine",preferredAuthType:"connection_string",connectionFields:[{key:"host",label:"Host",placeholder:"sql.example.com",required:!0},{key:"port",label:"Port",type:"number",defaultValue:"1433",placeholder:"1433"},{key:"database",label:"Database",placeholder:"mydb",required:!0},{key:"username",label:"Username",required:!0},{key:"password",label:"Password",type:"password",required:!0}],systemSpecificInstructions:`TCP/IP must be enabled on SQL Server. SQL Server logins require mixed-mode authentication.
605
605
 
606
606
  Default instances typically use TCP port 1433. Named instances can use dynamic ports and SQL Server Browser on UDP 1434; request the instance's actual TCP port when direct connections fail.`,keywords:["database","sql","sql server","mssql","transact-sql","t-sql","table","schema","view","stored procedure"]},redis_direct:{name:"redis_direct",apiUrl:"redis://<<username>>:<<password>>@<<host>>:<<port>>/<<database>>",regex:"^.*(rediss?://).*$",icon:"redis",docsUrl:"https://redis.io/docs/latest/commands/",preferredAuthType:"connection_string",connectionFields:[{key:"host",label:"Host",placeholder:"redis.example.com",required:!0},{key:"port",label:"Port",type:"number",defaultValue:"6379",placeholder:"6379"},{key:"database",label:"Database Index",placeholder:"0"},{key:"username",label:"Username",placeholder:"default"},{key:"password",label:"Password",type:"password",required:!0}],keywords:["database","cache","redis","key-value","nosql"]},mongodb_direct:{name:"mongodb_direct",apiUrl:"mongodb://<<username>>:<<password>>@<<host>>:<<port>>/<<database>>?authSource=admin",regex:"^.*(mongodb(\\+srv)?://).*$",icon:"mongodb",docsUrl:"https://www.mongodb.com/docs/manual/reference/method/",preferredAuthType:"connection_string",connectionFields:[{key:"host",label:"Host",placeholder:"cluster.example.com",required:!0},{key:"port",label:"Port",type:"number",defaultValue:"27017",placeholder:"27017"},{key:"database",label:"Database",placeholder:"mydb",required:!0},{key:"username",label:"Username",placeholder:"admin"},{key:"password",label:"Password",type:"password"}],keywords:["database","mongodb","mongo","nosql","document","collection","atlas"]},azure_sql:{name:"azure_sql",apiUrl:"mssql://<<user>>:<<password>>@<<host>>:1433/<<database>>",regex:"^.*(azure.*sql|sql.*azure|database\\.windows\\.net).*$",icon:"/logos/azure_sql.svg",docsUrl:"https://learn.microsoft.com/en-us/azure/azure-sql/",preferredAuthType:"connection_string",connectionFields:[{key:"host",label:"Host",placeholder:"myserver.database.windows.net",required:!0},{key:"database",label:"Database",placeholder:"mydb",required:!0},{key:"user",label:"Username",placeholder:"user@domain.com",required:!0},{key:"password",label:"Password",type:"password",required:!0},{key:"authType",label:"Auth Type",placeholder:"azure-active-directory-password"},{key:"clientId",label:"Client ID",placeholder:"App Registration client ID"},{key:"clientSecret",label:"Client Secret",type:"password",placeholder:"Service principal secret"},{key:"tenantId",label:"Tenant ID",placeholder:"Azure AD directory ID"}],systemSpecificInstructions:`Azure SQL supports two authentication modes:
607
607
 
@@ -634,7 +634,7 @@ Authentication is not sent as Authorization: Bearer. First call POST /openapi/v1
634
634
 
635
635
  API keys are generated by a Jisr Admin in Settings > Webhook & API Keys > API Keys. Enabled API and lookup permissions control which endpoints and fields are accessible, the secret can only be copied once, and employee financial fields require the "Get Employee Financial Info" permission.
636
636
 
637
- Most list endpoints paginate with page plus rpp or limit, capped at 100 records per page. Payroll and accrual endpoints often require specific type values, paygroup filters, and pay period dates set to the first day of a confirmed month. Some payroll endpoints, including employee monthly payables and payroll transaction deletion, are available only for whitelisted organizations.`},attio:{name:"attio",apiUrl:"https://api.attio.com/v2/",regex:"^.*attio.*$",icon:"/logos/attio.svg",docsUrl:"https://docs.attio.com/rest-api/overview",openApiUrl:"https://api.attio.com/openapi/api",preferredAuthType:"api_key",keywords:["people","objects","records","lists","entries","workspace_members","notes","tasks","threads","comments","sorts","api_slug","attribute_type","record_id","workspace_id","object_id"]},twilio:{name:"twilio",apiUrl:"https://api.twilio.com",regex:"^.*twilio.*$",icon:"/logos/twilio.svg",docsUrl:"https://www.twilio.com/docs/api",openApiUrl:"https://raw.githubusercontent.com/twilio/twilio-oai/refs/heads/main/spec/json/twilio_api_v2010.json",preferredAuthType:"api_key",keywords:["Messages","Media","MessageFeedback","Calls","Accounts","APIKeys","Addresses","UsageRecords","CallFeedback","CredentialsList","TaskRouter_Workspaces","TaskRouter_Tasks","TaskRouter_Workers","TaskRouter_Activities","MessagingServices"]},sendgrid:{name:"sendgrid",apiUrl:"https://api.sendgrid.com",regex:"^.*sendgrid.*$",icon:"/logos/sendgrid.svg",docsUrl:"https://www.twilio.com/docs/sendgrid/api-reference",openApiUrl:"https://raw.githubusercontent.com/sendgrid/sendgrid-oai/main/oai.json",preferredAuthType:"api_key",keywords:["mail_send","templates","campaigns","marketing_contacts","marketing_lists","suppression_groups","global_suppressions","asm_suppressions","subusers","stats","categories","whitelabel","ips","access_settings"]},github:{name:"github",apiUrl:"https://api.github.com",regex:"^.*github.*$",icon:"github",docsUrl:"https://docs.github.com/en/rest",openApiUrl:"https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json",preferredAuthType:"api_key",oauth:{authUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",scopes:"repo user admin:org workflow gist notifications delete_repo write:packages read:packages"},keywords:["repositories","issues","pull_requests","commits","branches","tags","releases","deployments","check_runs","actions_artifacts","organizations","packages","collaborators","gists","milestones"]},gitlab:{name:"gitlab",apiUrl:"https://api.gitlab.com",regex:"^.*gitlab.*$",icon:"gitlab",docsUrl:"https://docs.gitlab.com/api/rest/",openApiUrl:"https://gitlab.com/gitlab-org/gitlab/-/raw/master/doc/api/openapi/openapi.yaml",preferredAuthType:"api_key",oauth:{authUrl:"https://gitlab.com/oauth/authorize",tokenUrl:"https://gitlab.com/oauth/token",scopes:"api"},keywords:["projects","repositories","issues","pull_requests","commits","branches","tags","releases","deployments","check_runs","actions_artifacts","organizations","packages","collaborators","gists","milestones"]},bitbucket:{name:"bitbucket",apiUrl:"https://api.bitbucket.org",regex:"^.*bitbucket.*$",icon:"bitbucket",docsUrl:"https://developer.atlassian.com/cloud/bitbucket/rest",openApiUrl:"https://api.bitbucket.org/swagger.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://bitbucket.org/site/oauth2/authorize",tokenUrl:"https://bitbucket.org/site/oauth2/access_token",scopes:"repository:admin account:write team:write webhook"},keywords:["repositories","projects","commits","branches","pullrequests","downloads","issues","pipelines","branchRestrictions","components","milestones","refs","hooks","forks","user"]},slack:{name:"slack",label:"Slack",apiUrl:"https://slack.com/api",regex:"^.*slack.*$",icon:"slack",docsUrl:"https://docs.slack.dev/apis/web-api/",openApiUrl:"https://raw.githubusercontent.com/slackapi/slack-api-specs/master/web-api/slack_web_openapi_v2.json",preferredAuthType:"oauth2",oauth:{grant_type:"authorization_code",authUrl:"https://slack.com/oauth/v2/authorize",tokenUrl:"https://slack.com/api/oauth.v2.access",scopes:"channels:history channels:join channels:read files:read users:read users:read.email",client_id:"7626585708593.9087382641312"},keywords:["channel","conversation","user","file","event","message","workflow_step","workflow_published","workflow_step_execute","usergroup","im","mpim","group","check_run","apps_permissions_resource"],systemSpecificInstructions:"Slack OAuth returns a bot token. Bot access depends on its granted scopes and channel membership."},airtable:{name:"airtable",apiUrl:"https://api.airtable.com",regex:"^.*airtable.*$",icon:"airtable",docsUrl:"https://airtable.com/developers/web/api",preferredAuthType:"oauth2",oauth:{authUrl:"https://airtable.com/oauth2/v1/authorize",tokenUrl:"https://airtable.com/oauth2/v1/token",scopes:"data.recordComments:read data.recordComments:write data.records:read data.records:write schema.bases:read schema.bases:write user.email:read enterprise.groups:read data.records:manage enterprise.account:read enterprise.account:write enterprise.auditLogs:read enterprise.changeEvents:read enterprise.exports:manage enterprise.groups:manage enterprise.scim.usersAndGroups:manage enterprise.user:read enterprise.user:write webhook:manage",client_id:"02601365-de97-4191-b12d-e03c8540b03d",usePKCE:!0,tokenAuthMethod:"basic_auth",tokenContentType:"form"},keywords:["bases","tables","records","fields","views","formulas","attachments","comments","collaborators","metadata","schemas","api key","key"]},gmail:{name:"gmail",label:"Gmail",apiUrl:"https://gmail.googleapis.com/gmail/v1",regex:"^.*(gmail\\.googleapis|developers\\.google\\.com/gmail|mail\\.google).*$",icon:"gmail",docsUrl:"https://developers.google.com/gmail/api/reference/rest",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/gmail.readonly"},keywords:["messages","threads","labels","drafts","send","attachments","history","filters","settings","forwarding","inbox","profile","oauth"]},googleWorkspace:{name:"googleWorkspace",label:"Google Workspace",apiUrl:"https://www.googleapis.com",regex:"^.*(workspace\\.google\\.com|developers\\.google\\.com/workspace(?!/tasks)).*$",icon:"/logos/google.svg",docsUrl:"https://developers.google.com/workspace",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:["openid","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/calendar","https://www.googleapis.com/auth/calendar.settings.readonly","https://www.googleapis.com/auth/documents","https://www.googleapis.com/auth/spreadsheets","https://www.googleapis.com/auth/presentations","https://www.googleapis.com/auth/forms.body","https://www.googleapis.com/auth/forms.responses.readonly","https://www.googleapis.com/auth/gmail.send","https://www.googleapis.com/auth/contacts","https://www.googleapis.com/auth/contacts.other.readonly","https://www.googleapis.com/auth/directory.readonly","https://www.googleapis.com/auth/tasks","https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive.appdata"].join(" "),client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google Workspace OAuth app; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. The System URL is the shared Google API host; address each product by its own path prefix or host: Calendar /calendar/v3, Docs https://docs.googleapis.com/v1, Sheets https://sheets.googleapis.com/v4, Slides https://slides.googleapis.com/v1, Forms https://forms.googleapis.com/v1, Gmail https://gmail.googleapis.com/gmail/v1 (send only, via POST /users/me/messages/send with a base64url RFC 5322 message; use it only when the user explicitly asks to send), People https://people.googleapis.com/v1 (contacts, otherContacts, and people:searchDirectoryPeople for the Workspace directory; directory search requires a Google Workspace account), Tasks https://tasks.googleapis.com/tasks/v1, Drive https://www.googleapis.com/drive/v3 (drive.file scope: only files created or opened through this app). Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days.",keywords:["workspace","calendar","events","docs","documents","sheets","spreadsheets","slides","presentations","forms","responses","gmail","send email","contacts","people","directory","tasks","oauth"]},granola:{name:"granola",label:"Granola API",apiUrl:"https://public-api.granola.ai",regex:"^.*granola.*$",icon:"/logos/granola.svg",docsUrl:"https://docs.granola.ai",preferredAuthType:"api_key",keywords:["meeting","notes","transcript","summary","ai","recording"]},fathom:{name:"fathom",apiUrl:"https://api.fathom.ai/external/v1",regex:"^.*(fathom\\.ai|fathom\\.video).*$",icon:"/logos/fathom.png",docsUrl:"https://developers.fathom.ai",openApiUrl:"https://developers.fathom.ai/api-reference/openapi.yaml",preferredAuthType:"oauth2",oauth:{grant_type:"authorization_code",authUrl:"https://fathom.video/external/v1/oauth2/authorize",tokenUrl:"https://api.fathom.ai/external/v1/oauth2/token",scopes:"public_api",client_id:"NBYMQ3dZJDub0dL1X3MX7812Tjc91f-5fFcL5D3tXp4"},keywords:["meeting","meetings","notetaker","transcript","transcription","recording","summary","action items","webhook","oauth"],systemSpecificInstructions:"Fathom is an AI meeting notetaker. superglue provides a managed Fathom OAuth app, so no app registration is needed \u2014 authenticate directly via OAuth (authorization code with refresh tokens; the only scope is public_api). Alternatively, an API key created in Fathom settings works via an X-Api-Key header. Send OAuth tokens as Authorization: Bearer <<access_token>>. Webhooks must set at least one of include_transcript, include_summary, include_action_items, or include_crm_matches. Rate limits: 60 requests per 60 seconds overall, 30 per 60 seconds for transcript, summary, and content-heavy meeting requests (5 per 60 seconds under high load)."},fathomMcp:{name:"fathomMcp",label:"Fathom",apiUrl:"https://api.fathom.ai/mcp",regex:"^https://api\\.fathom\\.ai/mcp/?(?:\\?.*)?$",icon:"/logos/fathom.png",docsUrl:"https://developers.fathom.ai/mcp-docs",preferredAuthType:"oauth2",oauth:{authUrl:"https://fathom.video/mcp/oauth/authorize",tokenUrl:"https://api.fathom.ai/mcp/oauth/token",registrationUrl:"https://api.fathom.ai/mcp/oauth/register",scopes:"mcp",resource:"https://api.fathom.ai/mcp",tokenAuthMethod:"body",usePKCE:!0},systemSpecificInstructions:"Fathom is a brain context source (meetings) backed by remote MCP. Load the meetings skill before using it. Keep the MCP endpoint unchanged. Authentication uses OAuth dynamic client registration with PKCE. Store the registered client configuration on the shared System and tokens in the current user's credential. Discover the current read tools before use, search narrowly, and retrieve transcript content only when relevant. Never join, record, edit, or otherwise mutate meetings through this integration. Use the separate Fathom API template only when deterministic REST access is required.",keywords:["meetings","notes","transcripts","summaries","action_items","attendees","recordings","decisions"]},granolaMcp:{name:"granolaMcp",label:"Granola",apiUrl:"https://mcp.granola.ai/mcp",regex:"^https://mcp\\.granola\\.ai/mcp/?(?:\\?.*)?$",icon:"/logos/granola.svg",docsUrl:"https://docs.granola.ai/help-center/sharing/integrations/mcp",preferredAuthType:"oauth2",oauth:{authUrl:"https://mcp-auth.granola.ai/oauth2/authorize",tokenUrl:"https://mcp-auth.granola.ai/oauth2/token",registrationUrl:"https://mcp-auth.granola.ai/oauth2/register",scopes:"mcp",resource:"https://mcp.granola.ai/mcp",tokenAuthMethod:"body",usePKCE:!0},systemSpecificInstructions:"Granola is a brain context source (meetings) backed by remote MCP. Load the meetings skill before using it. Keep the MCP endpoint unchanged. Authentication uses OAuth dynamic client registration with PKCE. Store the registered client configuration on the shared System and tokens in the current user's credential. Search narrowly and retrieve transcript content only when relevant. Never edit meeting data through this integration.",keywords:["meetings","notes","transcripts","summaries","action_items","attendees","folders","decisions"]},googleDrive:{name:"googleDrive",label:"Google Drive",apiUrl:"https://www.googleapis.com/drive/v3",regex:"^.*(googleapis\\.com/drive|developers\\.google\\.com/drive|drive\\.google).*$",icon:"googledrive",docsUrl:"https://developers.google.com/drive/api/v3/reference",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/drive/v3/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/drive.readonly"},keywords:["files","folders","permissions","sharing","comments","revisions","changes","uploads","downloads","metadata","teamdrives","export","copy","move","oauth"],systemSpecificInstructions:"Use Drive API v3. Export Google Workspace files and use media download for stored files."},googleCalendar:{name:"googleCalendar",apiUrl:"https://www.googleapis.com/calendar/v3",regex:"^.*(googleapis\\.com/calendar|developers\\.google\\.com/calendar|calendar\\.google).*$",icon:"googlecalendar",docsUrl:"https://developers.google.com/calendar/api/v3/reference",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.settings.readonly",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Calendar; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days.",keywords:["events","calendars","attendees","reminders","recurring","availability","free busy","settings","acl","colors","notifications","timezone","quick add","oauth"]},googleSheets:{name:"googleSheets",apiUrl:"https://sheets.googleapis.com/v4",regex:"^.*(sheets\\.googleapis|developers\\.google\\.com/sheets|sheets\\.google).*$",icon:"googlesheets",docsUrl:"https://developers.google.com/sheets/api/reference/rest",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/sheets/v4/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive.file",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Sheets; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. The drive.file scope only lists files created or opened through this app; open any existing spreadsheet directly by its ID with the spreadsheets scope.",keywords:["spreadsheets","sheets","cells","ranges","values","formulas","formatting","charts","pivot tables","named ranges","protected ranges","batch update","append","oauth"]},googleDocs:{name:"googleDocs",label:"Google Docs",apiUrl:"https://docs.googleapis.com/v1",regex:"^.*(docs\\.googleapis|developers\\.google\\.com/docs|docs\\.google\\.com/document).*$",icon:"googledocs",docsUrl:"https://developers.google.com/docs/api/reference/rest",openApiUrl:"https://docs.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/documents https://www.googleapis.com/auth/drive.file",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Docs; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. Create a document with POST /documents and edit it with POST /documents/{documentId}:batchUpdate.",keywords:["documents","docs","text","paragraphs","headings","tables","images","batch update","insert text","replace text","named ranges","oauth"]},googleSlides:{name:"googleSlides",label:"Google Slides",apiUrl:"https://slides.googleapis.com/v1",regex:"^.*(slides\\.googleapis|developers\\.google\\.com/slides|docs\\.google\\.com/presentation).*$",icon:"googleslides",docsUrl:"https://developers.google.com/slides/api/reference/rest",openApiUrl:"https://slides.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/presentations https://www.googleapis.com/auth/drive.file",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Slides; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. Create a presentation with POST /presentations and edit it with POST /presentations/{presentationId}:batchUpdate.",keywords:["presentations","slides","decks","shapes","text boxes","images","layouts","batch update","thumbnails","oauth"]},googleForms:{name:"googleForms",label:"Google Forms",apiUrl:"https://forms.googleapis.com/v1",regex:"^.*(forms\\.googleapis|developers\\.google\\.com/forms|docs\\.google\\.com/forms).*$",icon:"googleforms",docsUrl:"https://developers.google.com/forms/api/reference/rest",openApiUrl:"https://forms.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/forms.body https://www.googleapis.com/auth/forms.responses.readonly https://www.googleapis.com/auth/drive.file",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Forms; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. Create a form with POST /forms (title only), add questions with POST /forms/{formId}:batchUpdate, and read submissions with GET /forms/{formId}/responses.",keywords:["forms","questions","responses","submissions","surveys","quizzes","batch update","items","oauth"]},googleContacts:{name:"googleContacts",label:"Google Contacts",apiUrl:"https://people.googleapis.com/v1",regex:"^.*(people\\.googleapis|developers\\.google\\.com/people|contacts\\.google\\.com).*$",icon:"/logos/google.svg",docsUrl:"https://developers.google.com/people/api/rest",openApiUrl:"https://people.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/contacts https://www.googleapis.com/auth/contacts.other.readonly https://www.googleapis.com/auth/directory.readonly",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Contacts; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. Use /people/me/connections and /people:createContact for saved contacts, /otherContacts for automatically saved contacts, and /people:searchDirectoryPeople for the Google Workspace directory (requires a Workspace account). Every request needs personFields or readMask.",keywords:["contacts","people","directory","other contacts","connections","emails","phone numbers","organizations","search","oauth"]},googleTasks:{name:"googleTasks",label:"Google Tasks",apiUrl:"https://tasks.googleapis.com/tasks/v1",regex:"^.*(tasks\\.googleapis|developers\\.google\\.com/(workspace/)?tasks|tasks\\.google\\.com).*$",icon:"googletasks",docsUrl:"https://developers.google.com/tasks/reference/rest",openApiUrl:"https://tasks.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/tasks",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Tasks; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. List task lists with GET /users/@me/lists and create tasks with POST /lists/{tasklist}/tasks.",keywords:["tasks","task lists","to-do","due dates","completed","subtasks","oauth"]},googleAnalytics:{name:"googleAnalytics",apiUrl:"https://analytics.google.com",regex:"^.*(analytics|analyticsdata).*$",icon:"googleAnalytics",docsUrl:"https://developers.google.com/analytics/devguides/reporting/data/v1",openApiUrl:"https://analyticsdata.googleapis.com/$discovery/rest?version=v1beta",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/analytics.edit"},keywords:["properties","dimensions","metrics","reports","audiences","conversions","events","goals","segments","real time","user activity","attribution","funnels","cohorts","oauth"]},youtube:{name:"youtube",apiUrl:"https://youtube.googleapis.com",regex:"^.*youtube.*$",icon:"youtube",docsUrl:"https://developers.google.com/youtube/v3/docs",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/youtube"},keywords:["videos","channels","playlists","comments","captions","live streams","analytics","thumbnails","subscriptions","activities","ratings","uploads","members","oauth"]},AWS:{name:"AWS",apiUrl:"https://amazonaws.com",regex:"^.*(aws|amazonaws).*$",icon:"/logos/aws.svg",docsUrl:"https://docs.aws.amazon.com/index.html",preferredAuthType:"api_key",keywords:["ec2","s3","lambda","rds","dynamodb","sqs","sns","cloudformation","iam","cloudwatch","vpc","instances","buckets","functions","api key"]},amazon_sp_api:{name:"amazon_sp_api",apiUrl:"https://sellingpartnerapi-na.amazon.com",regex:"^.*(sellingpartnerapi[-\\w]*\\.amazon\\.com).*$",icon:"/logos/amazon.svg",docsUrl:"https://developer-docs.amazon.com/sp-api/docs",preferredAuthType:"oauth2",oauth:{authUrl:"https://sellercentral.amazon.com/apps/authorize/consent",tokenUrl:"https://api.amazon.com/auth/o2/token",grant_type:"authorization_code",tokenAuthMethod:"body",tokenContentType:"form"},keywords:["orders","catalog items","listings","feeds","reports","fba inbound","fulfillment","inventory","pricing","seller central","marketplace"],systemSpecificInstructions:`Base host is region-specific: sellingpartnerapi-na.amazon.com (US/CA/MX/BR), sellingpartnerapi-eu.amazon.com (EU/UK/IN/ME/AF), sellingpartnerapi-fe.amazon.com (Singapore/AU/JP) \u2014 swap the region segment to match the seller's marketplace; sandbox testing uses sandbox.sellingpartnerapi-<region>.amazon.com. Requires registering an app in Seller Central > Develop Apps first. Third-party apps redirect sellers to https://sellercentral.amazon.com/apps/authorize/consent?application_id=<APP_ID>&state=<STATE> (add &version=beta only while the app is in Draft state, remove once Published); private/single-account developers can skip this by generating a refresh token directly via Seller Central > Develop Apps > "Authorize new developer" (self-authorization). Access tokens require header x-amz-access-token in addition to Authorization; some operations (e.g. FBA/notifications) use a separate grantless client_credentials flow instead of the refresh-token flow.`},googleCloud:{name:"googleCloud",apiUrl:"https://cloud.google.com",regex:"^.*(cloud\\.google|gcp|googlecloud).*$",icon:"googleCloud",docsUrl:"https://cloud.google.com/apis/docs/overview",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/cloud-platform"},keywords:["compute","storage","pubsub","cloud run","kubernetes","iam","vpc","cloud sql","bigtable","dataflow","logging","monitoring","oauth"]},bigquery:{name:"bigquery",apiUrl:"https://bigquery.googleapis.com/bigquery/v2",regex:"^.*(bigquery|bq\\.googleapis).*$",icon:"googleCloud",docsUrl:"https://cloud.google.com/bigquery/docs/reference/rest",openApiUrl:"https://bigquery.googleapis.com/$discovery/rest?version=v2",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/bigquery"},systemSpecificInstructions:`BigQuery REST API - Authentication Options:
637
+ Most list endpoints paginate with page plus rpp or limit, capped at 100 records per page. Payroll and accrual endpoints often require specific type values, paygroup filters, and pay period dates set to the first day of a confirmed month. Some payroll endpoints, including employee monthly payables and payroll transaction deletion, are available only for whitelisted organizations.`},attio:{name:"attio",apiUrl:"https://api.attio.com/v2/",regex:"^.*attio.*$",icon:"/logos/attio.svg",docsUrl:"https://docs.attio.com/rest-api/overview",openApiUrl:"https://api.attio.com/openapi/api",preferredAuthType:"api_key",keywords:["people","objects","records","lists","entries","workspace_members","notes","tasks","threads","comments","sorts","api_slug","attribute_type","record_id","workspace_id","object_id"]},twilio:{name:"twilio",apiUrl:"https://api.twilio.com",regex:"^.*twilio.*$",icon:"/logos/twilio.svg",docsUrl:"https://www.twilio.com/docs/api",openApiUrl:"https://raw.githubusercontent.com/twilio/twilio-oai/refs/heads/main/spec/json/twilio_api_v2010.json",preferredAuthType:"api_key",keywords:["Messages","Media","MessageFeedback","Calls","Accounts","APIKeys","Addresses","UsageRecords","CallFeedback","CredentialsList","TaskRouter_Workspaces","TaskRouter_Tasks","TaskRouter_Workers","TaskRouter_Activities","MessagingServices"]},sendgrid:{name:"sendgrid",apiUrl:"https://api.sendgrid.com",regex:"^.*sendgrid.*$",icon:"/logos/sendgrid.svg",docsUrl:"https://www.twilio.com/docs/sendgrid/api-reference",openApiUrl:"https://raw.githubusercontent.com/sendgrid/sendgrid-oai/main/oai.json",preferredAuthType:"api_key",keywords:["mail_send","templates","campaigns","marketing_contacts","marketing_lists","suppression_groups","global_suppressions","asm_suppressions","subusers","stats","categories","whitelabel","ips","access_settings"]},github:{name:"github",apiUrl:"https://api.github.com",regex:"^.*github.*$",icon:"github",docsUrl:"https://docs.github.com/en/rest",openApiUrl:"https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json",preferredAuthType:"api_key",oauth:{authUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",scopes:"repo user admin:org workflow gist notifications delete_repo write:packages read:packages"},keywords:["repositories","issues","pull_requests","commits","branches","tags","releases","deployments","check_runs","actions_artifacts","organizations","packages","collaborators","gists","milestones"]},gitlab:{name:"gitlab",apiUrl:"https://api.gitlab.com",regex:"^.*gitlab.*$",icon:"gitlab",docsUrl:"https://docs.gitlab.com/api/rest/",openApiUrl:"https://gitlab.com/gitlab-org/gitlab/-/raw/master/doc/api/openapi/openapi.yaml",preferredAuthType:"api_key",oauth:{authUrl:"https://gitlab.com/oauth/authorize",tokenUrl:"https://gitlab.com/oauth/token",scopes:"api"},keywords:["projects","repositories","issues","pull_requests","commits","branches","tags","releases","deployments","check_runs","actions_artifacts","organizations","packages","collaborators","gists","milestones"]},bitbucket:{name:"bitbucket",apiUrl:"https://api.bitbucket.org",regex:"^.*bitbucket.*$",icon:"bitbucket",docsUrl:"https://developer.atlassian.com/cloud/bitbucket/rest",openApiUrl:"https://api.bitbucket.org/swagger.json",preferredAuthType:"oauth2",oauth:{authUrl:"https://bitbucket.org/site/oauth2/authorize",tokenUrl:"https://bitbucket.org/site/oauth2/access_token",scopes:"repository:admin account:write team:write webhook"},keywords:["repositories","projects","commits","branches","pullrequests","downloads","issues","pipelines","branchRestrictions","components","milestones","refs","hooks","forks","user"]},slack:{name:"slack",label:"Slack",apiUrl:"https://slack.com/api",regex:"^.*slack.*$",icon:"slack",docsUrl:"https://docs.slack.dev/apis/web-api/",openApiUrl:"https://raw.githubusercontent.com/slackapi/slack-api-specs/master/web-api/slack_web_openapi_v2.json",preferredAuthType:"oauth2",oauth:{grant_type:"authorization_code",authUrl:"https://slack.com/oauth/v2/authorize",tokenUrl:"https://slack.com/api/oauth.v2.access",scopes:"channels:history channels:join channels:read files:read users:read users:read.email",client_id:"7626585708593.9087382641312"},keywords:["channel","conversation","user","file","event","message","workflow_step","workflow_published","workflow_step_execute","usergroup","im","mpim","group","check_run","apps_permissions_resource"],systemSpecificInstructions:"Slack OAuth returns a bot token. Bot access depends on its granted scopes and channel membership."},airtable:{name:"airtable",apiUrl:"https://api.airtable.com",regex:"^.*airtable.*$",icon:"airtable",docsUrl:"https://airtable.com/developers/web/api",preferredAuthType:"oauth2",oauth:{authUrl:"https://airtable.com/oauth2/v1/authorize",tokenUrl:"https://airtable.com/oauth2/v1/token",scopes:"data.recordComments:read data.recordComments:write data.records:read data.records:write schema.bases:read schema.bases:write user.email:read enterprise.groups:read data.records:manage enterprise.account:read enterprise.account:write enterprise.auditLogs:read enterprise.changeEvents:read enterprise.exports:manage enterprise.groups:manage enterprise.scim.usersAndGroups:manage enterprise.user:read enterprise.user:write webhook:manage",client_id:"02601365-de97-4191-b12d-e03c8540b03d",usePKCE:!0,tokenAuthMethod:"basic_auth",tokenContentType:"form"},keywords:["bases","tables","records","fields","views","formulas","attachments","comments","collaborators","metadata","schemas","api key","key"]},gmail:{name:"gmail",label:"Gmail",apiUrl:"https://gmail.googleapis.com/gmail/v1",regex:"^.*(gmail\\.googleapis|developers\\.google\\.com/gmail|mail\\.google).*$",icon:"gmail",docsUrl:"https://developers.google.com/gmail/api/reference/rest",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/gmail.readonly"},keywords:["messages","threads","labels","drafts","send","attachments","history","filters","settings","forwarding","inbox","profile","oauth"]},googleWorkspace:{name:"googleWorkspace",label:"Google Workspace",apiUrl:"https://www.googleapis.com",regex:"^.*(workspace\\.google\\.com|developers\\.google\\.com/workspace(?!/tasks)).*$",icon:"/logos/google.svg",docsUrl:"https://developers.google.com/workspace",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:["openid","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/calendar","https://www.googleapis.com/auth/calendar.settings.readonly","https://www.googleapis.com/auth/documents","https://www.googleapis.com/auth/spreadsheets","https://www.googleapis.com/auth/presentations","https://www.googleapis.com/auth/forms.body","https://www.googleapis.com/auth/forms.responses.readonly","https://www.googleapis.com/auth/gmail.send","https://www.googleapis.com/auth/contacts","https://www.googleapis.com/auth/contacts.other.readonly","https://www.googleapis.com/auth/directory.readonly","https://www.googleapis.com/auth/tasks","https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive.appdata"].join(" "),client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google Workspace OAuth app; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. The System URL is the shared Google API host; address each product by its own path prefix or host: Calendar /calendar/v3, Docs https://docs.googleapis.com/v1, Sheets https://sheets.googleapis.com/v4, Slides https://slides.googleapis.com/v1, Forms https://forms.googleapis.com/v1, Gmail https://gmail.googleapis.com/gmail/v1 (send only, via POST /users/me/messages/send with a base64url RFC 5322 message; use it only when the user explicitly asks to send), People https://people.googleapis.com/v1 (contacts, otherContacts, and people:searchDirectoryPeople for the Workspace directory; directory search requires a Google Workspace account), Tasks https://tasks.googleapis.com/tasks/v1, Drive https://www.googleapis.com/drive/v3 (drive.file scope: only files created or opened through this app). Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days.",keywords:["workspace","calendar","events","docs","documents","sheets","spreadsheets","slides","presentations","forms","responses","gmail","send email","contacts","people","directory","tasks","oauth"]},granola:{name:"granola",label:"Granola API",apiUrl:"https://public-api.granola.ai",regex:"^.*granola.*$",icon:"/logos/granola.svg",docsUrl:"https://docs.granola.ai",preferredAuthType:"api_key",keywords:["meeting","notes","transcript","summary","ai","recording"]},fathom:{name:"fathom",apiUrl:"https://api.fathom.ai/external/v1",regex:"^.*(fathom\\.ai|fathom\\.video).*$",icon:"/logos/fathom.png",docsUrl:"https://developers.fathom.ai",openApiUrl:"https://developers.fathom.ai/api-reference/openapi.yaml",preferredAuthType:"oauth2",oauth:{grant_type:"authorization_code",authUrl:"https://fathom.video/external/v1/oauth2/authorize",tokenUrl:"https://api.fathom.ai/external/v1/oauth2/token",scopes:"public_api",client_id:"NBYMQ3dZJDub0dL1X3MX7812Tjc91f-5fFcL5D3tXp4"},keywords:["meeting","meetings","notetaker","transcript","transcription","recording","summary","action items","webhook","oauth"],systemSpecificInstructions:"Fathom is an AI meeting notetaker. superglue provides a managed Fathom OAuth app, so no app registration is needed \u2014 authenticate directly via OAuth (authorization code with refresh tokens; the only scope is public_api). Alternatively, an API key created in Fathom settings works via an X-Api-Key header. Send OAuth tokens as Authorization: Bearer <<access_token>>. Webhooks must set at least one of include_transcript, include_summary, include_action_items, or include_crm_matches. Rate limits: 60 requests per 60 seconds overall, 30 per 60 seconds for transcript, summary, and content-heavy meeting requests (5 per 60 seconds under high load)."},fathomMcp:{name:"fathomMcp",label:"Fathom",apiUrl:"https://api.fathom.ai/mcp",regex:"^https://api\\.fathom\\.ai/mcp/?(?:\\?.*)?$",icon:"/logos/fathom.png",docsUrl:"https://developers.fathom.ai/mcp-docs",preferredAuthType:"oauth2",oauth:{authUrl:"https://fathom.video/mcp/oauth/authorize",tokenUrl:"https://api.fathom.ai/mcp/oauth/token",registrationUrl:"https://api.fathom.ai/mcp/oauth/register",scopes:"mcp",resource:"https://api.fathom.ai/mcp",tokenAuthMethod:"body",usePKCE:!0},systemSpecificInstructions:"Fathom is a brain context source (meetings) backed by remote MCP. Load the meetings skill before using it. Keep the MCP endpoint unchanged. Authentication uses OAuth dynamic client registration with PKCE. Store the registered client configuration on the shared System and tokens in the current user's credential. Discover the current read tools before use, search narrowly, and retrieve transcript content only when relevant. Never join, record, edit, or otherwise mutate meetings through this integration. Use the separate Fathom API template only when deterministic REST access is required.",keywords:["meetings","notes","transcripts","summaries","action_items","attendees","recordings","decisions"]},granolaMcp:{name:"granolaMcp",label:"Granola",apiUrl:"https://mcp.granola.ai/mcp",regex:"^https://mcp\\.granola\\.ai/mcp/?(?:\\?.*)?$",icon:"/logos/granola.svg",docsUrl:"https://docs.granola.ai/help-center/sharing/integrations/mcp",preferredAuthType:"oauth2",oauth:{authUrl:"https://mcp-auth.granola.ai/oauth2/authorize",tokenUrl:"https://mcp-auth.granola.ai/oauth2/token",registrationUrl:"https://mcp-auth.granola.ai/oauth2/register",scopes:"mcp",resource:"https://mcp.granola.ai/mcp",tokenAuthMethod:"body",usePKCE:!0},systemSpecificInstructions:"Granola is a brain context source (meetings) backed by remote MCP. Load the meetings skill before using it. Keep the MCP endpoint unchanged. Authentication uses OAuth dynamic client registration with PKCE. Store the registered client configuration on the shared System and tokens in the current user's credential. Search narrowly and retrieve transcript content only when relevant. Never edit meeting data through this integration.",keywords:["meetings","notes","transcripts","summaries","action_items","attendees","folders","decisions"]},readAiMcp:{name:"readAiMcp",label:"Read AI",apiUrl:"https://api.read.ai/mcp",regex:"^https://api\\.read\\.ai/mcp/?(?:\\?.*)?$",icon:"/logos/readai.png",docsUrl:"https://support.read.ai/hc/en-us/articles/49381158409491-MCP-Server",preferredAuthType:"oauth2",oauth:{authUrl:"https://authn.read.ai/oauth2/auth",tokenUrl:"https://authn.read.ai/oauth2/token",registrationUrl:"https://api.read.ai/oauth/register",scopes:"mcp:execute meeting:read offline_access",resource:"https://api.read.ai/mcp",tokenAuthMethod:"body",usePKCE:!0},systemSpecificInstructions:"Read AI is a brain context source (meetings) backed by remote MCP. Load the meetings skill before using it. Keep the MCP endpoint unchanged. Authentication uses OAuth dynamic client registration with PKCE. Store the registered client configuration on the shared System and tokens in the current user's credential. Request read-only scopes only. Discover the current tools before use, search narrowly, and retrieve transcript content only when relevant. Never join, record, edit, or otherwise mutate meetings through this integration.",keywords:["meetings","transcripts","summaries","action_items","topics","participants","metrics"]},googleDrive:{name:"googleDrive",label:"Google Drive",apiUrl:"https://www.googleapis.com/drive/v3",regex:"^.*(googleapis\\.com/drive|developers\\.google\\.com/drive|drive\\.google).*$",icon:"googledrive",docsUrl:"https://developers.google.com/drive/api/v3/reference",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/drive/v3/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/drive.readonly"},keywords:["files","folders","permissions","sharing","comments","revisions","changes","uploads","downloads","metadata","teamdrives","export","copy","move","oauth"],systemSpecificInstructions:"Use Drive API v3. Export Google Workspace files and use media download for stored files."},googleCalendar:{name:"googleCalendar",apiUrl:"https://www.googleapis.com/calendar/v3",regex:"^.*(googleapis\\.com/calendar|developers\\.google\\.com/calendar|calendar\\.google).*$",icon:"googlecalendar",docsUrl:"https://developers.google.com/calendar/api/v3/reference",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.settings.readonly",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Calendar; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days.",keywords:["events","calendars","attendees","reminders","recurring","availability","free busy","settings","acl","colors","notifications","timezone","quick add","oauth"]},googleSheets:{name:"googleSheets",apiUrl:"https://sheets.googleapis.com/v4",regex:"^.*(sheets\\.googleapis|developers\\.google\\.com/sheets|sheets\\.google).*$",icon:"googlesheets",docsUrl:"https://developers.google.com/sheets/api/reference/rest",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/sheets/v4/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive.file",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Sheets; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. The drive.file scope only lists files created or opened through this app; open any existing spreadsheet directly by its ID with the spreadsheets scope.",keywords:["spreadsheets","sheets","cells","ranges","values","formulas","formatting","charts","pivot tables","named ranges","protected ranges","batch update","append","oauth"]},googleDocs:{name:"googleDocs",label:"Google Docs",apiUrl:"https://docs.googleapis.com/v1",regex:"^.*(docs\\.googleapis|developers\\.google\\.com/docs|docs\\.google\\.com/document).*$",icon:"googledocs",docsUrl:"https://developers.google.com/docs/api/reference/rest",openApiUrl:"https://docs.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/documents https://www.googleapis.com/auth/drive.file",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Docs; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. Create a document with POST /documents and edit it with POST /documents/{documentId}:batchUpdate.",keywords:["documents","docs","text","paragraphs","headings","tables","images","batch update","insert text","replace text","named ranges","oauth"]},googleSlides:{name:"googleSlides",label:"Google Slides",apiUrl:"https://slides.googleapis.com/v1",regex:"^.*(slides\\.googleapis|developers\\.google\\.com/slides|docs\\.google\\.com/presentation).*$",icon:"googleslides",docsUrl:"https://developers.google.com/slides/api/reference/rest",openApiUrl:"https://slides.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/presentations https://www.googleapis.com/auth/drive.file",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Slides; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. Create a presentation with POST /presentations and edit it with POST /presentations/{presentationId}:batchUpdate.",keywords:["presentations","slides","decks","shapes","text boxes","images","layouts","batch update","thumbnails","oauth"]},googleForms:{name:"googleForms",label:"Google Forms",apiUrl:"https://forms.googleapis.com/v1",regex:"^.*(forms\\.googleapis|developers\\.google\\.com/forms|docs\\.google\\.com/forms).*$",icon:"googleforms",docsUrl:"https://developers.google.com/forms/api/reference/rest",openApiUrl:"https://forms.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/forms.body https://www.googleapis.com/auth/forms.responses.readonly https://www.googleapis.com/auth/drive.file",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Forms; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. Create a form with POST /forms (title only), add questions with POST /forms/{formId}:batchUpdate, and read submissions with GET /forms/{formId}/responses.",keywords:["forms","questions","responses","submissions","surveys","quizzes","batch update","items","oauth"]},googleContacts:{name:"googleContacts",label:"Google Contacts",apiUrl:"https://people.googleapis.com/v1",regex:"^.*(people\\.googleapis|developers\\.google\\.com/people|contacts\\.google\\.com).*$",icon:"/logos/google.svg",docsUrl:"https://developers.google.com/people/api/rest",openApiUrl:"https://people.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/contacts https://www.googleapis.com/auth/contacts.other.readonly https://www.googleapis.com/auth/directory.readonly",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Contacts; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. Use /people/me/connections and /people:createContact for saved contacts, /otherContacts for automatically saved contacts, and /people:searchDirectoryPeople for the Google Workspace directory (requires a Workspace account). Every request needs personFields or readMask.",keywords:["contacts","people","directory","other contacts","connections","emails","phone numbers","organizations","search","oauth"]},googleTasks:{name:"googleTasks",label:"Google Tasks",apiUrl:"https://tasks.googleapis.com/tasks/v1",regex:"^.*(tasks\\.googleapis|developers\\.google\\.com/(workspace/)?tasks|tasks\\.google\\.com).*$",icon:"googletasks",docsUrl:"https://developers.google.com/tasks/reference/rest",openApiUrl:"https://tasks.googleapis.com/$discovery/rest?version=v1",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/tasks",client_id:"259630754271-3uj914ocithh7mh56v61nr85a1rqevcu.apps.googleusercontent.com"},systemSpecificInstructions:"superglue provides a managed Google OAuth app for Google Tasks; users connect with their Google login and never need to create a Google Cloud project or supply a client ID or secret. Send OAuth tokens as Authorization: Bearer <<access_token>>. While the app is in Testing, only listed test users can connect and refresh tokens expire after seven days. List task lists with GET /users/@me/lists and create tasks with POST /lists/{tasklist}/tasks.",keywords:["tasks","task lists","to-do","due dates","completed","subtasks","oauth"]},googleAnalytics:{name:"googleAnalytics",apiUrl:"https://analytics.google.com",regex:"^.*(analytics|analyticsdata).*$",icon:"googleAnalytics",docsUrl:"https://developers.google.com/analytics/devguides/reporting/data/v1",openApiUrl:"https://analyticsdata.googleapis.com/$discovery/rest?version=v1beta",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/analytics.edit"},keywords:["properties","dimensions","metrics","reports","audiences","conversions","events","goals","segments","real time","user activity","attribution","funnels","cohorts","oauth"]},youtube:{name:"youtube",apiUrl:"https://youtube.googleapis.com",regex:"^.*youtube.*$",icon:"youtube",docsUrl:"https://developers.google.com/youtube/v3/docs",openApiUrl:"https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/youtube"},keywords:["videos","channels","playlists","comments","captions","live streams","analytics","thumbnails","subscriptions","activities","ratings","uploads","members","oauth"]},AWS:{name:"AWS",apiUrl:"https://amazonaws.com",regex:"^.*(aws|amazonaws).*$",icon:"/logos/aws.svg",docsUrl:"https://docs.aws.amazon.com/index.html",preferredAuthType:"api_key",keywords:["ec2","s3","lambda","rds","dynamodb","sqs","sns","cloudformation","iam","cloudwatch","vpc","instances","buckets","functions","api key"]},amazon_sp_api:{name:"amazon_sp_api",apiUrl:"https://sellingpartnerapi-na.amazon.com",regex:"^.*(sellingpartnerapi[-\\w]*\\.amazon\\.com).*$",icon:"/logos/amazon.svg",docsUrl:"https://developer-docs.amazon.com/sp-api/docs",preferredAuthType:"oauth2",oauth:{authUrl:"https://sellercentral.amazon.com/apps/authorize/consent",tokenUrl:"https://api.amazon.com/auth/o2/token",grant_type:"authorization_code",tokenAuthMethod:"body",tokenContentType:"form"},keywords:["orders","catalog items","listings","feeds","reports","fba inbound","fulfillment","inventory","pricing","seller central","marketplace"],systemSpecificInstructions:`Base host is region-specific: sellingpartnerapi-na.amazon.com (US/CA/MX/BR), sellingpartnerapi-eu.amazon.com (EU/UK/IN/ME/AF), sellingpartnerapi-fe.amazon.com (Singapore/AU/JP) \u2014 swap the region segment to match the seller's marketplace; sandbox testing uses sandbox.sellingpartnerapi-<region>.amazon.com. Requires registering an app in Seller Central > Develop Apps first. Third-party apps redirect sellers to https://sellercentral.amazon.com/apps/authorize/consent?application_id=<APP_ID>&state=<STATE> (add &version=beta only while the app is in Draft state, remove once Published); private/single-account developers can skip this by generating a refresh token directly via Seller Central > Develop Apps > "Authorize new developer" (self-authorization). Access tokens require header x-amz-access-token in addition to Authorization; some operations (e.g. FBA/notifications) use a separate grantless client_credentials flow instead of the refresh-token flow.`},googleCloud:{name:"googleCloud",apiUrl:"https://cloud.google.com",regex:"^.*(cloud\\.google|gcp|googlecloud).*$",icon:"googleCloud",docsUrl:"https://cloud.google.com/apis/docs/overview",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/cloud-platform"},keywords:["compute","storage","pubsub","cloud run","kubernetes","iam","vpc","cloud sql","bigtable","dataflow","logging","monitoring","oauth"]},bigquery:{name:"bigquery",apiUrl:"https://bigquery.googleapis.com/bigquery/v2",regex:"^.*(bigquery|bq\\.googleapis).*$",icon:"googleCloud",docsUrl:"https://cloud.google.com/bigquery/docs/reference/rest",openApiUrl:"https://bigquery.googleapis.com/$discovery/rest?version=v2",preferredAuthType:"oauth2",oauth:{authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:"https://www.googleapis.com/auth/bigquery"},systemSpecificInstructions:`BigQuery REST API - Authentication Options:
638
638
 
639
639
  OPTION 1: OAuth App (Recommended)
640
640
  If the user has or creates an OAuth app in their Google Cloud project:
@@ -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.99",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.101",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.99",
3
+ "version": "1.1.101",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },