MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / WebAdapter

Class WebAdapter

src/runtime/adapters/web.ts:79–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77// ---------------------------------------------------------------------------
78
79export class WebAdapter implements PlatformAdapter {
80 readonly name = "web";
81
82 private wss: WebSocketServer | null = null;
83 private agent: IPackAgent | null = null;
84 private ipcBroadcaster: IpcBroadcaster | null = null;
85 private conversationService: ConversationService | null = null;
86 private socketsByChannel = new Map<string, Set<WebSocket>>();
87
88 async start(ctx: AdapterContext): Promise<void> {
89 const { agent, server, app, rootDir, lifecycle } = ctx;
90 this.agent = agent;
91 this.ipcBroadcaster = ctx.ipcBroadcaster ?? null;
92 this.conversationService = new ConversationService(rootDir);
93
94 // -- API key & provider (in-memory, can be overridden by frontend) ------
95
96 const currentConf = configManager.getConfig();
97 let apiKey = currentConf.apiKey || "";
98 let currentProvider = currentConf.provider || "openai";
99
100 // -- HTTP API routes ----------------------------------------------------
101
102 app.get("/api/config", (_req, res) => {
103 const config = getPackConfig(rootDir);
104 const conf = configManager.getConfig();
105 const currentProvider = conf.provider || "openai";
106 const providerMeta = SUPPORTED_PROVIDERS[currentProvider];
107
108 const oauthConnected = providerMeta?.authType === "oauth"
109 ? agent.getAuthStorage().hasAuth(currentProvider)
110 : false;
111
112 res.json({
113 name: config.name,
114 description: config.description,
115 prompts: config.prompts || [],
116 skills: config.skills || [],
117 hasApiKey: !!conf.apiKey,
118 apiKey: conf.apiKey || "",
119 provider: currentProvider,
120 baseUrl: conf.baseUrl || "",
121 modelId: conf.modelId || "",
122 apiProtocol: conf.apiProtocol || "",
123 adapters: conf.adapters || {},
124 supportedProviders: SUPPORTED_PROVIDERS,
125 oauthConnected,
126 });
127 });
128
129 app.get("/api/skills", (_req, res) => {
130 const config = getPackConfig(rootDir);
131 res.json(config.skills || []);
132 });
133
134 app.post("/api/config/update", (req, res) => {
135 const { key, provider, baseUrl, modelId, apiProtocol, adapters } = req.body;
136 const updates: any = {};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected