@whoz-oss/coday-server 0.85.0 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.js +6 -5
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -306,7 +306,7 @@ ${a}\r
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
More details: https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md#removed-logprovider-and-loglevel-options
|
|
309
|
-
`)),t}function dZ(r){let e=r.logProvider&&r.logProvider();return e&&(r.logger=e),(0,rbt.getLogger)(r)}});var Zbe=S(mZ=>{"use strict";Object.defineProperty(mZ,"__esModule",{value:!0});mZ.legacyCreateProxyMiddleware=cbt;var abt=uZ(),obt=ul(),sbt=Vbe(),Gbe=obt.Debug.extend("legacy-create-proxy-middleware");function cbt(r,e){Gbe("init");let t=(0,sbt.legacyOptionsAdapter)(r,e),n=(0,abt.createProxyMiddleware)(t);return Gbe("add marker for patching req.url (old behavior)"),n.__LEGACY_HTTP_PROXY_MIDDLEWARE__=!0,n}});var Jbe=S(MT=>{"use strict";Object.defineProperty(MT,"__esModule",{value:!0});MT.legacyCreateProxyMiddleware=void 0;var ubt=Zbe();Object.defineProperty(MT,"legacyCreateProxyMiddleware",{enumerable:!0,get:function(){return ubt.legacyCreateProxyMiddleware}})});var Kbe=S(Zd=>{"use strict";var lbt=Zd&&Zd.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),fbt=Zd&&Zd.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&lbt(e,r,t)};Object.defineProperty(Zd,"__esModule",{value:!0});fbt(Jbe(),Zd)});var gZ=S(ru=>{"use strict";var pbt=ru&&ru.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),LT=ru&&ru.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&pbt(e,r,t)};Object.defineProperty(ru,"__esModule",{value:!0});LT(uZ(),ru);LT(Wbe(),ru);LT(NG(),ru);LT(Kbe(),ru)});var WT=wr(hte(),1);import fl from"path";import qT from"fs";import*as t7e from"path";var Fe=class{commandWord;description;requiredIntegrations=[];isInternal=!1;constructor(e){this.commandWord=e.commandWord,this.description=e.description,this.requiredIntegrations=e.requiredIntegrations||[],this.isInternal=!!e?.isInternal}getSubCommand(e){return e.slice(this.commandWord.length).trim()}accept(e,t){return!!e&&e.toLowerCase().startsWith(this.commandWord)}};function kO(r,e=80){if(r.length<=e)return r;try{if(r.trim().startsWith("{")||r.trim().startsWith("[")){let t=JSON.parse(r),n=JSON.stringify(t);return n.length<=e?n:n.substring(0,e)+`...(${n.length} chars)`}}catch{}return r.substring(0,e)+"..."}var li=class{constructor(e,t){this.type=t;if(e.timestamp)this.timestamp=e.timestamp;else{let n=Math.random().toString(36).substring(2,7);this.timestamp=`${new Date().toISOString()}-${n}`}this.parentKey=e.parentKey,this.length=0}timestamp;parentKey;static type;length;get date(){let e=this.timestamp.lastIndexOf("-");if(e>0){let t=this.timestamp.substring(e+1);if(t.length===5&&/^[a-z0-9]+$/.test(t))return new Date(this.timestamp.substring(0,e))}return new Date(this.timestamp)}},z7=class extends li{invite;constructor(e,t){super(e,t),this.invite=e.invite}buildAnswer(e){return new Hr({answer:e,parentKey:this.timestamp,invite:this.invite})}},w3=class r extends li{static type="heartbeat";constructor(e){super(e,r.type)}},ua=class r extends z7{defaultValue;static type="invite";constructor(e){super(e,r.type),this.defaultValue=e.defaultValue}},mte="InviteEventDefault",Hr=class r extends li{answer;invite;static type="answer";constructor(e){super(e,r.type),this.answer=e.answer??"No answer",this.invite=e.invite}},Df=class r extends li{speaker;text;static type="text";constructor(e){super(e,r.type),this.speaker=e.speaker,this.text=e.text}},El=class r extends li{chunk;static type="text_chunk";constructor(e){super(e,r.type),this.chunk=e.chunk,this.length=this.chunk.length}},_3=class r extends li{warning;static type="warn";constructor(e){super(e,r.type),this.warning=e.warning}},Oa=class r extends li{error;static type="error";constructor(e){super(e,r.type),this.error=e.error}},la=class r extends z7{options;optionalQuestion;static type="choice";constructor(e){super(e,r.type),this.options=e.options,this.optionalQuestion=e.optionalQuestion}},cn=class r extends li{toolRequestId;name;args;static type="tool_request";constructor(e){super(e,r.type),this.toolRequestId=e.toolRequestId??this.timestamp,this.name=e.name,this.args=e.args,this.length=this.args.length+this.name.length+this.toolRequestId.length+20}buildResponse(e){return new En({output:e,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(e=50){let t=kO(this.args,e);return`\u{1F527} ${this.name}(${t})`}},En=class r extends li{toolRequestId;output;static type="tool_response";constructor(e){if(super(e,r.type),this.toolRequestId=e.toolRequestId||this.timestamp||new Date().toISOString(),this.output=e.output,typeof this.output=="string")this.length=this.output.length+this.toolRequestId.length+20;else if(this.output.type==="text")this.length=this.output.content.length+this.toolRequestId.length+20;else if(this.output.type==="image"){let t=(this.output.width??0)*(this.output.height??0)/750;this.length=(t?t*3.5:this.output.content.length)+this.toolRequestId.length+20}else this.length=this.toolRequestId.length+20}getTextOutput(){return typeof this.output=="string"?this.output:this.output.type==="text"?this.output.content:this.output.type==="image"?`[Image: ${this.output.mimeType}]`:""}toSingleLineString(e=50){let t=this.getTextOutput(),n=kO(t,e),i=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${n}${i}`}},Of=class r extends li{static type="thinking";static debounce=5e3;constructor(e){super(e,r.type)}},fa=class r extends li{summary;static type="summary";constructor(e){super(e,r.type),this.summary=e.summary,this.length=this.summary.length}toSingleLineString(e=80){return`\u{1F4CB} Summary: ${kO(this.summary,e)}`}},Wt=class r extends li{role;name;content;static type="message";constructor(e){super(e,r.type),this.role=e.role,this.name=e.name,this.content=e.content,this.length=this.content.map(t=>{if(t.type==="text")return t.content.length;if(t.type==="image"){let n=(t.width||0)*(t.height||0)/750;return n?n*3.5:t.content.length}return 0}).reduce((t,n)=>t+n,0)}getTextContent(){return this.content.filter(e=>e.type==="text").map(e=>e.content).join(`
|
|
309
|
+
`)),t}function dZ(r){let e=r.logProvider&&r.logProvider();return e&&(r.logger=e),(0,rbt.getLogger)(r)}});var Zbe=S(mZ=>{"use strict";Object.defineProperty(mZ,"__esModule",{value:!0});mZ.legacyCreateProxyMiddleware=cbt;var abt=uZ(),obt=ul(),sbt=Vbe(),Gbe=obt.Debug.extend("legacy-create-proxy-middleware");function cbt(r,e){Gbe("init");let t=(0,sbt.legacyOptionsAdapter)(r,e),n=(0,abt.createProxyMiddleware)(t);return Gbe("add marker for patching req.url (old behavior)"),n.__LEGACY_HTTP_PROXY_MIDDLEWARE__=!0,n}});var Jbe=S(MT=>{"use strict";Object.defineProperty(MT,"__esModule",{value:!0});MT.legacyCreateProxyMiddleware=void 0;var ubt=Zbe();Object.defineProperty(MT,"legacyCreateProxyMiddleware",{enumerable:!0,get:function(){return ubt.legacyCreateProxyMiddleware}})});var Kbe=S(Zd=>{"use strict";var lbt=Zd&&Zd.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),fbt=Zd&&Zd.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&lbt(e,r,t)};Object.defineProperty(Zd,"__esModule",{value:!0});fbt(Jbe(),Zd)});var gZ=S(ru=>{"use strict";var pbt=ru&&ru.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),LT=ru&&ru.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&pbt(e,r,t)};Object.defineProperty(ru,"__esModule",{value:!0});LT(uZ(),ru);LT(Wbe(),ru);LT(NG(),ru);LT(Kbe(),ru)});var WT=wr(hte(),1);import fl from"path";import qT from"fs";import*as t7e from"path";var Fe=class{commandWord;description;requiredIntegrations=[];isInternal=!1;constructor(e){this.commandWord=e.commandWord,this.description=e.description,this.requiredIntegrations=e.requiredIntegrations||[],this.isInternal=!!e?.isInternal}getSubCommand(e){return e.slice(this.commandWord.length).trim()}accept(e,t){return!!e&&e.toLowerCase().startsWith(this.commandWord)}};function kO(r,e=80){if(r.length<=e)return r;try{if(r.trim().startsWith("{")||r.trim().startsWith("[")){let t=JSON.parse(r),n=JSON.stringify(t);return n.length<=e?n:n.substring(0,e)+`...(${n.length} chars)`}}catch{}return r.substring(0,e)+"..."}var li=class{constructor(e,t){this.type=t;if(e.timestamp)this.timestamp=e.timestamp;else{let n=Math.random().toString(36).substring(2,7);this.timestamp=`${new Date().toISOString()}-${n}`}this.parentKey=e.parentKey,this.length=0}timestamp;parentKey;static type;length;get date(){let e=this.timestamp.lastIndexOf("-");if(e>0){let t=this.timestamp.substring(e+1);if(t.length===5&&/^[a-z0-9]+$/.test(t))return new Date(this.timestamp.substring(0,e))}return new Date(this.timestamp)}},z7=class extends li{invite;constructor(e,t){super(e,t),this.invite=e.invite}buildAnswer(e){return new Hr({answer:e,parentKey:this.timestamp,invite:this.invite})}},w3=class r extends li{static type="heartbeat";constructor(e){super(e,r.type)}},ua=class r extends z7{defaultValue;static type="invite";constructor(e){super(e,r.type),this.defaultValue=e.defaultValue}},mte="InviteEventDefault",Hr=class r extends li{answer;invite;static type="answer";constructor(e){super(e,r.type),this.answer=e.answer??"No answer",this.invite=e.invite}},Df=class r extends li{speaker;text;static type="text";constructor(e){super(e,r.type),this.speaker=e.speaker,this.text=e.text}},El=class r extends li{chunk;static type="text_chunk";constructor(e){super(e,r.type),this.chunk=e.chunk,this.length=this.chunk.length}},_3=class r extends li{warning;static type="warn";constructor(e){super(e,r.type),this.warning=e.warning}},Oa=class r extends li{error;static type="error";constructor(e){super(e,r.type),this.error=e.error}},la=class r extends z7{options;optionalQuestion;allowFreeText;static type="choice";constructor(e){super(e,r.type),this.options=e.options,this.optionalQuestion=e.optionalQuestion,this.allowFreeText=e.allowFreeText??!1}},cn=class r extends li{toolRequestId;name;args;static type="tool_request";constructor(e){super(e,r.type),this.toolRequestId=e.toolRequestId??this.timestamp,this.name=e.name,this.args=e.args,this.length=this.args.length+this.name.length+this.toolRequestId.length+20}buildResponse(e){return new En({output:e,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(e=50){let t=kO(this.args,e);return`\u{1F527} ${this.name}(${t})`}},En=class r extends li{toolRequestId;output;static type="tool_response";constructor(e){if(super(e,r.type),this.toolRequestId=e.toolRequestId||this.timestamp||new Date().toISOString(),this.output=e.output,typeof this.output=="string")this.length=this.output.length+this.toolRequestId.length+20;else if(this.output.type==="text")this.length=this.output.content.length+this.toolRequestId.length+20;else if(this.output.type==="image"){let t=(this.output.width??0)*(this.output.height??0)/750;this.length=(t?t*3.5:this.output.content.length)+this.toolRequestId.length+20}else this.length=this.toolRequestId.length+20}getTextOutput(){return typeof this.output=="string"?this.output:this.output.type==="text"?this.output.content:this.output.type==="image"?`[Image: ${this.output.mimeType}]`:""}toSingleLineString(e=50){let t=this.getTextOutput(),n=kO(t,e),i=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${n}${i}`}},Of=class r extends li{static type="thinking";static debounce=5e3;constructor(e){super(e,r.type)}},fa=class r extends li{summary;static type="summary";constructor(e){super(e,r.type),this.summary=e.summary,this.length=this.summary.length}toSingleLineString(e=80){return`\u{1F4CB} Summary: ${kO(this.summary,e)}`}},Wt=class r extends li{role;name;content;static type="message";constructor(e){super(e,r.type),this.role=e.role,this.name=e.name,this.content=e.content,this.length=this.content.map(t=>{if(t.type==="text")return t.content.length;if(t.type==="image"){let n=(t.width||0)*(t.height||0)/750;return n?n*3.5:t.content.length}return 0}).reduce((t,n)=>t+n,0)}getTextContent(){return this.content.filter(e=>e.type==="text").map(e=>e.content).join(`
|
|
310
310
|
`)}},nc=class r extends li{threadId;name;summary;static type="thread_update";constructor(e){super(e,r.type),this.threadId=e.threadId,this.name=e.name,this.summary=e.summary}},ic=class r extends li{filename;operation;size;mimeType;static type="file";constructor(e){super(e,r.type),this.filename=e.filename,this.operation=e.operation,this.size=e.size,this.mimeType=e.mimeType}toSingleLineString(){let e=this.operation==="created"?"\u{1F4C4}":this.operation==="updated"?"\u{1F4DD}":"\u{1F5D1}\uFE0F",t=this.size?` (${(this.size/1024).toFixed(1)} KB)`:"";return`${e} ${this.operation}: ${this.filename}${t}`}},kl=class r extends li{authUrl;state;integrationName;static type="oauth_request";constructor(e){super(e,r.type),this.authUrl=e.authUrl,this.state=e.state,this.integrationName=e.integrationName}},U7=class r extends li{code;state;integrationName;error;errorDescription;static type="oauth_callback";constructor(e){super(e,r.type),this.code=e.code,this.state=e.state,this.integrationName=e.integrationName,this.error=e.error,this.errorDescription=e.errorDescription}},gDe={[Wt.type]:Wt,[Hr.type]:Hr,[la.type]:la,[Oa.type]:Oa,[w3.type]:w3,[ua.type]:ua,[cn.type]:cn,[En.type]:En,[Df.type]:Df,[El.type]:El,[Of.type]:Of,[_3.type]:_3,[nc.type]:nc,[fa.type]:fa,[ic.type]:ic,[kl.type]:kl,[U7.type]:U7};function B7(r){let e=gDe[r.type];return e?new e(r):void 0}var H7=class{constructor(e,t,n,i=!1){this.aiClient=t;this.tools=n;this.internal=i;this.name=e.name,this.description=e.description,this.definition={...e}}name;description;definition;get systemInstructions(){return this.definition.instructions}getAiClient(){return this.aiClient}async run(e,t){let n=e.trim(),i=new Hr({answer:n});return t.addAnswerEvent(i),await this.aiClient.run(this,t)}};var W7={name:"Coday",description:"Default fallback agent with neutral character and access to all tools",instructions:`
|
|
311
311
|
You are Coday, an AI assistant designed for interactive usage by users through various chat-like interfaces.
|
|
312
312
|
|
|
@@ -594,7 +594,7 @@ Proceeding will:
|
|
|
594
594
|
Stopping will:
|
|
595
595
|
- End the current run
|
|
596
596
|
- Clear pending commands
|
|
597
|
-
- Return to prompt`;if(await this.interactor.chooseOption(["proceed","stop"],u,"What do you want to do?")==="stop")return i.runStatus="STOPPED",!1;a.price>0?(a.priceThreshold*=2,this.interactor.displayText(`Cost threshold increased to ${a.priceThreshold.toFixed(2)}`)):(a.iterationsThreshold*=2,this.interactor.displayText(`Iteration threshold increased to ${a.iterationsThreshold}`))}return await Promise.all(t.map(async o=>{let s;try{this.interactor.sendEvent(o),s=await n.tools.run(o)}catch(c){let u=`Error running tool ${o.name}: ${c}`;console.error(u),s=o.buildResponse(u)}this.interactor.sendEvent(s),i.addToolRequests(n.name,[o]),i.addToolResponseEvents([s])})),this.shouldProceed(i)}handleError(e,t,n){let i=`${n} error occurred`;if(e instanceof Error){i=`${n} error: ${e.message}`;let a=e;a.status===401||a.statusCode===401?i=`${n} authentication failed. Please check your API key.`:a.status===429||a.statusCode===429?i=`${n} rate limit exceeded. Please try again later.`:a.code==="ECONNREFUSED"||a.code==="ENOTFOUND"||a.code==="ETIMEDOUT"?i=`Network error connecting to ${n}. Please check your internet connection.`:e.message?.includes("Max tokens")&&(i=`${n} response exceeded token limit. Try simplifying your request or splitting it into smaller parts.`)}console.error(`${n} client error:`,e),t.next(new Oa({error:e instanceof Error?e:new Error(i)})),this.interactor.displayText(`\u26A0\uFE0F ${i}`)}shouldProceed(e){return e.runStatus==="RUNNING"&&!this.killed}showAgentAndUsage(e,t,n,i){let a=`\u{1F916} ${e.name} | ${t} - ${n} `;if(!i.usage)return;let o=`Loop${i.usage.iterations>1?"s":""}: ${i.usage.iterations} | `,s=`Input: ${i.usage.input}, Output: ${i.usage.output} | `,c=`Cache write: ${i.usage.cache_write}, Cache read: ${i.usage.cache_read}`,u=`\u{1F3C3}$${i.usage.price.toFixed(3)} / \u{1F9F5}$${i.price.toFixed(3)}`;this.interactor.displayText(a+u),this.interactor.debug(o+s+c)}getModel(e){let t=e.definition.modelName?.toLowerCase(),n=this.models.find(i=>i.alias?.toLowerCase()===t);return n||this.models.find(i=>i.name.toLowerCase()===t)}supportsModel(e){return this.models.some(t=>t.name.toLowerCase()===e||t?.alias?.toLowerCase()===e)}returnError(e){return(0,gie.of)(new Oa({error:e}))}logAgentUsage(e,t,n,i){let a=i?.usage?.input??0,o=i?.usage?.output??0,s=a+o;this.logger?.logAgentUsage(i?.username??this.username??"no_username",e.name,t,n,this.name,a,o,s)}};var Kt=class{constructor(e,t,n){this.interactor=e;this.name=t,this.config=n}tools=[];name;config;async kill(){}async getTools(e,t,n){return this.tools=await this.buildTools(e,n),this.tools.filter(i=>{if(!t||!t.length)return!0;let a=i.function.name.split("__")[1]??i.function.name;return t.includes(a)})}};var h0=class r{constructor(e,t){this.project=e;this.username=t}commandQueue=[];clearCommands(){this.commandQueue=[]}oneshot=!1;fileReadOnly=!1;threadFilesRoot;stackDepth=3;data={};aiThread;addCommands(...e){this.commandQueue.unshift(...e)}getFirstCommand(){return this.commandQueue.shift()}getSubContext(...e){let t=new r(this.project,this.username);return t.oneshot=this.oneshot,t.fileReadOnly=this.fileReadOnly,t.addCommands(...e),t.stackDepth=this.stackDepth-1,t}cloneWithoutCommands(){let e=new r(this.project,this.username);return e.oneshot=this.oneshot,e.fileReadOnly=this.fileReadOnly,e.stackDepth=this.stackDepth,e.data=this.data,e}};var TGe=["project","user"],Di=class{static validate(e){if(!TGe.includes(e))throw new Error(`Invalid configuration level: ${e}. Only PROJECT and USER levels are allowed.`)}};var vie=[".pdf",".doc",".docx",".odt",".rtf",".xls",".xlsx",".ods",".csv",".tsv",".txt",".md",".markdown",".rst",".json",".xml",".yaml",".yml",".toml",".html",".htm",".css",".svg",".ts",".tsx",".js",".jsx",".py",".java",".cpp",".c",".h",".hpp",".cs",".go",".rs",".rb",".php",".swift",".kt",".scala",".sh",".bash",".sql",".env",".properties",".ini",".conf",".config",".log"];function mx(r){let e=r.toLowerCase().substring(r.lastIndexOf("."));return vie.includes(e)}function yie(){return vie.join(", ")}var gx=class{constructor(e){this.tools=e;this.charLength=JSON.stringify(e).length}charLength=0;getTools(){return[...this.tools]}async run(e){let t=this.tools.find(s=>s.function.name===e.name);if(!t)throw new Error(`Tool '${e.name}' not found`);let n,i=t.function.function,a=JSON.parse(e.args),o=Array.isArray(a)?a:[a];if(n=await i(...o),n||(n=`Tool function ${e.name} finished without error.`),typeof n!="string"){if(n&&typeof n=="object"&&"type"in n&&(n.type==="text"||n.type==="image"))return e.buildResponse(n);n=JSON.stringify(n)}return e.buildResponse(n)}};var vx={CONFLUENCE:[],GIT:[],GITLAB:[],JIRA:[],SLACK:[],ZENDESK:[],BASECAMP:[]},Bf=Object.keys(vx).filter(r=>vx[r]?.length===0);var Kn=wr(bs(),1),yx=class{events=new Kn.Subject;thinking$=new Kn.Subject;subs=[];lastInviteEvent;debugLevelEnabled=!1;constructor(){this.subs.push(this.thinking$.pipe((0,Kn.throttleTime)(Of.debounce)).subscribe(()=>this.sendEvent(new Of({}))))}async promptText(e,t){let n=new ua({invite:e,defaultValue:t});this.lastInviteEvent=n;let i=this.events.pipe((0,Kn.filter)(a=>a.parentKey===n.timestamp),(0,Kn.filter)(a=>a instanceof Hr),(0,Kn.take)(1),(0,Kn.map)(a=>a.answer));this.sendEvent(n);try{return await(0,Kn.firstValueFrom)(i)}catch(a){throw new Error(`No answer received over invite ${n.timestamp} : ${a.message}`)}}async promptSecretText(e,t,n="********"){let i=t?n:"",a=await this.promptText(e,i);if(a===n&&t)return t;if(a)return a}async chooseOption(e,t,n){let
|
|
597
|
+
- Return to prompt`;if(await this.interactor.chooseOption(["proceed","stop"],u,"What do you want to do?")==="stop")return i.runStatus="STOPPED",!1;a.price>0?(a.priceThreshold*=2,this.interactor.displayText(`Cost threshold increased to ${a.priceThreshold.toFixed(2)}`)):(a.iterationsThreshold*=2,this.interactor.displayText(`Iteration threshold increased to ${a.iterationsThreshold}`))}return await Promise.all(t.map(async o=>{let s;try{this.interactor.sendEvent(o),s=await n.tools.run(o)}catch(c){let u=`Error running tool ${o.name}: ${c}`;console.error(u),s=o.buildResponse(u)}this.interactor.sendEvent(s),i.addToolRequests(n.name,[o]),i.addToolResponseEvents([s])})),this.shouldProceed(i)}handleError(e,t,n){let i=`${n} error occurred`;if(e instanceof Error){i=`${n} error: ${e.message}`;let a=e;a.status===401||a.statusCode===401?i=`${n} authentication failed. Please check your API key.`:a.status===429||a.statusCode===429?i=`${n} rate limit exceeded. Please try again later.`:a.code==="ECONNREFUSED"||a.code==="ENOTFOUND"||a.code==="ETIMEDOUT"?i=`Network error connecting to ${n}. Please check your internet connection.`:e.message?.includes("Max tokens")&&(i=`${n} response exceeded token limit. Try simplifying your request or splitting it into smaller parts.`)}console.error(`${n} client error:`,e),t.next(new Oa({error:e instanceof Error?e:new Error(i)})),this.interactor.displayText(`\u26A0\uFE0F ${i}`)}shouldProceed(e){return e.runStatus==="RUNNING"&&!this.killed}showAgentAndUsage(e,t,n,i){let a=`\u{1F916} ${e.name} | ${t} - ${n} `;if(!i.usage)return;let o=`Loop${i.usage.iterations>1?"s":""}: ${i.usage.iterations} | `,s=`Input: ${i.usage.input}, Output: ${i.usage.output} | `,c=`Cache write: ${i.usage.cache_write}, Cache read: ${i.usage.cache_read}`,u=`\u{1F3C3}$${i.usage.price.toFixed(3)} / \u{1F9F5}$${i.price.toFixed(3)}`;this.interactor.displayText(a+u),this.interactor.debug(o+s+c)}getModel(e){let t=e.definition.modelName?.toLowerCase(),n=this.models.find(i=>i.alias?.toLowerCase()===t);return n||this.models.find(i=>i.name.toLowerCase()===t)}supportsModel(e){return this.models.some(t=>t.name.toLowerCase()===e||t?.alias?.toLowerCase()===e)}returnError(e){return(0,gie.of)(new Oa({error:e}))}logAgentUsage(e,t,n,i){let a=i?.usage?.input??0,o=i?.usage?.output??0,s=a+o;this.logger?.logAgentUsage(i?.username??this.username??"no_username",e.name,t,n,this.name,a,o,s)}};var Kt=class{constructor(e,t,n){this.interactor=e;this.name=t,this.config=n}tools=[];name;config;async kill(){}async getTools(e,t,n){return this.tools=await this.buildTools(e,n),this.tools.filter(i=>{if(!t||!t.length)return!0;let a=i.function.name.split("__")[1]??i.function.name;return t.includes(a)})}};var h0=class r{constructor(e,t){this.project=e;this.username=t}commandQueue=[];clearCommands(){this.commandQueue=[]}oneshot=!1;fileReadOnly=!1;threadFilesRoot;stackDepth=3;data={};aiThread;addCommands(...e){this.commandQueue.unshift(...e)}getFirstCommand(){return this.commandQueue.shift()}getSubContext(...e){let t=new r(this.project,this.username);return t.oneshot=this.oneshot,t.fileReadOnly=this.fileReadOnly,t.addCommands(...e),t.stackDepth=this.stackDepth-1,t}cloneWithoutCommands(){let e=new r(this.project,this.username);return e.oneshot=this.oneshot,e.fileReadOnly=this.fileReadOnly,e.stackDepth=this.stackDepth,e.data=this.data,e}};var TGe=["project","user"],Di=class{static validate(e){if(!TGe.includes(e))throw new Error(`Invalid configuration level: ${e}. Only PROJECT and USER levels are allowed.`)}};var vie=[".pdf",".doc",".docx",".odt",".rtf",".xls",".xlsx",".ods",".csv",".tsv",".txt",".md",".markdown",".rst",".json",".xml",".yaml",".yml",".toml",".html",".htm",".css",".svg",".ts",".tsx",".js",".jsx",".py",".java",".cpp",".c",".h",".hpp",".cs",".go",".rs",".rb",".php",".swift",".kt",".scala",".sh",".bash",".sql",".env",".properties",".ini",".conf",".config",".log"];function mx(r){let e=r.toLowerCase().substring(r.lastIndexOf("."));return vie.includes(e)}function yie(){return vie.join(", ")}var gx=class{constructor(e){this.tools=e;this.charLength=JSON.stringify(e).length}charLength=0;getTools(){return[...this.tools]}async run(e){let t=this.tools.find(s=>s.function.name===e.name);if(!t)throw new Error(`Tool '${e.name}' not found`);let n,i=t.function.function,a=JSON.parse(e.args),o=Array.isArray(a)?a:[a];if(n=await i(...o),n||(n=`Tool function ${e.name} finished without error.`),typeof n!="string"){if(n&&typeof n=="object"&&"type"in n&&(n.type==="text"||n.type==="image"))return e.buildResponse(n);n=JSON.stringify(n)}return e.buildResponse(n)}};var vx={CONFLUENCE:[],GIT:[],GITLAB:[],JIRA:[],SLACK:[],ZENDESK:[],BASECAMP:[]},Bf=Object.keys(vx).filter(r=>vx[r]?.length===0);var Kn=wr(bs(),1),yx=class{events=new Kn.Subject;thinking$=new Kn.Subject;subs=[];lastInviteEvent;debugLevelEnabled=!1;constructor(){this.subs.push(this.thinking$.pipe((0,Kn.throttleTime)(Of.debounce)).subscribe(()=>this.sendEvent(new Of({}))))}async promptText(e,t){let n=new ua({invite:e,defaultValue:t});this.lastInviteEvent=n;let i=this.events.pipe((0,Kn.filter)(a=>a.parentKey===n.timestamp),(0,Kn.filter)(a=>a instanceof Hr),(0,Kn.take)(1),(0,Kn.map)(a=>a.answer));this.sendEvent(n);try{return await(0,Kn.firstValueFrom)(i)}catch(a){throw new Error(`No answer received over invite ${n.timestamp} : ${a.message}`)}}async promptSecretText(e,t,n="********"){let i=t?n:"",a=await this.promptText(e,i);if(a===n&&t)return t;if(a)return a}async chooseOption(e,t,n,i){let a=new la({options:e,invite:t,optionalQuestion:n,allowFreeText:i??!1}),o=this.events.pipe((0,Kn.filter)(s=>s.parentKey===a.timestamp),(0,Kn.filter)(s=>s instanceof Hr),(0,Kn.take)(1),(0,Kn.map)(s=>s.answer));this.sendEvent(a);try{return await(0,Kn.firstValueFrom)(o)}catch(s){throw new Error(`No answer received over choice ${a.timestamp} : ${s.message}`)}}displayText(e,t){this.sendEvent(new Df({text:e,speaker:t}))}debug(e){if(!this.debugLevelEnabled)return;let t=`${new Date().toISOString()} DEBUG: ${e.toString()}`;console.log(t),this.sendEvent(new Df({text:t}))}warn(e){this.sendEvent(new _3({warning:e}))}error(e){this.sendEvent(new Oa({error:e}))}thinking(){this.thinking$.next(null)}sendEvent(e){this.events.next(e)}replayLastInvite(){this.lastInviteEvent&&this.sendEvent(this.lastInviteEvent)}kill(){this.subs.forEach(e=>e.unsubscribe()),this.events.complete()}};var F4=class{title;content;level;agentName;createdAt;updatedAt;constructor(e){this.title=e.title??"no title",this.content=e.content??"no content",this.level=e.level??"PROJECT",this.agentName=e.agentName,this.createdAt=e.createdAt??new Date,this.updatedAt=e.updatedAt}update(e){return this.title=e.title??this.title,this.content=e.content??this.content,this.level=e.level??this.level,this.agentName=e.agentName,this.createdAt=e.createdAt??new Date,this.updatedAt=e.updatedAt??new Date,this}};var pc=class extends yx{constructor(t){super();this.clientId=t}addAnswerEvent(t,n){let i=new Hr({answer:t,parentKey:n});this.sendEvent(i)}kill(){console.log(`Interactor for clientId ${this.clientId} killed`),super.kill()}};var bie={version:1};var bx=class extends Fe{constructor(t){super({commandWord:"add-query",description:"[internal] used to allow user feedback between flow commands.",isInternal:!0});this.interactor=t}async handle(t,n){let i=this.getSubCommand(t),a=i||"What message would you want to add ?",o=await this.interactor.promptText(`${a}
|
|
598
598
|
(type nothing to proceed) `),s=i?`To the following query: "${i}"
|
|
599
599
|
I answer: `:"",c=o?`"${o}"`:i?'nothing."':"";return(o||i)&&n.addCommands(`@ ${s}${c}`),n}};function Ze(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t}function me(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}var K$=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return K$=r.randomUUID.bind(r),r.randomUUID();let e=new Uint8Array(1),t=r?()=>r.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^t()&15>>+n/4).toString(16))};function yu(r){return typeof r=="object"&&r!==null&&("name"in r&&r.name==="AbortError"||"message"in r&&String(r.message).includes("FetchRequestCanceledException"))}var N4=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null){try{if(Object.prototype.toString.call(r)==="[object Error]"){let e=new Error(r.message,r.cause?{cause:r.cause}:{});return r.stack&&(e.stack=r.stack),r.cause&&!e.cause&&(e.cause=r.cause),r.name&&(e.name=r.name),e}}catch{}try{return new Error(JSON.stringify(r))}catch{}}return new Error(r)};var ot=class extends Error{},fi=class r extends ot{constructor(e,t,n,i){super(`${r.makeMessage(e,t,n)}`),this.status=e,this.headers=i,this.requestID=i?.get("request-id"),this.error=t}static makeMessage(e,t,n){let i=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&i?`${e} ${i}`:e?`${e} status code (no body)`:i||"(no status code or body)"}static generate(e,t,n,i){if(!e||!i)return new Zl({message:n,cause:N4(t)});let a=t;return e===400?new g0(e,a,n,i):e===401?new v0(e,a,n,i):e===403?new y0(e,a,n,i):e===404?new b0(e,a,n,i):e===409?new x0(e,a,n,i):e===422?new w0(e,a,n,i):e===429?new _0(e,a,n,i):e>=500?new S0(e,a,n,i):new r(e,a,n,i)}},Oi=class extends fi{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},Zl=class extends fi{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},m0=class extends Zl{constructor({message:e}={}){super({message:e??"Request timed out."})}},g0=class extends fi{},v0=class extends fi{},y0=class extends fi{},b0=class extends fi{},x0=class extends fi{},w0=class extends fi{},_0=class extends fi{},S0=class extends fi{};var DGe=/^[a-z][a-z0-9+.-]*:/i,wie=r=>DGe.test(r),Y$=r=>(Y$=Array.isArray,Y$(r)),X$=Y$;function Q$(r){return typeof r!="object"?{}:r??{}}function _ie(r){if(!r)return!0;for(let e in r)return!1;return!0}function Sie(r,e){return Object.prototype.hasOwnProperty.call(r,e)}var Eie=(r,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new ot(`${r} must be an integer`);if(e<0)throw new ot(`${r} must be a positive integer`);return e};var xx=r=>{try{return JSON.parse(r)}catch{return}};var kie=r=>new Promise(e=>setTimeout(e,r));var Jl="0.65.0";var Pie=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function OGe(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var IGe=()=>{let r=OGe();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Jl,"X-Stainless-OS":Cie(Deno.build.os),"X-Stainless-Arch":Aie(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Jl,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(r==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Jl,"X-Stainless-OS":Cie(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Aie(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=$Ge();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Jl,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Jl,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function $Ge(){if(typeof navigator>"u"||!navigator)return null;let r=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of r){let n=t.exec(navigator.userAgent);if(n){let i=n[1]||0,a=n[2]||0,o=n[3]||0;return{browser:e,version:`${i}.${a}.${o}`}}}return null}var Aie=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",Cie=r=>(r=r.toLowerCase(),r.includes("ios")?"iOS":r==="android"?"Android":r==="darwin"?"MacOS":r==="win32"?"Windows":r==="freebsd"?"FreeBSD":r==="openbsd"?"OpenBSD":r==="linux"?"Linux":r?`Other:${r}`:"Unknown"),Tie,Die=()=>Tie??(Tie=IGe());function Oie(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ej(...r){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...r)}function wx(r){let e=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return ej({start(){},async pull(t){let{done:n,value:i}=await e.next();n?t.close():t.enqueue(i)},async cancel(){await e.return?.()}})}function M4(r){if(r[Symbol.asyncIterator])return r;let e=r.getReader();return{async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Iie(r){if(r===null||typeof r!="object")return;if(r[Symbol.asyncIterator]){await r[Symbol.asyncIterator]().return?.();return}let e=r.getReader(),t=e.cancel();e.releaseLock(),await t}var $ie=({headers:r,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});function Fie(r){let e=0;for(let i of r)e+=i.length;let t=new Uint8Array(e),n=0;for(let i of r)t.set(i,n),n+=i.length;return t}var jie;function L4(r){let e;return(jie??(e=new globalThis.TextEncoder,jie=e.encode.bind(e)))(r)}var Rie;function tj(r){let e;return(Rie??(e=new globalThis.TextDecoder,Rie=e.decode.bind(e)))(r)}var uo,lo,bu=class{constructor(){uo.set(this,void 0),lo.set(this,void 0),Ze(this,uo,new Uint8Array,"f"),Ze(this,lo,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?L4(e):e;Ze(this,uo,Fie([me(this,uo,"f"),t]),"f");let n=[],i;for(;(i=FGe(me(this,uo,"f"),me(this,lo,"f")))!=null;){if(i.carriage&&me(this,lo,"f")==null){Ze(this,lo,i.index,"f");continue}if(me(this,lo,"f")!=null&&(i.index!==me(this,lo,"f")+1||i.carriage)){n.push(tj(me(this,uo,"f").subarray(0,me(this,lo,"f")-1))),Ze(this,uo,me(this,uo,"f").subarray(me(this,lo,"f")),"f"),Ze(this,lo,null,"f");continue}let a=me(this,lo,"f")!==null?i.preceding-1:i.preceding,o=tj(me(this,uo,"f").subarray(0,a));n.push(o),Ze(this,uo,me(this,uo,"f").subarray(i.index),"f"),Ze(this,lo,null,"f")}return n}flush(){return me(this,uo,"f").length?this.decode(`
|
|
600
600
|
`):[]}};uo=new WeakMap,lo=new WeakMap;bu.NEWLINE_CHARS=new Set([`
|
|
@@ -1044,7 +1044,7 @@ Summary:
|
|
|
1044
1044
|
`)+c}};var hE=class extends Vn{constructor(t,n){super({commandWord:"stats",description:"Show usage statistics and analytics",isInternal:!0},t);this.services=n;this.handlers=[new pE(this.interactor,this.services),new dE(this.interactor,this.services)]}};var Rit=100,mE=class{constructor(e,t,n,i){this.interactor=e;this.aiHandler=t;this.configHandler=n;this.services=i}handlers=[];maxIterations=Rit;killed=!1;processing=!1;async init(e){try{let t=new bx(this.interactor),n=new oE(this.interactor,this.services);if(this.handlers=[this.configHandler,new mS(this.interactor),new Zx(this.interactor),t,n,new R_(this.interactor),new fE(this.interactor),new hE(this.interactor,this.services)],e?.prompts)for(let[i,a]of Object.entries(e.prompts))this.handlers.push(new pS(a,i));if(this.services.project.selectedProject){let i=await this.services.prompt.list(this.services.project.selectedProject.name),a=new hS(this.interactor,this.services.prompt,this.services.project.selectedProject.name,i);this.handlers.push(a)}this.handlers.push(this.aiHandler),this.handlers=this.handlers.filter(i=>i.requiredIntegrations.every(a=>this.services.integration.hasIntegration(a)))}catch(t){this.interactor.error(`Error initializing handlers: ${t}`)}}async handle(e){if(!e)throw new Error("Invalid command context");let t=0,n;this.processing=!0;try{do{if(this.killed)return e;if(n=e.getFirstCommand(),t++,this.isHelpAsked(n)){let a=["Available commands:",this.formatHelp("help/h/[nothing]","displays this help message"),...this.handlers.slice().filter(o=>!o.isInternal).map(o=>this.formatHelp(o.commandWord,o.description)).sort(),this.formatHelp("[any other text]","defaults to asking the AI with the current context.")];this.interactor.displayText(a.join(`
|
|
1045
1045
|
`));continue}if(!n)break;let i=this.handlers.find(a=>a.accept(n,e));try{if(i){if(e=await i.handle(n,e),e.aiThread?.runStatus==="STOPPED")return e.clearCommands(),this.processing=!1,e}else n.startsWith(this.aiHandler.commandWord)?this.interactor.error(`Could not handle request ${n}, check your AI integration`):e.addCommands(`${this.aiHandler.commandWord} ${n}`)}catch(a){this.interactor.error(`An error occurred while trying to process your request: ${a}`)}}while((n||t<this.maxIterations)&&this.processing)}finally{this.processing=!1}return t>=this.maxIterations&&this.interactor.warn("Maximum iterations reached for a command"),e}isHelpAsked(e){return e===""||e==="help"||e==="h"}formatHelp(e,t){return` - ${e.padEnd(15," ")} : ${t}`}stop(){this.processing=!1}kill(){this.stop(),this.killed=!0,this.aiHandler.kill()}};var Afe=wr(bs(),1);function kfe(r){let e=r.match(/^@(\S*)(?:\s+([\s\S]*))?$/);if(!e)return["",r];let t=e[1],n=e[2]||"";return[t?.toLowerCase()??"",n]}var gE=class extends Fe{constructor(t,n,i){super({commandWord:"@",description:"calls the AI with the given command and current context. 'reset' for using a new thread. You can call whatever assistant in your openai account by its name, ex: joke_generator called by @jok (choice prompt if multiple matches)."});this.interactor=t;this.agentService=n;this.threadService=i}async handle(t,n){let[i,a]=kfe(t),o=i?t:a;this.interactor.debug(`Agent name extracted from command: ${i}`);let s=await this.selectAgent(i,n);return s?a.trim()?this.runAgent(s,o,n):(this.interactor.debug(`Agent ${s.name} selected.`),n):(this.interactor.error("Failed to find any agent"),n)}async selectAgent(t,n){if(t){let s=await this.agentService.findAgentByNameStart(t,n);return s&&this.interactor.debug(`Selected agent: ${s.name}`),s}let i=n?.aiThread?.getLastAgentName();if(i){let s=await this.agentService.findByName(i,n);if(s)return this.interactor.debug(`Select last used agent: ${s.name}`),s;this.interactor.warn("Previously selected agent not available anymore")}let a=this.agentService.getPreferredAgent();if(a){let s=await this.agentService.findByName(a,n);if(s)return this.interactor.debug(`Selected default agent: ${a}`),s;this.interactor.warn(`Preferred agent '${a}' not found, using default.`)}let o=await this.agentService.findByName("coday",n);return o?this.interactor.debug("Selected default 'Coday' agent"):this.interactor.error("Critical failure: Cannot initialize default Coday agent!"),o}async runAgent(t,n,i){let a=await t.run(n,i.aiThread);await this.checkAndAutoSave(i.aiThread,t),a.subscribe({next:o=>{this.interactor.sendEvent(o)},error:o=>{o.message==="Processing interrupted by user request"?this.interactor.debug("Processing stopped gracefully"):this.interactor.error(`Error in AI processing: ${o.message}`)}});try{await(0,Afe.lastValueFrom)(a,{defaultValue:void 0})}catch(o){this.interactor.error(`Could not run agent ${t.name} : ${o.message}`)}finally{try{await this.threadService.autoSave()}catch(o){this.interactor.debug(`Final auto-save failed: ${o}`)}}return i}async checkAndAutoSave(t,n){if(t.getUserMessageCount()!==0)if(t.name)try{await this.threadService.autoSave()}catch(i){this.interactor.debug(`Auto-save failed: ${i}`)}else try{let i=await $le(t,n);await this.threadService.autoSave(i),this.interactor.displayText(`Thread auto-renamed to "${i}"`)}catch(i){this.interactor.warn(`Auto-rename failed: ${i}`)}}async kill(){await this.agentService.kill()}};var e7e=wr(Sc(),1);import*as WC from"fs/promises";import*as Cd from"path";var Cfe={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",google:"GEMINI_API_KEY"},vm=class{constructor(e,t,n,i){this.interactor=e;this.userService=t;this.projectsAiProviderConfigs=n;this.logger=i}aiClients=[];aiProviderConfigs;init(e){if(this.aiProviderConfigs)return;let t=e.project.ai||[],n=this.projectsAiProviderConfigs||[],i=this.userService.config.ai||[],a=this.detectProvidersFromEnvironment(),o=new Set([...t.map(l=>l.name.toLowerCase()),...n.map(l=>l.name.toLowerCase()),...i.map(l=>l.name.toLowerCase())]);this.aiProviderConfigs=[];for(let l of[...a,...t,...n,...i]){let f=this.aiProviderConfigs.findIndex(d=>d.name===l.name);if(f===-1)this.aiProviderConfigs.push(l);else{let d=this.aiProviderConfigs[f],p=d.models?[...d.models]:[];(l.models??[]).forEach(h=>{let g=p.findIndex(v=>v.alias===h.alias||v.name===h.name);if(g===-1)p.push(h);else{let v=p[g];p[g]={...v,...h,price:{...v.price,...h.price}}}}),this.aiProviderConfigs[f]={...d,...l,models:p}}}this.aiClients=this.aiProviderConfigs.map(l=>this.createClient(l)).filter(l=>!!l);let s=a.filter(l=>!o.has(l.name.toLowerCase())).map(l=>l.name.toLowerCase()),c=new Set(s),u=`AI providers (models listed as: name (alias)):
|
|
1046
1046
|
`+this.aiProviderConfigs.map(l=>{let f=this.aiClients.find(v=>v.name.toLowerCase()===l.name.toLowerCase()),d=!!f,p=d?"\u2705":"\u274C",h=c.has(l.name.toLowerCase())?" (auto-detected)":"",g=` - ${p} ${l.name}${h}`;if(d&&Array.isArray(f.models)&&f.models.length>0){let v=f.models.map(y=>y.alias&&y.alias!==y.name?`${y.name} (${y.alias})`:y.name).join(", ");g+=`, models: ${v}`}return g}).join(`
|
|
1047
|
-
`);this.interactor.displayText(u)}getClient(e,t){let n=this.aiClients.filter(i=>{let a=!e||i.name.toLowerCase()===e.toLowerCase(),o=!t||i.supportsModel(t.toLowerCase());return a&&o});return n.length?n[0]:void 0}getAllModels(){let e=[];for(let t of this.aiClients)if(t.models)for(let n of t.models)e.push({name:n.name,providerName:t.name});return e}cleanup(){this.aiClients.forEach(e=>e.kill()),this.aiClients=[]}kill(){this.cleanup(),this.aiProviderConfigs=void 0}getApiKey(e){let t=Cfe[e.name];return(t?process.env[t]??process.env[`${e.name.toUpperCase()}_API_KEY`]:void 0)??e.apiKey}detectProvidersFromEnvironment(){let e=[];for(let[t,n]of Object.entries(Cfe)){let i=process.env[n];if(i){let a={name:t,apiKey:i};e.push(a),this.interactor.debug(`\u{1F50D} Auto-detected ${t} provider from ${n} environment variable`)}}return e}createClient(e){let t=this.getApiKey(e);if(!t){this.interactor.displayText(`\u2139\uFE0F no api key for AI provider '${e.name}'`);return}let n={...e,apiKey:t};switch(e.name.toLowerCase()){case"anthropic":return new Vx(this.interactor,n,this.logger);case"google":return new fS(this.interactor,n,this.logger);default:return new nm(this.interactor,n,this.logger)}}};function Tfe(r){return({query:t,agentName:n})=>{try{let i=`@${n} ${t}`;return r.addCommands(i),`Query successfully redirected to agent '${n}'. The agent will process the query with full context after this run completes.`}catch(i){return`Error during redirection: ${i.message}`}}}var M6=class extends Kt{constructor(t,n,i,a){super(t,i,a);this.agentSummaries=n}static TYPE="AI";async buildTools(t,n){let i=[];if(!t.oneshot){let a=async({message:s,options:c})=>`User answered: ${c?.length?await this.interactor.chooseOption(c,s):await this.interactor.promptText(s)}`,o={type:"function",function:{name:`${this.name}__queryUser`,description:`Allows to ask the user a question.
|
|
1047
|
+
`);this.interactor.displayText(u)}getClient(e,t){let n=this.aiClients.filter(i=>{let a=!e||i.name.toLowerCase()===e.toLowerCase(),o=!t||i.supportsModel(t.toLowerCase());return a&&o});return n.length?n[0]:void 0}getAllModels(){let e=[];for(let t of this.aiClients)if(t.models)for(let n of t.models)e.push({name:n.name,providerName:t.name});return e}cleanup(){this.aiClients.forEach(e=>e.kill()),this.aiClients=[]}kill(){this.cleanup(),this.aiProviderConfigs=void 0}getApiKey(e){let t=Cfe[e.name];return(t?process.env[t]??process.env[`${e.name.toUpperCase()}_API_KEY`]:void 0)??e.apiKey}detectProvidersFromEnvironment(){let e=[];for(let[t,n]of Object.entries(Cfe)){let i=process.env[n];if(i){let a={name:t,apiKey:i};e.push(a),this.interactor.debug(`\u{1F50D} Auto-detected ${t} provider from ${n} environment variable`)}}return e}createClient(e){let t=this.getApiKey(e);if(!t){this.interactor.displayText(`\u2139\uFE0F no api key for AI provider '${e.name}'`);return}let n={...e,apiKey:t};switch(e.name.toLowerCase()){case"anthropic":return new Vx(this.interactor,n,this.logger);case"google":return new fS(this.interactor,n,this.logger);default:return new nm(this.interactor,n,this.logger)}}};function Tfe(r){return({query:t,agentName:n})=>{try{let i=`@${n} ${t}`;return r.addCommands(i),`Query successfully redirected to agent '${n}'. The agent will process the query with full context after this run completes.`}catch(i){return`Error during redirection: ${i.message}`}}}var M6=class extends Kt{constructor(t,n,i,a){super(t,i,a);this.agentSummaries=n}static TYPE="AI";async buildTools(t,n){let i=[];if(!t.oneshot){let a=async({message:s,options:c})=>`User answered: ${c?.length?await this.interactor.chooseOption(c,s,void 0,!0):await this.interactor.promptText(s)}`,o={type:"function",function:{name:`${this.name}__queryUser`,description:`Allows to ask the user a question.
|
|
1048
1048
|
IMPORTANT: Use this tool only when necessary, as it is intrusive for the user.
|
|
1049
1049
|
|
|
1050
1050
|
If no options are provided, the user can answer with free text.
|
|
@@ -1191,7 +1191,7 @@ Should be used selectively for significant knowledge that:
|
|
|
1191
1191
|
2) will be valuable in multiple future interactions
|
|
1192
1192
|
3) is not redundant with existing memories (in that case, update the existing one)
|
|
1193
1193
|
|
|
1194
|
-
Do not memorize partial knowledge, single-use information, or minor implementation details.`,parameters:{type:"object",properties:{title:{type:"string",description:"Title of the memory: should be precise, unique, and reflect the full scope of the content. Avoid generic titles unless the content is really generic."},content:{type:"string",description:"Content of the memory: must be complete, validated knowledge with clear structure (sections, examples when relevant). Should include enough context to be self-contained but avoid redundancy with other memories. Length: preferably between a paragraph (for focused topics) and 3 pages (for complex patterns)."}}},parse:JSON.parse,function:u}};i.push(l);let f=async({title:p})=>{try{return this.memoryService.deleteMemory(p),`Memory deleted: ${p}`}catch(m){let h=`Failed to delete memory: ${m instanceof Error?m.message:"Unknown error"}`;return this.interactor.error(h),h}},d={type:"function",function:{name:`${this.name}__delete`,description:"Delete a memory entry by its title. Works for both PROJECT and USER level memories.",parameters:{type:"object",properties:{title:{type:"string",description:"Title of the memory to delete."}}},parse:JSON.parse,function:f}};return i.push(d),i}};var L1e="PARAMETERS",v8=class extends Kt{static TYPE="PROJECT_SCRIPTS";constructor(e,t,n){super(e,t,n)}async buildTools(e,t){let n=[],i=e.project.scripts,a=i?Object.entries(i).map(o=>{let s=async u=>{let l;return o[1].command.includes(L1e)?l=o[1].command.replace(L1e,u?.stringParameters??""):l=`${o[1].command} ${u?.stringParameters??""}`,await ph({command:l,root:e.project.root,interactor:this.interactor,requireConfirmation:o[1].requireConfirmation})};return{type:"function",function:{name:`${this.name}__${o[0]}`,description:o[1].description,parameters:o[1].parametersDescription?{type:"object",properties:{stringParameters:{type:"string",description:o[1].parametersDescription}}}:{type:"object",properties:{}},parse:JSON.parse,function:s}}}):[];return n.push(...a),n}};import{execFile as Zht}from"child_process";import{promisify as Jht}from"util";var ud=Jht(Zht),Kht=/^[a-zA-Z0-9_-]+$/;function Yht(r){return Kht.test(r)?null:`Error: invalid session name '${r}'. Only alphanumeric characters, hyphens and underscores are allowed.`}var y8=class extends Kt{static TYPE="TMUX";constructor(e,t){super(e,t)}async buildTools(e,t){return[{type:"function",function:{name:`${this.name}__run`,description:`Manage long-running processes in persistent tmux sessions.
|
|
1194
|
+
Do not memorize partial knowledge, single-use information, or minor implementation details.`,parameters:{type:"object",properties:{title:{type:"string",description:"Title of the memory: should be precise, unique, and reflect the full scope of the content. Avoid generic titles unless the content is really generic."},content:{type:"string",description:"Content of the memory: must be complete, validated knowledge with clear structure (sections, examples when relevant). Should include enough context to be self-contained but avoid redundancy with other memories. Length: preferably between a paragraph (for focused topics) and 3 pages (for complex patterns)."}}},parse:JSON.parse,function:u}};i.push(l);let f=async({title:p})=>{try{return this.memoryService.deleteMemory(p),`Memory deleted: ${p}`}catch(m){let h=`Failed to delete memory: ${m instanceof Error?m.message:"Unknown error"}`;return this.interactor.error(h),h}},d={type:"function",function:{name:`${this.name}__delete`,description:"Delete a memory entry by its title. Works for both PROJECT and USER level memories.",parameters:{type:"object",properties:{title:{type:"string",description:"Title of the memory to delete."}}},parse:JSON.parse,function:f}};return i.push(d),i}};var L1e="PARAMETERS",v8=class extends Kt{static TYPE="PROJECT_SCRIPTS";constructor(e,t,n){super(e,t,n)}async buildTools(e,t){let n=[],i=e.project.scripts,a=i?Object.entries(i).map(o=>{let s=async u=>{let l;return o[1].command.includes(L1e)?l=o[1].command.replace(L1e,u?.stringParameters??""):l=`${o[1].command} ${u?.stringParameters??""}`,await ph({command:l,root:e.project.root,interactor:this.interactor,requireConfirmation:o[1].requireConfirmation})};return{type:"function",function:{name:`${this.name}__${o[0]}`,description:o[1].description,parameters:o[1].parametersDescription?{type:"object",properties:{stringParameters:{type:"string",description:o[1].parametersDescription}}}:{type:"object",properties:{}},parse:JSON.parse,function:s}}}):[];return n.push(...a),n}};import{execFile as Zht}from"child_process";import{promisify as Jht}from"util";var ud=Jht(Zht),Kht=/^[a-zA-Z0-9_-]+$/;function Yht(r){return Kht.test(r)?null:`Error: invalid session name '${r}'. Only alphanumeric characters, hyphens and underscores are allowed.`}var y8=class extends Kt{static TYPE="TMUX";constructor(e,t){super(e,t)}async buildTools(e,t){let n=e.project.root;return[{type:"function",function:{name:`${this.name}__run`,description:`Manage long-running processes in persistent tmux sessions.
|
|
1195
1195
|
Sessions survive across agent interactions and can be inspected at any time.
|
|
1196
1196
|
|
|
1197
1197
|
Actions:
|
|
@@ -1202,7 +1202,8 @@ Actions:
|
|
|
1202
1202
|
- send <session> <command>: send a command to an already running session
|
|
1203
1203
|
- stop <session>: kill a session and its processes
|
|
1204
1204
|
|
|
1205
|
-
Use clear, stable session names matching the application role, eg: "backend", "frontend", "agentos", "worker", "db".`,parameters:{type:"object",properties:{action:{type:"string",enum:["list","status","start","logs","send","stop"],description:"The tmux action to perform."},session:{type:"string",description:"Session name (required for all actions except list)."},command:{type:"string",description:"Command to run (required for start and send actions)."}}},parse:JSON.parse,function:async({action:n,session:i,command:a})=>{try{if(i!==void 0){let o=Yht(i);if(o)return o}switch(n){case"list":try{let{stdout:o}=await ud("tmux",["list-sessions"]);return o.trim()}catch{return"No tmux sessions running"}case"status":{if(!i)return"Error: session name is required for status";try{return await ud("tmux",["has-session","-t",i]),"running"}catch{return"stopped"}}case"start":{if(!i)return"Error: session name is required for start";if(!a)return"Error: command is required for start";try{await ud("tmux",["new-session","-d","-s",i,"-x","220","-y","50"])}catch{}return await ud("tmux",["send-keys","-t",i,a,"Enter"]),`Session '${i}' started`}case"logs":{if(!i)return"Error: session name is required for logs";try{let{stdout:o}=await ud("tmux",["capture-pane","-t",i,"-p","-S","-200"]);return o.trim()}catch{return`Session '${i}' not found`}}case"send":{if(!i)return"Error: session name is required for send";if(!a)return"Error: command is required for send";try{return await ud("tmux",["send-keys","-t",i,a,"Enter"]),`Command sent to session '${i}'`}catch{return`Session '${i}' not found`}}case"stop":{if(!i)return"Error: session name is required for stop";try{return await ud("tmux",["kill-session","-t",i]),`Session '${i}' killed`}catch{return`Session '${i}' not found`}}default:return`Unknown action: ${n}`}}catch(o){let s=`tmux error: ${o instanceof Error?o.message:String(o)}`;return this.interactor.error(s),s}}}}]}async kill(){}};var Xht=["push","push -f","push --force","push --tags","reset","&&","clean"],q1e=async({params:r,root:e,interactor:t})=>{let n=`git ${r}`,i=Xht.some(a=>r.includes(a));return await ph({command:n,root:e,interactor:t,requireConfirmation:i})};var b8=class extends Kt{constructor(t,n,i,a){super(t,i,a);this.integrationService=n}static TYPE="GIT";async buildTools(t,n){let i=[];if(!this.integrationService.hasIntegration("GIT"))return i;let a=async({params:s})=>await q1e({params:s,root:t.project.root,interactor:this.interactor}),o={type:"function",function:{name:`${this.name}__git`,description:"Run git command and parameters.",parameters:{type:"object",properties:{params:{type:"string",description:"Additional command (like add, log, diff, status) and parameters for git, will be composed as `git [params]`."}}},parse:JSON.parse,function:a}};return i.push(o),i}};function x8(r,e){return function(){return r.apply(e,arguments)}}var{toString:Qht}=Object.prototype,{getPrototypeOf:tH}=Object,{iterator:kA,toStringTag:U1e}=Symbol,AA=(r=>e=>{let t=Qht.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),zs=r=>(r=r.toLowerCase(),e=>AA(e)===r),CA=r=>e=>typeof e===r,{isArray:l1}=Array,u1=CA("undefined");function w8(r){return r!==null&&!u1(r)&&r.constructor!==null&&!u1(r.constructor)&&Ya(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}var B1e=zs("ArrayBuffer");function emt(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&B1e(r.buffer),e}var tmt=CA("string"),Ya=CA("function"),H1e=CA("number"),_8=r=>r!==null&&typeof r=="object",rmt=r=>r===!0||r===!1,EA=r=>{if(AA(r)!=="object")return!1;let e=tH(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(U1e in r)&&!(kA in r)},nmt=r=>{if(!_8(r)||w8(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},imt=zs("Date"),amt=zs("File"),omt=zs("Blob"),smt=zs("FileList"),cmt=r=>_8(r)&&Ya(r.pipe),umt=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Ya(r.append)&&((e=AA(r))==="formdata"||e==="object"&&Ya(r.toString)&&r.toString()==="[object FormData]"))},lmt=zs("URLSearchParams"),[fmt,pmt,dmt,hmt]=["ReadableStream","Request","Response","Headers"].map(zs),mmt=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function S8(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,i;if(typeof r!="object"&&(r=[r]),l1(r))for(n=0,i=r.length;n<i;n++)e.call(null,r[n],n,r);else{if(w8(r))return;let a=t?Object.getOwnPropertyNames(r):Object.keys(r),o=a.length,s;for(n=0;n<o;n++)s=a[n],e.call(null,r[s],s,r)}}function W1e(r,e){if(w8(r))return null;e=e.toLowerCase();let t=Object.keys(r),n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}var ld=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,V1e=r=>!u1(r)&&r!==ld;function eH(){let{caseless:r,skipUndefined:e}=V1e(this)&&this||{},t={},n=(i,a)=>{let o=r&&W1e(t,a)||a;EA(t[o])&&EA(i)?t[o]=eH(t[o],i):EA(i)?t[o]=eH({},i):l1(i)?t[o]=i.slice():(!e||!u1(i))&&(t[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&S8(arguments[i],n);return t}var gmt=(r,e,t,{allOwnKeys:n}={})=>(S8(e,(i,a)=>{t&&Ya(i)?r[a]=x8(i,t):r[a]=i},{allOwnKeys:n}),r),vmt=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),ymt=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},bmt=(r,e,t,n)=>{let i,a,o,s={};if(e=e||{},r==null)return e;do{for(i=Object.getOwnPropertyNames(r),a=i.length;a-- >0;)o=i[a],(!n||n(o,r,e))&&!s[o]&&(e[o]=r[o],s[o]=!0);r=t!==!1&&tH(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},xmt=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;let n=r.indexOf(e,t);return n!==-1&&n===t},wmt=r=>{if(!r)return null;if(l1(r))return r;let e=r.length;if(!H1e(e))return null;let t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},_mt=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&tH(Uint8Array)),Smt=(r,e)=>{let n=(r&&r[kA]).call(r),i;for(;(i=n.next())&&!i.done;){let a=i.value;e.call(r,a[0],a[1])}},Emt=(r,e)=>{let t,n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},kmt=zs("HTMLFormElement"),Amt=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),z1e=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),Cmt=zs("RegExp"),G1e=(r,e)=>{let t=Object.getOwnPropertyDescriptors(r),n={};S8(t,(i,a)=>{let o;(o=e(i,a,r))!==!1&&(n[a]=o||i)}),Object.defineProperties(r,n)},Tmt=r=>{G1e(r,(e,t)=>{if(Ya(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;let n=r[t];if(Ya(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Pmt=(r,e)=>{let t={},n=i=>{i.forEach(a=>{t[a]=!0})};return l1(r)?n(r):n(String(r).split(e)),t},Dmt=()=>{},Omt=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function Imt(r){return!!(r&&Ya(r.append)&&r[U1e]==="FormData"&&r[kA])}var $mt=r=>{let e=new Array(10),t=(n,i)=>{if(_8(n)){if(e.indexOf(n)>=0)return;if(w8(n))return n;if(!("toJSON"in n)){e[i]=n;let a=l1(n)?[]:{};return S8(n,(o,s)=>{let c=t(o,i+1);!u1(c)&&(a[s]=c)}),e[i]=void 0,a}}return n};return t(r,0)},jmt=zs("AsyncFunction"),Rmt=r=>r&&(_8(r)||Ya(r))&&Ya(r.then)&&Ya(r.catch),Z1e=((r,e)=>r?setImmediate:e?((t,n)=>(ld.addEventListener("message",({source:i,data:a})=>{i===ld&&a===t&&n.length&&n.shift()()},!1),i=>{n.push(i),ld.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ya(ld.postMessage)),Fmt=typeof queueMicrotask<"u"?queueMicrotask.bind(ld):typeof process<"u"&&process.nextTick||Z1e,Nmt=r=>r!=null&&Ya(r[kA]),ee={isArray:l1,isArrayBuffer:B1e,isBuffer:w8,isFormData:umt,isArrayBufferView:emt,isString:tmt,isNumber:H1e,isBoolean:rmt,isObject:_8,isPlainObject:EA,isEmptyObject:nmt,isReadableStream:fmt,isRequest:pmt,isResponse:dmt,isHeaders:hmt,isUndefined:u1,isDate:imt,isFile:amt,isBlob:omt,isRegExp:Cmt,isFunction:Ya,isStream:cmt,isURLSearchParams:lmt,isTypedArray:_mt,isFileList:smt,forEach:S8,merge:eH,extend:gmt,trim:mmt,stripBOM:vmt,inherits:ymt,toFlatObject:bmt,kindOf:AA,kindOfTest:zs,endsWith:xmt,toArray:wmt,forEachEntry:Smt,matchAll:Emt,isHTMLForm:kmt,hasOwnProperty:z1e,hasOwnProp:z1e,reduceDescriptors:G1e,freezeMethods:Tmt,toObjectSet:Pmt,toCamelCase:Amt,noop:Dmt,toFiniteNumber:Omt,findKey:W1e,global:ld,isContextDefined:V1e,isSpecCompliantForm:Imt,toJSONObject:$mt,isAsyncFn:jmt,isThenable:Rmt,setImmediate:Z1e,asap:Fmt,isIterable:Nmt};function f1(r,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}ee.inherits(f1,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ee.toJSONObject(this.config),code:this.code,status:this.status}}});var J1e=f1.prototype,K1e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{K1e[r]={value:r}});Object.defineProperties(f1,K1e);Object.defineProperty(J1e,"isAxiosError",{value:!0});f1.from=(r,e,t,n,i,a)=>{let o=Object.create(J1e);ee.toFlatObject(r,o,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");let s=r&&r.message?r.message:"Error",c=e==null&&r?r.code:e;return f1.call(o,s,c,t,n,i),r&&o.cause==null&&Object.defineProperty(o,"cause",{value:r,configurable:!0}),o.name=r&&r.name||"Error",a&&Object.assign(o,a),o};var je=f1;var F4e=wr(R4e(),1),OA=F4e.default;function pH(r){return ee.isPlainObject(r)||ee.isArray(r)}function M4e(r){return ee.endsWith(r,"[]")?r.slice(0,-2):r}function N4e(r,e,t){return r?r.concat(e).map(function(i,a){return i=M4e(i),!t&&a?"["+i+"]":i}).join(t?".":""):e}function T1t(r){return ee.isArray(r)&&!r.some(pH)}var P1t=ee.toFlatObject(ee,{},null,function(e){return/^is[A-Z]/.test(e)});function D1t(r,e,t){if(!ee.isObject(r))throw new TypeError("target must be an object");e=e||new(OA||FormData),t=ee.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,g){return!ee.isUndefined(g[h])});let n=t.metaTokens,i=t.visitor||l,a=t.dots,o=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&ee.isSpecCompliantForm(e);if(!ee.isFunction(i))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(ee.isDate(m))return m.toISOString();if(ee.isBoolean(m))return m.toString();if(!c&&ee.isBlob(m))throw new je("Blob is not supported. Use a Buffer instead.");return ee.isArrayBuffer(m)||ee.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function l(m,h,g){let v=m;if(m&&!g&&typeof m=="object"){if(ee.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(ee.isArray(m)&&T1t(m)||(ee.isFileList(m)||ee.endsWith(h,"[]"))&&(v=ee.toArray(m)))return h=M4e(h),v.forEach(function(x,k){!(ee.isUndefined(x)||x===null)&&e.append(o===!0?N4e([h],k,a):o===null?h:h+"[]",u(x))}),!1}return pH(m)?!0:(e.append(N4e(g,h,a),u(m)),!1)}let f=[],d=Object.assign(P1t,{defaultVisitor:l,convertValue:u,isVisitable:pH});function p(m,h){if(!ee.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(m),ee.forEach(m,function(v,y){(!(ee.isUndefined(v)||v===null)&&i.call(e,v,ee.isString(y)?y.trim():y,h,d))===!0&&p(v,h?h.concat(y):[y])}),f.pop()}}if(!ee.isObject(r))throw new TypeError("data must be an object");return p(r),e}var tf=D1t;function L4e(r){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function q4e(r,e){this._pairs=[],r&&tf(r,this,e)}var z4e=q4e.prototype;z4e.append=function(e,t){this._pairs.push([e,t])};z4e.toString=function(e){let t=e?function(n){return e.call(this,n,L4e)}:L4e;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};var U4e=q4e;function O1t(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function fd(r,e,t){if(!e)return r;let n=t&&t.encode||O1t;ee.isFunction(t)&&(t={serialize:t});let i=t&&t.serialize,a;if(i?a=i(e,t):a=ee.isURLSearchParams(e)?e.toString():new U4e(e,t).toString(n),a){let o=r.indexOf("#");o!==-1&&(r=r.slice(0,o)),r+=(r.indexOf("?")===-1?"?":"&")+a}return r}var dH=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ee.forEach(this.handlers,function(n){n!==null&&e(n)})}},hH=dH;var p1={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};import $1t from"crypto";import I1t from"url";var B4e=I1t.URLSearchParams;var mH="abcdefghijklmnopqrstuvwxyz",H4e="0123456789",W4e={DIGIT:H4e,ALPHA:mH,ALPHA_DIGIT:mH+mH.toUpperCase()+H4e},j1t=(r=16,e=W4e.ALPHA_DIGIT)=>{let t="",{length:n}=e,i=new Uint32Array(r);$1t.randomFillSync(i);for(let a=0;a<r;a++)t+=e[i[a]%n];return t},V4e={isNode:!0,classes:{URLSearchParams:B4e,FormData:OA,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:W4e,generateString:j1t,protocols:["http","https","file","data"]};var yH={};xf(yH,{hasBrowserEnv:()=>vH,hasStandardBrowserEnv:()=>R1t,hasStandardBrowserWebWorkerEnv:()=>F1t,navigator:()=>gH,origin:()=>N1t});var vH=typeof window<"u"&&typeof document<"u",gH=typeof navigator=="object"&&navigator||void 0,R1t=vH&&(!gH||["ReactNative","NativeScript","NS"].indexOf(gH.product)<0),F1t=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",N1t=vH&&window.location.href||"http://localhost";var _r={...yH,...V4e};function bH(r,e){return tf(r,new _r.classes.URLSearchParams,{visitor:function(t,n,i,a){return _r.isNode&&ee.isBuffer(t)?(this.append(n,t.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...e})}function M1t(r){return ee.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function L1t(r){let e={},t=Object.keys(r),n,i=t.length,a;for(n=0;n<i;n++)a=t[n],e[a]=r[a];return e}function q1t(r){function e(t,n,i,a){let o=t[a++];if(o==="__proto__")return!0;let s=Number.isFinite(+o),c=a>=t.length;return o=!o&&ee.isArray(i)?i.length:o,c?(ee.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!s):((!i[o]||!ee.isObject(i[o]))&&(i[o]=[]),e(t,n,i[o],a)&&ee.isArray(i[o])&&(i[o]=L1t(i[o])),!s)}if(ee.isFormData(r)&&ee.isFunction(r.entries)){let t={};return ee.forEachEntry(r,(n,i)=>{e(M1t(n),i,t,0)}),t}return null}var IA=q1t;function z1t(r,e,t){if(ee.isString(r))try{return(e||JSON.parse)(r),ee.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}var xH={transitional:p1,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){let n=t.getContentType()||"",i=n.indexOf("application/json")>-1,a=ee.isObject(e);if(a&&ee.isHTMLForm(e)&&(e=new FormData(e)),ee.isFormData(e))return i?JSON.stringify(IA(e)):e;if(ee.isArrayBuffer(e)||ee.isBuffer(e)||ee.isStream(e)||ee.isFile(e)||ee.isBlob(e)||ee.isReadableStream(e))return e;if(ee.isArrayBufferView(e))return e.buffer;if(ee.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return bH(e,this.formSerializer).toString();if((s=ee.isFileList(e))||n.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return tf(s?{"files[]":e}:e,c&&new c,this.formSerializer)}}return a||i?(t.setContentType("application/json",!1),z1t(e)):e}],transformResponse:[function(e){let t=this.transitional||xH.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(ee.isResponse(e)||ee.isReadableStream(e))return e;if(e&&ee.isString(e)&&(n&&!this.responseType||i)){let o=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(s){if(o)throw s.name==="SyntaxError"?je.from(s,je.ERR_BAD_RESPONSE,this,null,this.response):s}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_r.classes.FormData,Blob:_r.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ee.forEach(["delete","get","head","post","put","patch"],r=>{xH.headers[r]={}});var d1=xH;var U1t=ee.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),G4e=r=>{let e={},t,n,i;return r&&r.split(`
|
|
1205
|
+
Use clear, stable session names matching the application role, eg: "backend", "frontend", "agentos", "worker", "db".
|
|
1206
|
+
New sessions always start from the project root directory.`,parameters:{type:"object",properties:{action:{type:"string",enum:["list","status","start","logs","send","stop"],description:"The tmux action to perform."},session:{type:"string",description:"Session name (required for all actions except list)."},command:{type:"string",description:"Command to run (required for start and send actions)."}}},parse:JSON.parse,function:async({action:i,session:a,command:o})=>{try{if(a!==void 0){let s=Yht(a);if(s)return s}switch(i){case"list":try{let{stdout:s}=await ud("tmux",["list-sessions"]);return s.trim()}catch{return"No tmux sessions running"}case"status":{if(!a)return"Error: session name is required for status";try{return await ud("tmux",["has-session","-t",a]),"running"}catch{return"stopped"}}case"start":{if(!a)return"Error: session name is required for start";if(!o)return"Error: command is required for start";try{await ud("tmux",["new-session","-d","-s",a,"-x","220","-y","50","-c",n])}catch{}return await ud("tmux",["send-keys","-t",a,o,"Enter"]),`Session '${a}' started`}case"logs":{if(!a)return"Error: session name is required for logs";try{let{stdout:s}=await ud("tmux",["capture-pane","-t",a,"-p","-S","-200"]);return s.trim()}catch{return`Session '${a}' not found`}}case"send":{if(!a)return"Error: session name is required for send";if(!o)return"Error: command is required for send";try{return await ud("tmux",["send-keys","-t",a,o,"Enter"]),`Command sent to session '${a}'`}catch{return`Session '${a}' not found`}}case"stop":{if(!a)return"Error: session name is required for stop";try{return await ud("tmux",["kill-session","-t",a]),`Session '${a}' killed`}catch{return`Session '${a}' not found`}}default:return`Unknown action: ${i}`}}catch(s){let c=`tmux error: ${s instanceof Error?s.message:String(s)}`;return this.interactor.error(c),c}}}}]}async kill(){}};var Xht=["push","push -f","push --force","push --tags","reset","&&","clean"],q1e=async({params:r,root:e,interactor:t})=>{let n=`git ${r}`,i=Xht.some(a=>r.includes(a));return await ph({command:n,root:e,interactor:t,requireConfirmation:i})};var b8=class extends Kt{constructor(t,n,i,a){super(t,i,a);this.integrationService=n}static TYPE="GIT";async buildTools(t,n){let i=[];if(!this.integrationService.hasIntegration("GIT"))return i;let a=async({params:s})=>await q1e({params:s,root:t.project.root,interactor:this.interactor}),o={type:"function",function:{name:`${this.name}__git`,description:"Run git command and parameters.",parameters:{type:"object",properties:{params:{type:"string",description:"Additional command (like add, log, diff, status) and parameters for git, will be composed as `git [params]`."}}},parse:JSON.parse,function:a}};return i.push(o),i}};function x8(r,e){return function(){return r.apply(e,arguments)}}var{toString:Qht}=Object.prototype,{getPrototypeOf:tH}=Object,{iterator:kA,toStringTag:U1e}=Symbol,AA=(r=>e=>{let t=Qht.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),zs=r=>(r=r.toLowerCase(),e=>AA(e)===r),CA=r=>e=>typeof e===r,{isArray:l1}=Array,u1=CA("undefined");function w8(r){return r!==null&&!u1(r)&&r.constructor!==null&&!u1(r.constructor)&&Ya(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}var B1e=zs("ArrayBuffer");function emt(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&B1e(r.buffer),e}var tmt=CA("string"),Ya=CA("function"),H1e=CA("number"),_8=r=>r!==null&&typeof r=="object",rmt=r=>r===!0||r===!1,EA=r=>{if(AA(r)!=="object")return!1;let e=tH(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(U1e in r)&&!(kA in r)},nmt=r=>{if(!_8(r)||w8(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},imt=zs("Date"),amt=zs("File"),omt=zs("Blob"),smt=zs("FileList"),cmt=r=>_8(r)&&Ya(r.pipe),umt=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Ya(r.append)&&((e=AA(r))==="formdata"||e==="object"&&Ya(r.toString)&&r.toString()==="[object FormData]"))},lmt=zs("URLSearchParams"),[fmt,pmt,dmt,hmt]=["ReadableStream","Request","Response","Headers"].map(zs),mmt=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function S8(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,i;if(typeof r!="object"&&(r=[r]),l1(r))for(n=0,i=r.length;n<i;n++)e.call(null,r[n],n,r);else{if(w8(r))return;let a=t?Object.getOwnPropertyNames(r):Object.keys(r),o=a.length,s;for(n=0;n<o;n++)s=a[n],e.call(null,r[s],s,r)}}function W1e(r,e){if(w8(r))return null;e=e.toLowerCase();let t=Object.keys(r),n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}var ld=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,V1e=r=>!u1(r)&&r!==ld;function eH(){let{caseless:r,skipUndefined:e}=V1e(this)&&this||{},t={},n=(i,a)=>{let o=r&&W1e(t,a)||a;EA(t[o])&&EA(i)?t[o]=eH(t[o],i):EA(i)?t[o]=eH({},i):l1(i)?t[o]=i.slice():(!e||!u1(i))&&(t[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&S8(arguments[i],n);return t}var gmt=(r,e,t,{allOwnKeys:n}={})=>(S8(e,(i,a)=>{t&&Ya(i)?r[a]=x8(i,t):r[a]=i},{allOwnKeys:n}),r),vmt=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),ymt=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},bmt=(r,e,t,n)=>{let i,a,o,s={};if(e=e||{},r==null)return e;do{for(i=Object.getOwnPropertyNames(r),a=i.length;a-- >0;)o=i[a],(!n||n(o,r,e))&&!s[o]&&(e[o]=r[o],s[o]=!0);r=t!==!1&&tH(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},xmt=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;let n=r.indexOf(e,t);return n!==-1&&n===t},wmt=r=>{if(!r)return null;if(l1(r))return r;let e=r.length;if(!H1e(e))return null;let t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},_mt=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&tH(Uint8Array)),Smt=(r,e)=>{let n=(r&&r[kA]).call(r),i;for(;(i=n.next())&&!i.done;){let a=i.value;e.call(r,a[0],a[1])}},Emt=(r,e)=>{let t,n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},kmt=zs("HTMLFormElement"),Amt=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),z1e=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),Cmt=zs("RegExp"),G1e=(r,e)=>{let t=Object.getOwnPropertyDescriptors(r),n={};S8(t,(i,a)=>{let o;(o=e(i,a,r))!==!1&&(n[a]=o||i)}),Object.defineProperties(r,n)},Tmt=r=>{G1e(r,(e,t)=>{if(Ya(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;let n=r[t];if(Ya(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Pmt=(r,e)=>{let t={},n=i=>{i.forEach(a=>{t[a]=!0})};return l1(r)?n(r):n(String(r).split(e)),t},Dmt=()=>{},Omt=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function Imt(r){return!!(r&&Ya(r.append)&&r[U1e]==="FormData"&&r[kA])}var $mt=r=>{let e=new Array(10),t=(n,i)=>{if(_8(n)){if(e.indexOf(n)>=0)return;if(w8(n))return n;if(!("toJSON"in n)){e[i]=n;let a=l1(n)?[]:{};return S8(n,(o,s)=>{let c=t(o,i+1);!u1(c)&&(a[s]=c)}),e[i]=void 0,a}}return n};return t(r,0)},jmt=zs("AsyncFunction"),Rmt=r=>r&&(_8(r)||Ya(r))&&Ya(r.then)&&Ya(r.catch),Z1e=((r,e)=>r?setImmediate:e?((t,n)=>(ld.addEventListener("message",({source:i,data:a})=>{i===ld&&a===t&&n.length&&n.shift()()},!1),i=>{n.push(i),ld.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ya(ld.postMessage)),Fmt=typeof queueMicrotask<"u"?queueMicrotask.bind(ld):typeof process<"u"&&process.nextTick||Z1e,Nmt=r=>r!=null&&Ya(r[kA]),ee={isArray:l1,isArrayBuffer:B1e,isBuffer:w8,isFormData:umt,isArrayBufferView:emt,isString:tmt,isNumber:H1e,isBoolean:rmt,isObject:_8,isPlainObject:EA,isEmptyObject:nmt,isReadableStream:fmt,isRequest:pmt,isResponse:dmt,isHeaders:hmt,isUndefined:u1,isDate:imt,isFile:amt,isBlob:omt,isRegExp:Cmt,isFunction:Ya,isStream:cmt,isURLSearchParams:lmt,isTypedArray:_mt,isFileList:smt,forEach:S8,merge:eH,extend:gmt,trim:mmt,stripBOM:vmt,inherits:ymt,toFlatObject:bmt,kindOf:AA,kindOfTest:zs,endsWith:xmt,toArray:wmt,forEachEntry:Smt,matchAll:Emt,isHTMLForm:kmt,hasOwnProperty:z1e,hasOwnProp:z1e,reduceDescriptors:G1e,freezeMethods:Tmt,toObjectSet:Pmt,toCamelCase:Amt,noop:Dmt,toFiniteNumber:Omt,findKey:W1e,global:ld,isContextDefined:V1e,isSpecCompliantForm:Imt,toJSONObject:$mt,isAsyncFn:jmt,isThenable:Rmt,setImmediate:Z1e,asap:Fmt,isIterable:Nmt};function f1(r,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}ee.inherits(f1,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ee.toJSONObject(this.config),code:this.code,status:this.status}}});var J1e=f1.prototype,K1e={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{K1e[r]={value:r}});Object.defineProperties(f1,K1e);Object.defineProperty(J1e,"isAxiosError",{value:!0});f1.from=(r,e,t,n,i,a)=>{let o=Object.create(J1e);ee.toFlatObject(r,o,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");let s=r&&r.message?r.message:"Error",c=e==null&&r?r.code:e;return f1.call(o,s,c,t,n,i),r&&o.cause==null&&Object.defineProperty(o,"cause",{value:r,configurable:!0}),o.name=r&&r.name||"Error",a&&Object.assign(o,a),o};var je=f1;var F4e=wr(R4e(),1),OA=F4e.default;function pH(r){return ee.isPlainObject(r)||ee.isArray(r)}function M4e(r){return ee.endsWith(r,"[]")?r.slice(0,-2):r}function N4e(r,e,t){return r?r.concat(e).map(function(i,a){return i=M4e(i),!t&&a?"["+i+"]":i}).join(t?".":""):e}function T1t(r){return ee.isArray(r)&&!r.some(pH)}var P1t=ee.toFlatObject(ee,{},null,function(e){return/^is[A-Z]/.test(e)});function D1t(r,e,t){if(!ee.isObject(r))throw new TypeError("target must be an object");e=e||new(OA||FormData),t=ee.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,g){return!ee.isUndefined(g[h])});let n=t.metaTokens,i=t.visitor||l,a=t.dots,o=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&ee.isSpecCompliantForm(e);if(!ee.isFunction(i))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(ee.isDate(m))return m.toISOString();if(ee.isBoolean(m))return m.toString();if(!c&&ee.isBlob(m))throw new je("Blob is not supported. Use a Buffer instead.");return ee.isArrayBuffer(m)||ee.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function l(m,h,g){let v=m;if(m&&!g&&typeof m=="object"){if(ee.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(ee.isArray(m)&&T1t(m)||(ee.isFileList(m)||ee.endsWith(h,"[]"))&&(v=ee.toArray(m)))return h=M4e(h),v.forEach(function(x,k){!(ee.isUndefined(x)||x===null)&&e.append(o===!0?N4e([h],k,a):o===null?h:h+"[]",u(x))}),!1}return pH(m)?!0:(e.append(N4e(g,h,a),u(m)),!1)}let f=[],d=Object.assign(P1t,{defaultVisitor:l,convertValue:u,isVisitable:pH});function p(m,h){if(!ee.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(m),ee.forEach(m,function(v,y){(!(ee.isUndefined(v)||v===null)&&i.call(e,v,ee.isString(y)?y.trim():y,h,d))===!0&&p(v,h?h.concat(y):[y])}),f.pop()}}if(!ee.isObject(r))throw new TypeError("data must be an object");return p(r),e}var tf=D1t;function L4e(r){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function q4e(r,e){this._pairs=[],r&&tf(r,this,e)}var z4e=q4e.prototype;z4e.append=function(e,t){this._pairs.push([e,t])};z4e.toString=function(e){let t=e?function(n){return e.call(this,n,L4e)}:L4e;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};var U4e=q4e;function O1t(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function fd(r,e,t){if(!e)return r;let n=t&&t.encode||O1t;ee.isFunction(t)&&(t={serialize:t});let i=t&&t.serialize,a;if(i?a=i(e,t):a=ee.isURLSearchParams(e)?e.toString():new U4e(e,t).toString(n),a){let o=r.indexOf("#");o!==-1&&(r=r.slice(0,o)),r+=(r.indexOf("?")===-1?"?":"&")+a}return r}var dH=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ee.forEach(this.handlers,function(n){n!==null&&e(n)})}},hH=dH;var p1={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};import $1t from"crypto";import I1t from"url";var B4e=I1t.URLSearchParams;var mH="abcdefghijklmnopqrstuvwxyz",H4e="0123456789",W4e={DIGIT:H4e,ALPHA:mH,ALPHA_DIGIT:mH+mH.toUpperCase()+H4e},j1t=(r=16,e=W4e.ALPHA_DIGIT)=>{let t="",{length:n}=e,i=new Uint32Array(r);$1t.randomFillSync(i);for(let a=0;a<r;a++)t+=e[i[a]%n];return t},V4e={isNode:!0,classes:{URLSearchParams:B4e,FormData:OA,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:W4e,generateString:j1t,protocols:["http","https","file","data"]};var yH={};xf(yH,{hasBrowserEnv:()=>vH,hasStandardBrowserEnv:()=>R1t,hasStandardBrowserWebWorkerEnv:()=>F1t,navigator:()=>gH,origin:()=>N1t});var vH=typeof window<"u"&&typeof document<"u",gH=typeof navigator=="object"&&navigator||void 0,R1t=vH&&(!gH||["ReactNative","NativeScript","NS"].indexOf(gH.product)<0),F1t=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",N1t=vH&&window.location.href||"http://localhost";var _r={...yH,...V4e};function bH(r,e){return tf(r,new _r.classes.URLSearchParams,{visitor:function(t,n,i,a){return _r.isNode&&ee.isBuffer(t)?(this.append(n,t.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...e})}function M1t(r){return ee.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function L1t(r){let e={},t=Object.keys(r),n,i=t.length,a;for(n=0;n<i;n++)a=t[n],e[a]=r[a];return e}function q1t(r){function e(t,n,i,a){let o=t[a++];if(o==="__proto__")return!0;let s=Number.isFinite(+o),c=a>=t.length;return o=!o&&ee.isArray(i)?i.length:o,c?(ee.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!s):((!i[o]||!ee.isObject(i[o]))&&(i[o]=[]),e(t,n,i[o],a)&&ee.isArray(i[o])&&(i[o]=L1t(i[o])),!s)}if(ee.isFormData(r)&&ee.isFunction(r.entries)){let t={};return ee.forEachEntry(r,(n,i)=>{e(M1t(n),i,t,0)}),t}return null}var IA=q1t;function z1t(r,e,t){if(ee.isString(r))try{return(e||JSON.parse)(r),ee.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}var xH={transitional:p1,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){let n=t.getContentType()||"",i=n.indexOf("application/json")>-1,a=ee.isObject(e);if(a&&ee.isHTMLForm(e)&&(e=new FormData(e)),ee.isFormData(e))return i?JSON.stringify(IA(e)):e;if(ee.isArrayBuffer(e)||ee.isBuffer(e)||ee.isStream(e)||ee.isFile(e)||ee.isBlob(e)||ee.isReadableStream(e))return e;if(ee.isArrayBufferView(e))return e.buffer;if(ee.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return bH(e,this.formSerializer).toString();if((s=ee.isFileList(e))||n.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return tf(s?{"files[]":e}:e,c&&new c,this.formSerializer)}}return a||i?(t.setContentType("application/json",!1),z1t(e)):e}],transformResponse:[function(e){let t=this.transitional||xH.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(ee.isResponse(e)||ee.isReadableStream(e))return e;if(e&&ee.isString(e)&&(n&&!this.responseType||i)){let o=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(s){if(o)throw s.name==="SyntaxError"?je.from(s,je.ERR_BAD_RESPONSE,this,null,this.response):s}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_r.classes.FormData,Blob:_r.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ee.forEach(["delete","get","head","post","put","patch"],r=>{xH.headers[r]={}});var d1=xH;var U1t=ee.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),G4e=r=>{let e={},t,n,i;return r&&r.split(`
|
|
1206
1207
|
`).forEach(function(o){i=o.indexOf(":"),t=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!t||e[t]&&U1t[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e};var Z4e=Symbol("internals");function E8(r){return r&&String(r).trim().toLowerCase()}function $A(r){return r===!1||r==null?r:ee.isArray(r)?r.map($A):String(r)}function B1t(r){let e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=t.exec(r);)e[n[1]]=n[2];return e}var H1t=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function wH(r,e,t,n,i){if(ee.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!ee.isString(e)){if(ee.isString(n))return e.indexOf(n)!==-1;if(ee.isRegExp(n))return n.test(e)}}function W1t(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function V1t(r,e){let t=ee.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+t,{value:function(i,a,o){return this[n].call(this,e,i,a,o)},configurable:!0})})}var h1=class{constructor(e){e&&this.set(e)}set(e,t,n){let i=this;function a(s,c,u){let l=E8(c);if(!l)throw new Error("header name must be a non-empty string");let f=ee.findKey(i,l);(!f||i[f]===void 0||u===!0||u===void 0&&i[f]!==!1)&&(i[f||c]=$A(s))}let o=(s,c)=>ee.forEach(s,(u,l)=>a(u,l,c));if(ee.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(ee.isString(e)&&(e=e.trim())&&!H1t(e))o(G4e(e),t);else if(ee.isObject(e)&&ee.isIterable(e)){let s={},c,u;for(let l of e){if(!ee.isArray(l))throw TypeError("Object iterator must return a key-value pair");s[u=l[0]]=(c=s[u])?ee.isArray(c)?[...c,l[1]]:[c,l[1]]:l[1]}o(s,t)}else e!=null&&a(t,e,n);return this}get(e,t){if(e=E8(e),e){let n=ee.findKey(this,e);if(n){let i=this[n];if(!t)return i;if(t===!0)return B1t(i);if(ee.isFunction(t))return t.call(this,i,n);if(ee.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=E8(e),e){let n=ee.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||wH(this,this[n],n,t)))}return!1}delete(e,t){let n=this,i=!1;function a(o){if(o=E8(o),o){let s=ee.findKey(n,o);s&&(!t||wH(n,n[s],s,t))&&(delete n[s],i=!0)}}return ee.isArray(e)?e.forEach(a):a(e),i}clear(e){let t=Object.keys(this),n=t.length,i=!1;for(;n--;){let a=t[n];(!e||wH(this,this[a],a,e,!0))&&(delete this[a],i=!0)}return i}normalize(e){let t=this,n={};return ee.forEach(this,(i,a)=>{let o=ee.findKey(n,a);if(o){t[o]=$A(i),delete t[a];return}let s=e?W1t(a):String(a).trim();s!==a&&delete t[a],t[s]=$A(i),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return ee.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&ee.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
|
|
1207
1208
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){let n=(this[Z4e]=this[Z4e]={accessors:{}}).accessors,i=this.prototype;function a(o){let s=E8(o);n[s]||(V1t(i,o),n[s]=!0)}return ee.isArray(e)?e.forEach(a):a(e),this}};h1.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ee.reduceDescriptors(h1.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}});ee.freezeMethods(h1);var yn=h1;function k8(r,e){let t=this||d1,n=e||t,i=yn.from(n.headers),a=n.data;return ee.forEach(r,function(s){a=s.call(t,a,i.normalize(),e?e.status:void 0)}),i.normalize(),a}function A8(r){return!!(r&&r.__CANCEL__)}function J4e(r,e,t){je.call(this,r??"canceled",je.ERR_CANCELED,e,t),this.name="CanceledError"}ee.inherits(J4e,je,{__CANCEL__:!0});var Co=J4e;function Hc(r,e,t){let n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new je("Request failed with status code "+t.status,[je.ERR_BAD_REQUEST,je.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function _H(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function SH(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function pd(r,e,t){let n=!_H(e);return r&&(n||t==!1)?SH(r,e):e}var m5e=wr(Y4e(),1),g5e=wr(FH(),1);import _4t from"http";import S4t from"https";import E4t from"util";import rf from"zlib";var md="1.12.2";function O8(r){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}var u4t=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function NH(r,e,t){let n=t&&t.Blob||_r.classes.Blob,i=O8(r);if(e===void 0&&n&&(e=!0),i==="data"){r=i.length?r.slice(i.length+1):r;let a=u4t.exec(r);if(!a)throw new je("Invalid URL",je.ERR_INVALID_URL);let o=a[1],s=a[2],c=a[3],u=Buffer.from(decodeURIComponent(c),s?"base64":"utf8");if(e){if(!n)throw new je("Blob is not supported",je.ERR_NOT_SUPPORT);return new n([u],{type:o})}return u}throw new je("Unsupported protocol "+i,je.ERR_NOT_SUPPORT)}import y1 from"stream";import l4t from"stream";var MH=Symbol("internals"),LH=class extends l4t.Transform{constructor(e){e=ee.toFlatObject(e,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!ee.isUndefined(i[n])),super({readableHighWaterMark:e.chunkSize});let t=this[MH]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(t.isCaptured||(t.isCaptured=!0))})}_read(e){let t=this[MH];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,n){let i=this[MH],a=i.maxRate,o=this.readableHighWaterMark,s=i.timeWindow,c=1e3/s,u=a/c,l=i.minChunkSize!==!1?Math.max(i.minChunkSize,u*.01):0,f=(p,m)=>{let h=Buffer.byteLength(p);i.bytesSeen+=h,i.bytes+=h,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(p)?process.nextTick(m):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(m)}},d=(p,m)=>{let h=Buffer.byteLength(p),g=null,v=o,y,x=0;if(a){let k=Date.now();(!i.ts||(x=k-i.ts)>=s)&&(i.ts=k,y=u-i.bytes,i.bytes=y<0?-y:0,x=0),y=u-i.bytes}if(a){if(y<=0)return setTimeout(()=>{m(null,p)},s-x);y<v&&(v=y)}v&&h>v&&h-v>l&&(g=p.subarray(v),p=p.subarray(0,v)),f(p,g?()=>{process.nextTick(m,null,g)}:m)};d(e,function p(m,h){if(m)return n(m);h?d(h,p):n(null)})}},qH=LH;import{EventEmitter as k4t}from"events";import p4t from"util";import{Readable as d4t}from"stream";var{asyncIterator:i5e}=Symbol,f4t=async function*(r){r.stream?yield*r.stream():r.arrayBuffer?yield await r.arrayBuffer():r[i5e]?yield*r[i5e]():yield r},jA=f4t;var h4t=_r.ALPHABET.ALPHA_DIGIT+"-_",I8=typeof TextEncoder=="function"?new TextEncoder:new p4t.TextEncoder,gd=`\r
|
|
1208
1209
|
`,m4t=I8.encode(gd),g4t=2,zH=class{constructor(e,t){let{escapeName:n}=this.constructor,i=ee.isString(t),a=`Content-Disposition: form-data; name="${n(e)}"${!i&&t.name?`; filename="${n(t.name)}"`:""}${gd}`;i?t=I8.encode(String(t).replace(/\r?\n|\r\n?/g,gd)):a+=`Content-Type: ${t.type||"application/octet-stream"}${gd}`,this.headers=I8.encode(a+gd),this.contentLength=i?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+g4t,this.name=e,this.value=t}async*encode(){yield this.headers;let{value:e}=this;ee.isTypedArray(e)?yield e:yield*jA(e),yield m4t}static escapeName(e){return String(e).replace(/[\r\n"]/g,t=>({"\r":"%0D","\n":"%0A",'"':"%22"})[t])}},v4t=(r,e,t)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+_r.generateString(i,h4t)}=t||{};if(!ee.isFormData(r))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=I8.encode("--"+a+gd),s=I8.encode("--"+a+"--"+gd),c=s.byteLength,u=Array.from(r.entries()).map(([f,d])=>{let p=new zH(f,d);return c+=p.size,p});c+=o.byteLength*u.length,c=ee.toFiniteNumber(c);let l={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(c)&&(l["Content-Length"]=c),e&&e(l),d4t.from((async function*(){for(let f of u)yield o,yield*f.encode();yield s})())},a5e=v4t;import y4t from"stream";var UH=class extends y4t.Transform{__transform(e,t,n){this.push(e),n()}_transform(e,t,n){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,t)}this.__transform(e,t,n)}},o5e=UH;var b4t=(r,e)=>ee.isAsyncFn(r)?function(...t){let n=t.pop();r.apply(this,t).then(i=>{try{e?n(null,...e(i)):n(null,i)}catch(a){n(a)}},n)}:r,s5e=b4t;function x4t(r,e){r=r||10;let t=new Array(r),n=new Array(r),i=0,a=0,o;return e=e!==void 0?e:1e3,function(c){let u=Date.now(),l=n[a];o||(o=u),t[i]=c,n[i]=u;let f=a,d=0;for(;f!==i;)d+=t[f++],f=f%r;if(i=(i+1)%r,i===a&&(a=(a+1)%r),u-o<e)return;let p=l&&u-l;return p?Math.round(d*1e3/p):void 0}}var c5e=x4t;function w4t(r,e){let t=0,n=1e3/e,i,a,o=(u,l=Date.now())=>{t=l,i=null,a&&(clearTimeout(a),a=null),r(...u)};return[(...u)=>{let l=Date.now(),f=l-t;f>=n?o(u,l):(i=u,a||(a=setTimeout(()=>{a=null,o(i)},n-f)))},()=>i&&o(i)]}var u5e=w4t;var rl=(r,e,t=3)=>{let n=0,i=c5e(50,250);return u5e(a=>{let o=a.loaded,s=a.lengthComputable?a.total:void 0,c=o-n,u=i(c),l=o<=s;n=o;let f={loaded:o,total:s,progress:s?o/s:void 0,bytes:c,rate:u||void 0,estimated:u&&s&&l?(s-o)/u:void 0,event:a,lengthComputable:s!=null,[e?"download":"upload"]:!0};r(f)},t)},g1=(r,e)=>{let t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},v1=r=>(...e)=>ee.asap(()=>r(...e));function BH(r){if(!r||typeof r!="string"||!r.startsWith("data:"))return 0;let e=r.indexOf(",");if(e<0)return 0;let t=r.slice(5,e),n=r.slice(e+1);if(/;base64/i.test(t)){let a=n.length,o=n.length;for(let d=0;d<o;d++)if(n.charCodeAt(d)===37&&d+2<o){let p=n.charCodeAt(d+1),m=n.charCodeAt(d+2);(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)&&(m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102)&&(a-=2,d+=2)}let s=0,c=o-1,u=d=>d>=2&&n.charCodeAt(d-2)===37&&n.charCodeAt(d-1)===51&&(n.charCodeAt(d)===68||n.charCodeAt(d)===100);c>=0&&(n.charCodeAt(c)===61?(s++,c--):u(c)&&(s++,c-=3)),s===1&&c>=0&&(n.charCodeAt(c)===61||u(c))&&s++;let f=Math.floor(a/4)*3-(s||0);return f>0?f:0}return Buffer.byteLength(n,"utf8")}var l5e={flush:rf.constants.Z_SYNC_FLUSH,finishFlush:rf.constants.Z_SYNC_FLUSH},A4t={flush:rf.constants.BROTLI_OPERATION_FLUSH,finishFlush:rf.constants.BROTLI_OPERATION_FLUSH},f5e=ee.isFunction(rf.createBrotliDecompress),{http:C4t,https:T4t}=g5e.default,P4t=/https:?/,p5e=_r.protocols.map(r=>r+":"),d5e=(r,[e,t])=>(r.on("end",t).on("error",t),e);function D4t(r,e){r.beforeRedirects.proxy&&r.beforeRedirects.proxy(r),r.beforeRedirects.config&&r.beforeRedirects.config(r,e)}function v5e(r,e,t){let n=e;if(!n&&n!==!1){let i=m5e.default.getProxyForUrl(t);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");r.headers["Proxy-Authorization"]="Basic "+a}r.headers.host=r.hostname+(r.port?":"+r.port:"");let i=n.hostname||n.host;r.hostname=i,r.host=i,r.port=n.port,r.path=t,n.protocol&&(r.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}r.beforeRedirects.proxy=function(a){v5e(a,e,a.href)}}var O4t=typeof process<"u"&&ee.kindOf(process)==="process",I4t=r=>new Promise((e,t)=>{let n,i,a=(c,u)=>{i||(i=!0,n&&n(c,u))},o=c=>{a(c),e(c)},s=c=>{a(c,!0),t(c)};r(o,s,c=>n=c).catch(s)}),$4t=({address:r,family:e})=>{if(!ee.isString(r))throw TypeError("address must be a string");return{address:r,family:e||(r.indexOf(".")<0?6:4)}},h5e=(r,e)=>$4t(ee.isObject(r)?r:{address:r,family:e}),y5e=O4t&&function(e){return I4t(async function(n,i,a){let{data:o,lookup:s,family:c}=e,{responseType:u,responseEncoding:l}=e,f=e.method.toUpperCase(),d,p=!1,m;if(s){let N=s5e(s,F=>ee.isArray(F)?F:[F]);s=(F,H,M)=>{N(F,H,(G,V,re)=>{if(G)return M(G);let q=ee.isArray(V)?V.map(te=>h5e(te)):[h5e(V,re)];H.all?M(G,q):M(G,q[0].address,q[0].family)})}}let h=new k4t,g=()=>{e.cancelToken&&e.cancelToken.unsubscribe(v),e.signal&&e.signal.removeEventListener("abort",v),h.removeAllListeners()};a((N,F)=>{d=!0,F&&(p=!0,g())});function v(N){h.emit("abort",!N||N.type?new Co(null,e,m):N)}h.once("abort",i),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(v),e.signal&&(e.signal.aborted?v():e.signal.addEventListener("abort",v)));let y=pd(e.baseURL,e.url,e.allowAbsoluteUrls),x=new URL(y,_r.hasBrowserEnv?_r.origin:void 0),k=x.protocol||p5e[0];if(k==="data:"){if(e.maxContentLength>-1){let F=String(e.url||y||"");if(BH(F)>e.maxContentLength)return i(new je("maxContentLength size of "+e.maxContentLength+" exceeded",je.ERR_BAD_RESPONSE,e))}let N;if(f!=="GET")return Hc(n,i,{status:405,statusText:"method not allowed",headers:{},config:e});try{N=NH(e.url,u==="blob",{Blob:e.env&&e.env.Blob})}catch(F){throw je.from(F,je.ERR_BAD_REQUEST,e)}return u==="text"?(N=N.toString(l),(!l||l==="utf8")&&(N=ee.stripBOM(N))):u==="stream"&&(N=y1.Readable.from(N)),Hc(n,i,{data:N,status:200,statusText:"OK",headers:new yn,config:e})}if(p5e.indexOf(k)===-1)return i(new je("Unsupported protocol "+k,je.ERR_BAD_REQUEST,e));let E=yn.from(e.headers).normalize();E.set("User-Agent","axios/"+md,!1);let{onUploadProgress:A,onDownloadProgress:j}=e,I=e.maxRate,w,_;if(ee.isSpecCompliantForm(o)){let N=E.getContentType(/boundary=([-_\w\d]{10,70})/i);o=a5e(o,F=>{E.set(F)},{tag:`axios-${md}-boundary`,boundary:N&&N[1]||void 0})}else if(ee.isFormData(o)&&ee.isFunction(o.getHeaders)){if(E.set(o.getHeaders()),!E.hasContentLength())try{let N=await E4t.promisify(o.getLength).call(o);Number.isFinite(N)&&N>=0&&E.setContentLength(N)}catch{}}else if(ee.isBlob(o)||ee.isFile(o))o.size&&E.setContentType(o.type||"application/octet-stream"),E.setContentLength(o.size||0),o=y1.Readable.from(jA(o));else if(o&&!ee.isStream(o)){if(!Buffer.isBuffer(o))if(ee.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(ee.isString(o))o=Buffer.from(o,"utf-8");else return i(new je("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",je.ERR_BAD_REQUEST,e));if(E.setContentLength(o.length,!1),e.maxBodyLength>-1&&o.length>e.maxBodyLength)return i(new je("Request body larger than maxBodyLength limit",je.ERR_BAD_REQUEST,e))}let b=ee.toFiniteNumber(E.getContentLength());ee.isArray(I)?(w=I[0],_=I[1]):w=_=I,o&&(A||w)&&(ee.isStream(o)||(o=y1.Readable.from(o,{objectMode:!1})),o=y1.pipeline([o,new qH({maxRate:ee.toFiniteNumber(w)})],ee.noop),A&&o.on("progress",d5e(o,g1(b,rl(v1(A),!1,3)))));let T;if(e.auth){let N=e.auth.username||"",F=e.auth.password||"";T=N+":"+F}if(!T&&x.username){let N=x.username,F=x.password;T=N+":"+F}T&&E.delete("authorization");let D;try{D=fd(x.pathname+x.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(N){let F=new Error(N.message);return F.config=e,F.url=e.url,F.exists=!0,i(F)}E.set("Accept-Encoding","gzip, compress, deflate"+(f5e?", br":""),!1);let C={path:D,method:f,headers:E.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:T,protocol:k,family:c,beforeRedirect:D4t,beforeRedirects:{}};!ee.isUndefined(s)&&(C.lookup=s),e.socketPath?C.socketPath=e.socketPath:(C.hostname=x.hostname.startsWith("[")?x.hostname.slice(1,-1):x.hostname,C.port=x.port,v5e(C,e.proxy,k+"//"+x.hostname+(x.port?":"+x.port:"")+C.path));let P,R=P4t.test(C.protocol);if(C.agent=R?e.httpsAgent:e.httpAgent,e.transport?P=e.transport:e.maxRedirects===0?P=R?S4t:_4t:(e.maxRedirects&&(C.maxRedirects=e.maxRedirects),e.beforeRedirect&&(C.beforeRedirects.config=e.beforeRedirect),P=R?T4t:C4t),e.maxBodyLength>-1?C.maxBodyLength=e.maxBodyLength:C.maxBodyLength=1/0,e.insecureHTTPParser&&(C.insecureHTTPParser=e.insecureHTTPParser),m=P.request(C,function(F){if(m.destroyed)return;let H=[F],M=+F.headers["content-length"];if(j||_){let te=new qH({maxRate:ee.toFiniteNumber(_)});j&&te.on("progress",d5e(te,g1(M,rl(v1(j),!0,3)))),H.push(te)}let G=F,V=F.req||m;if(e.decompress!==!1&&F.headers["content-encoding"])switch((f==="HEAD"||F.statusCode===204)&&delete F.headers["content-encoding"],(F.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":H.push(rf.createUnzip(l5e)),delete F.headers["content-encoding"];break;case"deflate":H.push(new o5e),H.push(rf.createUnzip(l5e)),delete F.headers["content-encoding"];break;case"br":f5e&&(H.push(rf.createBrotliDecompress(A4t)),delete F.headers["content-encoding"])}G=H.length>1?y1.pipeline(H,ee.noop):H[0];let re=y1.finished(G,()=>{re(),g()}),q={status:F.statusCode,statusText:F.statusMessage,headers:new yn(F.headers),config:e,request:V};if(u==="stream")q.data=G,Hc(n,i,q);else{let te=[],X=0;G.on("data",function(Z){te.push(Z),X+=Z.length,e.maxContentLength>-1&&X>e.maxContentLength&&(p=!0,G.destroy(),i(new je("maxContentLength size of "+e.maxContentLength+" exceeded",je.ERR_BAD_RESPONSE,e,V)))}),G.on("aborted",function(){if(p)return;let Z=new je("stream has been aborted",je.ERR_BAD_RESPONSE,e,V);G.destroy(Z),i(Z)}),G.on("error",function(Z){m.destroyed||i(je.from(Z,null,e,V))}),G.on("end",function(){try{let Z=te.length===1?te[0]:Buffer.concat(te);u!=="arraybuffer"&&(Z=Z.toString(l),(!l||l==="utf8")&&(Z=ee.stripBOM(Z))),q.data=Z}catch(Z){return i(je.from(Z,null,e,q.request,q))}Hc(n,i,q)})}h.once("abort",te=>{G.destroyed||(G.emit("error",te),G.destroy())})}),h.once("abort",N=>{i(N),m.destroy(N)}),m.on("error",function(F){i(je.from(F,null,e,m))}),m.on("socket",function(F){F.setKeepAlive(!0,1e3*60)}),e.timeout){let N=parseInt(e.timeout,10);if(Number.isNaN(N)){i(new je("error trying to parse `config.timeout` to int",je.ERR_BAD_OPTION_VALUE,e,m));return}m.setTimeout(N,function(){if(d)return;let H=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",M=e.transitional||p1;e.timeoutErrorMessage&&(H=e.timeoutErrorMessage),i(new je(H,M.clarifyTimeoutError?je.ETIMEDOUT:je.ECONNABORTED,e,m)),v()})}if(ee.isStream(o)){let N=!1,F=!1;o.on("end",()=>{N=!0}),o.once("error",H=>{F=!0,m.destroy(H)}),o.on("close",()=>{!N&&!F&&v(new Co("Request stream has been aborted",e,m))}),o.pipe(m)}else m.end(o)})};var b5e=_r.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,_r.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(_r.origin),_r.navigator&&/(msie|trident)/i.test(_r.navigator.userAgent)):()=>!0;var x5e=_r.hasStandardBrowserEnv?{write(r,e,t,n,i,a){let o=[r+"="+encodeURIComponent(e)];ee.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),ee.isString(n)&&o.push("path="+n),ee.isString(i)&&o.push("domain="+i),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(r){let e=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var w5e=r=>r instanceof yn?{...r}:r;function Bs(r,e){e=e||{};let t={};function n(u,l,f,d){return ee.isPlainObject(u)&&ee.isPlainObject(l)?ee.merge.call({caseless:d},u,l):ee.isPlainObject(l)?ee.merge({},l):ee.isArray(l)?l.slice():l}function i(u,l,f,d){if(ee.isUndefined(l)){if(!ee.isUndefined(u))return n(void 0,u,f,d)}else return n(u,l,f,d)}function a(u,l){if(!ee.isUndefined(l))return n(void 0,l)}function o(u,l){if(ee.isUndefined(l)){if(!ee.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function s(u,l,f){if(f in e)return n(u,l);if(f in r)return n(void 0,u)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(u,l,f)=>i(w5e(u),w5e(l),f,!0)};return ee.forEach(Object.keys({...r,...e}),function(l){let f=c[l]||i,d=f(r[l],e[l],l);ee.isUndefined(d)&&f!==s||(t[l]=d)}),t}var RA=r=>{let e=Bs({},r),{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=e;if(e.headers=o=yn.from(o),e.url=fd(pd(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),s&&o.set("Authorization","Basic "+btoa((s.username||"")+":"+(s.password?unescape(encodeURIComponent(s.password)):""))),ee.isFormData(t)){if(_r.hasStandardBrowserEnv||_r.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(ee.isFunction(t.getHeaders)){let c=t.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([l,f])=>{u.includes(l.toLowerCase())&&o.set(l,f)})}}if(_r.hasStandardBrowserEnv&&(n&&ee.isFunction(n)&&(n=n(e)),n||n!==!1&&b5e(e.url))){let c=i&&a&&x5e.read(a);c&&o.set(i,c)}return e};var j4t=typeof XMLHttpRequest<"u",_5e=j4t&&function(r){return new Promise(function(t,n){let i=RA(r),a=i.data,o=yn.from(i.headers).normalize(),{responseType:s,onUploadProgress:c,onDownloadProgress:u}=i,l,f,d,p,m;function h(){p&&p(),m&&m(),i.cancelToken&&i.cancelToken.unsubscribe(l),i.signal&&i.signal.removeEventListener("abort",l)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function v(){if(!g)return;let x=yn.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),E={data:!s||s==="text"||s==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:x,config:r,request:g};Hc(function(j){t(j),h()},function(j){n(j),h()},E),g=null}"onloadend"in g?g.onloadend=v:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(v)},g.onabort=function(){g&&(n(new je("Request aborted",je.ECONNABORTED,r,g)),g=null)},g.onerror=function(k){let E=k&&k.message?k.message:"Network Error",A=new je(E,je.ERR_NETWORK,r,g);A.event=k||null,n(A),g=null},g.ontimeout=function(){let k=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",E=i.transitional||p1;i.timeoutErrorMessage&&(k=i.timeoutErrorMessage),n(new je(k,E.clarifyTimeoutError?je.ETIMEDOUT:je.ECONNABORTED,r,g)),g=null},a===void 0&&o.setContentType(null),"setRequestHeader"in g&&ee.forEach(o.toJSON(),function(k,E){g.setRequestHeader(E,k)}),ee.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),s&&s!=="json"&&(g.responseType=i.responseType),u&&([d,m]=rl(u,!0),g.addEventListener("progress",d)),c&&g.upload&&([f,p]=rl(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(l=x=>{g&&(n(!x||x.type?new Co(null,r,g):x),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(l),i.signal&&(i.signal.aborted?l():i.signal.addEventListener("abort",l)));let y=O8(i.url);if(y&&_r.protocols.indexOf(y)===-1){n(new je("Unsupported protocol "+y+":",je.ERR_BAD_REQUEST,r));return}g.send(a||null)})};var R4t=(r,e)=>{let{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,i,a=function(u){if(!i){i=!0,s();let l=u instanceof Error?u:this.reason;n.abort(l instanceof je?l:new Co(l instanceof Error?l.message:l))}},o=e&&setTimeout(()=>{o=null,a(new je(`timeout ${e} of ms exceeded`,je.ETIMEDOUT))},e),s=()=>{r&&(o&&clearTimeout(o),o=null,r.forEach(u=>{u.unsubscribe?u.unsubscribe(a):u.removeEventListener("abort",a)}),r=null)};r.forEach(u=>u.addEventListener("abort",a));let{signal:c}=n;return c.unsubscribe=()=>ee.asap(s),c}},S5e=R4t;var F4t=function*(r,e){let t=r.byteLength;if(!e||t<e){yield r;return}let n=0,i;for(;n<t;)i=n+e,yield r.slice(n,i),n=i},N4t=async function*(r,e){for await(let t of M4t(r))yield*F4t(t,e)},M4t=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},HH=(r,e,t,n)=>{let i=N4t(r,e),a=0,o,s=c=>{o||(o=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await i.next();if(u){s(),c.close();return}let f=l.byteLength;if(t){let d=a+=f;t(d)}c.enqueue(new Uint8Array(l))}catch(u){throw s(u),u}},cancel(c){return s(c),i.return()}},{highWaterMark:2})};var E5e=64*1024,{isFunction:FA}=ee,L4t=(({Request:r,Response:e})=>({Request:r,Response:e}))(ee.global),{ReadableStream:k5e,TextEncoder:A5e}=ee.global,C5e=(r,...e)=>{try{return!!r(...e)}catch{return!1}},q4t=r=>{r=ee.merge.call({skipUndefined:!0},L4t,r);let{fetch:e,Request:t,Response:n}=r,i=e?FA(e):typeof fetch=="function",a=FA(t),o=FA(n);if(!i)return!1;let s=i&&FA(k5e),c=i&&(typeof A5e=="function"?(m=>h=>m.encode(h))(new A5e):async m=>new Uint8Array(await new t(m).arrayBuffer())),u=a&&s&&C5e(()=>{let m=!1,h=new t(_r.origin,{body:new k5e,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!h}),l=o&&s&&C5e(()=>ee.isReadableStream(new n("").body)),f={stream:l&&(m=>m.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!f[m]&&(f[m]=(h,g)=>{let v=h&&h[m];if(v)return v.call(h);throw new je(`Response type '${m}' is not supported`,je.ERR_NOT_SUPPORT,g)})});let d=async m=>{if(m==null)return 0;if(ee.isBlob(m))return m.size;if(ee.isSpecCompliantForm(m))return(await new t(_r.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(ee.isArrayBufferView(m)||ee.isArrayBuffer(m))return m.byteLength;if(ee.isURLSearchParams(m)&&(m=m+""),ee.isString(m))return(await c(m)).byteLength},p=async(m,h)=>{let g=ee.toFiniteNumber(m.getContentLength());return g??d(h)};return async m=>{let{url:h,method:g,data:v,signal:y,cancelToken:x,timeout:k,onDownloadProgress:E,onUploadProgress:A,responseType:j,headers:I,withCredentials:w="same-origin",fetchOptions:_}=RA(m),b=e||fetch;j=j?(j+"").toLowerCase():"text";let T=S5e([y,x&&x.toAbortSignal()],k),D=null,C=T&&T.unsubscribe&&(()=>{T.unsubscribe()}),P;try{if(A&&u&&g!=="get"&&g!=="head"&&(P=await p(I,v))!==0){let G=new t(h,{method:"POST",body:v,duplex:"half"}),V;if(ee.isFormData(v)&&(V=G.headers.get("content-type"))&&I.setContentType(V),G.body){let[re,q]=g1(P,rl(v1(A)));v=HH(G.body,E5e,re,q)}}ee.isString(w)||(w=w?"include":"omit");let R=a&&"credentials"in t.prototype,N={..._,signal:T,method:g.toUpperCase(),headers:I.normalize().toJSON(),body:v,duplex:"half",credentials:R?w:void 0};D=a&&new t(h,N);let F=await(a?b(D,_):b(h,N)),H=l&&(j==="stream"||j==="response");if(l&&(E||H&&C)){let G={};["status","statusText","headers"].forEach(te=>{G[te]=F[te]});let V=ee.toFiniteNumber(F.headers.get("content-length")),[re,q]=E&&g1(V,rl(v1(E),!0))||[];F=new n(HH(F.body,E5e,re,()=>{q&&q(),C&&C()}),G)}j=j||"text";let M=await f[ee.findKey(f,j)||"text"](F,m);return!H&&C&&C(),await new Promise((G,V)=>{Hc(G,V,{data:M,headers:yn.from(F.headers),status:F.status,statusText:F.statusText,config:m,request:D})})}catch(R){throw C&&C(),R&&R.name==="TypeError"&&/Load failed|fetch/i.test(R.message)?Object.assign(new je("Network Error",je.ERR_NETWORK,m,D),{cause:R.cause||R}):je.from(R,R&&R.code,m,D)}}},z4t=new Map,WH=r=>{let e=r?r.env:{},{fetch:t,Request:n,Response:i}=e,a=[n,i,t],o=a.length,s=o,c,u,l=z4t;for(;s--;)c=a[s],u=l.get(c),u===void 0&&l.set(c,u=s?new Map:q4t(e)),l=u;return u},O2r=WH();var VH={http:y5e,xhr:_5e,fetch:{get:WH}};ee.forEach(VH,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});var T5e=r=>`- ${r}`,B4t=r=>ee.isFunction(r)||r===null||r===!1,NA={getAdapter:(r,e)=>{r=ee.isArray(r)?r:[r];let{length:t}=r,n,i,a={};for(let o=0;o<t;o++){n=r[o];let s;if(i=n,!B4t(n)&&(i=VH[(s=String(n)).toLowerCase()],i===void 0))throw new je(`Unknown adapter '${s}'`);if(i&&(ee.isFunction(i)||(i=i.get(e))))break;a[s||"#"+o]=i}if(!i){let o=Object.entries(a).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),s=t?o.length>1?`since :
|