@superglue/cli 1.1.254 → 1.1.255
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/cli.js +1 -1
- package/dist/skills/superglue/SKILL.md +9 -11
- package/package.json +1 -1
- package/skills/superglue/SKILL.md +9 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "superglue",
|
|
3
3
|
"description": "Build, test, and manage superglue tools via the sg CLI. Use when working with superglue tools, systems, APIs, SDKs, or the sg command.",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.255",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "superglue",
|
|
7
7
|
"email": "hello@superglue.cloud"
|
package/dist/cli.js
CHANGED
|
@@ -2239,7 +2239,7 @@ ${s}`;return}if(UI(e,i,KLe)){XLe(e,o)&&(r.retry=e.toString("utf8",o));return}if(
|
|
|
2239
2239
|
`);t.stack=r?`${r}
|
|
2240
2240
|
${o}`:i.stack}ae.exports.fetch=function(e,r=void 0){return R$e(e,r).catch(n=>{throw dJ?fJ(n,dJ):n&&typeof n=="object"&&Error.captureStackTrace(n,ae.exports.fetch),n})};ae.exports.Headers=Cl().Headers;ae.exports.Response=Ih().Response;ae.exports.Request=pd().Request;ae.exports.FormData=oE().FormData;var{setGlobalOrigin:N$e,getGlobalOrigin:O$e}=uB();ae.exports.setGlobalOrigin=N$e;ae.exports.getGlobalOrigin=O$e;var{CacheStorage:x$e}=X4(),{kConstruct:U$e}=dt();ae.exports.caches=new x$e(U$e);var{deleteCookie:M$e,getCookies:P$e,getSetCookies:L$e,setCookie:$$e,parseCookie:F$e}=dW();ae.exports.deleteCookie=M$e;ae.exports.getCookies=P$e;ae.exports.getSetCookies=L$e;ae.exports.setCookie=$$e;ae.exports.parseCookie=F$e;var{parseMIMEType:j$e,serializeAMimeType:z$e}=ui();ae.exports.parseMIMEType=j$e;ae.exports.serializeAMimeType=z$e;var{CloseEvent:q$e,ErrorEvent:H$e,MessageEvent:G$e}=wI(),{WebSocket:Y$e,ping:V$e}=qW();ae.exports.WebSocket=Y$e;ae.exports.CloseEvent=q$e;ae.exports.ErrorEvent=H$e;ae.exports.MessageEvent=G$e;ae.exports.ping=V$e;ae.exports.WebSocketStream=KW().WebSocketStream;ae.exports.WebSocketError=qT().WebSocketError;ae.exports.request=Rh(_d.request);ae.exports.stream=Rh(_d.stream);ae.exports.pipeline=Rh(_d.pipeline);ae.exports.connect=Rh(_d.connect);ae.exports.upgrade=Rh(_d.upgrade);ae.exports.MockClient=I$e;ae.exports.MockCallHistory=C$e;ae.exports.MockCallHistoryLog=b$e;ae.exports.MockPool=w$e;ae.exports.MockAgent=S$e;ae.exports.SnapshotAgent=_$e;ae.exports.mockErrors=B$e;var{EventSource:W$e}=uJ();ae.exports.EventSource=W$e;function J$e(){globalThis.fetch=ae.exports.fetch,globalThis.Headers=ae.exports.Headers,globalThis.Response=ae.exports.Response,globalThis.Request=ae.exports.Request,globalThis.FormData=ae.exports.FormData,globalThis.WebSocket=ae.exports.WebSocket,globalThis.CloseEvent=ae.exports.CloseEvent,globalThis.ErrorEvent=ae.exports.ErrorEvent,globalThis.MessageEvent=ae.exports.MessageEvent,globalThis.EventSource=ae.exports.EventSource}ae.exports.install=J$e});var yJ=y(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:!0});vd.SuperglueClient=vd.SuperglueHttpError=void 0;var Bd=hn(),un=Ew(),Z$e=s_(),K$e=Tj(),X$e=ki(),Zs=UA(),eFe=MA(),Oh=14400*1e3,Nh;if(typeof globalThis.process<"u"&&globalThis.process.versions?.node)try{let{Agent:t}=gJ();Nh=new t({headersTimeout:Oh,bodyTimeout:Oh})}catch{}function mJ(t){if(t?.aborted)throw t.reason??new DOMException("Aborted","AbortError")}var LI=class extends Error{constructor(e,r,n,i){super(e),this.status=r,this.code=n,this.details=i,this.name="SuperglueHttpError"}};vd.SuperglueHttpError=LI;var JT=class{constructor({apiKey:e,apiEndpoint:r,onInfrastructureError:n,refreshToken:i,sseTokenProvider:o,tokenProvider:s}){if(!e&&!s)throw new Error("SuperglueClient requires either apiKey or tokenProvider");this.tokenProvider=s??(async()=>e),this.apiEndpoint=r??"https://api.superglue.cloud",this.sseManager=new Z$e.SSELogSubscriptionManager(this.apiEndpoint,o??this.tokenProvider,i),this.onInfrastructureError=n,this.refreshToken=i}async getApiKey(){return this.tokenProvider()}async fetchWithAuthRetry(e,r){let n=await this.getApiKey(),i=await e(n);if(i.status!==401||!this.refreshToken)return i;mJ(r);let o=await this.refreshToken();return mJ(r),!o||o===n?i:(i.body?.cancel(),e(o))}isInfrastructureError(e){return(0,X$e.isAbortError)(e)?!1:!!(e instanceof TypeError&&e.message.toLowerCase().includes("fetch")||e instanceof Error&&e.name==="TimeoutError")}async restRequest(e,r,n,i,o){let a=await(await this.restResponse({method:e,path:r,body:n,extraHeaders:i,requestInit:o})).text();if(a)return JSON.parse(a)}async restData(...e){return(await this.restRequest(...e)).data}async restResponse({method:e,path:r,body:n,extraHeaders:i,requestInit:o}){let s=`${this.apiEndpoint.replace(/\/$/,"")}${r}`,a=n!=null,c=typeof FormData<"u"&&n instanceof FormData,l=u=>{let d={Authorization:`Bearer ${u}`,...i};return a&&!c&&e!=="GET"&&(d["Content-Type"]="application/json"),fetch(s,{...o,method:e,headers:d,body:a?c?n:JSON.stringify(n):void 0,signal:o?.signal??AbortSignal.timeout(Oh),...Nh?{dispatcher:Nh}:{}})};return this.sendAuthorized(l,o?.signal)}async sendAuthorized(e,r){let n;try{n=await this.fetchWithAuthRetry(e,r)}catch(i){throw this.isInfrastructureError(i)&&this.onInfrastructureError?.(),i}if(!n.ok)throw await this.buildHttpError(n);return n}async uploadFiles(e,r){if(typeof r?.process!="boolean")throw new Error("process must be a boolean");if(e.length===0)return[];let n=e.map(u=>({...u,contentLength:u.contentLength??this.getUploadContentLength(u.content)})),o=(await this.restRequest("POST","/v1/files/uploads",{process:r.process,...r.allowUnprocessed?{allowUnprocessed:!0}:{},files:n.map(({fileName:u,contentType:d,contentLength:A})=>({fileName:u,contentLength:A,...d?{contentType:d}:{}}))})).data.files;if(o.length!==n.length)throw await Promise.all(o.map(u=>this.deleteFileUpload(u.id).catch(()=>{}))),new Error("Upload response did not match the selected files");let s=await Promise.allSettled(o.map(async(u,d)=>{let A=n[d],p=await fetch(u.uploadUrl,{method:"PUT",body:A.content,headers:{...u.uploadHeaders,...A.contentType?{"Content-Type":A.contentType}:{}},signal:AbortSignal.timeout(Math.min(Oh,u.expiresIn*1e3))});if(!p.ok)throw new Error(`Upload failed for ${A.fileName}: ${p.status} ${p.statusText}`);return u.id})),a=s.flatMap(u=>u.status==="fulfilled"?[u.value]:[]),c=new Map;if(a.length>0)try{let u=await this.restRequest("POST","/v1/files/uploads/complete",{fileIds:a});c=new Map(u.data.files.map(d=>[d.id,d]))}catch(u){c=new Map(a.map(d=>[d,{id:d,fileName:n[o.findIndex(A=>A.id===d)]?.fileName||d,contentLength:n[o.findIndex(A=>A.id===d)]?.contentLength||0,status:"failed",error:u instanceof Error?u.message:String(u)}]))}let l=o.map((u,d)=>{let A=s[d],p=n[d];return A.status==="rejected"?{id:u.id,fileName:p.fileName,contentLength:p.contentLength,status:"failed",error:A.reason instanceof Error?A.reason.message:String(A.reason)}:c.get(u.id)||{id:u.id,fileName:p.fileName,contentLength:p.contentLength,status:"failed",error:"Upload completion returned no result"}});return await Promise.all(l.filter(u=>u.status==="failed").map(u=>this.deleteFileUpload(u.id).catch(()=>{}))),l}async deleteFileUpload(e){await this.restRequest("DELETE",`/v1/files/uploads/${encodeURIComponent(e)}`)}getUploadContentLength(e){return typeof e=="string"?new TextEncoder().encode(e).byteLength:e instanceof Uint8Array?e.byteLength:e.size}async buildHttpError(e){e.status>=500&&this.onInfrastructureError?.();let r=await e.text(),n=`HTTP ${e.status}: ${r}`,i,o;try{let s=JSON.parse(r);s&&typeof s=="object"&&!Array.isArray(s)&&(o=s),typeof s?.code=="string"&&(i=s.code);let a=s.error;typeof a=="string"?n=a:a&&typeof a=="object"&&(n=a.message||JSON.stringify(a))}catch{}return new LI(n,e.status,i,o)}async streamRequest(e,r,n){let i=e.includes("?")?"&":"?",o=`${this.apiEndpoint.replace(/\/$/,"")}${e}${i}stream=true`,s=l=>fetch(o,{method:"POST",headers:{Authorization:`Bearer ${l}`,Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify(r),signal:n??AbortSignal.timeout(Oh),...Nh?{dispatcher:Nh}:{}}),a;try{a=await this.fetchWithAuthRetry(s,n)}catch(l){throw this.isInfrastructureError(l)&&this.onInfrastructureError?.(),l}if(!a.ok)throw await this.buildHttpError(a);if(!(a.headers.get("content-type")||"").includes("text/event-stream")){let l=await a.text();return l?JSON.parse(l):void 0}try{return await(0,K$e.consumeEventStreamResult)(a)}catch(l){throw this.isInfrastructureError(l)&&this.onInfrastructureError?.(),l}}async subscribeToLogsSSE(e={}){return this.sseManager.subscribeToLogs(e)}async disconnect(){await this.sseManager.disconnect()}async listMemoryNotes(e={}){let r=new URLSearchParams;e.scope&&r.set("scope",e.scope),e.query&&r.set("query",e.query);let n=r.toString();return this.restData("GET",`/v1/memory-notes${n?`?${n}`:""}`)}async createMemoryNote(e){return this.restData("POST","/v1/memory-notes",e)}async updateMemoryNote(e,r){return this.restData("PATCH",`/v1/memory-notes/${encodeURIComponent(e)}`,r)}async deleteMemoryNote(e){await this.restRequest("DELETE",`/v1/memory-notes/${encodeURIComponent(e)}`)}async clearMemoryNotes(e){return(await this.restRequest("DELETE",`/v1/memory-notes?scope=${e}`)).data.deleted}async getMe(){return this.restRequest("GET","/v1/me")}async completeOnboarding(){return this.restRequest("POST","/v1/me/onboarding/complete")}async runTool(e){let r=await this.restRequest("POST",`/v1/tools/${encodeURIComponent(e.toolId)}/run`,{inputs:e.payload,files:e.files,credentials:e.credentials,includeStepResultData:e.includeStepResultData,options:e.options,runId:e.runId,stateFixture:e.stateFixture},void 0,e.signal?{signal:e.signal}:void 0);return{success:r.status==="success",data:r.data,error:r.error,tool:r.tool,stepResults:r.stepResults?.map(n=>({...n}))||[],...r.fileArtifacts&&r.fileArtifacts.length>0?{fileArtifacts:r.fileArtifacts}:{},...r.metadata?.warnings?.length?{warnings:r.metadata.warnings}:{}}}async runToolConfig(e){let r=e.createRun?"/v1/tools/run?createRun=true":"/v1/tools/run",n=await this.restRequest("POST",r,{tool:e.tool,payload:e.payload,files:e.files,credentials:e.credentials,includeStepResultData:e.includeStepResultData,options:e.options,runId:e.runId,stateFixture:e.stateFixture,executionKind:e.executionKind,parentToolId:e.parentToolId,draftId:e.draftId},e.traceId?{"X-Trace-Id":e.traceId}:void 0,e.signal?{signal:e.signal}:void 0);return{success:n.status?n.status==="success":n.success??!1,data:n.data,error:n.error,tool:n.tool||e.tool,stepResults:n.stepResults?.map(o=>({...o}))||[],...n.fileArtifacts&&n.fileArtifacts.length>0?{fileArtifacts:n.fileArtifacts}:{},...n.metadata?.warnings?.length?{warnings:n.metadata.warnings}:{}}}async abortToolExecution(e){return{success:!0,runId:(await this.restRequest("POST",`/v1/runs/${encodeURIComponent(e)}/cancel`)).runId}}async executeStep({step:e,payload:r,files:n,previousResults:i,credentials:o,credentialsList:s,options:a,runId:c,systemIds:l,connectionId:u,systemAuth:d,createRun:A,parentToolId:p,stepIndex:h,stepId:f,signal:E,stream:S}){let B={step:e,payload:r,files:n,previousResults:i,credentials:o,credentialsList:s,options:a,runId:c,systemIds:l,connectionId:u,systemAuth:d,createRun:A,parentToolId:p,stepIndex:h,stepId:f};return S?this.streamRequest("/v1/tools/step/run",B,E):this.restRequest("POST","/v1/tools/step/run",B,void 0,E?{signal:E}:void 0)}async abortStep(e){return this.restRequest("POST","/v1/tools/step/abort",{runId:e})}async executeTransformOnly({outputTransform:e,outputSchema:r,inputSchema:n,payload:i,files:o,stepResults:s,options:a,runId:c,createRun:l,parentToolId:u,stepId:d,signal:A,stream:p}){let h={outputTransform:e,outputSchema:r,inputSchema:n,payload:i,files:o,stepResults:s,options:a,runId:c,createRun:l,parentToolId:u,stepId:d};return p?this.streamRequest("/v1/tools/transform/run",h,A):this.restRequest("POST","/v1/tools/transform/run",h,void 0,A?{signal:A}:void 0)}async createRun({toolId:e,toolConfig:r,toolResult:n,stepResults:i,toolPayload:o,status:s,error:a,startedAt:c,completedAt:l,executionKind:u,parentToolId:d,draftId:A}){return this.restRequest("POST","/v1/runs",{toolId:e,toolConfig:r,toolResult:n,stepResults:i,toolPayload:o,status:s,error:a,startedAt:(0,Zs.toUTCISOString)(c,"run.startedAt"),completedAt:(0,Zs.toUTCISOString)(l,"run.completedAt"),executionKind:u,parentToolId:d,draftId:A})}async checkRunLimit(){return this.restData("POST","/v1/runs/check-limit")}async extract({file:e,envelope:r}){if(!e)throw new Error("File must be provided for extract.");let n=new FormData;n.append("file",e);let i=r?"/v1/extract?envelope=true":"/v1/extract";return this.restRequest("POST",i,n)}mapOpenAPIRunToRun(e){let r={running:Bd.RunStatus.RUNNING,success:Bd.RunStatus.SUCCESS,failed:Bd.RunStatus.FAILED,aborted:Bd.RunStatus.ABORTED};return{runId:e.runId??e.id,toolId:e.toolId,tool:e.tool,systemIds:e.systemIds,status:r[e.status]??Bd.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??Bd.RunExecutionKind.FULL},fileArtifacts:e.fileArtifacts}}mapOpenAPIScheduleToToolSchedule(e){return{...e,lastRunAt:e.lastRunAt?(0,Zs.requireUTCDate)(e.lastRunAt,"schedule.lastRunAt"):void 0,nextRunAt:(0,Zs.requireUTCDate)(e.nextRunAt,"schedule.nextRunAt"),createdAt:(0,Zs.requireUTCDate)(e.createdAt,"schedule.createdAt"),updatedAt:(0,Zs.requireUTCDate)(e.updatedAt,"schedule.updatedAt")}}async listRuns(e={}){let r=(0,un.createSearchListQueryParams)(e);e.toolId!==void 0&&r.set("toolId",e.toolId),e.searchUserIds?.length&&r.set("searchUserIds",e.searchUserIds.join(",")),e.includeTotal!==void 0&&r.set("includeTotal",String(e.includeTotal)),e.startedAfter!==void 0&&r.set("startedAfter",e.startedAfter instanceof Date?(0,Zs.toUTCISOString)(e.startedAfter,"run.startedAfter"):e.startedAfter),e.statuses!==void 0?r.set("status",e.statuses.join(",")):e.status!==void 0&&r.set("status",e.status),e.requestSources!==void 0&&r.set("requestSources",e.requestSources.join(",")),e.executionKinds!==void 0&&r.set("executionKinds",e.executionKinds.join(",")),e.userId!==void 0&&r.set("userId",e.userId),e.systemId!==void 0&&r.set("systemId",e.systemId),e.systemIds!==void 0&&r.set("systemIds",e.systemIds.join(","));let n=r.size>0?`?${r.toString()}`:"",i=await this.restRequest("GET",`/v1/runs${n}`,void 0,void 0,{signal:e.signal});return{data:i.data.map(o=>this.mapOpenAPIRunToRun(o)),total:i.total,page:i.page,limit:i.limit,hasMore:i.hasMore}}async getComputeUsage(e){let r=new URLSearchParams({from:(0,Zs.toUTCISOString)(e.from,"computeUsage.from"),to:(0,Zs.toUTCISOString)(e.to,"computeUsage.to")});return this.restRequest("GET",`/v1/usage/compute?${r.toString()}`,void 0,void 0,{signal:e.signal})}async getRun(e){try{let r=await this.restRequest("GET",`/v1/runs/${encodeURIComponent(e)}`);return this.mapOpenAPIRunToRun(r)}catch(r){if(r.message?.includes("404")||r.message?.includes("not found"))return null;throw r}}async getTool(e){try{return await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}`)}catch(r){if(r.message?.includes("404")||r.message?.includes("not found")||r.message?.includes("403")||r.message?.includes("not allowed"))return null;throw r}}async getToolState(e){return(await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/state`)).state}async setToolState(e,r){await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/state`,{state:r})}async deleteToolState(e){return(await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/state`)).deletedKeys}async archiveTool(e,r=!0){return this.updateTool(e,{archived:r})}async bulkArchiveTools(e,r=!0){return this.restRequest("POST","/v1/tools/bulk/archive",{ids:e,archived:r})}async bulkDeleteTools(e){return this.restRequest("POST","/v1/tools/bulk/delete",{ids:e})}async listTools(e={}){let r=(0,un.createListQueryParams)(e);e.includeArchived!==void 0&&r.set("includeArchived",String(e.includeArchived));let n=r.size>0?`?${r.toString()}`:"";return this.restRequest("GET",`/v1/tools${n}`)}async listAllTools(e={}){return(0,un.listAllPages)((r,n)=>this.listTools({...e,page:r,limit:n}))}async createTool(e,r){return this.restRequest("POST","/v1/tools",{...r,id:e})}async updateTool(e,r){return this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}`,r)}async deleteTool(e){try{return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}`),!0}catch(r){if(r.message?.includes("404"))return!1;throw r}}async renameTool(e,r){return this.restRequest("POST",`/v1/tools/${encodeURIComponent(e)}/rename`,{newId:r})}async getWorkflow(e){return this.getTool(e)}async archiveWorkflow(e,r=!0){return this.upsertWorkflow(e,{archived:r})}async createWorkflow(e,r){return this.createTool(e,r)}async updateWorkflow(e,r){return this.updateTool(e,r)}async upsertWorkflow(e,r){return await this.getTool(e)?this.updateTool(e,r):this.createTool(e,r)}async deleteWorkflow(e){return this.deleteTool(e)}async renameWorkflow(e,r){return this.renameTool(e,r)}async listProjectSummaries(e={}){let r=(0,un.createSearchListQueryParams)(e);return r.set("includeResources","false"),e.includeArchived!==void 0&&r.set("includeArchived",String(e.includeArchived)),this.restRequest("GET",`/v1/projects?${r.toString()}`)}async listAllProjectSummaries({includeArchived:e}={}){return(0,un.listAllPages)((r,n)=>this.listProjectSummaries({page:r,limit:n,...e!==void 0?{includeArchived:e}:{}}))}async listAllProjectTasks(e){return(0,un.listAllPages)((r,n)=>this.restRequest("GET",`/v1/projects/${encodeURIComponent(e)}/tasks?page=${r}&limit=${n}`))}async saveProjectTask({projectId:e,taskId:r,input:n}){let i=`/v1/projects/${encodeURIComponent(e)}/tasks${r?`/${encodeURIComponent(r)}`:""}`;return this.restData(r?"PATCH":"POST",i,n)}async listAllProjectLabels(e){return(0,un.listAllPages)((r,n)=>this.restRequest("GET",`/v1/projects/${encodeURIComponent(e)}/labels?page=${r}&limit=${n}`))}async saveProjectLabel({projectId:e,labelId:r,input:n}){let i=`/v1/projects/${encodeURIComponent(e)}/labels${r?`/${encodeURIComponent(r)}`:""}`;return this.restData(r?"PATCH":"POST",i,n)}async deleteProjectLabel({projectId:e,labelId:r}){await this.restRequest("DELETE",`/v1/projects/${encodeURIComponent(e)}/labels/${encodeURIComponent(r)}`)}async listSchedules(e={}){let r=(0,un.createListQueryParams)(e),n=r.size>0?`?${r.toString()}`:"",i=e.toolId?`/v1/tools/${encodeURIComponent(e.toolId)}/schedules${n}`:`/v1/schedules${n}`,o=await this.restRequest("GET",i);return{...o,data:o.data.map(s=>this.mapOpenAPIScheduleToToolSchedule(s))}}async listAllSchedules(e={}){return(0,un.listAllPages)((r,n)=>this.listSchedules({...e,page:r,limit:n}))}async getToolSchedule(e,r){try{let n=await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(r)}`);return this.mapOpenAPIScheduleToToolSchedule(n)}catch(n){if(n.message?.includes("404")||n.message?.includes("not found"))return null;throw n}}async createToolSchedule(e,r){let n=await this.restRequest("POST",`/v1/tools/${encodeURIComponent(e)}/schedules`,{...r,timezone:r.timezone||(0,eFe.getRuntimeTimezone)()});return this.mapOpenAPIScheduleToToolSchedule(n)}async updateToolSchedule(e,r,n){let i=await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(r)}`,n);return this.mapOpenAPIScheduleToToolSchedule(i)}async deleteToolSchedule(e,r){return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(r)}`),!0}async bulkSetSchedulesEnabled(e,r){return this.restRequest("POST","/v1/schedules/bulk/enable",{ids:e,enabled:r})}async bulkDeleteSchedules(e){return this.restRequest("POST","/v1/schedules/bulk/delete",{ids:e})}async listConnections(e={}){let r=(0,un.createListQueryParams)(e);e.systemId!==void 0&&r.set("systemId",e.systemId);let n=r.size>0?`?${r.toString()}`:"";return this.restRequest("GET",`/v1/connections${n}`)}async listAllConnections(e={}){return(0,un.listAllPages)((r,n)=>this.listConnections({...e,page:r,limit:n}))}async createOAuthApp(e){return this.restData("POST","/v1/oauth-apps",e)}async updateOAuthApp(e,r){return this.restData("PUT",`/v1/oauth-apps/${encodeURIComponent(e)}`,r)}async deleteOAuthApp(e){await this.restRequest("DELETE",`/v1/oauth-apps/${encodeURIComponent(e)}`)}async listOAuthApps({systemId:e}={}){return(0,un.listAllPages)(async(r,n)=>{let i=new URLSearchParams({page:String(r),limit:String(n),...e?{systemId:e}:{}});return this.restRequest("GET",`/v1/oauth-apps?${i}`)})}async getConnectionSetup(e){return this.restData("GET",`/v1/connections/setup/${encodeURIComponent(e)}`)}async createConnection(e){return this.restData("POST","/v1/connections",e)}async replaceConnection(e,r){return this.restData("PUT",`/v1/connections/${encodeURIComponent(e)}`,{credentials:r})}async updateConnection(e,r){return this.restData("PATCH",`/v1/connections/${encodeURIComponent(e)}`,r)}async deleteConnection(e){await this.restRequest("DELETE",`/v1/connections/${encodeURIComponent(e)}`)}async setDefaultConnection(e){await this.restRequest("POST",`/v1/connections/${encodeURIComponent(e)}/default`)}async listSystems(e={}){let r=(0,un.createListQueryParams)(e),n=r.size>0?`?${r.toString()}`:"";return this.restRequest("GET",`/v1/systems${n}`)}async listAllSystems(e={}){return(0,un.listAllPages)((r,n)=>this.listSystems({...e,page:r,limit:n}))}async createOAuthExchange(e){return(await this.restRequest("POST","/v1/oauth/exchanges",e)).data}async completeOAuthExchange(e,r){return(await this.restRequest("POST",`/v1/oauth/exchanges/${encodeURIComponent(e)}/complete`,r)).data}async describeOAuthProviderPage(e){return(await this.restRequest("POST",`/v1/oauth/exchanges/${encodeURIComponent(e)}/provider-page`)).data}async generateCredentialsLink(e){try{return{success:!0,credentialsUrl:(await this.restRequest("POST","/v1/authenticate",e||{})).data.credentialsUrl}}catch(r){return{success:!1,error:r.message}}}};vd.SuperglueClient=JT});var IJ=y(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.UnquotedKeyStrategy=rr.TripleQuoteStrategy=rr.TrailingCommaStrategy=rr.SingleQuoteStrategy=rr.PythonLiteralStrategy=rr.CommentStrategy=rr.ResilientJsonParser=rr.RepairStrategy=void 0;rr.parseJsonResilient=tFe;rr.parseJSON=rFe;var Fi=class{validate(e){try{return JSON.parse(e),!0}catch{return!1}}};rr.RepairStrategy=Fi;var $I=class extends Fi{constructor(){super(...arguments),this.name="TripleQuoteRepair",this.description="Converts triple-quoted strings to proper JSON, parsing nested JSON content"}canApply(e){return/"""/.test(e)}apply(e){return e.replace(/"""([\s\S]*?)"""/g,(r,n)=>{let i=n.trim();if(i.startsWith("{")&&i.endsWith("}")||i.startsWith("[")&&i.endsWith("]"))try{let s=JSON.parse(i);return JSON.stringify(s)}catch{return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`})}};rr.TripleQuoteStrategy=$I;var FI=class extends Fi{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")}};rr.PythonLiteralStrategy=FI;var jI=class extends Fi{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")}};rr.TrailingCommaStrategy=jI;var zI=class extends Fi{constructor(){super(...arguments),this.name="SingleQuoteRepair",this.description="Converts single quotes to double quotes"}canApply(e){return/[{,]\s*'[^']*'\s*:/.test(e)||/:\s*'[^']*'/.test(e)}apply(e){let r=e.replace(/([{,]\s*)'([^']+)'(\s*:)/g,'$1"$2"$3');return r=r.replace(/(:\s*)'([^']+)'(\s*[,}])/g,'$1"$2"$3'),r}};rr.SingleQuoteStrategy=zI;var qI=class extends Fi{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')}};rr.UnquotedKeyStrategy=qI;var HI=class extends Fi{constructor(){super(...arguments),this.name="CommentRemoval",this.description="Removes JavaScript-style comments"}canApply(e){return/\/\/.*$|\/\*[\s\S]*?\*\//m.test(e)}apply(e){let r=e.replace(/\/\/.*$/gm,"");return r=r.replace(/\/\*[\s\S]*?\*\//g,""),r}};rr.CommentStrategy=HI;var ZT=class extends Fi{constructor(){super(...arguments),this.name="UnescapedControlCharactersRepair",this.description="Escapes unescaped control characters (newlines, tabs, etc.) in JSON strings"}canApply(e){try{return JSON.parse(e),!1}catch(r){let n=r.message||"";return n.includes("control character")||n.includes("Bad control")||n.includes("Unexpected token")&&/[\n\r\t]/.test(e)}}apply(e){let r="",n=!1,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=o>0?e[o-1]:"";if(i){r+=s,i=!1;continue}if(s==="\\"&&n){r+=s,i=!0;continue}if(s==='"'&&a!=="\\"){n=!n,r+=s;continue}if(n)switch(s){case`
|
|
2241
2241
|
`:r+="\\n";break;case"\r":r+="\\r";break;case" ":r+="\\t";break;case"\b":r+="\\b";break;case"\f":r+="\\f";break;default:let c=s.charCodeAt(0);c<32?r+="\\u"+("0000"+c.toString(16)).slice(-4):r+=s}else r+=s}return r}},KT=class extends Fi{constructor(){super(...arguments),this.name="TrailingCharactersRepair",this.description="Removes trailing characters after valid JSON structure"}canApply(e){let r=e.trim();if(!r.startsWith("{")&&!r.startsWith("["))return!1;let n=0,i=0,o=!1,s=!1;for(let a=0;a<r.length;a++){let c=r[a];if(o)s?s=!1:c==="\\"?s=!0:c==='"'&&(o=!1);else if(c==='"')o=!0;else if(c==="{")n++;else if(c==="}"){if(n--,n===0&&i===0&&a>0&&a<r.length-1)return!0}else if(c==="[")i++;else if(c==="]"&&(i--,i===0&&n===0&&a>0&&a<r.length-1))return!0}return!1}apply(e){let r=e.trim(),n=0,i=0,o=!1,s=!1,a=-1;for(let c=0;c<r.length;c++){let l=r[c];if(o)s?s=!1:l==="\\"?s=!0:l==='"'&&(o=!1);else if(l==='"')o=!0;else if(l==="{")n++;else if(l==="}"){if(n--,n===0&&i===0&&c>0){a=c;break}}else if(l==="[")i++;else if(l==="]"&&(i--,i===0&&n===0&&c>0)){a=c;break}}return a>0&&a<r.length-1?r.substring(0,a+1):e}},xh=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 $I,new zI,new ZT,new KT,new FI,new jI,new qI,new HI]}parse(e){let r=Date.now();this.repairLog=[];let n=e instanceof Buffer?e.toString("utf8"):String(e);try{return{success:!0,data:JSON.parse(n),metadata:{parseTime:Date.now()-r,strategiesApplied:[]}}}catch(s){if(!this.options.attemptRepair)return{success:!1,error:`JSON parse error: ${s}`,metadata:{parseTime:Date.now()-r}}}let i=n,o=[];for(let s of this.strategies)if(s.canApply(i)){let a=i;if(i=s.apply(i),a!==i){o.push(s.name),this.repairLog.push(s.description),this.options.logRepairs&&console.log(`Applied ${s.name}: ${s.description}`);try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-r,strategiesApplied:o}}}catch{}}}try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-r,strategiesApplied:o}}}catch(s){let a=this.aggressiveFallback(i);return a.success?{...a,repairs:[...this.repairLog,"Applied aggressive fallback"],metadata:{parseTime:Date.now()-r,strategiesApplied:[...o,"AggressiveFallback"]}}:{success:!1,error:`Failed to parse JSON after applying ${o.length} strategies: ${s}`,repairs:this.repairLog,metadata:{parseTime:Date.now()-r,strategiesApplied:o}}}}aggressiveFallback(e){try{let r=e.indexOf("{"),n=e.indexOf("[");if(r===-1&&n===-1)return{success:!1,error:"No JSON-like structure found"};let i=r===-1?n:n===-1?r:Math.min(r,n),o=e.substring(i);for(let a of this.strategies)a.canApply(o)&&(o=a.apply(o));return{success:!0,data:JSON.parse(o)}}catch(r){return{success:!1,error:`Aggressive fallback failed: ${r}`}}}addStrategy(e){this.strategies.push(e)}removeStrategy(e){this.strategies=this.strategies.filter(r=>r.name!==e)}getStrategies(){return this.strategies.map(e=>e.name)}};rr.ResilientJsonParser=xh;var EJ=new xh;function tFe(t,e){return(e?new xh(e):EJ).parse(t)}function rFe(t){let e=EJ.parse(t);if(e.success)return e.repairs&&e.repairs.length>0&&console.log("JSON parsed with repairs:",e.repairs),e.data;throw new Error(`Failed to parse JSON: ${e.error}`)}});var bJ=y(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.MANAGED_OAUTH_APP_PREFIX=void 0;Er.projectOAuthAppAuthentication=oFe;Er.withoutOAuthAppOwnedFields=sFe;Er.hasOAuthClientChanged=aFe;Er.isDynamicOAuthConfiguration=cFe;Er.isReusableOAuthAppForTemplate=lFe;Er.findOrganizationOAuthApp=uFe;Er.getManagedOAuthTemplateId=CJ;Er.getOAuthAppSharedConfiguration=dFe;Er.copyOAuthAppConfiguration=AFe;Er.encryptConnectionAuthentication=pFe;Er.decryptConnectionAuthentication=hFe;Er.isManagedOAuthEndpointAllowed=fFe;var nFe=xy(),iFe=ki();function oFe(t){let{clientSecret:e,config:r,...n}=t,{extraHeaders:i,extraBodyParams:o,...s}=r??{};return{...n,...r?{config:s}:{}}}function sFe(t){if(!t.oauthAppId)return t;let{clientId:e,clientSecret:r,tokenUrl:n,...i}=t;return CJ(t)&&n?{...i,tokenUrl:n}:i}function aFe(t,e){return t.type!=="oauth2"?!1:e.type!=="oauth2"?!0:t.oauthAppId||e.oauthAppId?t.oauthAppId!==e.oauthAppId:t.clientId!==e.clientId}Er.MANAGED_OAUTH_APP_PREFIX="managed:";function cFe({authentication:t,template:e}){return t.oauthClientMode==="dynamic"||!!e?.oauth?.registrationUrl&&!t.clientSecret}function lFe({app:t,template:e}){return!e?.oauth?.registrationUrl||!!t.clientSecretHash}function uFe({apps:t,systemId:e,templateId:r}){return t.filter(n=>n.source==="organization"&&(n.systemId===e||r!==void 0&&n.templateId===r)).sort((n,i)=>(n.createdAt??"").localeCompare(i.createdAt??""))[0]}function CJ(t){if(t?.type==="oauth2")return t.oauthAppId?.startsWith(Er.MANAGED_OAUTH_APP_PREFIX)?t.oauthAppId.slice(Er.MANAGED_OAUTH_APP_PREFIX.length):void 0}function dFe(t){let{grantType:e,scopes:r,oauthAppId:n,...i}=t;return i}function AFe({appAuthentication:t,authentication:e}){if(e?.type!=="oauth2")return{...t};let r=Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));return{...t,...r,config:{...t.config,...e.config}}}function pFe({authentication:t,encrypt:e}){if(t.type!=="oauth2")return t;let r={...t,config:{...t.config}};t.clientSecret!==void 0&&(r.clientSecret=e({value:t.clientSecret}).value);for(let n of["extraHeaders","extraBodyParams"]){let i=t.config?.[n];i!==void 0&&(r.config[n]=e({value:(0,iFe.safeStringify)(i)}).value)}return r}function hFe({authentication:t,decrypt:e}){if(t.type!=="oauth2")return t;let r={...t,config:{...t.config}};t.clientSecret!==void 0&&(r.clientSecret=e({value:t.clientSecret}).value);for(let n of["extraHeaders","extraBodyParams"]){let i=t.config?.[n];typeof i=="string"&&(r.config[n]=JSON.parse(e({value:i}).value))}return r}function fFe({templateId:t,endpoint:e,url:r}){let n=nFe.systems[t]?.oauth,i=n?.[e];if(!n?.managed||!i)return!1;try{let o=new URL(r),s=new URL(i);return o.protocol!=="https:"||o.port||o.username||o.password||o.hash||o.pathname!==s.pathname?!1:o.hostname===s.hostname||(n.managedEndpointHosts??[]).some(a=>a.startsWith("*.")?o.hostname.endsWith(a.slice(1)):o.hostname===a)}catch{return!1}}});var wJ=y(SJ=>{"use strict";Object.defineProperty(SJ,"__esModule",{value:!0})});var zr=y(Z=>{"use strict";var gFe=Z&&Z.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),ue=Z&&Z.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&gFe(e,t,r)};Object.defineProperty(Z,"__esModule",{value:!0});Z.SSELogSubscriptionManager=Z.SuperglueHttpError=Z.SuperglueClient=void 0;ue(MC(),Z);ue(UP(),Z);ue(Bm(),Z);ue(HP(),Z);ue(nL(),Z);ue(oL(),Z);ue(uL(),Z);ue(dL(),Z);ue(pL(),Z);ue(uw(),Z);ue($L(),Z);ue(FL(),Z);ue(mg(),Z);ue(GL(),Z);ue(YL(),Z);ue(VL(),Z);ue(WL(),Z);ue(Ew(),Z);ue(t$(),Z);ue(Iw(),Z);ue(o$(),Z);ue(pu(),Z);ue(A$(),Z);ue(bw(),Z);ue(aF(),Z);ue(Zw(),Z);ue(t0(),Z);ue(lF(),Z);ue(uF(),Z);ue(AF(),Z);ue(a1(),Z);ue(l1(),Z);ue(u1(),Z);ue(A1(),Z);ue(p1(),Z);ue(T1(),Z);ue(D0(),Z);ue(iy(),Z);ue(T0(),Z);ue(O1(),Z);ue(U1(),Z);ue(P0(),Z);ue(q1(),Z);ue(vm(),Z);ue(Z1(),Z);ue(X1(),Z);ue(Qm(),Z);ue(Q0(),Z);ue(fj(),Z);ue(gj(),Z);ue(xy(),Z);ue(Ij(),Z);ue(Cj(),Z);ue(bj(),Z);ue(_j(),Z);ue(vj(),Z);ue(hn(),Z);ue(ki(),Z);ue(Qj(),Z);ue(Z0(),Z);ue(UA(),Z);ue(MA(),Z);var _J=yJ();Object.defineProperty(Z,"SuperglueClient",{enumerable:!0,get:function(){return _J.SuperglueClient}});Object.defineProperty(Z,"SuperglueHttpError",{enumerable:!0,get:function(){return _J.SuperglueHttpError}});var mFe=s_();Object.defineProperty(Z,"SSELogSubscriptionManager",{enumerable:!0,get:function(){return mFe.SSELogSubscriptionManager}});ue(IJ(),Z);ue(bJ(),Z);ue(wJ(),Z)});var TC=require("commander");var dn=Be(require("fs")),QJ=Be(require("os")),Ks=Be(require("path")),Uh=Be(zr()),BJ=new Set(["runner","builder","admin"]),vJ={output:{mode:"stdout",directory:".superglue/output"},preset:"admin"};function Xs(t){let e=Ks.join(process.cwd(),".superglue"),r=QJ.homedir();if(!r)return e;let n=Ks.join(r,".superglue");return t===!0?e:t===!1?n:dn.existsSync(Ks.join(e,"config.json"))?e:n}function XT(t){return Ks.join(Xs(t),"config.json")}function GI(t){let e=XT(t);if(!dn.existsSync(e))return{};try{return JSON.parse(dn.readFileSync(e,"utf-8"))}catch{return{}}}function Qd(t){let e=GI(),r=t.apiKey||(0,Uh.readProcessEnvironmentValue)("SUPERGLUE_API_KEY")||e.apiKey||"",n=t.endpoint||(0,Uh.readProcessEnvironmentValue)("SUPERGLUE_API_ENDPOINT")||e.endpoint||"https://api.superglue.cloud",i=(0,Uh.readProcessEnvironmentValue)("SUPERGLUE_WEB_ENDPOINT")||e.webEndpoint||n.replace(/:3002\b/,":3001").replace(/api\.superglue/,"app.superglue"),o=(0,Uh.readProcessEnvironmentValue)("SUPERGLUE_CLI_PRESET"),s=o&&BJ.has(o)?o:e.preset&&BJ.has(e.preset)?e.preset:"admin";return{...vJ,...e,apiKey:r,endpoint:n,webEndpoint:i,preset:s,output:{...vJ.output,...e.output}}}function YI(t,e){let r=Xs(e);dn.existsSync(r)||dn.mkdirSync(r,{recursive:!0}),dn.writeFileSync(Ks.join(r,"config.json"),JSON.stringify(t,null,2)+`
|
|
2242
|
-
`,{mode:384})}function VI(t,e){let r=Ks.join(Xs(e),"drafts");if(dn.existsSync(r)||dn.mkdirSync(r,{recursive:!0}),t.output.mode==="stdout+file"){let n=Ks.resolve(t.output.directory);dn.existsSync(n)||dn.mkdirSync(n,{recursive:!0})}}var sD=Be(zr());var eD=Be(require("readline"));var kJ=require("child_process"),RJ=require("util");var TJ={name:"@superglue/cli",version:"1.1.
|
|
2242
|
+
`,{mode:384})}function VI(t,e){let r=Ks.join(Xs(e),"drafts");if(dn.existsSync(r)||dn.mkdirSync(r,{recursive:!0}),t.output.mode==="stdout+file"){let n=Ks.resolve(t.output.directory);dn.existsSync(n)||dn.mkdirSync(n,{recursive:!0})}}var sD=Be(zr());var eD=Be(require("readline"));var kJ=require("child_process"),RJ=require("util");var TJ={name:"@superglue/cli",version:"1.1.255",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 EFe=(0,RJ.promisify)(kJ.exec),qr=TJ.version;function DJ(t){let e=t.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:t}}function JI(t,e){let r=t.split("."),n=e.split("."),i=Math.max(r.length,n.length);for(let o=0;o<i;o++){let s=DJ(r[o]||"0"),a=DJ(n[o]||"0");if(s.numeric<a.numeric)return-1;if(s.numeric>a.numeric||s.prerelease===null&&a.prerelease!==null)return 1;if(s.prerelease!==null&&a.prerelease===null)return-1;if(s.prerelease!==null&&a.prerelease!==null){if(s.prerelease<a.prerelease)return-1;if(s.prerelease>a.prerelease)return 1}}return 0}async function ZI(){try{let t=await fetch("https://registry.npmjs.org/@superglue/cli/latest",{signal:AbortSignal.timeout(5e3)});return t.ok&&(await t.json()).version||null}catch{return null}}var WI=null;function NJ(){Ie()&&(WI=ZI())}async function OJ(){if(!(!Ie()||!WI)){try{let t=new Promise(r=>{setTimeout(()=>r(null),2e3).unref()}),e=await Promise.race([WI,t]);e&&JI(qr,e)<0&&(console.error(""),console.error(`${C.cyan}${C.bold} Update available: ${qr} \u2192 ${e}${C.reset}`),console.error(`${C.cyan} Run ${C.bold}sg update${C.reset}${C.cyan} to upgrade${C.reset}`),console.error(""))}catch{}WI=null}}async function xJ(){let t=await ZI();if(!t)return{success:!1,message:"Could not fetch latest version from npm"};if(JI(qr,t)>=0)return{success:!0,message:`Already on latest version (${qr})`};try{return await EFe("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${qr} to ${t}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var Ie=()=>process.argv.includes("--table")&&process.stdout.isTTY,Ei=()=>process.argv.includes("--full"),C={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 UJ(t,e){let r=e||t;return`\x1B]8;;${t}\x07${C.underline}${C.cyan}${r}${C.reset}\x1B]8;;\x07`}function MJ(){if(!Ie())return;let t=C.reset,e=C.dim,r="\x1B[47;30m",n=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),n.forEach(i=>{let o=i.search(/\S/),s=i.length-[...i].reverse().join("").search(/\S/)-1;if(o===-1)return console.log(" "+i);let a=i.slice(0,o),c=i.slice(o,s+1).split("").map(u=>u===" "?" ":"\u2588").join(""),l=i.slice(s+1);console.log(` ${a}${r}${c}${t}${l}`)}),console.log(` ${e} CLI v${qr}${t}`),console.log("")}function nr(t){if(!Ie())return{stop:()=>{},update:()=>{},log:()=>{}};let e=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],r=0,n=t,i=()=>process.stdout.write("\r\x1B[2K"),o=()=>{process.stdout.write(`\r ${C.cyan}${e[r++%e.length]}${C.reset} ${n}`)},s=setInterval(o,80);return{update:a=>{n=a},log:a=>{i(),console.log(` ${C.dim}\u2502${C.reset} ${a}`),o()},stop:a=>{clearInterval(s),i(),a&&console.log(` ${a}`)}}}function de(t){Ie()?KI(t):console.log(JSON.stringify(t,null,2))}function Me(t,e){Ie()?(console.log(` ${C.green}\u2713${C.reset} ${t}`),e&&KI(e,4)):console.log(JSON.stringify({success:!0,message:t,...e&&typeof e=="object"?e:{data:e}}))}function D(t,e){Ie()?(console.error(` ${C.red}\u2717${C.reset} ${t}`),e&&KI(e,4)):console.error(JSON.stringify({success:!1,error:t,details:e}))}function $n(t){Ie()&&console.log(` ${C.dim}${t}${C.reset}`)}function Dl(t){Ie()&&(console.log(`
|
|
2243
2243
|
${C.bold}${C.cyan}${t}${C.reset}`),console.log(` ${C.dim}${"\u2500".repeat(t.length)}${C.reset}`))}function lr(t,e,r){if(!Ie()){console.log(JSON.stringify({success:!0,total:r?.total??t.length,items:t}));return}if(t.length===0){console.log(`
|
|
2244
2244
|
${C.dim}0 results${C.reset}
|
|
2245
2245
|
`);return}let n=e||Object.keys(t[0]),i=Ei()?1/0:60,o=n.map(u=>Math.min(i,Math.max(u.length,...t.map(d=>String(d[u]??"").replace(/[\n\r]+/g," ").trim().length))));console.log("");let s=n.map((u,d)=>`${C.bold}${C.cyan}${u.toUpperCase().padEnd(o[d])}${C.reset}`).join(" ");console.log(` ${s}`);let a=o.map(u=>`${C.dim}${"\u2500".repeat(u)}${C.reset}`).join(`${C.dim}\u2500\u2500${C.reset}`);console.log(` ${a}`);for(let u of t){let d=n.map((A,p)=>{let h=String(u[A]??"").replace(/[\n\r]+/g," ").trim();if(h.length>i){let E=`\u2026 (${h.length})`;h=h.slice(0,Math.max(0,i-E.length))+`${C.dim}${E}${C.reset}`}return A==="status"?`${{success:C.green,running:C.yellow,failed:C.red,aborted:C.red,error:C.red,pending:C.dim}[h.toLowerCase()]||""}${h.padEnd(o[p])}${C.reset}`:h.padEnd(o[p])}).join(" ");console.log(` ${d}`)}let c=r?.total??t.length,l=c===t.length?`${t.length} result${t.length===1?"":"s"}`:`${t.length} of ${c} result${c===1?"":"s"}`;console.log(`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: superglue
|
|
3
|
-
description: "Build, test, deploy and integrate superglue tools
|
|
3
|
+
description: "Build, test, deploy, and integrate superglue tools with the sg CLI and superglue SDKs. Load before running any sg command or writing superglue SDK, REST, or webhook integration code, then run `sg skill <topic>` for the protocols and topics involved."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# superglue CLI (`sg`) — Agent Reference
|
|
@@ -30,7 +30,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
|
|
|
30
30
|
| `sg skill access-rules` | RBAC roles, resource grants, and tool/credential permissions (enterprise only) |
|
|
31
31
|
| `sg skill superglue-email` | Custom report and notification emails with attachments through superglue's email service |
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Before You Start
|
|
34
34
|
|
|
35
35
|
**Pre-requisites for using the CLI**
|
|
36
36
|
|
|
@@ -40,7 +40,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
|
|
|
40
40
|
|
|
41
41
|
**Calling systems and running tools**
|
|
42
42
|
|
|
43
|
-
1.
|
|
43
|
+
1. Pull the relevant system context with `sg system find` before calling system endpoints and before building tools.
|
|
44
44
|
2. Consult provider documentation when an API or service behavior is unclear.
|
|
45
45
|
|
|
46
46
|
**Authentication & Credentials**
|
|
@@ -146,8 +146,6 @@ Blocked commands print a clear error showing the current preset and how to chang
|
|
|
146
146
|
|
|
147
147
|
Systems are derived: a connection namespace is derived from existing connections. There is no system record to create or edit; you create and edit your connection.
|
|
148
148
|
|
|
149
|
-
Removed commands (`sg system create`, `edit`, `credentials`, and `search-docs`) return a deprecation error with `sg update` and replacement guidance. Removed system API endpoints return HTTP 410 with the same guidance. Run `sg update`, then use connection commands; use `sg system find --id <id>` for system knowledge. Legacy `/credentials` API aliases remain available with deprecation headers.
|
|
150
|
-
|
|
151
149
|
Match accessible owned and shared connections to the requested account, tenant, and environment, even across different system IDs. Respect an explicit connection choice or request for separate access. Otherwise, prefer suitable existing access; ask only when the account or connection choice is unclear. Defaults apply within one system ID and do not establish authentication or suitability.
|
|
152
150
|
|
|
153
151
|
1. Read the relevant tool's namespace first, then inspect existing namespaces with `sg system find <query>`. List accessible connections in each candidate namespace with `sg system connection list --system-id <id>`. Reuse an existing id for the same logical service; preserve IDs referenced by saved tools. For a new namespace, use the template id, not its display name. Without a template, choose a descriptive id. Keep account labels in connection names; separate namespaces when tools need distinct services or environments.
|
|
@@ -157,7 +155,7 @@ Match accessible owned and shared connections to the requested account, tenant,
|
|
|
157
155
|
5. Verify connectivity with `sg system call`
|
|
158
156
|
6. For updates: re-run `sg system connection set --system-id <id>` with the fields to change. When the namespace holds several connections, pass `--connection-id <id>` from `sg system connection list` to `set`, `clear`, `oauth`, and `call`; without it, `set` and `oauth` target your default or oldest owned connection
|
|
159
157
|
|
|
160
|
-
A connection linked to an OAuth app uses the app's client ID, client secret, and token URL; app secret rotations reach every linked connection. Other authentication fields are copied on selection and stay connection-specific; scope edits remain local. Changing the client ID or token URL detaches the connection and requires its own client secret; `--oauth-app-id ""` also detaches and must be sent together with the connection's own client secret.
|
|
158
|
+
A connection linked to an OAuth app uses the app's client ID, client secret, and token URL; app secret rotations reach every linked connection. Other authentication fields are copied on selection and stay connection-specific; scope edits remain local. Changing the client ID or token URL detaches the connection and requires its own client secret; `--oauth-app-id ""` also detaches and must be sent together with the connection's own client secret. Linking, switching, or detaching an app, or changing the client ID, deletes the connection's OAuth tokens; authorize again afterward. Other authentication changes keep tokens and supplemental secrets. Managed secrets stay hidden and restricted to approved provider endpoints. Every org member can use any organization OAuth app; its creator and administrators edit it. Client credentials connections keep their own client ID and secret and never take `--oauth-app-id`.
|
|
161
159
|
|
|
162
160
|
When selecting an OAuth app on an existing non-OAuth connection, also pass `--authentication '{"type":"oauth2"}'`. An app-only update to a non-OAuth connection returns a validation error.
|
|
163
161
|
|
|
@@ -448,7 +446,7 @@ Object/array return values are `JSON.stringify`'d automatically when spliced int
|
|
|
448
446
|
|
|
449
447
|
```javascript
|
|
450
448
|
sourceData = {
|
|
451
|
-
// Payload fields at
|
|
449
|
+
// Payload fields at root level, not under sourceData.payload
|
|
452
450
|
userId: "123",
|
|
453
451
|
date: "2024-01-15",
|
|
454
452
|
|
|
@@ -483,7 +481,7 @@ sourceData = {
|
|
|
483
481
|
- Batch continuation: process a large import in manageable batches and save the next cursor, so each scheduled run continues where the previous run stopped.
|
|
484
482
|
- Polling-based change detection: poll an API on a schedule, compare its version or fingerprint with the previous result, and trigger follow-up work only when it changes. This is useful when the provider lacks the required webhook.
|
|
485
483
|
- Incremental syncs and dedupe: store a timestamp or cursor for new records, or a bounded set such as `persistedState.seenIds`.
|
|
486
|
-
- State gives at-least-once execution with progress tracking, never exactly-once: crashes, concurrent-run conflicts, and state resets all cause re-processing, which re-executes side effects. Steps that write to external systems
|
|
484
|
+
- State gives at-least-once execution with progress tracking, never exactly-once: crashes, concurrent-run conflicts, and state resets all cause re-processing, which re-executes side effects. Steps that write to external systems must be replay-safe — upsert by a stable external id or pass an idempotency key — or duplicates will land in the target system.
|
|
487
485
|
- Keep set-valued keys bounded (e.g. keep only the most recent ~1,000 ids): an unbounded set eventually exceeds the 64KB value limit, which rejects the tool's entire state write on every run.
|
|
488
486
|
- Never copy credential values into state — state is stored unencrypted and readable by anyone with read access to the tool.
|
|
489
487
|
- Inspect current state via `sg tool state get <toolId>` (values matching known connection secrets are masked); reset it via `sg tool state reset <toolId>`. A reset wins over in-flight runs: their updates to pre-reset keys are discarded as conflicts; only keys they newly add are kept.
|
|
@@ -502,13 +500,13 @@ Safe naming: payload inputs get specific, domain-flavored names (`customerId`, `
|
|
|
502
500
|
|
|
503
501
|
### Step Result Envelopes
|
|
504
502
|
|
|
505
|
-
**Every** step result is wrapped in `{ currentItem, data, success }`.
|
|
503
|
+
**Every** step result is wrapped in `{ currentItem, data, success }`. Account for it when writing data selectors or transforms.
|
|
506
504
|
|
|
507
505
|
- **Object selector (or none)** — access via `sourceData.stepId.data`
|
|
508
506
|
- **Array selector (loop)** — array of envelopes: `sourceData.stepId.map(i => i.data)`
|
|
509
507
|
- **Paginated step** — all pages merged into a single `.data` field: access via `sourceData.stepId.data`. Do NOT `.map()` over it — returns a single object if one result, array if multiple (unwrapped from single-element array).
|
|
510
508
|
|
|
511
|
-
|
|
509
|
+
Read step results through `.data`: `sourceData.stepId.results` hits the envelope, not the API response.
|
|
512
510
|
|
|
513
511
|
### Data Selectors
|
|
514
512
|
|
|
@@ -561,7 +559,7 @@ All user-provided JS runs in an isolated Deno sandbox.
|
|
|
561
559
|
|
|
562
560
|
### Connections and placeholders
|
|
563
561
|
|
|
564
|
-
Secrets are referenced by name as `<<systemId_credentialKey>>` and resolved from the selected connection at execution time.
|
|
562
|
+
Secrets are referenced by name as `<<systemId_credentialKey>>` and resolved from the selected connection at execution time. Reference them explicitly:
|
|
565
563
|
|
|
566
564
|
```
|
|
567
565
|
System id="stripe", selected connection has secret named: api_key
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: superglue
|
|
3
|
-
description: "Build, test, deploy and integrate superglue tools
|
|
3
|
+
description: "Build, test, deploy, and integrate superglue tools with the sg CLI and superglue SDKs. Load before running any sg command or writing superglue SDK, REST, or webhook integration code, then run `sg skill <topic>` for the protocols and topics involved."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# superglue CLI (`sg`) — Agent Reference
|
|
@@ -30,7 +30,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
|
|
|
30
30
|
| `sg skill access-rules` | RBAC roles, resource grants, and tool/credential permissions (enterprise only) |
|
|
31
31
|
| `sg skill superglue-email` | Custom report and notification emails with attachments through superglue's email service |
|
|
32
32
|
|
|
33
|
-
##
|
|
33
|
+
## Before You Start
|
|
34
34
|
|
|
35
35
|
**Pre-requisites for using the CLI**
|
|
36
36
|
|
|
@@ -40,7 +40,7 @@ Read these on demand — they are authoritative for their topic and kept in sync
|
|
|
40
40
|
|
|
41
41
|
**Calling systems and running tools**
|
|
42
42
|
|
|
43
|
-
1.
|
|
43
|
+
1. Pull the relevant system context with `sg system find` before calling system endpoints and before building tools.
|
|
44
44
|
2. Consult provider documentation when an API or service behavior is unclear.
|
|
45
45
|
|
|
46
46
|
**Authentication & Credentials**
|
|
@@ -146,8 +146,6 @@ Blocked commands print a clear error showing the current preset and how to chang
|
|
|
146
146
|
|
|
147
147
|
Systems are derived: a connection namespace is derived from existing connections. There is no system record to create or edit; you create and edit your connection.
|
|
148
148
|
|
|
149
|
-
Removed commands (`sg system create`, `edit`, `credentials`, and `search-docs`) return a deprecation error with `sg update` and replacement guidance. Removed system API endpoints return HTTP 410 with the same guidance. Run `sg update`, then use connection commands; use `sg system find --id <id>` for system knowledge. Legacy `/credentials` API aliases remain available with deprecation headers.
|
|
150
|
-
|
|
151
149
|
Match accessible owned and shared connections to the requested account, tenant, and environment, even across different system IDs. Respect an explicit connection choice or request for separate access. Otherwise, prefer suitable existing access; ask only when the account or connection choice is unclear. Defaults apply within one system ID and do not establish authentication or suitability.
|
|
152
150
|
|
|
153
151
|
1. Read the relevant tool's namespace first, then inspect existing namespaces with `sg system find <query>`. List accessible connections in each candidate namespace with `sg system connection list --system-id <id>`. Reuse an existing id for the same logical service; preserve IDs referenced by saved tools. For a new namespace, use the template id, not its display name. Without a template, choose a descriptive id. Keep account labels in connection names; separate namespaces when tools need distinct services or environments.
|
|
@@ -157,7 +155,7 @@ Match accessible owned and shared connections to the requested account, tenant,
|
|
|
157
155
|
5. Verify connectivity with `sg system call`
|
|
158
156
|
6. For updates: re-run `sg system connection set --system-id <id>` with the fields to change. When the namespace holds several connections, pass `--connection-id <id>` from `sg system connection list` to `set`, `clear`, `oauth`, and `call`; without it, `set` and `oauth` target your default or oldest owned connection
|
|
159
157
|
|
|
160
|
-
A connection linked to an OAuth app uses the app's client ID, client secret, and token URL; app secret rotations reach every linked connection. Other authentication fields are copied on selection and stay connection-specific; scope edits remain local. Changing the client ID or token URL detaches the connection and requires its own client secret; `--oauth-app-id ""` also detaches and must be sent together with the connection's own client secret.
|
|
158
|
+
A connection linked to an OAuth app uses the app's client ID, client secret, and token URL; app secret rotations reach every linked connection. Other authentication fields are copied on selection and stay connection-specific; scope edits remain local. Changing the client ID or token URL detaches the connection and requires its own client secret; `--oauth-app-id ""` also detaches and must be sent together with the connection's own client secret. Linking, switching, or detaching an app, or changing the client ID, deletes the connection's OAuth tokens; authorize again afterward. Other authentication changes keep tokens and supplemental secrets. Managed secrets stay hidden and restricted to approved provider endpoints. Every org member can use any organization OAuth app; its creator and administrators edit it. Client credentials connections keep their own client ID and secret and never take `--oauth-app-id`.
|
|
161
159
|
|
|
162
160
|
When selecting an OAuth app on an existing non-OAuth connection, also pass `--authentication '{"type":"oauth2"}'`. An app-only update to a non-OAuth connection returns a validation error.
|
|
163
161
|
|
|
@@ -448,7 +446,7 @@ Object/array return values are `JSON.stringify`'d automatically when spliced int
|
|
|
448
446
|
|
|
449
447
|
```javascript
|
|
450
448
|
sourceData = {
|
|
451
|
-
// Payload fields at
|
|
449
|
+
// Payload fields at root level, not under sourceData.payload
|
|
452
450
|
userId: "123",
|
|
453
451
|
date: "2024-01-15",
|
|
454
452
|
|
|
@@ -483,7 +481,7 @@ sourceData = {
|
|
|
483
481
|
- Batch continuation: process a large import in manageable batches and save the next cursor, so each scheduled run continues where the previous run stopped.
|
|
484
482
|
- Polling-based change detection: poll an API on a schedule, compare its version or fingerprint with the previous result, and trigger follow-up work only when it changes. This is useful when the provider lacks the required webhook.
|
|
485
483
|
- Incremental syncs and dedupe: store a timestamp or cursor for new records, or a bounded set such as `persistedState.seenIds`.
|
|
486
|
-
- State gives at-least-once execution with progress tracking, never exactly-once: crashes, concurrent-run conflicts, and state resets all cause re-processing, which re-executes side effects. Steps that write to external systems
|
|
484
|
+
- State gives at-least-once execution with progress tracking, never exactly-once: crashes, concurrent-run conflicts, and state resets all cause re-processing, which re-executes side effects. Steps that write to external systems must be replay-safe — upsert by a stable external id or pass an idempotency key — or duplicates will land in the target system.
|
|
487
485
|
- Keep set-valued keys bounded (e.g. keep only the most recent ~1,000 ids): an unbounded set eventually exceeds the 64KB value limit, which rejects the tool's entire state write on every run.
|
|
488
486
|
- Never copy credential values into state — state is stored unencrypted and readable by anyone with read access to the tool.
|
|
489
487
|
- Inspect current state via `sg tool state get <toolId>` (values matching known connection secrets are masked); reset it via `sg tool state reset <toolId>`. A reset wins over in-flight runs: their updates to pre-reset keys are discarded as conflicts; only keys they newly add are kept.
|
|
@@ -502,13 +500,13 @@ Safe naming: payload inputs get specific, domain-flavored names (`customerId`, `
|
|
|
502
500
|
|
|
503
501
|
### Step Result Envelopes
|
|
504
502
|
|
|
505
|
-
**Every** step result is wrapped in `{ currentItem, data, success }`.
|
|
503
|
+
**Every** step result is wrapped in `{ currentItem, data, success }`. Account for it when writing data selectors or transforms.
|
|
506
504
|
|
|
507
505
|
- **Object selector (or none)** — access via `sourceData.stepId.data`
|
|
508
506
|
- **Array selector (loop)** — array of envelopes: `sourceData.stepId.map(i => i.data)`
|
|
509
507
|
- **Paginated step** — all pages merged into a single `.data` field: access via `sourceData.stepId.data`. Do NOT `.map()` over it — returns a single object if one result, array if multiple (unwrapped from single-element array).
|
|
510
508
|
|
|
511
|
-
|
|
509
|
+
Read step results through `.data`: `sourceData.stepId.results` hits the envelope, not the API response.
|
|
512
510
|
|
|
513
511
|
### Data Selectors
|
|
514
512
|
|
|
@@ -561,7 +559,7 @@ All user-provided JS runs in an isolated Deno sandbox.
|
|
|
561
559
|
|
|
562
560
|
### Connections and placeholders
|
|
563
561
|
|
|
564
|
-
Secrets are referenced by name as `<<systemId_credentialKey>>` and resolved from the selected connection at execution time.
|
|
562
|
+
Secrets are referenced by name as `<<systemId_credentialKey>>` and resolved from the selected connection at execution time. Reference them explicitly:
|
|
565
563
|
|
|
566
564
|
```
|
|
567
565
|
System id="stripe", selected connection has secret named: api_key
|