Files
openclaw/packages/ai/src/internal/default-runtime.ts
Brian Bell bacb33a909 fix: keep Bedrock live smoke on Bedrock runtime (#99607)
* fix: preserve Bedrock live API providers

* fix: derive Bedrock smoke region from AWS config

* fix: honor Bedrock discovery region in smoke

* fix: keep Bedrock live smoke on Bedrock runtime

---------

Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
2026-07-06 08:19:42 -07:00

41 lines
1.4 KiB
TypeScript

// Process-default registry/runtime retained for the OpenClaw compatibility
// facade (src/llm). Deliberately not part of the public package API: external
// consumers create isolated runtimes via createLlmRuntime(); exporting these
// from the root barrel would reintroduce the mutable process-global registry.
import { createApiRegistry, type ApiRegistry } from "../api-registry.js";
import { createLlmRuntime, type LlmRuntime } from "../stream.js";
type DefaultRuntimeState = {
registry: ApiRegistry;
runtime: LlmRuntime;
};
const DEFAULT_RUNTIME_KEY = Symbol.for("openclaw.ai.defaultRuntime");
function resolveDefaultRuntime(): DefaultRuntimeState {
const globalStore = globalThis as Record<PropertyKey, unknown>;
if (Object.hasOwn(globalStore, DEFAULT_RUNTIME_KEY)) {
return globalStore[DEFAULT_RUNTIME_KEY] as DefaultRuntimeState;
}
const registry = createApiRegistry();
const runtime = createLlmRuntime(registry);
const state = { registry, runtime };
globalStore[DEFAULT_RUNTIME_KEY] = state;
return state;
}
const defaultRuntime = resolveDefaultRuntime();
export const defaultApiRegistry = defaultRuntime.registry;
export const defaultLlmRuntime = defaultRuntime.runtime;
export const {
registerApiProvider,
getApiProvider,
getApiProviders,
unregisterApiProviders,
clearApiProviders,
} = defaultApiRegistry;
export const { stream, complete, streamSimple, completeSimple } = defaultLlmRuntime;