mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:50:43 +00:00
test: configure parallels smoke provider timeout
This commit is contained in:
@@ -13,11 +13,11 @@ import {
|
||||
parseMode,
|
||||
parseProvider,
|
||||
providerIdFromModelId,
|
||||
providerTimeoutConfigJson,
|
||||
repoRoot,
|
||||
resolveHostIp,
|
||||
resolveHostPort,
|
||||
resolveLatestVersion,
|
||||
resolveParallelsModelTimeoutSeconds,
|
||||
resolveProviderAuth,
|
||||
resolveSnapshot,
|
||||
run,
|
||||
@@ -690,14 +690,17 @@ rm -rf /root/.openclaw/test-bad-plugin`);
|
||||
private verifyLocalTurn(): void {
|
||||
this.guestExec(["openclaw", "models", "set", this.auth.modelId]);
|
||||
const providerId = providerIdFromModelId(this.auth.modelId) || this.options.provider;
|
||||
this.guestExec([
|
||||
"openclaw",
|
||||
"config",
|
||||
"set",
|
||||
`models.providers.${providerId}.timeoutSeconds`,
|
||||
String(resolveParallelsModelTimeoutSeconds("linux")),
|
||||
"--strict-json",
|
||||
]);
|
||||
const providerTimeoutConfig = providerTimeoutConfigJson(this.auth.modelId, "linux");
|
||||
if (providerTimeoutConfig) {
|
||||
this.guestExec([
|
||||
"openclaw",
|
||||
"config",
|
||||
"set",
|
||||
`models.providers.${providerId}`,
|
||||
providerTimeoutConfig,
|
||||
"--strict-json",
|
||||
]);
|
||||
}
|
||||
this.guestExec([
|
||||
"openclaw",
|
||||
"config",
|
||||
|
||||
@@ -12,10 +12,10 @@ import {
|
||||
parseMode,
|
||||
parseProvider,
|
||||
providerIdFromModelId,
|
||||
providerTimeoutConfigJson,
|
||||
resolveHostIp,
|
||||
resolveHostPort,
|
||||
resolveLatestVersion,
|
||||
resolveParallelsModelTimeoutSeconds,
|
||||
resolveProviderAuth,
|
||||
resolveSnapshot,
|
||||
run,
|
||||
@@ -974,15 +974,18 @@ exit 1`);
|
||||
private verifyTurn(): void {
|
||||
this.guestExec([guestNode, guestOpenClawEntry, "models", "set", this.auth.modelId]);
|
||||
const providerId = providerIdFromModelId(this.auth.modelId) || this.options.provider;
|
||||
this.guestExec([
|
||||
guestNode,
|
||||
guestOpenClawEntry,
|
||||
"config",
|
||||
"set",
|
||||
`models.providers.${providerId}.timeoutSeconds`,
|
||||
String(resolveParallelsModelTimeoutSeconds("macos")),
|
||||
"--strict-json",
|
||||
]);
|
||||
const providerTimeoutConfig = providerTimeoutConfigJson(this.auth.modelId, "macos");
|
||||
if (providerTimeoutConfig) {
|
||||
this.guestExec([
|
||||
guestNode,
|
||||
guestOpenClawEntry,
|
||||
"config",
|
||||
"set",
|
||||
`models.providers.${providerId}`,
|
||||
providerTimeoutConfig,
|
||||
"--strict-json",
|
||||
]);
|
||||
}
|
||||
this.guestExec([
|
||||
guestNode,
|
||||
guestOpenClawEntry,
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
windowsModelProviderTimeoutScript,
|
||||
windowsOpenClawResolver,
|
||||
} from "./powershell.ts";
|
||||
import { providerIdFromModelId, resolveParallelsModelTimeoutSeconds } from "./provider-auth.ts";
|
||||
import { providerIdFromModelId, providerTimeoutConfigJson } from "./provider-auth.ts";
|
||||
import type { Platform, ProviderAuth } from "./types.ts";
|
||||
|
||||
export interface NpmUpdateScriptInput {
|
||||
@@ -20,12 +20,13 @@ function posixModelProviderTimeoutCommand(
|
||||
platform: Platform,
|
||||
): string {
|
||||
const providerId = providerIdFromModelId(modelId);
|
||||
if (!providerId) {
|
||||
const configJson = providerTimeoutConfigJson(modelId, platform);
|
||||
if (!providerId || !configJson) {
|
||||
return "";
|
||||
}
|
||||
return `${command} config set ${shellQuote(
|
||||
`models.providers.${providerId}.timeoutSeconds`,
|
||||
)} ${resolveParallelsModelTimeoutSeconds(platform)} --strict-json`;
|
||||
return `${command} config set ${shellQuote(`models.providers.${providerId}`)} ${shellQuote(
|
||||
configJson,
|
||||
)} --strict-json`;
|
||||
}
|
||||
|
||||
function posixAssertAgentOkScript(command: string, input: NpmUpdateScriptInput, sessionId: string) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { providerIdFromModelId, resolveParallelsModelTimeoutSeconds } from "./provider-auth.ts";
|
||||
import { providerIdFromModelId, providerTimeoutConfigJson } from "./provider-auth.ts";
|
||||
|
||||
export function psSingleQuote(value: string): string {
|
||||
return `'${value.replaceAll("'", "''")}'`;
|
||||
@@ -16,12 +16,11 @@ export function encodePowerShell(script: string): string {
|
||||
|
||||
export function windowsModelProviderTimeoutScript(modelId: string): string {
|
||||
const providerId = providerIdFromModelId(modelId);
|
||||
if (!providerId) {
|
||||
const configJson = providerTimeoutConfigJson(modelId, "windows");
|
||||
if (!providerId || !configJson) {
|
||||
return "";
|
||||
}
|
||||
return `Invoke-OpenClaw config set ${psSingleQuote(
|
||||
`models.providers.${providerId}.timeoutSeconds`,
|
||||
)} ${resolveParallelsModelTimeoutSeconds("windows")} --strict-json
|
||||
return `Invoke-OpenClaw config set ${psSingleQuote(`models.providers.${providerId}`)} ${psSingleQuote(configJson)} --strict-json
|
||||
if ($LASTEXITCODE -ne 0) { throw "model provider timeout config set failed" }`;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,30 @@ export function resolveParallelsModelTimeoutSeconds(platform?: Platform): number
|
||||
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : 600;
|
||||
}
|
||||
|
||||
export function providerTimeoutConfigJson(modelId: string, platform: Platform): string {
|
||||
const providerId = providerIdFromModelId(modelId);
|
||||
if (providerId !== "openai") {
|
||||
return "";
|
||||
}
|
||||
const modelName = modelId.slice("openai/".length).trim();
|
||||
if (!modelName) {
|
||||
return "";
|
||||
}
|
||||
return JSON.stringify({
|
||||
api: "openai-responses",
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
models: [
|
||||
{
|
||||
contextWindow: 1_047_576,
|
||||
id: modelName,
|
||||
maxTokens: 32_768,
|
||||
name: modelName,
|
||||
},
|
||||
],
|
||||
timeoutSeconds: resolveParallelsModelTimeoutSeconds(platform),
|
||||
});
|
||||
}
|
||||
|
||||
export function parseProvider(value: string): Provider {
|
||||
if (value === "openai" || value === "anthropic" || value === "minimax") {
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user