@alexsun-top/opencode-chat-room 0.6.3 → 0.6.4

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.4 — 2026-11-15
4
+
5
+ - Forbid the host's built-in question, confirmation, and approval dialogs for any agent that belongs to a room: every question and every manual step goes into the room, even when the person who must answer is the operator of the current session. Native dialogs leave no room record and only reach one human.
6
+ - Refuse the host's question tool from a room member instead of only advising against it: the call fails with the room-tool instructions, so the agent asks where the answer is recorded. A center that cannot be reached leaves the tool untouched.
7
+ - Tell agents to reach a scheduled moment with a room reminder instead of `sleep`, a long foreground command, or a polling loop, and to run long work in the background. A wait held in a shell hides the schedule from the room and dies with the process.
8
+
3
9
  ## 0.6.3 — 2026-11-15
4
10
 
5
11
  - Keep a room pinned to the live bottom while images, diagrams and attachments finish loading. Late rows used to push the thread down by their full height, so a room opened at the bottom could end up above the newest message; a growth-triggered scroll also counted as the reader scrolling away, which stopped the pin for good. Only real user scrolling ends the pin now.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexsun-top/opencode-chat-room",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "A chat-room plugin and central server for OpenCode.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,12 +27,15 @@ export function initEvents(app) {
27
27
  const thread = $("#thread");
28
28
  app.state.listMetrics = { height: messageList.offsetHeight, top: thread.scrollTop, client: thread.clientHeight };
29
29
  };
30
+ const wasAtBottom = () => {
31
+ const previous = app.state.listMetrics;
32
+ return previous.height - previous.top - previous.client <= 80;
33
+ };
30
34
  new ResizeObserver(() => {
31
- const thread = $("#thread"), previous = app.state.listMetrics, growth = messageList.offsetHeight - previous.height;
35
+ const thread = $("#thread"), growth = messageList.offsetHeight - app.state.listMetrics.height;
32
36
  // Judge the position before this growth: a reader who was at the bottom stays there,
33
37
  // a reader in history is left alone, and a viewport resize keeps following the anchor.
34
- const wasAtBottom = previous.height - previous.top - previous.client <= 80;
35
- if (growth > 0 && wasAtBottom) thread.scrollTop = thread.scrollHeight;
38
+ if (growth > 0 && wasAtBottom()) thread.scrollTop = thread.scrollHeight;
36
39
  rememberListMetrics();
37
40
  }).observe(messageList);
38
41
  app.showRestoreFailure = (message) => {
@@ -26,9 +26,11 @@ Prefer a persistent room question over the agent's native question dialog for wo
26
26
 
27
27
  Keep each question focused. Include concrete choices when useful. The human answers through OC Chat's Questions panel; ordinary chat messages do not dismiss a pending question.
28
28
 
29
+ While you belong to any room, do not call the host's built-in question, confirmation, or approval tool. This holds even when the human you need is the operator of the current session: a built-in dialog leaves no trace in the room, reaches only one human, and pushes the others to answer the same question again. Ask in the room instead, and route any manual step (restarts, credentials, releases) through the room as well.
30
+
29
31
  Question messages require ChatRoom 0.4.0 or newer on the client and central server. If that workflow is unavailable, explain the limitation in the room rather than claiming a question was queued.
30
32
 
31
- Discuss shared questions in the room rather than opening private dialogs. Consolidate unresolved decisions for the human. Continue independent work while awaiting an answer, without repeatedly polling or sending reminder duplicates. Use a native question dialog only when no room is available or the user explicitly requests it.
33
+ Discuss shared questions in the room rather than opening private dialogs. Consolidate unresolved decisions for the human. Continue independent work while awaiting an answer, without repeatedly polling or sending reminder duplicates. The only exception is a session with no room at all.
32
34
 
33
35
  ## Room tool basics
34
36
 
@@ -82,6 +84,10 @@ Templates support `{{time}}`, `{{initiator}}`, and `{{room}}`. The server posts
82
84
 
83
85
  When a scheduled reminder delivers a plan the human already approved, start executing it right away. Do not ask for a second confirmation of the schedule or the plan; report progress and results in the room instead. Still stop for a decision the plan never covered, such as a new destination or an irreversible action outside the agreed scope.
84
86
 
87
+ Waiting for a wall-clock time is what reminders are for. After joining a room, never block on `sleep`, a long foreground command, or a polling loop to reach a scheduled moment: create a reminder in the room instead and let the delivery wake the work. A `sleep` holds a shell and an agent slot for the whole wait, hides the schedule from the other members, and turns a missed wake-up into a silent failure; a reminder is recorded, visible to everyone, and survives restarts. Prefer a reminder even for short waits when the wait is part of the plan other people should see.
88
+
89
+ Run long work in the background rather than blocking on it, and let the completion notification resume the work. Reserve foreground execution for commands whose result the next step reads, and keep those short. When a task needs several minutes of waiting, say what you are waiting for in the room and schedule the check as a reminder instead of holding the turn.
90
+
85
91
  ## Share files and media
86
92
 
87
93
  In central mode, upload a local file with the room tool:
package/src/v1-plugin.ts CHANGED
@@ -2,6 +2,7 @@ import type { Config, Plugin, PluginInput, ToolDefinition } from "@opencode-ai/p
2
2
  import type { V2Runtime } from "./v2-plugin";
3
3
  import type { QueueTransport } from "./queue-transport";
4
4
  import { fileURLToPath } from "node:url";
5
+ import { request } from "./center-client";
5
6
 
6
7
  const bundledSkillsPath = fileURLToPath(new URL("../skills", import.meta.url));
7
8
 
@@ -14,6 +15,7 @@ export function createV1Server(deps: {
14
15
  checkInbox(runtime: V2Runtime, sessionID: string): Promise<void>;
15
16
  wake(runtime: V2Runtime, sessions: ReadonlySet<string>): Promise<void>;
16
17
  central: boolean;
18
+ hasRooms?(runtime: V2Runtime, sessionID: string): Promise<boolean>;
17
19
  }) : Plugin {
18
20
  return async (input) => {
19
21
  const sessions = new Set<string>();
@@ -24,6 +26,10 @@ export function createV1Server(deps: {
24
26
  };
25
27
  const runtime = deps.runtime(input, transport);
26
28
  const adminTool = deps.admin;
29
+ const hasRooms = deps.hasRooms ?? (async (runtime: V2Runtime, sessionID: string) => {
30
+ const rooms = await request(runtime.center, `/rooms?sessionID=${encodeURIComponent(sessionID)}`, "GET");
31
+ return Array.isArray(rooms) && rooms.length > 0;
32
+ });
27
33
  let timer: ReturnType<typeof setInterval> | undefined;
28
34
  if (deps.central) {
29
35
  const sweep = (pollInbox: boolean) => void deps.run(runtime, async () => {
@@ -58,6 +64,18 @@ export function createV1Server(deps: {
58
64
  };
59
65
  },
60
66
  dispose: async () => { if (timer) clearInterval(timer); },
67
+ // A session that belongs to a room must ask there, where the question is recorded
68
+ // and every member sees it. Questions asked through the host dialog reach one person.
69
+ "tool.execute.before": async (hook: { tool: string; sessionID: string }) => {
70
+ if (hook.tool !== "question") return;
71
+ let member = false;
72
+ try {
73
+ member = await deps.run(runtime, () => hasRooms(runtime, hook.sessionID));
74
+ } catch {
75
+ return; // A center that cannot answer must not block the agent's tooling.
76
+ }
77
+ if (member) throw new Error("Do not ask through the host dialog while this session belongs to a room. Send the question in the room instead: room tool, action send, isQuestion true, with the room ID and enough context for the human to answer.");
78
+ },
61
79
  "chat.message": async (event: { sessionID: string }) => {
62
80
  sessions.add(event.sessionID);
63
81
  await deps.run(runtime, async () => {