@superglue/cli 1.1.192 → 1.1.193
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/cli.js +2 -2
- package/package.json +1 -1
|
@@ -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.
|
|
4
|
+
"version": "1.1.193",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "superglue",
|
|
7
7
|
"email": "hello@superglue.cloud"
|
package/dist/cli.js
CHANGED
|
@@ -247,7 +247,7 @@ window.addEventListener("load",schedule);
|
|
|
247
247
|
<p style="margin:0 0 24px 0;font-size:14px;line-height:1.6;color:#5a5a5a;text-align:center;">${o}</p>
|
|
248
248
|
${s}
|
|
249
249
|
${a}
|
|
250
|
-
<p style="margin:0;font-size:13px;line-height:1.5;color:#8a8a8a;text-align:center;">You receive this because someone shared access with you on superglue.</p>`})}});var gL=m(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.AGENT_CRON_WEEKDAY_NAMES=Ke.AGENT_CRON_FREQUENCIES=Ke.AGENT_CRON_INSTRUCTIONS_MAX_CHARS=Ke.BRIEFING_ACTIONS_METADATA_KEY=Ke.BRIEFING_ACTION_LIMITS=Ke.AGENT_CRON_KINDS=void 0;Ke.isAgentCronKind=the;Ke.listAvailableAgentCronKinds=nhe;Ke.readBriefingActions=ohe;Ke.isAgentCronTime=fL;Ke.isAgentCronWeekday=hL;Ke.describeAgentCronSchedule=che;Ke.parseAgentCronUpdate=lhe;var ehe=kd();Ke.AGENT_CRON_KINDS=["daily-briefing","memory-reflection"];function the(t){return typeof t=="string"&&Ke.AGENT_CRON_KINDS.includes(t)}var rhe={"daily-briefing":t=>t.briefings,"memory-reflection":()=>!0};function nhe(t){return Ke.AGENT_CRON_KINDS.filter(e=>rhe[e](t))}Ke.BRIEFING_ACTION_LIMITS={maxActions:
|
|
250
|
+
<p style="margin:0;font-size:13px;line-height:1.5;color:#8a8a8a;text-align:center;">You receive this because someone shared access with you on superglue.</p>`})}});var gL=m(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.AGENT_CRON_WEEKDAY_NAMES=Ke.AGENT_CRON_FREQUENCIES=Ke.AGENT_CRON_INSTRUCTIONS_MAX_CHARS=Ke.BRIEFING_ACTIONS_METADATA_KEY=Ke.BRIEFING_ACTION_LIMITS=Ke.AGENT_CRON_KINDS=void 0;Ke.isAgentCronKind=the;Ke.listAvailableAgentCronKinds=nhe;Ke.readBriefingActions=ohe;Ke.isAgentCronTime=fL;Ke.isAgentCronWeekday=hL;Ke.describeAgentCronSchedule=che;Ke.parseAgentCronUpdate=lhe;var ehe=kd();Ke.AGENT_CRON_KINDS=["daily-briefing","memory-reflection"];function the(t){return typeof t=="string"&&Ke.AGENT_CRON_KINDS.includes(t)}var rhe={"daily-briefing":t=>t.briefings,"memory-reflection":()=>!0};function nhe(t){return Ke.AGENT_CRON_KINDS.filter(e=>rhe[e](t))}Ke.BRIEFING_ACTION_LIMITS={maxActions:20,title:80,description:160,prompt:2e3};Ke.BRIEFING_ACTIONS_METADATA_KEY="briefingActions";function ihe(t){if(!t||typeof t!="object")return!1;let{title:e,description:r,prompt:n}=t;return typeof e=="string"&&typeof r=="string"&&typeof n=="string"}function ohe(t){let e=t[Ke.BRIEFING_ACTIONS_METADATA_KEY];return Array.isArray(e)?e.filter(ihe):[]}var she=/^([01]\d|2[0-3]):[0-5]\d$/;function fL(t){return typeof t=="string"&&she.test(t)}Ke.AGENT_CRON_INSTRUCTIONS_MAX_CHARS=2e3;Ke.AGENT_CRON_FREQUENCIES=["weekdays","weekly"];Ke.AGENT_CRON_WEEKDAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function hL(t){return Number.isInteger(t)&&t>=0&&t<=6}var ahe={weekdays:"Weekdays",daily:"Daily"};function che(t){return`${t.frequency==="weekly"?`${Ke.AGENT_CRON_WEEKDAY_NAMES[t.weekday]}s`:ahe[t.frequency]} at ${t.time} ${t.timezone.replace(/_/g," ")}`}function uhe(t,e){return t===void 0?e===void 0?{}:{error:'weekday requires frequency "weekly"; pass both together'}:t==="weekdays"?e===void 0?{cadence:{frequency:t}}:{error:'weekday applies only to frequency "weekly"'}:t==="weekly"?hL(e)?{cadence:{frequency:t,weekday:e}}:{error:'frequency "weekly" requires weekday as an integer from 0 (Sunday) to 6 (Saturday)'}:{error:`frequency must be one of ${Ke.AGENT_CRON_FREQUENCIES.join(", ")}`}}function lhe(t){let{enabled:e,time:r,timezone:n,instructions:i,frequency:o,weekday:s}=t,a=uhe(o,s);if("error"in a)return a;let c={...a.cadence};if(e!==void 0){if(typeof e!="boolean")return{error:"enabled must be a boolean"};c.enabled=e}if(r!==void 0){if(!fL(r))return{error:"time must use HH:MM in 24-hour format"};c.time=r}if(n!==void 0){if(typeof n!="string"||!(0,ehe.isValidTimezone)(n))return{error:"timezone must be a valid IANA timezone name, e.g. Europe/Berlin"};c.timezone=n}if(i===null)c.instructions=null;else if(i!==void 0){if(typeof i!="string")return{error:"instructions must be a string or null"};if(i.length>Ke.AGENT_CRON_INSTRUCTIONS_MAX_CHARS)return{error:`instructions must be at most ${Ke.AGENT_CRON_INSTRUCTIONS_MAX_CHARS} characters`};c.instructions=i}return Object.keys(c).length===0?{error:"Provide enabled, frequency, weekday, time, timezone, or instructions"}:{update:c}}});var zd=m(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.SUPERGLUE_HEADING_CSS=Qs.SUPERGLUE_DESIGN=void 0;Qs.superglueFontStack=dhe;Qs.SUPERGLUE_DESIGN={colors:{background:"#ffffff",surface:"#fafafa",text:"#18191b",mutedText:"#5f646d",border:"#e4e5e7",primary:"#1c1e21",onPrimary:"#ffffff",accent:"#0080ff",link:"#0080ff",success:"#25935f",warning:"#c17c15",danger:"#b23434"},shades:{surface2:"#f4f5f6",ink3:"#848a94",line2:"#ecedee",input:"#c8cbd0",primaryHover:"#3b3e44",ring:"#2f3237"},chart:["#0080ff","#22c3c3","#a542d7","#e2368c","#28bd73","#f2a93b","#6b7280","#0f766e"],fonts:{heading:{family:"Crimson Text",fallback:'Georgia, "Times New Roman", serif'},body:{family:"Inter",fallback:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif'},mono:{family:"JetBrains Mono",fallback:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"}},radius:8};Qs.SUPERGLUE_HEADING_CSS="h1,h2,h3,h4,h5,h6{font-family:var(--sg-font-heading)}h1,h2{font-weight:400;letter-spacing:-.02em}h3,h4,h5,h6{font-weight:600;letter-spacing:-.01em}";function dhe(t){let e=Qs.SUPERGLUE_DESIGN.fonts[t];return`"${e.family}", ${e.fallback}`}});var mL=m(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.HTML_ARTIFACT_PERMISSIONS_POLICY=_n.PORTABLE_HTML_ARTIFACT_VERSION=void 0;_n.escapeText=Gb;_n.escapeAttribute=pu;_n.buildPortableHtmlArtifactDocument=ghe;var Ahe=zd(),phe=wn();_n.PORTABLE_HTML_ARTIFACT_VERSION=2;var fhe=["accelerometer","all-screens-capture","ambient-light-sensor","attribution-reporting","autoplay","battery","bluetooth","browsing-topics","camera","captured-surface-control","clipboard-read","clipboard-write","compute-pressure","deferred-fetch","digital-credentials-create","digital-credentials-get","direct-sockets","display-capture","encrypted-media","execution-while-not-rendered","execution-while-out-of-viewport","focus-without-user-activation","fullscreen","gamepad","geolocation","gyroscope","hid","identity-credentials-get","idle-detection","join-ad-interest-group","keyboard-map","language-detector","language-model","local-fonts","magnetometer","microphone","midi","navigation-override","otp-credentials","payment","picture-in-picture","publickey-credentials-get","run-ad-auction","screen-wake-lock","serial","smart-card","speaker-selection","storage-access","sync-xhr","tools","translator","usb","web-share","window-management","xr-spatial-tracking"];_n.HTML_ARTIFACT_PERMISSIONS_POLICY=fhe.map(t=>`${t} 'none'`).join("; ");var hhe=["default-src 'none'","script-src 'unsafe-inline'","style-src 'unsafe-inline'","img-src data:","font-src data:","frame-src 'self'","child-src 'self'","base-uri 'none'","form-action 'none'"].join("; ");function Gb(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function pu(t){return Gb(t).replace(/"/g,""")}function ghe({artifact:t,initialData:e={}}){let n=`<script>(()=>{const frame=document.querySelector("iframe");const data=${(0,phe.safeStringify)(e,0).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.addEventListener("message",event=>{if(event.source===frame.contentWindow&&event.data&&event.data.source==="superglue-artifact"&&event.data.type==="ready"){frame.contentWindow.postMessage({source:"superglue-artifact-host",type:"init",data},"*")}})})();</script>`;return`<!doctype html><html lang="en" data-superglue-artifact-wrapper="${_n.PORTABLE_HTML_ARTIFACT_VERSION}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><meta name="superglue-artifact-wrapper" content="${_n.PORTABLE_HTML_ARTIFACT_VERSION}"><meta name="superglue-artifact-id" content="${pu(t.id)}"><meta name="superglue-artifact-content-hash" content="${pu(t.contentHash)}"><meta http-equiv="Content-Security-Policy" content="${hhe}"><title>${Gb(t.title)}</title><style>html,body{width:100%;height:100%;margin:0;overflow:hidden;background:${Ahe.SUPERGLUE_DESIGN.colors.surface}}body{display:flex;flex-direction:column}iframe{display:block;flex:1;width:100%;border:0;background:#fff}</style></head><body><iframe title="${pu(t.title)}" srcdoc="${pu(t.html)}" sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox" allow="${pu(_n.HTML_ARTIFACT_PERMISSIONS_POLICY)}" referrerpolicy="no-referrer"></iframe>${n}</body></html>`}});var yL=m(Sg=>{"use strict";Object.defineProperty(Sg,"__esModule",{value:!0});Sg.HTML_ARTIFACT_BRIDGE_SOURCE=void 0;Sg.HTML_ARTIFACT_BRIDGE_SOURCE=String.raw`(() => {
|
|
251
251
|
const HOST_SOURCE = "superglue-artifact-host";
|
|
252
252
|
const ARTIFACT_SOURCE = "superglue-artifact";
|
|
253
253
|
const FIELD_SELECTOR = "input[name],select[name],textarea[name]";
|
|
@@ -1856,7 +1856,7 @@ ${s}`;return}if(Gy(e,i,QNe)){_Ne(e,o)&&(r.retry=e.toString("utf8",o));return}if(
|
|
|
1856
1856
|
`);t.stack=r?`${r}
|
|
1857
1857
|
${o}`:i.stack}Z.exports.fetch=function(e,r=void 0){return sOe(e,r).catch(n=>{throw TY?OY(n,TY):n&&typeof n=="object"&&Error.captureStackTrace(n,Z.exports.fetch),n})};Z.exports.Headers=yc().Headers;Z.exports.Response=JA().Response;Z.exports.Request=Ku().Request;Z.exports.FormData=hm().FormData;var{setGlobalOrigin:aOe,getGlobalOrigin:cOe}=Ow();Z.exports.setGlobalOrigin=aOe;Z.exports.getGlobalOrigin=cOe;var{CacheStorage:uOe}=yG(),{kConstruct:lOe}=Ge();Z.exports.caches=new uOe(lOe);var{deleteCookie:dOe,getCookies:AOe,getSetCookies:pOe,setCookie:fOe,parseCookie:hOe}=TG();Z.exports.deleteCookie=dOe;Z.exports.getCookies=AOe;Z.exports.getSetCookies=pOe;Z.exports.setCookie=fOe;Z.exports.parseCookie=hOe;var{parseMIMEType:gOe,serializeAMimeType:mOe}=Tn();Z.exports.parseMIMEType=gOe;Z.exports.serializeAMimeType=mOe;var{CloseEvent:yOe,ErrorEvent:EOe,MessageEvent:IOe}=Oy(),{WebSocket:COe,ping:bOe}=uY();Z.exports.WebSocket=COe;Z.exports.CloseEvent=yOe;Z.exports.ErrorEvent=EOe;Z.exports.MessageEvent=IOe;Z.exports.ping=bOe;Z.exports.WebSocketStream=mY().WebSocketStream;Z.exports.WebSocketError=fv().WebSocketError;Z.exports.request=ap(ll.request);Z.exports.stream=ap(ll.stream);Z.exports.pipeline=ap(ll.pipeline);Z.exports.connect=ap(ll.connect);Z.exports.upgrade=ap(ll.upgrade);Z.exports.MockClient=VNe;Z.exports.MockCallHistory=JNe;Z.exports.MockCallHistoryLog=WNe;Z.exports.MockPool=KNe;Z.exports.MockAgent=ZNe;Z.exports.SnapshotAgent=XNe;Z.exports.mockErrors=eOe;var{EventSource:SOe}=DY();Z.exports.EventSource=SOe;function wOe(){globalThis.fetch=Z.exports.fetch,globalThis.Headers=Z.exports.Headers,globalThis.Response=Z.exports.Response,globalThis.Request=Z.exports.Request,globalThis.FormData=Z.exports.FormData,globalThis.WebSocket=Z.exports.WebSocket,globalThis.CloseEvent=Z.exports.CloseEvent,globalThis.ErrorEvent=Z.exports.ErrorEvent,globalThis.MessageEvent=Z.exports.MessageEvent,globalThis.EventSource=Z.exports.EventSource}Z.exports.install=wOe});var xY=m(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});Al.SuperglueClient=Al.SuperglueHttpError=void 0;var dl=yr(),Pn=Hb(),BOe=TS(),QOe=VP(),_Oe=wn(),is=su(),vOe=kd(),up=14400*1e3,cp;if(typeof globalThis.process<"u"&&globalThis.process.versions?.node)try{let{Agent:t}=UY();cp=new t({headersTimeout:up,bodyTimeout:up})}catch{}function MY(t){if(t?.aborted)throw t.reason??new DOMException("Aborted","AbortError")}var Jy=class extends Error{constructor(e,r,n,i){super(e),this.status=r,this.code=n,this.details=i,this.name="SuperglueHttpError"}};Al.SuperglueHttpError=Jy;var Iv=class{constructor({apiKey:e,apiEndpoint:r,onInfrastructureError:n,refreshToken:i,sseTokenProvider:o,tokenProvider:s}){if(!e&&!s)throw new Error("SuperglueClient requires either apiKey or tokenProvider");this.tokenProvider=s??(async()=>e),this.apiEndpoint=r??"https://api.superglue.cloud",this.sseManager=new BOe.SSELogSubscriptionManager(this.apiEndpoint,o??this.tokenProvider,i),this.onInfrastructureError=n,this.refreshToken=i}async getApiKey(){return this.tokenProvider()}async fetchWithAuthRetry(e,r){let n=await this.getApiKey(),i=await e(n);if(i.status!==401||!this.refreshToken)return i;MY(r);let o=await this.refreshToken();return MY(r),!o||o===n?i:(i.body?.cancel(),e(o))}isInfrastructureError(e){return(0,_Oe.isAbortError)(e)?!1:!!(e instanceof TypeError&&e.message.toLowerCase().includes("fetch")||e instanceof Error&&e.name==="TimeoutError")}async restRequest(e,r,n,i,o){let a=await(await this.restResponse({method:e,path:r,body:n,extraHeaders:i,requestInit:o})).text();if(a)return JSON.parse(a)}async restResponse({method:e,path:r,body:n,extraHeaders:i,requestInit:o}){let s=`${this.apiEndpoint.replace(/\/$/,"")}${r}`,a=n!=null,c=typeof FormData<"u"&&n instanceof FormData,u=d=>{let A={Authorization:`Bearer ${d}`,...i};return a&&!c&&e!=="GET"&&(A["Content-Type"]="application/json"),fetch(s,{...o,method:e,headers:A,body:a?c?n:JSON.stringify(n):void 0,signal:o?.signal??AbortSignal.timeout(up),...cp?{dispatcher:cp}:{}})},l;try{l=await this.fetchWithAuthRetry(u,o?.signal)}catch(d){throw this.isInfrastructureError(d)&&this.onInfrastructureError?.(),d}if(!l.ok)throw await this.buildHttpError(l);return l}async uploadFiles(e,r){if(typeof r?.process!="boolean")throw new Error("process must be a boolean");if(e.length===0)return[];let n=e.map(l=>({...l,contentLength:l.contentLength??this.getUploadContentLength(l.content)})),o=(await this.restRequest("POST","/v1/files/uploads",{process:r.process,...r.allowUnprocessed?{allowUnprocessed:!0}:{},files:n.map(({fileName:l,contentType:d,contentLength:A})=>({fileName:l,contentLength:A,...d?{contentType:d}:{}}))})).data.files;if(o.length!==n.length)throw await Promise.all(o.map(l=>this.deleteFileUpload(l.id).catch(()=>{}))),new Error("Upload response did not match the selected files");let s=await Promise.allSettled(o.map(async(l,d)=>{let A=n[d],p=await fetch(l.uploadUrl,{method:"PUT",body:A.content,headers:A.contentType?{"Content-Type":A.contentType}:void 0,signal:AbortSignal.timeout(Math.min(up,l.expiresIn*1e3))});if(!p.ok)throw new Error(`Upload failed for ${A.fileName}: ${p.status} ${p.statusText}`);return l.id})),a=s.flatMap(l=>l.status==="fulfilled"?[l.value]:[]),c=new Map;if(a.length>0)try{let l=await this.restRequest("POST","/v1/files/uploads/complete",{fileIds:a});c=new Map(l.data.files.map(d=>[d.id,d]))}catch(l){c=new Map(a.map(d=>[d,{id:d,fileName:n[o.findIndex(A=>A.id===d)]?.fileName||d,contentLength:n[o.findIndex(A=>A.id===d)]?.contentLength||0,status:"failed",error:l instanceof Error?l.message:String(l)}]))}let u=o.map((l,d)=>{let A=s[d],p=n[d];return A.status==="rejected"?{id:l.id,fileName:p.fileName,contentLength:p.contentLength,status:"failed",error:A.reason instanceof Error?A.reason.message:String(A.reason)}:c.get(l.id)||{id:l.id,fileName:p.fileName,contentLength:p.contentLength,status:"failed",error:"Upload completion returned no result"}});return await Promise.all(u.filter(l=>l.status==="failed").map(l=>this.deleteFileUpload(l.id).catch(()=>{}))),u}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 r=await e.text(),n=`HTTP ${e.status}: ${r}`,i,o;try{let s=JSON.parse(r);s&&typeof s=="object"&&!Array.isArray(s)&&(o=s),typeof s?.code=="string"&&(i=s.code);let a=s.error;typeof a=="string"?n=a:a&&typeof a=="object"&&(n=a.message||JSON.stringify(a))}catch{}return new Jy(n,e.status,i,o)}async streamRequest(e,r,n){let i=e.includes("?")?"&":"?",o=`${this.apiEndpoint.replace(/\/$/,"")}${e}${i}stream=true`,s=u=>fetch(o,{method:"POST",headers:{Authorization:`Bearer ${u}`,Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify(r),signal:n??AbortSignal.timeout(up),...cp?{dispatcher:cp}:{}}),a;try{a=await this.fetchWithAuthRetry(s,n)}catch(u){throw this.isInfrastructureError(u)&&this.onInfrastructureError?.(),u}if(!a.ok)throw await this.buildHttpError(a);if(!(a.headers.get("content-type")||"").includes("text/event-stream")){let u=await a.text();return u?JSON.parse(u):void 0}try{return await(0,QOe.consumeEventStreamResult)(a)}catch(u){throw this.isInfrastructureError(u)&&this.onInfrastructureError?.(),u}}async subscribeToLogsSSE(e={}){return this.sseManager.subscribeToLogs(e)}async disconnect(){await this.sseManager.disconnect()}async listMemoryNotes(e={}){let r=new URLSearchParams;e.scope&&r.set("scope",e.scope),e.query&&r.set("query",e.query);let n=r.toString();return(await this.restRequest("GET",`/v1/memory-notes${n?`?${n}`:""}`)).data}async createMemoryNote(e){return(await this.restRequest("POST","/v1/memory-notes",e)).data}async updateMemoryNote(e,r){return(await this.restRequest("PATCH",`/v1/memory-notes/${encodeURIComponent(e)}`,r)).data}async deleteMemoryNote(e){await this.restRequest("DELETE",`/v1/memory-notes/${encodeURIComponent(e)}`)}async clearMemoryNotes(e){return(await this.restRequest("DELETE",`/v1/memory-notes?scope=${e}`)).data.deleted}async getMe(){return this.restRequest("GET","/v1/me")}async completeOnboarding(){return this.restRequest("POST","/v1/me/onboarding/complete")}async runTool(e){let r=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:r.status==="success",data:r.data,error:r.error,tool:r.tool,stepResults:r.stepResults?.map(n=>({...n}))||[],...r.fileArtifacts&&r.fileArtifacts.length>0?{fileArtifacts:r.fileArtifacts}:{},...r.metadata?.warnings?.length?{warnings:r.metadata.warnings}:{}}}async runToolConfig(e){let r=e.createRun?"/v1/tools/run?createRun=true":"/v1/tools/run",n=await this.restRequest("POST",r,{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:n.status?n.status==="success":n.success??!1,data:n.data,error:n.error,tool:n.tool||e.tool,stepResults:n.stepResults?.map(o=>({...o}))||[],...n.fileArtifacts&&n.fileArtifacts.length>0?{fileArtifacts:n.fileArtifacts}:{},...n.metadata?.warnings?.length?{warnings:n.metadata.warnings}:{}}}async abortToolExecution(e){return{success:!0,runId:(await this.restRequest("POST",`/v1/runs/${encodeURIComponent(e)}/cancel`)).runId}}async executeStep({step:e,payload:r,files:n,previousResults:i,credentials:o,options:s,runId:a,systemIds:c,credentialId:u,systemAuth:l,createRun:d,parentToolId:A,stepIndex:p,stepId:h,signal:g,stream:S}){let B={step:e,payload:r,files:n,previousResults:i,credentials:o,options:s,runId:a,systemIds:c,credentialId:u,systemAuth:l,createRun:d,parentToolId:A,stepIndex:p,stepId:h};return S?this.streamRequest("/v1/tools/step/run",B,g):this.restRequest("POST","/v1/tools/step/run",B,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:r,inputSchema:n,payload:i,files:o,stepResults:s,options:a,runId:c,createRun:u,parentToolId:l,stepId:d,signal:A,stream:p}){let h={outputTransform:e,outputSchema:r,inputSchema:n,payload:i,files:o,stepResults:s,options:a,runId:c,createRun:u,parentToolId:l,stepId:d};return p?this.streamRequest("/v1/tools/transform/run",h,A):this.restRequest("POST","/v1/tools/transform/run",h,void 0,A?{signal:A}:void 0)}async createRun({toolId:e,toolConfig:r,toolResult:n,stepResults:i,toolPayload:o,status:s,error:a,startedAt:c,completedAt:u,executionKind:l,parentToolId:d,draftId:A}){return this.restRequest("POST","/v1/runs",{toolId:e,toolConfig:r,toolResult:n,stepResults:i,toolPayload:o,status:s,error:a,startedAt:(0,is.toUTCISOString)(c,"run.startedAt"),completedAt:(0,is.toUTCISOString)(u,"run.completedAt"),executionKind:l,parentToolId:d,draftId:A})}async checkRunLimit(){return(await this.restRequest("POST","/v1/runs/check-limit")).data}async extract({file:e,envelope:r}){if(!e)throw new Error("File must be provided for extract.");let n=new FormData;n.append("file",e);let i=r?"/v1/extract?envelope=true":"/v1/extract";return this.restRequest("POST",i,n)}mapOpenAPIRunToRun(e){let r={running:dl.RunStatus.RUNNING,success:dl.RunStatus.SUCCESS,failed:dl.RunStatus.FAILED,aborted:dl.RunStatus.ABORTED};return{runId:e.runId??e.id,toolId:e.toolId,tool:e.tool,systemIds:e.systemIds,status:r[e.status]??dl.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??dl.RunExecutionKind.FULL},fileArtifacts:e.fileArtifacts}}mapOpenAPIScheduleToToolSchedule(e){return{...e,lastRunAt:e.lastRunAt?(0,is.requireUTCDate)(e.lastRunAt,"schedule.lastRunAt"):void 0,nextRunAt:(0,is.requireUTCDate)(e.nextRunAt,"schedule.nextRunAt"),createdAt:(0,is.requireUTCDate)(e.createdAt,"schedule.createdAt"),updatedAt:(0,is.requireUTCDate)(e.updatedAt,"schedule.updatedAt")}}async listRuns(e={}){let r=(0,Pn.createSearchListQueryParams)(e);e.toolId!==void 0&&r.set("toolId",e.toolId),e.searchUserIds?.length&&r.set("searchUserIds",e.searchUserIds.join(",")),e.includeTotal!==void 0&&r.set("includeTotal",String(e.includeTotal)),e.startedAfter!==void 0&&r.set("startedAfter",e.startedAfter instanceof Date?(0,is.toUTCISOString)(e.startedAfter,"run.startedAfter"):e.startedAfter),e.statuses!==void 0?r.set("status",e.statuses.join(",")):e.status!==void 0&&r.set("status",e.status),e.requestSources!==void 0&&r.set("requestSources",e.requestSources.join(",")),e.executionKinds!==void 0&&r.set("executionKinds",e.executionKinds.join(",")),e.userId!==void 0&&r.set("userId",e.userId),e.systemId!==void 0&&r.set("systemId",e.systemId),e.systemIds!==void 0&&r.set("systemIds",e.systemIds.join(","));let n=r.size>0?`?${r.toString()}`:"",i=await this.restRequest("GET",`/v1/runs${n}`,void 0,void 0,{signal:e.signal});return{data:i.data.map(o=>this.mapOpenAPIRunToRun(o)),total:i.total,page:i.page,limit:i.limit,hasMore:i.hasMore}}async getActivityCounts(e){let r=new URLSearchParams;e?.from&&r.set("from",e.from instanceof Date?(0,is.toUTCISOString)(e.from,"activity.from"):e.from),e?.to&&r.set("to",e.to instanceof Date?(0,is.toUTCISOString)(e.to,"activity.to"):e.to);let n=r.toString();return(await this.restRequest("GET",`/v1/activity/counts${n?`?${n}`:""}`,void 0,void 0,{signal:e?.signal})).counts}async getRun(e){try{let r=await this.restRequest("GET",`/v1/runs/${encodeURIComponent(e)}`);return this.mapOpenAPIRunToRun(r)}catch(r){if(r.message?.includes("404")||r.message?.includes("not found"))return null;throw r}}async getTool(e){try{return await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}`)}catch(r){if(r.message?.includes("404")||r.message?.includes("not found")||r.message?.includes("403")||r.message?.includes("not allowed"))return null;throw r}}async getToolState(e){return(await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/state`)).state}async setToolState(e,r){await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/state`,{state:r})}async deleteToolState(e){return(await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/state`)).deletedKeys}async archiveTool(e,r=!0){return this.updateTool(e,{archived:r})}async bulkArchiveTools(e,r=!0){return this.restRequest("POST","/v1/tools/bulk/archive",{ids:e,archived:r})}async bulkDeleteTools(e){return this.restRequest("POST","/v1/tools/bulk/delete",{ids:e})}async listTools(e={}){let r=(0,Pn.createListQueryParams)(e);e.includeArchived!==void 0&&r.set("includeArchived",String(e.includeArchived));let n=r.size>0?`?${r.toString()}`:"";return this.restRequest("GET",`/v1/tools${n}`)}async listAllTools(e={}){return(0,Pn.listAllPages)((r,n)=>this.listTools({...e,page:r,limit:n}))}async createTool(e,r){return this.restRequest("POST","/v1/tools",{...r,id:e})}async updateTool(e,r){return this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}`,r)}async deleteTool(e){try{return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}`),!0}catch(r){if(r.message?.includes("404"))return!1;throw r}}async renameTool(e,r){return this.restRequest("POST",`/v1/tools/${encodeURIComponent(e)}/rename`,{newId:r})}async getWorkflow(e){return this.getTool(e)}async archiveWorkflow(e,r=!0){return this.upsertWorkflow(e,{archived:r})}async createWorkflow(e,r){return this.createTool(e,r)}async updateWorkflow(e,r){return this.updateTool(e,r)}async upsertWorkflow(e,r){return await this.getTool(e)?this.updateTool(e,r):this.createTool(e,r)}async deleteWorkflow(e){return this.deleteTool(e)}async renameWorkflow(e,r){return this.renameTool(e,r)}async listProjectSummaries(e={}){let r=(0,Pn.createSearchListQueryParams)(e);return r.set("includeResources","false"),e.includeArchived!==void 0&&r.set("includeArchived",String(e.includeArchived)),this.restRequest("GET",`/v1/projects?${r.toString()}`)}async listAllProjectSummaries({includeArchived:e}={}){return(0,Pn.listAllPages)((r,n)=>this.listProjectSummaries({page:r,limit:n,...e!==void 0?{includeArchived:e}:{}}))}async listAllProjectTasks(e){return(0,Pn.listAllPages)((r,n)=>this.restRequest("GET",`/v1/projects/${encodeURIComponent(e)}/tasks?page=${r}&limit=${n}`))}async saveProjectTask({projectId:e,taskId:r,input:n}){let i=`/v1/projects/${encodeURIComponent(e)}/tasks${r?`/${encodeURIComponent(r)}`:""}`;return(await this.restRequest(r?"PATCH":"POST",i,n)).data}async listSchedules(e={}){let r=(0,Pn.createListQueryParams)(e),n=r.size>0?`?${r.toString()}`:"",i=e.toolId?`/v1/tools/${encodeURIComponent(e.toolId)}/schedules${n}`:`/v1/schedules${n}`,o=await this.restRequest("GET",i);return{...o,data:o.data.map(s=>this.mapOpenAPIScheduleToToolSchedule(s))}}async listAllSchedules(e={}){return(0,Pn.listAllPages)((r,n)=>this.listSchedules({...e,page:r,limit:n}))}async getToolSchedule(e,r){try{let n=await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(r)}`);return this.mapOpenAPIScheduleToToolSchedule(n)}catch(n){if(n.message?.includes("404")||n.message?.includes("not found"))return null;throw n}}async createToolSchedule(e,r){let n=await this.restRequest("POST",`/v1/tools/${encodeURIComponent(e)}/schedules`,{...r,timezone:r.timezone||(0,vOe.getRuntimeTimezone)()});return this.mapOpenAPIScheduleToToolSchedule(n)}async updateToolSchedule(e,r,n){let i=await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(r)}`,n);return this.mapOpenAPIScheduleToToolSchedule(i)}async deleteToolSchedule(e,r){return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(r)}`),!0}async bulkSetSchedulesEnabled(e,r){return this.restRequest("POST","/v1/schedules/bulk/enable",{ids:e,enabled:r})}async bulkDeleteSchedules(e){return this.restRequest("POST","/v1/schedules/bulk/delete",{ids:e})}async listCredentials(e={}){let r=(0,Pn.createListQueryParams)(e);e.systemId!==void 0&&r.set("systemId",e.systemId);let n=r.size>0?`?${r.toString()}`:"";return this.restRequest("GET",`/v1/credentials${n}`)}async listAllCredentials(e={}){return(0,Pn.listAllPages)((r,n)=>this.listCredentials({...e,page:r,limit:n}))}async createCredentials(e){return(await this.restRequest("POST","/v1/credentials",e)).data}async replaceCredentials(e,r){return(await this.restRequest("PUT",`/v1/credentials/${encodeURIComponent(e)}`,{credentials:r})).data}async updateCredentials(e,r){return(await this.restRequest("PATCH",`/v1/credentials/${encodeURIComponent(e)}`,r)).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 r=(0,Pn.createListQueryParams)(e),n=r.size>0?`?${r.toString()}`:"";return this.restRequest("GET",`/v1/systems${n}`)}async listAllSystems(e={}){return(0,Pn.listAllPages)((r,n)=>this.listSystems({...e,page:r,limit:n}))}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,r){return(await this.restRequest("PATCH",`/v1/systems/${encodeURIComponent(e)}`,r)).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 listManagedOAuthTemplateIds(){return(await this.restRequest("GET","/v1/oauth2/managed-apps")).data.templateIds}async createOAuthExchange(e){return(await this.restRequest("POST","/v1/oauth/exchanges",e)).data}async completeOAuthExchange(e,r){return(await this.restRequest("POST",`/v1/oauth/exchanges/${encodeURIComponent(e)}/complete`,r)).data}async searchSystemDocumentation(e,r){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/search`,{keywords:r})).data}async triggerSystemDocumentationScrapeJob(e,r){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/scrape`,r)).data}async fetchOpenApiSpec(e,r,n){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/openapi`,{url:r,link:n?.link})).data}async uploadSystemDocumentationFiles(e,r,n){let i=await this.uploadFiles(r,{process:!0}),o=i.flatMap(s=>s.status==="uploaded"?[s.id]:[]);if(o.length>0)try{await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/files`,{fileIds:o,link:n?.link!==!1})}catch(s){throw await Promise.all(o.map(a=>this.deleteFileUpload(a).catch(()=>{}))),s}if(!n?.settle){let s=i.filter(a=>a.status==="failed");if(s.length>0)throw new Error(s.map(a=>a.error).join("; "))}return i}async listSystemDocumentationFiles(e,r){let n=new URLSearchParams;r?.length&&n.set("fileIds",r.join(","));let i=n.size>0?`?${n.toString()}`:"";return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/documentation/files${i}`)).data}async getSystemDocumentationFileContent(e,r,n){return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/documentation/files/${encodeURIComponent(r)}/content?processed=${n.processed}`)).data}async deleteSystemDocumentationFile(e,r){await this.restRequest("DELETE",`/v1/systems/${encodeURIComponent(e)}/documentation/files/${encodeURIComponent(r)}`)}async generateCredentialsLink(e){try{return{success:!0,credentialsUrl:(await this.restRequest("POST","/v1/authenticate",e||{})).data.credentialsUrl}}catch(r){return{success:!1,error:r.message}}}};Al.SuperglueClient=Iv});var PY=m(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.UnquotedKeyStrategy=pt.TripleQuoteStrategy=pt.TrailingCommaStrategy=pt.SingleQuoteStrategy=pt.PythonLiteralStrategy=pt.CommentStrategy=pt.ResilientJsonParser=pt.RepairStrategy=void 0;pt.parseJsonResilient=DOe;pt.parseJSON=TOe;pt.isValidJson=ROe;pt.prettyPrintJson=kOe;pt.minifyJson=NOe;var ii=class{validate(e){try{return JSON.parse(e),!0}catch{return!1}}};pt.RepairStrategy=ii;var Wy=class extends ii{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,(r,n)=>{let i=n.trim();if(i.startsWith("{")&&i.endsWith("}")||i.startsWith("[")&&i.endsWith("]"))try{let s=JSON.parse(i);return JSON.stringify(s)}catch{return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`})}};pt.TripleQuoteStrategy=Wy;var Zy=class extends ii{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")}};pt.PythonLiteralStrategy=Zy;var Ky=class extends ii{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")}};pt.TrailingCommaStrategy=Ky;var Xy=class extends ii{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 r=e.replace(/([{,]\s*)'([^']+)'(\s*:)/g,'$1"$2"$3');return r=r.replace(/(:\s*)'([^']+)'(\s*[,}])/g,'$1"$2"$3'),r}};pt.SingleQuoteStrategy=Xy;var eE=class extends ii{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')}};pt.UnquotedKeyStrategy=eE;var tE=class extends ii{constructor(){super(...arguments),this.name="CommentRemoval",this.description="Removes JavaScript-style comments"}canApply(e){return/\/\/.*$|\/\*[\s\S]*?\*\//m.test(e)}apply(e){let r=e.replace(/\/\/.*$/gm,"");return r=r.replace(/\/\*[\s\S]*?\*\//g,""),r}};pt.CommentStrategy=tE;var Cv=class extends ii{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(r){let n=r.message||"";return n.includes("control character")||n.includes("Bad control")||n.includes("Unexpected token")&&/[\n\r\t]/.test(e)}}apply(e){let r="",n=!1,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=o>0?e[o-1]:"";if(i){r+=s,i=!1;continue}if(s==="\\"&&n){r+=s,i=!0;continue}if(s==='"'&&a!=="\\"){n=!n,r+=s;continue}if(n)switch(s){case`
|
|
1858
1858
|
`:r+="\\n";break;case"\r":r+="\\r";break;case" ":r+="\\t";break;case"\b":r+="\\b";break;case"\f":r+="\\f";break;default:let c=s.charCodeAt(0);c<32?r+="\\u"+("0000"+c.toString(16)).slice(-4):r+=s}else r+=s}return r}},bv=class extends ii{constructor(){super(...arguments),this.name="TrailingCharactersRepair",this.description="Removes trailing characters after valid JSON structure"}canApply(e){let r=e.trim();if(!r.startsWith("{")&&!r.startsWith("["))return!1;let n=0,i=0,o=!1,s=!1;for(let a=0;a<r.length;a++){let c=r[a];if(o)s?s=!1:c==="\\"?s=!0:c==='"'&&(o=!1);else if(c==='"')o=!0;else if(c==="{")n++;else if(c==="}"){if(n--,n===0&&i===0&&a>0&&a<r.length-1)return!0}else if(c==="[")i++;else if(c==="]"&&(i--,i===0&&n===0&&a>0&&a<r.length-1))return!0}return!1}apply(e){let r=e.trim(),n=0,i=0,o=!1,s=!1,a=-1;for(let c=0;c<r.length;c++){let u=r[c];if(o)s?s=!1:u==="\\"?s=!0:u==='"'&&(o=!1);else if(u==='"')o=!0;else if(u==="{")n++;else if(u==="}"){if(n--,n===0&&i===0&&c>0){a=c;break}}else if(u==="[")i++;else if(u==="]"&&(i--,i===0&&n===0&&c>0)){a=c;break}}return a>0&&a<r.length-1?r.substring(0,a+1):e}},pl=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 Wy,new Xy,new Cv,new bv,new Zy,new Ky,new eE,new tE]}parse(e){let r=Date.now();this.repairLog=[];let n=e instanceof Buffer?e.toString("utf8"):String(e);try{return{success:!0,data:JSON.parse(n),metadata:{parseTime:Date.now()-r,strategiesApplied:[]}}}catch(s){if(!this.options.attemptRepair)return{success:!1,error:`JSON parse error: ${s}`,metadata:{parseTime:Date.now()-r}}}let i=n,o=[];for(let s of this.strategies)if(s.canApply(i)){let a=i;if(i=s.apply(i),a!==i){o.push(s.name),this.repairLog.push(s.description),this.options.logRepairs&&console.log(`Applied ${s.name}: ${s.description}`);try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-r,strategiesApplied:o}}}catch{}}}try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-r,strategiesApplied:o}}}catch(s){let a=this.aggressiveFallback(i);return a.success?{...a,repairs:[...this.repairLog,"Applied aggressive fallback"],metadata:{parseTime:Date.now()-r,strategiesApplied:[...o,"AggressiveFallback"]}}:{success:!1,error:`Failed to parse JSON after applying ${o.length} strategies: ${s}`,repairs:this.repairLog,metadata:{parseTime:Date.now()-r,strategiesApplied:o}}}}aggressiveFallback(e){try{let r=e.indexOf("{"),n=e.indexOf("[");if(r===-1&&n===-1)return{success:!1,error:"No JSON-like structure found"};let i=r===-1?n:n===-1?r:Math.min(r,n),o=e.substring(i);for(let a of this.strategies)a.canApply(o)&&(o=a.apply(o));return{success:!0,data:JSON.parse(o)}}catch(r){return{success:!1,error:`Aggressive fallback failed: ${r}`}}}addStrategy(e){this.strategies.push(e)}removeStrategy(e){this.strategies=this.strategies.filter(r=>r.name!==e)}getStrategies(){return this.strategies.map(e=>e.name)}};pt.ResilientJsonParser=pl;var LY=new pl;function DOe(t,e){return(e?new pl(e):LY).parse(t)}function TOe(t){let e=LY.parse(t);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 ROe(t){try{return JSON.parse(t),!0}catch{return!1}}function kOe(t,e=2){return JSON.stringify(t,null,e)}function NOe(t){let r=new pl().parse(t);if(r.success)return JSON.stringify(r.data);throw new Error("Cannot minify invalid JSON")}});var gr=m(K=>{"use strict";var OOe=K&&K.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),ce=K&&K.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&OOe(e,t,r)};Object.defineProperty(K,"__esModule",{value:!0});K.SSELogSubscriptionManager=K.SuperglueHttpError=K.SuperglueClient=void 0;ce(XM(),K);ce(nx(),K);ce(hx(),K);ce(mx(),K);ce(bx(),K);ce(Sx(),K);ce(Bx(),K);ce(Ld(),K);ce(oL(),K);ce(SI(),K);ce(cL(),K);ce(uL(),K);ce(lL(),K);ce(dL(),K);ce(Hb(),K);ce(pL(),K);ce(gL(),K);ce(mL(),K);ce(yL(),K);ce(Vb(),K);ce(Kb(),K);ce(IL(),K);ce(CL(),K);ce(SL(),K);ce(rh(),K);ce(BL(),K);ce(QL(),K);ce(vL(),K);ce(DL(),K);ce(kL(),K);ce(YL(),K);ce(cS(),K);ce(zd(),K);ce(aS(),K);ce(KL(),K);ce(eP(),K);ce(rP(),K);ce(Tb(),K);ce(AP(),K);ce(fP(),K);ce(Ag(),K);ce(_P(),K);ce(NP(),K);ce(OP(),K);ce(QS(),K);ce(LP(),K);ce(PP(),K);ce(zP(),K);ce(HP(),K);ce(yr(),K);ce(wn(),K);ce(GP(),K);ce(YP(),K);ce(vg(),K);ce(su(),K);ce(kd(),K);var FY=xY();Object.defineProperty(K,"SuperglueClient",{enumerable:!0,get:function(){return FY.SuperglueClient}});Object.defineProperty(K,"SuperglueHttpError",{enumerable:!0,get:function(){return FY.SuperglueHttpError}});var UOe=TS();Object.defineProperty(K,"SSELogSubscriptionManager",{enumerable:!0,get:function(){return UOe.SSELogSubscriptionManager}});ce(PY(),K)});var PE=require("commander");var kr=ge(require("fs")),zY=ge(require("os")),os=ge(require("path")),lp=ge(gr()),$Y=new Set(["runner","builder","admin"]),jY={output:{mode:"stdout",directory:".superglue/output"},preset:"admin"};function ss(t){let e=os.join(process.cwd(),".superglue"),r=zY.homedir();if(!r)return e;let n=os.join(r,".superglue");return t===!0?e:t===!1?n:kr.existsSync(os.join(e,"config.json"))?e:n}function Sv(t){return os.join(ss(t),"config.json")}function rE(t){let e=Sv(t);if(!kr.existsSync(e))return{};try{return JSON.parse(kr.readFileSync(e,"utf-8"))}catch{return{}}}function fl(t){let e=rE(),r=t.apiKey||(0,lp.readProcessEnvironmentValue)("SUPERGLUE_API_KEY")||e.apiKey||"",n=t.endpoint||(0,lp.readProcessEnvironmentValue)("SUPERGLUE_API_ENDPOINT")||e.endpoint||"https://api.superglue.cloud",i=(0,lp.readProcessEnvironmentValue)("SUPERGLUE_WEB_ENDPOINT")||e.webEndpoint||n.replace(/:3002\b/,":3001").replace(/api\.superglue/,"app.superglue"),o=(0,lp.readProcessEnvironmentValue)("SUPERGLUE_CLI_PRESET"),s=o&&$Y.has(o)?o:e.preset&&$Y.has(e.preset)?e.preset:"admin";return{...jY,...e,apiKey:r,endpoint:n,webEndpoint:i,preset:s,output:{...jY.output,...e.output}}}function nE(t,e){let r=ss(e);kr.existsSync(r)||kr.mkdirSync(r,{recursive:!0}),kr.writeFileSync(os.join(r,"config.json"),JSON.stringify(t,null,2)+`
|
|
1859
|
-
`,{mode:384})}function iE(t,e){let r=os.join(ss(e),"drafts");if(kr.existsSync(r)||kr.mkdirSync(r,{recursive:!0}),t.output.mode==="stdout+file"){let n=os.resolve(t.output.directory);kr.existsSync(n)||kr.mkdirSync(n,{recursive:!0})}}var Tv=ge(gr());var wv=ge(require("readline"));var GY=require("child_process"),YY=require("util");var qY={name:"@superglue/cli",version:"1.1.
|
|
1859
|
+
`,{mode:384})}function iE(t,e){let r=os.join(ss(e),"drafts");if(kr.existsSync(r)||kr.mkdirSync(r,{recursive:!0}),t.output.mode==="stdout+file"){let n=os.resolve(t.output.directory);kr.existsSync(n)||kr.mkdirSync(n,{recursive:!0})}}var Tv=ge(gr());var wv=ge(require("readline"));var GY=require("child_process"),YY=require("util");var qY={name:"@superglue/cli",version:"1.1.193",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 xOe=(0,YY.promisify)(GY.exec),mr=qY.version;function HY(t){let e=t.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:t}}function sE(t,e){let r=t.split("."),n=e.split("."),i=Math.max(r.length,n.length);for(let o=0;o<i;o++){let s=HY(r[o]||"0"),a=HY(n[o]||"0");if(s.numeric<a.numeric)return-1;if(s.numeric>a.numeric||s.prerelease===null&&a.prerelease!==null)return 1;if(s.prerelease!==null&&a.prerelease===null)return-1;if(s.prerelease!==null&&a.prerelease!==null){if(s.prerelease<a.prerelease)return-1;if(s.prerelease>a.prerelease)return 1}}return 0}async function aE(){try{let t=await fetch("https://registry.npmjs.org/@superglue/cli/latest",{signal:AbortSignal.timeout(5e3)});return t.ok&&(await t.json()).version||null}catch{return null}}var oE=null;function VY(){se()&&(oE=aE())}async function JY(){if(!(!se()||!oE)){try{let t=new Promise(r=>{setTimeout(()=>r(null),2e3).unref()}),e=await Promise.race([oE,t]);e&&sE(mr,e)<0&&(console.error(""),console.error(`${E.cyan}${E.bold} Update available: ${mr} \u2192 ${e}${E.reset}`),console.error(`${E.cyan} Run ${E.bold}sg update${E.reset}${E.cyan} to upgrade${E.reset}`),console.error(""))}catch{}oE=null}}async function WY(){let t=await aE();if(!t)return{success:!1,message:"Could not fetch latest version from npm"};if(sE(mr,t)>=0)return{success:!0,message:`Already on latest version (${mr})`};try{return await xOe("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${mr} to ${t}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var se=()=>process.argv.includes("--table")&&process.stdout.isTTY,Nr=()=>process.argv.includes("--full"),E={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 ZY(t,e){let r=e||t;return`\x1B]8;;${t}\x07${E.underline}${E.cyan}${r}${E.reset}\x1B]8;;\x07`}function KY(){if(!se())return;let t=E.reset,e=E.dim,r="\x1B[47;30m",n=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),n.forEach(i=>{let o=i.search(/\S/),s=i.length-[...i].reverse().join("").search(/\S/)-1;if(o===-1)return console.log(" "+i);let a=i.slice(0,o),c=i.slice(o,s+1).split("").map(l=>l===" "?" ":"\u2588").join(""),u=i.slice(s+1);console.log(` ${a}${r}${c}${t}${u}`)}),console.log(` ${e} CLI v${mr}${t}`),console.log("")}function lt(t){if(!se())return{stop:()=>{},update:()=>{},log:()=>{}};let e=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],r=0,n=t,i=()=>process.stdout.write("\r\x1B[2K"),o=()=>{process.stdout.write(`\r ${E.cyan}${e[r++%e.length]}${E.reset} ${n}`)},s=setInterval(o,80);return{update:a=>{n=a},log:a=>{i(),console.log(` ${E.dim}\u2502${E.reset} ${a}`),o()},stop:a=>{clearInterval(s),i(),a&&console.log(` ${a}`)}}}function ee(t){se()?cE(t):console.log(JSON.stringify(t,null,2))}function ve(t,e){se()?(console.log(` ${E.green}\u2713${E.reset} ${t}`),e&&cE(e,4)):console.log(JSON.stringify({success:!0,message:t,...e&&typeof e=="object"?e:{data:e}}))}function D(t,e){se()?(console.error(` ${E.red}\u2717${E.reset} ${t}`),e&&cE(e,4)):console.error(JSON.stringify({success:!1,error:t,details:e}))}function XY(t){se()&&console.log(` ${E.yellow}\u26A0${E.reset} ${t}`)}function sr(t){se()&&console.log(` ${E.dim}${t}${E.reset}`)}function as(t){se()&&(console.log(`
|
|
1860
1860
|
${E.bold}${E.cyan}${t}${E.reset}`),console.log(` ${E.dim}${"\u2500".repeat(t.length)}${E.reset}`))}function Or(t,e,r){if(!se()){console.log(JSON.stringify({success:!0,total:r?.total??t.length,items:t}));return}if(t.length===0){console.log(`
|
|
1861
1861
|
${E.dim}0 results${E.reset}
|
|
1862
1862
|
`);return}let n=e||Object.keys(t[0]),i=Nr()?1/0:60,o=n.map(l=>Math.min(i,Math.max(l.length,...t.map(d=>String(d[l]??"").replace(/[\n\r]+/g," ").trim().length))));console.log("");let s=n.map((l,d)=>`${E.bold}${E.cyan}${l.toUpperCase().padEnd(o[d])}${E.reset}`).join(" ");console.log(` ${s}`);let a=o.map(l=>`${E.dim}${"\u2500".repeat(l)}${E.reset}`).join(`${E.dim}\u2500\u2500${E.reset}`);console.log(` ${a}`);for(let l of t){let d=n.map((A,p)=>{let h=String(l[A]??"").replace(/[\n\r]+/g," ").trim();if(h.length>i){let S=`\u2026 (${h.length})`;h=h.slice(0,Math.max(0,i-S.length))+`${E.dim}${S}${E.reset}`}return A==="status"?`${{success:E.green,running:E.yellow,failed:E.red,aborted:E.red,error:E.red,pending:E.dim}[h.toLowerCase()]||""}${h.padEnd(o[p])}${E.reset}`:h.padEnd(o[p])}).join(" ");console.log(` ${d}`)}let c=r?.total??t.length,u=c===t.length?`${t.length} result${t.length===1?"":"s"}`:`${t.length} of ${c} result${c===1?"":"s"}`;console.log(`
|