mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 06:02:42 +00:00
Change branch() to use entryId instead of entryIndex
- AgentSession.branch(entryId: string) now takes entry ID - SessionBeforeBranchEvent.entryId replaces entryIndex - getUserMessagesForBranching() returns entryId - Update RPC types and client - Update UserMessageSelectorComponent - Update hook examples and tests - Update docs (hooks.md, sdk.md)
This commit is contained in:
parent
027d39aa33
commit
8e1e99ca05
12 changed files with 64 additions and 50 deletions
|
|
@ -326,17 +326,17 @@ export class RpcClient {
|
|||
* Branch from a specific message.
|
||||
* @returns Object with `text` (the message text) and `cancelled` (if hook cancelled)
|
||||
*/
|
||||
async branch(entryIndex: number): Promise<{ text: string; cancelled: boolean }> {
|
||||
const response = await this.send({ type: "branch", entryIndex });
|
||||
async branch(entryId: string): Promise<{ text: string; cancelled: boolean }> {
|
||||
const response = await this.send({ type: "branch", entryId });
|
||||
return this.getData(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get messages available for branching.
|
||||
*/
|
||||
async getBranchMessages(): Promise<Array<{ entryIndex: number; text: string }>> {
|
||||
async getBranchMessages(): Promise<Array<{ entryId: string; text: string }>> {
|
||||
const response = await this.send({ type: "get_branch_messages" });
|
||||
return this.getData<{ messages: Array<{ entryIndex: number; text: string }> }>(response).messages;
|
||||
return this.getData<{ messages: Array<{ entryId: string; text: string }> }>(response).messages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
|||
}
|
||||
|
||||
case "branch": {
|
||||
const result = await session.branch(command.entryIndex);
|
||||
const result = await session.branch(command.entryId);
|
||||
return success(id, "branch", { text: result.selectedText, cancelled: result.cancelled });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ export type RpcCommand =
|
|||
| { id?: string; type: "get_session_stats" }
|
||||
| { id?: string; type: "export_html"; outputPath?: string }
|
||||
| { id?: string; type: "switch_session"; sessionPath: string }
|
||||
| { id?: string; type: "branch"; entryIndex: number }
|
||||
| { id?: string; type: "branch"; entryId: string }
|
||||
| { id?: string; type: "get_branch_messages" }
|
||||
| { id?: string; type: "get_last_assistant_text" }
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ export type RpcResponse =
|
|||
type: "response";
|
||||
command: "get_branch_messages";
|
||||
success: true;
|
||||
data: { messages: Array<{ entryIndex: number; text: string }> };
|
||||
data: { messages: Array<{ entryId: string; text: string }> };
|
||||
}
|
||||
| {
|
||||
id?: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue