thinkpool-pair 0.7.249 → 0.7.251

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
@@ -3142,7 +3142,9 @@ async function cancelRestoredDispatchPermissions(terminalIds) {
3142
3142
  await Promise.all(terminals.map(async (terminalId) => {
3143
3143
  const result = await cancelDurableDispatchPermissions({
3144
3144
  supabaseUrl: SUPABASE_URL, anonKey: SUPABASE_ANON, token: codeAuthToken, roomCode: room,
3145
- bridgeId: BRIDGE_ID, terminalId, reason: 'bridge_restarted',
3145
+ // New bridge process, old durable bridge authority: filter by the
3146
+ // restored terminal and let the cleanup read each historical binding.
3147
+ terminalId, reason: 'bridge_restarted',
3146
3148
  })
3147
3149
  if (!result.ok && process.env.TP_DEBUG) process.stderr.write(`\n ◇ restored dispatch cleanup incomplete (${result.code})\n`)
3148
3150
  }))
@@ -9,13 +9,13 @@ const SETTLED = new Set(['denied', 'idempotent_replay', 'already_resolved', 'sta
9
9
 
10
10
  const safeString = (value) => typeof value === 'string' && value.length > 0
11
11
 
12
- export function pendingDispatchItems (items, { bridgeId, terminalId, permissionIds = null } = {}) {
13
- if (!safeString(bridgeId) || !safeString(terminalId)) return []
12
+ export function pendingDispatchItems (items, { bridgeId = null, terminalId, permissionIds = null } = {}) {
13
+ if ((bridgeId != null && !safeString(bridgeId)) || !safeString(terminalId)) return []
14
14
  const requested = permissionIds == null ? null : new Set(permissionIds.filter(safeString))
15
15
  return (Array.isArray(items) ? items : []).filter((item) => {
16
16
  const permissionId = item?.request_context?.permission_id
17
17
  return PENDING.has(item?.status) && item?.item_kind === 'approval' && item?.action_kind === 'dispatch' &&
18
- item?.bridge_authority_id === bridgeId && item?.local_authority_id === terminalId &&
18
+ (!bridgeId || item?.bridge_authority_id === bridgeId) && item?.local_authority_id === terminalId &&
19
19
  safeString(permissionId) && (!requested || requested.has(permissionId))
20
20
  })
21
21
  }
@@ -35,7 +35,7 @@ export async function cancelDurableDispatchPermissions ({
35
35
  terminalId, permissionIds = null, reason = 'dispatch_superseded',
36
36
  } = {}) {
37
37
  if (typeof fetchImpl !== 'function' || !safeString(supabaseUrl) || !safeString(anonKey) ||
38
- !safeString(token) || !safeString(roomCode) || !safeString(bridgeId) || !safeString(terminalId)) {
38
+ !safeString(token) || !safeString(roomCode) || (bridgeId != null && !safeString(bridgeId)) || !safeString(terminalId)) {
39
39
  return Object.freeze({ ok: false, code: 'cleanup_unavailable', canceled: 0 })
40
40
  }
41
41
  if (permissionIds != null && (!Array.isArray(permissionIds) || !permissionIds.length)) {
@@ -54,7 +54,10 @@ export async function cancelDurableDispatchPermissions ({
54
54
  p_decision: 'deny',
55
55
  p_resolution_code: 'canceled',
56
56
  p_resolution_payload: { decision: 'deny', reason },
57
- p_bridge_authority_id: bridgeId,
57
+ // A restart receives a fresh bridge ID. The old row remains protected
58
+ // by its immutable authority binding, so resolve it with that exact
59
+ // value after the owner-authenticated RLS list—not a guessed current ID.
60
+ p_bridge_authority_id: item.bridge_authority_id,
58
61
  p_local_authority_id: terminalId,
59
62
  p_idempotency_key: `cancel-dispatch:${item.id}:${reason}`.slice(0, 160),
60
63
  } })
@@ -14,6 +14,19 @@ const outputText = (update) => {
14
14
  return ''
15
15
  }
16
16
 
17
+ const diffInput = (content) => {
18
+ const diffs = (Array.isArray(content) ? content : []).filter((part) => part?.type === 'diff')
19
+ if (!diffs.length) return null
20
+ if (diffs.length === 1) return {
21
+ file_path: diffs[0].path || '', path: diffs[0].path || '',
22
+ old_string: diffs[0].oldText || '', new_string: diffs[0].newText || '',
23
+ }
24
+ return {
25
+ file_path: diffs[0].path || '', path: diffs[0].path || '',
26
+ edits: diffs.map((diff) => ({ file_path: diff.path || '', old_string: diff.oldText || '', new_string: diff.newText || '' })),
27
+ }
28
+ }
29
+
17
30
  export function hermesToolFor(update = {}) {
18
31
  const kind = String(update.kind || '').toLowerCase()
19
32
  const title = String(update.title || '')
@@ -22,7 +35,11 @@ export function hermesToolFor(update = {}) {
22
35
  const shellText = (update.content || []).map(textOf).find((text) => text.trim().startsWith('$ '))
23
36
  const location = update.locations?.[0]?.path
24
37
  if (kind === 'execute' || terminal || shellText) return { name: 'Bash', input: { ...raw, command: raw.command || shellText?.trim().slice(2) || title } }
25
- if (kind === 'edit') return { name: title.toLowerCase().includes('write') ? 'Write' : 'Edit', input: { ...raw, file_path: raw.path || location || '', path: raw.path || location || '' } }
38
+ if (kind === 'edit') {
39
+ const diff = diffInput(update.content)
40
+ const name = diff?.edits ? 'MultiEdit' : title.toLowerCase().includes('write') ? 'Write' : 'Edit'
41
+ return { name, input: { ...raw, ...(diff || {}), file_path: diff?.file_path || raw.path || location || '', path: diff?.path || raw.path || location || '' } }
42
+ }
26
43
  if (kind === 'read') return { name: 'Read', input: { ...raw, file_path: raw.path || location || '', path: raw.path || location || '' } }
27
44
  if (kind === 'search') return { name: 'Grep', input: raw }
28
45
  if (kind === 'fetch') return { name: 'WebFetch', input: raw }
@@ -76,9 +93,11 @@ export class HermesEventMapper {
76
93
  const merged = { ...prior, ...update }
77
94
  this.tools.set(update.toolCallId, merged)
78
95
  if (!['completed', 'failed'].includes(update.status)) return
96
+ const completedTool = hermesToolFor(merged)
79
97
  this._emit({
80
98
  kind: 'tool_result', toolUseId: update.toolCallId,
81
99
  content: [{ type: 'text', text: outputText(merged) }],
100
+ toolInput: { ...(prior.input || {}), ...(completedTool.input || {}) },
82
101
  isError: update.status === 'failed',
83
102
  durationMs: prior.startedAt ? Date.now() - prior.startedAt : undefined,
84
103
  parentToolUseId: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinkpool-pair",
3
- "version": "0.7.249",
3
+ "version": "0.7.251",
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": {