UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

23 lines (22 loc) • 1.14 kB
import { t as AsyncContext } from "./async-context-BYDAvG9A.mjs"; import { o as getAsyncWorkSignal } from "./async-work-scope-BXagjUap.mjs"; //#region src/state/agent-database-preparation-context.ts const preparation = new AsyncContext(Symbol("agentDatabasePreparation")); /** Carry readiness observation without borrowing startup's database access. */ function withAgentDatabasePreparationContext(e, t) { return preparation.getStore() === e ? t() : preparation.run(e, t); } function waitForAgentDatabasePreparation(e, t) { return preparation.getStore()?.()?.waitForAgentPreparation(e, t); } /** Wait before acquiring write/session authority; startup alone owns the completion and budget. */ function waitForAgentDatabaseWriteAdmission(e, t = {}) { const n = [t.signal, getAsyncWorkSignal()].filter((e) => e !== void 0); return (t.owner ?? preparation.getStore()?.())?.waitForAgentPreparation(e, { env: t.env, signal: n.length ? AbortSignal.any(n) : void 0, forWrite: true }); } //#endregion export { waitForAgentDatabaseWriteAdmission as n, withAgentDatabasePreparationContext as r, waitForAgentDatabasePreparation as t };