fix(cli,core): resolve lint and type errors in agent stream and core types

This commit is contained in:
Michael Bleigh
2026-03-24 19:10:09 -07:00
parent f853d2f9da
commit 0afe5117a4
6 changed files with 373 additions and 197 deletions
@@ -211,7 +211,9 @@ class LegacyAgentProtocol implements AgentProtocol {
this._emit(toolUpdates);
};
this._config.getMessageBus().subscribe(MessageBusType.TOOL_CALLS_UPDATE, handleToolCallsUpdate);
this._config
.getMessageBus()
.subscribe(MessageBusType.TOOL_CALLS_UPDATE, handleToolCallsUpdate);
try {
while (true) {
@@ -246,17 +248,23 @@ class LegacyAgentProtocol implements AgentProtocol {
toolCallRequests.push(event.value);
}
const translatedEvents = translateEvent(event, this._translationState);
const translatedEvents = translateEvent(
event,
this._translationState,
);
for (const ev of translatedEvents) {
if (ev.type === 'tool_request') {
const tool = this._config.getToolRegistry().getTool(ev.name);
const invocation = tool?.build(ev.args);
ev._meta = {
displayName: tool?.displayName ?? ev.name,
description: invocation?.getDescription() ?? tool?.description ?? '',
isOutputMarkdown: tool?.isOutputMarkdown ?? false,
kind: tool?.kind,
legacyState: {
displayName: tool?.displayName ?? ev.name,
description:
invocation?.getDescription() ?? tool?.description ?? '',
isOutputMarkdown: tool?.isOutputMarkdown ?? false,
kind: tool?.kind,
},
};
}
}
@@ -371,7 +379,9 @@ class LegacyAgentProtocol implements AgentProtocol {
currentParts = toolResponseParts;
}
} finally {
this._config.getMessageBus().unsubscribe(MessageBusType.TOOL_CALLS_UPDATE, handleToolCallsUpdate);
this._config
.getMessageBus()
.unsubscribe(MessageBusType.TOOL_CALLS_UPDATE, handleToolCallsUpdate);
}
}
+29
View File
@@ -182,6 +182,16 @@ export interface ToolRequest {
name: string;
/** The arguments for the tool. */
args: Record<string, unknown>;
/** UI specific metadata */
_meta?: {
legacyState?: {
displayName?: string;
isOutputMarkdown?: boolean;
description?: string;
kind?: string;
};
[key: string]: unknown;
};
}
/**
@@ -194,6 +204,18 @@ export interface ToolUpdate {
displayContent?: ContentPart[];
content?: ContentPart[];
data?: Record<string, unknown>;
/** UI specific metadata */
_meta?: {
legacyState?: {
status?: string;
progressMessage?: string;
progress?: number;
progressTotal?: number;
pid?: number;
description?: string;
};
[key: string]: unknown;
};
}
export interface ToolResponse {
@@ -207,6 +229,13 @@ export interface ToolResponse {
data?: Record<string, unknown>;
/** When true, the tool call encountered an error that will be sent to the model. */
isError?: boolean;
/** UI specific metadata */
_meta?: {
legacyState?: {
outputFile?: string;
};
[key: string]: unknown;
};
}
export type ElicitationRequest = {