@superglue/cli 1.1.37 → 1.1.38

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.37",
4
+ "version": "1.1.38",
5
5
  "author": {
6
6
  "name": "superglue",
7
7
  "email": "hello@superglue.cloud"
package/dist/cli.js CHANGED
@@ -855,7 +855,7 @@ WRITING DATA: POST /source/{destinationSourceId}/user and POST /source/{destinat
855
855
 
856
856
  ACTIVITY TYPES: Call GET /activityTypes before posting activities \u2014 the activityType field must match an accepted value for the room.
857
857
 
858
- DEPRECATED ENDPOINTS: GET /user/{email} and GET /members are deprecated; use V2 equivalents instead.`},teamcity:{name:"teamcity",apiUrl:"https://{host}/app/rest",regex:"^.*(teamcity|jetbrains[\\s._-]?teamcity|\\/app\\/rest).*$",icon:"teamcity",docsUrl:"https://www.jetbrains.com/help/teamcity/rest/teamcity-rest-api-documentation.html",preferredAuthType:"api_key",keywords:["builds","projects","agents","artifacts","vcs roots","build configurations","build chains","test reports","deployments"],systemSpecificInstructions:"TeamCity is self-hosted; the API base URL is https://{host}/app/rest where {host} is your TeamCity server hostname. Tokens are personal access tokens created per-user under My Settings & Tools \u2192 Access Tokens \u2014 not a global admin panel. Use as Authorization: Bearer <token>. The OpenAPI spec is available at runtime on the server itself at /app/rest/swagger.json. Basic auth is available via /httpAuth/app/rest/... as a fallback. The API version segment (e.g. /app/rest/2018.1/...) is optional; omitting it uses the latest version."},expensify:{name:"expensify",apiUrl:"https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations",regex:"^.*(expensify|integrations\\.expensify\\.com).*$",icon:"expensify",docsUrl:"https://integrations.expensify.com/Integration-Server/doc/",preferredAuthType:"api_key",keywords:["report","expense","policy","employee","category","tag","card","domain","receipt","transaction","approver","reimbursement"],systemSpecificInstructions:`Expensify uses a non-standard single-endpoint API: all requests are POSTs to https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations with credentials (partnerUserID and partnerUserSecret) embedded in the JSON body under a "credentials" key, not in headers. Obtain partnerUserID and partnerUserSecret exclusively from https://www.expensify.com/tools/integrations/ \u2014 this page is not reachable from the main account settings. Report creation requires explicit enablement by emailing concierge@expensify.com. The card reconciliation export requires the credentials to belong to a domain admin account. To operate on another user's data via the "userEmail" parameter, that user must first grant third-party access to your partner account.`}};ke.systemOptions=[{value:"manual",label:"Custom API",icon:"default"},...Object.entries(ke.systems).map(([o,e])=>({value:o,label:o.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()).trim(),icon:e.icon||"default"}))];function Ru(o){if(o.templateName&&ke.systems[o.templateName])return{key:o.templateName,template:ke.systems[o.templateName]};if(o.id&&ke.systems[o.id])return{key:o.id,template:ke.systems[o.id]};if(o.id){let e=o.id.replace(/-\d+$/,"");if(e!==o.id&&ke.systems[e])return{key:e,template:ke.systems[e]}}if(o.name&&ke.systems[o.name])return{key:o.name,template:ke.systems[o.name]};if(o.url){let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(o.url)?o.url:`https://${o.url}`,t=[];for(let[a,i]of Object.entries(ke.systems))try{if(new RegExp(i.regex).test(e)){let s=i.regex.length+(i.regex.includes("(?!")?100:0);t.push({key:a,template:i,specificity:s})}}catch{console.error(`Invalid regex pattern for system: ${a}`)}if(t.length>0){let a=t.sort((i,s)=>s.specificity-i.specificity)[0];return{key:a.key,template:a.template}}}return null}function gY(o){return!o||o.length===0?[]:[...new Set(o)]}function pY(o){return ke.systems[o]?.oauth||null}function hY(o){let e=ob(o),t=e.type==="oauth2"?e.config||{}:{},a=o.credentials||{},i=Ru(o)?.template.oauth,s=a.tokenAuthMethod,r=t.tokenAuthMethod,n=a.tokenContentType,c=t.tokenContentType,m=i?.extraHeaders,l=i?.extraBodyParams,u=(0,Du.parseJsonRecord)(t.extraHeaders),d=(0,Du.parseJsonRecord)(t.extraBodyParams),g=(0,Du.parseJsonRecord)(a.extraHeaders),p=(0,Du.parseJsonRecord)(a.extraBodyParams);return g&&(m=g),p&&(l=p),u&&(m=u),d&&(l=d),{tokenAuthMethod:r==="body"||r==="basic_auth"?r:s==="body"||s==="basic_auth"?s:i?.tokenAuthMethod,tokenContentType:c==="form"||c==="json"?c:n==="form"||n==="json"?n:i?.tokenContentType,extraHeaders:m,extraBodyParams:l}}function fY(o){let e=ob(o);if(e.type==="oauth2"&&e.tokenUrl)return e.tokenUrl;let t=Ru(o)?.template.oauth;if(t?.tokenUrl)return t.tokenUrl;if(!o.url)throw new Error(`Cannot determine OAuth token URL for system ${o.id}: no url or token_url provided`);try{return`${new URL(o.url.startsWith("http")?o.url:`https://${o.url}`).origin}/oauth/token`}catch{return`${o.url}/oauth/token`}}});var f2=y(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.KNOWLEDGE_BASE_CHANGE_LABEL=We.SYSTEM_PLAYGROUND_DRAFT_ID=void 0;We.normalizeSystemKnowledgeBaseInput=p2;We.buildSystemPendingOutput=h2;We.getSystemFieldDisplayLabel=wY;We.formatSystemChangePreview=Nu;We.formatCredentialDisplayValue=vY;We.buildMergedSystemPlaygroundConfig=xY;We.summarizeSystemPlaygroundChanges=zY;We.convertUploadToClientPayload=qY;var Tu=jc(),jr=Pt(),ab=tb(),bY=/\.(json|yaml|yml)$|openapi|swagger|\/v[23]\//i;We.SYSTEM_PLAYGROUND_DRAFT_ID="@playground-draft";We.KNOWLEDGE_BASE_CHANGE_LABEL="Knowledge base";var yY={name:"Display name",url:"System endpoint",instructions:"Usage instructions",specificinstructions:"Usage instructions",credentialownership:"Credential source",credentialmode:"Credential source"};function kY(o,e){return o==="openapi"||o==="scrape"?o:bY.test(e)?"openapi":"scrape"}function ms(o){return Array.isArray(o)?[...new Set(o.map(e=>String(e||"").trim()).filter(Boolean))]:[]}function p2(o){let e=o?.knowledgeBase&&typeof o.knowledgeBase=="object"&&!Array.isArray(o.knowledgeBase)?o.knowledgeBase:null,t=typeof e?.files=="string"&&e.files.trim().length>0?e.files:void 0,a=[];if(Array.isArray(e?.addUrls))for(let r of e.addUrls){if(!r||typeof r!="object")continue;let n=r.url;if(typeof n!="string")continue;let c=n.trim();c&&a.push({url:c,source:kY(r.source,c)})}let i=new Set,s=a.filter(r=>{let n=`${r.source}:${r.url.toLowerCase()}`;return i.has(n)?!1:(i.add(n),!0)});return{...t?{files:t}:{},urls:s,removeDocumentIds:ms(e?.removeDocumentIds)}}function h2(o){let e={...o||{}},{templateId:t,endpoint:a,auth:i,askForUserInputs:s,...r}=e,n=(0,Tu.mapAgentAuthInput)(i).authentication;if(t){let c=ab.systems[t];if(c){let m=(0,ab.mergeSystemTemplateAuthentication)({authentication:n||r.authentication,template:c});e={name:c.name,url:c.apiUrl,...r,templateName:t,...a?{url:a}:{},...m?{authentication:m}:{}}}}else e={...r,...a?{url:a}:{},...n?{authentication:n}:{}};return{status:"awaiting_user_input",pendingInputs:(0,Tu.normalizeAskForUserInputs)(o?.askForUserInputs),systemConfig:e}}function AY(o){return o.replace(/^\/+/,"").replace(/\s+/g,"").toLowerCase()}function u2(o){return o.length>240?`${o.slice(0,240)}...`:o}function d2(o){return o?o.type==="api_key"?"API key":o.type==="basic_auth"?"Basic auth":o.type==="connection_string"?"Connection string":o.type==="oauth2"?"OAuth 2.0":"No auth":"None"}function g2(o){let e=o.authentication;if(e?.type!=="oauth2")return null;if(e.oauthClientMode)return e.oauthClientMode==="managed"?"superglue-managed":"Custom";let t=o.templateName?ab.systems[o.templateName]?.oauth?.client_id:void 0;return t&&e.clientId===t?"superglue-managed":"Custom"}function wY(o){let e=o.trim();if(!e)return"System";let t="Credential \xB7 ";if(e.startsWith(t))return e.slice(t.length);let a=AY(e);return a==="knowledgebase"?We.KNOWLEDGE_BASE_CHANGE_LABEL:yY[a]||e}function Nu(o,e="(empty)"){if(o==null||o==="")return e;if(typeof o=="string"){let t=o.trim();return t?u2(t):e}return typeof o=="number"||typeof o=="boolean"?String(o):u2((0,jr.safeStringify)(o,0))}function vY(o,e){return e==null||e===""?"(empty)":(0,jr.isSensitiveCredentialKey)(o)?typeof e=="object"?"****":(0,jr.maskCredentialValue)(o,e)||"(empty)":Nu(e)}function xY({draft:o,input:e,mode:t}){let a=t==="create"?h2(e).systemConfig||{}:e||{},{draftId:i,documentationUrl:s,openApiUrl:r,files:n,knowledgeBase:c,removeDocumentIds:m,removeCredentialKeys:l,scrapeUrl:u,scrapeKeywords:d,endpoint:g,auth:p,credentials:b,requiredCredentialKeys:v,tags:k,...x}=a,w=o.system,j=p!==void 0?t==="edit"?(0,Tu.mergeAgentAuthInput)(w.authentication,p):(0,Tu.mapAgentAuthInput)(p).authentication:void 0,I=x.name??w.name,D=I?(0,jr.slugify)(I):"",R=x.id??(w.id||D),S=!!j||x.authentication!==void 0?j||x.authentication:w.authentication;return{id:R,name:I,url:g??x.url??w.url,templateName:x.templateName??w.templateName,icon:x.icon??w.icon,tags:k!==void 0?ms(k):w.tags,specificInstructions:x.specificInstructions??w.specificInstructions,requiredCredentialKeys:v!==void 0?ms(v):w.requiredCredentialKeys,authentication:S,tunnel:x.tunnel!==void 0?x.tunnel:w.tunnel}}function zY({previous:o,next:e,input:t}){let a=[],i=(r,n,c)=>{(n||"")!==(c||"")&&a.push({label:r,value:`${Nu(n)} -> ${Nu(c)}`})};for(let[r,n,c]of[["Display name",o.name,e.name],["System endpoint",o.url,e.url],["Template",o.templateName,e.templateName],["Icon",o.icon,e.icon],["Usage instructions",o.specificInstructions,e.specificInstructions],["Required secrets",ms(o.requiredCredentialKeys).join(", "),ms(e.requiredCredentialKeys).join(", ")],["Tags",ms(o.tags).join(", "),ms(e.tags).join(", ")]])i(r,n,c);if((0,jr.safeStringify)(o.authentication||null,0)!==(0,jr.safeStringify)(e.authentication||null,0)){let r=g2(o),n=g2(e);r&&n&&r!==n&&a.push({label:"OAuth client",value:`${r} -> ${n}`});let c=d2(o.authentication),m=d2(e.authentication);a.push({label:"Authentication configuration",value:c===m?`Updated ${m} settings`:`${c} -> ${m}`})}let s=p2(t);s.files&&a.push({label:We.KNOWLEDGE_BASE_CHANGE_LABEL,value:"Documentation file uploads staged"});for(let r of s.urls)a.push({label:We.KNOWLEDGE_BASE_CHANGE_LABEL,value:r.source==="openapi"?`OpenAPI URL staged: ${r.url}`:`Documentation URL staged: ${r.url}`});for(let r of s.removeDocumentIds)a.push({label:We.KNOWLEDGE_BASE_CHANGE_LABEL,value:`Document removed: ${r}`});return a}async function qY(o){if(o.sourceKind==="resolved-payload"&&o.content!==void 0)return{fileName:o.fileName,content:o.content,contentType:o.contentType,contentLength:o.contentLength};if(o.file)return{fileName:o.fileName,content:o.file,contentType:o.contentType,contentLength:o.contentLength};throw new Error(`Missing upload content for ${o.fileName}`)}});var A2=y(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.PAGINATION_RUNTIME_KEYS=ao.RESERVED_RUNTIME_KEYS=void 0;ao.getToolDeclaredInputKeys=y2;ao.toolHasActivePagination=ib;ao.collectToolKeyCollisions=CY;ao.formatToolKeyCollisionError=jY;ao.getCollidingRuntimePayloadKeys=QY;ao.formatPayloadKeyCollisionError=BY;var EY=At(),b2=Pt();ao.RESERVED_RUNTIME_KEYS=["__files__","currentItem","sg_auth_email","sg_auth_jwt","persistedState"];ao.PAGINATION_RUNTIME_KEYS=["page","offset","cursor","limit","pageSize"];function IY(o){if(!o)return null;if(typeof o=="string")try{let e=JSON.parse(o);return e&&typeof e=="object"?e:null}catch{return null}return typeof o=="object"?o:null}function y2(o){let t=IY(o)?.properties;if(!t||typeof t!="object")return[];let a=Object.keys(t),i=t.payload;return i&&t.credentials&&a.every(r=>r==="payload"||r==="credentials")?i&&typeof i=="object"&&i.properties&&typeof i.properties=="object"?Object.keys(i.properties):[]:a}function ib(o){return(o.steps||[]).some(e=>(0,EY.isRequestConfig)(e.config)&&e.config.pagination&&e.config.pagination.type!=="disabled")}function k2(o){return o==="__files__"?"the runtime file map":o==="currentItem"?"the loop iteration variable":o==="sg_auth_email"?"the authenticated user's email":o==="sg_auth_jwt"?"a signed JWT proving the authenticated user's identity":o==="persistedState"?"the persistent tool state object":"a runtime-injected value"}function CY({tool:o}){let e=[],t=y2(o.inputSchema),a=(o.steps||[]).map(u=>u.id).filter(Boolean),i=ib(o),s=new Set(ao.RESERVED_RUNTIME_KEYS),r=new Set(ao.PAGINATION_RUNTIME_KEYS),n=(0,b2.getToolSystemIds)(o).map(u=>`${u}_`),c=new Set;for(let u of a)c.has(u)&&e.push({key:u,source:"stepId",kind:"duplicate-step-id",message:`Step id "${u}" is used by more than one step. Each step result is stored under its step id, so duplicate ids overwrite each other. Rename one of the steps.`}),c.add(u);let m=(u,d)=>{let g=d==="input"?`Input "${u}"`:`Step id "${u}"`;s.has(u)&&e.push({key:u,source:d,kind:"reserved",message:`${g} collides with ${k2(u)}, which the runtime injects into sourceData. Choose a different name.`}),i&&r.has(u)&&e.push({key:u,source:d,kind:"pagination",message:`${g} collides with the pagination variable "${u}" and this tool has a paginated step, so the value would override the runtime's pagination counter. Rename it (e.g. "max_results" instead of "limit").`});let p=n.find(b=>u.startsWith(b));p&&e.push({key:u,source:d,kind:"credential",message:`${g} starts with "${p}", the credential namespace of a system this tool uses. Credentials always win over payload values, so this name is reserved even if no such credential exists yet. Choose a name without the system prefix.`})};for(let u of t)m(u,"input");for(let u of c)m(u,"stepId");let l=new Set(a);for(let u of t)l.has(u)&&e.push({key:u,source:"input",kind:"step-id",message:`Input "${u}" has the same name as a step id. The step result overwrites the input value in sourceData after that step runs. Rename the input or the step.`});return e}function jY(o){let e=o.map(t=>`- ${t.message}`);return`Tool has ${o.length} key name collision${o.length===1?"":"s"} with the runtime namespace:
858
+ DEPRECATED ENDPOINTS: GET /user/{email} and GET /members are deprecated; use V2 equivalents instead.`},teamcity:{name:"teamcity",apiUrl:"https://{host}/app/rest",regex:"^.*(teamcity|jetbrains[\\s._-]?teamcity|\\/app\\/rest).*$",icon:"teamcity",docsUrl:"https://www.jetbrains.com/help/teamcity/rest/teamcity-rest-api-documentation.html",preferredAuthType:"api_key",keywords:["builds","projects","agents","artifacts","vcs roots","build configurations","build chains","test reports","deployments"],systemSpecificInstructions:"TeamCity is self-hosted; the API base URL is https://{host}/app/rest where {host} is your TeamCity server hostname. Tokens are personal access tokens created per-user under My Settings & Tools \u2192 Access Tokens \u2014 not a global admin panel. Use as Authorization: Bearer <token>. The OpenAPI spec is available at runtime on the server itself at /app/rest/swagger.json. Basic auth is available via /httpAuth/app/rest/... as a fallback. The API version segment (e.g. /app/rest/2018.1/...) is optional; omitting it uses the latest version."},expensify:{name:"expensify",apiUrl:"https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations",regex:"^.*(expensify|integrations\\.expensify\\.com).*$",icon:"expensify",docsUrl:"https://integrations.expensify.com/Integration-Server/doc/",preferredAuthType:"api_key",keywords:["report","expense","policy","employee","category","tag","card","domain","receipt","transaction","approver","reimbursement"],systemSpecificInstructions:`Expensify uses a non-standard single-endpoint API: all requests are POSTs to https://integrations.expensify.com/Integration-Server/ExpensifyIntegrations with credentials (partnerUserID and partnerUserSecret) embedded in the JSON body under a "credentials" key, not in headers. Obtain partnerUserID and partnerUserSecret exclusively from https://www.expensify.com/tools/integrations/ \u2014 this page is not reachable from the main account settings. Report creation requires explicit enablement by emailing concierge@expensify.com. The card reconciliation export requires the credentials to belong to a domain admin account. To operate on another user's data via the "userEmail" parameter, that user must first grant third-party access to your partner account.`},dhl:{name:"dhl",apiUrl:"https://api-eu.dhl.com/track/shipments",regex:"^.*(dhl|api-eu\\.dhl\\.com|dhl[\\s._-]?tracking).*$",icon:"simpleicons:dhl",docsUrl:"https://developer.dhl.com/api-reference/shipment-tracking",preferredAuthType:"api_key",keywords:["tracking","shipment","trackingNumber","events","status","carrier","parcel","logistics","origin","destination"],systemSpecificInstructions:"Auth header is DHL-API-Key, not a generic Authorization header \u2014 get the key by registering an app on developer.dhl.com (free tier works for tracking). The apiUrl covers the EU region host; other DHL developer-portal products (e.g. Parcel DE Shipping) use different base paths and credentials and are not covered by this template."},weclapp:{name:"weclapp",apiUrl:"https://{tenant}.weclapp.com/webapp/api/v2",regex:"^.*(weclapp).*$",icon:"lucide:building-2",docsUrl:"https://www.weclapp.com/api/",openApiUrl:"https://www.weclapp.com/api/swagger.json",preferredAuthType:"api_key",keywords:["party","customer","supplier","salesOrder","salesInvoice","article","purchaseOrder","shipment","quotation","ticket","warehouseStock","accountingTransaction"],systemSpecificInstructions:"Auth header is AuthenticationToken (not Bearer or Basic) \u2014 generate it in the weclapp UI under user settings. {tenant} is the subdomain of your weclapp instance (e.g. mycompany for mycompany.weclapp.com)."},windchill:{name:"windchill",apiUrl:"https://{host}/Windchill/servlet/odata",regex:"^.*(windchill|ptc[\\s._-]?windchill).*$",icon:"/logos/ptc.svg",docsUrl:"https://support.ptc.com/help/windchill/r13.1.2.0/en/Windchill_Help_Center/middlemap_landingpages/WCRESTServices_LP.html",preferredAuthType:"basic_auth",keywords:["odata","plm","changeMgmt","changeNotices","parts","documents","cadDocuments","productStructure","workflow"],systemSpecificInstructions:"Windchill OData REST Services must be enabled by a Windchill administrator before any endpoint responds. Basic Auth alone works for GET requests; POST/PUT/PATCH/DELETE calls additionally require first fetching a CSRF_NONCE from the GetCSRFToken endpoint and sending it as a request header, or writes fail with 401/403. {host} is the self-hosted Windchill instance; there is no public multi-tenant host or OpenAPI spec."}};ke.systemOptions=[{value:"manual",label:"Custom API",icon:"default"},...Object.entries(ke.systems).map(([o,e])=>({value:o,label:o.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()).trim(),icon:e.icon||"default"}))];function Ru(o){if(o.templateName&&ke.systems[o.templateName])return{key:o.templateName,template:ke.systems[o.templateName]};if(o.id&&ke.systems[o.id])return{key:o.id,template:ke.systems[o.id]};if(o.id){let e=o.id.replace(/-\d+$/,"");if(e!==o.id&&ke.systems[e])return{key:e,template:ke.systems[e]}}if(o.name&&ke.systems[o.name])return{key:o.name,template:ke.systems[o.name]};if(o.url){let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(o.url)?o.url:`https://${o.url}`,t=[];for(let[a,i]of Object.entries(ke.systems))try{if(new RegExp(i.regex).test(e)){let s=i.regex.length+(i.regex.includes("(?!")?100:0);t.push({key:a,template:i,specificity:s})}}catch{console.error(`Invalid regex pattern for system: ${a}`)}if(t.length>0){let a=t.sort((i,s)=>s.specificity-i.specificity)[0];return{key:a.key,template:a.template}}}return null}function gY(o){return!o||o.length===0?[]:[...new Set(o)]}function pY(o){return ke.systems[o]?.oauth||null}function hY(o){let e=ob(o),t=e.type==="oauth2"?e.config||{}:{},a=o.credentials||{},i=Ru(o)?.template.oauth,s=a.tokenAuthMethod,r=t.tokenAuthMethod,n=a.tokenContentType,c=t.tokenContentType,m=i?.extraHeaders,l=i?.extraBodyParams,u=(0,Du.parseJsonRecord)(t.extraHeaders),d=(0,Du.parseJsonRecord)(t.extraBodyParams),g=(0,Du.parseJsonRecord)(a.extraHeaders),p=(0,Du.parseJsonRecord)(a.extraBodyParams);return g&&(m=g),p&&(l=p),u&&(m=u),d&&(l=d),{tokenAuthMethod:r==="body"||r==="basic_auth"?r:s==="body"||s==="basic_auth"?s:i?.tokenAuthMethod,tokenContentType:c==="form"||c==="json"?c:n==="form"||n==="json"?n:i?.tokenContentType,extraHeaders:m,extraBodyParams:l}}function fY(o){let e=ob(o);if(e.type==="oauth2"&&e.tokenUrl)return e.tokenUrl;let t=Ru(o)?.template.oauth;if(t?.tokenUrl)return t.tokenUrl;if(!o.url)throw new Error(`Cannot determine OAuth token URL for system ${o.id}: no url or token_url provided`);try{return`${new URL(o.url.startsWith("http")?o.url:`https://${o.url}`).origin}/oauth/token`}catch{return`${o.url}/oauth/token`}}});var f2=y(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.KNOWLEDGE_BASE_CHANGE_LABEL=We.SYSTEM_PLAYGROUND_DRAFT_ID=void 0;We.normalizeSystemKnowledgeBaseInput=p2;We.buildSystemPendingOutput=h2;We.getSystemFieldDisplayLabel=wY;We.formatSystemChangePreview=Nu;We.formatCredentialDisplayValue=vY;We.buildMergedSystemPlaygroundConfig=xY;We.summarizeSystemPlaygroundChanges=zY;We.convertUploadToClientPayload=qY;var Tu=jc(),jr=Pt(),ab=tb(),bY=/\.(json|yaml|yml)$|openapi|swagger|\/v[23]\//i;We.SYSTEM_PLAYGROUND_DRAFT_ID="@playground-draft";We.KNOWLEDGE_BASE_CHANGE_LABEL="Knowledge base";var yY={name:"Display name",url:"System endpoint",instructions:"Usage instructions",specificinstructions:"Usage instructions",credentialownership:"Credential source",credentialmode:"Credential source"};function kY(o,e){return o==="openapi"||o==="scrape"?o:bY.test(e)?"openapi":"scrape"}function ms(o){return Array.isArray(o)?[...new Set(o.map(e=>String(e||"").trim()).filter(Boolean))]:[]}function p2(o){let e=o?.knowledgeBase&&typeof o.knowledgeBase=="object"&&!Array.isArray(o.knowledgeBase)?o.knowledgeBase:null,t=typeof e?.files=="string"&&e.files.trim().length>0?e.files:void 0,a=[];if(Array.isArray(e?.addUrls))for(let r of e.addUrls){if(!r||typeof r!="object")continue;let n=r.url;if(typeof n!="string")continue;let c=n.trim();c&&a.push({url:c,source:kY(r.source,c)})}let i=new Set,s=a.filter(r=>{let n=`${r.source}:${r.url.toLowerCase()}`;return i.has(n)?!1:(i.add(n),!0)});return{...t?{files:t}:{},urls:s,removeDocumentIds:ms(e?.removeDocumentIds)}}function h2(o){let e={...o||{}},{templateId:t,endpoint:a,auth:i,askForUserInputs:s,...r}=e,n=(0,Tu.mapAgentAuthInput)(i).authentication;if(t){let c=ab.systems[t];if(c){let m=(0,ab.mergeSystemTemplateAuthentication)({authentication:n||r.authentication,template:c});e={name:c.name,url:c.apiUrl,...r,templateName:t,...a?{url:a}:{},...m?{authentication:m}:{}}}}else e={...r,...a?{url:a}:{},...n?{authentication:n}:{}};return{status:"awaiting_user_input",pendingInputs:(0,Tu.normalizeAskForUserInputs)(o?.askForUserInputs),systemConfig:e}}function AY(o){return o.replace(/^\/+/,"").replace(/\s+/g,"").toLowerCase()}function u2(o){return o.length>240?`${o.slice(0,240)}...`:o}function d2(o){return o?o.type==="api_key"?"API key":o.type==="basic_auth"?"Basic auth":o.type==="connection_string"?"Connection string":o.type==="oauth2"?"OAuth 2.0":"No auth":"None"}function g2(o){let e=o.authentication;if(e?.type!=="oauth2")return null;if(e.oauthClientMode)return e.oauthClientMode==="managed"?"superglue-managed":"Custom";let t=o.templateName?ab.systems[o.templateName]?.oauth?.client_id:void 0;return t&&e.clientId===t?"superglue-managed":"Custom"}function wY(o){let e=o.trim();if(!e)return"System";let t="Credential \xB7 ";if(e.startsWith(t))return e.slice(t.length);let a=AY(e);return a==="knowledgebase"?We.KNOWLEDGE_BASE_CHANGE_LABEL:yY[a]||e}function Nu(o,e="(empty)"){if(o==null||o==="")return e;if(typeof o=="string"){let t=o.trim();return t?u2(t):e}return typeof o=="number"||typeof o=="boolean"?String(o):u2((0,jr.safeStringify)(o,0))}function vY(o,e){return e==null||e===""?"(empty)":(0,jr.isSensitiveCredentialKey)(o)?typeof e=="object"?"****":(0,jr.maskCredentialValue)(o,e)||"(empty)":Nu(e)}function xY({draft:o,input:e,mode:t}){let a=t==="create"?h2(e).systemConfig||{}:e||{},{draftId:i,documentationUrl:s,openApiUrl:r,files:n,knowledgeBase:c,removeDocumentIds:m,removeCredentialKeys:l,scrapeUrl:u,scrapeKeywords:d,endpoint:g,auth:p,credentials:b,requiredCredentialKeys:v,tags:k,...x}=a,w=o.system,j=p!==void 0?t==="edit"?(0,Tu.mergeAgentAuthInput)(w.authentication,p):(0,Tu.mapAgentAuthInput)(p).authentication:void 0,I=x.name??w.name,D=I?(0,jr.slugify)(I):"",R=x.id??(w.id||D),S=!!j||x.authentication!==void 0?j||x.authentication:w.authentication;return{id:R,name:I,url:g??x.url??w.url,templateName:x.templateName??w.templateName,icon:x.icon??w.icon,tags:k!==void 0?ms(k):w.tags,specificInstructions:x.specificInstructions??w.specificInstructions,requiredCredentialKeys:v!==void 0?ms(v):w.requiredCredentialKeys,authentication:S,tunnel:x.tunnel!==void 0?x.tunnel:w.tunnel}}function zY({previous:o,next:e,input:t}){let a=[],i=(r,n,c)=>{(n||"")!==(c||"")&&a.push({label:r,value:`${Nu(n)} -> ${Nu(c)}`})};for(let[r,n,c]of[["Display name",o.name,e.name],["System endpoint",o.url,e.url],["Template",o.templateName,e.templateName],["Icon",o.icon,e.icon],["Usage instructions",o.specificInstructions,e.specificInstructions],["Required secrets",ms(o.requiredCredentialKeys).join(", "),ms(e.requiredCredentialKeys).join(", ")],["Tags",ms(o.tags).join(", "),ms(e.tags).join(", ")]])i(r,n,c);if((0,jr.safeStringify)(o.authentication||null,0)!==(0,jr.safeStringify)(e.authentication||null,0)){let r=g2(o),n=g2(e);r&&n&&r!==n&&a.push({label:"OAuth client",value:`${r} -> ${n}`});let c=d2(o.authentication),m=d2(e.authentication);a.push({label:"Authentication configuration",value:c===m?`Updated ${m} settings`:`${c} -> ${m}`})}let s=p2(t);s.files&&a.push({label:We.KNOWLEDGE_BASE_CHANGE_LABEL,value:"Documentation file uploads staged"});for(let r of s.urls)a.push({label:We.KNOWLEDGE_BASE_CHANGE_LABEL,value:r.source==="openapi"?`OpenAPI URL staged: ${r.url}`:`Documentation URL staged: ${r.url}`});for(let r of s.removeDocumentIds)a.push({label:We.KNOWLEDGE_BASE_CHANGE_LABEL,value:`Document removed: ${r}`});return a}async function qY(o){if(o.sourceKind==="resolved-payload"&&o.content!==void 0)return{fileName:o.fileName,content:o.content,contentType:o.contentType,contentLength:o.contentLength};if(o.file)return{fileName:o.fileName,content:o.file,contentType:o.contentType,contentLength:o.contentLength};throw new Error(`Missing upload content for ${o.fileName}`)}});var A2=y(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.PAGINATION_RUNTIME_KEYS=ao.RESERVED_RUNTIME_KEYS=void 0;ao.getToolDeclaredInputKeys=y2;ao.toolHasActivePagination=ib;ao.collectToolKeyCollisions=CY;ao.formatToolKeyCollisionError=jY;ao.getCollidingRuntimePayloadKeys=QY;ao.formatPayloadKeyCollisionError=BY;var EY=At(),b2=Pt();ao.RESERVED_RUNTIME_KEYS=["__files__","currentItem","sg_auth_email","sg_auth_jwt","persistedState"];ao.PAGINATION_RUNTIME_KEYS=["page","offset","cursor","limit","pageSize"];function IY(o){if(!o)return null;if(typeof o=="string")try{let e=JSON.parse(o);return e&&typeof e=="object"?e:null}catch{return null}return typeof o=="object"?o:null}function y2(o){let t=IY(o)?.properties;if(!t||typeof t!="object")return[];let a=Object.keys(t),i=t.payload;return i&&t.credentials&&a.every(r=>r==="payload"||r==="credentials")?i&&typeof i=="object"&&i.properties&&typeof i.properties=="object"?Object.keys(i.properties):[]:a}function ib(o){return(o.steps||[]).some(e=>(0,EY.isRequestConfig)(e.config)&&e.config.pagination&&e.config.pagination.type!=="disabled")}function k2(o){return o==="__files__"?"the runtime file map":o==="currentItem"?"the loop iteration variable":o==="sg_auth_email"?"the authenticated user's email":o==="sg_auth_jwt"?"a signed JWT proving the authenticated user's identity":o==="persistedState"?"the persistent tool state object":"a runtime-injected value"}function CY({tool:o}){let e=[],t=y2(o.inputSchema),a=(o.steps||[]).map(u=>u.id).filter(Boolean),i=ib(o),s=new Set(ao.RESERVED_RUNTIME_KEYS),r=new Set(ao.PAGINATION_RUNTIME_KEYS),n=(0,b2.getToolSystemIds)(o).map(u=>`${u}_`),c=new Set;for(let u of a)c.has(u)&&e.push({key:u,source:"stepId",kind:"duplicate-step-id",message:`Step id "${u}" is used by more than one step. Each step result is stored under its step id, so duplicate ids overwrite each other. Rename one of the steps.`}),c.add(u);let m=(u,d)=>{let g=d==="input"?`Input "${u}"`:`Step id "${u}"`;s.has(u)&&e.push({key:u,source:d,kind:"reserved",message:`${g} collides with ${k2(u)}, which the runtime injects into sourceData. Choose a different name.`}),i&&r.has(u)&&e.push({key:u,source:d,kind:"pagination",message:`${g} collides with the pagination variable "${u}" and this tool has a paginated step, so the value would override the runtime's pagination counter. Rename it (e.g. "max_results" instead of "limit").`});let p=n.find(b=>u.startsWith(b));p&&e.push({key:u,source:d,kind:"credential",message:`${g} starts with "${p}", the credential namespace of a system this tool uses. Credentials always win over payload values, so this name is reserved even if no such credential exists yet. Choose a name without the system prefix.`})};for(let u of t)m(u,"input");for(let u of c)m(u,"stepId");let l=new Set(a);for(let u of t)l.has(u)&&e.push({key:u,source:"input",kind:"step-id",message:`Input "${u}" has the same name as a step id. The step result overwrites the input value in sourceData after that step runs. Rename the input or the step.`});return e}function jY(o){let e=o.map(t=>`- ${t.message}`);return`Tool has ${o.length} key name collision${o.length===1?"":"s"} with the runtime namespace:
859
859
  ${e.join(`
860
860
  `)}`}function QY({payload:o,tool:e}){let t=[],a=new Set(ao.RESERVED_RUNTIME_KEYS),i=new Set(ao.PAGINATION_RUNTIME_KEYS),s=new Set((e.steps||[]).map(c=>c.id).filter(Boolean)),r=ib(e),n=(0,b2.getToolSystemIds)(e).map(c=>`${c}_`);for(let c of Object.keys(o)){a.has(c)&&t.push({key:c,kind:"reserved",message:`Payload key "${c}" collides with ${k2(c)}, which the runtime injects into sourceData. Remove or rename it.`}),s.has(c)&&t.push({key:c,kind:"step-id",message:`Payload key "${c}" has the same name as a step id. The step result overwrites the payload value in sourceData after that step runs. Remove or rename it.`}),r&&i.has(c)&&t.push({key:c,kind:"pagination",message:`Payload key "${c}" collides with a pagination variable and this tool has a paginated step, so it would override the runtime's pagination counter. Remove or rename it.`});let m=n.find(l=>c.startsWith(l));m&&t.push({key:c,kind:"credential",message:`Payload key "${c}" starts with "${m}", the credential namespace of a system this tool uses. Credentials always win over payload values. Remove or rename it.`})}return t}function BY(o){let e=o.map(t=>`- ${t.message}`);return`Payload has ${o.length} key name collision${o.length===1?"":"s"} with the runtime namespace:
861
861
  ${e.join(`
@@ -1398,7 +1398,7 @@ ${s}`;break;case"retry":X9(s)&&(t[i]=s);break;case"id":e5(s)&&(t[i]=s);break;cas
1398
1398
  `);o.stack=t?`${t}
1399
1399
  ${s}`:i.stack}B.exports.fetch=function(e,t=void 0){return Zne(e,t).catch(a=>{throw u5?h5(a,u5):a&&typeof a=="object"&&Error.captureStackTrace(a,B.exports.fetch),a})};B.exports.Headers=_s().Headers;B.exports.Response=Bm().Response;B.exports.Request=ln().Request;B.exports.FormData=ad().FormData;var{setGlobalOrigin:Xne,getGlobalOrigin:ece}=ly();B.exports.setGlobalOrigin=Xne;B.exports.getGlobalOrigin=ece;var{CacheStorage:oce}=K3(),{kConstruct:tce}=ue();B.exports.caches=new oce(tce);var{deleteCookie:ace,getCookies:ice,getSetCookies:sce,setCookie:rce,parseCookie:nce}=m9();B.exports.deleteCookie=ace;B.exports.getCookies=ice;B.exports.getSetCookies=sce;B.exports.setCookie=rce;B.exports.parseCookie=nce;var{parseMIMEType:cce,serializeAMimeType:mce}=ct();B.exports.parseMIMEType=cce;B.exports.serializeAMimeType=mce;var{CloseEvent:lce,ErrorEvent:uce,MessageEvent:dce}=vg(),{WebSocket:gce,ping:pce}=L9();B.exports.WebSocket=gce;B.exports.CloseEvent=lce;B.exports.ErrorEvent=uce;B.exports.MessageEvent=dce;B.exports.ping=pce;B.exports.WebSocketStream=J9().WebSocketStream;B.exports.WebSocketError=_w().WebSocketError;B.exports.request=Pm(wn.request);B.exports.stream=Pm(wn.stream);B.exports.pipeline=Pm(wn.pipeline);B.exports.connect=Pm(wn.connect);B.exports.upgrade=Pm(wn.upgrade);B.exports.MockClient=_ne;B.exports.MockCallHistory=Fne;B.exports.MockCallHistoryLog=Lne;B.exports.MockPool=Hne;B.exports.MockAgent=Pne;B.exports.SnapshotAgent=Yne;B.exports.mockErrors=Gne;var{EventSource:hce}=l5();B.exports.EventSource=hce;function fce(){globalThis.fetch=B.exports.fetch,globalThis.Headers=B.exports.Headers,globalThis.Response=B.exports.Response,globalThis.Request=B.exports.Request,globalThis.FormData=B.exports.FormData,globalThis.WebSocket=B.exports.WebSocket,globalThis.CloseEvent=B.exports.CloseEvent,globalThis.ErrorEvent=B.exports.ErrorEvent,globalThis.MessageEvent=B.exports.MessageEvent,globalThis.EventSource=B.exports.EventSource}B.exports.install=fce});var b5=y(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.SuperglueClient=xn.SuperglueHttpError=void 0;var vn=At(),bce=rb(),yce=j2(),kce=Pt(),Ma=kr(),Ace=mu(),Ng=14400*1e3,Hm;if(typeof globalThis.process<"u"&&globalThis.process.versions?.node)try{let{Agent:o}=f5();Hm=new o({headersTimeout:Ng,bodyTimeout:Ng})}catch{}var Ug=class extends Error{constructor(e,t,a,i){super(e),this.status=t,this.code=a,this.details=i,this.name="SuperglueHttpError"}};xn.SuperglueHttpError=Ug;var Gw=class{constructor({apiKey:e,apiEndpoint:t,onInfrastructureError:a,sseTokenProvider:i,tokenProvider:s}){if(!e&&!s)throw new Error("SuperglueClient requires either apiKey or tokenProvider");this.tokenProvider=s??(async()=>e),this.apiEndpoint=t??"https://api.superglue.cloud",this.sseManager=new bce.SSELogSubscriptionManager(this.apiEndpoint,i??this.tokenProvider),this.onInfrastructureError=a}async getApiKey(){return this.tokenProvider()}isInfrastructureError(e){return(0,kce.isAbortError)(e)?!1:!!(e instanceof TypeError&&e.message.toLowerCase().includes("fetch")||e instanceof Error&&e.name==="TimeoutError")}async restRequest(e,t,a,i,s){let n=await(await this.restResponse({method:e,path:t,body:a,extraHeaders:i,requestInit:s})).text();if(n)return JSON.parse(n)}async restResponse({method:e,path:t,body:a,extraHeaders:i,requestInit:s}){let r=`${this.apiEndpoint.replace(/\/$/,"")}${t}`,c={Authorization:`Bearer ${await this.getApiKey()}`,...i};a&&e!=="GET"&&(c["Content-Type"]="application/json");let m;try{m=await fetch(r,{...s,method:e,headers:c,body:a?JSON.stringify(a):void 0,signal:s?.signal??AbortSignal.timeout(Ng),...Hm?{dispatcher:Hm}:{}})}catch(l){throw this.isInfrastructureError(l)&&this.onInfrastructureError?.(),l}if(!m.ok)throw await this.buildHttpError(m);return m}async buildHttpError(e){e.status>=500&&this.onInfrastructureError?.();let t=await e.text(),a=`HTTP ${e.status}: ${t}`,i,s;try{let r=JSON.parse(t);r&&typeof r=="object"&&!Array.isArray(r)&&(s=r),typeof r?.code=="string"&&(i=r.code);let n=r.error;typeof n=="string"?a=n:n&&typeof n=="object"&&(a=n.message||JSON.stringify(n))}catch{}return new Ug(a,e.status,i,s)}async streamRequest(e,t,a){let i=e.includes("?")?"&":"?",s=`${this.apiEndpoint.replace(/\/$/,"")}${e}${i}stream=true`,n={Authorization:`Bearer ${await this.getApiKey()}`,Accept:"text/event-stream","Content-Type":"application/json"},c;try{c=await fetch(s,{method:"POST",headers:n,body:JSON.stringify(t),signal:a??AbortSignal.timeout(Ng),...Hm?{dispatcher:Hm}:{}})}catch(l){throw this.isInfrastructureError(l)&&this.onInfrastructureError?.(),l}if(!c.ok)throw await this.buildHttpError(c);if(!(c.headers.get("content-type")||"").includes("text/event-stream")){let l=await c.text();return l?JSON.parse(l):void 0}try{return await(0,yce.consumeEventStreamResult)(c)}catch(l){throw this.isInfrastructureError(l)&&this.onInfrastructureError?.(),l}}async subscribeToLogsSSE(e={}){return this.sseManager.subscribeToLogs(e)}async disconnect(){await this.sseManager.disconnect()}async getMe(){return this.restRequest("GET","/v1/me")}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(s=>({...s}))||[],...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:s,options:r,runId:n,systemIds:c,createRun:m,parentToolId:l,stepIndex:u,stepId:d,signal:g,stream:p}){let b={step:e,payload:t,files:a,previousResults:i,credentials:s,options:r,runId:n,systemIds:c,createRun:m,parentToolId:l,stepIndex:u,stepId:d};return p?this.streamRequest("/v1/tools/step/run",b,g):this.restRequest("POST","/v1/tools/step/run",b,void 0,g?{signal:g}:void 0)}async abortStep(e){return this.restRequest("POST","/v1/tools/step/abort",{runId:e})}async executeTransformOnly({outputTransform:e,outputSchema:t,inputSchema:a,payload:i,files:s,stepResults:r,options:n,runId:c,createRun:m,parentToolId:l,stepId:u,signal:d,stream:g}){let p={outputTransform:e,outputSchema:t,inputSchema:a,payload:i,files:s,stepResults:r,options:n,runId:c,createRun:m,parentToolId:l,stepId:u};return g?this.streamRequest("/v1/tools/transform/run",p,d):this.restRequest("POST","/v1/tools/transform/run",p,void 0,d?{signal:d}:void 0)}async createRun({toolId:e,toolConfig:t,toolResult:a,stepResults:i,toolPayload:s,status:r,error:n,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:s,status:r,error:n,startedAt:(0,Ma.toUTCISOString)(c,"run.startedAt"),completedAt:(0,Ma.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=new URL(`${this.apiEndpoint.replace(/\/$/,"")}/v1/extract`);t&&i.searchParams.set("envelope","true");let s=i.toString(),r=await this.getApiKey(),n=await fetch(s,{method:"POST",headers:{Authorization:`Bearer ${r}`},body:a});if(!n.ok){let c=await n.text(),m=`HTTP ${n.status}: ${c}`;try{let l=JSON.parse(c);l.error&&(m=l.error)}catch{}throw new Error(m)}return n.json()}mapOpenAPIRunToRun(e){let t={running:vn.RunStatus.RUNNING,success:vn.RunStatus.SUCCESS,failed:vn.RunStatus.FAILED,aborted:vn.RunStatus.ABORTED};return{runId:e.runId??e.id,toolId:e.toolId,tool:e.tool,systemIds:e.systemIds,status:t[e.status]??vn.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??vn.RunExecutionKind.FULL},fileArtifacts:e.fileArtifacts}}mapOpenAPIScheduleToToolSchedule(e){return{...e,lastRunAt:e.lastRunAt?(0,Ma.requireUTCDate)(e.lastRunAt,"schedule.lastRunAt"):void 0,nextRunAt:(0,Ma.requireUTCDate)(e.nextRunAt,"schedule.nextRunAt"),createdAt:(0,Ma.requireUTCDate)(e.createdAt,"schedule.createdAt"),updatedAt:(0,Ma.requireUTCDate)(e.updatedAt,"schedule.updatedAt")}}async listRuns(e){let{limit:t=100,page:a=1,toolId:i,search:s,searchUserIds:r,includeTotal:n=!0,startedAfter:c,status:m,requestSources:l,executionKinds:u,userId:d,systemId:g,signal:p}=e??{},b=new URLSearchParams({limit:String(t),page:String(a)});i&&b.set("toolId",i),s?.trim()&&b.set("search",s.trim()),r&&r.length>0&&b.set("searchUserIds",r.join(",")),n||b.set("includeTotal","false"),c&&b.set("startedAfter",c instanceof Date?(0,Ma.toUTCISOString)(c,"run.startedAfter"):c),m&&b.set("status",m),l&&l.length>0&&b.set("requestSources",l.join(",")),u&&u.length>0&&b.set("executionKinds",u.join(",")),d&&b.set("userId",d),g&&b.set("systemId",g);let v=await this.restRequest("GET",`/v1/runs?${b.toString()}`,void 0,void 0,{signal:p});return{items:v.data.map(k=>this.mapOpenAPIRunToRun(k)),total:v.total,page:v.page,limit:v.limit,hasMore:v.hasMore}}async getActivityCounts(e){let t=new URLSearchParams;e?.from&&t.set("from",e.from instanceof Date?(0,Ma.toUTCISOString)(e.from,"activity.from"):e.from),e?.to&&t.set("to",e.to instanceof Date?(0,Ma.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){return(await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/state`,{state:t})).warnings}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=10,t=0,a=!1){let i=Math.floor(t/e)+1,s=a?"&includeArchived=true":"",r=await this.restRequest("GET",`/v1/tools?limit=${e}&page=${i}${s}`);return{items:r.data,total:r.total}}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 listWorkflows(e=10,t=0,a=!1){return this.listTools(e,t,a)}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 listToolSchedules(e){if(e&&typeof e=="object")return this.listToolSchedulesPage(e);let t=[],a=typeof e=="string"?e:void 0,i=1;for(;;){let s=await this.listToolSchedulesPage({toolId:a,limit:1e3,page:i});if(t.push(...s.items),!s.hasMore||s.items.length===0)break;i+=1}return t}async listToolSchedulesPage(e){let{toolId:t,limit:a=100,page:i=1}=e??{},s=new URLSearchParams({limit:String(a),page:String(i)}),r=t?`/v1/tools/${encodeURIComponent(t)}/schedules?${s.toString()}`:`/v1/schedules?${s.toString()}`,n=await this.restRequest("GET",r);return{items:n.data.map(c=>this.mapOpenAPIScheduleToToolSchedule(c)),total:n.total,page:n.page,limit:n.limit,hasMore:n.hasMore}}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,Ace.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=new URLSearchParams;e?.systemId&&t.set("systemId",e.systemId);let a=t.toString();return(await this.restRequest("GET",`/v1/credentials${a?`?${a}`:""}`)).data.items}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=10,t=1){let a=new URLSearchParams({limit:String(e),page:String(t)}),i=await this.restRequest("GET",`/v1/systems?${a.toString()}`);return{items:i.data,total:i.total}}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 createSystemFileUploadUrls(e,t,a){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/file-references`,{files:t.map(s=>({fileName:s.fileName,metadata:{contentType:s.contentType,contentLength:s.contentLength}})),link:a?.link})).data.files}async uploadSystemFileReferences(e,t,a){if(t.length===0)return[];let i=await this.createSystemFileUploadUrls(e,t.map(n=>({fileName:n.fileName,contentType:n.contentType,contentLength:n.contentLength})),{link:a?.link}),r=(await Promise.allSettled(i.map(async(n,c)=>{let m=t[c],l=await fetch(n.uploadUrl,{method:"PUT",body:m.content,headers:m.contentType?{"Content-Type":m.contentType}:void 0});if(!l.ok)throw new Error(`Upload failed for ${m.fileName}: ${l.status} ${l.statusText}`);return this.processFileReference(n.id).catch(()=>{}),n.id}))).map((n,c)=>{let m=t[c],l=i[c].id;return n.status==="fulfilled"?{id:l,fileName:m.fileName,contentLength:m.contentLength,status:"uploaded"}:(this.deleteSystemFileReference(e,l).catch(()=>{}),{id:l,fileName:m.fileName,contentLength:m.contentLength,status:"failed",error:n.reason instanceof Error?n.reason.message:"Upload failed"})});if(!a?.settle){let n=r.filter(c=>c.status==="failed");if(n.length>0)throw new Error(n.map(c=>c.error).join("; "))}return r}async processFileReference(e){return this.restRequest("POST",`/v1/file-references/${encodeURIComponent(e)}/process`)}async listSystemFileReferences(e){return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/file-references`)).data}async listFileReferences(e){if(e.length===0)return{files:[],total:0};let t=new URLSearchParams;t.set("fileIds",e.join(",")),t.set("limit",String(e.length));let a=await this.restRequest("GET",`/v1/file-references?${t.toString()}`);return{files:a.items,total:a.total}}async deleteSystemFileReference(e,t){await this.restRequest("DELETE",`/v1/systems/${encodeURIComponent(e)}/file-references/${encodeURIComponent(t)}`)}async getFileReferenceContent(e){return(await this.restRequest("GET",`/v1/file-references/${encodeURIComponent(e)}?includeContent=true`)).data.content??null}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}}}};xn.SuperglueClient=Gw});var k5=y(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.UnquotedKeyStrategy=Ie.TripleQuoteStrategy=Ie.TrailingCommaStrategy=Ie.SingleQuoteStrategy=Ie.PythonLiteralStrategy=Ie.CommentStrategy=Ie.ResilientJsonParser=Ie.RepairStrategy=void 0;Ie.parseJsonResilient=wce;Ie.parseJSON=vce;Ie.isValidJson=xce;Ie.prettyPrintJson=zce;Ie.minifyJson=qce;var Nt=class{validate(e){try{return JSON.parse(e),!0}catch{return!1}}};Ie.RepairStrategy=Nt;var Mg=class extends Nt{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 r=JSON.parse(i);return JSON.stringify(r)}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")}"`})}};Ie.TripleQuoteStrategy=Mg;var Og=class extends Nt{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")}};Ie.PythonLiteralStrategy=Og;var _g=class extends Nt{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")}};Ie.TrailingCommaStrategy=_g;var Fg=class extends Nt{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}};Ie.SingleQuoteStrategy=Fg;var Lg=class extends Nt{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')}};Ie.UnquotedKeyStrategy=Lg;var Pg=class extends Nt{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}};Ie.CommentStrategy=Pg;var Vw=class extends Nt{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 s=0;s<e.length;s++){let r=e[s],n=s>0?e[s-1]:"";if(i){t+=r,i=!1;continue}if(r==="\\"&&a){t+=r,i=!0;continue}if(r==='"'&&n!=="\\"){a=!a,t+=r;continue}if(a)switch(r){case`
1400
1400
  `: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=r.charCodeAt(0);c<32?t+="\\u"+("0000"+c.toString(16)).slice(-4):t+=r}else t+=r}return t}},Ww=class extends Nt{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,s=!1,r=!1;for(let n=0;n<t.length;n++){let c=t[n];if(s)r?r=!1:c==="\\"?r=!0:c==='"'&&(s=!1);else if(c==='"')s=!0;else if(c==="{")a++;else if(c==="}"){if(a--,a===0&&i===0&&n>0&&n<t.length-1)return!0}else if(c==="[")i++;else if(c==="]"&&(i--,i===0&&a===0&&n>0&&n<t.length-1))return!0}return!1}apply(e){let t=e.trim(),a=0,i=0,s=!1,r=!1,n=-1;for(let c=0;c<t.length;c++){let m=t[c];if(s)r?r=!1:m==="\\"?r=!0:m==='"'&&(s=!1);else if(m==='"')s=!0;else if(m==="{")a++;else if(m==="}"){if(a--,a===0&&i===0&&c>0){n=c;break}}else if(m==="[")i++;else if(m==="]"&&(i--,i===0&&a===0&&c>0)){n=c;break}}return n>0&&n<t.length-1?t.substring(0,n+1):e}},zn=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 Mg,new Fg,new Vw,new Ww,new Og,new _g,new Lg,new Pg]}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(r){if(!this.options.attemptRepair)return{success:!1,error:`JSON parse error: ${r}`,metadata:{parseTime:Date.now()-t}}}let i=a,s=[];for(let r of this.strategies)if(r.canApply(i)){let n=i;if(i=r.apply(i),n!==i){s.push(r.name),this.repairLog.push(r.description),this.options.logRepairs&&console.log(`Applied ${r.name}: ${r.description}`);try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:s}}}catch{}}}try{return{success:!0,data:JSON.parse(i),repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:s}}}catch(r){let n=this.aggressiveFallback(i);return n.success?{...n,repairs:[...this.repairLog,"Applied aggressive fallback"],metadata:{parseTime:Date.now()-t,strategiesApplied:[...s,"AggressiveFallback"]}}:{success:!1,error:`Failed to parse JSON after applying ${s.length} strategies: ${r}`,repairs:this.repairLog,metadata:{parseTime:Date.now()-t,strategiesApplied:s}}}}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),s=e.substring(i);for(let n of this.strategies)n.canApply(s)&&(s=n.apply(s));return{success:!0,data:JSON.parse(s)}}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)}};Ie.ResilientJsonParser=zn;var y5=new zn;function wce(o,e){return(e?new zn(e):y5).parse(o)}function vce(o){let e=y5.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 xce(o){try{return JSON.parse(o),!0}catch{return!1}}function zce(o,e=2){return JSON.stringify(o,null,e)}function qce(o){let t=new zn().parse(o);if(t.success)return JSON.stringify(t.data);throw new Error("Cannot minify invalid JSON")}});var bt=y(H=>{"use strict";var Ece=H&&H.__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]})),oe=H&&H.__exportStar||function(o,e){for(var t in o)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Ece(e,o,t)};Object.defineProperty(H,"__esModule",{value:!0});H.SSELogSubscriptionManager=H.SuperglueHttpError=H.SuperglueClient=void 0;oe(L1(),H);oe($1(),H);oe(X1(),H);oe(jc(),H);oe(hE(),H);oe(fE(),H);oe(bE(),H);oe(yE(),H);oe(kE(),H);oe(wE(),H);oe(vE(),H);oe(zE(),H);oe(qE(),H);oe(IE(),H);oe(cl(),H);oe(jE(),H);oe(QE(),H);oe(SE(),H);oe(TE(),H);oe(FE(),H);oe(PE(),H);oe(YE(),H);oe(a2(),H);oe(s2(),H);oe($f(),H);oe(f2(),H);oe(tb(),H);oe(A2(),H);oe(z2(),H);oe(E2(),H);oe(At(),H);oe(Pt(),H);oe(I2(),H);oe(C2(),H);oe(xu(),H);oe(kr(),H);oe(mu(),H);var A5=b5();Object.defineProperty(H,"SuperglueClient",{enumerable:!0,get:function(){return A5.SuperglueClient}});Object.defineProperty(H,"SuperglueHttpError",{enumerable:!0,get:function(){return A5.SuperglueHttpError}});var Ice=rb();Object.defineProperty(H,"SSELogSubscriptionManager",{enumerable:!0,get:function(){return Ice.SSELogSubscriptionManager}});oe(k5(),H)});var wp=require("commander");var jo=$(require("fs")),x5=$(require("os")),Oa=$(require("path")),Ym=$(bt()),w5=new Set(["runner","builder","admin"]),v5={output:{mode:"stdout",directory:".superglue/output"},preset:"admin"};function _a(o){let e=Oa.join(process.cwd(),".superglue"),t=x5.homedir();if(!t)return e;let a=Oa.join(t,".superglue");return o===!0?e:o===!1?a:jo.existsSync(Oa.join(e,"config.json"))?e:a}function $w(o){return Oa.join(_a(o),"config.json")}function Hg(o){let e=$w(o);if(!jo.existsSync(e))return{};try{return JSON.parse(jo.readFileSync(e,"utf-8"))}catch{return{}}}function qn(o){let e=Hg(),t=o.apiKey||(0,Ym.readProcessEnvironmentValue)("SUPERGLUE_API_KEY")||e.apiKey||"",a=o.endpoint||(0,Ym.readProcessEnvironmentValue)("SUPERGLUE_API_ENDPOINT")||e.endpoint||"https://api.superglue.cloud",i=(0,Ym.readProcessEnvironmentValue)("SUPERGLUE_WEB_ENDPOINT")||e.webEndpoint||a.replace(/:3002\b/,":3001").replace(/api\.superglue/,"app.superglue"),s=(0,Ym.readProcessEnvironmentValue)("SUPERGLUE_CLI_PRESET"),r=s&&w5.has(s)?s:e.preset&&w5.has(e.preset)?e.preset:"admin";return{...v5,...e,apiKey:t,endpoint:a,webEndpoint:i,preset:r,output:{...v5.output,...e.output}}}function Yg(o,e){let t=_a(e);jo.existsSync(t)||jo.mkdirSync(t,{recursive:!0}),jo.writeFileSync(Oa.join(t,"config.json"),JSON.stringify(o,null,2)+`
1401
- `,{mode:384})}function Gg(o,e){let t=Oa.join(_a(e),"drafts");if(jo.existsSync(t)||jo.mkdirSync(t,{recursive:!0}),o.output.mode==="stdout+file"){let a=Oa.resolve(o.output.directory);jo.existsSync(a)||jo.mkdirSync(a,{recursive:!0})}}var tv=$(bt());var Jw=$(require("readline"));var E5=require("child_process"),I5=require("util");var z5={name:"@superglue/cli",version:"1.1.13",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 jce=(0,I5.promisify)(E5.exec),bo=z5.version;function q5(o){let e=o.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:o}}function Wg(o,e){let t=o.split("."),a=e.split("."),i=Math.max(t.length,a.length);for(let s=0;s<i;s++){let r=q5(t[s]||"0"),n=q5(a[s]||"0");if(r.numeric<n.numeric)return-1;if(r.numeric>n.numeric||r.prerelease===null&&n.prerelease!==null)return 1;if(r.prerelease!==null&&n.prerelease===null)return-1;if(r.prerelease!==null&&n.prerelease!==null){if(r.prerelease<n.prerelease)return-1;if(r.prerelease>n.prerelease)return 1}}return 0}async function $g(){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 Vg=null;function C5(){Y()&&(Vg=$g())}async function j5(){if(!(!Y()||!Vg)){try{let o=new Promise(t=>{setTimeout(()=>t(null),2e3).unref()}),e=await Promise.race([Vg,o]);e&&Wg(bo,e)<0&&(console.error(""),console.error(`${h.cyan}${h.bold} Update available: ${bo} \u2192 ${e}${h.reset}`),console.error(`${h.cyan} Run ${h.bold}sg update${h.reset}${h.cyan} to upgrade${h.reset}`),console.error(""))}catch{}Vg=null}}async function Q5(){let o=await $g();if(!o)return{success:!1,message:"Could not fetch latest version from npm"};if(Wg(bo,o)>=0)return{success:!0,message:`Already on latest version (${bo})`};try{return await jce("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${bo} to ${o}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var Y=()=>process.argv.includes("--table")&&process.stdout.isTTY,yt=()=>process.argv.includes("--full"),h={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 B5(o,e){let t=e||o;return`\x1B]8;;${o}\x07${h.underline}${h.cyan}${t}${h.reset}\x1B]8;;\x07`}function S5(){if(!Y())return;let o=h.reset,e=h.dim,t="\x1B[47;30m",a=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),a.forEach(i=>{let s=i.search(/\S/),r=i.length-[...i].reverse().join("").search(/\S/)-1;if(s===-1)return console.log(" "+i);let n=i.slice(0,s),c=i.slice(s,r+1).split("").map(l=>l===" "?" ":"\u2588").join(""),m=i.slice(r+1);console.log(` ${n}${t}${c}${o}${m}`)}),console.log(` ${e} CLI v${bo}${o}`),console.log("")}function ze(o){if(!Y())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"),s=()=>{process.stdout.write(`\r ${h.cyan}${e[t++%e.length]}${h.reset} ${a}`)},r=setInterval(s,80);return{update:n=>{a=n},log:n=>{i(),console.log(` ${h.dim}\u2502${h.reset} ${n}`),s()},stop:n=>{clearInterval(r),i(),n&&console.log(` ${n}`)}}}function M(o){Y()?Jg(o):console.log(JSON.stringify(o,null,2))}function ie(o,e){Y()?(console.log(` ${h.green}\u2713${h.reset} ${o}`),e&&Jg(e,4)):console.log(JSON.stringify({success:!0,message:o,...e&&typeof e=="object"?e:{data:e}}))}function z(o,e){Y()?(console.error(` ${h.red}\u2717${h.reset} ${o}`),e&&Jg(e,4)):console.error(JSON.stringify({success:!1,error:o,details:e}))}function D5(o){Y()&&console.log(` ${h.yellow}\u26A0${h.reset} ${o}`)}function no(o){Y()&&console.log(` ${h.dim}${o}${h.reset}`)}function Fa(o){Y()&&(console.log(`
1401
+ `,{mode:384})}function Gg(o,e){let t=Oa.join(_a(e),"drafts");if(jo.existsSync(t)||jo.mkdirSync(t,{recursive:!0}),o.output.mode==="stdout+file"){let a=Oa.resolve(o.output.directory);jo.existsSync(a)||jo.mkdirSync(a,{recursive:!0})}}var tv=$(bt());var Jw=$(require("readline"));var E5=require("child_process"),I5=require("util");var z5={name:"@superglue/cli",version:"1.1.38",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 jce=(0,I5.promisify)(E5.exec),bo=z5.version;function q5(o){let e=o.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:o}}function Wg(o,e){let t=o.split("."),a=e.split("."),i=Math.max(t.length,a.length);for(let s=0;s<i;s++){let r=q5(t[s]||"0"),n=q5(a[s]||"0");if(r.numeric<n.numeric)return-1;if(r.numeric>n.numeric||r.prerelease===null&&n.prerelease!==null)return 1;if(r.prerelease!==null&&n.prerelease===null)return-1;if(r.prerelease!==null&&n.prerelease!==null){if(r.prerelease<n.prerelease)return-1;if(r.prerelease>n.prerelease)return 1}}return 0}async function $g(){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 Vg=null;function C5(){Y()&&(Vg=$g())}async function j5(){if(!(!Y()||!Vg)){try{let o=new Promise(t=>{setTimeout(()=>t(null),2e3).unref()}),e=await Promise.race([Vg,o]);e&&Wg(bo,e)<0&&(console.error(""),console.error(`${h.cyan}${h.bold} Update available: ${bo} \u2192 ${e}${h.reset}`),console.error(`${h.cyan} Run ${h.bold}sg update${h.reset}${h.cyan} to upgrade${h.reset}`),console.error(""))}catch{}Vg=null}}async function Q5(){let o=await $g();if(!o)return{success:!1,message:"Could not fetch latest version from npm"};if(Wg(bo,o)>=0)return{success:!0,message:`Already on latest version (${bo})`};try{return await jce("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${bo} to ${o}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var Y=()=>process.argv.includes("--table")&&process.stdout.isTTY,yt=()=>process.argv.includes("--full"),h={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 B5(o,e){let t=e||o;return`\x1B]8;;${o}\x07${h.underline}${h.cyan}${t}${h.reset}\x1B]8;;\x07`}function S5(){if(!Y())return;let o=h.reset,e=h.dim,t="\x1B[47;30m",a=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),a.forEach(i=>{let s=i.search(/\S/),r=i.length-[...i].reverse().join("").search(/\S/)-1;if(s===-1)return console.log(" "+i);let n=i.slice(0,s),c=i.slice(s,r+1).split("").map(l=>l===" "?" ":"\u2588").join(""),m=i.slice(r+1);console.log(` ${n}${t}${c}${o}${m}`)}),console.log(` ${e} CLI v${bo}${o}`),console.log("")}function ze(o){if(!Y())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"),s=()=>{process.stdout.write(`\r ${h.cyan}${e[t++%e.length]}${h.reset} ${a}`)},r=setInterval(s,80);return{update:n=>{a=n},log:n=>{i(),console.log(` ${h.dim}\u2502${h.reset} ${n}`),s()},stop:n=>{clearInterval(r),i(),n&&console.log(` ${n}`)}}}function M(o){Y()?Jg(o):console.log(JSON.stringify(o,null,2))}function ie(o,e){Y()?(console.log(` ${h.green}\u2713${h.reset} ${o}`),e&&Jg(e,4)):console.log(JSON.stringify({success:!0,message:o,...e&&typeof e=="object"?e:{data:e}}))}function z(o,e){Y()?(console.error(` ${h.red}\u2717${h.reset} ${o}`),e&&Jg(e,4)):console.error(JSON.stringify({success:!1,error:o,details:e}))}function D5(o){Y()&&console.log(` ${h.yellow}\u26A0${h.reset} ${o}`)}function no(o){Y()&&console.log(` ${h.dim}${o}${h.reset}`)}function Fa(o){Y()&&(console.log(`
1402
1402
  ${h.bold}${h.cyan}${o}${h.reset}`),console.log(` ${h.dim}${"\u2500".repeat(o.length)}${h.reset}`))}function sa(o,e,t){if(!Y()){console.log(JSON.stringify({success:!0,total:t?.total??o.length,items:o}));return}if(o.length===0){console.log(`
1403
1403
  ${h.dim}0 results${h.reset}
1404
1404
  `);return}let a=e||Object.keys(o[0]),i=yt()?1/0:60,s=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 r=a.map((l,u)=>`${h.bold}${h.cyan}${l.toUpperCase().padEnd(s[u])}${h.reset}`).join(" ");console.log(` ${r}`);let n=s.map(l=>`${h.dim}${"\u2500".repeat(l)}${h.reset}`).join(`${h.dim}\u2500\u2500${h.reset}`);console.log(` ${n}`);for(let l of o){let u=a.map((d,g)=>{let p=String(l[d]??"").replace(/[\n\r]+/g," ").trim();if(p.length>i){let v=`\u2026 (${p.length})`;p=p.slice(0,Math.max(0,i-v.length))+`${h.dim}${v}${h.reset}`}return d==="status"?`${{success:h.green,running:h.yellow,failed:h.red,aborted:h.red,error:h.red,pending:h.dim}[p.toLowerCase()]||""}${p.padEnd(s[g])}${h.reset}`:p.padEnd(s[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.37",
3
+ "version": "1.1.38",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },