Skip to content

Conversation

@microchipgnu
Copy link
Member

No description provided.

Copy link
Member

@SurgeCode SurgeCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing

@microchipgnu microchipgnu marked this pull request as ready for review January 22, 2025 16:57
@rubenmarcus rubenmarcus merged commit d1e6a42 into main Feb 4, 2025
1 check passed
}

const API_CONFIG: ApiConfig = {
key: process.env.BITTE_API_KEY!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely the culprit of the following dirty error which I will paste in entirety to demonstrate how gross it is:

yarn run v1.22.22
$ concurrently "next dev" "make-agent dev"
[1] file:///Users/bh2smith/Projects/other/agent-next-boilerplate/node_modules/make-agent/dist/index.js:493
[1] Status: ${V.status}`)}catch(V){let J=V instanceof Error?V.message:JSON.stringify(V);console.error(`Failed to request plugin verification: ${J}`)}}}var{VERCEL_ENV:Lo,VERCEL_URL:hi1,VERCEL_BRANCH_URL:ni1,VERCEL_PROJECT_PRODUCTION_URL:oi1}=process.env,si1=(()=>{switch(Lo){case"production":return`https://${oi1}`;case"preview":return`https://${ni1||hi1}`;default:return"http://localhost:3000/"}})(),JU=(p)=>{if(Lo)return si1;if(process.env.URL)return process.env.URL;if(process.env.HEROKU_APP_NAME)return`https://${process.env.HEROKU_APP_NAME}.herokuapp.com`;if(process.env.EB_ENVIRONMENT_URL)return process.env.EB_ENVIRONMENT_URL;if(process.env.K_SERVICE&&process.env.K_REVISION)return`https://${process.env.K_SERVICE}-${process.env.K_REVISION}.a.run.app`;if(process.env.WEBSITE_HOSTNAME)return`https://${process.env.WEBSITE_HOSTNAME}`;if(process.env.DIGITALOCEAN_APP_URL)return process.env.DIGITALOCEAN_APP_URL;if(process.env.RENDER_EXTERNAL_URL)return process.env.RENDER_EXTERNAL_URL;if(process.env.BITTE_AGENT_URL)return process.env.BITTE_AGENT_URL;return`http://localhost/:${p||3000}`},bd=JU();var F21=D0(Q21(),1),t90=3,e90=1000;async function u8(p){try{let d=p.toString(),D=await W21(d),f;try{f=JSON.parse(D)}catch(v){return console.error("Failed to parse OpenAPI spec JSON:",v instanceof Error?v.message:"Unknown error"),{isValid:!1}}try{await F21.default.validate(f),console.log("OpenAPI specification is valid.")}catch(v){if(v instanceof Error){if(console.error("OpenAPI validation failed:",v.message),"details"in v){let Z=v.details;console.error("Validation details:",Z.map((V)=>({path:V.instancePath,error:V.message,params:V.params})))}}return{isValid:!1}}return{isValid:!0,accountId:f["x-mb"]?.["account-id"]}}catch(d){return console.error("Unexpected error:",d instanceof Error?d.message:"Unknown error"),{isValid:!1}}}async function W21(p,d=t90){try{let D=await fetch(p);if(!D.ok)throw new Error(`HTTP error! status: ${D.status}`);let f=await D.text();return JSON.parse(f),f}catch(D){if(d>0)return console.log("Retrying..."),await new Promise((f)=>setTimeout(f,e90)),W21(p,d-1);throw D}}function t5(p){return new URL(p).hostname}function k8(p){return new URL(`${p}/${ku}`)}var K21=new S4().name("delete").description("Delete your AI agent plugin").option("-u, --url <url>","Specify the deployment URL").action(async(p)=>{let d=p.url||bd;if(!d){console.error("Deployed URL could not be determined.");return}let D=t5(d),f=k8(d),{isValid:$,accountId:v}=await u8(f);if(!$){console.error("OpenAPI specification validation failed.");return}if(!v){console.error("Failed to parse account ID from OpenAPI specification.");return}let Z=new F9;if(!await Z.auth.getAuthentication()){console.error("Authentication failed. Unable to delete the plugin.");return}try{await Z.delete(D),console.log(`Plugin ${D} deleted successfully.`)}catch(J){console.error("Failed to delete the plugin:",J)}});var q21=new S4().name("deploy").description("Deploy your AI agent, making it discoverable and registering it as a plugin").option("-u, --url <url>","Specify the deployment URL").action(async(p)=>{let d=p.url||bd;if(!d){console.error("Deployed URL could not be determined.");return}let D=t5(d),f=k8(d),{isValid:$,accountId:v}=await u8(f);if(!$){console.error("OpenAPI specification validation failed.");return}if(!v){console.error("Failed to parse account ID from OpenAPI specification.");return}let Z=new F9;try{if(!await Z.update(D))console.log("Attempting to register plugin..."),await Z.register({pluginId:D})}catch(V){console.error(`Failed to deploy plugin ${D}. Error: ${V}`)}});var Fd1=D0(df(),1);import p50 from"node:net";async function PM(p,{host:d,timeout:D=1000}={}){if(typeof d!=="string")throw new TypeError("Specify a `host`");let f=new Promise(($,v)=>{let Z=new p50.Socket,V=()=>{Z.destroy(),v()};Z.setTimeout(D),Z.once("error",V),Z.once("timeout",V),Z.connect(p,d,()=>{Z.end(),$()})});try{return await f,!0}catch{return!1}}var cX=D0(Xd1(),1);import{promises as VT}from"fs";import ev from"path";async function Gd1(p,d){let D=cX.default();D.use(cX.default.json({limit:"2mb"}));let f=[ev.resolve(process.cwd(),"dist","playground"),ev.resolve(process.cwd(),"node_modules","make-agent","dist","playground"),ev.resolve(process.cwd(),"..","make-agent","dist","playground")],$;for(let v of f)try{if(await VT.access(v),await VT.access(ev.join(v,"index.html")).then(()=>!0).catch(()=>!1)){$=v;break}}catch{continue}if(!$)throw new Error("Could not find static files directory with index.html");return D.use(cX.default.static($,{setHeaders:(v,Z)=>{if(Z.endsWith(".css"))v.setHeader("Content-Type","text/css")}})),D.get("/api/config",async(v,Z)=>{try{let V={serverStartTime:new Date().toISOString(),environment:"make-agent",localAgent:{pluginId:v.hostname,accountId:"anon",spec:d},bitteApiKey:p.key,bitteApiUrl:p.url};Z.json(V)}catch(V){Z.status(500).json({error:"Failed to fetch AI plugin spec"})}}),D.get("*",async(v,Z)=>{console.log(v.path);let V=ev.join($,"index.html");try{let J=await VT.readFile(V,"utf8");Z.setHeader("Content-Type","text/html"),Z.send(J)}catch(J){Z.status(404).send("Not found")}}),new Promise((v,Z)=>{try{let V=D.listen(p.serverPort,()=>{console.log(`[Server] UI server listening http://localhost/:${p.serverPort}`),console.log("[Server] Ready to handle requests"),v(V)})}catch(V){Z(V)}})}function zd1(){let d=["BITTE_API_KEY"].filter((D)=>!process.env[D]);if(d.length>0)throw new Error(`Missing required environment variables: ${d.join(", ")}
[1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
[1] 
[1] Error: Missing required environment variables: BITTE_API_KEY
[1] Please ensure these are set in your .env file
[1]     at zd1 (file:///Users/bh2smith/Projects/other/agent-next-boilerplate/node_modules/make-agent/dist/index.js:493:5392)
[1]     at file:///Users/bh2smith/Projects/other/agent-next-boilerplate/node_modules/make-agent/dist/index.js:496:680
[1]     at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
[1]     at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:483:26)
[1]     at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)
[1]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically the "dev" command is the only one no longer subject to the check with the warning.

Search the project for BITTE_API_KEY and find the other commands still have it.

Comment on lines +64 to +65
"near-ca": "^0.8.1",
"near-safe": "^0.9.6",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe that either of these dependencies are used in this project.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closed by #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants