mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
refactor(core): extract shared usage, auth, and display helpers
This commit is contained in:
@@ -8,9 +8,12 @@ import path from "node:path";
|
||||
import { GatewayClient } from "../../src/gateway/client.js";
|
||||
import { connectGatewayClient } from "../../src/gateway/test-helpers.e2e.js";
|
||||
import { loadOrCreateDeviceIdentity } from "../../src/infra/device-identity.js";
|
||||
import { extractFirstTextBlock } from "../../src/shared/chat-message-content.js";
|
||||
import { sleep } from "../../src/utils.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../src/utils/message-channel.js";
|
||||
|
||||
export { extractFirstTextBlock };
|
||||
|
||||
type NodeListPayload = {
|
||||
nodes?: Array<{ nodeId?: string; connected?: boolean; paired?: boolean }>;
|
||||
};
|
||||
@@ -358,22 +361,6 @@ export async function waitForNodeStatus(
|
||||
throw new Error(`timeout waiting for node status for ${nodeId}`);
|
||||
}
|
||||
|
||||
export function extractFirstTextBlock(message: unknown): string | undefined {
|
||||
if (!message || typeof message !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
const content = (message as { content?: unknown }).content;
|
||||
if (!Array.isArray(content) || content.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const first = content[0];
|
||||
if (!first || typeof first !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
const text = (first as { text?: unknown }).text;
|
||||
return typeof text === "string" ? text : undefined;
|
||||
}
|
||||
|
||||
export async function waitForChatFinalEvent(params: {
|
||||
events: ChatEventPayload[];
|
||||
runId: string;
|
||||
|
||||
Reference in New Issue
Block a user