thinkpool-pair 0.6.26 → 0.6.27
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 +6 -6
- package/package.json +1 -1
package/bridge.mjs
CHANGED
|
@@ -445,12 +445,12 @@ function printLocal(evt) {
|
|
|
445
445
|
// relay STRUCTURED events. onEvent → broadcast `code-event` + print locally +
|
|
446
446
|
// persist to the host file; tool calls round-trip through the perm card; the
|
|
447
447
|
// rolling log replays to joiners and survives bridge restarts (session-store).
|
|
448
|
-
function openStructured({ id, model, resume, log }) {
|
|
448
|
+
function openStructured({ id, model, resume, log, commands }) {
|
|
449
449
|
if (sessions.has(id)) return
|
|
450
|
-
const entry = { cmd: 'claude', kind: 'structured', log: Array.isArray(log) ? log.slice(-STRUCTURED_LOG_MAX) : [], pending: new Map(), session: null, recovered: false }
|
|
450
|
+
const entry = { cmd: 'claude', kind: 'structured', log: Array.isArray(log) ? log.slice(-STRUCTURED_LOG_MAX) : [], pending: new Map(), session: null, recovered: false, commands: Array.isArray(commands) ? commands : undefined }
|
|
451
451
|
sessions.set(id, entry)
|
|
452
452
|
if (entry.log.length) process.stderr.write(`\n ◆ restored ${entry.log.length} prior events (${id.slice(0, 8)})${resume ? ' + resuming live context' : ''}.\n`)
|
|
453
|
-
const persist = () => saveSession(room, id, { sessionId: entry.session?.sessionId || resume || null, log: entry.log })
|
|
453
|
+
const persist = () => saveSession(room, id, { sessionId: entry.session?.sessionId || resume || null, log: entry.log, commands: entry.commands })
|
|
454
454
|
entry.session = startClaudeSession({
|
|
455
455
|
cwd: process.cwd(), model, resume,
|
|
456
456
|
onEvent: (evt) => {
|
|
@@ -461,7 +461,7 @@ function openStructured({ id, model, resume, log }) {
|
|
|
461
461
|
process.stderr.write(`\n ◆ saved session expired — starting fresh (transcript kept).\n`)
|
|
462
462
|
try { entry.session?.end() } catch { /* noop */ }
|
|
463
463
|
sessions.delete(id)
|
|
464
|
-
openStructured({ id, model, log: entry.log })
|
|
464
|
+
openStructured({ id, model, log: entry.log, commands: entry.commands })
|
|
465
465
|
return
|
|
466
466
|
}
|
|
467
467
|
// Stamp a wall-clock ts on every transcript event so the web client can
|
|
@@ -472,7 +472,7 @@ function openStructured({ id, model, resume, log }) {
|
|
|
472
472
|
// The init system event carries the session's slash command list. Stash it
|
|
473
473
|
// on the entry so the ANNOUNCE can hand it to clients that connect/reload
|
|
474
474
|
// AFTER init (the one-time code-event would miss them), then re-announce.
|
|
475
|
-
if (evt.kind === 'system' && Array.isArray(evt.commands) && evt.commands.length && !entry.commands) { entry.commands = evt.commands; announce() }
|
|
475
|
+
if (evt.kind === 'system' && Array.isArray(evt.commands) && evt.commands.length && !entry.commands) { entry.commands = evt.commands; announce(); persist() }
|
|
476
476
|
// Chrome events (mode / usage / clear) are transient state, not transcript —
|
|
477
477
|
// broadcast + print them, but keep them out of the persisted/replayed log.
|
|
478
478
|
const chrome = evt.kind === 'mode' || evt.kind === 'usage' || evt.kind === 'clear'
|
|
@@ -691,7 +691,7 @@ channel
|
|
|
691
691
|
// replay its transcript + resume the live SDK context if recent enough.
|
|
692
692
|
if (wantStructured(attachedCmd)) {
|
|
693
693
|
const prev = loadLatest(room)
|
|
694
|
-
if (prev && (prev.log?.length || prev.sessionId)) openStructured({ id: prev.id, resume: canResume(prev) ? prev.sessionId : undefined, log: prev.log })
|
|
694
|
+
if (prev && (prev.log?.length || prev.sessionId)) openStructured({ id: prev.id, resume: canResume(prev) ? prev.sessionId : undefined, log: prev.log, commands: prev.commands })
|
|
695
695
|
else openStructured({ id: randomUUID() })
|
|
696
696
|
}
|
|
697
697
|
else openTerm({ id: randomUUID(), cmd: attachedCmd, args: attachedArgs, attached: true })
|