@superglue/cli 1.1.108 → 1.1.109

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.108",
4
+ "version": "1.1.109",
5
5
  "author": {
6
6
  "name": "superglue",
7
7
  "email": "hello@superglue.cloud"
package/dist/cli.js CHANGED
@@ -1667,7 +1667,7 @@ ${r}`;break;case"retry":CN(r)&&(t[i]=r);break;case"id":SN(r)&&(t[i]=r);break;cas
1667
1667
  `);o.stack=t?`${t}
1668
1668
  ${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`
1669
1669
  `: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)+`
1670
- `,{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.108",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(`
1670
+ `,{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.109",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(`
1671
1671
  ${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(`
1672
1672
  ${b.dim}0 results${b.reset}
1673
1673
  `);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(`
@@ -64,7 +64,7 @@ A failed operation fails the step with NetSuite's error messages. `importObjects
64
64
 
65
65
  In `deploy.xml`, each `path` starts with `~` (the project root), is case-sensitive, and can use `*` for all files in a folder. The element order is `configuration`, `files`, `objects`, and NetSuite processes the paths in sequence. Supply your own `deploy.xml` for files outside `FileCabinet/SuiteScripts/`. A project with files only in other folders fails without one.
66
66
 
67
- NetSuite refuses a project whose objects need a feature the manifest does not declare. The default manifest adds `SERVERSIDESCRIPTING` for server script objects (`restlet`, `suitelet`, `usereventscript`, `scheduledscript`, `mapreducescript`, `workflowactionscript`, `massupdatescript`, `portlet`, `bundleinstallationscript`) and `WORKFLOW` for a `workflow`, read from each object's root element. Client scripts and custom record types need no feature. Supply your own `manifest.xml` when validation names another feature:
67
+ NetSuite refuses a project whose objects need a feature the manifest does not declare. The default manifest adds `SERVERSIDESCRIPTING` for server script objects (`restlet`, `suitelet`, `usereventscript`, `scheduledscript`, `mapreducescript`, `workflowactionscript`, `massupdatescript`, `portlet`, `bundleinstallationscript`) and `WORKFLOW` for a `workflow`, read from each object's root element. Client scripts and custom record types need no feature. Supply your own `manifest.xml` when validation names another feature, or when the project references an object that already exists in the account, for example `[scriptid=custcol_sg_code]`: validation fails with "missing in the project and also not included in the dependencies list" unless you add that object's XML to `files` or declare it under `<dependencies><objects><object>custcol_sg_code</object></objects></dependencies>`:
68
68
 
69
69
  ```xml
70
70
  <manifest projecttype="ACCOUNTCUSTOMIZATION">
@@ -144,9 +144,11 @@ States hold the logic. This block is shortened from Oracle's example, which list
144
144
  ```
145
145
 
146
146
  - `workflowstate`: `scriptid` and `name` are required. Optional: `description`, `donotexitworkflow`, `positionx`, `positiony`. Structured fields: `workflowactions`, `workflowstatecustomfields`, `workflowtransitions`.
147
- - `workflowactions` can occur several times in a state. Its `triggertype` attribute is required: `ONENTRY`, `ONEXIT`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`, `BEFOREUSEREDIT`, `BEFOREFIELDEDIT`, `AFTERFIELDEDIT`, `AFTERFIELDSOURCING`, or `BEFOREUSERSUBMIT`.
147
+ - `workflowactions` can occur several times in a state. Its `triggertype` attribute is required: `ONENTRY`, `ONEXIT`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`, `BEFOREUSEREDIT`, `BEFOREFIELDEDIT`, `AFTERFIELDEDIT`, `AFTERFIELDSOURCING`, or `BEFOREUSERSUBMIT`. Server actions such as `setfieldvalueaction` run on server triggers (`ONENTRY`, `ONEXIT`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`). User-facing actions such as `showmessageaction` and `confirmaction` need client triggers (`BEFOREUSEREDIT`, `BEFOREFIELDEDIT`, `AFTERFIELDEDIT`, `AFTERFIELDSOURCING`, `BEFOREUSERSUBMIT`). `validate` names a wrong pairing precisely.
148
148
  - Action elements: `addbuttonaction`, `removebuttonaction`, `confirmaction`, `showmessageaction`, `returnusererroraction`, `setfieldvalueaction`, `setfieldmandatoryaction`, `setdisplaylabelaction`, `setdisplaytypeaction`, `lockrecordaction`, `createrecordaction`, `createlineaction`, `transformrecordaction`, `gotorecordaction`, `gotopageaction`, `sendemailaction`, `sendcampaignemailaction`, `subscribetorecordaction`, `initiateworkflowaction`, `customaction`. Groups: `workflowactiongroup`, `workflowsublistactiongroup`. Each action needs its own `scriptid`.
149
- - `workflowtransition`: `scriptid` and `tostate` are required. Optional: `triggertype` (`ONENTRY`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`), `buttonaction` (a reference to an `addbuttonaction`), `conditionsavedsearch`, `contexttypes`, `eventtypes`, `scheduledelay`, `scheduletimeunit`, `waitforworkflow`, `waitforworkflowstate`, and `initcondition`.
149
+ - `sendemailaction` needs values, not only the type elements: `sendertype` `SPECIFIC` with `<sender>` (employee internal ID) and `recipienttype` `ADDRESS` with `<recipientemail>` pass.
150
+ - Line-level actions go in `<setfieldvalueactions>` with `<sublist>ITEM</sublist>` (not `STDBODYITEM` or `SALESORDER:ITEM`). Standard line field codes are record-specific and not guessable (`STDLINEMEMO`, `STDLINEITEM`, `STDLINEQUANTITY`, `STDLINERATE`, `STDLINEDESCRIPTION` are all rejected; an expense workflow uses `STDRECORDEREXPLINECATEGORY`). Reference a custom column field instead, or import a UI-built workflow to read the code. A custom segment column takes the segment's script ID, not the field's.
151
+ - `workflowtransition`: `scriptid` and `tostate` are required. Optional: `triggertype` (`ONENTRY`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`), `buttonaction` (a reference to an `addbuttonaction`), `conditionsavedsearch`, `contexttypes`, `eventtypes`, `scheduledelay`, `scheduletimeunit` (singular: `HOUR`, `DAY`; plural forms are rejected), `waitforworkflow`, `waitforworkflowstate`, and `initcondition`.
150
152
  - References use the full script ID path. State: `[scriptid=customworkflow_approvals.workflowstate_approved]`. Button: `[scriptid=customworkflow_approvals.workflowstate_approvalpending.workflowaction_approvebutton]`. Custom field: `[scriptid=custbody_approvalstatus]`. Standard fields use codes such as `STDBODYSALESREP`.
151
153
 
152
154
  Conditions (`initcondition`) have a required `type`, an optional `formula`, and optional `parameters`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superglue/cli",
3
- "version": "1.1.108",
3
+ "version": "1.1.109",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },
@@ -64,7 +64,7 @@ A failed operation fails the step with NetSuite's error messages. `importObjects
64
64
 
65
65
  In `deploy.xml`, each `path` starts with `~` (the project root), is case-sensitive, and can use `*` for all files in a folder. The element order is `configuration`, `files`, `objects`, and NetSuite processes the paths in sequence. Supply your own `deploy.xml` for files outside `FileCabinet/SuiteScripts/`. A project with files only in other folders fails without one.
66
66
 
67
- NetSuite refuses a project whose objects need a feature the manifest does not declare. The default manifest adds `SERVERSIDESCRIPTING` for server script objects (`restlet`, `suitelet`, `usereventscript`, `scheduledscript`, `mapreducescript`, `workflowactionscript`, `massupdatescript`, `portlet`, `bundleinstallationscript`) and `WORKFLOW` for a `workflow`, read from each object's root element. Client scripts and custom record types need no feature. Supply your own `manifest.xml` when validation names another feature:
67
+ NetSuite refuses a project whose objects need a feature the manifest does not declare. The default manifest adds `SERVERSIDESCRIPTING` for server script objects (`restlet`, `suitelet`, `usereventscript`, `scheduledscript`, `mapreducescript`, `workflowactionscript`, `massupdatescript`, `portlet`, `bundleinstallationscript`) and `WORKFLOW` for a `workflow`, read from each object's root element. Client scripts and custom record types need no feature. Supply your own `manifest.xml` when validation names another feature, or when the project references an object that already exists in the account, for example `[scriptid=custcol_sg_code]`: validation fails with "missing in the project and also not included in the dependencies list" unless you add that object's XML to `files` or declare it under `<dependencies><objects><object>custcol_sg_code</object></objects></dependencies>`:
68
68
 
69
69
  ```xml
70
70
  <manifest projecttype="ACCOUNTCUSTOMIZATION">
@@ -144,9 +144,11 @@ States hold the logic. This block is shortened from Oracle's example, which list
144
144
  ```
145
145
 
146
146
  - `workflowstate`: `scriptid` and `name` are required. Optional: `description`, `donotexitworkflow`, `positionx`, `positiony`. Structured fields: `workflowactions`, `workflowstatecustomfields`, `workflowtransitions`.
147
- - `workflowactions` can occur several times in a state. Its `triggertype` attribute is required: `ONENTRY`, `ONEXIT`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`, `BEFOREUSEREDIT`, `BEFOREFIELDEDIT`, `AFTERFIELDEDIT`, `AFTERFIELDSOURCING`, or `BEFOREUSERSUBMIT`.
147
+ - `workflowactions` can occur several times in a state. Its `triggertype` attribute is required: `ONENTRY`, `ONEXIT`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`, `BEFOREUSEREDIT`, `BEFOREFIELDEDIT`, `AFTERFIELDEDIT`, `AFTERFIELDSOURCING`, or `BEFOREUSERSUBMIT`. Server actions such as `setfieldvalueaction` run on server triggers (`ONENTRY`, `ONEXIT`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`). User-facing actions such as `showmessageaction` and `confirmaction` need client triggers (`BEFOREUSEREDIT`, `BEFOREFIELDEDIT`, `AFTERFIELDEDIT`, `AFTERFIELDSOURCING`, `BEFOREUSERSUBMIT`). `validate` names a wrong pairing precisely.
148
148
  - Action elements: `addbuttonaction`, `removebuttonaction`, `confirmaction`, `showmessageaction`, `returnusererroraction`, `setfieldvalueaction`, `setfieldmandatoryaction`, `setdisplaylabelaction`, `setdisplaytypeaction`, `lockrecordaction`, `createrecordaction`, `createlineaction`, `transformrecordaction`, `gotorecordaction`, `gotopageaction`, `sendemailaction`, `sendcampaignemailaction`, `subscribetorecordaction`, `initiateworkflowaction`, `customaction`. Groups: `workflowactiongroup`, `workflowsublistactiongroup`. Each action needs its own `scriptid`.
149
- - `workflowtransition`: `scriptid` and `tostate` are required. Optional: `triggertype` (`ONENTRY`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`), `buttonaction` (a reference to an `addbuttonaction`), `conditionsavedsearch`, `contexttypes`, `eventtypes`, `scheduledelay`, `scheduletimeunit`, `waitforworkflow`, `waitforworkflowstate`, and `initcondition`.
149
+ - `sendemailaction` needs values, not only the type elements: `sendertype` `SPECIFIC` with `<sender>` (employee internal ID) and `recipienttype` `ADDRESS` with `<recipientemail>` pass.
150
+ - Line-level actions go in `<setfieldvalueactions>` with `<sublist>ITEM</sublist>` (not `STDBODYITEM` or `SALESORDER:ITEM`). Standard line field codes are record-specific and not guessable (`STDLINEMEMO`, `STDLINEITEM`, `STDLINEQUANTITY`, `STDLINERATE`, `STDLINEDESCRIPTION` are all rejected; an expense workflow uses `STDRECORDEREXPLINECATEGORY`). Reference a custom column field instead, or import a UI-built workflow to read the code. A custom segment column takes the segment's script ID, not the field's.
151
+ - `workflowtransition`: `scriptid` and `tostate` are required. Optional: `triggertype` (`ONENTRY`, `BEFORELOAD`, `BEFORESUBMIT`, `AFTERSUBMIT`, `SCHEDULED`), `buttonaction` (a reference to an `addbuttonaction`), `conditionsavedsearch`, `contexttypes`, `eventtypes`, `scheduledelay`, `scheduletimeunit` (singular: `HOUR`, `DAY`; plural forms are rejected), `waitforworkflow`, `waitforworkflowstate`, and `initcondition`.
150
152
  - References use the full script ID path. State: `[scriptid=customworkflow_approvals.workflowstate_approved]`. Button: `[scriptid=customworkflow_approvals.workflowstate_approvalpending.workflowaction_approvebutton]`. Custom field: `[scriptid=custbody_approvalstatus]`. Standard fields use codes such as `STDBODYSALESREP`.
151
153
 
152
154
  Conditions (`initcondition`) have a required `type`, an optional `formula`, and optional `parameters`: