@hasna/conversations 0.2.45 → 0.2.46
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/bin/hook.js +35 -0
- package/bin/index.js +635 -84
- package/bin/mcp.js +393 -63
- package/dist/index.d.ts +1 -0
- package/dist/index.js +159 -0
- package/dist/lib/space-notifications.d.ts +19 -0
- package/dist/lib/space-notifications.test.d.ts +1 -0
- package/dist/mcp/channel.d.ts +4 -1
- package/dist/mcp/channel.test.d.ts +1 -0
- package/dist/mcp/tools/messaging.d.ts +1 -1
- package/dist/mcp/tools/spaces.d.ts +2 -0
- package/dist/types.d.ts +17 -0
- package/package.json +1 -1
package/bin/hook.js
CHANGED
|
@@ -9656,6 +9656,18 @@ function getDb() {
|
|
|
9656
9656
|
PRIMARY KEY (space, agent)
|
|
9657
9657
|
)
|
|
9658
9658
|
`);
|
|
9659
|
+
db.exec(`
|
|
9660
|
+
CREATE TABLE IF NOT EXISTS space_subscriptions (
|
|
9661
|
+
space TEXT NOT NULL REFERENCES spaces(name),
|
|
9662
|
+
agent TEXT NOT NULL,
|
|
9663
|
+
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%f', 'now')),
|
|
9664
|
+
preview_chars INTEGER NOT NULL DEFAULT 140,
|
|
9665
|
+
since_message_id INTEGER NOT NULL DEFAULT 0,
|
|
9666
|
+
PRIMARY KEY (space, agent)
|
|
9667
|
+
)
|
|
9668
|
+
`);
|
|
9669
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_space_subscriptions_agent ON space_subscriptions(agent)");
|
|
9670
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_space_subscriptions_space ON space_subscriptions(space)");
|
|
9659
9671
|
db.exec(`
|
|
9660
9672
|
CREATE TABLE IF NOT EXISTS agent_presence (
|
|
9661
9673
|
id TEXT NOT NULL,
|
|
@@ -9696,6 +9708,16 @@ function getDb() {
|
|
|
9696
9708
|
)
|
|
9697
9709
|
`);
|
|
9698
9710
|
db.exec("CREATE INDEX IF NOT EXISTS idx_reactions_message ON reactions(message_id)");
|
|
9711
|
+
db.exec(`
|
|
9712
|
+
CREATE TABLE IF NOT EXISTS space_notification_reads (
|
|
9713
|
+
agent TEXT NOT NULL,
|
|
9714
|
+
message_id INTEGER NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
|
|
9715
|
+
read_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%f', 'now')),
|
|
9716
|
+
PRIMARY KEY (agent, message_id)
|
|
9717
|
+
)
|
|
9718
|
+
`);
|
|
9719
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_space_notification_reads_agent ON space_notification_reads(agent)");
|
|
9720
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_space_notification_reads_message ON space_notification_reads(message_id)");
|
|
9699
9721
|
const existingTables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all();
|
|
9700
9722
|
const tableNames = existingTables.map((t) => t.name);
|
|
9701
9723
|
if (tableNames.includes("channels") && tableNames.includes("spaces")) {
|
|
@@ -9743,6 +9765,19 @@ function getDb() {
|
|
|
9743
9765
|
if (!spaceColNames.includes("topic")) {
|
|
9744
9766
|
db.exec("ALTER TABLE spaces ADD COLUMN topic TEXT");
|
|
9745
9767
|
}
|
|
9768
|
+
const spaceSubscriptionCols = db.prepare("PRAGMA table_info(space_subscriptions)").all();
|
|
9769
|
+
const spaceSubscriptionColNames = spaceSubscriptionCols.map((c) => c.name);
|
|
9770
|
+
if (!spaceSubscriptionColNames.includes("since_message_id")) {
|
|
9771
|
+
db.exec("ALTER TABLE space_subscriptions ADD COLUMN since_message_id INTEGER NOT NULL DEFAULT 0");
|
|
9772
|
+
db.exec(`
|
|
9773
|
+
UPDATE space_subscriptions
|
|
9774
|
+
SET since_message_id = COALESCE(
|
|
9775
|
+
(SELECT MAX(m.id) FROM messages m WHERE m.space = space_subscriptions.space),
|
|
9776
|
+
0
|
|
9777
|
+
)
|
|
9778
|
+
WHERE since_message_id = 0
|
|
9779
|
+
`);
|
|
9780
|
+
}
|
|
9746
9781
|
const msgCols2 = db.prepare("PRAGMA table_info(messages)").all();
|
|
9747
9782
|
const colNames2 = msgCols2.map((c) => c.name);
|
|
9748
9783
|
if (!colNames2.includes("edited_at")) {
|