@vibecontrols/vibe-plugin-tunnel 2026.428.4 → 2026.429.2

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- function agentBaseUrl(){return process.env.AGENT_BASE_URL??"http://localhost:3005"}async function apiGet(path){let res=await fetch(`${agentBaseUrl()}/api/tunnels${path}`);if(!res.ok){let text=await res.text().catch(()=>"");throw Error(`GET ${path} failed (${res.status}): ${text}`)}return await res.json()}async function apiPost(path,body){let res=await fetch(`${agentBaseUrl()}/api/tunnels${path}`,{method:"POST",headers:{"Content-Type":"application/json"},body:body?JSON.stringify(body):void 0});if(!res.ok){let text=await res.text().catch(()=>"");throw Error(`POST ${path} failed (${res.status}): ${text}`)}return await res.json()}async function apiDelete(path){let res=await fetch(`${agentBaseUrl()}/api/tunnels${path}`,{method:"DELETE"});if(!res.ok){let text=await res.text().catch(()=>"");throw Error(`DELETE ${path} failed (${res.status}): ${text}`)}return await res.json()}function registerTunnelCommands(program,_hostServices){let cmd=program.command("tunnel").description("Manage tunnels across providers");cmd.command("list").description("List tunnels (optionally filtered by provider)").option("--provider <name>","Limit to a specific provider").action(async(opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiGet(`/${qs}`);if(result.tunnels.length===0){console.log("No tunnels.");return}for(let t of result.tunnels)console.log(`${t.id} ${t.providerName} ${t.status} ${t.url} ${t.protocol}:${t.localPort}`)}),cmd.command("get <tunnelId>").description("Get tunnel status").option("--provider <name>").action(async(tunnelId,opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiGet(`/${tunnelId}${qs}`);console.log(JSON.stringify(result,null,2))}),cmd.command("start <tunnelId>").description("Start a prepared tunnel session").option("--provider <name>").action(async(tunnelId,opts)=>{let result=await apiPost(`/${tunnelId}/start`,{provider:opts.provider});console.log(JSON.stringify(result,null,2))}),cmd.command("stop <tunnelId>").description("Stop an active tunnel").option("--provider <name>").action(async(tunnelId,opts)=>{let result=await apiPost(`/${tunnelId}/stop`,{provider:opts.provider});console.log(JSON.stringify(result,null,2))}),cmd.command("delete <tunnelId>").description("Delete a tunnel").option("--provider <name>").action(async(tunnelId,opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiDelete(`/${tunnelId}${qs}`);console.log(JSON.stringify(result,null,2))}),cmd.command("sessions <tunnelId>").description("List sessions for a tunnel").option("--provider <name>").action(async(tunnelId,opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiGet(`/${tunnelId}/sessions${qs}`);console.log(JSON.stringify(result,null,2))}),cmd.command("status").description("Manager + per-provider health summary").action(async()=>{let result=await apiGet("/health");console.log(JSON.stringify(result,null,2))});let providersCmd=cmd.command("providers").description("Manage tunnel providers");providersCmd.command("list").description("List registered tunnel providers and capabilities").action(async()=>{let result=await apiGet("/providers");for(let p of result.providers){let star=p.isDefault?"* ":" ",ok=p.health.ok?"ok":`error (${p.health.message??""})`;console.log(`${star}${p.name} [${ok}]`)}}),providersCmd.command("set-default <name>").description("Set the default tunnel provider").action(async(name)=>{let result=await apiPost("/default",{provider:name});console.log(JSON.stringify(result,null,2))});let domainsCmd=cmd.command("domains").description("Manage custom domains on a tunnel");domainsCmd.command("add <tunnelId> <domain>").option("--provider <name>").action(async(tunnelId,domain,opts)=>{let result=await apiPost(`/${tunnelId}/domains`,{domain,provider:opts.provider});console.log(JSON.stringify(result,null,2))}),domainsCmd.command("rm <tunnelId> <domain>").option("--provider <name>").action(async(tunnelId,domain,opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiDelete(`/${tunnelId}/domains/${encodeURIComponent(domain)}${qs}`);console.log(JSON.stringify(result,null,2))}),cmd.command("doctor").description("Diagnose tunnel providers").action(async()=>{try{let health=await apiGet("/health");console.log(`manager: ${health.manager}`);for(let p of health.providers)console.log(` ${p.name}: ${p.ok?"ok":`fail - ${p.message}`}`)}catch(err){console.error(`Failed to reach agent: ${err}`),process.exitCode=1}})}var DEFAULT_PROVIDER_CONFIG_KEY="provider:default:tunnel";var LOG_SOURCE="tunnel-manager";class TunnelManager{registry;host;log={info:()=>{},warn:()=>{},error:()=>{},debug:()=>{}};init(host){if(this.host=host,this.registry=host.serviceRegistry,host.logger)this.log=host.logger;this.log.info(LOG_SOURCE,"Tunnel manager initialized")}async resolveProvider(name){if(!this.registry)throw Error("Service registry not available");let explicit=name?.trim();if(explicit){let provider2=this.registry.getProviderByName("tunnel",explicit);if(!provider2)throw Error(`Tunnel provider '${explicit}' is not registered`);return provider2}let fallback=await this.defaultProviderName();if(!fallback)throw Error("No default tunnel provider configured and none specified");let provider=this.registry.getProviderByName("tunnel",fallback);if(!provider)throw Error(`Default tunnel provider '${fallback}' is not registered`);return provider}async defaultProviderName(){let fromConfig=await this.host?.getConfig?.(DEFAULT_PROVIDER_CONFIG_KEY);if(fromConfig)return fromConfig;let entries=this.registry?.listProvidersForType("tunnel")??[],flagged=entries.find((e)=>e.isDefault);if(flagged)return flagged.pluginName;if(entries.length===1)return entries[0].pluginName;return}listProviderEntries(){return this.registry?.listProvidersForType("tunnel")??[]}async listAllTunnels(filterProvider){let entries=this.listProviderEntries(),targeted=filterProvider?entries.filter((e)=>e.pluginName===filterProvider):entries,results=[];for(let entry of targeted){let provider=this.registry?.getProviderByName("tunnel",entry.pluginName);if(!provider)continue;try{let tunnels=await provider.list();results.push({provider:entry.pluginName,tunnels})}catch(err){this.log.warn(LOG_SOURCE,`listAllTunnels: ${entry.pluginName} failed`,{error:String(err)})}}return results}async listProviders(){let entries=this.listProviderEntries(),snapshots=[];for(let entry of entries){let provider=this.registry?.getProviderByName("tunnel",entry.pluginName);if(!provider)continue;let health;try{health=await provider.healthCheck()}catch(err){health={ok:!1,message:String(err)}}snapshots.push({name:entry.pluginName,isDefault:entry.isDefault,capabilities:provider.getCapabilities(),health})}return snapshots}async getTunnel(id,opts={}){if(opts.provider){let provider=await this.resolveProvider(opts.provider),tunnel=await provider.getStatus(id);return tunnel?{provider:provider.name,tunnel}:null}for(let entry of this.listProviderEntries()){let provider=this.registry?.getProviderByName("tunnel",entry.pluginName);if(!provider)continue;try{let tunnel=await provider.getStatus(id);if(tunnel)return{provider:entry.pluginName,tunnel}}catch{}}return null}async issueSession(req){let{provider:providerName,...rest}=req,provider=await this.resolveProvider(providerName);return{...await provider.issueSession(rest),provider:provider.name}}async startTunnel(id,opts={}){return(await this.resolveProvider(opts.provider)).start(id)}async stopTunnel(id,opts={}){return(await this.resolveProvider(opts.provider)).stop(id)}async deleteTunnel(id,opts={}){return(await this.resolveProvider(opts.provider)).delete(id)}async rotate(id,opts={}){return(await this.resolveProvider(opts.provider)).rotate(id)}async attachDomain(id,domain,opts={}){return(await this.resolveProvider(opts.provider)).attachCustomDomain(id,domain)}async detachDomain(id,domain,opts={}){return(await this.resolveProvider(opts.provider)).detachCustomDomain(id,domain)}async listSessions(id,opts={}){return(await this.resolveProvider(opts.provider)).listSessions(id)}async getHealth(){let entries=this.listProviderEntries(),providers=[];for(let entry of entries){let provider=this.registry?.getProviderByName("tunnel",entry.pluginName);if(!provider){providers.push({name:entry.pluginName,ok:!1,message:"unavailable"});continue}try{let result=await provider.healthCheck();providers.push({name:entry.pluginName,ok:result.ok,message:result.message})}catch(err){providers.push({name:entry.pluginName,ok:!1,message:String(err)})}}return{manager:"ok",providers}}async setDefault(providerName){if(await this.resolveProvider(providerName),this.registry?.setProviderDefault)this.registry.setProviderDefault("tunnel",providerName);if(this.host?.setConfig)await this.host.setConfig(DEFAULT_PROVIDER_CONFIG_KEY,providerName);this.log.info(LOG_SOURCE,`Default tunnel provider set to ${providerName}`)}}import{Elysia,t}from"elysia";function readProvider(query){return query?.provider??void 0}function createTunnelManagerRoutes(manager){return new Elysia().get("/providers",async({set})=>{try{return{providers:await manager.listProviders()}}catch(err){return set.status=500,{error:"Failed to list providers",details:String(err)}}}).post("/default",async({body,set})=>{try{return await manager.setDefault(body.provider),{success:!0,provider:body.provider}}catch(err){return set.status=400,{error:String(err)}}},{body:t.Object({provider:t.String()})}).get("/health",async({set})=>{try{return await manager.getHealth()}catch(err){return set.status=500,{error:"Failed to get health",details:String(err)}}}).get("/",async({query,set})=>{try{let providerName=readProvider(query),results=await manager.listAllTunnels(providerName);return{tunnels:results.flatMap((r)=>r.tunnels.map((t2)=>({...t2,providerName:r.provider}))),byProvider:results}}catch(err){return set.status=500,{error:"Failed to list tunnels",details:String(err)}}}).post("/issue-session",async({body,set})=>{try{return await manager.issueSession({provider:body.provider,protocol:body.protocol,localPort:body.localPort,localHost:body.localHost,subdomain:body.subdomain,customDomain:body.customDomain,ttlSeconds:body.ttlSeconds,metadata:body.metadata,controlPlanePayload:body.controlPlanePayload})}catch(err){return set.status=500,{error:"Failed to issue session",details:String(err)}}},{body:t.Object({provider:t.Optional(t.String()),protocol:t.Union([t.Literal("http"),t.Literal("https"),t.Literal("tcp"),t.Literal("udp")]),localPort:t.Number(),localHost:t.Optional(t.String()),subdomain:t.Optional(t.String()),customDomain:t.Optional(t.String()),ttlSeconds:t.Optional(t.Number()),metadata:t.Optional(t.Any()),controlPlanePayload:t.Optional(t.Any())})}).get("/:id",async({params,query,set})=>{try{let result=await manager.getTunnel(params.id,{provider:readProvider(query)});if(!result)return set.status=404,{error:"Tunnel not found"};return result}catch(err){return set.status=500,{error:"Failed to get tunnel",details:String(err)}}}).get("/:id/sessions",async({params,query,set})=>{try{return{sessions:await manager.listSessions(params.id,{provider:readProvider(query)})}}catch(err){return set.status=500,{error:"Failed to list sessions",details:String(err)}}}).post("/:id/start",async({params,body,set})=>{try{return{success:!0,tunnel:await manager.startTunnel(params.id,{provider:body?.provider})}}catch(err){return set.status=500,{error:"Failed to start tunnel",details:String(err)}}},{body:t.Optional(t.Object({provider:t.Optional(t.String())}))}).post("/:id/stop",async({params,body,set})=>{try{return await manager.stopTunnel(params.id,{provider:body?.provider}),{success:!0}}catch(err){return set.status=500,{error:"Failed to stop tunnel",details:String(err)}}},{body:t.Optional(t.Object({provider:t.Optional(t.String())}))}).post("/:id/rotate",async({params,body,set})=>{try{return{success:!0,session:await manager.rotate(params.id,{provider:body?.provider})}}catch(err){return set.status=500,{error:"Failed to rotate tunnel",details:String(err)}}},{body:t.Optional(t.Object({provider:t.Optional(t.String())}))}).delete("/:id",async({params,query,set})=>{try{return await manager.deleteTunnel(params.id,{provider:readProvider(query)}),{success:!0}}catch(err){return set.status=500,{error:"Failed to delete tunnel",details:String(err)}}}).post("/:id/domains",async({params,body,set})=>{try{return await manager.attachDomain(params.id,body.domain,{provider:body.provider}),{success:!0}}catch(err){return set.status=500,{error:"Failed to attach domain",details:String(err)}}},{body:t.Object({domain:t.String(),provider:t.Optional(t.String())})}).delete("/:id/domains/:domain",async({params,query,set})=>{try{return await manager.detachDomain(params.id,params.domain,{provider:readProvider(query)}),{success:!0}}catch(err){return set.status=500,{error:"Failed to detach domain",details:String(err)}}})}var manager=new TunnelManager,vibePlugin={name:"tunnel",version:"0.1.0",description:"VibeTunnels manager \u2014 dispatches to registered tunnel providers",tags:["backend","cli","integration"],cliCommand:"tunnel",apiPrefix:"/api/tunnels",createRoutes:()=>createTunnelManagerRoutes(manager),onServerStart:(_app,hostServices)=>{manager.init(hostServices)},onCliSetup:(program,hostServices)=>{registerTunnelCommands(program,hostServices)}},src_default=vibePlugin;export{vibePlugin,src_default as default,TunnelManager};
2
+ var __require=import.meta.require;function agentBaseUrl(){return process.env.AGENT_BASE_URL??"http://localhost:3005"}function authHeaders(){let fromEnv=process.env.AGENT_API_KEY??process.env.X_AGENT_API_KEY;if(fromEnv)return{"x-agent-api-key":fromEnv};try{let{readFileSync,existsSync}=__require("fs"),{join,resolve}=__require("path"),dir=process.env.VIBECONTROLS_HOME??join(process.cwd(),".boff","vibecontrols"),configPath=join(resolve(dir),"agents",process.env.VIBECONTROLS_AGENT_ID??"default","config.json");if(existsSync(configPath)){let cfg=JSON.parse(readFileSync(configPath,"utf-8"));if(cfg["static-api-key"])return{"x-agent-api-key":cfg["static-api-key"]}}}catch{}return{}}async function apiGet(path){let res=await fetch(`${agentBaseUrl()}/api/tunnels${path}`,{headers:authHeaders()});if(!res.ok){let text=await res.text().catch(()=>"");throw Error(`GET ${path} failed (${res.status}): ${text}`)}return await res.json()}async function apiPost(path,body){let res=await fetch(`${agentBaseUrl()}/api/tunnels${path}`,{method:"POST",headers:{"Content-Type":"application/json",...authHeaders()},body:body?JSON.stringify(body):void 0});if(!res.ok){let text=await res.text().catch(()=>"");throw Error(`POST ${path} failed (${res.status}): ${text}`)}return await res.json()}async function apiDelete(path){let res=await fetch(`${agentBaseUrl()}/api/tunnels${path}`,{method:"DELETE",headers:authHeaders()});if(!res.ok){let text=await res.text().catch(()=>"");throw Error(`DELETE ${path} failed (${res.status}): ${text}`)}return await res.json()}function registerTunnelCommands(program,_hostServices){let cmd=program.command("tunnel").description("Manage tunnels across providers");cmd.command("list").description("List tunnels (optionally filtered by provider)").option("--provider <name>","Limit to a specific provider").action(async(opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiGet(`/${qs}`);if(result.tunnels.length===0){console.log("No tunnels.");return}for(let t of result.tunnels)console.log(`${t.id} ${t.providerName} ${t.status} ${t.url} ${t.protocol}:${t.localPort}`)}),cmd.command("get <tunnelId>").description("Get tunnel status").option("--provider <name>").action(async(tunnelId,opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiGet(`/${tunnelId}${qs}`);console.log(JSON.stringify(result,null,2))}),cmd.command("start <tunnelId>").description("Start a prepared tunnel session").option("--provider <name>").action(async(tunnelId,opts)=>{let result=await apiPost(`/${tunnelId}/start`,{provider:opts.provider});console.log(JSON.stringify(result,null,2))}),cmd.command("stop <tunnelId>").description("Stop an active tunnel").option("--provider <name>").action(async(tunnelId,opts)=>{let result=await apiPost(`/${tunnelId}/stop`,{provider:opts.provider});console.log(JSON.stringify(result,null,2))}),cmd.command("delete <tunnelId>").description("Delete a tunnel").option("--provider <name>").action(async(tunnelId,opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiDelete(`/${tunnelId}${qs}`);console.log(JSON.stringify(result,null,2))}),cmd.command("sessions <tunnelId>").description("List sessions for a tunnel").option("--provider <name>").action(async(tunnelId,opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiGet(`/${tunnelId}/sessions${qs}`);console.log(JSON.stringify(result,null,2))}),cmd.command("status").description("Manager + per-provider health summary").action(async()=>{let result=await apiGet("/health");console.log(JSON.stringify(result,null,2))});let providersCmd=cmd.command("providers").description("Manage tunnel providers");providersCmd.command("list").description("List registered tunnel providers and capabilities").action(async()=>{let result=await apiGet("/providers");for(let p of result.providers){let star=p.isDefault?"* ":" ",ok=p.health.ok?"ok":`error (${p.health.message??""})`;console.log(`${star}${p.name} [${ok}]`)}}),providersCmd.command("set-default <name>").description("Set the default tunnel provider").action(async(name)=>{let result=await apiPost("/default",{provider:name});console.log(JSON.stringify(result,null,2))});let domainsCmd=cmd.command("domains").description("Manage custom domains on a tunnel");domainsCmd.command("add <tunnelId> <domain>").option("--provider <name>").action(async(tunnelId,domain,opts)=>{let result=await apiPost(`/${tunnelId}/domains`,{domain,provider:opts.provider});console.log(JSON.stringify(result,null,2))}),domainsCmd.command("rm <tunnelId> <domain>").option("--provider <name>").action(async(tunnelId,domain,opts)=>{let qs=opts.provider?`?provider=${encodeURIComponent(opts.provider)}`:"",result=await apiDelete(`/${tunnelId}/domains/${encodeURIComponent(domain)}${qs}`);console.log(JSON.stringify(result,null,2))}),cmd.command("doctor").description("Diagnose tunnel providers").action(async()=>{try{let health=await apiGet("/health");console.log(`manager: ${health.manager}`);for(let p of health.providers)console.log(` ${p.name}: ${p.ok?"ok":`fail - ${p.message}`}`)}catch(err){console.error(`Failed to reach agent: ${err}`),process.exitCode=1}})}var DEFAULT_PROVIDER_CONFIG_KEY="provider:default:tunnel";var LOG_SOURCE="tunnel-manager";class TunnelManager{registry;host;log={info:()=>{},warn:()=>{},error:()=>{},debug:()=>{}};init(host){if(this.host=host,this.registry=host.serviceRegistry,host.logger)this.log=host.logger;this.log.info(LOG_SOURCE,"Tunnel manager initialized")}async resolveProvider(name){if(!this.registry)throw Error("Service registry not available");let explicit=name?.trim();if(explicit){let provider2=this.registry.getProviderByName("tunnel",explicit);if(!provider2)throw Error(`Tunnel provider '${explicit}' is not registered`);return provider2}let fallback=await this.defaultProviderName();if(!fallback)throw Error("No default tunnel provider configured and none specified");let provider=this.registry.getProviderByName("tunnel",fallback);if(!provider)throw Error(`Default tunnel provider '${fallback}' is not registered`);return provider}async defaultProviderName(){let fromConfig=await this.host?.getConfig?.(DEFAULT_PROVIDER_CONFIG_KEY);if(fromConfig)return fromConfig;let entries=this.registry?.listProvidersForType("tunnel")??[],flagged=entries.find((e)=>e.isDefault);if(flagged)return flagged.pluginName;if(entries.length===1)return entries[0].pluginName;return}listProviderEntries(){return this.registry?.listProvidersForType("tunnel")??[]}async listAllTunnels(filterProvider){let entries=this.listProviderEntries(),targeted=filterProvider?entries.filter((e)=>e.pluginName===filterProvider):entries,results=[];for(let entry of targeted){let provider=this.registry?.getProviderByName("tunnel",entry.pluginName);if(!provider)continue;try{let tunnels=await provider.list();results.push({provider:entry.pluginName,tunnels})}catch(err){this.log.warn(LOG_SOURCE,`listAllTunnels: ${entry.pluginName} failed`,{error:String(err)})}}return results}async listProviders(){let entries=this.listProviderEntries(),snapshots=[];for(let entry of entries){let provider=this.registry?.getProviderByName("tunnel",entry.pluginName);if(!provider)continue;let health;try{health=await provider.healthCheck()}catch(err){health={ok:!1,message:String(err)}}snapshots.push({name:entry.pluginName,isDefault:entry.isDefault,capabilities:provider.getCapabilities(),health})}return snapshots}async getTunnel(id,opts={}){if(opts.provider){let provider=await this.resolveProvider(opts.provider),tunnel=await provider.getStatus(id);return tunnel?{provider:provider.name,tunnel}:null}for(let entry of this.listProviderEntries()){let provider=this.registry?.getProviderByName("tunnel",entry.pluginName);if(!provider)continue;try{let tunnel=await provider.getStatus(id);if(tunnel)return{provider:entry.pluginName,tunnel}}catch{}}return null}async issueSession(req){let{provider:providerName,...rest}=req,provider=await this.resolveProvider(providerName);return{...await provider.issueSession(rest),provider:provider.name}}async startTunnel(id,opts={}){return(await this.resolveProvider(opts.provider)).start(id)}async stopTunnel(id,opts={}){return(await this.resolveProvider(opts.provider)).stop(id)}async deleteTunnel(id,opts={}){return(await this.resolveProvider(opts.provider)).delete(id)}async rotate(id,opts={}){return(await this.resolveProvider(opts.provider)).rotate(id)}async attachDomain(id,domain,opts={}){return(await this.resolveProvider(opts.provider)).attachCustomDomain(id,domain)}async detachDomain(id,domain,opts={}){return(await this.resolveProvider(opts.provider)).detachCustomDomain(id,domain)}async listSessions(id,opts={}){return(await this.resolveProvider(opts.provider)).listSessions(id)}async getHealth(){let entries=this.listProviderEntries(),providers=[];for(let entry of entries){let provider=this.registry?.getProviderByName("tunnel",entry.pluginName);if(!provider){providers.push({name:entry.pluginName,ok:!1,message:"unavailable"});continue}try{let result=await provider.healthCheck();providers.push({name:entry.pluginName,ok:result.ok,message:result.message})}catch(err){providers.push({name:entry.pluginName,ok:!1,message:String(err)})}}return{manager:"ok",providers}}async setDefault(providerName){if(await this.resolveProvider(providerName),this.registry?.setProviderDefault)this.registry.setProviderDefault("tunnel",providerName);if(this.host?.setConfig)await this.host.setConfig(DEFAULT_PROVIDER_CONFIG_KEY,providerName);this.log.info(LOG_SOURCE,`Default tunnel provider set to ${providerName}`)}}import{Elysia,t}from"elysia";function readProvider(query){return query?.provider??void 0}function createTunnelManagerRoutes(manager){return new Elysia().get("/providers",async({set})=>{try{return{providers:await manager.listProviders()}}catch(err){return set.status=500,{error:"Failed to list providers",details:String(err)}}}).post("/default",async({body,set})=>{try{return await manager.setDefault(body.provider),{success:!0,provider:body.provider}}catch(err){return set.status=400,{error:String(err)}}},{body:t.Object({provider:t.String()})}).get("/health",async({set})=>{try{return await manager.getHealth()}catch(err){return set.status=500,{error:"Failed to get health",details:String(err)}}}).get("/",async({query,set})=>{try{let providerName=readProvider(query),results=await manager.listAllTunnels(providerName);return{tunnels:results.flatMap((r)=>r.tunnels.map((t2)=>({...t2,providerName:r.provider}))),byProvider:results}}catch(err){return set.status=500,{error:"Failed to list tunnels",details:String(err)}}}).post("/issue-session",async({body,set})=>{try{return await manager.issueSession({provider:body.provider,protocol:body.protocol,localPort:body.localPort,localHost:body.localHost,subdomain:body.subdomain,customDomain:body.customDomain,ttlSeconds:body.ttlSeconds,metadata:body.metadata,controlPlanePayload:body.controlPlanePayload})}catch(err){return set.status=500,{error:"Failed to issue session",details:String(err)}}},{body:t.Object({provider:t.Optional(t.String()),protocol:t.Union([t.Literal("http"),t.Literal("https"),t.Literal("tcp"),t.Literal("udp")]),localPort:t.Number(),localHost:t.Optional(t.String()),subdomain:t.Optional(t.String()),customDomain:t.Optional(t.String()),ttlSeconds:t.Optional(t.Number()),metadata:t.Optional(t.Any()),controlPlanePayload:t.Optional(t.Any())})}).get("/:id",async({params,query,set})=>{try{let result=await manager.getTunnel(params.id,{provider:readProvider(query)});if(!result)return set.status=404,{error:"Tunnel not found"};return result}catch(err){return set.status=500,{error:"Failed to get tunnel",details:String(err)}}}).get("/:id/sessions",async({params,query,set})=>{try{return{sessions:await manager.listSessions(params.id,{provider:readProvider(query)})}}catch(err){return set.status=500,{error:"Failed to list sessions",details:String(err)}}}).post("/:id/start",async({params,body,set})=>{try{return{success:!0,tunnel:await manager.startTunnel(params.id,{provider:body?.provider})}}catch(err){return set.status=500,{error:"Failed to start tunnel",details:String(err)}}},{body:t.Optional(t.Object({provider:t.Optional(t.String())}))}).post("/:id/stop",async({params,body,set})=>{try{return await manager.stopTunnel(params.id,{provider:body?.provider}),{success:!0}}catch(err){return set.status=500,{error:"Failed to stop tunnel",details:String(err)}}},{body:t.Optional(t.Object({provider:t.Optional(t.String())}))}).post("/:id/rotate",async({params,body,set})=>{try{return{success:!0,session:await manager.rotate(params.id,{provider:body?.provider})}}catch(err){return set.status=500,{error:"Failed to rotate tunnel",details:String(err)}}},{body:t.Optional(t.Object({provider:t.Optional(t.String())}))}).delete("/:id",async({params,query,set})=>{try{return await manager.deleteTunnel(params.id,{provider:readProvider(query)}),{success:!0}}catch(err){return set.status=500,{error:"Failed to delete tunnel",details:String(err)}}}).post("/:id/domains",async({params,body,set})=>{try{return await manager.attachDomain(params.id,body.domain,{provider:body.provider}),{success:!0}}catch(err){return set.status=500,{error:"Failed to attach domain",details:String(err)}}},{body:t.Object({domain:t.String(),provider:t.Optional(t.String())})}).delete("/:id/domains/:domain",async({params,query,set})=>{try{return await manager.detachDomain(params.id,params.domain,{provider:readProvider(query)}),{success:!0}}catch(err){return set.status=500,{error:"Failed to detach domain",details:String(err)}}})}var manager=new TunnelManager,vibePlugin={name:"tunnel",version:"0.1.0",description:"VibeTunnels manager \u2014 dispatches to registered tunnel providers",tags:["backend","cli","integration"],cliCommand:"tunnel",apiPrefix:"/api/tunnels",createRoutes:()=>createTunnelManagerRoutes(manager),onServerStart:(_app,hostServices)=>{manager.init(hostServices)},onCliSetup:(program,hostServices)=>{registerTunnelCommands(program,hostServices)}},src_default=vibePlugin;export{vibePlugin,src_default as default,TunnelManager};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibecontrols/vibe-plugin-tunnel",
3
- "version": "2026.428.4",
3
+ "version": "2026.429.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",