mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:18:28 +00:00
feat: extend Control UI assistant identity
This commit is contained in:
@@ -26,15 +26,18 @@ import {
|
||||
import { normalizeAgentId } from "../../routing/session-key.js";
|
||||
import { parseMessageWithAttachments } from "../chat-attachments.js";
|
||||
import {
|
||||
type AgentIdentityParams,
|
||||
type AgentWaitParams,
|
||||
ErrorCodes,
|
||||
errorShape,
|
||||
formatValidationErrors,
|
||||
validateAgentIdentityParams,
|
||||
validateAgentParams,
|
||||
validateAgentWaitParams,
|
||||
} from "../protocol/index.js";
|
||||
import { loadSessionEntry } from "../session-utils.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import { resolveAssistantIdentity } from "../assistant-identity.js";
|
||||
import { waitForAgentJob } from "./agent-job.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
|
||||
@@ -369,6 +372,43 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
});
|
||||
});
|
||||
},
|
||||
"agent.identity.get": ({ params, respond }) => {
|
||||
if (!validateAgentIdentityParams(params)) {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
errorShape(
|
||||
ErrorCodes.INVALID_REQUEST,
|
||||
`invalid agent.identity.get params: ${formatValidationErrors(
|
||||
validateAgentIdentityParams.errors,
|
||||
)}`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
const p = params as AgentIdentityParams;
|
||||
const agentIdRaw = typeof p.agentId === "string" ? p.agentId.trim() : "";
|
||||
const sessionKeyRaw = typeof p.sessionKey === "string" ? p.sessionKey.trim() : "";
|
||||
let agentId = agentIdRaw ? normalizeAgentId(agentIdRaw) : undefined;
|
||||
if (sessionKeyRaw) {
|
||||
const resolved = resolveAgentIdFromSessionKey(sessionKeyRaw);
|
||||
if (agentId && resolved !== agentId) {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
errorShape(
|
||||
ErrorCodes.INVALID_REQUEST,
|
||||
`invalid agent.identity.get params: agent "${agentIdRaw}" does not match session key agent "${resolved}"`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
agentId = resolved;
|
||||
}
|
||||
const cfg = loadConfig();
|
||||
const identity = resolveAssistantIdentity({ cfg, agentId });
|
||||
respond(true, identity, undefined);
|
||||
},
|
||||
"agent.wait": async ({ params, respond }) => {
|
||||
if (!validateAgentWaitParams(params)) {
|
||||
respond(
|
||||
|
||||
Reference in New Issue
Block a user