openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.29 kB
JavaScript
import{H as e}from"./openclaw-state-read-sqlite-database-admission-CrkztOzk.mjs";import{_ as t}from"./openclaw-state-read-openclaw-state-db-cache-DyomEqgV.mjs";import{C as n,u as r}from"./openclaw-state-read-sqlite-post-commit-CsXPYVOo.mjs";import{t as i}from"./openclaw-state-read-sqlite-schema-facts-Dtolu7-X.mjs";import{a,o}from"./openclaw-state-read-kysely-sync-Bcu0Qb7F.mjs";import{n as s,r as c}from"./openclaw-state-read.worker.js";import{t as l}from"./openclaw-state-read-subagent-registry.store.codec-DKFOdqLq.mjs";async function streamSubagentRegistryInWorker(u,d,f){let p=c(u.databasePath,u.location,u.expectedIdentity,u.snapshotRoot),{db:m}=p.database,h=[],g=0;try{s(m,u.databasePath),r(m)||i(m),f();let e=a(m).selectFrom(`subagent_runs`).selectAll().orderBy(`run_id`,`asc`),t=[],n=0;for(let r of o(m,e)){let e=Buffer.byteLength(r.payload_json);t.length&&(t.length===128||n+e>1048576)&&((await d.request(t)).consumed(),t=[],n=0);let i=l(r);if(!i)throw Error(`Canonical subagent restore found an unreadable durable row`);t.push({entry:i,createdAt:r.created_at}),n+=e,g+=1}t.length&&(await d.request(t)).consumed()}catch(n){!r(m)&&e(n)&&t(m),h.push(n)}try{p.close()}catch(e){h.push(e)}return n(h,`Subagent restore and reader cleanup failed`),g}export{streamSubagentRegistryInWorker};