mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-04-30 14:02:56 +08:00
test: harden plugin prerelease smoke checks
This commit is contained in:
@@ -138,6 +138,7 @@
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"description": "Deprecated alias for fileFormat.",
|
||||
"enum": ["png", "pdf"]
|
||||
},
|
||||
"fileQuality": {
|
||||
@@ -157,19 +158,23 @@
|
||||
},
|
||||
"imageFormat": {
|
||||
"type": "string",
|
||||
"description": "Deprecated alias for fileFormat.",
|
||||
"enum": ["png", "pdf"]
|
||||
},
|
||||
"imageQuality": {
|
||||
"type": "string",
|
||||
"description": "Deprecated alias for fileQuality.",
|
||||
"enum": ["standard", "hq", "print"]
|
||||
},
|
||||
"imageScale": {
|
||||
"type": "number",
|
||||
"description": "Deprecated alias for fileScale.",
|
||||
"minimum": 1,
|
||||
"maximum": 4
|
||||
},
|
||||
"imageMaxWidth": {
|
||||
"type": "number",
|
||||
"description": "Deprecated alias for fileMaxWidth.",
|
||||
"minimum": 640,
|
||||
"maximum": 2400
|
||||
},
|
||||
|
||||
@@ -24,19 +24,49 @@ function summarizeSessionRows(rows: Array<Record<string, unknown>> | undefined)
|
||||
}));
|
||||
}
|
||||
|
||||
function formatUnknownError(error: unknown): string {
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
if (error === undefined || error === null) {
|
||||
return "";
|
||||
}
|
||||
if (typeof error === "string") {
|
||||
return error;
|
||||
}
|
||||
if (typeof error === "number" || typeof error === "boolean" || typeof error === "bigint") {
|
||||
return `${error}`;
|
||||
}
|
||||
if (typeof error === "symbol") {
|
||||
return error.description ?? "symbol";
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(error) ?? "";
|
||||
} catch {
|
||||
return Object.prototype.toString.call(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function waitForGatewaySeededConversation(gateway: GatewayRpcClient) {
|
||||
let lastList: { sessions?: Array<Record<string, unknown>> } | undefined;
|
||||
let lastError: unknown;
|
||||
try {
|
||||
return await waitFor(
|
||||
"seeded conversation in gateway sessions.list",
|
||||
async () => {
|
||||
lastList = await gateway.request<{ sessions?: Array<Record<string, unknown>> }>(
|
||||
"sessions.list",
|
||||
{ limit: 50, includeDerivedTitles: true, includeLastMessage: true },
|
||||
);
|
||||
try {
|
||||
lastList = await gateway.request<{ sessions?: Array<Record<string, unknown>> }>(
|
||||
"sessions.list",
|
||||
{ limit: 50, includeDerivedTitles: false, includeLastMessage: false },
|
||||
);
|
||||
lastError = undefined;
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
return undefined;
|
||||
}
|
||||
return lastList.sessions?.find((entry) => entry.key === "agent:main:main");
|
||||
},
|
||||
60_000,
|
||||
180_000,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
@@ -44,6 +74,7 @@ async function waitForGatewaySeededConversation(gateway: GatewayRpcClient) {
|
||||
{
|
||||
count: lastList?.sessions?.length ?? 0,
|
||||
sessions: summarizeSessionRows(lastList?.sessions),
|
||||
lastError: formatUnknownError(lastError),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
@@ -60,24 +91,9 @@ async function main() {
|
||||
assert(gatewayToken, "missing GW_TOKEN");
|
||||
|
||||
const gateway = await connectGateway({ url: gatewayUrl, token: gatewayToken });
|
||||
let mcpHandle = await connectMcpClient({
|
||||
gatewayUrl,
|
||||
gatewayToken,
|
||||
});
|
||||
let mcp = mcpHandle.client;
|
||||
let mcpHandle: Awaited<ReturnType<typeof connectMcpClient>> | undefined;
|
||||
|
||||
try {
|
||||
if (await maybeApprovePendingBridgePairing(gateway)) {
|
||||
await Promise.allSettled([mcp.close(), mcpHandle.transport.close()]);
|
||||
mcpHandle = await connectMcpClient({
|
||||
gatewayUrl,
|
||||
gatewayToken,
|
||||
});
|
||||
mcp = mcpHandle.client;
|
||||
}
|
||||
const callTool = <T>(params: Parameters<typeof mcp.callTool>[0]) =>
|
||||
mcp.callTool(params, undefined, { timeout: 240_000 }) as Promise<T>;
|
||||
|
||||
const gatewayConversation = await waitForGatewaySeededConversation(gateway);
|
||||
assert(
|
||||
(gatewayConversation.deliveryContext as { channel?: unknown } | undefined)?.channel ===
|
||||
@@ -89,6 +105,23 @@ async function main() {
|
||||
"expected seeded gateway deliveryContext target",
|
||||
);
|
||||
|
||||
mcpHandle = await connectMcpClient({
|
||||
gatewayUrl,
|
||||
gatewayToken,
|
||||
});
|
||||
let mcp = mcpHandle.client;
|
||||
|
||||
if (await maybeApprovePendingBridgePairing(gateway)) {
|
||||
await Promise.allSettled([mcp.close(), mcpHandle.transport.close()]);
|
||||
mcpHandle = await connectMcpClient({
|
||||
gatewayUrl,
|
||||
gatewayToken,
|
||||
});
|
||||
mcp = mcpHandle.client;
|
||||
}
|
||||
const callTool = <T>(params: Parameters<typeof mcp.callTool>[0]) =>
|
||||
mcp.callTool(params, undefined, { timeout: 240_000 }) as Promise<T>;
|
||||
|
||||
let lastMcpConversationList: unknown;
|
||||
const conversation = await waitFor(
|
||||
"seeded conversation in conversations_list",
|
||||
@@ -333,7 +366,10 @@ async function main() {
|
||||
) + "\n",
|
||||
);
|
||||
} finally {
|
||||
await Promise.allSettled([mcp.close(), mcpHandle.transport.close(), gateway.close()]);
|
||||
await Promise.allSettled([
|
||||
...(mcpHandle ? [mcpHandle.client.close(), mcpHandle.transport.close()] : []),
|
||||
gateway.close(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user