@kelceyp/caw-server 0.0.2 → 0.0.4
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/main.js +161 -99
- package/dist/main.js.map +4 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -56172,127 +56172,180 @@ var createMcpServer = ({ sessionManager } = {}) => {
|
|
|
56172
56172
|
name: "caw-server",
|
|
56173
56173
|
version: "0.0.1"
|
|
56174
56174
|
});
|
|
56175
|
-
server.registerTool("
|
|
56176
|
-
title: "
|
|
56177
|
-
description: "
|
|
56178
|
-
inputSchema: exports_external2.object({
|
|
56179
|
-
|
|
56180
|
-
|
|
56181
|
-
|
|
56182
|
-
|
|
56175
|
+
server.registerTool("list_sessions", {
|
|
56176
|
+
title: "List Active Sessions",
|
|
56177
|
+
description: "List all active WebSocket sessions with their pageIds and states",
|
|
56178
|
+
inputSchema: exports_external2.object({})
|
|
56179
|
+
}, async () => {
|
|
56180
|
+
if (!sessionManager) {
|
|
56181
|
+
return {
|
|
56182
|
+
content: [
|
|
56183
|
+
{
|
|
56184
|
+
type: "text",
|
|
56185
|
+
text: "Error: SessionManager not initialized"
|
|
56186
|
+
}
|
|
56187
|
+
],
|
|
56188
|
+
isError: true
|
|
56189
|
+
};
|
|
56190
|
+
}
|
|
56191
|
+
const sessions = sessionManager.getAllSessions();
|
|
56192
|
+
if (sessions.length === 0) {
|
|
56193
|
+
return {
|
|
56194
|
+
content: [
|
|
56195
|
+
{
|
|
56196
|
+
type: "text",
|
|
56197
|
+
text: "No active sessions"
|
|
56198
|
+
}
|
|
56199
|
+
]
|
|
56200
|
+
};
|
|
56201
|
+
}
|
|
56202
|
+
const sessionList = sessions.map((s) => `• ${s.pageId} (${s.state}, capabilities: ${s.capabilities.join(", ")})`).join(`
|
|
56203
|
+
`);
|
|
56183
56204
|
return {
|
|
56184
56205
|
content: [
|
|
56185
56206
|
{
|
|
56186
56207
|
type: "text",
|
|
56187
|
-
text: `
|
|
56208
|
+
text: `Active sessions (${sessions.length}):
|
|
56209
|
+
${sessionList}`
|
|
56188
56210
|
}
|
|
56189
56211
|
]
|
|
56190
56212
|
};
|
|
56191
56213
|
});
|
|
56192
|
-
|
|
56193
|
-
|
|
56194
|
-
|
|
56195
|
-
|
|
56196
|
-
|
|
56197
|
-
|
|
56198
|
-
|
|
56199
|
-
|
|
56200
|
-
|
|
56201
|
-
|
|
56202
|
-
|
|
56203
|
-
|
|
56204
|
-
|
|
56205
|
-
|
|
56206
|
-
|
|
56207
|
-
|
|
56208
|
-
|
|
56209
|
-
|
|
56210
|
-
|
|
56211
|
-
|
|
56212
|
-
|
|
56213
|
-
|
|
56214
|
-
|
|
56215
|
-
|
|
56216
|
-
}
|
|
56217
|
-
|
|
56218
|
-
|
|
56219
|
-
|
|
56220
|
-
|
|
56221
|
-
|
|
56222
|
-
|
|
56223
|
-
|
|
56224
|
-
|
|
56225
|
-
|
|
56226
|
-
|
|
56227
|
-
|
|
56228
|
-
|
|
56229
|
-
}
|
|
56230
|
-
}
|
|
56231
|
-
|
|
56232
|
-
|
|
56233
|
-
|
|
56234
|
-
|
|
56235
|
-
|
|
56236
|
-
|
|
56237
|
-
|
|
56214
|
+
server.registerTool("get_state", {
|
|
56215
|
+
title: "Get ChatGPT State",
|
|
56216
|
+
description: "Get the current state of ChatGPT (IDLE, COMPOSING, RESPONDING, or UNKNOWN)",
|
|
56217
|
+
inputSchema: exports_external2.object({
|
|
56218
|
+
pageId: exports_external2.string().describe("Page ID of the ChatGPT tab")
|
|
56219
|
+
})
|
|
56220
|
+
}, async ({ pageId }) => {
|
|
56221
|
+
if (!sessionManager) {
|
|
56222
|
+
return {
|
|
56223
|
+
content: [
|
|
56224
|
+
{
|
|
56225
|
+
type: "text",
|
|
56226
|
+
text: "Error: SessionManager not initialized"
|
|
56227
|
+
}
|
|
56228
|
+
],
|
|
56229
|
+
isError: true
|
|
56230
|
+
};
|
|
56231
|
+
}
|
|
56232
|
+
try {
|
|
56233
|
+
const result = await sessionManager.sendCommand(pageId, "getState", {});
|
|
56234
|
+
return {
|
|
56235
|
+
content: [
|
|
56236
|
+
{
|
|
56237
|
+
type: "text",
|
|
56238
|
+
text: `ChatGPT state: ${result.state}`
|
|
56239
|
+
}
|
|
56240
|
+
]
|
|
56241
|
+
};
|
|
56242
|
+
} catch (error) {
|
|
56243
|
+
return {
|
|
56244
|
+
content: [
|
|
56245
|
+
{
|
|
56246
|
+
type: "text",
|
|
56247
|
+
text: `Error: ${error.message}`
|
|
56248
|
+
}
|
|
56249
|
+
],
|
|
56250
|
+
isError: true
|
|
56251
|
+
};
|
|
56252
|
+
}
|
|
56253
|
+
});
|
|
56254
|
+
server.registerTool("send_message", {
|
|
56255
|
+
title: "Send Message to ChatGPT",
|
|
56256
|
+
description: "Send a message to ChatGPT and wait for the response. Requires ChatGPT to be in IDLE state.",
|
|
56257
|
+
inputSchema: exports_external2.object({
|
|
56258
|
+
pageId: exports_external2.string().describe("Page ID of the ChatGPT tab"),
|
|
56259
|
+
text: exports_external2.string().describe("Message to send to ChatGPT"),
|
|
56260
|
+
timeout: exports_external2.number().optional().describe("Timeout in milliseconds (default: 120000)")
|
|
56261
|
+
})
|
|
56262
|
+
}, async ({ pageId, text, timeout }) => {
|
|
56263
|
+
if (!sessionManager) {
|
|
56264
|
+
return {
|
|
56265
|
+
content: [
|
|
56266
|
+
{
|
|
56267
|
+
type: "text",
|
|
56268
|
+
text: "Error: SessionManager not initialized"
|
|
56269
|
+
}
|
|
56270
|
+
],
|
|
56271
|
+
isError: true
|
|
56272
|
+
};
|
|
56273
|
+
}
|
|
56274
|
+
try {
|
|
56275
|
+
const result = await sessionManager.sendCommand(pageId, "sendMessage", { text, timeout });
|
|
56276
|
+
return {
|
|
56277
|
+
content: [
|
|
56278
|
+
{
|
|
56279
|
+
type: "text",
|
|
56280
|
+
text: `ChatGPT response (turn ${result.turn}, ${result.duration}ms):
|
|
56238
56281
|
|
|
56239
56282
|
${result.text}`
|
|
56240
|
-
|
|
56241
|
-
|
|
56242
|
-
|
|
56243
|
-
|
|
56283
|
+
}
|
|
56284
|
+
]
|
|
56285
|
+
};
|
|
56286
|
+
} catch (error) {
|
|
56287
|
+
return {
|
|
56288
|
+
content: [
|
|
56289
|
+
{
|
|
56290
|
+
type: "text",
|
|
56291
|
+
text: `Error: ${error.message}`
|
|
56292
|
+
}
|
|
56293
|
+
],
|
|
56294
|
+
isError: true
|
|
56295
|
+
};
|
|
56296
|
+
}
|
|
56297
|
+
});
|
|
56298
|
+
server.registerTool("get_last_message", {
|
|
56299
|
+
title: "Get Last ChatGPT Message",
|
|
56300
|
+
description: "Get the most recent message from ChatGPT",
|
|
56301
|
+
inputSchema: exports_external2.object({
|
|
56302
|
+
pageId: exports_external2.string().describe("Page ID of the ChatGPT tab")
|
|
56303
|
+
})
|
|
56304
|
+
}, async ({ pageId }) => {
|
|
56305
|
+
if (!sessionManager) {
|
|
56306
|
+
return {
|
|
56307
|
+
content: [
|
|
56308
|
+
{
|
|
56309
|
+
type: "text",
|
|
56310
|
+
text: "Error: SessionManager not initialized"
|
|
56311
|
+
}
|
|
56312
|
+
],
|
|
56313
|
+
isError: true
|
|
56314
|
+
};
|
|
56315
|
+
}
|
|
56316
|
+
try {
|
|
56317
|
+
const result = await sessionManager.sendCommand(pageId, "getLastMessage", {});
|
|
56318
|
+
if (result.text) {
|
|
56244
56319
|
return {
|
|
56245
56320
|
content: [
|
|
56246
56321
|
{
|
|
56247
56322
|
type: "text",
|
|
56248
|
-
text:
|
|
56323
|
+
text: result.text
|
|
56249
56324
|
}
|
|
56250
|
-
]
|
|
56251
|
-
isError: true
|
|
56325
|
+
]
|
|
56252
56326
|
};
|
|
56253
|
-
}
|
|
56254
|
-
});
|
|
56255
|
-
server.registerTool("get_last_message", {
|
|
56256
|
-
title: "Get Last ChatGPT Message",
|
|
56257
|
-
description: "Get the most recent message from ChatGPT",
|
|
56258
|
-
inputSchema: exports_external2.object({
|
|
56259
|
-
pageId: exports_external2.string().describe("Page ID of the ChatGPT tab")
|
|
56260
|
-
})
|
|
56261
|
-
}, async ({ pageId }) => {
|
|
56262
|
-
try {
|
|
56263
|
-
const result = await sessionManager.sendCommand(pageId, "getLastMessage", {});
|
|
56264
|
-
if (result.text) {
|
|
56265
|
-
return {
|
|
56266
|
-
content: [
|
|
56267
|
-
{
|
|
56268
|
-
type: "text",
|
|
56269
|
-
text: result.text
|
|
56270
|
-
}
|
|
56271
|
-
]
|
|
56272
|
-
};
|
|
56273
|
-
} else {
|
|
56274
|
-
return {
|
|
56275
|
-
content: [
|
|
56276
|
-
{
|
|
56277
|
-
type: "text",
|
|
56278
|
-
text: "No message found"
|
|
56279
|
-
}
|
|
56280
|
-
]
|
|
56281
|
-
};
|
|
56282
|
-
}
|
|
56283
|
-
} catch (error) {
|
|
56327
|
+
} else {
|
|
56284
56328
|
return {
|
|
56285
56329
|
content: [
|
|
56286
56330
|
{
|
|
56287
56331
|
type: "text",
|
|
56288
|
-
text:
|
|
56332
|
+
text: "No message found"
|
|
56289
56333
|
}
|
|
56290
|
-
]
|
|
56291
|
-
isError: true
|
|
56334
|
+
]
|
|
56292
56335
|
};
|
|
56293
56336
|
}
|
|
56294
|
-
})
|
|
56295
|
-
|
|
56337
|
+
} catch (error) {
|
|
56338
|
+
return {
|
|
56339
|
+
content: [
|
|
56340
|
+
{
|
|
56341
|
+
type: "text",
|
|
56342
|
+
text: `Error: ${error.message}`
|
|
56343
|
+
}
|
|
56344
|
+
],
|
|
56345
|
+
isError: true
|
|
56346
|
+
};
|
|
56347
|
+
}
|
|
56348
|
+
});
|
|
56296
56349
|
return server;
|
|
56297
56350
|
};
|
|
56298
56351
|
var McpServer_default = createMcpServer;
|
|
@@ -56872,9 +56925,18 @@ var create8 = (options = {}) => {
|
|
|
56872
56925
|
sessions.clear();
|
|
56873
56926
|
connectionToPageId.clear();
|
|
56874
56927
|
};
|
|
56928
|
+
const getAllSessions = () => {
|
|
56929
|
+
return Array.from(sessions.values()).map((session) => ({
|
|
56930
|
+
pageId: session.pageId,
|
|
56931
|
+
state: session.state,
|
|
56932
|
+
capabilities: session.capabilities,
|
|
56933
|
+
version: session.version
|
|
56934
|
+
}));
|
|
56935
|
+
};
|
|
56875
56936
|
return Object.freeze({
|
|
56876
56937
|
getSession,
|
|
56877
56938
|
getPageIdForConnection,
|
|
56939
|
+
getAllSessions,
|
|
56878
56940
|
handleHello,
|
|
56879
56941
|
handlePongWithConnection,
|
|
56880
56942
|
handleResponse,
|
|
@@ -56912,4 +56974,4 @@ ${signal} received, shutting down gracefully...`);
|
|
|
56912
56974
|
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
56913
56975
|
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
56914
56976
|
|
|
56915
|
-
//# debugId=
|
|
56977
|
+
//# debugId=8D10CA39C678E94C64756E2164756E21
|