@kelceyp/caw-server 0.0.8 → 0.0.10
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 +190 -1
- package/dist/main.js.map +3 -3
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -56530,6 +56530,195 @@ ${result.text}` }]
|
|
|
56530
56530
|
};
|
|
56531
56531
|
}
|
|
56532
56532
|
});
|
|
56533
|
+
server.registerTool("get_message_count", {
|
|
56534
|
+
title: "Get Message Count",
|
|
56535
|
+
description: "Get the total number of turns (message pairs) in the conversation",
|
|
56536
|
+
inputSchema: exports_external2.object({
|
|
56537
|
+
pageId: exports_external2.string().describe("Page ID of the ChatGPT tab")
|
|
56538
|
+
})
|
|
56539
|
+
}, async ({ pageId }) => {
|
|
56540
|
+
if (!sessionManager) {
|
|
56541
|
+
return {
|
|
56542
|
+
content: [{ type: "text", text: "Error: SessionManager not initialized" }],
|
|
56543
|
+
isError: true
|
|
56544
|
+
};
|
|
56545
|
+
}
|
|
56546
|
+
const claimCheck = verifyClaimedError(pageId);
|
|
56547
|
+
if (claimCheck.error) {
|
|
56548
|
+
return {
|
|
56549
|
+
content: [{ type: "text", text: `Error: ${claimCheck.message}` }],
|
|
56550
|
+
isError: true
|
|
56551
|
+
};
|
|
56552
|
+
}
|
|
56553
|
+
try {
|
|
56554
|
+
const result = await sessionManager.sendCommand(pageId, "getMessageCount", {});
|
|
56555
|
+
return {
|
|
56556
|
+
content: [{ type: "text", text: `Message count: ${result.count} turns` }]
|
|
56557
|
+
};
|
|
56558
|
+
} catch (error) {
|
|
56559
|
+
return {
|
|
56560
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
56561
|
+
isError: true
|
|
56562
|
+
};
|
|
56563
|
+
}
|
|
56564
|
+
});
|
|
56565
|
+
server.registerTool("get_message", {
|
|
56566
|
+
title: "Get Message",
|
|
56567
|
+
description: 'Get a specific message by turn number and role, or by address notation (e.g., "5u", "3a", "7u.5-10")',
|
|
56568
|
+
inputSchema: exports_external2.object({
|
|
56569
|
+
pageId: exports_external2.string().describe("Page ID of the ChatGPT tab"),
|
|
56570
|
+
turn: exports_external2.number().optional().describe("Turn number (1-based)"),
|
|
56571
|
+
role: exports_external2.enum(["user", "assistant"]).optional().describe("Message role"),
|
|
56572
|
+
address: exports_external2.string().optional().describe('Address notation (e.g., "5u", "3a", "7u.5-10")')
|
|
56573
|
+
})
|
|
56574
|
+
}, async ({ pageId, turn, role, address }) => {
|
|
56575
|
+
if (!sessionManager) {
|
|
56576
|
+
return {
|
|
56577
|
+
content: [{ type: "text", text: "Error: SessionManager not initialized" }],
|
|
56578
|
+
isError: true
|
|
56579
|
+
};
|
|
56580
|
+
}
|
|
56581
|
+
const claimCheck = verifyClaimedError(pageId);
|
|
56582
|
+
if (claimCheck.error) {
|
|
56583
|
+
return {
|
|
56584
|
+
content: [{ type: "text", text: `Error: ${claimCheck.message}` }],
|
|
56585
|
+
isError: true
|
|
56586
|
+
};
|
|
56587
|
+
}
|
|
56588
|
+
if (!address && (turn === undefined || !role)) {
|
|
56589
|
+
return {
|
|
56590
|
+
content: [{ type: "text", text: "Error: Either address or (turn + role) is required" }],
|
|
56591
|
+
isError: true
|
|
56592
|
+
};
|
|
56593
|
+
}
|
|
56594
|
+
try {
|
|
56595
|
+
const result = await sessionManager.sendCommand(pageId, "getMessage", { turn, role, address });
|
|
56596
|
+
if (result.error) {
|
|
56597
|
+
return {
|
|
56598
|
+
content: [{ type: "text", text: `Error: ${result.error}` }],
|
|
56599
|
+
isError: true
|
|
56600
|
+
};
|
|
56601
|
+
}
|
|
56602
|
+
if (result.text) {
|
|
56603
|
+
return {
|
|
56604
|
+
content: [{ type: "text", text: result.text }]
|
|
56605
|
+
};
|
|
56606
|
+
} else {
|
|
56607
|
+
return {
|
|
56608
|
+
content: [{ type: "text", text: "Message not found" }]
|
|
56609
|
+
};
|
|
56610
|
+
}
|
|
56611
|
+
} catch (error) {
|
|
56612
|
+
return {
|
|
56613
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
56614
|
+
isError: true
|
|
56615
|
+
};
|
|
56616
|
+
}
|
|
56617
|
+
});
|
|
56618
|
+
server.registerTool("get_conversation", {
|
|
56619
|
+
title: "Get Conversation",
|
|
56620
|
+
description: "Get the full conversation history as a structured array of messages",
|
|
56621
|
+
inputSchema: exports_external2.object({
|
|
56622
|
+
pageId: exports_external2.string().describe("Page ID of the ChatGPT tab")
|
|
56623
|
+
})
|
|
56624
|
+
}, async ({ pageId }) => {
|
|
56625
|
+
if (!sessionManager) {
|
|
56626
|
+
return {
|
|
56627
|
+
content: [{ type: "text", text: "Error: SessionManager not initialized" }],
|
|
56628
|
+
isError: true
|
|
56629
|
+
};
|
|
56630
|
+
}
|
|
56631
|
+
const claimCheck = verifyClaimedError(pageId);
|
|
56632
|
+
if (claimCheck.error) {
|
|
56633
|
+
return {
|
|
56634
|
+
content: [{ type: "text", text: `Error: ${claimCheck.message}` }],
|
|
56635
|
+
isError: true
|
|
56636
|
+
};
|
|
56637
|
+
}
|
|
56638
|
+
try {
|
|
56639
|
+
const result = await sessionManager.sendCommand(pageId, "getConversation", {});
|
|
56640
|
+
const messages = result.messages || [];
|
|
56641
|
+
if (messages.length === 0) {
|
|
56642
|
+
return {
|
|
56643
|
+
content: [{ type: "text", text: "No messages in conversation" }]
|
|
56644
|
+
};
|
|
56645
|
+
}
|
|
56646
|
+
const formatted = messages.map((m) => {
|
|
56647
|
+
const roleChar = m.role === "user" ? "u" : "a";
|
|
56648
|
+
const addr = `${m.turn}${roleChar}`;
|
|
56649
|
+
const preview = m.text.length > 100 ? m.text.substring(0, 100) + "..." : m.text;
|
|
56650
|
+
return `[${addr}] ${m.role}: ${preview}`;
|
|
56651
|
+
}).join(`
|
|
56652
|
+
|
|
56653
|
+
`);
|
|
56654
|
+
return {
|
|
56655
|
+
content: [{ type: "text", text: `Conversation (${messages.length} messages):
|
|
56656
|
+
|
|
56657
|
+
${formatted}` }]
|
|
56658
|
+
};
|
|
56659
|
+
} catch (error) {
|
|
56660
|
+
return {
|
|
56661
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
56662
|
+
isError: true
|
|
56663
|
+
};
|
|
56664
|
+
}
|
|
56665
|
+
});
|
|
56666
|
+
server.registerTool("find_message", {
|
|
56667
|
+
title: "Find Message",
|
|
56668
|
+
description: "Search conversation messages using a regex pattern",
|
|
56669
|
+
inputSchema: exports_external2.object({
|
|
56670
|
+
pageId: exports_external2.string().describe("Page ID of the ChatGPT tab"),
|
|
56671
|
+
pattern: exports_external2.string().describe("Regex pattern to search for"),
|
|
56672
|
+
role: exports_external2.enum(["user", "assistant", "all"]).optional().describe("Filter by role (default: all)"),
|
|
56673
|
+
firstMatch: exports_external2.boolean().optional().describe("Stop after first match (default: false)"),
|
|
56674
|
+
caseInsensitive: exports_external2.boolean().optional().describe("Case insensitive search (default: false)")
|
|
56675
|
+
})
|
|
56676
|
+
}, async ({ pageId, pattern, role, firstMatch, caseInsensitive }) => {
|
|
56677
|
+
if (!sessionManager) {
|
|
56678
|
+
return {
|
|
56679
|
+
content: [{ type: "text", text: "Error: SessionManager not initialized" }],
|
|
56680
|
+
isError: true
|
|
56681
|
+
};
|
|
56682
|
+
}
|
|
56683
|
+
const claimCheck = verifyClaimedError(pageId);
|
|
56684
|
+
if (claimCheck.error) {
|
|
56685
|
+
return {
|
|
56686
|
+
content: [{ type: "text", text: `Error: ${claimCheck.message}` }],
|
|
56687
|
+
isError: true
|
|
56688
|
+
};
|
|
56689
|
+
}
|
|
56690
|
+
try {
|
|
56691
|
+
const result = await sessionManager.sendCommand(pageId, "findMessage", {
|
|
56692
|
+
pattern,
|
|
56693
|
+
role: role || "all",
|
|
56694
|
+
firstMatch: firstMatch || false,
|
|
56695
|
+
caseInsensitive: caseInsensitive || false
|
|
56696
|
+
});
|
|
56697
|
+
if (result.error) {
|
|
56698
|
+
return {
|
|
56699
|
+
content: [{ type: "text", text: `Error: ${result.error}` }],
|
|
56700
|
+
isError: true
|
|
56701
|
+
};
|
|
56702
|
+
}
|
|
56703
|
+
const matches = result.matches || [];
|
|
56704
|
+
if (matches.length === 0) {
|
|
56705
|
+
return {
|
|
56706
|
+
content: [{ type: "text", text: "No matches found" }]
|
|
56707
|
+
};
|
|
56708
|
+
}
|
|
56709
|
+
const formatted = matches.map((m) => `• ${m.address} (turn ${m.turn}, ${m.role})`).join(`
|
|
56710
|
+
`);
|
|
56711
|
+
return {
|
|
56712
|
+
content: [{ type: "text", text: `Found ${result.count} match(es):
|
|
56713
|
+
${formatted}` }]
|
|
56714
|
+
};
|
|
56715
|
+
} catch (error) {
|
|
56716
|
+
return {
|
|
56717
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
56718
|
+
isError: true
|
|
56719
|
+
};
|
|
56720
|
+
}
|
|
56721
|
+
});
|
|
56533
56722
|
return server;
|
|
56534
56723
|
};
|
|
56535
56724
|
var McpServer_default = createMcpServer;
|
|
@@ -57413,4 +57602,4 @@ ${signal} received, shutting down gracefully...`);
|
|
|
57413
57602
|
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
57414
57603
|
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
57415
57604
|
|
|
57416
|
-
//# debugId=
|
|
57605
|
+
//# debugId=36327466799C28A164756E2164756E21
|