thinkpool-pair 0.7.217 → 0.7.218

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/bridge.mjs CHANGED
@@ -65,7 +65,7 @@ import { writeLaneArtifact, digestSlice, appendDigest, resumeLane } from './flow
65
65
  import { createFlowWorktree, worktreeSpec } from './flow-worktree.mjs'
66
66
  import { startPreview, stopAllPreviews, previews } from './flow-preview.mjs'
67
67
  import { ViewportManager, createViewportTools, sharedViewportBrowser } from './viewport.mjs'
68
- import { designPrompt, resolveDesignSource, validateDesignRequest } from './design-edit.mjs'
68
+ import { designPrompt, resolveDesignSource, syncRealtimeAuth, validateDesignRequest } from './design-edit.mjs'
69
69
  // FL-M9 — per-lane preview servers leak (one per done lane, never stopped until shutdown).
70
70
  // Lane previews are keyed `lane:<flowId>:<laneId>`; stop a whole flow's set when it assembles
71
71
  // (the assembled preview supersedes them) or when a lane is reverted.
@@ -739,6 +739,13 @@ let myServeUid = null // this bridge's authed uid (null = anon)
739
739
  }
740
740
  }
741
741
 
742
+ // Private realtime topics authorize the JWT carried by the socket at join time.
743
+ // Supabase's REST auth helpers do not propagate codeAuthToken to Realtime, so pin
744
+ // it before constructing any channel. A direct/anonymous bridge stays on anon.
745
+ if (!await syncRealtimeAuth(supabase, codeAuthToken, SUPABASE_ANON) && codeAuthToken) {
746
+ process.stderr.write('\n ⚠ realtime auth could not be initialized; private bridge features are unavailable.\n')
747
+ }
748
+
742
749
  refreshOwnerPlan() // fire-and-forget on boot (codeAuthToken now set from env OR the stored login)
743
750
 
744
751
  // ── Pre-flight budget caps — spec docs/specs/2026-07-01-budget-caps.md (nexos steal #1).
@@ -4014,7 +4021,13 @@ if (process.env.THINKPOOL_PAIR_AUTOUPDATE === '1' && VERSION) {
4014
4021
  if (m.t === 'update-available') surfaceUpdate(m.version)
4015
4022
  // Supervisor rotated the owner JWT (account.mjs scheduleTokenRefresh) — adopt
4016
4023
  // it so our authed writes (code-mockup) never go stale on a long session (L16).
4017
- else if (m.t === 'token') { codeAuthToken = m.accessToken || null; refreshOwnerPlan() }
4024
+ else if (m.t === 'token') {
4025
+ codeAuthToken = m.accessToken || null
4026
+ syncRealtimeAuth(supabase, codeAuthToken, SUPABASE_ANON).then((ok) => {
4027
+ if (!ok && codeAuthToken) process.stderr.write('\n ⚠ realtime auth refresh failed; private bridge features may need a reconnect.\n')
4028
+ })
4029
+ refreshOwnerPlan()
4030
+ }
4018
4031
  })
4019
4032
  setInterval(() => { try { process.send({ t: 'idle', idle: idleNow(), between: betweenTurns(), webPeer: webPeerPresent() }) } catch { /* parent gone */ } }, 5000).unref()
4020
4033
  } else if (VERSION) {
package/design-edit.mjs CHANGED
@@ -8,6 +8,20 @@ const MAX_TEXT = 4_000
8
8
 
9
9
  const clean = (value, max) => String(value ?? '').replace(/\0/g, '').trim().slice(0, max)
10
10
 
11
+ // supabase-js does not copy the Auth session into an already-created Realtime
12
+ // client. Private tpdesign:* joins therefore need the bridge owner's JWT pinned
13
+ // explicitly, both at boot and whenever the account supervisor rotates it.
14
+ export async function syncRealtimeAuth(client, accessToken, fallbackToken = null) {
15
+ const token = accessToken || fallbackToken
16
+ if (!token || typeof client?.realtime?.setAuth !== 'function') return false
17
+ try {
18
+ await client.realtime.setAuth(token)
19
+ return true
20
+ } catch {
21
+ return false
22
+ }
23
+ }
24
+
11
25
  export function sourceRevision(source) {
12
26
  return crypto.createHash('sha256').update(String(source)).digest('hex').slice(0, 24)
13
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinkpool-pair",
3
- "version": "0.7.217",
3
+ "version": "0.7.218",
4
4
  "description": "Share a local coding-agent CLI (Claude Code, Codex, Gemini, Aider, …) into a ThinkPool Code room, live.",
5
5
  "type": "module",
6
6
  "bin": {