@superglue/cli 1.1.182 → 1.1.183

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.182",
4
+ "version": "1.1.183",
5
5
  "author": {
6
6
  "name": "superglue",
7
7
  "email": "hello@superglue.cloud"
package/dist/cli.js CHANGED
@@ -689,7 +689,7 @@ label[data-sg-choice]:has(input:focus-visible){box-shadow:0 0 0 1px var(--sg-rin
689
689
  @media print{[data-sg-deck]{display:block;padding:0}[data-sg-slide]{zoom:1;box-shadow:none}}
690
690
  @media (max-width:640px){.sg-mapping{grid-template-columns:1fr}.sg-mapping>i{display:none}}
691
691
  @media print{.sg-card,.sg-kpi{break-inside:avoid;box-shadow:none}h1,h2,h3,h4,h5,h6{break-after:avoid}}
692
- `.trim();var Kpe=`<style data-sg-base>${ou.ARTIFACT_BASE_CSS}</style>`;function Xpe(t){return t.includes("<style data-sg-base>")?t:(0,Zpe.injectHeadStyle)(t,Kpe,"start")}});var Ox=m(Md=>{"use strict";Object.defineProperty(Md,"__esModule",{value:!0});Md.DeploymentConfigError=void 0;Md.buildDeploymentConfig=ofe;var efe=["pro","team","enterprise"],Ag={pro:"prod_UjB46ulzKsQ1Ef",team:"prod_UiMeaL02tN4BMg",enterprise:"prod_UapuUIQQuluzUV"},pg=["openai","anthropic","gemini","azure","bedrock","vertex"],tfe=["tavily","model_provider","searxng","disabled"],rfe=["openai","anthropic","azure"],nfe=["cloud","enterprise"],ife=["aws","minio"],Nx=["email_password","google","github","okta"],Mb=class{constructor(e){this.raw=e,this.issues=[]}build(){let e=this.requiredPort("API_PORT",3002,"runtime.apiPort"),r=this.requiredPort("WEB_PORT",3001,"runtime.webPort"),n=this.requiredUrl("PUBLIC_API_URL",`http://localhost:${e}`,"runtime.publicApiUrl"),i=this.url("INTERNAL_API_URL",n,"runtime.internalApiUrl"),o=this.requiredUrl("PUBLIC_APP_URL","https://app.superglue.cloud","runtime.publicAppUrl"),s=this.url("INTERNAL_APP_URL",o,"runtime.internalAppUrl"),a=this.deploymentMode(),c=this.requiredBoolean("BLOCK_LOCAL_REQUESTS",!1,"security.blockLocalRequests"),u=this.llm(this.choice("PRIMARY_LLM_PROVIDER",pg,"openai","llm.primary.provider"),this.required("PRIMARY_LLM_MODEL","llm.primary.model"),"llm.primary"),l=this.llmFallbacks(),d=this.llm(this.choice("SUMMARIZE_LLM_PROVIDER",pg,"openai","llm.summarize.provider"),this.required("SUMMARIZE_LLM_MODEL","llm.summarize.model"),"llm.summarize"),A={deployment:{mode:a,orgConcurrencyLimits:a==="enterprise"?"disabled":"tier_config"},runtime:{apiPort:e,webPort:r,publicApiUrl:n,internalApiUrl:i,publicAppUrl:o,internalAppUrl:s,scheduler:this.scheduler()},website:{contactFormToEmail:this.optional("WEBSITE_CONTACT_FORM_TO_EMAIL")??null},security:{jwtSecret:this.required("JWT_AUTH_SECRET","security.jwtSecret"),internalApiToken:this.required("INTERNAL_API_TOKEN","security.internalApiToken"),credentialsEncryptionKey:this.required("MASTER_ENCRYPTION_KEY","security.credentialsEncryptionKey"),blockLocalRequests:c},storage:{postgres:{host:this.required("POSTGRES_HOST","storage.postgres.host"),port:this.requiredPort("POSTGRES_PORT",5432,"storage.postgres.port"),username:this.required("POSTGRES_USERNAME","storage.postgres.username"),password:this.required("POSTGRES_PASSWORD","storage.postgres.password"),database:this.required("POSTGRES_DB","storage.postgres.database"),ssl:this.requiredBoolean("POSTGRES_SSL",!0,"storage.postgres.ssl")},objectStorage:this.objectStorage()},llm:{primary:u,primaryFallbacks:l,summarize:d},externalProviders:{posthog:this.posthog(),langfuse:this.langfuse(),resend:this.resend(),loops:this.loops(),teamsBot:this.teamsBot(),webSearch:this.webSearch(u.provider,l)},billing:this.billing(a),bundles:this.bundles(),features:{briefings:this.boolean("BRIEFINGS_ENABLED",!1,"features.briefings")},auth:this.auth()};if(this.issues.length>0)throw new fg(this.issues);return A}optional(e){let r=this.raw[e]?.trim();return r||void 0}required(e,r){let n=this.optional(e);return n||(this.issues.push({path:r,message:`${e} is required.`}),"")}requiredOptional(e,r){let n=this.optional(e);return n||this.issues.push({path:r,message:`${e} is required.`}),n}boolean(e,r,n){let i=this.optional(e);return i?i==="true"?!0:i==="false"?!1:(this.issues.push({path:n,message:`${e} must be "true" or "false".`}),r):r}requiredBoolean(e,r,n){let i=this.requiredOptional(e,n);return i?i==="true"?!0:i==="false"?!1:(this.issues.push({path:n,message:`${e} must be "true" or "false".`}),r):r}port(e,r,n){let i=this.optional(e);if(!i)return r;let o=Number(i);return!Number.isInteger(o)||o<1||o>65535?(this.issues.push({path:n,message:`${e} must be a TCP port between 1 and 65535.`}),r):o}requiredPort(e,r,n){return this.requiredOptional(e,n)?this.port(e,r,n):r}url(e,r,n){let i=this.optional(e)||r;try{return new URL(i).toString().replace(/\/$/,"")}catch{return this.issues.push({path:n,message:`${e} must be a valid URL.`}),r}}requiredUrl(e,r,n){return this.requiredOptional(e,n)?this.url(e,r,n):r}choice(e,r,n,i){let o=this.requiredOptional(e,i)?.toLowerCase();return o?r.includes(o)?o:(this.issues.push({path:i,message:`${e} must be one of: ${r.join(", ")}.`}),n):n}listChoice(e,r,n){let i=this.requiredOptional(e,n);if(!i)return[];let o=[],s=new Set;for(let a of i.split(",")){let c=a.trim().toLowerCase();if(!(!c||s.has(c))){if(s.add(c),r.includes(c)){o.push(c);continue}this.issues.push({path:n,message:`${e} contains unsupported value "${c}". Use one of: ${r.join(", ")}.`})}}return o.length===0&&this.issues.push({path:n,message:`${e} must include at least one provider.`}),o}list(e){return(this.optional(e)??"").split(",").map(r=>r.trim()).filter(Boolean)}deploymentMode(){return this.choice("DEPLOYMENT_MODE",nfe,"cloud","deployment.mode")}scheduler(){return this.requiredBoolean("START_SCHEDULER_SERVER",!1,"runtime.scheduler.mode")?{mode:"in_process"}:{mode:"disabled"}}objectStorage(){if(this.choice("S3_PROVIDER",ife,"aws","storage.objectStorage.provider")==="minio")return{provider:"minio",endpoint:this.required("S3_ENDPOINT","storage.objectStorage.endpoint"),publicEndpoint:this.optional("S3_PUBLIC_ENDPOINT")??null,bucketName:this.required("MINIO_BUCKET_NAME","storage.objectStorage.bucketName"),bucketPrefix:this.bucketPrefix(this.optional("MINIO_BUCKET_PREFIX")||this.optional("AWS_BUCKET_PREFIX")),accessKeyId:this.required("MINIO_ROOT_USER","storage.objectStorage.accessKeyId"),secretAccessKey:this.required("MINIO_ROOT_PASSWORD","storage.objectStorage.secretAccessKey")};let r=this.optional("AWS_S3_ACCESS_KEY_ID"),n=this.optional("AWS_S3_SECRET_ACCESS_KEY");return(r&&!n||!r&&n)&&this.issues.push({path:"storage.objectStorage.credentials",message:"AWS_S3_ACCESS_KEY_ID and AWS_S3_SECRET_ACCESS_KEY must be set together."}),{provider:"aws",region:this.required("AWS_S3_REGION","storage.objectStorage.region"),bucketName:this.required("AWS_BUCKET_NAME","storage.objectStorage.bucketName"),bucketPrefix:this.bucketPrefix(this.optional("AWS_BUCKET_PREFIX")),...r&&n?{accessKeyId:r,secretAccessKey:n,...this.optional("AWS_S3_SESSION_TOKEN")&&{sessionToken:this.optional("AWS_S3_SESSION_TOKEN")}}:{}}}bucketPrefix(e){let r=e?.replace(/^\/+|\/+$/g,"");return r?`${r}/`:""}llm(e,r,n){let i=e.toLowerCase();if(!pg.includes(i))return this.issues.push({path:`${n}.provider`,message:`${n} provider must be one of: ${pg.join(", ")}.`}),{provider:"openai",apiKey:this.optional("OPENAI_API_KEY")||"",model:r};switch(i){case"openai":return this.openai(r,n);case"anthropic":return this.anthropic(r,n);case"gemini":return this.gemini(r,n);case"azure":return this.azure(r,n);case"bedrock":return this.bedrock(r,n);case"vertex":return this.vertex(r,n)}}openai(e,r){return{provider:"openai",apiKey:this.required("OPENAI_API_KEY",`${r}.apiKey`),model:e,...e==="gpt-6.1-sol"&&{reasoningEffort:"medium"},...this.optional("OPENAI_BASE_URL")&&{baseUrl:this.optional("OPENAI_BASE_URL")}}}anthropic(e,r){return{provider:"anthropic",apiKey:this.required("ANTHROPIC_API_KEY",`${r}.apiKey`),model:e,...this.optional("ANTHROPIC_BASE_URL")&&{baseUrl:this.optional("ANTHROPIC_BASE_URL")}}}gemini(e,r){return{provider:"gemini",apiKey:this.required("GEMINI_API_KEY",`${r}.apiKey`),model:e,...this.optional("GEMINI_BASE_URL")&&{baseUrl:this.optional("GEMINI_BASE_URL")}}}llmFallbacks(){return this.list("PRIMARY_LLM_FALLBACKS").flatMap((e,r)=>{let n=`llm.primaryFallbacks.${r}`,i=e.indexOf(":"),o=e.slice(0,i).trim(),s=e.slice(i+1).trim();return i===-1||!o||!s?(this.issues.push({path:n,message:`PRIMARY_LLM_FALLBACKS entry "${e}" must use the provider:model format.`}),[]):[this.llm(o,s,n)]})}azure(e,r){let n=this.optional("AZURE_RESOURCE_NAME"),i=this.optional("AZURE_BASE_URL");return!n&&!i&&this.issues.push({path:r,message:"AZURE_RESOURCE_NAME or AZURE_BASE_URL is required when using Azure."}),{provider:"azure",apiKey:this.required("AZURE_API_KEY",`${r}.apiKey`),model:e,...n&&{resourceName:n},...i&&{baseUrl:i},...this.optional("AZURE_API_VERSION")&&{apiVersion:this.optional("AZURE_API_VERSION")},useDeploymentBasedUrls:this.boolean("AZURE_USE_DEPLOYMENT_BASED_URLS",!1,`${r}.useDeploymentBasedUrls`)}}bedrock(e,r){let n=this.optional("BEDROCK_AWS_ACCESS_KEY_ID"),i=this.optional("BEDROCK_AWS_SECRET_ACCESS_KEY");return(n&&!i||!n&&i)&&this.issues.push({path:`${r}.credentials`,message:"BEDROCK_AWS_ACCESS_KEY_ID and BEDROCK_AWS_SECRET_ACCESS_KEY must be set together."}),{provider:"bedrock",model:e,region:this.required("AWS_BEDROCK_REGION",`${r}.region`),...this.optional("AWS_BASE_URL")&&{baseUrl:this.optional("AWS_BASE_URL")},...n&&i&&{accessKeyId:n,secretAccessKey:i,...this.optional("BEDROCK_AWS_SESSION_TOKEN")&&{sessionToken:this.optional("BEDROCK_AWS_SESSION_TOKEN")}}}}vertex(e,r){let n=this.optional("VERTEX_API_KEY"),i=this.optional("VERTEX_CLIENT_EMAIL"),o=this.optional("VERTEX_PRIVATE_KEY"),s=this.optional("GOOGLE_APPLICATION_CREDENTIALS"),a=i&&o?{type:"service_account",clientEmail:i,privateKey:o}:s?{type:"credentials_file",path:s}:n?{type:"api_key",apiKey:n}:null;return a||this.issues.push({path:`${r}.auth`,message:"VERTEX_API_KEY, VERTEX_CLIENT_EMAIL plus VERTEX_PRIVATE_KEY, or GOOGLE_APPLICATION_CREDENTIALS is required when using Vertex."}),e.startsWith("claude")&&a?.type==="api_key"&&this.issues.push({path:`${r}.auth`,message:"Vertex Claude models require service account or credentials-file auth."}),{provider:"vertex",model:e,...this.optional("VERTEX_PROJECT")&&{project:this.optional("VERTEX_PROJECT")},...this.optional("VERTEX_LOCATION")&&{location:this.optional("VERTEX_LOCATION")},auth:a||{type:"api_key",apiKey:""}}}webSearch(e,r){let n=this.choice("WEB_SEARCH_PROVIDER",tfe,"disabled","externalProviders.webSearch.provider"),i=this.optional("WEB_SEARCH_API_KEY"),o=rfe.includes(e)?e:null;return n==="disabled"?{provider:"disabled"}:n==="model_provider"?o?r.some(s=>s.provider!==o)?(this.issues.push({path:"externalProviders.webSearch",message:"WEB_SEARCH_PROVIDER=model_provider requires every PRIMARY_LLM_FALLBACKS entry to use the primary LLM provider."}),{provider:"disabled"}):{provider:"model_provider",llmProvider:o}:(this.issues.push({path:"externalProviders.webSearch",message:"WEB_SEARCH_PROVIDER=model_provider requires OpenAI, Anthropic, or Azure."}),{provider:"disabled"}):n==="tavily"?i?{provider:"tavily",apiKey:i}:(this.issues.push({path:"externalProviders.webSearch.apiKey",message:"WEB_SEARCH_API_KEY is required when WEB_SEARCH_PROVIDER=tavily."}),{provider:"disabled"}):n==="searxng"?this.searxng(i):{provider:"disabled"}}searxng(e){return{provider:"searxng",endpoint:this.required("WEB_SEARCH_ENDPOINT","externalProviders.webSearch.endpoint"),...e&&{apiKey:e}}}posthog(){return this.boolean("POSTHOG_ENABLED",!1,"externalProviders.posthog.enabled")?{enabled:!0,apiKey:this.required("POSTHOG_KEY","externalProviders.posthog.apiKey"),serverHost:this.required("POSTHOG_HOST","externalProviders.posthog.serverHost")}:{enabled:!1}}langfuse(){return this.boolean("LANGFUSE_ENABLED",!1,"externalProviders.langfuse.enabled")?{enabled:!0,publicKey:this.required("LANGFUSE_PUBLIC_KEY","externalProviders.langfuse.publicKey"),secretKey:this.required("LANGFUSE_SECRET_KEY","externalProviders.langfuse.secretKey"),baseUrl:this.required("LANGFUSE_BASE_URL","externalProviders.langfuse.baseUrl"),tracingEnvironment:this.required("LANGFUSE_TRACING_ENVIRONMENT","externalProviders.langfuse.tracingEnvironment")}:{enabled:!1}}resend(){return this.boolean("RESEND_ENABLED",!1,"externalProviders.resend.enabled")?{enabled:!0,apiKey:this.required("RESEND_API_KEY","externalProviders.resend.apiKey"),fromEmail:this.required("RESEND_FROM_EMAIL","externalProviders.resend.fromEmail")}:{enabled:!1}}loops(){return this.boolean("LOOPS_ENABLED",!1,"externalProviders.loops.enabled")?{enabled:!0,apiKey:this.required("LOOPS_API_KEY","externalProviders.loops.apiKey")}:{enabled:!1}}teamsBot(){return this.boolean("TEAMS_BOT_ENABLED",!1,"externalProviders.teamsBot.enabled")?{enabled:!0,appId:this.required("TEAMS_BOT_APP_ID","externalProviders.teamsBot.appId"),appPassword:this.required("TEAMS_BOT_APP_PASSWORD","externalProviders.teamsBot.appPassword"),tenantId:this.optional("TEAMS_BOT_TENANT_ID")??null}:{enabled:!1}}bundles(){let e=this.optional("SAGE_INTACCT_SENDER_ID"),r=this.optional("SAGE_INTACCT_SENDER_PASSWORD");return(e&&!r||!e&&r)&&this.issues.push({path:"bundles.sageIntacctSender",message:"SAGE_INTACCT_SENDER_ID and SAGE_INTACCT_SENDER_PASSWORD must be set together."}),{sageIntacctSender:e&&r?{senderId:e,senderPassword:r}:null}}billing(e){return e==="enterprise"?{provider:"disabled"}:{provider:"stripe",secretKey:this.required("STRIPE_SECRET_KEY","billing.secretKey"),webhookSecret:this.required("STRIPE_WEBHOOK_SECRET","billing.webhookSecret"),productIds:this.stripeProductIds()}}stripeProductIds(){let e=this.optional("STRIPE_PRODUCT_IDS");if(!e)return Ag;try{let r=JSON.parse(e);if(!r||typeof r!="object"||Array.isArray(r))return this.issues.push({path:"billing.productIds",message:"STRIPE_PRODUCT_IDS must be a JSON object."}),Ag;let n={...Ag};for(let i of efe){let o=r[i];typeof o=="string"&&o.trim()&&(n[i]=o.trim())}return n}catch{return this.issues.push({path:"billing.productIds",message:"STRIPE_PRODUCT_IDS must be valid JSON."}),Ag}}auth(){let e=this.optional("OKTA_SCIM_TOKEN");e&&e.length<32&&this.issues.push({path:"auth.providers.okta.scimToken",message:"OKTA_SCIM_TOKEN must contain at least 32 characters."});let r=this.listChoice("AUTH_PROVIDERS",Nx,"auth.providers"),n=new Map,i=this.configuredOAuthProvider("google","GOOGLE"),o=this.configuredOAuthProvider("github","GITHUB"),s=this.configuredOktaProvider();i&&n.set("google",i),o&&n.set("github",o),s&&n.set("okta",s);for(let d of r)switch(d){case"email_password":n.set(d,{provider:d});break;case"google":n.set(d,this.oauthProvider(d,"GOOGLE","auth.providers.google"));break;case"github":n.set(d,this.oauthProvider(d,"GITHUB","auth.providers.github"));break;case"okta":n.set(d,this.oktaProvider());break}let a=Nx.flatMap(d=>{let A=n.get(d);return A?[A]:[]}),c=this.requiredBoolean("AUTH_DISABLE_SIGNUP",!1,"auth.disableSignup"),u=this.requiredBoolean("AUTH_DISABLE_INVITES",!1,"auth.disableInvites"),l=n.has("okta");return c&&u&&!l&&this.issues.push({path:"auth",message:"AUTH_DISABLE_SIGNUP and AUTH_DISABLE_INVITES cannot both be true without an Okta provider \u2014 no account creation path would remain."}),{providers:a,visibleProviders:r,disableSignup:c,disableInvites:u}}configuredOAuthProvider(e,r){let n=this.optional(`${r}_CLIENT_ID`),i=this.optional(`${r}_CLIENT_SECRET`);if(!(!n||!i))return{provider:e,clientId:n,clientSecret:i}}configuredOktaProvider(){let e=this.optional("OKTA_CLIENT_ID"),r=this.optional("OKTA_CLIENT_SECRET"),n=this.optional("OKTA_ISSUER"),i=this.optional("OKTA_ORG_ID"),o=this.optional("OKTA_SCIM_TOKEN");if(!(!e||!r||!n||!i))return{provider:"okta",clientId:e,clientSecret:r,issuer:n.replace(/\/$/,""),organizationId:i,...o?{scimToken:o}:{}}}oauthProvider(e,r,n){return{provider:e,clientId:this.required(`${r}_CLIENT_ID`,`${n}.clientId`),clientSecret:this.required(`${r}_CLIENT_SECRET`,`${n}.clientSecret`)}}oktaProvider(){let e=this.optional("OKTA_SCIM_TOKEN");return{provider:"okta",clientId:this.required("OKTA_CLIENT_ID","auth.providers.okta.clientId"),clientSecret:this.required("OKTA_CLIENT_SECRET","auth.providers.okta.clientSecret"),issuer:this.required("OKTA_ISSUER","auth.providers.okta.issuer").replace(/\/$/,""),organizationId:this.required("OKTA_ORG_ID","auth.providers.okta.organizationId"),...e?{scimToken:e}:{}}}},fg=class extends Error{constructor(e){super(`Invalid deployment environment:
692
+ `.trim();var Kpe=`<style data-sg-base>${ou.ARTIFACT_BASE_CSS}</style>`;function Xpe(t){return t.includes("<style data-sg-base>")?t:(0,Zpe.injectHeadStyle)(t,Kpe,"start")}});var Ox=m(Md=>{"use strict";Object.defineProperty(Md,"__esModule",{value:!0});Md.DeploymentConfigError=void 0;Md.buildDeploymentConfig=ofe;var efe=["pro","team","enterprise"],Ag={pro:"prod_UjB46ulzKsQ1Ef",team:"prod_UiMeaL02tN4BMg",enterprise:"prod_UapuUIQQuluzUV"},pg=["openai","anthropic","gemini","azure","bedrock","vertex"],tfe=["tavily","model_provider","searxng","disabled"],rfe=["openai","anthropic","azure"],nfe=["cloud","enterprise"],ife=["aws","minio"],Nx=["email_password","google","github","okta"],Mb=class{constructor(e){this.raw=e,this.issues=[]}build(){let e=this.requiredPort("API_PORT",3002,"runtime.apiPort"),r=this.requiredPort("WEB_PORT",3001,"runtime.webPort"),n=this.requiredUrl("PUBLIC_API_URL",`http://localhost:${e}`,"runtime.publicApiUrl"),i=this.url("INTERNAL_API_URL",n,"runtime.internalApiUrl"),o=this.requiredUrl("PUBLIC_APP_URL","https://app.superglue.cloud","runtime.publicAppUrl"),s=this.url("INTERNAL_APP_URL",o,"runtime.internalAppUrl"),a=this.deploymentMode(),c=this.requiredBoolean("BLOCK_LOCAL_REQUESTS",!1,"security.blockLocalRequests"),u=this.llm(this.choice("PRIMARY_LLM_PROVIDER",pg,"openai","llm.primary.provider"),this.required("PRIMARY_LLM_MODEL","llm.primary.model"),"llm.primary"),l=this.llmFallbacks(),d=this.llm(this.choice("SUMMARIZE_LLM_PROVIDER",pg,"openai","llm.summarize.provider"),this.required("SUMMARIZE_LLM_MODEL","llm.summarize.model"),"llm.summarize"),A={deployment:{mode:a,orgConcurrencyLimits:a==="enterprise"?"disabled":"tier_config"},runtime:{apiPort:e,webPort:r,publicApiUrl:n,internalApiUrl:i,publicAppUrl:o,internalAppUrl:s,scheduler:this.scheduler()},website:{contactFormToEmail:this.optional("WEBSITE_CONTACT_FORM_TO_EMAIL")??null},security:{jwtSecret:this.required("JWT_AUTH_SECRET","security.jwtSecret"),internalApiToken:this.required("INTERNAL_API_TOKEN","security.internalApiToken"),credentialsEncryptionKey:this.required("MASTER_ENCRYPTION_KEY","security.credentialsEncryptionKey"),blockLocalRequests:c,trustProxyHops:this.nonNegativeInteger("TRUST_PROXY_HOPS",1,"security.trustProxyHops")},storage:{postgres:{host:this.required("POSTGRES_HOST","storage.postgres.host"),port:this.requiredPort("POSTGRES_PORT",5432,"storage.postgres.port"),username:this.required("POSTGRES_USERNAME","storage.postgres.username"),password:this.required("POSTGRES_PASSWORD","storage.postgres.password"),database:this.required("POSTGRES_DB","storage.postgres.database"),ssl:this.requiredBoolean("POSTGRES_SSL",!0,"storage.postgres.ssl")},objectStorage:this.objectStorage()},llm:{primary:u,primaryFallbacks:l,summarize:d},externalProviders:{posthog:this.posthog(),langfuse:this.langfuse(),resend:this.resend(),loops:this.loops(),teamsBot:this.teamsBot(),webSearch:this.webSearch(u.provider,l)},billing:this.billing(a),bundles:this.bundles(),features:{briefings:this.boolean("BRIEFINGS_ENABLED",!1,"features.briefings")},auth:this.auth()};if(this.issues.length>0)throw new fg(this.issues);return A}optional(e){let r=this.raw[e]?.trim();return r||void 0}required(e,r){let n=this.optional(e);return n||(this.issues.push({path:r,message:`${e} is required.`}),"")}requiredOptional(e,r){let n=this.optional(e);return n||this.issues.push({path:r,message:`${e} is required.`}),n}boolean(e,r,n){let i=this.optional(e);return i?i==="true"?!0:i==="false"?!1:(this.issues.push({path:n,message:`${e} must be "true" or "false".`}),r):r}requiredBoolean(e,r,n){let i=this.requiredOptional(e,n);return i?i==="true"?!0:i==="false"?!1:(this.issues.push({path:n,message:`${e} must be "true" or "false".`}),r):r}port(e,r,n){let i=this.optional(e);if(!i)return r;let o=Number(i);return!Number.isInteger(o)||o<1||o>65535?(this.issues.push({path:n,message:`${e} must be a TCP port between 1 and 65535.`}),r):o}nonNegativeInteger(e,r,n){let i=this.optional(e);if(!i)return r;let o=Number(i);return!Number.isInteger(o)||o<0?(this.issues.push({path:n,message:`${e} must be a non-negative integer.`}),r):o}requiredPort(e,r,n){return this.requiredOptional(e,n)?this.port(e,r,n):r}url(e,r,n){let i=this.optional(e)||r;try{return new URL(i).toString().replace(/\/$/,"")}catch{return this.issues.push({path:n,message:`${e} must be a valid URL.`}),r}}requiredUrl(e,r,n){return this.requiredOptional(e,n)?this.url(e,r,n):r}choice(e,r,n,i){let o=this.requiredOptional(e,i)?.toLowerCase();return o?r.includes(o)?o:(this.issues.push({path:i,message:`${e} must be one of: ${r.join(", ")}.`}),n):n}listChoice(e,r,n){let i=this.requiredOptional(e,n);if(!i)return[];let o=[],s=new Set;for(let a of i.split(",")){let c=a.trim().toLowerCase();if(!(!c||s.has(c))){if(s.add(c),r.includes(c)){o.push(c);continue}this.issues.push({path:n,message:`${e} contains unsupported value "${c}". Use one of: ${r.join(", ")}.`})}}return o.length===0&&this.issues.push({path:n,message:`${e} must include at least one provider.`}),o}list(e){return(this.optional(e)??"").split(",").map(r=>r.trim()).filter(Boolean)}deploymentMode(){return this.choice("DEPLOYMENT_MODE",nfe,"cloud","deployment.mode")}scheduler(){return this.requiredBoolean("START_SCHEDULER_SERVER",!1,"runtime.scheduler.mode")?{mode:"in_process"}:{mode:"disabled"}}objectStorage(){if(this.choice("S3_PROVIDER",ife,"aws","storage.objectStorage.provider")==="minio")return{provider:"minio",endpoint:this.required("S3_ENDPOINT","storage.objectStorage.endpoint"),publicEndpoint:this.optional("S3_PUBLIC_ENDPOINT")??null,bucketName:this.required("MINIO_BUCKET_NAME","storage.objectStorage.bucketName"),bucketPrefix:this.bucketPrefix(this.optional("MINIO_BUCKET_PREFIX")||this.optional("AWS_BUCKET_PREFIX")),accessKeyId:this.required("MINIO_ROOT_USER","storage.objectStorage.accessKeyId"),secretAccessKey:this.required("MINIO_ROOT_PASSWORD","storage.objectStorage.secretAccessKey")};let r=this.optional("AWS_S3_ACCESS_KEY_ID"),n=this.optional("AWS_S3_SECRET_ACCESS_KEY");return(r&&!n||!r&&n)&&this.issues.push({path:"storage.objectStorage.credentials",message:"AWS_S3_ACCESS_KEY_ID and AWS_S3_SECRET_ACCESS_KEY must be set together."}),{provider:"aws",region:this.required("AWS_S3_REGION","storage.objectStorage.region"),bucketName:this.required("AWS_BUCKET_NAME","storage.objectStorage.bucketName"),bucketPrefix:this.bucketPrefix(this.optional("AWS_BUCKET_PREFIX")),...r&&n?{accessKeyId:r,secretAccessKey:n,...this.optional("AWS_S3_SESSION_TOKEN")&&{sessionToken:this.optional("AWS_S3_SESSION_TOKEN")}}:{}}}bucketPrefix(e){let r=e?.replace(/^\/+|\/+$/g,"");return r?`${r}/`:""}llm(e,r,n){let i=e.toLowerCase();if(!pg.includes(i))return this.issues.push({path:`${n}.provider`,message:`${n} provider must be one of: ${pg.join(", ")}.`}),{provider:"openai",apiKey:this.optional("OPENAI_API_KEY")||"",model:r};switch(i){case"openai":return this.openai(r,n);case"anthropic":return this.anthropic(r,n);case"gemini":return this.gemini(r,n);case"azure":return this.azure(r,n);case"bedrock":return this.bedrock(r,n);case"vertex":return this.vertex(r,n)}}openai(e,r){return{provider:"openai",apiKey:this.required("OPENAI_API_KEY",`${r}.apiKey`),model:e,...e==="gpt-6.1-sol"&&{reasoningEffort:"medium"},...this.optional("OPENAI_BASE_URL")&&{baseUrl:this.optional("OPENAI_BASE_URL")}}}anthropic(e,r){return{provider:"anthropic",apiKey:this.required("ANTHROPIC_API_KEY",`${r}.apiKey`),model:e,...this.optional("ANTHROPIC_BASE_URL")&&{baseUrl:this.optional("ANTHROPIC_BASE_URL")}}}gemini(e,r){return{provider:"gemini",apiKey:this.required("GEMINI_API_KEY",`${r}.apiKey`),model:e,...this.optional("GEMINI_BASE_URL")&&{baseUrl:this.optional("GEMINI_BASE_URL")}}}llmFallbacks(){return this.list("PRIMARY_LLM_FALLBACKS").flatMap((e,r)=>{let n=`llm.primaryFallbacks.${r}`,i=e.indexOf(":"),o=e.slice(0,i).trim(),s=e.slice(i+1).trim();return i===-1||!o||!s?(this.issues.push({path:n,message:`PRIMARY_LLM_FALLBACKS entry "${e}" must use the provider:model format.`}),[]):[this.llm(o,s,n)]})}azure(e,r){let n=this.optional("AZURE_RESOURCE_NAME"),i=this.optional("AZURE_BASE_URL");return!n&&!i&&this.issues.push({path:r,message:"AZURE_RESOURCE_NAME or AZURE_BASE_URL is required when using Azure."}),{provider:"azure",apiKey:this.required("AZURE_API_KEY",`${r}.apiKey`),model:e,...n&&{resourceName:n},...i&&{baseUrl:i},...this.optional("AZURE_API_VERSION")&&{apiVersion:this.optional("AZURE_API_VERSION")},useDeploymentBasedUrls:this.boolean("AZURE_USE_DEPLOYMENT_BASED_URLS",!1,`${r}.useDeploymentBasedUrls`)}}bedrock(e,r){let n=this.optional("BEDROCK_AWS_ACCESS_KEY_ID"),i=this.optional("BEDROCK_AWS_SECRET_ACCESS_KEY");return(n&&!i||!n&&i)&&this.issues.push({path:`${r}.credentials`,message:"BEDROCK_AWS_ACCESS_KEY_ID and BEDROCK_AWS_SECRET_ACCESS_KEY must be set together."}),{provider:"bedrock",model:e,region:this.required("AWS_BEDROCK_REGION",`${r}.region`),...this.optional("AWS_BASE_URL")&&{baseUrl:this.optional("AWS_BASE_URL")},...n&&i&&{accessKeyId:n,secretAccessKey:i,...this.optional("BEDROCK_AWS_SESSION_TOKEN")&&{sessionToken:this.optional("BEDROCK_AWS_SESSION_TOKEN")}}}}vertex(e,r){let n=this.optional("VERTEX_API_KEY"),i=this.optional("VERTEX_CLIENT_EMAIL"),o=this.optional("VERTEX_PRIVATE_KEY"),s=this.optional("GOOGLE_APPLICATION_CREDENTIALS"),a=i&&o?{type:"service_account",clientEmail:i,privateKey:o}:s?{type:"credentials_file",path:s}:n?{type:"api_key",apiKey:n}:null;return a||this.issues.push({path:`${r}.auth`,message:"VERTEX_API_KEY, VERTEX_CLIENT_EMAIL plus VERTEX_PRIVATE_KEY, or GOOGLE_APPLICATION_CREDENTIALS is required when using Vertex."}),e.startsWith("claude")&&a?.type==="api_key"&&this.issues.push({path:`${r}.auth`,message:"Vertex Claude models require service account or credentials-file auth."}),{provider:"vertex",model:e,...this.optional("VERTEX_PROJECT")&&{project:this.optional("VERTEX_PROJECT")},...this.optional("VERTEX_LOCATION")&&{location:this.optional("VERTEX_LOCATION")},auth:a||{type:"api_key",apiKey:""}}}webSearch(e,r){let n=this.choice("WEB_SEARCH_PROVIDER",tfe,"disabled","externalProviders.webSearch.provider"),i=this.optional("WEB_SEARCH_API_KEY"),o=rfe.includes(e)?e:null;return n==="disabled"?{provider:"disabled"}:n==="model_provider"?o?r.some(s=>s.provider!==o)?(this.issues.push({path:"externalProviders.webSearch",message:"WEB_SEARCH_PROVIDER=model_provider requires every PRIMARY_LLM_FALLBACKS entry to use the primary LLM provider."}),{provider:"disabled"}):{provider:"model_provider",llmProvider:o}:(this.issues.push({path:"externalProviders.webSearch",message:"WEB_SEARCH_PROVIDER=model_provider requires OpenAI, Anthropic, or Azure."}),{provider:"disabled"}):n==="tavily"?i?{provider:"tavily",apiKey:i}:(this.issues.push({path:"externalProviders.webSearch.apiKey",message:"WEB_SEARCH_API_KEY is required when WEB_SEARCH_PROVIDER=tavily."}),{provider:"disabled"}):n==="searxng"?this.searxng(i):{provider:"disabled"}}searxng(e){return{provider:"searxng",endpoint:this.required("WEB_SEARCH_ENDPOINT","externalProviders.webSearch.endpoint"),...e&&{apiKey:e}}}posthog(){return this.boolean("POSTHOG_ENABLED",!1,"externalProviders.posthog.enabled")?{enabled:!0,apiKey:this.required("POSTHOG_KEY","externalProviders.posthog.apiKey"),serverHost:this.required("POSTHOG_HOST","externalProviders.posthog.serverHost")}:{enabled:!1}}langfuse(){return this.boolean("LANGFUSE_ENABLED",!1,"externalProviders.langfuse.enabled")?{enabled:!0,publicKey:this.required("LANGFUSE_PUBLIC_KEY","externalProviders.langfuse.publicKey"),secretKey:this.required("LANGFUSE_SECRET_KEY","externalProviders.langfuse.secretKey"),baseUrl:this.required("LANGFUSE_BASE_URL","externalProviders.langfuse.baseUrl"),tracingEnvironment:this.required("LANGFUSE_TRACING_ENVIRONMENT","externalProviders.langfuse.tracingEnvironment")}:{enabled:!1}}resend(){return this.boolean("RESEND_ENABLED",!1,"externalProviders.resend.enabled")?{enabled:!0,apiKey:this.required("RESEND_API_KEY","externalProviders.resend.apiKey"),fromEmail:this.required("RESEND_FROM_EMAIL","externalProviders.resend.fromEmail")}:{enabled:!1}}loops(){return this.boolean("LOOPS_ENABLED",!1,"externalProviders.loops.enabled")?{enabled:!0,apiKey:this.required("LOOPS_API_KEY","externalProviders.loops.apiKey")}:{enabled:!1}}teamsBot(){return this.boolean("TEAMS_BOT_ENABLED",!1,"externalProviders.teamsBot.enabled")?{enabled:!0,appId:this.required("TEAMS_BOT_APP_ID","externalProviders.teamsBot.appId"),appPassword:this.required("TEAMS_BOT_APP_PASSWORD","externalProviders.teamsBot.appPassword"),tenantId:this.optional("TEAMS_BOT_TENANT_ID")??null}:{enabled:!1}}bundles(){let e=this.optional("SAGE_INTACCT_SENDER_ID"),r=this.optional("SAGE_INTACCT_SENDER_PASSWORD");return(e&&!r||!e&&r)&&this.issues.push({path:"bundles.sageIntacctSender",message:"SAGE_INTACCT_SENDER_ID and SAGE_INTACCT_SENDER_PASSWORD must be set together."}),{sageIntacctSender:e&&r?{senderId:e,senderPassword:r}:null}}billing(e){return e==="enterprise"?{provider:"disabled"}:{provider:"stripe",secretKey:this.required("STRIPE_SECRET_KEY","billing.secretKey"),webhookSecret:this.required("STRIPE_WEBHOOK_SECRET","billing.webhookSecret"),productIds:this.stripeProductIds()}}stripeProductIds(){let e=this.optional("STRIPE_PRODUCT_IDS");if(!e)return Ag;try{let r=JSON.parse(e);if(!r||typeof r!="object"||Array.isArray(r))return this.issues.push({path:"billing.productIds",message:"STRIPE_PRODUCT_IDS must be a JSON object."}),Ag;let n={...Ag};for(let i of efe){let o=r[i];typeof o=="string"&&o.trim()&&(n[i]=o.trim())}return n}catch{return this.issues.push({path:"billing.productIds",message:"STRIPE_PRODUCT_IDS must be valid JSON."}),Ag}}auth(){let e=this.optional("OKTA_SCIM_TOKEN");e&&e.length<32&&this.issues.push({path:"auth.providers.okta.scimToken",message:"OKTA_SCIM_TOKEN must contain at least 32 characters."});let r=this.listChoice("AUTH_PROVIDERS",Nx,"auth.providers"),n=new Map,i=this.configuredOAuthProvider("google","GOOGLE"),o=this.configuredOAuthProvider("github","GITHUB"),s=this.configuredOktaProvider();i&&n.set("google",i),o&&n.set("github",o),s&&n.set("okta",s);for(let d of r)switch(d){case"email_password":n.set(d,{provider:d});break;case"google":n.set(d,this.oauthProvider(d,"GOOGLE","auth.providers.google"));break;case"github":n.set(d,this.oauthProvider(d,"GITHUB","auth.providers.github"));break;case"okta":n.set(d,this.oktaProvider());break}let a=Nx.flatMap(d=>{let A=n.get(d);return A?[A]:[]}),c=this.requiredBoolean("AUTH_DISABLE_SIGNUP",!1,"auth.disableSignup"),u=this.requiredBoolean("AUTH_DISABLE_INVITES",!1,"auth.disableInvites"),l=n.has("okta");return c&&u&&!l&&this.issues.push({path:"auth",message:"AUTH_DISABLE_SIGNUP and AUTH_DISABLE_INVITES cannot both be true without an Okta provider \u2014 no account creation path would remain."}),{providers:a,visibleProviders:r,disableSignup:c,disableInvites:u}}configuredOAuthProvider(e,r){let n=this.optional(`${r}_CLIENT_ID`),i=this.optional(`${r}_CLIENT_SECRET`);if(!(!n||!i))return{provider:e,clientId:n,clientSecret:i}}configuredOktaProvider(){let e=this.optional("OKTA_CLIENT_ID"),r=this.optional("OKTA_CLIENT_SECRET"),n=this.optional("OKTA_ISSUER"),i=this.optional("OKTA_ORG_ID"),o=this.optional("OKTA_SCIM_TOKEN");if(!(!e||!r||!n||!i))return{provider:"okta",clientId:e,clientSecret:r,issuer:n.replace(/\/$/,""),organizationId:i,...o?{scimToken:o}:{}}}oauthProvider(e,r,n){return{provider:e,clientId:this.required(`${r}_CLIENT_ID`,`${n}.clientId`),clientSecret:this.required(`${r}_CLIENT_SECRET`,`${n}.clientSecret`)}}oktaProvider(){let e=this.optional("OKTA_SCIM_TOKEN");return{provider:"okta",clientId:this.required("OKTA_CLIENT_ID","auth.providers.okta.clientId"),clientSecret:this.required("OKTA_CLIENT_SECRET","auth.providers.okta.clientSecret"),issuer:this.required("OKTA_ISSUER","auth.providers.okta.issuer").replace(/\/$/,""),organizationId:this.required("OKTA_ORG_ID","auth.providers.okta.organizationId"),...e?{scimToken:e}:{}}}},fg=class extends Error{constructor(e){super(`Invalid deployment environment:
693
693
  ${e.map(r=>`- ${r.path}: ${r.message}`).join(`
694
694
  `)}`),this.issues=e,this.name="DeploymentConfigError"}};Md.DeploymentConfigError=fg;function ofe(t){return new Mb(t).build()}});var Ux=m(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.readProcessDeploymentEnvironment=sfe;Ta.readProcessEnvironmentValue=xb;Ta.writeProcessEnvironmentValue=afe;Ta.isProcessEnvironmentValue=cfe;Ta.readProcessEnvironmentSnapshot=ufe;function sfe(){return process.env}function xb(t){return process.env[t]}function afe(t,e){process.env[t]=e}function cfe(t,e){return xb(t)===e}function ufe(t){return Object.fromEntries(t.map(e=>[e,xb(e)]))}});var xx=m(Mx=>{"use strict";Object.defineProperty(Mx,"__esModule",{value:!0})});var Px=m(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.ADD_VALID_INVITE_MESSAGE=void 0;St.normalizeInvitationEmail=Ss;St.isValidInvitationEmail=Pb;St.isOrganizationInviteRole=Lx;St.parseOrganizationInviteRole=Afe;St.getInvitationTimestamp=pfe;St.createInviteRow=ffe;St.isInviteRowEmpty=Fb;St.isInviteRowEmailInvalid=hfe;St.validateInviteRows=gfe;St.getInviteValidationMessage=mfe;St.getInviteRowsForInvitations=yfe;St.getInviteRowsForEmails=Efe;St.mapInvitationsToRows=Ife;St.formatEmailList=Lb;St.isStaleInvitationError=Cfe;var lfe=qc();St.ADD_VALID_INVITE_MESSAGE="Add at least one valid invite.";var dfe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function Ss(t){return t.trim().toLowerCase()}function Pb(t){return dfe.test(Ss(t))}function Lx(t){return t==="member"||t==="admin"}function Afe(t){return t?Lx(t)?t:null:"member"}function pfe(t){if(!t)return 0;let e=(0,lfe.getUTCTimestampMs)(t);return Number.isFinite(e)?e:0}function ffe(t,e){return{id:t,email:"",role:"member",...e?.length?{targetOrgIds:e}:{}}}function Fb(t){return!t.email.trim()&&t.role==="member"}function hfe(t,e){let r=Ss(t.email);return r?Pb(r)?e.filter(n=>Ss(n.email)===r).length>1:!0:!Fb(t)}function gfe(t){let e=new Set,r=[],n=[],i=[],o=0;for(let s of t){let a=Ss(s.email);if(!a){Fb(s)||(o+=1);continue}if(!Pb(a)){n.push(a);continue}if(e.has(a)){i.push(a);continue}if(e.add(a),s.targetOrgIds?.length)for(let c of s.targetOrgIds)r.push({email:a,role:s.role,targetOrgId:c});else r.push({email:a,role:s.role})}return{invitations:r,invalidEmails:n,duplicateEmails:i,incompleteRows:o}}function mfe(t){return t.invalidEmails.length>0?`Fix invalid email: ${Lb(t.invalidEmails)}`:t.duplicateEmails.length>0?`Remove duplicate email: ${Lb(t.duplicateEmails)}`:t.incompleteRows>0?"Check invite rows.":t.invitations.length===0?St.ADD_VALID_INVITE_MESSAGE:null}function yfe(t,e){let r=new Set(e.map(n=>n.email));return t.filter(n=>r.has(Ss(n.email)))}function Efe(t,e){let r=new Set(e.map(Ss));return t.filter(n=>r.has(Ss(n.email)))}function Ife(t,e){let r=new Map;for(let n of t){let i=r.get(n.email);if(i){n.targetOrgId&&!i.targetOrgIds?.includes(n.targetOrgId)&&(i.targetOrgIds=[...i.targetOrgIds??[],n.targetOrgId]);continue}r.set(n.email,{id:e(),email:n.email,role:n.role,...n.targetOrgId?{targetOrgIds:[n.targetOrgId]}:{}})}return[...r.values()]}function Lb(t){return t.length<=3?t.join(", "):`${t.slice(0,3).join(", ")} and ${t.length-3} more`}function Cfe(t){if(!(t instanceof Error))return!1;let e=t.message.toLowerCase();return e.includes("pending invitation not found")||e.includes("invitation has expired")}});var Fx=m(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.ORG_LOGO_STORAGE_PATH=Jt.LOGO_CONTENT_TYPE=Jt.LOGO_CANVAS_SIZE=Jt.ACCEPTED_LOGO_MIME_TYPES=Jt.UPLOADED_LOGO_TOKEN=void 0;Jt.isLibraryIconToken=Sfe;Jt.isUploadedLogoToken=wfe;Jt.isStoredLogo=Bfe;Jt.UPLOADED_LOGO_TOKEN="upload:custom";var bfe=["lucide:","simpleicons:"];function Sfe(t){return!!t&&bfe.some(e=>t.startsWith(e))}function wfe(t){return t===Jt.UPLOADED_LOGO_TOKEN}function Bfe(t){return!!t&&t.startsWith("s3://")}Jt.ACCEPTED_LOGO_MIME_TYPES=["image/png","image/jpeg","image/webp"];Jt.LOGO_CANVAS_SIZE=512;Jt.LOGO_CONTENT_TYPE="image/png";Jt.ORG_LOGO_STORAGE_PATH="org/logo.png"});var jx=m(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.MCP_SERVER_NAME_MAX_LENGTH=Pr.MCP_SERVER_NAME_MIN_LENGTH=void 0;Pr.sanitizeMcpServerNameInput=$x;Pr.slugifyMcpServerName=_fe;Pr.validateMcpServerName=Dfe;Pr.MCP_SERVER_NAME_MIN_LENGTH=2;Pr.MCP_SERVER_NAME_MAX_LENGTH=63;var Qfe=/^[a-z0-9][a-z0-9-]*[a-z0-9]$/,vfe=new Set([".well-known","oauth","health","register"]);function $x(t){return t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-")}function _fe(t){return $x(t).replace(/^-|-$/g,"")}function Dfe(t){return!t||t.length<Pr.MCP_SERVER_NAME_MIN_LENGTH||t.length>Pr.MCP_SERVER_NAME_MAX_LENGTH?`Name must be between ${Pr.MCP_SERVER_NAME_MIN_LENGTH} and ${Pr.MCP_SERVER_NAME_MAX_LENGTH} characters`:Qfe.test(t)?vfe.has(t)?`Name '${t}' is reserved`:null:"Name must contain only lowercase letters, numbers, and hyphens, and must start and end with a letter or number"}});var qx=m(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.MEMORY_NOTE_MAX_CHARS=ws.MEMORY_NOTE_SCOPES=void 0;ws.isMemoryNoteScope=Tfe;ws.MEMORY_NOTE_SCOPES=["user","org"];ws.MEMORY_NOTE_MAX_CHARS=500;function Tfe(t){return typeof t=="string"&&ws.MEMORY_NOTE_SCOPES.includes(t)}});var hg=m(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});su.parseJsonRecord=Rfe;su.buildAuthCodeExchangeRequest=kfe;su.buildClientCredentialsExchangeRequest=Nfe;su.buildRefreshTokenExchangeRequest=Ofe;function Rfe(t){if(t)try{return typeof t=="string"?JSON.parse(t):t}catch{return}}function $b(t,e,r){let n=t.tokenContentType==="json",i=t.tokenAuthMethod==="basic_auth",o={"Content-Type":n?"application/json":"application/x-www-form-urlencoded",Accept:"application/json",...t.extraHeaders};if(i&&r){let s=Buffer.from(`${encodeURIComponent(e)}:${encodeURIComponent(r)}`).toString("base64");o.Authorization=`Basic ${s}`}return o}function jb(t,e){return e?JSON.stringify(t):new URLSearchParams(t).toString()}function qb(t,e,r,n){(!(e.tokenAuthMethod==="basic_auth")||!n)&&(t.client_id=r,n&&(t.client_secret=n))}function kfe(t){let e=t.config||{},r=e.tokenContentType==="json",n={grant_type:"authorization_code",code:t.code,redirect_uri:t.redirectUri,...e.extraBodyParams};return qb(n,e,t.clientId,t.clientSecret),t.codeVerifier&&(n.code_verifier=t.codeVerifier),{url:t.tokenUrl,headers:$b(e,t.clientId,t.clientSecret),body:jb(n,r)}}function Nfe(t){let e=t.config||{},r=e.tokenContentType==="json",n={grant_type:"client_credentials",...t.scopes&&{scope:t.scopes},...e.extraBodyParams};return qb(n,e,t.clientId,t.clientSecret),{url:t.tokenUrl,headers:$b(e,t.clientId,t.clientSecret),body:jb(n,r)}}function Ofe(t){let e=t.config||{},r=e.tokenContentType==="json",n={grant_type:"refresh_token",refresh_token:t.refreshToken,...e.extraBodyParams};return qb(n,e,t.clientId,t.clientSecret),{url:t.tokenUrl,headers:$b(e,t.clientId,t.clientSecret),body:jb(n,r)}}});var Gx=m(gg=>{"use strict";Object.defineProperty(gg,"__esModule",{value:!0});gg.resolveOAuthConfig=void 0;var zx=hg(),Ufe=Td(),Hx=(t,e,r)=>{let n=(0,zx.parseJsonRecord)(t);return n||((0,zx.parseJsonRecord)(e)??r)},Mfe=(t,e,r)=>{let n=(0,Ufe.resolveOAuthConfigFromAuthentication)({input:t,authentication:r,templateOAuth:e});return Object.fromEntries(Object.entries({...n,extraHeaders:Hx(t.extraHeaders,n.extraHeaders,e?.extraHeaders),extraBodyParams:Hx(t.extraBodyParams,n.extraBodyParams,e?.extraBodyParams)}).filter(([,i])=>i!=null))};gg.resolveOAuthConfig=Mfe});var zb=m(xd=>{"use strict";Object.defineProperty(xd,"__esModule",{value:!0});xd.SUPERGLUE_LOGO_SVG=void 0;xd.parseLegacyBrandGuidelines=xfe;function xfe(t){let e=t.brand;if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e.guidelines;return typeof r=="string"&&r.trim()?r:null}xd.SUPERGLUE_LOGO_SVG='<svg viewBox="72 206 9240 2552" height="22" role="img" aria-label="superglue" xmlns="http://www.w3.org/2000/svg" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5"><g><path d="M9207.13,1482.19c0,-646.571 -524.934,-1171.51 -1171.51,-1171.51l-6687.56,-0c-646.571,-0 -1171.51,524.934 -1171.51,1171.51c0,646.571 524.934,1171.51 1171.51,1171.51l6687.56,0c646.571,0 1171.51,-524.934 1171.51,-1171.51Z" style="fill:#fff;stroke:#000;stroke-width:208.33px;"/><g><path d="M1207.81,2068.52l390.187,-0l1.044,-130.41l129.367,-0l-0,-390.188l-130.411,-0l0,-130.411l-130.41,0l-0,-130.41l-130.41,0l1.043,-261.864l259.777,0l0,-129.367l-390.187,0l-0,129.367l-130.411,1.043l0,390.188l130.411,0l-0,130.411l130.41,-0l-0,130.41l130.41,-0l0,260.821l-260.82,-0l-0,130.41Zm-130.411,-130.41l129.367,-0l0,-129.367l-129.367,-0l0,129.367Zm521.642,-782.463l129.367,0l-0,-129.367l-129.367,0l-0,129.367Z" style="fill-rule:nonzero;"/><path d="M1948.54,2068.52l520.599,-0l1.043,-130.41l129.367,-0l-0,-1042.24l-259.778,0l0,1042.24l-261.864,1.043l0,-1043.28l-259.777,0l0,1042.24l130.41,-0l0,130.41Z" style="fill-rule:nonzero;"/><path d="M2689.27,2068.52l259.778,-0l1.043,-521.641l390.188,-0l1.043,-130.411l129.367,0l0,-390.188l-130.41,0l-0,-130.41l-129.367,0l-0,520.598l-261.864,1.043l1.043,-392.274l259.777,0l0,-129.367l-520.598,0l0,1172.65Z" style="fill-rule:nonzero;"/><path d="M3560.41,2068.52l651.009,-0l-0,-129.367l-391.231,-0l1.043,-392.274l259.778,-0l-0,-129.368l-260.821,0l1.043,-392.274l390.188,0l-0,-129.367l-651.009,0l0,1172.65Z" style="fill-rule:nonzero;"/><path d="M4301.14,2068.52l259.778,-0l1.043,-521.641l260.821,-0l-0,521.641l259.777,-0l0,-520.598l-130.41,-0l1.043,-131.454l129.367,0l0,-390.188l-130.41,0l-0,-130.41l-129.367,0l-0,520.598l-261.864,1.043l1.043,-392.274l259.777,0l0,-129.367l-520.598,0l0,1172.65Z" style="fill-rule:nonzero;"/><path d="M5302.69,2068.52l520.598,-0l1.043,-130.41l129.367,-0l0,-520.599l-259.777,0l-0,520.599l-261.864,1.043l1.043,-913.916l390.188,0l-0,-129.367l-520.598,0l-0,129.367l-130.411,1.043l0,911.83l130.411,-0l-0,130.41Zm521.641,-912.873l129.367,0l0,-129.367l-129.367,0l0,129.367Z" style="fill-rule:nonzero;"/><path d="M6043.42,2068.52l651.008,-0l0,-129.367l-391.231,-0l0,-1043.28l-259.777,0l-0,1172.65Z" style="fill-rule:nonzero;"/><path d="M6914.56,2068.52l520.598,-0l1.043,-130.41l129.367,-0l0,-1042.24l-259.777,0l-0,1042.24l-261.864,1.043l-0,-1043.28l-259.777,0l-0,1042.24l130.41,-0l-0,130.41Z" style="fill-rule:nonzero;"/><path d="M7655.29,2068.52l651.008,-0l0,-129.367l-391.231,-0l1.043,-392.274l259.778,-0l-0,-129.368l-260.821,0l1.043,-392.274l390.188,0l0,-129.367l-651.008,0l-0,1172.65Z" style="fill-rule:nonzero;"/></g></g></svg>'});var Hb=m(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.designCustomCssSchema=gt.designStyleSchema=gt.DESIGN_CUSTOM_CSS_MAX_CHARS=gt.DESIGN_STYLE_OPTIONS=void 0;gt.compileDesignStyleCss=$fe;gt.hasDesignStyle=jfe;var Fr=Bd();gt.DESIGN_STYLE_OPTIONS={header:["rule","band","minimal","centered"],surfaces:["outline","shadow","filled","flat","accent-top","accent-left"],headingCase:["none","upper"],headingDecoration:["none","underline","bar"],tables:["lines","grid","striped","header-filled"],buttons:["rounded","pill","square"],density:["compact","regular","airy"],bullets:["disc","dash","arrow","square"]};gt.DESIGN_CUSTOM_CSS_MAX_CHARS=2e4;var Lfe=/<|url\s*\(|@import|expression\s*\(|javascript:|behavior\s*:|-moz-binding/i;gt.designStyleSchema=Fr.z.object({header:Fr.z.enum(gt.DESIGN_STYLE_OPTIONS.header).optional(),surfaces:Fr.z.enum(gt.DESIGN_STYLE_OPTIONS.surfaces).optional(),headingCase:Fr.z.enum(gt.DESIGN_STYLE_OPTIONS.headingCase).optional(),headingDecoration:Fr.z.enum(gt.DESIGN_STYLE_OPTIONS.headingDecoration).optional(),headingWeight:Fr.z.number().int().min(100).max(900).optional(),headingTracking:Fr.z.number().min(-.08).max(.3).optional(),headingScale:Fr.z.number().min(.8).max(1.5).optional(),tables:Fr.z.enum(gt.DESIGN_STYLE_OPTIONS.tables).optional(),buttons:Fr.z.enum(gt.DESIGN_STYLE_OPTIONS.buttons).optional(),density:Fr.z.enum(gt.DESIGN_STYLE_OPTIONS.density).optional(),bullets:Fr.z.enum(gt.DESIGN_STYLE_OPTIONS.bullets).optional()}).describe("Component and layout style: header (rule, band, minimal, centered), surfaces for cards and KPI tiles (outline, shadow, filled, flat, accent-top, accent-left), headingCase (none, upper), headingDecoration (none, underline, bar), headingWeight 100-900, headingTracking in em (-0.08 to 0.3), headingScale (0.8 to 1.5), tables (lines, grid, striped, header-filled), buttons (rounded, pill, square), density (compact, regular, airy), bullets (disc, dash, arrow, square).");gt.designCustomCssSchema=Fr.z.string().max(gt.DESIGN_CUSTOM_CSS_MAX_CHARS).refine(t=>!Lfe.test(t),{message:"Custom CSS cannot contain <, url(), @import, expression(), or javascript:"}).describe("Extra CSS applied to every artifact after the theme. Style the sg-* classes and elements; no url(), @import, or <.");var Yx=".sg-card,.sg-kpi,.sg-callout,.sg-table",Pfe={dash:"\u2013",arrow:"\u2192"},Ffe={header:{band:".sg-header{background:var(--sg-header-bg);color:var(--sg-header-ink);border:0;padding:18px 24px;border-radius:var(--sg-radius-xl)}.sg-header .sg-header-title,.sg-header .sg-header-meta,.sg-header .sg-eyebrow{color:inherit}.sg-header .sg-header-meta{opacity:.85}",minimal:".sg-header{border-bottom:0;padding-bottom:0}",centered:".sg-header{flex-direction:column;align-items:center;text-align:center;gap:10px}.sg-header .sg-header-meta{margin-left:0}main>h1,main>h1+p,.sg-header+h1,.sg-header+.sg-eyebrow,.sg-eyebrow+h1{text-align:center}"},surfaces:{shadow:`${Yx}{border-color:transparent;box-shadow:0 1px 2px rgb(0 0 0/.06),0 6px 18px rgb(0 0 0/.08)}`,filled:`${Yx}{background:var(--sg-surface-2);border-color:transparent;box-shadow:none}`,flat:".sg-card,.sg-kpi{background:transparent;border-color:transparent;box-shadow:none;padding-left:0;padding-right:0}.sg-callout{background:transparent;box-shadow:none}","accent-top":".sg-card,.sg-kpi{border-top:4px solid var(--sg-primary)}","accent-left":".sg-card,.sg-kpi{border-left:4px solid var(--sg-primary)}"},headingCase:{upper:"h1,h2,h3,.sg-kpi-label,.sg-table th{text-transform:uppercase}"},headingDecoration:{underline:"h2{padding-bottom:6px;border-bottom:2px solid var(--sg-primary)}",bar:'h2::before{content:"";display:block;width:40px;height:4px;margin:0 0 10px;background:var(--sg-primary);border-radius:2px}'},tables:{grid:".sg-table th,.sg-table td{border-right:1px solid var(--sg-line-2)}.sg-table th:last-child,.sg-table td:last-child{border-right:0}",striped:".sg-table tbody tr:nth-child(even) td{background:var(--sg-surface)}","header-filled":".sg-table th{background:var(--sg-primary);color:var(--sg-on-primary)}"},buttons:{pill:".sg-button{border-radius:999px}",square:".sg-button{border-radius:0}.sg-badge{border-radius:2px}"},density:{compact:"body{line-height:1.45}.sg-card,.sg-kpi{padding:10px 12px}.sg-grid{gap:8px}.sg-header{margin-bottom:16px}h2{margin-top:18px}",airy:"body{line-height:1.7}.sg-card,.sg-kpi{padding:22px 26px}.sg-grid{gap:20px}.sg-header{margin-bottom:36px}h2{margin-top:40px}"},bullets:{square:"main ul{list-style:square}"}};function $fe(t){if(!t)return"";let e=[];for(let i of Object.keys(gt.DESIGN_STYLE_OPTIONS)){let o=t[i];if(!o)continue;let s=Ffe[i][o];s&&e.push(s)}let r=t.bullets?Pfe[t.bullets]:void 0;r&&e.push(`main ul{list-style:none;padding-left:1.4em}main ul>li{position:relative}main ul>li::before{content:"${r}";position:absolute;left:-1.4em;color:var(--sg-accent)}`);let n=[];return t.headingWeight!==void 0&&n.push(`font-weight:${t.headingWeight}`),t.headingTracking!==void 0&&n.push(`letter-spacing:${t.headingTracking}em`),n.length&&e.push(`h1,h2,h3{${n.join(";")}}`),t.headingScale!==void 0&&e.push(`:root{--sg-heading-scale:${t.headingScale}}`),e.join(`
695
695
  `)}function jfe(t){return!!t&&Object.values(t).some(e=>e!==void 0)}});var aL=m(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.SUPERGLUE_ATTRIBUTION_TEXT=Y.SUPERGLUE_ATTRIBUTION_URL=Y.DESIGN_LOGO_SLOT_REFERENCES=Y.designTokensSchema=Y.designFontRoleSchema=Y.designColorSchema=Y.DESIGN_FONT_FAMILY_PATTERN=Y.DESIGN_THEME_FONT_MAX_BYTES=Y.DESIGN_ASSET_LIMITS=Y.DESIGN_TEMPLATE_FORMATS=Y.DESIGN_LOGO_VARIANTS=Y.DESIGN_ASSET_KINDS=Y.DESIGN_FONT_CONTENT_TYPES=Y.DESIGN_FONT_FORMATS=Y.DESIGN_FONT_ROLES=Y.DESIGN_COLOR_ROLE_LABELS=Y.DESIGN_COLOR_ROLES=Y.DESIGN_CHART_COLOR_COUNT=Y.DESIGN_ASSET_DESCRIPTION_MAX_CHARS=Y.DESIGN_ASSET_NAME_MAX_CHARS=Y.DESIGN_GUIDELINES_MAX_CHARS=void 0;Y.applyThemeLogos=Kx;Y.hasDarkHeaderBand=Xx;Y.isDeckArtifactHtml=Jfe;Y.isDesignSystemEmpty=Wfe;Y.hasDesignTokens=Gb;Y.designFontStack=mg;Y.relativeLuminance=eL;Y.isDarkColor=tL;Y.superglueFontRoles=rL;Y.compileDesignSystemCss=the;Y.buildDesignFontFaceCss=nL;Y.selectThemeFontsForHtml=iL;Y.buildDesignThemeStyle=oL;Y.superglueLogoDataUri=she;Y.injectArtifactAttribution=sL;Y.decorateArtifactHtml=uhe;var Hn=Bd(),qfe=Ub(),Wx=Nb(),zfe=zb(),yg=Hb(),Zx=Ud();Y.DESIGN_GUIDELINES_MAX_CHARS=8e3;Y.DESIGN_ASSET_NAME_MAX_CHARS=120;Y.DESIGN_ASSET_DESCRIPTION_MAX_CHARS=500;Y.DESIGN_CHART_COLOR_COUNT=8;Y.DESIGN_COLOR_ROLES=["background","surface","text","mutedText","border","primary","onPrimary","accent","link","success","warning","danger"];Y.DESIGN_COLOR_ROLE_LABELS={background:"Page background",surface:"Cards and panels",text:"Text",mutedText:"Secondary text",border:"Borders",primary:"Brand color",onPrimary:"Text on brand color",accent:"Second brand color",link:"Links",success:"Success",warning:"Warning",danger:"Error"};Y.DESIGN_FONT_ROLES=["heading","body","mono"];Y.DESIGN_FONT_FORMATS=["woff2","woff","ttf","otf"];Y.DESIGN_FONT_CONTENT_TYPES={woff2:"font/woff2",woff:"font/woff",ttf:"font/ttf",otf:"font/otf"};Y.DESIGN_ASSET_KINDS=["logo","font","template","reference"];Y.DESIGN_LOGO_VARIANTS=["on-dark","icon"];Y.DESIGN_TEMPLATE_FORMATS=["html","docx","pptx"];Y.DESIGN_ASSET_LIMITS={logo:{maxCount:Y.DESIGN_LOGO_VARIANTS.length,maxBytes:10*1024*1024},font:{maxCount:8,maxBytes:1024*1024},template:{maxCount:20,maxBytes:20*1024*1024},reference:{maxCount:30,maxBytes:50*1024*1024}};Y.DESIGN_THEME_FONT_MAX_BYTES=3*1024*1024;var Hfe=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;Y.DESIGN_FONT_FAMILY_PATTERN=/^[\p{L}\p{N} ._&+-]{1,80}$/u;var Gfe=/^[\p{L}\p{N} ,._"'-]{1,200}$/u;Y.designColorSchema=Hn.z.string().trim().regex(Hfe,"Use a hex color such as #1a2b3c");Y.designFontRoleSchema=Hn.z.object({family:Hn.z.string().trim().regex(Y.DESIGN_FONT_FAMILY_PATTERN,"Use a plain font family name without quotes"),fallback:Hn.z.string().trim().regex(Gfe,"Use a CSS font stack such as Arial, sans-serif").optional()});Y.designTokensSchema=Hn.z.object({colors:Hn.z.partialRecord(Hn.z.enum(Y.DESIGN_COLOR_ROLES),Y.designColorSchema).optional().describe(`Hex color per role: ${Y.DESIGN_COLOR_ROLES.join(", ")}.`),chart:Hn.z.array(Y.designColorSchema).max(Y.DESIGN_CHART_COLOR_COUNT).optional().describe("Data-series colors in order, at most 8."),fonts:Hn.z.partialRecord(Hn.z.enum(Y.DESIGN_FONT_ROLES),Y.designFontRoleSchema).optional().describe("Font per role (heading, body, mono): { family, fallback? } with the family name unquoted and an optional CSS fallback stack."),radius:Hn.z.number().int().min(0).max(32).optional().describe("Corner radius in px, 0-32."),style:yg.designStyleSchema.optional(),css:yg.designCustomCssSchema.optional()});Y.DESIGN_LOGO_SLOT_REFERENCES={primary:"design/logo","on-dark":"design/logo-on-dark",icon:"design/logo-icon"};var Yfe=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*\sdata-sg-logo\s*=\s*"(primary|on-dark|icon)"(?:[^>"']|"[^"]*"|'[^']*')*>/gi,Vfe=/<(header|div)\b[^>]*\sclass\s*=\s*"[^"]*\bsg-header\b[^"]*"[^>]*>[\s\S]*?<\/\1>/gi;function Vx(t,e){return t.replace(Yfe,(r,n)=>{let i=e(n);return i?r.replace(/\ssrc\s*=\s*("[^"]*"|'[^']*'|[^\s"'>]+)/i,` src="${i}"`):r})}function Kx(t,e){let r=e.header?t.replace(Vfe,n=>Vx(n,i=>i==="primary"?e.header:void 0)):t;return Vx(r,n=>e[n]??e.primary)}function Xx(t){return t.style?.header==="band"&&tL(t.colors?.primary??Zx.SUPERGLUE_DESIGN.colors.primary)}function Jfe(t){return/<main\b[^>]*\bdata-sg-deck\b/i.test(t)}function Wfe(t){return t?!t.guidelines&&t.assets.length===0&&!Gb(t.tokens):!0}function Gb(t){return t?Object.keys(t.colors??{}).length>0||(t.chart?.length??0)>0||Object.keys(t.fonts??{}).length>0||t.radius!==void 0||(0,yg.hasDesignStyle)(t.style)||!!t.css?.trim():!1}var Zfe='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif',Kfe="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";function mg(t,e){let r=e.fallback??(t==="mono"?Kfe:Zfe);return`"${e.family}", ${r}`}function Xfe(t){let e=t.slice(1);return e.length===3&&(e=[...e].map(r=>r+r).join("")),[0,2,4].map(r=>parseInt(e.slice(r,r+2),16))}function eL(t){let e=Xfe(t).map(r=>{let n=r/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4});return .2126*e[0]+.7152*e[1]+.0722*e[2]}function tL(t){return eL(t)<.18}var ehe={background:["--sg-bg"],surface:["--sg-surface"],text:["--sg-ink"],mutedText:["--sg-ink-2"],border:["--sg-line"],primary:["--sg-primary","--sg-ring"],onPrimary:["--sg-on-primary"],accent:["--sg-accent"],link:["--sg-link"],success:["--sg-success"],warning:["--sg-warning"],danger:["--sg-destructive"]};function rL(t){let e=t.fonts??{};return Y.DESIGN_FONT_ROLES.filter(r=>!e[r]&&!(r==="heading"&&e.body))}function the(t,{htmlTemplates:e,hasOnDarkLogo:r}){let n=t.fonts?.heading?"h1,h2,h3,h4,h5,h6{font-family:var(--sg-font-heading)}":rL(t).includes("heading")&&!e?Zx.SUPERGLUE_HEADING_CSS:"";if(!Gb(t))return n;let i=[],o=t.colors??{};for(let a of Y.DESIGN_COLOR_ROLES){let c=o[a];if(c)for(let u of ehe[a])i.push(`${u}:${c}`)}o.surface&&i.push(`--sg-surface-2:color-mix(in srgb,${o.surface} 92%,var(--sg-ink))`),o.mutedText&&i.push(`--sg-ink-3:color-mix(in srgb,${o.mutedText} 75%,var(--sg-bg))`),o.border&&(i.push(`--sg-line-2:color-mix(in srgb,${o.border} 60%,var(--sg-bg))`),i.push(`--sg-input:color-mix(in srgb,${o.border} 80%,var(--sg-ink))`)),o.primary&&i.push(`--sg-primary-hover:color-mix(in srgb,${o.primary} 85%,#000)`),(t.chart??[]).forEach((a,c)=>i.push(`--sg-chart-${c+1}:${a}`));let s=t.fonts??{};return s.body&&i.push(`--sg-font-sans:${mg("body",s.body)}`),s.heading?i.push(`--sg-font-heading:${mg("heading",s.heading)}`):s.body&&i.push("--sg-font-heading:var(--sg-font-sans)"),s.mono&&i.push(`--sg-font-mono:${mg("mono",s.mono)}`),t.radius!==void 0&&(i.push(`--sg-radius:${t.radius}px`),i.push(`--sg-radius-md:${Math.round(t.radius*.75)}px`),i.push(`--sg-radius-xl:${Math.round(t.radius*1.5)}px`)),[i.length?`:root{${i.join(";")}}`:"",n,(0,yg.compileDesignStyleCss)(t.style),Xx(t)&&!r?".sg-header img{box-sizing:content-box;background:#fff;padding:6px 10px;border-radius:var(--sg-radius-md)}":"",t.css?.trim()??""].filter(Boolean).join(`
@@ -1807,7 +1807,7 @@ ${s}`;return}if(Ny(e,i,nke)){ike(e,o)&&(r.retry=e.toString("utf8",o));return}if(
1807
1807
  `);t.stack=r?`${r}
1808
1808
  ${o}`:i.stack}J.exports.fetch=function(e,r=void 0){return xke(e,r).catch(n=>{throw zG?VG(n,zG):n&&typeof n=="object"&&Error.captureStackTrace(n,J.exports.fetch),n})};J.exports.Headers=lc().Headers;J.exports.Response=FA().Response;J.exports.Request=ju().Request;J.exports.FormData=rm().FormData;var{setGlobalOrigin:Lke,getGlobalOrigin:Pke}=gw();J.exports.setGlobalOrigin=Lke;J.exports.getGlobalOrigin=Pke;var{CacheStorage:Fke}=kH(),{kConstruct:$ke}=je();J.exports.caches=new Fke($ke);var{deleteCookie:jke,getCookies:qke,getSetCookies:zke,setCookie:Hke,parseCookie:Gke}=zH();J.exports.deleteCookie=jke;J.exports.getCookies=qke;J.exports.getSetCookies=zke;J.exports.setCookie=Hke;J.exports.parseCookie=Gke;var{parseMIMEType:Yke,serializeAMimeType:Vke}=wn();J.exports.parseMIMEType=Yke;J.exports.serializeAMimeType=Vke;var{CloseEvent:Jke,ErrorEvent:Wke,MessageEvent:Zke}=Cy(),{WebSocket:Kke,ping:Xke}=SG();J.exports.WebSocket=Kke;J.exports.CloseEvent=Jke;J.exports.ErrorEvent=Wke;J.exports.MessageEvent=Zke;J.exports.ping=Xke;J.exports.WebSocketStream=RG().WebSocketStream;J.exports.WebSocketError=Wv().WebSocketError;J.exports.request=KA(el.request);J.exports.stream=KA(el.stream);J.exports.pipeline=KA(el.pipeline);J.exports.connect=KA(el.connect);J.exports.upgrade=KA(el.upgrade);J.exports.MockClient=Bke;J.exports.MockCallHistory=Qke;J.exports.MockCallHistoryLog=vke;J.exports.MockPool=Dke;J.exports.MockAgent=_ke;J.exports.SnapshotAgent=Tke;J.exports.mockErrors=Rke;var{EventSource:eNe}=qG();J.exports.EventSource=eNe;function tNe(){globalThis.fetch=J.exports.fetch,globalThis.Headers=J.exports.Headers,globalThis.Response=J.exports.Response,globalThis.Request=J.exports.Request,globalThis.FormData=J.exports.FormData,globalThis.WebSocket=J.exports.WebSocket,globalThis.CloseEvent=J.exports.CloseEvent,globalThis.ErrorEvent=J.exports.ErrorEvent,globalThis.MessageEvent=J.exports.MessageEvent,globalThis.EventSource=J.exports.EventSource}J.exports.install=tNe});var ZG=m(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.SuperglueClient=rl.SuperglueHttpError=void 0;var tl=pr(),Nn=_b(),rNe=AS(),nNe=cP(),iNe=pn(),Xo=qc(),oNe=sd(),ep=14400*1e3,XA;if(typeof globalThis.process<"u"&&globalThis.process.versions?.node)try{let{Agent:t}=JG();XA=new t({headersTimeout:ep,bodyTimeout:ep})}catch{}function WG(t){if(t?.aborted)throw t.reason??new DOMException("Aborted","AbortError")}var My=class extends Error{constructor(e,r,n,i){super(e),this.status=r,this.code=n,this.details=i,this.name="SuperglueHttpError"}};rl.SuperglueHttpError=My;var r_=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 rNe.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;WG(r);let o=await this.refreshToken();return WG(r),!o||o===n?i:(i.body?.cancel(),e(o))}isInfrastructureError(e){return(0,iNe.isAbortError)(e)?!1:!!(e instanceof TypeError&&e.message.toLowerCase().includes("fetch")||e instanceof Error&&e.name==="TimeoutError")}async restRequest(e,r,n,i,o){let a=await(await this.restResponse({method:e,path:r,body:n,extraHeaders:i,requestInit:o})).text();if(a)return JSON.parse(a)}async restResponse({method:e,path:r,body:n,extraHeaders:i,requestInit:o}){let s=`${this.apiEndpoint.replace(/\/$/,"")}${r}`,a=n!=null,c=typeof FormData<"u"&&n instanceof FormData,u=d=>{let A={Authorization:`Bearer ${d}`,...i};return a&&!c&&e!=="GET"&&(A["Content-Type"]="application/json"),fetch(s,{...o,method:e,headers:A,body:a?c?n:JSON.stringify(n):void 0,signal:o?.signal??AbortSignal.timeout(ep),...XA?{dispatcher:XA}:{}})},l;try{l=await this.fetchWithAuthRetry(u,o?.signal)}catch(d){throw this.isInfrastructureError(d)&&this.onInfrastructureError?.(),d}if(!l.ok)throw await this.buildHttpError(l);return l}async uploadFiles(e,r){if(typeof r?.process!="boolean")throw new Error("process must be a boolean");if(e.length===0)return[];let n=e.map(l=>({...l,contentLength:l.contentLength??this.getUploadContentLength(l.content)})),o=(await this.restRequest("POST","/v1/files/uploads",{process:r.process,...r.allowUnprocessed?{allowUnprocessed:!0}:{},files:n.map(({fileName:l,contentType:d,contentLength:A})=>({fileName:l,contentLength:A,...d?{contentType:d}:{}}))})).data.files;if(o.length!==n.length)throw await Promise.all(o.map(l=>this.deleteFileUpload(l.id).catch(()=>{}))),new Error("Upload response did not match the selected files");let s=await Promise.allSettled(o.map(async(l,d)=>{let A=n[d],p=await fetch(l.uploadUrl,{method:"PUT",body:A.content,headers:A.contentType?{"Content-Type":A.contentType}:void 0,signal:AbortSignal.timeout(Math.min(ep,l.expiresIn*1e3))});if(!p.ok)throw new Error(`Upload failed for ${A.fileName}: ${p.status} ${p.statusText}`);return l.id})),a=s.flatMap(l=>l.status==="fulfilled"?[l.value]:[]),c=new Map;if(a.length>0)try{let l=await this.restRequest("POST","/v1/files/uploads/complete",{fileIds:a});c=new Map(l.data.files.map(d=>[d.id,d]))}catch(l){c=new Map(a.map(d=>[d,{id:d,fileName:n[o.findIndex(A=>A.id===d)]?.fileName||d,contentLength:n[o.findIndex(A=>A.id===d)]?.contentLength||0,status:"failed",error:l instanceof Error?l.message:String(l)}]))}let u=o.map((l,d)=>{let A=s[d],p=n[d];return A.status==="rejected"?{id:l.id,fileName:p.fileName,contentLength:p.contentLength,status:"failed",error:A.reason instanceof Error?A.reason.message:String(A.reason)}:c.get(l.id)||{id:l.id,fileName:p.fileName,contentLength:p.contentLength,status:"failed",error:"Upload completion returned no result"}});return await Promise.all(u.filter(l=>l.status==="failed").map(l=>this.deleteFileUpload(l.id).catch(()=>{}))),u}async deleteFileUpload(e){await this.restRequest("DELETE",`/v1/files/uploads/${encodeURIComponent(e)}`)}getUploadContentLength(e){return typeof e=="string"?new TextEncoder().encode(e).byteLength:e instanceof Uint8Array?e.byteLength:e.size}async buildHttpError(e){e.status>=500&&this.onInfrastructureError?.();let r=await e.text(),n=`HTTP ${e.status}: ${r}`,i,o;try{let s=JSON.parse(r);s&&typeof s=="object"&&!Array.isArray(s)&&(o=s),typeof s?.code=="string"&&(i=s.code);let a=s.error;typeof a=="string"?n=a:a&&typeof a=="object"&&(n=a.message||JSON.stringify(a))}catch{}return new My(n,e.status,i,o)}async streamRequest(e,r,n){let i=e.includes("?")?"&":"?",o=`${this.apiEndpoint.replace(/\/$/,"")}${e}${i}stream=true`,s=u=>fetch(o,{method:"POST",headers:{Authorization:`Bearer ${u}`,Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify(r),signal:n??AbortSignal.timeout(ep),...XA?{dispatcher:XA}:{}}),a;try{a=await this.fetchWithAuthRetry(s,n)}catch(u){throw this.isInfrastructureError(u)&&this.onInfrastructureError?.(),u}if(!a.ok)throw await this.buildHttpError(a);if(!(a.headers.get("content-type")||"").includes("text/event-stream")){let u=await a.text();return u?JSON.parse(u):void 0}try{return await(0,nNe.consumeEventStreamResult)(a)}catch(u){throw this.isInfrastructureError(u)&&this.onInfrastructureError?.(),u}}async subscribeToLogsSSE(e={}){return this.sseManager.subscribeToLogs(e)}async disconnect(){await this.sseManager.disconnect()}async listMemoryNotes(e={}){let r=new URLSearchParams;e.scope&&r.set("scope",e.scope),e.query&&r.set("query",e.query);let n=r.toString();return(await this.restRequest("GET",`/v1/memory-notes${n?`?${n}`:""}`)).data}async createMemoryNote(e){return(await this.restRequest("POST","/v1/memory-notes",e)).data}async updateMemoryNote(e,r){return(await this.restRequest("PATCH",`/v1/memory-notes/${encodeURIComponent(e)}`,r)).data}async deleteMemoryNote(e){await this.restRequest("DELETE",`/v1/memory-notes/${encodeURIComponent(e)}`)}async clearMemoryNotes(e){return(await this.restRequest("DELETE",`/v1/memory-notes?scope=${e}`)).data.deleted}async getMe(){return this.restRequest("GET","/v1/me")}async completeOnboarding(){return this.restRequest("POST","/v1/me/onboarding/complete")}async runTool(e){let r=await this.restRequest("POST",`/v1/tools/${encodeURIComponent(e.toolId)}/run`,{inputs:e.payload,files:e.files,credentials:e.credentials,includeStepResultData:e.includeStepResultData,options:e.options,runId:e.runId,stateFixture:e.stateFixture},void 0,e.signal?{signal:e.signal}:void 0);return{success:r.status==="success",data:r.data,error:r.error,tool:r.tool,stepResults:r.stepResults?.map(n=>({...n}))||[],...r.fileArtifacts&&r.fileArtifacts.length>0?{fileArtifacts:r.fileArtifacts}:{},...r.metadata?.warnings?.length?{warnings:r.metadata.warnings}:{}}}async runToolConfig(e){let r=e.createRun?"/v1/tools/run?createRun=true":"/v1/tools/run",n=await this.restRequest("POST",r,{tool:e.tool,payload:e.payload,files:e.files,credentials:e.credentials,includeStepResultData:e.includeStepResultData,options:e.options,runId:e.runId,stateFixture:e.stateFixture,executionKind:e.executionKind,parentToolId:e.parentToolId,draftId:e.draftId},e.traceId?{"X-Trace-Id":e.traceId}:void 0,e.signal?{signal:e.signal}:void 0);return{success:n.status?n.status==="success":n.success??!1,data:n.data,error:n.error,tool:n.tool||e.tool,stepResults:n.stepResults?.map(o=>({...o}))||[],...n.fileArtifacts&&n.fileArtifacts.length>0?{fileArtifacts:n.fileArtifacts}:{},...n.metadata?.warnings?.length?{warnings:n.metadata.warnings}:{}}}async abortToolExecution(e){return{success:!0,runId:(await this.restRequest("POST",`/v1/runs/${encodeURIComponent(e)}/cancel`)).runId}}async executeStep({step:e,payload:r,files:n,previousResults:i,credentials:o,options:s,runId:a,systemIds:c,credentialId:u,systemAuth:l,createRun:d,parentToolId:A,stepIndex:p,stepId:h,signal:g,stream:S}){let B={step:e,payload:r,files:n,previousResults:i,credentials:o,options:s,runId:a,systemIds:c,credentialId:u,systemAuth:l,createRun:d,parentToolId:A,stepIndex:p,stepId:h};return S?this.streamRequest("/v1/tools/step/run",B,g):this.restRequest("POST","/v1/tools/step/run",B,void 0,g?{signal:g}:void 0)}async abortStep(e){return this.restRequest("POST","/v1/tools/step/abort",{runId:e})}async executeTransformOnly({outputTransform:e,outputSchema:r,inputSchema:n,payload:i,files:o,stepResults:s,options:a,runId:c,createRun:u,parentToolId:l,stepId:d,signal:A,stream:p}){let h={outputTransform:e,outputSchema:r,inputSchema:n,payload:i,files:o,stepResults:s,options:a,runId:c,createRun:u,parentToolId:l,stepId:d};return p?this.streamRequest("/v1/tools/transform/run",h,A):this.restRequest("POST","/v1/tools/transform/run",h,void 0,A?{signal:A}:void 0)}async createRun({toolId:e,toolConfig:r,toolResult:n,stepResults:i,toolPayload:o,status:s,error:a,startedAt:c,completedAt:u,executionKind:l,parentToolId:d,draftId:A}){return this.restRequest("POST","/v1/runs",{toolId:e,toolConfig:r,toolResult:n,stepResults:i,toolPayload:o,status:s,error:a,startedAt:(0,Xo.toUTCISOString)(c,"run.startedAt"),completedAt:(0,Xo.toUTCISOString)(u,"run.completedAt"),executionKind:l,parentToolId:d,draftId:A})}async checkRunLimit(){return(await this.restRequest("POST","/v1/runs/check-limit")).data}async extract({file:e,envelope:r}){if(!e)throw new Error("File must be provided for extract.");let n=new FormData;n.append("file",e);let i=r?"/v1/extract?envelope=true":"/v1/extract";return this.restRequest("POST",i,n)}mapOpenAPIRunToRun(e){let r={running:tl.RunStatus.RUNNING,success:tl.RunStatus.SUCCESS,failed:tl.RunStatus.FAILED,aborted:tl.RunStatus.ABORTED};return{runId:e.runId??e.id,toolId:e.toolId,tool:e.tool,systemIds:e.systemIds,status:r[e.status]??tl.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??tl.RunExecutionKind.FULL},fileArtifacts:e.fileArtifacts}}mapOpenAPIScheduleToToolSchedule(e){return{...e,lastRunAt:e.lastRunAt?(0,Xo.requireUTCDate)(e.lastRunAt,"schedule.lastRunAt"):void 0,nextRunAt:(0,Xo.requireUTCDate)(e.nextRunAt,"schedule.nextRunAt"),createdAt:(0,Xo.requireUTCDate)(e.createdAt,"schedule.createdAt"),updatedAt:(0,Xo.requireUTCDate)(e.updatedAt,"schedule.updatedAt")}}async listRuns(e={}){let r=(0,Nn.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,Xo.toUTCISOString)(e.startedAfter,"run.startedAfter"):e.startedAfter),e.statuses!==void 0?r.set("status",e.statuses.join(",")):e.status!==void 0&&r.set("status",e.status),e.requestSources!==void 0&&r.set("requestSources",e.requestSources.join(",")),e.executionKinds!==void 0&&r.set("executionKinds",e.executionKinds.join(",")),e.userId!==void 0&&r.set("userId",e.userId),e.systemId!==void 0&&r.set("systemId",e.systemId),e.systemIds!==void 0&&r.set("systemIds",e.systemIds.join(","));let n=r.size>0?`?${r.toString()}`:"",i=await this.restRequest("GET",`/v1/runs${n}`,void 0,void 0,{signal:e.signal});return{data:i.data.map(o=>this.mapOpenAPIRunToRun(o)),total:i.total,page:i.page,limit:i.limit,hasMore:i.hasMore}}async getActivityCounts(e){let r=new URLSearchParams;e?.from&&r.set("from",e.from instanceof Date?(0,Xo.toUTCISOString)(e.from,"activity.from"):e.from),e?.to&&r.set("to",e.to instanceof Date?(0,Xo.toUTCISOString)(e.to,"activity.to"):e.to);let n=r.toString();return(await this.restRequest("GET",`/v1/activity/counts${n?`?${n}`:""}`,void 0,void 0,{signal:e?.signal})).counts}async getRun(e){try{let r=await this.restRequest("GET",`/v1/runs/${encodeURIComponent(e)}`);return this.mapOpenAPIRunToRun(r)}catch(r){if(r.message?.includes("404")||r.message?.includes("not found"))return null;throw r}}async getTool(e){try{return await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}`)}catch(r){if(r.message?.includes("404")||r.message?.includes("not found")||r.message?.includes("403")||r.message?.includes("not allowed"))return null;throw r}}async getToolState(e){return(await this.restRequest("GET",`/v1/tools/${encodeURIComponent(e)}/state`)).state}async setToolState(e,r){await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/state`,{state:r})}async deleteToolState(e){return(await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/state`)).deletedKeys}async archiveTool(e,r=!0){return this.updateTool(e,{archived:r})}async bulkArchiveTools(e,r=!0){return this.restRequest("POST","/v1/tools/bulk/archive",{ids:e,archived:r})}async bulkDeleteTools(e){return this.restRequest("POST","/v1/tools/bulk/delete",{ids:e})}async listTools(e={}){let r=(0,Nn.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,Nn.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,Nn.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,Nn.listAllPages)((r,n)=>this.listProjectSummaries({page:r,limit:n,...e!==void 0?{includeArchived:e}:{}}))}async listAllProjectTasks(e){return(0,Nn.listAllPages)((r,n)=>this.restRequest("GET",`/v1/projects/${encodeURIComponent(e)}/tasks?page=${r}&limit=${n}`))}async saveProjectTask({projectId:e,taskId:r,input:n}){let i=`/v1/projects/${encodeURIComponent(e)}/tasks${r?`/${encodeURIComponent(r)}`:""}`;return(await this.restRequest(r?"PATCH":"POST",i,n)).data}async listSchedules(e={}){let r=(0,Nn.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,Nn.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,oNe.getRuntimeTimezone)()});return this.mapOpenAPIScheduleToToolSchedule(n)}async updateToolSchedule(e,r,n){let i=await this.restRequest("PUT",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(r)}`,n);return this.mapOpenAPIScheduleToToolSchedule(i)}async deleteToolSchedule(e,r){return await this.restRequest("DELETE",`/v1/tools/${encodeURIComponent(e)}/schedules/${encodeURIComponent(r)}`),!0}async bulkSetSchedulesEnabled(e,r){return this.restRequest("POST","/v1/schedules/bulk/enable",{ids:e,enabled:r})}async bulkDeleteSchedules(e){return this.restRequest("POST","/v1/schedules/bulk/delete",{ids:e})}async listCredentials(e={}){let r=(0,Nn.createListQueryParams)(e);e.systemId!==void 0&&r.set("systemId",e.systemId);let n=r.size>0?`?${r.toString()}`:"";return this.restRequest("GET",`/v1/credentials${n}`)}async listAllCredentials(e={}){return(0,Nn.listAllPages)((r,n)=>this.listCredentials({...e,page:r,limit:n}))}async createCredentials(e){return(await this.restRequest("POST","/v1/credentials",e)).data}async replaceCredentials(e,r){return(await this.restRequest("PUT",`/v1/credentials/${encodeURIComponent(e)}`,{credentials:r})).data}async updateCredentials(e,r){return(await this.restRequest("PATCH",`/v1/credentials/${encodeURIComponent(e)}`,r)).data}async deleteCredentials(e){await this.restRequest("DELETE",`/v1/credentials/${encodeURIComponent(e)}`)}async setDefaultCredentials(e){await this.restRequest("POST",`/v1/credentials/${encodeURIComponent(e)}/default`)}async listSystems(e={}){let r=(0,Nn.createListQueryParams)(e),n=r.size>0?`?${r.toString()}`:"";return this.restRequest("GET",`/v1/systems${n}`)}async listAllSystems(e={}){return(0,Nn.listAllPages)((r,n)=>this.listSystems({...e,page:r,limit:n}))}async getSystem(e){return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}`)).data}async createSystem(e){return(await this.restRequest("POST","/v1/systems",e)).data}async updateSystem(e,r){return(await this.restRequest("PATCH",`/v1/systems/${encodeURIComponent(e)}`,r)).data}async deleteSystem(e){return await this.restRequest("DELETE",`/v1/systems/${encodeURIComponent(e)}`),!0}async bulkDeleteSystems(e){return this.restRequest("POST","/v1/systems/bulk/delete",{ids:e})}async listManagedOAuthTemplateIds(){return(await this.restRequest("GET","/v1/oauth2/managed-apps")).data.templateIds}async createOAuthExchange(e){return(await this.restRequest("POST","/v1/oauth/exchanges",e)).data}async completeOAuthExchange(e,r){return(await this.restRequest("POST",`/v1/oauth/exchanges/${encodeURIComponent(e)}/complete`,r)).data}async searchSystemDocumentation(e,r){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/search`,{keywords:r})).data}async triggerSystemDocumentationScrapeJob(e,r){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/scrape`,r)).data}async fetchOpenApiSpec(e,r,n){return(await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/openapi`,{url:r,link:n?.link})).data}async uploadSystemDocumentationFiles(e,r,n){let i=await this.uploadFiles(r,{process:!0}),o=i.flatMap(s=>s.status==="uploaded"?[s.id]:[]);if(o.length>0)try{await this.restRequest("POST",`/v1/systems/${encodeURIComponent(e)}/documentation/files`,{fileIds:o,link:n?.link!==!1})}catch(s){throw await Promise.all(o.map(a=>this.deleteFileUpload(a).catch(()=>{}))),s}if(!n?.settle){let s=i.filter(a=>a.status==="failed");if(s.length>0)throw new Error(s.map(a=>a.error).join("; "))}return i}async listSystemDocumentationFiles(e,r){let n=new URLSearchParams;r?.length&&n.set("fileIds",r.join(","));let i=n.size>0?`?${n.toString()}`:"";return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/documentation/files${i}`)).data}async getSystemDocumentationFileContent(e,r,n){return(await this.restRequest("GET",`/v1/systems/${encodeURIComponent(e)}/documentation/files/${encodeURIComponent(r)}/content?processed=${n.processed}`)).data}async deleteSystemDocumentationFile(e,r){await this.restRequest("DELETE",`/v1/systems/${encodeURIComponent(e)}/documentation/files/${encodeURIComponent(r)}`)}async generateCredentialsLink(e){try{return{success:!0,credentialsUrl:(await this.restRequest("POST","/v1/authenticate",e||{})).data.credentialsUrl}}catch(r){return{success:!1,error:r.message}}}};rl.SuperglueClient=r_});var XG=m(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.UnquotedKeyStrategy=ct.TripleQuoteStrategy=ct.TrailingCommaStrategy=ct.SingleQuoteStrategy=ct.PythonLiteralStrategy=ct.CommentStrategy=ct.ResilientJsonParser=ct.RepairStrategy=void 0;ct.parseJsonResilient=sNe;ct.parseJSON=aNe;ct.isValidJson=cNe;ct.prettyPrintJson=uNe;ct.minifyJson=lNe;var Kn=class{validate(e){try{return JSON.parse(e),!0}catch{return!1}}};ct.RepairStrategy=Kn;var xy=class extends Kn{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")}"`})}};ct.TripleQuoteStrategy=xy;var Ly=class extends Kn{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")}};ct.PythonLiteralStrategy=Ly;var Py=class extends Kn{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")}};ct.TrailingCommaStrategy=Py;var Fy=class extends Kn{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}};ct.SingleQuoteStrategy=Fy;var $y=class extends Kn{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')}};ct.UnquotedKeyStrategy=$y;var jy=class extends Kn{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}};ct.CommentStrategy=jy;var n_=class extends Kn{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`
1809
1809
  `: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}},i_=class extends Kn{constructor(){super(...arguments),this.name="TrailingCharactersRepair",this.description="Removes trailing characters after valid JSON structure"}canApply(e){let r=e.trim();if(!r.startsWith("{")&&!r.startsWith("["))return!1;let n=0,i=0,o=!1,s=!1;for(let a=0;a<r.length;a++){let c=r[a];if(o)s?s=!1:c==="\\"?s=!0:c==='"'&&(o=!1);else if(c==='"')o=!0;else if(c==="{")n++;else if(c==="}"){if(n--,n===0&&i===0&&a>0&&a<r.length-1)return!0}else if(c==="[")i++;else if(c==="]"&&(i--,i===0&&n===0&&a>0&&a<r.length-1))return!0}return!1}apply(e){let r=e.trim(),n=0,i=0,o=!1,s=!1,a=-1;for(let c=0;c<r.length;c++){let u=r[c];if(o)s?s=!1:u==="\\"?s=!0:u==='"'&&(o=!1);else if(u==='"')o=!0;else if(u==="{")n++;else if(u==="}"){if(n--,n===0&&i===0&&c>0){a=c;break}}else if(u==="[")i++;else if(u==="]"&&(i--,i===0&&n===0&&c>0)){a=c;break}}return a>0&&a<r.length-1?r.substring(0,a+1):e}},nl=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 xy,new Fy,new n_,new i_,new Ly,new Py,new $y,new jy]}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)}};ct.ResilientJsonParser=nl;var KG=new nl;function sNe(t,e){return(e?new nl(e):KG).parse(t)}function aNe(t){let e=KG.parse(t);if(e.success)return e.repairs&&e.repairs.length>0&&console.log("JSON parsed with repairs:",e.repairs),e.data;throw new Error(`Failed to parse JSON: ${e.error}`)}function cNe(t){try{return JSON.parse(t),!0}catch{return!1}}function uNe(t,e=2){return JSON.stringify(t,null,e)}function lNe(t){let r=new nl().parse(t);if(r.success)return JSON.stringify(r.data);throw new Error("Cannot minify invalid JSON")}});var dr=m(Z=>{"use strict";var dNe=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]})),ce=Z&&Z.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&dNe(e,t,r)};Object.defineProperty(Z,"__esModule",{value:!0});Z.SSELogSubscriptionManager=Z.SuperglueHttpError=Z.SuperglueClient=void 0;ce(tN(),Z);ce(IM(),Z);ce(kM(),Z);ce(OM(),Z);ce(PM(),Z);ce(FM(),Z);ce(jM(),Z);ce(Td(),Z);ce(bx(),Z);ce(Sx(),Z);ce(wx(),Z);ce(Bx(),Z);ce(_b(),Z);ce(vx(),Z);ce(Tx(),Z);ce(Rx(),Z);ce(kx(),Z);ce(Rb(),Z);ce(Ub(),Z);ce(Ox(),Z);ce(Ux(),Z);ce(xx(),Z);ce(mp(),Z);ce(Px(),Z);ce(Fx(),Z);ce(jx(),Z);ce(qx(),Z);ce(Gx(),Z);ce(aL(),Z);ce(Hb(),Z);ce(Ud(),Z);ce(zb(),Z);ce(AL(),Z);ce(fL(),Z);ce(gL(),Z);ce(pb(),Z);ce(QL(),Z);ce(_L(),Z);ce(Xh(),Z);ce($L(),Z);ce(YL(),Z);ce(VL(),Z);ce(cS(),Z);ce(KL(),Z);ce(XL(),Z);ce(nP(),Z);ce(oP(),Z);ce(pr(),Z);ce(pn(),Z);ce(sP(),Z);ce(aP(),Z);ce(hg(),Z);ce(qc(),Z);ce(sd(),Z);var eY=ZG();Object.defineProperty(Z,"SuperglueClient",{enumerable:!0,get:function(){return eY.SuperglueClient}});Object.defineProperty(Z,"SuperglueHttpError",{enumerable:!0,get:function(){return eY.SuperglueHttpError}});var ANe=AS();Object.defineProperty(Z,"SSELogSubscriptionManager",{enumerable:!0,get:function(){return ANe.SSELogSubscriptionManager}});ce(XG(),Z)});var QE=require("commander");var vr=fe(require("fs")),nY=fe(require("os")),es=fe(require("path")),tp=fe(dr()),tY=new Set(["runner","builder","admin"]),rY={output:{mode:"stdout",directory:".superglue/output"},preset:"admin"};function ts(t){let e=es.join(process.cwd(),".superglue"),r=nY.homedir();if(!r)return e;let n=es.join(r,".superglue");return t===!0?e:t===!1?n:vr.existsSync(es.join(e,"config.json"))?e:n}function o_(t){return es.join(ts(t),"config.json")}function qy(t){let e=o_(t);if(!vr.existsSync(e))return{};try{return JSON.parse(vr.readFileSync(e,"utf-8"))}catch{return{}}}function il(t){let e=qy(),r=t.apiKey||(0,tp.readProcessEnvironmentValue)("SUPERGLUE_API_KEY")||e.apiKey||"",n=t.endpoint||(0,tp.readProcessEnvironmentValue)("SUPERGLUE_API_ENDPOINT")||e.endpoint||"https://api.superglue.cloud",i=(0,tp.readProcessEnvironmentValue)("SUPERGLUE_WEB_ENDPOINT")||e.webEndpoint||n.replace(/:3002\b/,":3001").replace(/api\.superglue/,"app.superglue"),o=(0,tp.readProcessEnvironmentValue)("SUPERGLUE_CLI_PRESET"),s=o&&tY.has(o)?o:e.preset&&tY.has(e.preset)?e.preset:"admin";return{...rY,...e,apiKey:r,endpoint:n,webEndpoint:i,preset:s,output:{...rY.output,...e.output}}}function zy(t,e){let r=ts(e);vr.existsSync(r)||vr.mkdirSync(r,{recursive:!0}),vr.writeFileSync(es.join(r,"config.json"),JSON.stringify(t,null,2)+`
1810
- `,{mode:384})}function Hy(t,e){let r=es.join(ts(e),"drafts");if(vr.existsSync(r)||vr.mkdirSync(r,{recursive:!0}),t.output.mode==="stdout+file"){let n=es.resolve(t.output.directory);vr.existsSync(n)||vr.mkdirSync(n,{recursive:!0})}}var A_=fe(dr());var s_=fe(require("readline"));var sY=require("child_process"),aY=require("util");var iY={name:"@superglue/cli",version:"1.1.182",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 fNe=(0,aY.promisify)(sY.exec),Ar=iY.version;function oY(t){let e=t.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:t}}function Yy(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=oY(r[o]||"0"),a=oY(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 Vy(){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 Gy=null;function cY(){ne()&&(Gy=Vy())}async function uY(){if(!(!ne()||!Gy)){try{let t=new Promise(r=>{setTimeout(()=>r(null),2e3).unref()}),e=await Promise.race([Gy,t]);e&&Yy(Ar,e)<0&&(console.error(""),console.error(`${y.cyan}${y.bold} Update available: ${Ar} \u2192 ${e}${y.reset}`),console.error(`${y.cyan} Run ${y.bold}sg update${y.reset}${y.cyan} to upgrade${y.reset}`),console.error(""))}catch{}Gy=null}}async function lY(){let t=await Vy();if(!t)return{success:!1,message:"Could not fetch latest version from npm"};if(Yy(Ar,t)>=0)return{success:!0,message:`Already on latest version (${Ar})`};try{return await fNe("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${Ar} to ${t}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var ne=()=>process.argv.includes("--table")&&process.stdout.isTTY,_r=()=>process.argv.includes("--full"),y={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 dY(t,e){let r=e||t;return`\x1B]8;;${t}\x07${y.underline}${y.cyan}${r}${y.reset}\x1B]8;;\x07`}function AY(){if(!ne())return;let t=y.reset,e=y.dim,r="\x1B[47;30m",n=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),n.forEach(i=>{let o=i.search(/\S/),s=i.length-[...i].reverse().join("").search(/\S/)-1;if(o===-1)return console.log(" "+i);let a=i.slice(0,o),c=i.slice(o,s+1).split("").map(l=>l===" "?" ":"\u2588").join(""),u=i.slice(s+1);console.log(` ${a}${r}${c}${t}${u}`)}),console.log(` ${e} CLI v${Ar}${t}`),console.log("")}function ot(t){if(!ne())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 ${y.cyan}${e[r++%e.length]}${y.reset} ${n}`)},s=setInterval(o,80);return{update:a=>{n=a},log:a=>{i(),console.log(` ${y.dim}\u2502${y.reset} ${a}`),o()},stop:a=>{clearInterval(s),i(),a&&console.log(` ${a}`)}}}function K(t){ne()?Jy(t):console.log(JSON.stringify(t,null,2))}function Be(t,e){ne()?(console.log(` ${y.green}\u2713${y.reset} ${t}`),e&&Jy(e,4)):console.log(JSON.stringify({success:!0,message:t,...e&&typeof e=="object"?e:{data:e}}))}function _(t,e){ne()?(console.error(` ${y.red}\u2717${y.reset} ${t}`),e&&Jy(e,4)):console.error(JSON.stringify({success:!1,error:t,details:e}))}function pY(t){ne()&&console.log(` ${y.yellow}\u26A0${y.reset} ${t}`)}function tr(t){ne()&&console.log(` ${y.dim}${t}${y.reset}`)}function rs(t){ne()&&(console.log(`
1810
+ `,{mode:384})}function Hy(t,e){let r=es.join(ts(e),"drafts");if(vr.existsSync(r)||vr.mkdirSync(r,{recursive:!0}),t.output.mode==="stdout+file"){let n=es.resolve(t.output.directory);vr.existsSync(n)||vr.mkdirSync(n,{recursive:!0})}}var A_=fe(dr());var s_=fe(require("readline"));var sY=require("child_process"),aY=require("util");var iY={name:"@superglue/cli",version:"1.1.183",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 fNe=(0,aY.promisify)(sY.exec),Ar=iY.version;function oY(t){let e=t.match(/^(\d+)(?:-(.+))?$/);return e?{numeric:parseInt(e[1],10),prerelease:e[2]||null}:{numeric:0,prerelease:t}}function Yy(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=oY(r[o]||"0"),a=oY(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 Vy(){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 Gy=null;function cY(){ne()&&(Gy=Vy())}async function uY(){if(!(!ne()||!Gy)){try{let t=new Promise(r=>{setTimeout(()=>r(null),2e3).unref()}),e=await Promise.race([Gy,t]);e&&Yy(Ar,e)<0&&(console.error(""),console.error(`${y.cyan}${y.bold} Update available: ${Ar} \u2192 ${e}${y.reset}`),console.error(`${y.cyan} Run ${y.bold}sg update${y.reset}${y.cyan} to upgrade${y.reset}`),console.error(""))}catch{}Gy=null}}async function lY(){let t=await Vy();if(!t)return{success:!1,message:"Could not fetch latest version from npm"};if(Yy(Ar,t)>=0)return{success:!0,message:`Already on latest version (${Ar})`};try{return await fNe("npm install -g @superglue/cli@latest"),{success:!0,message:`Updated from ${Ar} to ${t}`}}catch(e){return{success:!1,message:`Update failed: ${e.message}. Try manually: npm install -g @superglue/cli@latest`}}}var ne=()=>process.argv.includes("--table")&&process.stdout.isTTY,_r=()=>process.argv.includes("--full"),y={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 dY(t,e){let r=e||t;return`\x1B]8;;${t}\x07${y.underline}${y.cyan}${r}${y.reset}\x1B]8;;\x07`}function AY(){if(!ne())return;let t=y.reset,e=y.dim,r="\x1B[47;30m",n=[" #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@- "," =@@@- @@@@ "," @@@ @@% "," -@@ @@@@= @@@ @@@ @@@@@#@ @@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@ @@@@@@* %@@ "," @@ @@@ *@ @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @% @@@ @@@ @@@ @@* @@# "," #@@ @@@# @@@ @@@ @@@ :@@ @@@ @@@ -@@ @@@ @@@ @@@ @@@ @@* @@ "," @@- @@@@= @@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@% @@@ @@@ @@@ @@@@@. @@."," #@% .@@@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* @@ "," @@ @ @@@ @@@ @@@ @@@ @@@ @@@ -@@ @@@ @@% @@@ @@@ @@@ @@* *@@ "," -@@ @@@@= @@@@@@ @@@ @@@@@@@ @@@ -@@ @@@@@@ @@@@@@% @@@@@@. @@@@@@* #@@ "," :@@* @@@ "," %@@@ =@@@. "," :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% "];console.log(""),n.forEach(i=>{let o=i.search(/\S/),s=i.length-[...i].reverse().join("").search(/\S/)-1;if(o===-1)return console.log(" "+i);let a=i.slice(0,o),c=i.slice(o,s+1).split("").map(l=>l===" "?" ":"\u2588").join(""),u=i.slice(s+1);console.log(` ${a}${r}${c}${t}${u}`)}),console.log(` ${e} CLI v${Ar}${t}`),console.log("")}function ot(t){if(!ne())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 ${y.cyan}${e[r++%e.length]}${y.reset} ${n}`)},s=setInterval(o,80);return{update:a=>{n=a},log:a=>{i(),console.log(` ${y.dim}\u2502${y.reset} ${a}`),o()},stop:a=>{clearInterval(s),i(),a&&console.log(` ${a}`)}}}function K(t){ne()?Jy(t):console.log(JSON.stringify(t,null,2))}function Be(t,e){ne()?(console.log(` ${y.green}\u2713${y.reset} ${t}`),e&&Jy(e,4)):console.log(JSON.stringify({success:!0,message:t,...e&&typeof e=="object"?e:{data:e}}))}function _(t,e){ne()?(console.error(` ${y.red}\u2717${y.reset} ${t}`),e&&Jy(e,4)):console.error(JSON.stringify({success:!1,error:t,details:e}))}function pY(t){ne()&&console.log(` ${y.yellow}\u26A0${y.reset} ${t}`)}function tr(t){ne()&&console.log(` ${y.dim}${t}${y.reset}`)}function rs(t){ne()&&(console.log(`
1811
1811
  ${y.bold}${y.cyan}${t}${y.reset}`),console.log(` ${y.dim}${"\u2500".repeat(t.length)}${y.reset}`))}function Dr(t,e,r){if(!ne()){console.log(JSON.stringify({success:!0,total:r?.total??t.length,items:t}));return}if(t.length===0){console.log(`
1812
1812
  ${y.dim}0 results${y.reset}
1813
1813
  `);return}let n=e||Object.keys(t[0]),i=_r()?1/0:60,o=n.map(l=>Math.min(i,Math.max(l.length,...t.map(d=>String(d[l]??"").replace(/[\n\r]+/g," ").trim().length))));console.log("");let s=n.map((l,d)=>`${y.bold}${y.cyan}${l.toUpperCase().padEnd(o[d])}${y.reset}`).join(" ");console.log(` ${s}`);let a=o.map(l=>`${y.dim}${"\u2500".repeat(l)}${y.reset}`).join(`${y.dim}\u2500\u2500${y.reset}`);console.log(` ${a}`);for(let l of t){let d=n.map((A,p)=>{let h=String(l[A]??"").replace(/[\n\r]+/g," ").trim();if(h.length>i){let S=`\u2026 (${h.length})`;h=h.slice(0,Math.max(0,i-S.length))+`${y.dim}${S}${y.reset}`}return A==="status"?`${{success:y.green,running:y.yellow,failed:y.red,aborted:y.red,error:y.red,pending:y.dim}[h.toLowerCase()]||""}${h.padEnd(o[p])}${y.reset}`:h.padEnd(o[p])}).join(" ");console.log(` ${d}`)}let c=r?.total??t.length,u=c===t.length?`${t.length} result${t.length===1?"":"s"}`:`${t.length} of ${c} result${c===1?"":"s"}`;console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superglue/cli",
3
- "version": "1.1.182",
3
+ "version": "1.1.183",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },