switchroom 0.13.55 → 0.13.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "switchroom",
3
- "version": "0.13.55",
3
+ "version": "0.13.57",
4
4
  "description": "Run Claude Code 24/7 on your Claude Pro/Max subscription over Telegram. Open-source alternative to OpenClaw and NanoClaw — no API keys.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -47,10 +47,12 @@ disallowed database, you'll get a clean block reason naming the DB.
47
47
  The Notion MCP exposes the standard set:
48
48
 
49
49
  - **Search.** `search` finds pages or databases by title/content
50
- across what the integration can see. switchroom's PreToolUse hook
51
- post-filters results to your allowlist pages outside it are
52
- dropped before they reach you. The response's metadata field
53
- indicates how many were filtered.
50
+ across what the integration can see. **In switchroom v1, `search`
51
+ is BLOCKED for any agent with a non-empty
52
+ `notion_workspace.databases:` allowlist** the post-filter that
53
+ would strip out-of-allowlist results isn't wired yet. Use
54
+ `query_database` against your allowed DBs instead. Admin-shaped
55
+ agents (no per-DB filter) can search normally.
54
56
  - **Database queries.** `query_database` runs a filter+sort against
55
57
  a database. You need the database's UUID (operator gives these
56
58
  via friendly names in `notion_workspace.databases` — ask the
@@ -98,11 +100,13 @@ The Notion MCP exposes the standard set:
98
100
 
99
101
  ### "Find that thing about X"
100
102
 
101
- 1. `search` with the query. Take only the top result unless ambiguous.
102
- 2. The post-filter has already redacted out-of-allowlist results;
103
- don't worry about leakage.
104
- 3. If 0 results: try a `query_database` against the most likely DB
105
- with a property filter (matches the value).
103
+ 1. If you have full search access (no `databases:` filter): `search`
104
+ with the query, take the top result unless ambiguous.
105
+ 2. If `search` is blocked for you (the hook will return a clear
106
+ message naming the v1 limitation): `query_database` against
107
+ each of your allowed DBs in turn, with a title-contains or
108
+ property filter. List your allowed DBs by checking
109
+ `notion_workspace.databases:` in your config via `config_get`.
106
110
 
107
111
  ### "Update the page about X"
108
112
 
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Ack-first state flag — load-bearing for the ack-first-pretool hook
3
+ * (see `src/cli/ack-first-pretool.ts` and
4
+ * `reference/conversational-pacing.md` beat 1).
5
+ *
6
+ * The gateway is the source of truth for "has the model called reply
7
+ * yet this turn?". The PreToolUse hook runs as a short-lived child
8
+ * process so it can't read gateway in-memory state; the hand-off is
9
+ * a single file inside `$TELEGRAM_STATE_DIR`:
10
+ *
11
+ * - `markAckSent()` touches the file on the first reply per turn.
12
+ * - `clearAckSent()` removes it at turn_started.
13
+ * - The hook checks `existsSync(path)` → allow / block.
14
+ *
15
+ * Per-agent isolation is built-in: `$TELEGRAM_STATE_DIR` is the
16
+ * agent's per-container state dir (~/.switchroom/agents/<name>/telegram,
17
+ * bind-mounted into /state/agent/home/.switchroom/agents/<name>/telegram
18
+ * inside the container).
19
+ *
20
+ * All operations are best-effort: a write or unlink failure logs to
21
+ * stderr and returns; the gate is informational UX, not a safety
22
+ * primitive, so a broken state-dir must never wedge reply itself.
23
+ */
24
+
25
+ import { closeSync, existsSync, openSync, unlinkSync } from "node:fs";
26
+ import { join } from "node:path";
27
+
28
+ export const ACK_SENT_MARKER = "ack-sent.flag";
29
+
30
+ function markerPath(): string | null {
31
+ const dir = process.env.TELEGRAM_STATE_DIR;
32
+ if (!dir) return null;
33
+ return join(dir, ACK_SENT_MARKER);
34
+ }
35
+
36
+ /** Create the ack-sent marker. Idempotent (no-op if it exists). */
37
+ export function markAckSent(): void {
38
+ const path = markerPath();
39
+ if (path == null) return;
40
+ if (existsSync(path)) return;
41
+ try {
42
+ const fd = openSync(path, "w");
43
+ closeSync(fd);
44
+ } catch (err) {
45
+ process.stderr.write(
46
+ `ack-flag: markAckSent failed path=${path}: ${err}\n`,
47
+ );
48
+ }
49
+ }
50
+
51
+ /** Remove the ack-sent marker. Idempotent. */
52
+ export function clearAckSent(): void {
53
+ const path = markerPath();
54
+ if (path == null) return;
55
+ try {
56
+ unlinkSync(path);
57
+ } catch (err: unknown) {
58
+ // ENOENT is the common case (turn started before any prior turn
59
+ // ran a reply); silently swallow.
60
+ const code = (err as { code?: string } | undefined)?.code;
61
+ if (code === "ENOENT") return;
62
+ process.stderr.write(
63
+ `ack-flag: clearAckSent failed path=${path}: ${err}\n`,
64
+ );
65
+ }
66
+ }