shadok-ai 0.19.5 → 0.19.7

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/README.md CHANGED
@@ -76,6 +76,15 @@ Enter to skip; you can add it later from the web UI).
76
76
  - **Channels** — one `claude` process each, running in parallel. Renaming,
77
77
  grouping, and closing all sync live between the browser and Telegram: it's
78
78
  one list, server-owned, not two copies.
79
+ - **Rooms** — a channel with **no agent**, where people talk: same column,
80
+ same groups, same chat, nothing running behind it and no quota spent. **+ new
81
+ room** under the agents; an admin can mirror one into a Telegram topic, and a
82
+ message there lands in the room (commands answer that there is no agent
83
+ here). Closing a room archives it: it leaves the list for everyone and its
84
+ messages stay on disk. The column tells the three kinds apart at a glance —
85
+ an **agent** is a round avatar with initials, a **room** a square slate tile
86
+ with a speech bubble (and no presence dot), and an agent with **scheduled
87
+ prompts** wears a dashed ring and a clock.
79
88
  - **Groups** — on a desktop the groups live in their own **left column**: pick
80
89
  one to narrow the agents pane to it, and the global tools (Profiles, Ledger,
81
90
  Secrets, Users, Security, Telegram, Sound) stay in the header at the top. Each
@@ -1306,6 +1315,7 @@ client, or immediately on an explicit `stop` (which ends it for everyone).
1306
1315
  | `{type:"term-attach"}` · `{type:"term-detach"}` | **experimental, tmux only** — open/close the pane's raw byte pipe |
1307
1316
  | `{type:"term-input", data}` · `{type:"term-resize", cols, rows}` | raw input (base64) / match the pane to the viewport |
1308
1317
  | `{type:"stop", sessionId?}` | ends the session for all clients; `sessionId` targets another channel (zombie cleanup) |
1318
+ | `{type:"room-join", roomId}` · `{type:"room-post", roomId, text, clientId?}` | a ROOM link (people only, same-origin browser): join a room (answered with `room-history`), then post to it (fanned out as `room-message`, refusals as `room-error`). A connection is an agent link or a room link, never both — `start` is refused after `room-join` |
1309
1319
 
1310
1320
  **server → client**
1311
1321
 
