thinkpool-pair 0.6.18 → 0.6.20
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 +22 -0
- package/package.json +1 -1
package/bridge.mjs
CHANGED
|
@@ -435,6 +435,11 @@ function openStructured({ id, model, resume, log }) {
|
|
|
435
435
|
openStructured({ id, model, log: entry.log })
|
|
436
436
|
return
|
|
437
437
|
}
|
|
438
|
+
// Stamp a wall-clock ts on every transcript event so the web client can
|
|
439
|
+
// sort agent turns chronologically against room chat/whispers on reload
|
|
440
|
+
// (the client merges the replayed log with persisted human lines). Used
|
|
441
|
+
// for ordering only — agent timestamps are never displayed.
|
|
442
|
+
if (typeof evt.ts !== 'number') evt.ts = Date.now()
|
|
438
443
|
// Chrome events (mode / usage / clear) are transient state, not transcript —
|
|
439
444
|
// broadcast + print them, but keep them out of the persisted/replayed log.
|
|
440
445
|
const chrome = evt.kind === 'mode' || evt.kind === 'usage' || evt.kind === 'clear'
|
|
@@ -725,6 +730,23 @@ if (process.env.THINKPOOL_PAIR_AUTOUPDATE === '1' && VERSION) {
|
|
|
725
730
|
setInterval(check, POLL_MS).unref() // poll the registry
|
|
726
731
|
setInterval(applyIfIdle, 15000).unref() // once pending, land it as soon as idle
|
|
727
732
|
setTimeout(check, 60000).unref() // first check after the session settles
|
|
733
|
+
} else if (VERSION) {
|
|
734
|
+
// Foreground run (not the supervised service): it can't self-restart, but
|
|
735
|
+
// nudge once if a newer version is out so a relaunch with @latest picks it up.
|
|
736
|
+
setTimeout(async () => {
|
|
737
|
+
try {
|
|
738
|
+
const ctrl = new AbortController(); const to = setTimeout(() => ctrl.abort(), 8000)
|
|
739
|
+
const res = await fetch('https://registry.npmjs.org/thinkpool-pair/latest', { signal: ctrl.signal, headers: { accept: 'application/json' } }).finally(() => clearTimeout(to))
|
|
740
|
+
if (!res.ok) return
|
|
741
|
+
const j = await res.json(); const latest = typeof j?.version === 'string' ? j.version : null
|
|
742
|
+
if (!latest) return
|
|
743
|
+
const core = (v) => String(v).split('-')[0].split('.').map((n) => parseInt(n, 10) || 0)
|
|
744
|
+
const a = core(latest), b = core(VERSION)
|
|
745
|
+
let newer = false
|
|
746
|
+
for (let i = 0; i < 3; i++) { if ((a[i] || 0) > (b[i] || 0)) { newer = true; break } if ((a[i] || 0) < (b[i] || 0)) break }
|
|
747
|
+
if (newer) process.stderr.write(`\n ◆ thinkpool-pair ${latest} is out (you're on ${VERSION}) — restart with: npx thinkpool-pair@latest ${room}\n`)
|
|
748
|
+
} catch { /* offline — never block the session */ }
|
|
749
|
+
}, 60000).unref()
|
|
728
750
|
}
|
|
729
751
|
|
|
730
752
|
function shutdown() {
|