@theronap/agnoclast-mcp 0.9.297 → 0.9.298
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/lib/closeout.mjs +15 -2
- package/package.json +1 -1
package/lib/closeout.mjs
CHANGED
|
@@ -516,11 +516,24 @@ async function writeSegments(tools, sessionId, segments) {
|
|
|
516
516
|
return { ok: !r.isError && r.text.startsWith('Logged') && records.length === segments.length, records, text: r.text }
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
+
// A run on 2026-11-03 04:39Z found no brains and spent one of the session's two attempts, with the reply thrown away.
|
|
520
|
+
// A server that starts slowly can answer before it lists its tools, so ask again once, and keep what it said.
|
|
521
|
+
async function listBrains(tools, wait = 5_000) {
|
|
522
|
+
let reply = ''
|
|
523
|
+
for (let n = 0; n < 2; n++) {
|
|
524
|
+
if (n) await new Promise((r) => setTimeout(r, wait))
|
|
525
|
+
const r = await tools.call('my_brains', {}).catch((e) => ({ text: String(e?.message ?? e) }))
|
|
526
|
+
reply = r.text ?? ''
|
|
527
|
+
const list = parseBrains(reply)
|
|
528
|
+
if (list.length) return list
|
|
529
|
+
}
|
|
530
|
+
throw new Error(`no brains listed: ${reply.replace(/\s+/g, ' ').slice(0, 200)}`)
|
|
531
|
+
}
|
|
532
|
+
|
|
519
533
|
async function closeSession(session, { env, home, stopAtLog = false, write = true, noWiki = false }) {
|
|
520
534
|
const tools = await openTools(session.id, env, home)
|
|
521
535
|
try {
|
|
522
|
-
const list =
|
|
523
|
-
if (!list.length) throw new Error('no brains listed')
|
|
536
|
+
const list = await listBrains(tools)
|
|
524
537
|
const { guide, names, privateBrain } = brainGuide(list, home)
|
|
525
538
|
const digest = await digestSession(readFileSync(session.path, 'utf8'), { brains: guide, brainNames: names, privateBrain, env, stopAtLog })
|
|
526
539
|
if (digest.blocking.length) return { ok: false, why: digest.blocking.join('; '), cost: digest.cost, digest }
|
package/package.json
CHANGED