Merge branch 'main' into fix/export-ansi-indentation

This commit is contained in:
Mario Zechner 2026-02-05 03:13:32 +01:00 committed by GitHub
commit 2f18057ac2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 45 additions and 20 deletions

View file

@ -695,9 +695,9 @@ export class AgentSession {
);
}
if (options.streamingBehavior === "followUp") {
await this._queueFollowUp(expandedText);
await this._queueFollowUp(expandedText, currentImages);
} else {
await this._queueSteer(expandedText);
await this._queueSteer(expandedText, currentImages);
}
return;
}
@ -856,9 +856,10 @@ export class AgentSession {
* Queue a steering message to interrupt the agent mid-run.
* Delivered after current tool execution, skips remaining tools.
* Expands skill commands and prompt templates. Errors on extension commands.
* @param images Optional image attachments to include with the message
* @throws Error if text is an extension command
*/
async steer(text: string): Promise<void> {
async steer(text: string, images?: ImageContent[]): Promise<void> {
// Check for extension commands (cannot be queued)
if (text.startsWith("/")) {
this._throwIfExtensionCommand(text);
@ -868,16 +869,17 @@ export class AgentSession {
let expandedText = this._expandSkillCommand(text);
expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
await this._queueSteer(expandedText);
await this._queueSteer(expandedText, images);
}
/**
* Queue a follow-up message to be processed after the agent finishes.
* Delivered only when agent has no more tool calls or steering messages.
* Expands skill commands and prompt templates. Errors on extension commands.
* @param images Optional image attachments to include with the message
* @throws Error if text is an extension command
*/
async followUp(text: string): Promise<void> {
async followUp(text: string, images?: ImageContent[]): Promise<void> {
// Check for extension commands (cannot be queued)
if (text.startsWith("/")) {
this._throwIfExtensionCommand(text);
@ -887,17 +889,21 @@ export class AgentSession {
let expandedText = this._expandSkillCommand(text);
expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
await this._queueFollowUp(expandedText);
await this._queueFollowUp(expandedText, images);
}
/**
* Internal: Queue a steering message (already expanded, no extension command check).
*/
private async _queueSteer(text: string): Promise<void> {
private async _queueSteer(text: string, images?: ImageContent[]): Promise<void> {
this._steeringMessages.push(text);
const content: (TextContent | ImageContent)[] = [{ type: "text", text }];
if (images) {
content.push(...images);
}
this.agent.steer({
role: "user",
content: [{ type: "text", text }],
content,
timestamp: Date.now(),
});
}
@ -905,11 +911,15 @@ export class AgentSession {
/**
* Internal: Queue a follow-up message (already expanded, no extension command check).
*/
private async _queueFollowUp(text: string): Promise<void> {
private async _queueFollowUp(text: string, images?: ImageContent[]): Promise<void> {
this._followUpMessages.push(text);
const content: (TextContent | ImageContent)[] = [{ type: "text", text }];
if (images) {
content.push(...images);
}
this.agent.followUp({
role: "user",
content: [{ type: "text", text }],
content,
timestamp: Date.now(),
});
}

View file

@ -175,15 +175,15 @@ export class RpcClient {
/**
* Queue a steering message to interrupt the agent mid-run.
*/
async steer(message: string): Promise<void> {
await this.send({ type: "steer", message });
async steer(message: string, images?: ImageContent[]): Promise<void> {
await this.send({ type: "steer", message, images });
}
/**
* Queue a follow-up message to be processed after the agent finishes.
*/
async followUp(message: string): Promise<void> {
await this.send({ type: "follow_up", message });
async followUp(message: string, images?: ImageContent[]): Promise<void> {
await this.send({ type: "follow_up", message, images });
}
/**

View file

@ -328,12 +328,12 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
}
case "steer": {
await session.steer(command.message);
await session.steer(command.message, command.images);
return success(id, "steer");
}
case "follow_up": {
await session.followUp(command.message);
await session.followUp(command.message, command.images);
return success(id, "follow_up");
}

View file

@ -18,8 +18,8 @@ import type { CompactionResult } from "../../core/compaction/index.js";
export type RpcCommand =
// Prompting
| { id?: string; type: "prompt"; message: string; images?: ImageContent[]; streamingBehavior?: "steer" | "followUp" }
| { id?: string; type: "steer"; message: string }
| { id?: string; type: "follow_up"; message: string }
| { id?: string; type: "steer"; message: string; images?: ImageContent[] }
| { id?: string; type: "follow_up"; message: string; images?: ImageContent[] }
| { id?: string; type: "abort" }
| { id?: string; type: "new_session"; parentSession?: string }