@vibecontrols/vibe-plugin-session-manager 2026.509.2 → 2026.512.1
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 +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Elysia,t}from"elysia";function createLifecycleHooks(spec){let{name,onInit,onShutdown,telemetryEventName,skipPlatforms}=spec;return{onServerStart:async(_app,hostServices)=>{if(skipPlatforms&&skipPlatforms.includes(process.platform)){process.stderr.write(`[${name}] skipping init on unsupported platform '${process.platform}'
|
|
3
|
-
`);return}if(onInit)await onInit(hostServices);if(telemetryEventName)hostServices.telemetry?.emit(telemetryEventName,{plugin:name})},onServerStop:async(hostServices)=>{if(onShutdown)await onShutdown(hostServices)}}}var BoundLogger=class{constructor(logger,source){this.logger=logger,this.source=source}logger;source;info(message,meta){this.logger?.info?.(this.source,message,meta)}warn(message,meta){this.logger?.warn?.(this.source,message,meta)}error(message,meta){this.logger?.error?.(this.source,message,meta)}debug(message,meta){this.logger?.debug?.(this.source,message,meta)}};var ProviderRegistry=class{constructor(hostServices){this.hostServices=hostServices}hostServices;getServiceRegistry(){return this.hostServices?.serviceRegistry}registerProvider(type,name,provider){this.hostServices?.serviceRegistry?.
|
|
3
|
+
`);return}if(onInit)await onInit(hostServices);if(telemetryEventName)hostServices.telemetry?.emit(telemetryEventName,{plugin:name})},onServerStop:async(hostServices)=>{if(onShutdown)await onShutdown(hostServices)}}}var BoundLogger=class{constructor(logger,source){this.logger=logger,this.source=source}logger;source;info(message,meta){this.logger?.info?.(this.source,message,meta)}warn(message,meta){this.logger?.warn?.(this.source,message,meta)}error(message,meta){this.logger?.error?.(this.source,message,meta)}debug(message,meta){this.logger?.debug?.(this.source,message,meta)}};var ProviderRegistry=class{constructor(hostServices){this.hostServices=hostServices}hostServices;getServiceRegistry(){return this.hostServices?.serviceRegistry}registerProvider(type,name,provider){this.hostServices?.serviceRegistry?.registerProvider?.(type,provider,name)}getProvider(type,name){let reg=this.hostServices?.serviceRegistry;if(!reg)return;if(name===void 0)return reg.getProvider?.(type);if(!reg.listProvidersForType)return;if(!(reg.listProvidersForType(type)??[]).some((entry)=>typeof entry==="string"?entry===name:entry.pluginName===name))return;return reg.getProvider?.(type)}listProviders(type){return(this.hostServices?.serviceRegistry?.listProvidersForType?.(type)??[]).map((entry)=>typeof entry==="string"?entry:entry.pluginName)}withCliContribution(contribution){let contributors=this.hostServices?.cliContributors;if(!contributors)return;for(let section of contribution.statusSections??[])contributors.addStatusSection?.(section);for(let check of contribution.doctorChecks??[])contributors.addDoctorCheck?.(check)}};var PLUGIN_NAME="session-manager",PLUGIN_VERSION="2026.509.2",FEATURE_KEYS=["mouse","resize","capture","webTerminal","splitPanes","tabs","scrollback","clipboard","search"];class SessionManager{registry;log=new BoundLogger(void 0,PLUGIN_NAME);init(hostServices){this.log=new BoundLogger(hostServices?.logger,PLUGIN_NAME),this.registry=new ProviderRegistry(hostServices),this.log.info("Session manager initialized")}listProviderNames(){if(!this.registry)return this.log.warn("No service registry available"),[];return this.registry.listProviders("session")}getProvider(pluginName){if(!this.registry)return;return this.registry.getProvider("session",pluginName)}getAllCapabilities(){let names=this.listProviderNames(),results=[];for(let name of names){let provider=this.getProvider(name);if(!provider)continue;if(provider.getCapabilities)results.push(provider.getCapabilities());else results.push({provider:provider.name,features:{mouse:!1,resize:!1,capture:!1,webTerminal:!1,splitPanes:!1,tabs:!1,scrollback:!1,clipboard:!1,search:!1},platform:[]})}return results}getCapabilitiesForProvider(providerName){return this.getAllCapabilities().find((c)=>c.provider===providerName)??null}negotiate(desiredFeatures){let all=this.getAllCapabilities();if(all.length===0)return{bestProvider:null,supported:[],unsupported:desiredFeatures,candidates:[]};let validFeatures=desiredFeatures.filter((f)=>FEATURE_KEYS.includes(f)),candidates=all.map((cap)=>{let supported=[],unsupported=[];for(let feature of validFeatures){let key=feature;if(cap.features[key])supported.push(feature);else unsupported.push(feature)}return{provider:cap.provider,score:supported.length,supported,unsupported}});candidates.sort((a,b)=>{if(b.score!==a.score)return b.score-a.score;return a.provider.localeCompare(b.provider)});let best=candidates[0];return{bestProvider:best?best.provider:null,supported:best?best.supported:[],unsupported:best?best.unsupported:[],candidates}}async listProviders(){let names=this.listProviderNames(),results=[];for(let name of names){let provider=this.getProvider(name),health=null,capabilities=null;if(provider){try{health=await provider.healthCheck()}catch(err){this.log.error("Health check failed for provider",{pluginName:name,error:String(err)})}if(provider.getCapabilities)capabilities=provider.getCapabilities()}results.push({pluginName:name,providerName:provider?.name??name,isDefault:!1,health,capabilities})}return results}}function createSessionManagerRoutes(manager){return new Elysia().get("/capabilities",()=>{let capabilities=manager.getAllCapabilities();return{providers:capabilities,count:capabilities.length}}).get("/capabilities/:provider",({params})=>{let capabilities=manager.getCapabilitiesForProvider(params.provider);if(!capabilities)return{error:`Provider "${params.provider}" not found or has no capabilities`};return capabilities},{params:t.Object({provider:t.String()})}).post("/negotiate",({body})=>{return manager.negotiate(body.desiredFeatures)},{body:t.Object({desiredFeatures:t.Array(t.String())})}).get("/providers",async()=>{let providers=await manager.listProviders();return{providers,count:providers.length}})}var createPlugin=(_ctx)=>{let manager=new SessionManager,lifecycle=createLifecycleHooks({name:PLUGIN_NAME,telemetryEventName:"session.meta.ready",onInit:async(hostServices)=>{manager.init(hostServices),registerStatusContributors(hostServices)}});return{capabilities:{storage:"rw",subprocess:!0,broadcast:!0,audit:!0,telemetry:!0},name:PLUGIN_NAME,version:PLUGIN_VERSION,description:"Unified session manager \u2014 capability discovery, feature negotiation, and provider routing across session providers",tags:["backend","integration"],apiPrefix:"/api/session-manager",createRoutes(){return createSessionManagerRoutes(manager)},onCliSetup(_program,hostServices){registerStatusContributors(hostServices)},onServerStart:lifecycle.onServerStart,onServerStop:lifecycle.onServerStop}};function registerStatusContributors(hostServices){let reg=hostServices?.cliContributors;if(!reg)return;reg.addStatusSection?.({source:PLUGIN_NAME,title:"Sessions",render:async({agentUrl})=>{try{let res=await fetch(`${agentUrl}/api/sessions`);if(!res.ok)return null;let list=await res.json();if(!Array.isArray(list))return"\x1B[2m(unable to fetch)\x1B[22m";if(list.length===0)return"\x1B[2m(none)\x1B[22m";return`\x1B[32m${list.length} active\x1B[39m`}catch{return null}},json:async({agentUrl})=>{try{let res=await fetch(`${agentUrl}/api/sessions`);if(!res.ok)return null;return await res.json()}catch{return null}},jsonKey:"sessions"}),reg.addDoctorCheck?.({source:PLUGIN_NAME,run:async()=>{try{let port=(process.env.AGENT_URL??"http://localhost:3005").replace(/\/+$/,""),res=await fetch(`${port}/api/sessions`);if(!res.ok)return[{name:"Session manager",ok:!1,grade:"warn",message:`/api/sessions returned ${res.status}`}];let list=await res.json();if(!Array.isArray(list))return[{name:"Session manager",ok:!1,grade:"warn",message:"/api/sessions did not return an array"}];return[{name:"Session manager",ok:!0,message:`${list.length} active session(s)`}]}catch{return[]}}})}var src_default=createPlugin;export{src_default as default,createPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibecontrols/vibe-plugin-session-manager",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.512.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "SEE LICENSE IN LICENSE",
|
|
38
38
|
"description": "Unified session manager plugin for VibeControls Agent — capability discovery, feature negotiation, and provider routing across session providers",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@vibecontrols/plugin-sdk": "2026.509.
|
|
40
|
+
"@vibecontrols/plugin-sdk": "2026.509.2",
|
|
41
41
|
"elysia": "^1.3.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
},
|
|
69
69
|
"homepage": "https://vibecontrols.com",
|
|
70
70
|
"publishConfig": {
|
|
71
|
-
"access": "
|
|
72
|
-
"registry": "https://
|
|
71
|
+
"access": "public",
|
|
72
|
+
"registry": "https://registry.npmjs.org/"
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
"dist/**/*",
|