UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

44 lines (43 loc) • 1.41 kB
//#region src/llm/model-runtime-binding.ts const MODEL_LLM_RUNTIME = Symbol("openclaw.modelLlmRuntime"); const streamLlmRuntimes = /* @__PURE__ */ new WeakMap(); function bindModelRuntime(e, t) { const n = { ...e }; Object.defineProperty(n, MODEL_LLM_RUNTIME, { value: t, enumerable: false }); return n; } /** Carries the prepared lifecycle runtime without changing the serialized model shape. */ function bindModelLlmRuntime(e, t, n) { return bindModelRuntime(e, { runtime: t, completionTransport: n, completionOwner: getModelCompletionOwner(e) }); } function bindModelCompletionOwner(e, t) { return bindModelRuntime(e, { ...e[MODEL_LLM_RUNTIME], completionOwner: t }); } function getModelCompletionOwner(e) { return e[MODEL_LLM_RUNTIME]?.completionOwner; } function getModelLlmRuntime(e) { return e[MODEL_LLM_RUNTIME]?.runtime; } function getModelCompletionTransport(e) { return e[MODEL_LLM_RUNTIME]?.completionTransport; } /** Associates a prepared stream entry point with the runtime that owns it. */ function bindStreamLlmRuntime(e, t) { streamLlmRuntimes.set(e, t); } function getStreamLlmRuntime(e) { return e ? streamLlmRuntimes.get(e) : void 0; } //#endregion export { getModelCompletionTransport as a, getModelCompletionOwner as i, bindModelLlmRuntime as n, getModelLlmRuntime as o, bindStreamLlmRuntime as r, getStreamLlmRuntime as s, bindModelCompletionOwner as t };