@superglue/cli 1.1.113 → 1.1.114

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.113",
4
+ "version": "1.1.114",
5
5
  "author": {
6
6
  "name": "superglue",
7
7
  "email": "hello@superglue.cloud"
package/dist/cli.js CHANGED
@@ -309,20 +309,35 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
309
309
  return String(value);
310
310
  };
311
311
 
312
+ const fieldValue = (name) => (Object.prototype.hasOwnProperty.call(state, name) ? state[name] : undefined);
313
+
312
314
  const conditionMatches = (element) => {
313
315
  const field = element.getAttribute("data-sg-show-when");
314
316
  if (!field) return true;
315
- const value = state[field];
317
+ const value = fieldValue(field);
316
318
  const expected = element.getAttribute("data-sg-is");
317
319
  if (expected === null) return Array.isArray(value) ? value.length > 0 : Boolean(value);
318
- if (Array.isArray(value)) return value.map(String).includes(expected);
319
- return String(value) === expected;
320
+ const options = [expected, ...expected.split(",").map((option) => option.trim())];
321
+ const actual = Array.isArray(value) ? value.map(String) : [String(value)];
322
+ return actual.some((item) => options.includes(item));
323
+ };
324
+
325
+ const selectedCount = (value) => {
326
+ if (Array.isArray(value)) return value.length;
327
+ if (typeof value === "boolean") return Number(value);
328
+ return value === null || value === undefined || value === "" ? 0 : 1;
320
329
  };
321
330
 
322
331
  const computeValue = (element) => {
323
332
  const operation = element.getAttribute("data-sg-compute");
324
333
  const names = (element.getAttribute("data-sg-fields") || "").split(",").map((name) => name.trim()).filter(Boolean);
325
- const values = names.map((name) => state[name]).filter((value) => typeof value === "number" || (typeof value === "string" && value.trim() !== "")).map(Number).filter(Number.isFinite);
334
+ if (operation === "count") return names.reduce((total, name) => total + selectedCount(fieldValue(name)), 0);
335
+ const values = names
336
+ .flatMap((name) => (/^-?\d+(\.\d+)?$/.test(name) ? [Number(name)] : [fieldValue(name)].flat()))
337
+ .map((value) => (typeof value === "boolean" ? Number(value) : value))
338
+ .filter((value) => typeof value === "number" || (typeof value === "string" && value.trim() !== ""))
339
+ .map(Number)
340
+ .filter(Number.isFinite);
326
341
  if (!operation || values.length === 0) return null;
327
342
  if (operation === "sum") return values.reduce((total, value) => total + value, 0);
328
343
  if (operation === "product") return values.reduce((total, value) => total * value, 1);
@@ -358,6 +373,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
358
373
  element.style.setProperty("--sg-progress", String(((index + 1) / available.length) * 100) + "%");
359
374
  }
360
375
  }
376
+ const pageNames = available.map((page) => page.getAttribute("data-sg-page"));
377
+ for (const step of document.querySelectorAll("[data-sg-step]")) {
378
+ const stepIndex = pageNames.indexOf(step.getAttribute("data-sg-step"));
379
+ const stepState = stepIndex === index ? "current" : stepIndex >= 0 && stepIndex < index ? "done" : "upcoming";
380
+ step.setAttribute("data-sg-step-state", stepState);
381
+ if (stepState === "current") step.setAttribute("aria-current", "step");
382
+ else step.removeAttribute("aria-current");
383
+ }
361
384
  for (const button of document.querySelectorAll('[data-sg-action="previous"]')) button.disabled = index === 0;
362
385
  for (const button of document.querySelectorAll('[data-sg-action="next"]')) button.disabled = index === available.length - 1;
363
386
  };
