@alexsun-top/opencode-chat-room 0.5.3 → 0.5.5
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 +44 -0
- package/README.md +13 -1
- package/README.zh-CN.md +13 -1
- package/docs/administrator-rooms.md +6 -8
- package/package.json +2 -1
- package/server/admin-auth.ts +4 -2
- package/server/assets/base.css +5 -1
- package/server/assets/chat/admin.js +4 -9
- package/server/assets/chat/announcements.js +17 -1
- package/server/assets/chat/attachments.js +4 -1
- package/server/assets/chat/editor.js +15 -2
- package/server/assets/chat/events.js +25 -7
- package/server/assets/chat/markdown.js +31 -11
- package/server/assets/chat/mentions.js +3 -1
- package/server/assets/chat/messages.js +96 -32
- package/server/assets/chat/questions.js +12 -6
- package/server/assets/chat/reminders.js +4 -4
- package/server/assets/chat/replies.js +1 -5
- package/server/assets/chat/room-watcher.js +12 -4
- package/server/assets/chat/rooms.js +17 -6
- package/server/assets/chat/state.js +8 -7
- package/server/assets/chat/system-messages.js +2 -1
- package/server/assets/conversation.css +1 -3
- package/server/chat-server.ts +39 -38
- package/server/chat.html +2 -3
- package/server/json-body.ts +8 -0
- package/server/member-routes.ts +9 -11
- package/server/wake.ts +11 -2
- package/skills/chatroom/SKILL.md +5 -2
- package/src/admin-client.ts +3 -3
- package/src/agent-receipts.ts +3 -3
- package/src/center-inbox.ts +2 -2
- package/src/plugin-notifications.ts +6 -3
- package/src/resources.ts +4 -1
- package/src/sqlite-state.ts +56 -5
- package/src/store.ts +11 -4
- package/src/v2-plugin.ts +17 -0
- package/src/supervision-inbox.ts +0 -50
package/src/supervision-inbox.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { request, type CenterOpts } from "./center-client";
|
|
2
|
-
import { sendAsyncNotification, sendQueue, type QueueTransport } from "./queue-transport";
|
|
3
|
-
import { loadAdminCapability } from "./admin-credentials";
|
|
4
|
-
import { protectedAdminRequest } from "./admin-client";
|
|
5
|
-
|
|
6
|
-
type Delivery = { id: string; admissionID?: string; adminRoomId?: string; kind: "supervision"; text: string };
|
|
7
|
-
type Inbox = { deliveries?: Delivery[]; supervisionRoomIds?: string[] };
|
|
8
|
-
|
|
9
|
-
function promptText(item: Delivery): string {
|
|
10
|
-
return `<supervision>Reminder from admin room ${item.adminRoomId}. Use admin(action="admin_overview", roomId="${item.adminRoomId}") to review it.\n${item.text}</supervision>`;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async function push(opts: CenterOpts, sessionID: string, ownerID: string, transport: QueueTransport,
|
|
14
|
-
item: Delivery, capability?: string): Promise<void> {
|
|
15
|
-
const raw = promptText(item), text = capability ? raw.replaceAll(capability, "[redacted]") : raw;
|
|
16
|
-
const admissionID = item.admissionID ?? item.id;
|
|
17
|
-
const result = transport.protocol === "v1" ? await sendAsyncNotification(transport, sessionID, text)
|
|
18
|
-
: await sendQueue(transport, sessionID, text, admissionID, "steer");
|
|
19
|
-
if (result !== "delivered") return;
|
|
20
|
-
const body = { id: item.id, sessionID, receiverOwnerID: ownerID };
|
|
21
|
-
if (capability) await protectedAdminRequest(opts, "/supervision/ack", "POST", capability, sessionID, ownerID, body);
|
|
22
|
-
else await request(opts, "/supervision/ack", "POST", body);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export async function checkSupervisionInbox(opts: CenterOpts, sessionID: string, transport: QueueTransport): Promise<void> {
|
|
26
|
-
if (!opts.center || (transport.protocol === "v2" && !transport.receiverOwnerID)) return;
|
|
27
|
-
const ownerID = transport.receiverOwnerID ?? "";
|
|
28
|
-
let inbox: Inbox;
|
|
29
|
-
try {
|
|
30
|
-
const query = new URLSearchParams({ sessionID, receiverOwnerID: ownerID });
|
|
31
|
-
inbox = await request(opts, `/supervision/inbox?${query}`, "GET") as Inbox;
|
|
32
|
-
} catch { return; }
|
|
33
|
-
if (!inbox || typeof inbox !== "object") return;
|
|
34
|
-
|
|
35
|
-
const hintedRooms = Array.isArray(inbox.supervisionRoomIds)
|
|
36
|
-
? [...new Set(inbox.supervisionRoomIds.filter((room): room is string => typeof room === "string" && !!room))].slice(0, 50)
|
|
37
|
-
: [];
|
|
38
|
-
for (const roomId of hintedRooms) {
|
|
39
|
-
const capability = await loadAdminCapability({ center: opts.center, roomId, sessionID, ownerID });
|
|
40
|
-
if (!capability) continue;
|
|
41
|
-
try {
|
|
42
|
-
const query = new URLSearchParams({ sessionID, receiverOwnerID: ownerID, adminRoomId: roomId });
|
|
43
|
-
const result = await protectedAdminRequest(opts, `/supervision/inbox?${query}`, "GET", capability, sessionID, ownerID) as Inbox;
|
|
44
|
-
for (const item of (Array.isArray(result.deliveries) ? result.deliveries : []).slice(0, 50)) {
|
|
45
|
-
if (item?.kind !== "supervision" || item.adminRoomId !== roomId || !item.id || typeof item.text !== "string") continue;
|
|
46
|
-
try { await push(opts, sessionID, ownerID, transport, item, capability); } catch { /* Retry with the same server-issued ID next sweep. */ }
|
|
47
|
-
}
|
|
48
|
-
} catch { /* A room's protected feed does not block other admin rooms. */ }
|
|
49
|
-
}
|
|
50
|
-
}
|