feat(agents): support chat to agent (#403)
This commit is contained in:
@@ -59,6 +59,10 @@ interface BindingConfig extends Record<string, unknown> {
|
||||
interface AgentConfigDocument extends Record<string, unknown> {
|
||||
agents?: AgentsConfig;
|
||||
bindings?: BindingConfig[];
|
||||
session?: {
|
||||
mainKey?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AgentSummary {
|
||||
@@ -69,6 +73,7 @@ export interface AgentSummary {
|
||||
inheritedModel: boolean;
|
||||
workspace: string;
|
||||
agentDir: string;
|
||||
mainSessionKey: string;
|
||||
channelTypes: string[];
|
||||
}
|
||||
|
||||
@@ -201,6 +206,16 @@ function normalizeAgentIdForBinding(id: string): string {
|
||||
return (id ?? '').trim().toLowerCase() || '';
|
||||
}
|
||||
|
||||
function normalizeMainKey(value: unknown): string {
|
||||
if (typeof value !== 'string') return 'main';
|
||||
const trimmed = value.trim().toLowerCase();
|
||||
return trimmed || 'main';
|
||||
}
|
||||
|
||||
function buildAgentMainSessionKey(config: AgentConfigDocument, agentId: string): string {
|
||||
return `agent:${normalizeAgentIdForBinding(agentId) || MAIN_AGENT_ID}:${normalizeMainKey(config.session?.mainKey)}`;
|
||||
}
|
||||
|
||||
function getSimpleChannelBindingMap(bindings: unknown): Map<string, string> {
|
||||
const owners = new Map<string, string>();
|
||||
if (!Array.isArray(bindings)) return owners;
|
||||
@@ -369,6 +384,7 @@ async function buildSnapshotFromConfig(config: AgentConfigDocument): Promise<Age
|
||||
inheritedModel,
|
||||
workspace: entry.workspace || (entry.id === MAIN_AGENT_ID ? getDefaultWorkspacePath(config) : `~/.openclaw/workspace-${entry.id}`),
|
||||
agentDir: entry.agentDir || getDefaultAgentDirPath(entry.id),
|
||||
mainSessionKey: buildAgentMainSessionKey(config, entry.id),
|
||||
channelTypes: configuredChannels.filter((channelType) => channelOwners[channelType] === entryIdNorm),
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user