@@ -0,0 +1,135 @@
1
+ import type { TgBinding } from "./channels.js";
2
+ import { type Group, type Viewer } from "./groups.js";
3
+ /**
4
+ * Rooms: channels with no agent, where PEOPLE talk.
5
+ *
6
+ * A room is deliberately NOT a row of the channel registry (`channels.ts`).
7
+ * That registry answers "which agents exist", and every consumer of it reads it
8
+ * that way: the client resumes each row, the Telegram reconciler opens a bridge
9
+ * (= spawns an agent) behind each mirrored row, `firstAgentPlan` counts rows,
10
+ * crons, kinship and the ledger list them. A row with no process behind it
11
+ * would make each of those either spawn a `claude` or misbehave, and the only
12
+ * thing a room must never do is run one. A separate registry makes that
13
+ * mistake impossible rather than merely checked. Design:
14
+ * docs/superpowers/specs/2026-11-02-human-rooms-design.md.
15
+ *
16
+ * Storage, per launch dir (keyed like channels, crons and the ledger):
17
+ * ~/.shadok-ai/rooms/<key>.json the room list (rewritten atomically)
18
+ * ~/.shadok-ai/rooms/<key>.read.json per account, the last message seen
19
+ * ~/.shadok-ai/rooms/<key>/<roomId>.jsonl the messages, APPEND-ONLY
20
+ * Messages are appended and never rewritten, the reason the secret audit log is
21
+ * JSONL too: two processes never rewrite each other's lines, and a crash
22
+ * mid-write costs one truncated last line, which `parseMessages` skips.
23
+ */
24
+ export interface Room {
25
+ /** `r_` + 16 hex chars: never UUID-shaped, so it can never pass for a session id. */
26
+ id: string;
27
+ name: string;
28
+ /** Same group ids as channels: one column, one set of groups. */
29
+ group?: string | null;
30
+ createdBy: string;
31
+ createdAt: number;
32
+ /** Present iff the room is bound to a Telegram topic — what IS. Server-owned. */
33
+ telegram?: TgBinding | null;
34
+ /** What the user WANTS (same meaning as `Channel.mirror`). */
35
+ mirror?: boolean;
36
+ /** Closed rooms are archived, never deleted: a conversation between people is
37
+ * a record someone wants back the week after. */
38
+ archivedAt?: number;
39
+ }
40
+ export interface RoomMessage {
41
+ id: string;
42
+ ts: number;
43
+ /** Display name: the account on the web, the sender on Telegram. */
44
+ author: string;
45
+ /** Set only when the server KNOWS the account (a web session). */
46
+ account?: string;
47
+ origin: "web" | "telegram";
48
+ text: string;
49
+ /** The Telegram message id, for the mirror (dedup). */
50
+ tgMessageId?: number;
51
+ }
52
+ export declare const ROOM_ID_RE: RegExp;
53
+ export declare const ROOM_NAME_MAX = 80;
54
+ /** A room message is chat, not a document: past this it is refused, out loud. */
55
+ export declare const ROOM_TEXT_MAX = 16000;
56
+ export declare const ROOM_PAGE = 200;
57
+ export declare function newRoomId(): string;
58
+ export declare function isRoomId(s: unknown): s is string;
59
+ /** The trimmed name, or an explicit refusal. */
60
+ export declare function roomName(raw: unknown): {
61
+ ok: true;
62
+ name: string;
63
+ } | {
64
+ ok: false;
65
+ error: string;
66
+ };
67
+ /**
68
+ * The group a NEW room is filed into: the one the caller asked for, but only if
69
+ * it exists and the caller may see it; otherwise the commons (null). A caller
70
+ * can place a room in a group they belong to, never plant one in a group they
71
+ * do not — `spawnGroupForRequest`'s rule, minus the parent clause (a room has
72
+ * no launcher).
73
+ */
74
+ export declare function roomGroupFor(requested: unknown, groups: readonly Group[], viewer: Viewer | null): string | null;
75
+ /**
76
+ * The rooms a viewer may see: not archived, and the group rule of
77
+ * `visibleChannels` — no group → the commons, visible to all; a dangling group
78
+ * id → HIDDEN (fail closed, a lost group row must never reveal its rooms).
79
+ */
80
+ export declare function visibleRooms(rooms: readonly Room[], groups: readonly Group[], viewer: Viewer | null): Room[];
81
+ export declare function canSeeRoom(room: Room | undefined, groups: readonly Group[], viewer: Viewer | null): boolean;
82
+ /** Why a post is refused, or null. A `code` a client can switch on, and words. */
83
+ export declare function postRefusal(room: Room | undefined, text: unknown): {
84
+ code: string;
85
+ error: string;
86
+ } | null;
87
+ /** Pure: the list with one room's mutable fields changed. Server-owned fields
88
+ * (`id`, `createdBy`, `createdAt`, `telegram`, `archivedAt`) never move here. */
89
+ export declare function patchRoomIn(list: readonly Room[], id: string, patch: {
90
+ name?: string;
91
+ group?: string | null;
92
+ mirror?: boolean;
93
+ }): Room[];
94
+ /** Pure: parse a JSONL message file, skipping any line that is not a message
95
+ * (a truncated last line after a crash, a stray edit). */
96
+ export declare function parseMessages(raw: string): RoomMessage[];
97
+ /** Pure: the page of messages strictly before `before` (all when absent), the
98
+ * newest `limit` of them, oldest first. */
99
+ export declare function pageMessages(msgs: readonly RoomMessage[], before: number | undefined, limit?: number): RoomMessage[];
100
+ /** Pure: how many messages after `lastRead` were written by someone else. */
101
+ export declare function unreadCount(msgs: readonly RoomMessage[], lastRead: number, account: string | null): number;
102
+ /** Pure: the (live) room mirrored into this Telegram topic. */
103
+ export declare function roomForTopic(rooms: readonly Room[], chatId: number, threadId: number | undefined): Room | undefined;
104
+ /** The text a room message becomes in a Telegram topic. Pure. */
105
+ export declare function telegramLine(m: Pick<RoomMessage, "author" | "text">): string;
106
+ export declare function roomsRoot(home?: string): string;
107
+ /**
108
+ * The on-disk store. A class only so tests can point it at a scratch dir; the
109
+ * server keeps one. The message cache is keyed on the file's size: an append
110
+ * always grows it, so a stale entry is impossible without a rewrite, and the
111
+ * 4 s list poll does not re-read every room each time.
112
+ */
113
+ export declare class RoomStore {
114
+ private readonly root;
115
+ private readonly key;
116
+ private cache;
117
+ constructor(root?: string, key?: string);
118
+ private listFile;
119
+ private readFile;
120
+ private msgFile;
121
+ private writeAtomic;
122
+ list(): Room[];
123
+ save(list: Room[]): void;
124
+ get(id: string): Room | undefined;
125
+ /** Read-modify-write of ONE room; returns it, or undefined when unknown. */
126
+ update(id: string, fn: (r: Room) => Room): Room | undefined;
127
+ create(room: Room): void;
128
+ messages(id: string): RoomMessage[];
129
+ append(id: string, m: RoomMessage): void;
130
+ /** `{ [roomId]: { [account]: ts } }` */
131
+ private marks;
132
+ lastRead(id: string, account: string): number;
133
+ /** Only ever moves FORWARD: an old tab catching up must not resurrect unread. */
134
+ markRead(id: string, account: string, ts: number): void;
135
+ }
package/dist/rooms.js ADDED
@@ -0,0 +1,237 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { canSeeGroup } from "./groups.js";
6
+ import { instanceKey } from "./paths.js";
7
+ export const ROOM_ID_RE = /^r_[0-9a-f]{16}$/;
8
+ export const ROOM_NAME_MAX = 80;
9
+ /** A room message is chat, not a document: past this it is refused, out loud. */
10
+ export const ROOM_TEXT_MAX = 16_000;
11
+ export const ROOM_PAGE = 200;
12
+ export function newRoomId() {
13
+ return "r_" + randomBytes(8).toString("hex");
14
+ }
15
+ export function isRoomId(s) {
16
+ return typeof s === "string" && ROOM_ID_RE.test(s);
17
+ }
18
+ /** The trimmed name, or an explicit refusal. */
19
+ export function roomName(raw) {
20
+ const name = typeof raw === "string" ? raw.replace(/\s+/g, " ").trim() : "";
21
+ if (!name)
22
+ return { ok: false, error: "a room needs a name" };
23
+ if (name.length > ROOM_NAME_MAX)
24
+ return { ok: false, error: `a room name is at most ${ROOM_NAME_MAX} characters` };
25
+ return { ok: true, name };
26
+ }
27
+ /**
28
+ * The group a NEW room is filed into: the one the caller asked for, but only if
29
+ * it exists and the caller may see it; otherwise the commons (null). A caller
30
+ * can place a room in a group they belong to, never plant one in a group they
31
+ * do not — `spawnGroupForRequest`'s rule, minus the parent clause (a room has
32
+ * no launcher).
33
+ */
34
+ export function roomGroupFor(requested, groups, viewer) {
35
+ if (typeof requested !== "string" || !requested.trim())
36
+ return null;
37
+ const g = groups.find((x) => x.id === requested.trim());
38
+ return g && canSeeGroup(g, viewer) ? g.id : null;
39
+ }
40
+ /**
41
+ * The rooms a viewer may see: not archived, and the group rule of
42
+ * `visibleChannels` — no group → the commons, visible to all; a dangling group
43
+ * id → HIDDEN (fail closed, a lost group row must never reveal its rooms).
44
+ */
45
+ export function visibleRooms(rooms, groups, viewer) {
46
+ const byId = new Map(groups.map((g) => [g.id, g]));
47
+ return rooms.filter((r) => {
48
+ if (r.archivedAt)
49
+ return false;
50
+ if (!r.group)
51
+ return true;
52
+ const g = byId.get(r.group);
53
+ return !!g && canSeeGroup(g, viewer);
54
+ });
55
+ }
56
+ export function canSeeRoom(room, groups, viewer) {
57
+ return !!room && visibleRooms([room], groups, viewer).length === 1;
58
+ }
59
+ /** Why a post is refused, or null. A `code` a client can switch on, and words. */
60
+ export function postRefusal(room, text) {
61
+ if (!room)
62
+ return { code: "unknown-room", error: "no such room" };
63
+ if (room.archivedAt)
64
+ return { code: "archived", error: "this room is closed" };
65
+ if (typeof text !== "string" || !text.trim())
66
+ return { code: "empty", error: "an empty message" };
67
+ if (text.length > ROOM_TEXT_MAX)
68
+ return { code: "too-long", error: `a message is at most ${ROOM_TEXT_MAX} characters` };
69
+ return null;
70
+ }
71
+ /** Pure: the list with one room's mutable fields changed. Server-owned fields
72
+ * (`id`, `createdBy`, `createdAt`, `telegram`, `archivedAt`) never move here. */
73
+ export function patchRoomIn(list, id, patch) {
74
+ return list.map((r) => {
75
+ if (r.id !== id)
76
+ return r;
77
+ const next = { ...r };
78
+ if (patch.name !== undefined)
79
+ next.name = patch.name;
80
+ if (patch.group !== undefined)
81
+ next.group = patch.group;
82
+ if (patch.mirror !== undefined)
83
+ next.mirror = patch.mirror;
84
+ return next;
85
+ });
86
+ }
87
+ /** Pure: parse a JSONL message file, skipping any line that is not a message
88
+ * (a truncated last line after a crash, a stray edit). */
89
+ export function parseMessages(raw) {
90
+ const out = [];
91
+ for (const line of raw.split("\n")) {
92
+ if (!line.trim())
93
+ continue;
94
+ try {
95
+ const m = JSON.parse(line);
96
+ if (m && typeof m.id === "string" && typeof m.ts === "number" && typeof m.text === "string")
97
+ out.push(m);
98
+ }
99
+ catch {
100
+ /* a torn line: skip it, never fail the whole room */
101
+ }
102
+ }
103
+ return out;
104
+ }
105
+ /** Pure: the page of messages strictly before `before` (all when absent), the
106
+ * newest `limit` of them, oldest first. */
107
+ export function pageMessages(msgs, before, limit = ROOM_PAGE) {
108
+ const upTo = before === undefined ? msgs : msgs.filter((m) => m.ts < before);
109
+ return upTo.slice(Math.max(0, upTo.length - limit));
110
+ }
111
+ /** Pure: how many messages after `lastRead` were written by someone else. */
112
+ export function unreadCount(msgs, lastRead, account) {
113
+ let n = 0;
114
+ for (const m of msgs)
115
+ if (m.ts > lastRead && !(account && m.account === account))
116
+ n++;
117
+ return n;
118
+ }
119
+ /** Pure: the (live) room mirrored into this Telegram topic. */
120
+ export function roomForTopic(rooms, chatId, threadId) {
121
+ if (threadId == null)
122
+ return undefined; // a room is a topic, never a DM nor a General
123
+ return rooms.find((r) => !r.archivedAt && r.telegram?.chatId === chatId && r.telegram?.threadId === threadId);
124
+ }
125
+ /** The text a room message becomes in a Telegram topic. Pure. */
126
+ export function telegramLine(m) {
127
+ return `**${m.author}**\n${m.text}`;
128
+ }
129
+ // ── Storage ──────────────────────────────────────────────────────────────
130
+ export function roomsRoot(home = os.homedir()) {
131
+ return path.join(home, ".shadok-ai", "rooms");
132
+ }
133
+ /**
134
+ * The on-disk store. A class only so tests can point it at a scratch dir; the
135
+ * server keeps one. The message cache is keyed on the file's size: an append
136
+ * always grows it, so a stale entry is impossible without a rewrite, and the
137
+ * 4 s list poll does not re-read every room each time.
138
+ */
139
+ export class RoomStore {
140
+ root;
141
+ key;
142
+ cache = new Map();
143
+ constructor(root = roomsRoot(), key = instanceKey()) {
144
+ this.root = root;
145
+ this.key = key;
146
+ }
147
+ listFile() {
148
+ return path.join(this.root, this.key + ".json");
149
+ }
150
+ readFile() {
151
+ return path.join(this.root, this.key + ".read.json");
152
+ }
153
+ msgFile(id) {
154
+ if (!isRoomId(id))
155
+ throw new Error("bad room id");
156
+ return path.join(this.root, this.key, id + ".jsonl");
157
+ }
158
+ writeAtomic(file, value) {
159
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
160
+ const tmp = `${file}.${process.pid}.tmp`;
161
+ fs.writeFileSync(tmp, JSON.stringify(value, null, 2), { mode: 0o600 });
162
+ fs.renameSync(tmp, file);
163
+ }
164
+ list() {
165
+ try {
166
+ const v = JSON.parse(fs.readFileSync(this.listFile(), "utf8"));
167
+ return Array.isArray(v) ? v.filter((r) => r && isRoomId(r.id) && typeof r.name === "string") : [];
168
+ }
169
+ catch {
170
+ return [];
171
+ }
172
+ }
173
+ save(list) {
174
+ this.writeAtomic(this.listFile(), list);
175
+ }
176
+ get(id) {
177
+ return this.list().find((r) => r.id === id);
178
+ }
179
+ /** Read-modify-write of ONE room; returns it, or undefined when unknown. */
180
+ update(id, fn) {
181
+ const list = this.list();
182
+ const i = list.findIndex((r) => r.id === id);
183
+ if (i < 0)
184
+ return undefined;
185
+ list[i] = fn(list[i]);
186
+ this.save(list);
187
+ return list[i];
188
+ }
189
+ create(room) {
190
+ this.save([...this.list(), room]);
191
+ }
192
+ messages(id) {
193
+ const file = this.msgFile(id);
194
+ let size;
195
+ try {
196
+ size = fs.statSync(file).size;
197
+ }
198
+ catch {
199
+ return [];
200
+ }
201
+ const hit = this.cache.get(id);
202
+ if (hit && hit.size === size)
203
+ return hit.msgs;
204
+ const msgs = parseMessages(fs.readFileSync(file, "utf8"));
205
+ this.cache.set(id, { size, msgs });
206
+ return msgs;
207
+ }
208
+ append(id, m) {
209
+ const file = this.msgFile(id);
210
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
211
+ fs.appendFileSync(file, JSON.stringify(m) + "\n", { mode: 0o600 });
212
+ }
213
+ /** `{ [roomId]: { [account]: ts } }` */
214
+ marks() {
215
+ try {
216
+ const v = JSON.parse(fs.readFileSync(this.readFile(), "utf8"));
217
+ return v && typeof v === "object" ? v : {};
218
+ }
219
+ catch {
220
+ return {};
221
+ }
222
+ }
223
+ lastRead(id, account) {
224
+ const v = this.marks()[id]?.[account];
225
+ return typeof v === "number" ? v : 0;
226
+ }
227
+ /** Only ever moves FORWARD: an old tab catching up must not resurrect unread. */
228
+ markRead(id, account, ts) {
229
+ const all = this.marks();
230
+ const cur = all[id]?.[account] ?? 0;
231
+ if (ts <= cur)
232
+ return;
233
+ all[id] = { ...(all[id] ?? {}), [account]: ts };
234
+ this.writeAtomic(this.readFile(), all);
235
+ }
236
+ }
237
+ //# sourceMappingURL=rooms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rooms.js","sourceRoot":"","sources":["../src/rooms.ts"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