mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:30:42 +00:00
* fix(cron): isolate fresh cron session state * fix(cron): deep-copy isolated session state * fix(cron): reset isolated session context * test(providers): avoid shared mock races * test(providers): type injected stream fakes * ci: refresh package boundary on reply runtime changes --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
import type { StreamFn } from "@mariozechner/pi-agent-core";
|
|
import type { AnthropicVertexStreamDeps } from "./stream-runtime.js";
|
|
|
|
export {
|
|
ANTHROPIC_VERTEX_DEFAULT_MODEL_ID,
|
|
buildAnthropicVertexProvider,
|
|
} from "./provider-catalog.js";
|
|
export {
|
|
hasAnthropicVertexAvailableAuth,
|
|
hasAnthropicVertexCredentials,
|
|
resolveAnthropicVertexClientRegion,
|
|
resolveAnthropicVertexConfigApiKey,
|
|
resolveAnthropicVertexProjectId,
|
|
resolveAnthropicVertexRegion,
|
|
resolveAnthropicVertexRegionFromBaseUrl,
|
|
} from "./region.js";
|
|
import { buildAnthropicVertexProvider } from "./provider-catalog.js";
|
|
import { hasAnthropicVertexAvailableAuth } from "./region.js";
|
|
|
|
export function mergeImplicitAnthropicVertexProvider(params: {
|
|
existing?: ReturnType<typeof buildAnthropicVertexProvider>;
|
|
implicit: ReturnType<typeof buildAnthropicVertexProvider>;
|
|
}) {
|
|
const { existing, implicit } = params;
|
|
if (!existing) {
|
|
return implicit;
|
|
}
|
|
return {
|
|
...implicit,
|
|
...existing,
|
|
models:
|
|
Array.isArray(existing.models) && existing.models.length > 0
|
|
? existing.models
|
|
: implicit.models,
|
|
};
|
|
}
|
|
|
|
export function resolveImplicitAnthropicVertexProvider(params?: { env?: NodeJS.ProcessEnv }) {
|
|
const env = params?.env ?? process.env;
|
|
if (!hasAnthropicVertexAvailableAuth(env)) {
|
|
return null;
|
|
}
|
|
|
|
return buildAnthropicVertexProvider({ env });
|
|
}
|
|
|
|
export function createAnthropicVertexStreamFn(
|
|
projectId: string | undefined,
|
|
region: string,
|
|
baseURL?: string,
|
|
deps?: AnthropicVertexStreamDeps,
|
|
): StreamFn {
|
|
const streamFnPromise = import("./stream-runtime.js").then((runtime) =>
|
|
runtime.createAnthropicVertexStreamFn(projectId, region, baseURL, deps),
|
|
);
|
|
return async (model, context, options) => {
|
|
const streamFn = await streamFnPromise;
|
|
return streamFn(model, context, options);
|
|
};
|
|
}
|
|
|
|
export function createAnthropicVertexStreamFnForModel(
|
|
model: { baseUrl?: string },
|
|
env: NodeJS.ProcessEnv = process.env,
|
|
deps?: AnthropicVertexStreamDeps,
|
|
): StreamFn {
|
|
const streamFnPromise = import("./stream-runtime.js").then((runtime) =>
|
|
runtime.createAnthropicVertexStreamFnForModel(model, env, deps),
|
|
);
|
|
return async (...args) => {
|
|
const streamFn = await streamFnPromise;
|
|
return streamFn(...args);
|
|
};
|
|
}
|