fix: restore coding history and quota feedback

This commit is contained in:
inman
2026-09-01 11:46:04 +08:00
parent 38f85f6b5e
commit d523b72cf8
14 changed files with 480 additions and 49 deletions

View File

@@ -6,8 +6,8 @@ import type {
ConversationToolNode,
PublicUsage,
} from '../contracts';
import { isAIGatewayUserContextMissing } from '../../../shared/ai-gateway-error-details';
import type { PiRpcEvent } from './rpc-client';
import { projectPiProviderFailure } from './provider-failure';
import { subagentDetailsOfResult } from '../subagent-protocol';
import {
isProductToolName,
@@ -45,17 +45,6 @@ function retryFailure(message: string) {
};
}
function providerFailure(message: unknown) {
if (typeof message === 'string' && isAIGatewayUserContextMissing(message)) {
return {
code: 'CODING_PROVIDER_AUTH_REQUIRED' as const,
message: '模型服务身份上下文无效,请重试;若仍失败请重新登录。',
recoverable: true,
};
}
return retryFailure('模型服务请求失败,请稍后重试。');
}
function asRecord(value: unknown): Record<string, unknown> | null {
return value !== null && typeof value === 'object' && !Array.isArray(value)
? value as Record<string, unknown>
@@ -294,7 +283,7 @@ export class PiEventProjector {
...run,
status: 'error',
terminalReason: 'failed',
error: providerFailure(event.finalError),
error: projectPiProviderFailure(event.finalError),
},
}];
}
@@ -485,7 +474,7 @@ export class PiEventProjector {
...snapshot.run,
status: 'error',
terminalReason: 'failed',
error: providerFailure(assistant.errorMessage),
error: projectPiProviderFailure(assistant.errorMessage),
},
}];
}