This commit is contained in:
2026-07-26 14:02:37 +07:00
parent bc56546b49
commit 367ebc1c7f
171 changed files with 4617 additions and 10402 deletions
+12 -10
View File
@@ -176,7 +176,9 @@ export type AgentSessionEvent =
source: "compaction";
reason: "manual" | "threshold" | "overflow";
}
| { type: "summarization_retry_finished" };
| { type: "summarization_retry_finished" }
| { type: "auto_retry_end"; success: boolean; attempt: number; finalError?: string }
| { type: "bash_execution_update"; id?: string; delta: string };
/** Listener function for agent session events */
export type AgentSessionEventListener = (event: AgentSessionEvent) => void;
@@ -403,7 +405,7 @@ export class AgentSession {
}
private async _getRequiredRequestAuth(model: Model<any>): Promise<{
apiKey: string;
apiKey?: string;
headers?: Record<string, string>;
env?: Record<string, string>;
}> {
@@ -417,7 +419,7 @@ export class AgentSession {
}
throw error;
}
if (result?.auth.apiKey) {
if (result && (result.auth.apiKey || result.auth.headers)) {
return {
apiKey: result.auth.apiKey,
headers: withoutDeletedHeaders(result.auth.headers),
@@ -2055,11 +2057,7 @@ export class AgentSession {
let headers: Record<string, string> | undefined;
let env: Record<string, string> | undefined;
if (this.agent.streamFunction === streamSimple) {
const authResult = await this._modelRuntime.getAuth(this.model);
if (!authResult?.auth.apiKey) return false;
apiKey = authResult.auth.apiKey;
headers = withoutDeletedHeaders(authResult.auth.headers);
env = authResult.env;
({ apiKey, headers, env } = await this._getRequiredRequestAuth(this.model));
} else {
({ apiKey, headers, env } = await this._getSummarizationRequestAuth(this.model));
}
@@ -2760,12 +2758,13 @@ export class AgentSession {
* @param command The bash command to execute
* @param onChunk Optional streaming callback for output
* @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)
* @param options.id Optional identifier included in bash execution update events
* @param options.operations Custom BashOperations for remote execution
*/
async executeBash(
command: string,
onChunk?: (chunk: string) => void,
options?: { excludeFromContext?: boolean; operations?: BashOperations },
options?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },
): Promise<BashResult> {
this._bashAbortController = new AbortController();
@@ -2780,7 +2779,10 @@ export class AgentSession {
this.sessionManager.getCwd(),
options?.operations ?? createLocalBashOperations({ shellPath }),
{
onChunk,
onChunk: (delta) => {
onChunk?.(delta);
this._emit({ type: "bash_execution_update", id: options?.id, delta });
},
signal: this._bashAbortController.signal,
},
);