@@ -375,7 +398,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
375
398
  const renderState = () => {
376
399
  markHiddenChoiceLabels();
377
400
  for (const element of document.querySelectorAll("[data-sg-show-when]")) element.hidden = !conditionMatches(element);
378
- for (const element of document.querySelectorAll("[data-sg-bind]")) element.textContent = formatValue(state[element.getAttribute("data-sg-bind")], element);
401
+ for (const element of document.querySelectorAll("[data-sg-bind]")) element.textContent = formatValue(fieldValue(element.getAttribute("data-sg-bind")), element);
379
402
  for (const element of document.querySelectorAll("[data-sg-compute]")) element.textContent = formatValue(computeValue(element), element);
380
403
  renderPages();
381
404
  document.documentElement.dataset.sgArtifactReady = "true";
@@ -1667,7 +1690,7 @@ ${r}`;break;case"retry":IN(r)&&(t[i]=r);break;case"id":jN(r)&&(t[i]=r);break;cas
1667
1690
  `);o.stack=t?`${t}
1668
1691
  ${r}`:i.stack}G.exports.fetch=function(e,t=void 0){return RIe(e,t).catch(a=>{throw UN?FN(a,UN):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}=ax();G.exports.setGlobalOrigin=NIe;G.exports.getGlobalOrigin=OIe;var{CacheStorage:UIe}=qR(),{kConstruct:MIe}=Ue();G.exports.caches=new UIe(MIe);var{deleteCookie:LIe,getCookies:PIe,getSetCookies:FIe,setCookie:$Ie,parseCookie:HIe}=NR();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}=fN();G.exports.WebSocket=ZIe;G.exports.CloseEvent=YIe;G.exports.ErrorEvent=JIe;G.exports.MessageEvent=WIe;G.exports.ping=KIe;G.exports.WebSocketStream=zN().WebSocketStream;G.exports.WebSocketError=_q().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}=ON();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 GN=f(Rm=>{"use strict";Object.defineProperty(Rm,"__esModule",{value:!0});Rm.SuperglueClient=Rm.SuperglueHttpError=void 0;var Tm=Ht(),Mr=xv(),o2e=Xv(),t2e=a3(),a2e=Fa(),Lr=zc(),i2e=Lg(),wd=14400*1e3,vd;if(typeof globalThis.process<"u"&&globalThis.process.versions?.node)try{let{Agent:o}=$N();vd=new o({headersTimeout:wd,bodyTimeout:wd})}catch{}function HN(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 Uq=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;HN(t);let r=await this.refreshToken();return HN(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=Uq});var YN=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 Mq=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
1692
  `: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}},Lq=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 Mq,new Lq,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 VN=new Nm;function r2e(o,e){return(e?new Nm(e):VN).parse(o)}function n2e(o){let e=VN.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(RC(),oe);he(GC(),oe);he(l8(),oe);he(h8(),oe);he(k8(),oe);he(iu(),oe);he(U8(),oe);he(M8(),oe);he(L8(),oe);he(P8(),oe);he(xv(),oe);he($8(),oe);he(H8(),oe);he(G8(),oe);he(Ev(),oe);he(J8(),oe);he(Z8(),oe);he(K8(),oe);he(eQ(),oe);he(Md(),oe);he(tQ(),oe);he(aQ(),oe);he(rQ(),oe);he(cQ(),oe);he(Cv(),oe);he(pQ(),oe);he(fQ(),oe);he(yQ(),oe);he(kQ(),oe);he(SQ(),oe);he(QQ(),oe);he(Fv(),oe);he($Q(),oe);he(Wv(),oe);he(YQ(),oe);he(KQ(),oe);he(e3(),oe);he(Ht(),oe);he(Fa(),oe);he(o3(),oe);he(t3(),oe);he(jh(),oe);he(zc(),oe);he(Lg(),oe);var JN=GN();Object.defineProperty(oe,"SuperglueClient",{enumerable:!0,get:function(){return JN.SuperglueClient}});Object.defineProperty(oe,"SuperglueHttpError",{enumerable:!0,get:function(){return JN.SuperglueHttpError}});var u2e=Xv();Object.defineProperty(oe,"SSELogSubscriptionManager",{enumerable:!0,get:function(){return u2e.SSELogSubscriptionManager}});he(YN(),oe)});var Cy=require("commander");var kt=pe(require("fs")),KN=pe(require("os")),Pr=pe(require("path")),xd=pe(Pt()),WN=new Set(["runner","builder","admin"]),ZN={output:{mode:"stdout",directory:".superglue/output"},preset:"admin"};function Fr(o){let e=Pr.join(process.cwd(),".superglue"),t=KN.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 Pq(o){return Pr.join(Fr(o),"config.json")}function Jb(o){let e=Pq(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&&WN.has(r)?r:e.preset&&WN.has(e.preset)?e.preset:"admin";return{...ZN,...e,apiKey:t,endpoint:a,webEndpoint:i,preset:n,output:{...ZN.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 Jq=pe(Pt());var Fq=pe(require("readline"));var oO=require("child_process"),tO=require("util");var XN={name:"@superglue/cli",version:"1.1.113",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,tO.promisify)(oO.exec),rt=XN.version;function eO(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=eO(t[r]||"0"),s=eO(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 aO(){me()&&(Kb=ey())}async function iO(){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 rO(){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 nO(o,e){let t=e||o;return`\x1B]8;;${o}\x07${b.underline}${b.cyan}${t}${b.reset}\x1B]8;;\x07`}function sO(){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 cO(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(`
1693
+ `,{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 Jq=pe(Pt());var Fq=pe(require("readline"));var oO=require("child_process"),tO=require("util");var XN={name:"@superglue/cli",version:"1.1.114",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,tO.promisify)(oO.exec),rt=XN.version;function eO(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=eO(t[r]||"0"),s=eO(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 aO(){me()&&(Kb=ey())}async function iO(){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 rO(){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 nO(o,e){let t=e||o;return`\x1B]8;;${o}\x07${b.underline}${b.cyan}${t}${b.reset}\x1B]8;;\x07`}function sO(){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 cO(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
1694
  ${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
1695
  ${b.dim}0 results${b.reset}
1673
1696
  `);return}let a=e||Object.keys(o[0]),i=ya()?1/0:60,r=a.map(l=>Math.min(i,Math.max(l.length,...o.map(u=>String(u[l]??"").replace(/[\n\r]+/g," ").trim().length))));console.log("");let n=a.map((l,u)=>`${b.bold}${b.cyan}${l.toUpperCase().padEnd(r[u])}${b.reset}`).join(" ");console.log(` ${n}`);let s=r.map(l=>`${b.dim}${"\u2500".repeat(l)}${b.reset}`).join(`${b.dim}\u2500\u2500${b.reset}`);console.log(` ${s}`);for(let l of o){let u=a.map((d,g)=>{let h=String(l[d]??"").replace(/[\n\r]+/g," ").trim();if(h.length>i){let w=`\u2026 (${h.length})`;h=h.slice(0,Math.max(0,i-w.length))+`${b.dim}${w}${b.reset}`}return d==="status"?`${{success:b.green,running:b.yellow,failed:b.red,aborted:b.red,error:b.red,pending:b.dim}[h.toLowerCase()]||""}${h.padEnd(r[g])}${b.reset}`:h.padEnd(r[g])}).join(" ");console.log(` ${u}`)}let c=t?.total??o.length,m=c===o.length?`${o.length} result${o.length===1?"":"s"}`:`${o.length} of ${c} result${c===1?"":"s"}`;console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superglue/cli",
3
- "version": "1.1.113",
3
+ "version": "1.1.114",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },