@nexoracoding/cli 0.1.2 → 0.1.3
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/dist/index.js +8 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4040,7 +4040,7 @@ schema: v1
|
|
|
4040
4040
|
version: 0.0.1`,new iqe({accessToken:t??void 0,apiBase:Ai.apiBase,rootPath:void 0}),{currentUserSlug:"",onPremProxyUrl:null,orgScopeId:r,platformClient:new oqe(r,n),renderSecrets:!0,injectBlocks:e});if(o.errors){let i=o.errors?.find(s=>s.fatal);if(i)throw new Error(`Failed to load config: ${i.message}`)}if(!o?.config)throw new Error("Failed to load config");return o.config}async function lVs(e,t,r,n,o){let i=await jHs(e,new iqe({accessToken:t??void 0,apiBase:Ai.apiBase,rootPath:e.uriType==="file"?C5p(e.fileUri):void 0}),{currentUserSlug:"",alwaysUseProxy:!1,orgScopeId:r,renderSecrets:!0,platformClient:new oqe(r,n),onPremProxyUrl:null,injectBlocks:o}),s=i.errors;if(i.config){if(s?.length){let a=s?.length>1?s.map(u=>`
|
|
4041
4041
|
- ${u.message}`):s[0].message;console.warn(mt.dim(`Warning: ${a}`))}}else throw new Error(`Failed to load config:
|
|
4042
4042
|
${s}`);return i.config}async function M6r(e,t,r,n,o){return await lVs({fileUri:e,uriType:"file"},t,r,n,o)}async function cVs(e,t,r,n,o){let[i,s]=e.split("/");if(!i||!s)throw new Error(`Invalid assistant slug format. Expected "owner/package", got: ${e}`);if(!n.configuration.accessToken)return await lVs({uriType:"slug",fullSlug:{ownerSlug:i,packageSlug:s,versionSlug:"latest"}},t??null,r,n,o);let u=(await n.getAssistant({ownerSlug:i,packageSlug:s,alwaysUseProxy:"false",organizationId:r??void 0})).configResult,l=u.errors;if(l?.some(d=>d.fatal))throw new Error(l.map(d=>d.message).join(`
|
|
4043
|
-
`)??"Failed to load assistant.");let c=u.config;if(o.length>0){let d=await ZRe(o,t,r,n);c=XRe(c,d)}return c}function dVs(e){return e.startsWith(".")||e.startsWith("/")||e.startsWith("~")||/^[A-Za-z]:[/\\]/.test(e)||e.startsWith("\\\\")||e.includes(".yaml")||e.includes(".yml")||e.includes(".json")}function M5p(e){switch(e.type){case"cli-flag":return dVs(e.path)?`file://${e.path}`:`slug://${e.path}`;case"saved-uri":return e.uri;case"local-config-yaml":return`file://${uLt.join(Ai.continueHome,"config.yaml")}`;default:return null}}var D6r=x(()=>{"use strict";bG();Lp();VPt();Of();sVs();Up();uVs();ri()});function cLt(e){return!e||typeof e!="string"?!1:e.startsWith("nxr_")&&e.length>20}function pVs(e){return!e||typeof e!="string"?"A Nexora key is required":e.startsWith("nxr_")?"Invalid Nexora key (too short)":'
|
|
4043
|
+
`)??"Failed to load assistant.");let c=u.config;if(o.length>0){let d=await ZRe(o,t,r,n);c=XRe(c,d)}return c}function dVs(e){return e.startsWith(".")||e.startsWith("/")||e.startsWith("~")||/^[A-Za-z]:[/\\]/.test(e)||e.startsWith("\\\\")||e.includes(".yaml")||e.includes(".yml")||e.includes(".json")}function M5p(e){switch(e.type){case"cli-flag":return dVs(e.path)?`file://${e.path}`:`slug://${e.path}`;case"saved-uri":return e.uri;case"local-config-yaml":return`file://${uLt.join(Ai.continueHome,"config.yaml")}`;default:return null}}var D6r=x(()=>{"use strict";bG();Lp();VPt();Of();sVs();Up();uVs();ri()});function cLt(e){return!e||typeof e!="string"?!1:e.startsWith("nxr_")&&e.length>20}function pVs(e){return!e||typeof e!="string"?"A Nexora key is required":e.startsWith("nxr_")?"Invalid Nexora key (too short)":'A Nexora key must start with "nxr_"'}var L6r=x(()=>{"use strict"});import*as fVs from"readline";function dLt(e){return new Promise(t=>{let r=fVs.createInterface({input:process.stdin,output:process.stdout,terminal:!0});r.on("SIGINT",()=>{console.log(`
|
|
4044
4044
|
`),r.close(),process.exit(0)}),r.question(e,n=>{r.close(),t(n)})})}var k6r=x(()=>{"use strict"});var vl=E(O0=>{"use strict";var U6r=Symbol.for("yaml.alias"),mVs=Symbol.for("yaml.document"),pLt=Symbol.for("yaml.map"),hVs=Symbol.for("yaml.pair"),B6r=Symbol.for("yaml.scalar"),fLt=Symbol.for("yaml.seq"),uj=Symbol.for("yaml.node.type"),D5p=e=>!!e&&typeof e=="object"&&e[uj]===U6r,L5p=e=>!!e&&typeof e=="object"&&e[uj]===mVs,k5p=e=>!!e&&typeof e=="object"&&e[uj]===pLt,U5p=e=>!!e&&typeof e=="object"&&e[uj]===hVs,gVs=e=>!!e&&typeof e=="object"&&e[uj]===B6r,B5p=e=>!!e&&typeof e=="object"&&e[uj]===fLt;function _Vs(e){if(e&&typeof e=="object")switch(e[uj]){case pLt:case fLt:return!0}return!1}function F5p(e){if(e&&typeof e=="object")switch(e[uj]){case U6r:case pLt:case B6r:case fLt:return!0}return!1}var H5p=e=>(gVs(e)||_Vs(e))&&!!e.anchor;O0.ALIAS=U6r;O0.DOC=mVs;O0.MAP=pLt;O0.NODE_TYPE=uj;O0.PAIR=hVs;O0.SCALAR=B6r;O0.SEQ=fLt;O0.hasAnchor=H5p;O0.isAlias=D5p;O0.isCollection=_Vs;O0.isDocument=L5p;O0.isMap=k5p;O0.isNode=F5p;O0.isPair=U5p;O0.isScalar=gVs;O0.isSeq=B5p});var sqe=E(F6r=>{"use strict";var kT=vl(),CN=Symbol("break visit"),EVs=Symbol("skip children"),CG=Symbol("remove node");function mLt(e,t){let r=AVs(t);kT.isDocument(e)?eIe(null,e.contents,r,Object.freeze([e]))===CG&&(e.contents=null):eIe(null,e,r,Object.freeze([]))}mLt.BREAK=CN;mLt.SKIP=EVs;mLt.REMOVE=CG;function eIe(e,t,r,n){let o=TVs(e,t,r,n);if(kT.isNode(o)||kT.isPair(o))return SVs(e,n,o),eIe(e,o,r,n);if(typeof o!="symbol"){if(kT.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let s=eIe(i,t.items[i],r,n);if(typeof s=="number")i=s-1;else{if(s===CN)return CN;s===CG&&(t.items.splice(i,1),i-=1)}}}else if(kT.isPair(t)){n=Object.freeze(n.concat(t));let i=eIe("key",t.key,r,n);if(i===CN)return CN;i===CG&&(t.key=null);let s=eIe("value",t.value,r,n);if(s===CN)return CN;s===CG&&(t.value=null)}}return o}async function hLt(e,t){let r=AVs(t);kT.isDocument(e)?await tIe(null,e.contents,r,Object.freeze([e]))===CG&&(e.contents=null):await tIe(null,e,r,Object.freeze([]))}hLt.BREAK=CN;hLt.SKIP=EVs;hLt.REMOVE=CG;async function tIe(e,t,r,n){let o=await TVs(e,t,r,n);if(kT.isNode(o)||kT.isPair(o))return SVs(e,n,o),tIe(e,o,r,n);if(typeof o!="symbol"){if(kT.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let s=await tIe(i,t.items[i],r,n);if(typeof s=="number")i=s-1;else{if(s===CN)return CN;s===CG&&(t.items.splice(i,1),i-=1)}}}else if(kT.isPair(t)){n=Object.freeze(n.concat(t));let i=await tIe("key",t.key,r,n);if(i===CN)return CN;i===CG&&(t.key=null);let s=await tIe("value",t.value,r,n);if(s===CN)return CN;s===CG&&(t.value=null)}}return o}function AVs(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function TVs(e,t,r,n){if(typeof r=="function")return r(e,t,n);if(kT.isMap(t))return r.Map?.(e,t,n);if(kT.isSeq(t))return r.Seq?.(e,t,n);if(kT.isPair(t))return r.Pair?.(e,t,n);if(kT.isScalar(t))return r.Scalar?.(e,t,n);if(kT.isAlias(t))return r.Alias?.(e,t,n)}function SVs(e,t,r){let n=t[t.length-1];if(kT.isCollection(n))n.items[e]=r;else if(kT.isPair(n))e==="key"?n.key=r:n.value=r;else if(kT.isDocument(n))n.contents=r;else{let o=kT.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${o} parent`)}}F6r.visit=mLt;F6r.visitAsync=hLt});var H6r=E(vVs=>{"use strict";var yVs=vl(),V5p=sqe(),G5p={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},q5p=e=>e.replace(/[!,[\]{}]/g,t=>G5p[t]),aqe=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let n=t.trim().split(/[ \t]+/),o=n.shift();switch(o){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[i,s]=n;return this.tags[i]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let s=/^\d+\.\d+$/.test(i);return r(6,`Unsupported YAML version ${i}`,s),!1}}default:return r(0,`Unknown directive ${o}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let s=t.slice(2,-1);return s==="!"||s==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),s)}let[,n,o]=t.match(/^(.*!)([^!]*)$/s);o||r(`The ${t} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(o)}catch(s){return r(String(s)),null}return n==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,n]of Object.entries(this.tags))if(t.startsWith(n))return r+q5p(t.substring(n.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),o;if(t&&n.length>0&&yVs.isNode(t.contents)){let i={};V5p.visit(t.contents,(s,a)=>{yVs.isNode(a)&&a.tag&&(i[a.tag]=!0)}),o=Object.keys(i)}else o=[];for(let[i,s]of n)i==="!!"&&s==="tag:yaml.org,2002:"||(!t||o.some(a=>a.startsWith(s)))&&r.push(`%TAG ${i} ${s}`);return r.join(`
|
|
4045
4045
|
`)}};aqe.defaultYaml={explicit:!1,version:"1.2"};aqe.defaultTags={"!!":"tag:yaml.org,2002:"};vVs.Directives=aqe});var gLt=E(uqe=>{"use strict";var bVs=vl(),z5p=sqe();function j5p(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function CVs(e){let t=new Set;return z5p.visit(e,{Value(r,n){n.anchor&&t.add(n.anchor)}}),t}function RVs(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}function $5p(e,t){let r=[],n=new Map,o=null;return{onAnchor:i=>{r.push(i),o??(o=CVs(e));let s=RVs(t,o);return o.add(s),s},setAnchors:()=>{for(let i of r){let s=n.get(i);if(typeof s=="object"&&s.anchor&&(bVs.isScalar(s.node)||bVs.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:n}}uqe.anchorIsValid=j5p;uqe.anchorNames=CVs;uqe.createNodeAnchors=$5p;uqe.findNewAnchor=RVs});var V6r=E(IVs=>{"use strict";function lqe(e,t,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let o=0,i=n.length;o<i;++o){let s=n[o],a=lqe(e,n,String(o),s);a===void 0?delete n[o]:a!==s&&(n[o]=a)}else if(n instanceof Map)for(let o of Array.from(n.keys())){let i=n.get(o),s=lqe(e,n,o,i);s===void 0?n.delete(o):s!==i&&n.set(o,s)}else if(n instanceof Set)for(let o of Array.from(n)){let i=lqe(e,n,o,o);i===void 0?n.delete(o):i!==o&&(n.delete(o),n.add(i))}else for(let[o,i]of Object.entries(n)){let s=lqe(e,n,o,i);s===void 0?delete n[o]:s!==i&&(n[o]=s)}return e.call(t,r,n)}IVs.applyReviver=lqe});var YZ=E(xVs=>{"use strict";var W5p=vl();function wVs(e,t,r){if(Array.isArray(e))return e.map((n,o)=>wVs(n,String(o),r));if(e&&typeof e.toJSON=="function"){if(!r||!W5p.hasAnchor(e))return e.toJSON(t,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(e,n),r.onCreate=i=>{n.res=i,delete r.onCreate};let o=e.toJSON(t,r);return r.onCreate&&r.onCreate(o),o}return typeof e=="bigint"&&!r?.keep?Number(e):e}xVs.toJS=wVs});var _Lt=E(PVs=>{"use strict";var Y5p=V6r(),NVs=vl(),K5p=YZ(),G6r=class{constructor(t){Object.defineProperty(this,NVs.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:n,onAnchor:o,reviver:i}={}){if(!NVs.isDocument(t))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=K5p.toJS(this,"",s);if(typeof o=="function")for(let{count:u,res:l}of s.anchors.values())o(l,u);return typeof i=="function"?Y5p.applyReviver(i,{"":a},"",a):a}};PVs.NodeBase=G6r});var cqe=E(OVs=>{"use strict";var Q5p=gLt(),J5p=sqe(),rIe=vl(),X5p=_Lt(),Z5p=YZ(),q6r=class extends X5p.NodeBase{constructor(t){super(rIe.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],J5p.visit(t,{Node:(i,s)=>{(rIe.isAlias(s)||rIe.hasAnchor(s))&&n.push(s)}}),r&&(r.aliasResolveCache=n));let o;for(let i of n){if(i===this)break;i.anchor===this.source&&(o=i)}return o}toJSON(t,r){if(!r)return{source:this.source};let{anchors:n,doc:o,maxAliasCount:i}=r,s=this.resolve(o,r);if(!s){let u=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(u)}let a=n.get(s);if(a||(Z5p.toJS(s,null,r),a=n.get(s)),!a||a.res===void 0){let u="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(u)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=ELt(o,s,n)),a.count*a.aliasCount>i)){let u="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(u)}return a.res}toString(t,r,n){let o=`*${this.source}`;if(t){if(Q5p.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(t.implicitKey)return`${o} `}return o}};function ELt(e,t,r){if(rIe.isAlias(t)){let n=t.resolve(e),o=r&&n&&r.get(n);return o?o.count*o.aliasCount:0}else if(rIe.isCollection(t)){let n=0;for(let o of t.items){let i=ELt(e,o,r);i>n&&(n=i)}return n}else if(rIe.isPair(t)){let n=ELt(e,t.key,r),o=ELt(e,t.value,r);return Math.max(n,o)}return 1}OVs.Alias=q6r});var TA=E(z6r=>{"use strict";var e9p=vl(),t9p=_Lt(),r9p=YZ(),n9p=e=>!e||typeof e!="function"&&typeof e!="object",KZ=class extends t9p.NodeBase{constructor(t){super(e9p.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:r9p.toJS(this.value,t,r)}toString(){return String(this.value)}};KZ.BLOCK_FOLDED="BLOCK_FOLDED";KZ.BLOCK_LITERAL="BLOCK_LITERAL";KZ.PLAIN="PLAIN";KZ.QUOTE_DOUBLE="QUOTE_DOUBLE";KZ.QUOTE_SINGLE="QUOTE_SINGLE";z6r.Scalar=KZ;z6r.isScalarValue=n9p});var dqe=E(DVs=>{"use strict";var i9p=cqe(),Bpe=vl(),MVs=TA(),o9p="tag:yaml.org,2002:";function s9p(e,t,r){if(t){let n=r.filter(i=>i.tag===t),o=n.find(i=>!i.format)??n[0];if(!o)throw new Error(`Tag ${t} not found`);return o}return r.find(n=>n.identify?.(e)&&!n.format)}function a9p(e,t,r){if(Bpe.isDocument(e)&&(e=e.contents),Bpe.isNode(e))return e;if(Bpe.isPair(e)){let d=r.schema[Bpe.MAP].createNode?.(r.schema,null,r);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:n,onAnchor:o,onTagObj:i,schema:s,sourceObjects:a}=r,u;if(n&&e&&typeof e=="object"){if(u=a.get(e),u)return u.anchor??(u.anchor=o(e)),new i9p.Alias(u.anchor);u={anchor:null,node:null},a.set(e,u)}t?.startsWith("!!")&&(t=o9p+t.slice(2));let l=s9p(e,t,s.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new MVs.Scalar(e);return u&&(u.node=d),d}l=e instanceof Map?s[Bpe.MAP]:Symbol.iterator in Object(e)?s[Bpe.SEQ]:s[Bpe.MAP]}i&&(i(l),delete r.onTagObj);let c=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,e,r):new MVs.Scalar(e);return t?c.tag=t:l.default||(c.tag=l.tag),u&&(u.node=c),c}DVs.createNode=a9p});var TLt=E(ALt=>{"use strict";var u9p=dqe(),RG=vl(),l9p=_Lt();function j6r(e,t,r){let n=r;for(let o=t.length-1;o>=0;--o){let i=t[o];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let s=[];s[i]=n,n=s}else n=new Map([[i,n]])}return u9p.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var LVs=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,$6r=class extends l9p.NodeBase{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(n=>RG.isNode(n)||RG.isPair(n)?n.clone(t):n),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(LVs(t))this.add(r);else{let[n,...o]=t,i=this.get(n,!0);if(RG.isCollection(i))i.addIn(o,r);else if(i===void 0&&this.schema)this.set(n,j6r(this.schema,o,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${o}`)}}deleteIn(t){let[r,...n]=t;if(n.length===0)return this.delete(r);let o=this.get(r,!0);if(RG.isCollection(o))return o.deleteIn(n);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(t,r){let[n,...o]=t,i=this.get(n,!0);return o.length===0?!r&&RG.isScalar(i)?i.value:i:RG.isCollection(i)?i.getIn(o,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!RG.isPair(r))return!1;let n=r.value;return n==null||t&&RG.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(t){let[r,...n]=t;if(n.length===0)return this.has(r);let o=this.get(r,!0);return RG.isCollection(o)?o.hasIn(n):!1}setIn(t,r){let[n,...o]=t;if(o.length===0)this.set(n,r);else{let i=this.get(n,!0);if(RG.isCollection(i))i.setIn(o,r);else if(i===void 0&&this.schema)this.set(n,j6r(this.schema,o,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${o}`)}}};ALt.Collection=$6r;ALt.collectionFromPath=j6r;ALt.isEmptyPath=LVs});var pqe=E(SLt=>{"use strict";var c9p=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function W6r(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var d9p=(e,t,r)=>e.endsWith(`
|
|
4046
4046
|
`)?W6r(r,t):r.includes(`
|
|
@@ -4262,9 +4262,9 @@ Waiting for confirmation\u2026`)),ise(l.toString()).catch(()=>{})})})}async func
|
|
|
4262
4262
|
<context name="planMode">You are operating in _Plan Mode_, which means that your goal is to help the user investigate their ideas and develop a plan before taking action. You only have access to read-only tools and should not attempt to circumvent them to write / delete / create files. Ask the user to switch to agent mode if they want to make changes. For example, it is not acceptable to use the Bash tool to write to files.</context>
|
|
4263
4263
|
`:process.env.CONTINUE_CLI_DISABLE_COMMIT_SIGNATURE||(d+=`
|
|
4264
4264
|
<context name="commitSignature">When creating commits using any CLI or tool, include the following in the commit message:
|
|
4265
|
-
Generated with [Nexora](https://
|
|
4265
|
+
Generated with [Nexora](https://nexoracoding.com)
|
|
4266
4266
|
|
|
4267
|
-
Co-Authored-By: Nexora <noreply@
|
|
4267
|
+
Co-Authored-By: Nexora <noreply@nexoracoding.com>
|
|
4268
4268
|
</context>
|
|
4269
4269
|
`),n&&(d+=`
|
|
4270
4270
|
|
|
@@ -4355,9 +4355,8 @@ ${VQp()}
|
|
|
4355
4355
|
`}var FBt,ena=x(()=>{vee();FBt=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
4356
4356
|
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),ymf(r)}clear(){this._buffer=void 0}}});import VBt from"node:process";import{PassThrough as vmf}from"node:stream";function Cmf(){let e={};for(let t of bmf){let r=VBt.env[t];r!==void 0&&(r.startsWith("()")||(e[t]=r))}return e}function Rmf(){return"type"in VBt}var tna,bmf,HBt,rna=x(()=>{tna=ee(T7r(),1);ena();bmf=VBt.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];HBt=class{constructor(t){this._readBuffer=new FBt,this._stderrStream=null,this._serverParams=t,(t.stderr==="pipe"||t.stderr==="overlapped")&&(this._stderrStream=new vmf)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((t,r)=>{var n,o,i,s,a;this._process=(0,tna.default)(this._serverParams.command,(n=this._serverParams.args)!==null&&n!==void 0?n:[],{env:{...Cmf(),...this._serverParams.env},stdio:["pipe","pipe",(o=this._serverParams.stderr)!==null&&o!==void 0?o:"inherit"],shell:!1,windowsHide:VBt.platform==="win32"&&Rmf(),cwd:this._serverParams.cwd}),this._process.on("error",u=>{var l;r(u),(l=this.onerror)===null||l===void 0||l.call(this,u)}),this._process.on("spawn",()=>{t()}),this._process.on("close",u=>{var l;this._process=void 0,(l=this.onclose)===null||l===void 0||l.call(this)}),(i=this._process.stdin)===null||i===void 0||i.on("error",u=>{var l;(l=this.onerror)===null||l===void 0||l.call(this,u)}),(s=this._process.stdout)===null||s===void 0||s.on("data",u=>{this._readBuffer.append(u),this.processReadBuffer()}),(a=this._process.stdout)===null||a===void 0||a.on("error",u=>{var l;(l=this.onerror)===null||l===void 0||l.call(this,u)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){var t,r;return this._stderrStream?this._stderrStream:(r=(t=this._process)===null||t===void 0?void 0:t.stderr)!==null&&r!==void 0?r:null}get pid(){var t,r;return(r=(t=this._process)===null||t===void 0?void 0:t.pid)!==null&&r!==void 0?r:null}processReadBuffer(){for(var t,r;;)try{let n=this._readBuffer.readMessage();if(n===null)break;(t=this.onmessage)===null||t===void 0||t.call(this,n)}catch(n){(r=this.onerror)===null||r===void 0||r.call(this,n)}}async close(){var t;if(this._process){let r=this._process;this._process=void 0;let n=new Promise(o=>{r.once("close",()=>{o()})});try{(t=r.stdin)===null||t===void 0||t.end()}catch{}if(await Promise.race([n,new Promise(o=>setTimeout(o,2e3).unref())]),r.exitCode===null){try{r.kill("SIGTERM")}catch{}await Promise.race([n,new Promise(o=>setTimeout(o,2e3).unref())])}if(r.exitCode===null)try{r.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(t){return new Promise(r=>{var n;if(!(!((n=this._process)===null||n===void 0)&&n.stdin))throw new Error("Not connected");let o=Zra(t);this._process.stdin.write(o)?r():this._process.stdin.once("drain",r)})}}});var GBt,nna=x(()=>{qjr();GBt=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n}={}){let o;super({start(i){o=OBt({onEvent:s=>{i.enqueue(s)},onError(s){t==="terminate"?i.error(s):typeof t=="function"&&t(s)},onRetry:r,onComment:n})},transform(i){o.feed(i)}})}}});var Imf,M3,qBt,S7r=x(()=>{Zjr();vee();l7r();nna();Imf={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},M3=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},qBt=class{constructor(t,r){var n;this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=kBt(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=(n=r?.reconnectionOptions)!==null&&n!==void 0?n:Imf}async _authThenStart(){var t;if(!this._authProvider)throw new lw("No auth provider");let r;try{r=await Fj(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(t=this.onerror)===null||t===void 0||t.call(this,n),n}if(r!=="AUTHORIZED")throw new lw;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;let r={};if(this._authProvider){let o=await this._authProvider.tokens();o&&(r.Authorization=`Bearer ${o.access_token}`)}this._sessionId&&(r["mcp-session-id"]=this._sessionId),this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion);let n=Gwe((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...r,...n})}async _startOrAuthSse(t){var r,n,o,i;let{resumptionToken:s}=t;try{let a=await this._commonHeaders();a.set("Accept","text/event-stream"),s&&a.set("last-event-id",s);let u=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,{method:"GET",headers:a,signal:(n=this._abortController)===null||n===void 0?void 0:n.signal});if(!u.ok){if(await((o=u.body)===null||o===void 0?void 0:o.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new M3(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(a){throw(i=this.onerror)===null||i===void 0||i.call(this,a),a}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),o)}_scheduleReconnection(t,r=0){var n;let o=this._reconnectionOptions.maxRetries;if(r>=o){(n=this.onerror)===null||n===void 0||n.call(this,new Error(`Maximum reconnection attempts (${o}) exceeded.`));return}let i=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{var a;(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,r+1)})},i)}_handleSseStream(t,r,n){if(!t)return;let{onresumptiontoken:o,replayMessageId:i}=r,s,a=!1,u=!1;(async()=>{var c,d,p,f;try{let m=t.pipeThrough(new TextDecoderStream).pipeThrough(new GBt({onRetry:b=>{this._serverRetryMs=b}})).getReader();for(;;){let{value:b,done:I}=await m.read();if(I)break;if(b.id&&(s=b.id,a=!0,o?.(b.id)),!!b.data&&(!b.event||b.event==="message"))try{let w=yee.parse(JSON.parse(b.data));Rfe(w)&&(u=!0,i!==void 0&&(w.id=i)),(c=this.onmessage)===null||c===void 0||c.call(this,w)}catch(w){(d=this.onerror)===null||d===void 0||d.call(this,w)}}(n||a)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:o,replayMessageId:i},0)}catch(m){if((p=this.onerror)===null||p===void 0||p.call(this,new Error(`SSE stream disconnected: ${m}`)),(n||a)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:o,replayMessageId:i},0)}catch(b){(f=this.onerror)===null||f===void 0||f.call(this,new Error(`Failed to reconnect: ${b instanceof Error?b.message:String(b)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new lw("No auth provider");if(await Fj(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new lw("Failed to authorize")}async close(){var t,r;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)===null||t===void 0||t.abort(),(r=this.onclose)===null||r===void 0||r.call(this)}async send(t,r){var n,o,i,s,a;try{let{resumptionToken:u,onresumptiontoken:l}=r||{};if(u){this._startOrAuthSse({resumptionToken:u,replayMessageId:B5e(t)?t.id:void 0}).catch(b=>{var I;return(I=this.onerror)===null||I===void 0?void 0:I.call(this,b)});return}let c=await this._commonHeaders();c.set("content-type","application/json"),c.set("accept","application/json, text/event-stream");let d={...this._requestInit,method:"POST",headers:c,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},p=await((o=this._fetch)!==null&&o!==void 0?o:fetch)(this._url,d),f=p.headers.get("mcp-session-id");if(f&&(this._sessionId=f),!p.ok){let b=await p.text().catch(()=>null);if(p.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new M3(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:I,scope:w}=qwe(p);if(this._resourceMetadataUrl=I,this._scope=w,await Fj(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new lw;return this._hasCompletedAuthFlow=!0,this.send(t)}if(p.status===403&&this._authProvider){let{resourceMetadataUrl:I,scope:w,error:N}=qwe(p);if(N==="insufficient_scope"){let D=p.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===D)throw new M3(403,"Server returned 403 after trying upscoping");if(w&&(this._scope=w),I&&(this._resourceMetadataUrl=I),this._lastUpscopingHeader=D??void 0,await Fj(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new lw;return this.send(t)}}throw new M3(p.status,`Error POSTing to endpoint: ${b}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,p.status===202){await((i=p.body)===null||i===void 0?void 0:i.cancel()),bQs(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(b=>{var I;return(I=this.onerror)===null||I===void 0?void 0:I.call(this,b)});return}let g=(Array.isArray(t)?t:[t]).filter(b=>"method"in b&&"id"in b&&b.id!==void 0).length>0,S=p.headers.get("content-type");if(g)if(S?.includes("text/event-stream"))this._handleSseStream(p.body,{onresumptiontoken:l},!1);else if(S?.includes("application/json")){let b=await p.json(),I=Array.isArray(b)?b.map(w=>yee.parse(w)):[yee.parse(b)];for(let w of I)(s=this.onmessage)===null||s===void 0||s.call(this,w)}else throw new M3(-1,`Unexpected content type: ${S}`)}catch(u){throw(a=this.onerror)===null||a===void 0||a.call(this,u),u}}get sessionId(){return this._sessionId}async terminateSession(){var t,r,n,o;if(this._sessionId)try{let i=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},a=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,s);if(await((n=a.body)===null||n===void 0?void 0:n.cancel()),!a.ok&&a.status!==405)throw new M3(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(i){throw(o=this.onerror)===null||o===void 0||o.call(this,i),i}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}}});import{Agent as ina}from"https";function y7r(e,t){let r=e.requestOptions?.verifySsl===!1?new ina({rejectUnauthorized:!1}):void 0,n={...e.requestOptions?.headers,...t&&{Authorization:`Bearer ${t}`}};return new UBt(new URL(e.url),{eventSourceInit:{fetch:(o,i)=>fetch(o,{...i,headers:{...i?.headers,...n},...r&&{agent:r}})},requestInit:{headers:n,...r&&{agent:r}}})}function v7r(e,t){let r=e.requestOptions?.verifySsl===!1?new ina({rejectUnauthorized:!1}):void 0,n={...e.requestOptions?.headers,...t&&{Authorization:`Bearer ${t}`}};return new qBt(new URL(e.url),{requestInit:{headers:n,...r&&{agent:r}}})}function b7r(e,t){let r=e.env||{};if(process.env)for(let[i,s]of Object.entries(process.env))!(i in r)&&s&&(r[i]=s);let n=new HBt({command:e.command,args:e.args||[],env:r,cwd:e.cwd,stderr:"pipe"}),o=n.stderr;return o&&o.on("data",i=>{let s=i.toString().trim();s&&t.warnings.push(s)}),n}var ona=x(()=>{"use strict";c7r();rna();S7r()});function zBt(e){return e instanceof zwe&&e.code===401||e instanceof zwe&&e.code===405||e instanceof M3&&e.code===401||e instanceof M3&&e.code===405||e instanceof Error&&e.message.includes("401")||e instanceof Error&&e.message.includes("405")||e instanceof Error&&e.message.includes("Unauthorized")}var sna=x(()=>{"use strict";c7r();S7r()});var wmf,jBt,ana=x(()=>{"use strict";bG();$ta();Of();Zz();Bqe();ri();rw();ona();sna();lM();L0();wmf={mcpService:null,connections:[],tools:[],prompts:[]},jBt=class extends Ad{connections=new Map;assistant=null;isShuttingDown=!1;isHeadless;apiKeyCache=new Map;getDependencies(){return[dn.CONFIG,dn.AUTH]}constructor(){super("MCPService",{...wmf}),process.on("exit",()=>this.cleanup()),process.on("SIGINT",()=>this.cleanup()),process.on("SIGTERM",()=>this.cleanup())}async doInitialize(t,r,n){this.isHeadless=n,await this.shutdownConnections(),this.assistant=t,this.connections.clear();let o=t.mcpServers?.map(async s=>{if(s)return await this.connectServer(s)}),i=Promise.all(o??[]);if(n||r){if(await i,n){let s=Array.from(this.connections.values()).filter(a=>a.status==="error");if(s.length>0){let a=s.map(u=>`${u.config?.name}: ${u.error}`);throw new Error(`MCP server(s) failed to load:
|
|
4357
4357
|
${a.join(`
|
|
4358
|
-
`)}`)}}}else this.updateState();return this.currentState}updateState(){let t=Array.from(this.connections.values()).map(({client:s,...a})=>a),r=t.filter(s=>s.status==="connected"),n=r.flatMap(s=>s.tools),o=r.flatMap(s=>s.prompts),i={mcpService:this,connections:t,tools:n,prompts:o};this.setState(i),Xn.set(dn.MCP,i)}getState(){return{...this.currentState}}getOverallStatus(){let t=Array.from(this.connections.values()),r=t.some(n=>n.warnings.length>0);return t.some(n=>n.status==="connecting")?{status:"connecting",hasWarnings:r}:t.some(n=>n.status==="error")?{status:"error",hasWarnings:r}:t.some(n=>n.status==="connected")?{status:"connected",hasWarnings:r}:{status:"idle",hasWarnings:r}}async withTokenRefresh(t,r){let n=this.connections.get(t);if(!n)throw new Error(`Connection ${t} not found`);let o=n.config;if(!o||"command"in o)return await r();try{return await r()}catch(i){if(!zBt(i)||!await ej())throw i;let a=ll();this.apiKeyCache.delete(t);let u=a?.organizationId,l=null;try{let c=new URLSearchParams({url:o.url});u&&c.set("organizationSlug",u),o.sourceSlug&&c.set("slug",o.sourceSlug);let d=await fpe(`/ide/mcp-auth?${c.toString()}`);d.data.hasCredentials&&d.data.accessToken&&(l=d.data.accessToken,this.apiKeyCache.set(t,l))}catch{be.debug("Failed to fetch mcp oauth credentials")}if(!l)throw i;return this.apiKeyCache.set(o.name,l),await r()}}async runTool(t,r){for(let n of this.connections.values())if(n.status==="connected"&&n.client&&n.tools.find(i=>i.name===t)){let i=n.config.name;return await this.withTokenRefresh(i,async()=>{let s=this.connections.get(i);if(!s?.client)throw new Error(`Client for ${i} not available`);return await s.client.callTool({name:t,arguments:r})})}throw new Error(`Tool ${t} not found`)}async restartAllServers(){this.assistant&&(await this.shutdownConnections(),await this.initialize(this.assistant))}async restartServer(t){if(!this.assistant||!this.assistant.mcpServers)return;let r=this.assistant.mcpServers.find((o,i)=>o&&(o.name||`server-${i}`)===t);if(!r)throw new Error(`Server ${t} not found in configuration`);let n=this.connections.get(t);n&&(n.status==="connected"&&await this.shutdownConnection(n),this.connections.delete(t)),await this.connectServer(r)}async connectServer(t){let r={config:t,client:null,prompts:[],tools:[],status:"connecting",warnings:[]},n=t.name;this.connections.set(n,r),this.updateState();let s=WZ(JSON.stringify(t)).filter(a=>a.startsWith("secrets.")).map(a=>hGe(a.replace("secrets.","")).secretName);try{if(s.length>0){let l=`${t.name} MCP
|
|
4359
|
-
|
|
4360
|
-
Org-level secrets can only be used for MCP by Background Agents (https://docs.continue.dev/hub/agents/overview) when "Include in Env" is enabled for the secret.`;if(this.isHeadless)throw new Error(l);r.warnings.push(l)}let a=await this.getConnectedClient(t,r);r.client=a,r.status="connected",this.updateState();let u=a.getServerCapabilities();if(u?.prompts)try{r.prompts=await this.withTokenRefresh(n,async()=>{let l=this.connections.get(n);if(!l?.client)throw new Error(`Client for ${n} not available`);return(await l.client.listPrompts()).prompts})}catch(l){let c=wN(l);r.warnings.push(`Failed to load prompts: ${c}`),be.warn("Failed to load MCP prompts",{name:n,error:c})}if(u?.tools)try{r.tools=await this.withTokenRefresh(n,async()=>{let l=this.connections.get(n);if(!l?.client)throw new Error(`Client for ${n} not available`);return(await l.client.listTools()).tools})}catch(l){let c=wN(l);r.warnings.push(`Failed to load tools: ${c}`),be.warn("Failed to load MCP tools",{name:n,error:c})}}catch(a){let u=wN(a);if(r.status="error",r.warnings.length>0){let l=r.warnings.join(`
|
|
4358
|
+
`)}`)}}}else this.updateState();return this.currentState}updateState(){let t=Array.from(this.connections.values()).map(({client:s,...a})=>a),r=t.filter(s=>s.status==="connected"),n=r.flatMap(s=>s.tools),o=r.flatMap(s=>s.prompts),i={mcpService:this,connections:t,tools:n,prompts:o};this.setState(i),Xn.set(dn.MCP,i)}getState(){return{...this.currentState}}getOverallStatus(){let t=Array.from(this.connections.values()),r=t.some(n=>n.warnings.length>0);return t.some(n=>n.status==="connecting")?{status:"connecting",hasWarnings:r}:t.some(n=>n.status==="error")?{status:"error",hasWarnings:r}:t.some(n=>n.status==="connected")?{status:"connected",hasWarnings:r}:{status:"idle",hasWarnings:r}}async withTokenRefresh(t,r){let n=this.connections.get(t);if(!n)throw new Error(`Connection ${t} not found`);let o=n.config;if(!o||"command"in o)return await r();try{return await r()}catch(i){if(!zBt(i)||!await ej())throw i;let a=ll();this.apiKeyCache.delete(t);let u=a?.organizationId,l=null;try{let c=new URLSearchParams({url:o.url});u&&c.set("organizationSlug",u),o.sourceSlug&&c.set("slug",o.sourceSlug);let d=await fpe(`/ide/mcp-auth?${c.toString()}`);d.data.hasCredentials&&d.data.accessToken&&(l=d.data.accessToken,this.apiKeyCache.set(t,l))}catch{be.debug("Failed to fetch mcp oauth credentials")}if(!l)throw i;return this.apiKeyCache.set(o.name,l),await r()}}async runTool(t,r){for(let n of this.connections.values())if(n.status==="connected"&&n.client&&n.tools.find(i=>i.name===t)){let i=n.config.name;return await this.withTokenRefresh(i,async()=>{let s=this.connections.get(i);if(!s?.client)throw new Error(`Client for ${i} not available`);return await s.client.callTool({name:t,arguments:r})})}throw new Error(`Tool ${t} not found`)}async restartAllServers(){this.assistant&&(await this.shutdownConnections(),await this.initialize(this.assistant))}async restartServer(t){if(!this.assistant||!this.assistant.mcpServers)return;let r=this.assistant.mcpServers.find((o,i)=>o&&(o.name||`server-${i}`)===t);if(!r)throw new Error(`Server ${t} not found in configuration`);let n=this.connections.get(t);n&&(n.status==="connected"&&await this.shutdownConnection(n),this.connections.delete(t)),await this.connectServer(r)}async connectServer(t){let r={config:t,client:null,prompts:[],tools:[],status:"connecting",warnings:[]},n=t.name;this.connections.set(n,r),this.updateState();let s=WZ(JSON.stringify(t)).filter(a=>a.startsWith("secrets.")).map(a=>hGe(a.replace("secrets.","")).secretName);try{if(s.length>0){let l=`${t.name} MCP server has unresolved secrets: ${s.join(", ")}
|
|
4359
|
+
Set them as environment variables before starting Nexora, or add them to the \`env\` block of this server in your config.`;if(this.isHeadless)throw new Error(l);r.warnings.push(l)}let a=await this.getConnectedClient(t,r);r.client=a,r.status="connected",this.updateState();let u=a.getServerCapabilities();if(u?.prompts)try{r.prompts=await this.withTokenRefresh(n,async()=>{let l=this.connections.get(n);if(!l?.client)throw new Error(`Client for ${n} not available`);return(await l.client.listPrompts()).prompts})}catch(l){let c=wN(l);r.warnings.push(`Failed to load prompts: ${c}`),be.warn("Failed to load MCP prompts",{name:n,error:c})}if(u?.tools)try{r.tools=await this.withTokenRefresh(n,async()=>{let l=this.connections.get(n);if(!l?.client)throw new Error(`Client for ${n} not available`);return(await l.client.listTools()).tools})}catch(l){let c=wN(l);r.warnings.push(`Failed to load tools: ${c}`),be.warn("Failed to load MCP tools",{name:n,error:c})}}catch(a){let u=wN(a);if(r.status="error",r.warnings.length>0){let l=r.warnings.join(`
|
|
4361
4360
|
`);r.error=`${u}
|
|
4362
4361
|
|
|
4363
4362
|
Server stderr:
|
|
@@ -5816,7 +5815,7 @@ Applying fixes...`)),oam(e));let s=e.some(a=>a.status==="fail"||a.status==="erro
|
|
|
5816
5815
|
No reviews found. To add reviews:
|
|
5817
5816
|
`)+mt.dim(` 1. Create .continue/agents/my-review.md with agent instructions
|
|
5818
5817
|
`)+mt.dim(` 2. Or specify an agent: cn review --review-agents org/agent-name
|
|
5819
|
-
`)+mt.dim(` 3. Or configure reviews on https://
|
|
5818
|
+
`)+mt.dim(` 3. Or configure reviews on https://nexoracoding.com
|
|
5820
5819
|
`)),process.exit(0));let s=i.some(c=>c.sourceType==="hub"),a=i.map(c=>({name:c.name,status:"pending"}));t.checks=a,t.loading=!1,r();let u=[],l=async(c,d)=>{let p=Date.now(),f=null;try{a[d].status="running",a[d].startTime=Date.now(),r(),f=await SVa(d);let m=await iam(c.source,f,o,e),g=m.error?"error":m.patch.trim()?"fail":"pass",S=(Date.now()-p)/1e3;return a[d].status=g,a[d].duration=S,r(),{agent:c.source,name:c.name,status:g,patch:m.patch,output:m.agentOutput,duration:S,error:m.error}}catch(m){let g=(Date.now()-p)/1e3;return a[d].status="error",a[d].duration=g,r(),{agent:c.source,name:c.name,status:"error",patch:"",output:"",duration:g,error:m.message||String(m)}}finally{f&&await vVa(f)}};if(e.failFast)for(let c=0;c<i.length;c++){let d=await l(i[c],c);if(u.push(d),d.status==="fail"||d.status==="error")break}else{let c=await Promise.allSettled(i.map((d,p)=>l(d,p)));for(let d of c)d.status==="fulfilled"&&u.push(d.value)}n(),aam(u,o,e,s)}Lp();var idn=ee(U7a(),1);t3();aWe();Of();Lp();DG();ri();import{exec as _gm}from"child_process";import{existsSync as Egm,readFileSync as Agm}from"fs";import Tgm from"path";import{promisify as Sgm}from"util";var ygm=Sgm(_gm),vgm="environment.json",bgm=[".continue"];function B7a(){for(let e of bgm){let t=Tgm.join(process.cwd(),e,vgm);if(Egm(t))try{let r=Agm(t,"utf-8"),n=JSON.parse(r);return be.debug(`Found environment.json at: ${t}`),n}catch(r){return be.error(`Failed to parse environment.json at ${t}: ${ia(r)}`),null}}return be.debug("No environment.json file found"),null}async function Cgm(){let e=B7a();if(!e||!e.install){be.debug("No install script found in environment.json, skipping...");return}let t=e.install;be.debug(mt.blue(`
|
|
5821
5820
|
Running environment install script: ${mt.dim(t)}`));try{await ygm(t,{cwd:process.cwd(),encoding:"utf-8"}),be.debug(mt.green("\u2713 Environment install script completed successfully"))}catch(r){throw be.error(`Environment install script failed: ${ia(r)}`),new Error(`Failed to run environment install script: ${ia(r)}`)}}async function F7a(){let e=B7a();if(!e||!e.install){be.debug("No environment install script to run");return}be.debug(mt.blue("Running environment install script in background..."));try{await Cgm(),be.debug(mt.green("\u2713 Environment install script completed successfully"))}catch(t){be.error(mt.yellow("Warning: Environment install script failed:"),ia(t)),be.error(mt.dim("Server will continue to run without the install script."))}}tqt();vc();o_();ri();import{EventEmitter as Rgm}from"events";var ndn=class extends Rgm{queue=[];constructor(){super()}async enqueueMessage(t,r,n){let o={message:t,imageMap:r,timestamp:Date.now(),history:n};return this.queue.push(o),be.debug("MessageQueue: Message queued",{queueLength:this.queue.length}),this.emit("messageQueued",o),!0}getNextMessage(){return this.queue.shift()}getQueueLength(){return this.queue.length}},Qw=new ndn;f2t();Q1();NGt();tw();DG();sG();ri();vc();whe();ri();function H7a(e){try{let t=Mr.chatHistory.getHistory(),r=t[t.length-1];r&&r.message.role==="assistant"&&!r.message.content&&Mr.chatHistory.setHistory(t.slice(0,-1))}catch{let t=e[e.length-1];t&&t.message.role==="assistant"&&!t.message.content&&e.pop()}}async function V7a(e,t,r,n){let o=r.signal,s=setInterval(()=>{n()&&!o.aborted&&r.abort()},100),a={onContent:u=>{},onContentComplete:u=>{},onToolStart:(u,l)=>{},onToolResult:(u,l,c)=>{},onToolError:(u,l)=>{},onToolPermissionRequest:(u,l,c,d)=>{e.pendingPermission={toolName:u,toolArgs:l,requestId:c,timestamp:Date.now(),toolCallPreview:d};try{Mr.chatHistory.addSystemMessage(`WARNING: Tool ${u} requires permission`)}catch(p){be.error("Failed to add system message via ChatHistoryService",p,{context:"onToolPermissionRequest",toolName:u,requestId:c})}},onSystemMessage:u=>{try{Mr.chatHistory.addSystemMessage(u)}catch(l){be.error("Failed to add system message via ChatHistoryService",l,{context:"onSystemMessage"})}}};try{return await OU(e.session.history,e.model,t,r,a)||""}finally{clearInterval(s)}}function G7a(e){if(!e||e.length===0)return!1;let t=e[e.length-1];if(t?.message?.role!=="assistant")return!1;let r=t.message.tool_calls;return!r||r.length===0}function Igm(e,t){return t?!e.some(n=>n.message.role!=="system"):!1}async function odn(e,t={}){await Ac.capture("sessionStart",{}),q7a(t.id);let r=e;if(!e){let _e=Xhe();_e&&(r=_e)}let n=parseInt(t.timeout||"300",10),o=n*1e3,i=parseInt(t.port||"8000",10),{permissionOverrides:s}=X7e(t);await QG({options:t,toolPermissionOverrides:s,headless:!0});let a,u,l,c;try{if([a,u,l,c]=await Promise.all([Hj(dn.CONFIG),Hj(dn.MODEL),Hj(dn.TOOL_PERMISSIONS),Hj(dn.AGENT_FILE)]),!a.config||!u.llmApi||!u.model)throw new Error("Failed to initialize required services")}catch(_e){console.error(mt.red(`
|
|
5822
5821
|
Fatal error: failed to initialize the model/config service.
|
|
@@ -5911,9 +5910,9 @@ Please create both the AGENTS.md file and the .continue/rules/review.md file usi
|
|
|
5911
5910
|
`)}}async function rAm(){try{let e=await Mr.auth.login();await L7r(dn.AUTH);let t=e.authConfig&&DT(e.authConfig)?e.authConfig.userEmail||e.authConfig.userId:"user";return console.info(mt.green(`
|
|
5912
5911
|
Logged in as ${t}`)),{exit:!1,output:"Login successful! All services updated automatically."}}catch(e){return console.error(mt.red(`
|
|
5913
5912
|
Login failed: ${e.message}`)),{exit:!1,output:`Login failed: ${e.message}`}}}async function nAm(){try{return await Mr.auth.logout(),{exit:!0,output:"Logged out successfully"}}catch{return{exit:!0,output:"Logged out successfully"}}}async function iAm(){if(await ej()){let t=ll();return t&&DT(t)?{exit:!1,output:`Logged in as ${t.userEmail||t.userId}`}:{exit:!1,output:"Authenticated via environment variable"}}else return{exit:!1,output:"Not logged in. Use /login to authenticate."}}async function oAm(){try{let t=`nexora --fork ${cG().sessionId}`;try{return await(await Promise.resolve().then(()=>(jdn(),zdn))).default.write(t),{exit:!1,output:mt.gray(`${t} (copied to clipboard)`)}}catch{return{exit:!1,output:mt.gray(`${t}`)}}}catch(e){return{exit:!1,output:mt.red(`Failed to create fork command: ${e.message}`)}}}function cYa(e,t="title"){let r=e.join(" ").trim();if(!r)return{exit:!1,output:mt.yellow(`Indique un titre. Usage : /${t} <titre de la session>`)};try{return epe(r),{exit:!1,output:mt.green(`Session title updated to: "${r}"`)}}catch(n){return{exit:!1,output:mt.red(`Failed to update title: ${n.message}`)}}}function sAm(){let e=r$r();return uia(),{exit:!1,output:e>0?mt.green(`Checkpoint created \u2014 current files are the new baseline (${e} previous file(s) committed).`):mt.green("Checkpoint created \u2014 current files are the baseline.")}}function aAm(){if(r$r()===0)return{exit:!1,output:mt.yellow("Nothing to revert \u2014 no files changed since the last checkpoint.")};let{restored:t,deleted:r}=aia(),n=[];return t>0&&n.push(`${t} file(s) restored`),r>0&&n.push(`${r} created file(s) removed`),{exit:!1,output:mt.green(`Files reverted: ${n.join(", ")}.`)}}function uAm(){try{let e=AZ(),t=e.promptTokens+e.completionTokens;if(t===0&&e.totalCost===0)return{exit:!1,output:mt.gray("No usage yet \u2014 send a message to start tracking costs.")};let r=[mt.bold("Session cost"),"",` ${mt.white("Total cost")} ${mt.green(`$${e.totalCost.toFixed(6)}`)}`,` ${mt.white("Input tokens")} ${mt.cyan(e.promptTokens.toLocaleString())}`,` ${mt.white("Tokens sortie")} ${mt.cyan(e.completionTokens.toLocaleString())}`,` ${mt.white("Tokens total")} ${mt.cyan(t.toLocaleString())}`];return e.promptTokensDetails?.cachedTokens&&r.push(` ${mt.white("Cache (lecture)")} ${mt.cyan(e.promptTokensDetails.cachedTokens.toLocaleString())}`),e.promptTokensDetails?.cacheWriteTokens&&r.push(` ${mt.white("Cache (write)")} ${mt.cyan(e.promptTokensDetails.cacheWriteTokens.toLocaleString())}`),{exit:!1,output:r.join(`
|
|
5914
|
-
`)}}catch(e){return{exit:!1,output:mt.red(`Impossible de lire l'utilisation : ${e.message}`)}}}function lAm(){try{let e=eAm("git diff --color=never",{encoding:"utf8",maxBuffer:10485760});return e.trim()?{exit:!1,diffContent:e}:{exit:!1,output:mt.gray("No uncommitted changes in the current repository.")}}catch(e){let t=e?.status===128?"The current directory is not a git repository.":`
|
|
5913
|
+
`)}}catch(e){return{exit:!1,output:mt.red(`Impossible de lire l'utilisation : ${e.message}`)}}}function lAm(){try{let e=eAm("git diff --color=never",{encoding:"utf8",maxBuffer:10485760});return e.trim()?{exit:!1,diffContent:e}:{exit:!1,output:mt.gray("No uncommitted changes in the current repository.")}}catch(e){let t=e?.status===128?"The current directory is not a git repository.":`Could not get the diff: ${e.message}`;return{exit:!1,output:mt.yellow(t)}}}function cAm(){let e=[...Wie].sort((n,o)=>n.name.localeCompare(o.name)),t=Math.max(...e.map(n=>n.name.length));return{exit:!1,output:[mt.bold(`Outils disponibles (${e.length})`),"",...e.map(n=>{let o=(n.description||"").split(`
|
|
5915
5914
|
`)[0].trim(),i=o.length>70?o.slice(0,69).trim()+"\u2026":o;return` ${mt.cyan(n.name.padEnd(t))} ${mt.gray(i)}`})].join(`
|
|
5916
|
-
`)}}function dAm(){return{exit:!1,output:[mt.bold("Nexora CLI")+mt.gray(` v${Xg()}`),"",mt.white("
|
|
5915
|
+
`)}}function dAm(){return{exit:!1,output:[mt.bold("Nexora CLI")+mt.gray(` v${Xg()}`),"",mt.white(" An AI assistant for the terminal \u2014 write, edit and"),mt.white(" run tasks without leaving your terminal."),"",` ${mt.gray("Docs")} ${mt.cyan("https://nexoracoding.com/docs")}`,` ${mt.gray("Site")} ${mt.cyan("https://nexoracoding.com")}`,"",mt.gray(" Type /help for shortcuts, / for commands.")].join(`
|
|
5917
5916
|
`)}}function pAm(){return{copyLastResponse:!0}}function fAm(){return{exportSession:!0}}function mAm(){let e="https://github.com/kemzang-Bryan/Nexora/issues/new";return Promise.resolve().then(()=>(P_e(),t$t)).then(t=>t.default(e)).catch(()=>{}),{exit:!1,output:mt.gray(`Ouverture du rapport de bug : ${e}`)}}function hAm(e,t){let r=mt.green("\u2713"),n=mt.red("\u2717"),o=!!process.env.NEXORA_API_KEY||!!process.env.CONTINUE_API_KEY,i="\u2014",s=!1;try{let d=ll();s=d!==null,d&&DT(d)?i=d.account?.label||d.userEmail||"signed in":d&&(i="session Nexora")}catch{}let a=t?.models??[],u=a[0]?.model||a[0]?.name||"(set by plan/server)",l=o||s;return{exit:!1,output:[mt.bold("Nexora diagnostics"),"",` ${l?r:n} Authentication : ${o?"API key (env)":l?mt.white(i):mt.yellow("not signed in \u2014 /login")}`,` ${r} Model : ${mt.white(u)}`,` ${r} CLI version : ${mt.white("v"+Xg())}`,` ${r} Runtime : ${mt.white(`Node ${process.version} \xB7 ${process.platform}/${process.arch}`)}`,` ${r} Config folder : ${mt.gray(Ai.continueHome)}`,` ${r} Model proxy : ${mt.gray(Ai.modelProxyBase)}`,` ${r} Nexora site : ${mt.gray(Ai.siteUrl)}`].join(`
|
|
5918
5917
|
`)}}function gAm(){return{openJobsSelector:!0}}function _Am(){return{openSessionSelector:!0}}var EAm={help:tAm,clear:()=>({clear:!0,output:"Chat history cleared"}),exit:()=>({exit:!0,output:"Goodbye!"}),collab:C$a,config:()=>({openConfigSelector:!0}),login:rAm,logout:nAm,whoami:iAm,info:N$a,model:()=>({openModelSelector:!0}),compact:()=>({compact:!0}),mcp:()=>({openMcpSelector:!0}),resume:()=>({openSessionSelector:!0}),fork:oAm,title:e=>cYa(e,"title"),rename:e=>cYa(e,"rename"),init:(e,t)=>x$a(e,t),update:()=>({openUpdateSelector:!0}),jobs:gAm,sessions:_Am,checkpoint:sAm,revert:aAm,cost:uAm,diff:lAm,tools:cAm,copy:pAm,about:dAm,doctor:hAm,export:fAm,bug:mAm};async function dYa(e,t,r){if(!e.startsWith("/")||!e.trim().startsWith("/"))return null;let[n,...o]=e.slice(1).split(" ");co.recordSlashCommand(n),Ac.capture("useSlashCommand",{name:n});let i=new Set(["diff","apply"]),s=r?.isRemoteMode&&i.has(n)?void 0:EAm[n];if(s)return await s(o,t,r?.remoteUrl,r);let a=t.prompts?.find(d=>d?.name===n);if(a)return{newInput:a.prompt+o.join(" ")};let u=t.rules?.find(d=>{if(!d||typeof d=="string")return!1;let p=d;return p.invokable===!0&&p.name===n});return u?{newInput:u.rule+" "+o.join(" ")}:uWe(t,{isRemoteMode:r?.isRemoteMode}).some(d=>d.name.toLowerCase().includes(n.toLowerCase()))?{output:`Unknown command: ${n}`}:null}Q1();DG();ri();Phe();o_();nqt();DG();ri();async function pYa({chatHistory:e,model:t,llmApi:r,setChatHistory:n,setCompactionIndex:o,currentSession:i,setCurrentSession:s,setIsCompacting:a,setCompactionStartTime:u,setCompactionAbortController:l}){let c=new AbortController;l(c),a(!0),u(Date.now());try{let d=await Nhe(e,t,r,{abortController:c});if(c.signal.aborted)return;n(d.compactedHistory),o(d.compactionIndex);let p={...i,history:d.compactedHistory};$k(d.compactedHistory),s(p),n(f=>[...f,{message:{role:"system",content:"Chat history compacted successfully."},contextItems:[]}])}catch(d){c.signal.aborted?(be.info("Manual compaction was cancelled by user"),n(p=>[...p,{message:{role:"system",content:"Compaction cancelled."},contextItems:[]}])):(be.error("Compaction failed:",d),n(p=>[...p,{message:{role:"system",content:`Compaction failed: ${ia(d)}`},contextItems:[]}]))}finally{a(!1),u(null),l(null)}}async function $dn({chatHistory:e,model:t,llmApi:r,compactionIndex:n,setChatHistory:o,setCompactionIndex:i,abortController:s}){let a=await xhe(e,t,r,{isHeadless:!1,callbacks:{setChatHistory:o,setCompactionIndex:i}});return a.wasCompacted?{currentChatHistory:a.chatHistory,currentCompactionIndex:a.compactionIndex}:{currentChatHistory:e,currentCompactionIndex:n}}import*as hYa from"node:path";$Pt();ri();WPt();o_();t3();Q1();ri();async function AAm(){try{let t=await new Function('return import("sharp")')().catch(()=>null);return t?t.default||t:null}catch{return null}}async function TAm(e,t=1024,r=1024){try{let n=await AAm();if(!n)return be.debug("Sharp not available, using original image buffer"),{buffer:e,isJpeg:!1};be.debug("Processing image with Sharp...");let o=await n(e).resize(t,r,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:85,progressive:!0}).toBuffer();return be.debug(`Image processed with Sharp: ${e.length} bytes -> ${o.length} bytes`),{buffer:o,isJpeg:!0}}catch(n){return be.warn("Failed to process image with Sharp, using original:",n),{buffer:e,isJpeg:!1}}}function SAm(e){if(e.length<4)return"image/png";let t=e.subarray(0,4);if(t[0]===255&&t[1]===216&&t[2]===255)return"image/jpeg";if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return"image/png";if(t[0]===71&&t[1]===73&&t[2]===70&&t[3]===56)return"image/gif";if(t[0]===82&&t[1]===73&&e.length>=12){let r=e.subarray(8,12);if(r[0]===87&&r[1]===69&&r[2]===66&&r[3]===80)return"image/webp"}return"image/png"}async function fYa(e,t,r,n){be.debug(`Processing image placeholder: ${e}, original size: ${t.length} bytes`);try{let o=await TAm(t),i=o.buffer,s=o.isJpeg,a=10*1024*1024;if(i.length>a)return be.warn(`Processed image is still too large (${Math.round(i.length/1024/1024)}MB). Skipping image.`),{textContent:r.replace(e,"[Large image skipped - reduce image size and try again]")};be.debug("Converting processed image to base64...");let u=await new Promise(p=>{setImmediate(()=>{let f=i.toString("base64");p(f)})}),l=s?"image/jpeg":SAm(i),c=`data:${l};base64,${u}`;be.debug(`Image converted to base64 with MIME type ${l}, dataUrl length: ${c.length}`);let d=r.split(e);return d.length>1?(d[0]&&n.push({type:"text",text:d[0]}),n.push({type:"imageUrl",imageUrl:{url:c}}),{textContent:d.slice(1).join(e)}):{textContent:r}}catch(o){return be.error(`Failed to process image ${e}:`,o),{textContent:r.replace(e,"[Image processing failed]")}}}async function Qdn(e,t){if(e){let r=Zde();if(r)return r.history}return[]}function wAm(e){Ac.capture("useSlashCommand",{name:"config"}),e()}function gYa(e){return t=>e(r=>[...r,{message:{role:"system",content:t},contextItems:[]}])}function xAm(){if(process.platform!=="linux")return"Clipboard is not available on this system.";let e=process.env.WAYLAND_DISPLAY||process.env.XDG_SESSION_TYPE==="wayland"?"wl-clipboard":"xclip";return`Clipboard unavailable: install ${e} (sudo apt install ${e}), then try again.`}function NAm(e,t){let r=[...e].reverse().find(i=>i.message.role==="assistant"),n=typeof r?.message.content=="string"?r.message.content:Array.isArray(r?.message.content)?r.message.content.map(i=>i.type==="text"?i.text:"").join(""):"",o=gYa(t);if(!n.trim()){o("No response to copy yet.");return}Promise.resolve().then(()=>(jdn(),zdn)).then(({default:i})=>i.write(n)).then(()=>o("Last response copied to clipboard.")).catch(()=>o(xAm()))}function PAm(e,t){let r=gYa(t),n=a=>typeof a=="string"?a:Array.isArray(a)?a.map(u=>u.type==="text"?u.text:"").join(""):"",o=e.filter(a=>a.message.role!=="system").map(a=>`${a.message.role==="user"?"## \u{1F9D1} Vous":a.message.role==="assistant"?"## \u{1F916} Nexora":`## ${a.message.role}`}
|
|
5919
5918
|
|