@alexsun-top/opencode-chat-room 0.6.7 → 0.6.8
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/CHANGELOG.md +15 -0
- package/README.md +6 -3
- package/README.zh-CN.md +7 -3
- package/docs/administrator-rooms.md +7 -2
- package/package.json +4 -1
- package/plugin.ts +38 -8
- package/server/assets/base.css +228 -28
- package/server/assets/chat/admin-badge.js +28 -6
- package/server/assets/chat/admin.js +7 -1
- package/server/assets/chat/attachment-store.js +106 -0
- package/server/assets/chat/attachments.js +201 -21
- package/server/assets/chat/events.js +28 -8
- package/server/assets/chat/image-zoom.js +86 -2
- package/server/assets/chat/index.js +8 -0
- package/server/assets/chat/install-prompt.js +82 -0
- package/server/assets/chat/join-requests.js +355 -0
- package/server/assets/chat/markdown.js +54 -6
- package/server/assets/chat/members.js +4 -2
- package/server/assets/chat/message-polling.js +24 -3
- package/server/assets/chat/messages.js +6 -4
- package/server/assets/chat/questions.js +10 -6
- package/server/assets/chat/recall.js +279 -0
- package/server/assets/chat/reminders.js +52 -8
- package/server/assets/chat/replies.js +1 -1
- package/server/assets/chat/room-list.js +14 -5
- package/server/assets/chat/room-watcher.js +5 -1
- package/server/assets/chat/rooms.js +16 -4
- package/server/assets/chat/shortcuts.js +254 -0
- package/server/assets/chat/state.js +73 -14
- package/server/assets/chat/system-messages.js +3 -0
- package/server/assets/conversation.css +2 -2
- package/server/assets/keyboard-hints.css +51 -0
- package/server/assets/recall.css +29 -0
- package/server/assets/responsive.css +38 -13
- package/server/chat-server.ts +55 -66
- package/server/chat.html +146 -16
- package/server/inbox.ts +1 -1
- package/server/join-requests.ts +106 -0
- package/server/message-recall-routes.ts +37 -0
- package/server/newrooms.ts +9 -0
- package/server/room-join.ts +59 -0
- package/server/room-owner.ts +3 -20
- package/server/room-payload.ts +2 -0
- package/server/sw.js +1 -0
- package/server/wake.ts +45 -16
- package/skills/chatroom/SKILL.md +32 -0
- package/src/README.md +5 -3
- package/src/agent/admin-client.ts +28 -4
- package/src/center/center-client.ts +81 -4
- package/src/center/center-inbox.ts +35 -10
- package/src/center/center-wake.ts +25 -12
- package/src/center/message-ids.ts +7 -0
- package/src/center/notification-budget.ts +16 -0
- package/src/center/queue.ts +14 -4
- package/src/rooms/room-service.ts +10 -1
- package/src/runtime/plugin-notifications.ts +37 -11
- package/src/runtime/v2-plugin.ts +1 -1
- package/src/state/roles.ts +34 -0
- package/src/state/sqlite-state.ts +196 -27
- package/src/state/store.ts +22 -3
- package/src/tests/announcement-board.ts +9 -0
package/src/state/store.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import RoomService, { type Message, type Room } from "../rooms/room-service.ts";
|
|
7
|
-
import { acknowledgeQueued as sqliteAcknowledgeQueued, acknowledgeRead as sqliteAcknowledgeRead, answerQuestion as sqliteAnswerQuestion, appendRoomMessage as sqliteAppendRoomMessage, sendReply as sqliteSendReply, readHistoryPage, readInboxPage as sqliteInboxPage, readMessageReceipts, readQuestionExcerpt as sqliteQuestionExcerpt, readQuestions as sqliteReadQuestions, countOpenQuestions as sqliteCountOpenQuestions, readSqliteState, readUnreadPage, writeMessageReceipts, writePresenceState, writeSqliteState, type HistoryMessage } from "./sqlite-state.ts";
|
|
7
|
+
import { acknowledgeQueued as sqliteAcknowledgeQueued, acknowledgeRead as sqliteAcknowledgeRead, answerQuestion as sqliteAnswerQuestion, appendRoomMessage as sqliteAppendRoomMessage, sendReply as sqliteSendReply, readHistoryPage, readInboxPage as sqliteInboxPage, readMessageReceipts, readQuestionExcerpt as sqliteQuestionExcerpt, readQuestions as sqliteReadQuestions, countOpenQuestions as sqliteCountOpenQuestions, readSqliteState, readUnreadPage, recallMessage as sqliteRecallMessage, revealMessageContent as sqliteRevealMessageContent, isMessageRecalled, recalledMessageIDs as sqliteRecalledMessageIDs, writeMessageReceipts, writePresenceState, writeSqliteState, type HistoryMessage, type JoinRequest, listJoinRequests as sqliteListJoinRequests, readJoinRequest as sqliteReadJoinRequest, type RecallMessageResult, type RevealMessageResult } from "./sqlite-state.ts";
|
|
8
|
+
export type { JoinRequest, RecallMessageResult, RevealMessageResult } from "./sqlite-state.ts";
|
|
8
9
|
|
|
9
10
|
export function statePath(): string {
|
|
10
11
|
// JSON path remains the migration source; SQLite lives beside it.
|
|
@@ -31,7 +32,7 @@ export async function readUnreadMessages(roomID: string, afterTs: number, limit
|
|
|
31
32
|
export async function readInboxMessages(sessionID: string, roomID: string | null, excludeSelf: boolean, limit = 100, afterTs?: number) {
|
|
32
33
|
return sqliteInboxPage(databasePath(), sessionID, roomID, excludeSelf, limit, afterTs);
|
|
33
34
|
}
|
|
34
|
-
export async function readHistory(roomID: string, beforeSeq?: number, limit = 100, exclude?: { sessionID: string; name: string }): Promise<{ messages: HistoryMessage[]; nextBeforeSeq: number | null; hasMore: boolean }> {
|
|
35
|
+
export async function readHistory(roomID: string, beforeSeq?: number, limit = 100, exclude?: { sessionID: string; name: string }): Promise<{ messages: HistoryMessage[]; nextBeforeSeq: number | null; hasMore: boolean; recallVersion: number }> {
|
|
35
36
|
return readHistoryPage(databasePath(), roomID, beforeSeq, limit, exclude?.sessionID, exclude?.name);
|
|
36
37
|
}
|
|
37
38
|
export async function readQuestions(roomID: string): Promise<Message[]> { return sqliteReadQuestions(databasePath(), roomID); }
|
|
@@ -42,6 +43,24 @@ export async function answerQuestion(roomID: string, questionID: string, session
|
|
|
42
43
|
export async function sendReply(roomID: string, targetID: string, sessionID: string, text: string) { return sqliteSendReply(databasePath(), roomID, targetID, sessionID, text); }
|
|
43
44
|
export function appendRoomMessage(roomID: string, sessionID: string, text: string, isQuestion: boolean) { return sqliteAppendRoomMessage(databasePath(), roomID, sessionID, text, isQuestion); }
|
|
44
45
|
export async function readQuestionExcerpt(roomID: string, questionID: string) { return sqliteQuestionExcerpt(databasePath(), roomID, questionID); }
|
|
46
|
+
export function readJoinRequest(roomID: string, sessionID: string): Promise<JoinRequest | undefined> { return sqliteReadJoinRequest(databasePath(), roomID, sessionID); }
|
|
47
|
+
export function listJoinRequests(roomID: string, agentOnly = false): Promise<JoinRequest[]> { return sqliteListJoinRequests(databasePath(), roomID, agentOnly); }
|
|
48
|
+
|
|
49
|
+
// Soft recall + member-only reveal. Same implementation standalone and central.
|
|
50
|
+
export function recallMessage(roomID: string, messageID: string, sessionID: string): Promise<RecallMessageResult> {
|
|
51
|
+
return sqliteRecallMessage(databasePath(), roomID, messageID, sessionID);
|
|
52
|
+
}
|
|
53
|
+
export function revealMessageContent(roomID: string, messageID: string, sessionID: string): Promise<RevealMessageResult> {
|
|
54
|
+
return sqliteRevealMessageContent(databasePath(), roomID, messageID, sessionID);
|
|
55
|
+
}
|
|
56
|
+
export function messageRecalled(roomID: string, messageID: string): Promise<boolean> {
|
|
57
|
+
return isMessageRecalled(databasePath(), roomID, messageID);
|
|
58
|
+
}
|
|
59
|
+
// Authoritative batch recall check for pending notification batches; independent
|
|
60
|
+
// of the in-memory 500-message window.
|
|
61
|
+
export async function recalledMessageIDs(roomID: string, messageIDs: string[]): Promise<Set<string>> {
|
|
62
|
+
return new Set(await sqliteRecalledMessageIDs(databasePath(), roomID, messageIDs));
|
|
63
|
+
}
|
|
45
64
|
|
|
46
65
|
export async function loadRooms(): Promise<Room[]> {
|
|
47
66
|
return (await readSqliteState(databasePath())).rooms;
|
|
@@ -175,7 +194,7 @@ export function formatRoom(svc: RoomService, room: Room): string {
|
|
|
175
194
|
.join(", ");
|
|
176
195
|
const lines = [`Room ${room.id} (${room.name}) \u2014 members: ${members}`];
|
|
177
196
|
for (const m of room.messages.slice(-5)) {
|
|
178
|
-
lines.push(`[${timeOf(m.createdAt)}] ${senderName(svc, m)}: ${m.text}`);
|
|
197
|
+
lines.push(`[${timeOf(m.createdAt)}] ${senderName(svc, m)}: ${m.recalledAt ? "[recalled message]" : m.text}`);
|
|
179
198
|
}
|
|
180
199
|
return lines.join("\n");
|
|
181
200
|
}
|
|
@@ -7,6 +7,15 @@ export async function announcementBoardWorks(page: any, artifacts: string) {
|
|
|
7
7
|
await page.locator("#announcementPanel").waitFor({ state: "visible" });
|
|
8
8
|
await page.waitForFunction(() => document.querySelector("#announcementStatus")?.textContent === "No announcements yet.");
|
|
9
9
|
await openAnnouncement(page);
|
|
10
|
+
// The editor is a writing surface, not a four-line dialog.
|
|
11
|
+
const layout = await page.locator("#announcementDialog").evaluate((node: HTMLElement) => {
|
|
12
|
+
const box = node.getBoundingClientRect(), area = document.querySelector<HTMLElement>("#announcementContent")!.getBoundingClientRect();
|
|
13
|
+
return { width: box.width, left: box.left, right: box.right, areaHeight: area.height, viewport: innerWidth, scrollY: document.scrollingElement!.scrollTop };
|
|
14
|
+
});
|
|
15
|
+
expect(layout.width).toBeGreaterThan(700);
|
|
16
|
+
expect(layout.areaHeight).toBeGreaterThan(240);
|
|
17
|
+
expect(layout.left).toBeGreaterThanOrEqual(0); expect(layout.right).toBeLessThanOrEqual(layout.viewport);
|
|
18
|
+
expect(layout.scrollY).toBe(0);
|
|
10
19
|
await page.locator("#announcementName").fill(name);
|
|
11
20
|
await page.locator("#announcementContent").fill(content);
|
|
12
21
|
await page.locator("#btnSaveAnnouncement").click();
|