merge: integrate upstream main with local Makelore changes
This commit is contained in:
@@ -507,7 +507,7 @@ function publicWorkerState(state: PiWorkerPoolState): ConversationSnapshot['work
|
||||
code: state.failureCode === 'PI_RPC_PROTOCOL_ERROR'
|
||||
? 'CODING_RUNTIME_PROTOCOL_ERROR'
|
||||
: 'CODING_RUNTIME_START_FAILED',
|
||||
message: 'The local Agent worker stopped unexpectedly',
|
||||
message: '本地 Agent 服务已中断。',
|
||||
recoverable: true,
|
||||
},
|
||||
};
|
||||
@@ -515,6 +515,17 @@ function publicWorkerState(state: PiWorkerPoolState): ConversationSnapshot['work
|
||||
return { status: 'ready', generation: state.generation };
|
||||
}
|
||||
|
||||
function samePublicWorkerState(
|
||||
left: ConversationSnapshot['worker'],
|
||||
right: ConversationSnapshot['worker'],
|
||||
): boolean {
|
||||
return left.status === right.status
|
||||
&& left.generation === right.generation
|
||||
&& left.error?.code === right.error?.code
|
||||
&& left.error?.message === right.error?.message
|
||||
&& left.error?.recoverable === right.error?.recoverable;
|
||||
}
|
||||
|
||||
function runtimeFailure(error: unknown): CodingRuntimePublicError {
|
||||
if (error instanceof CodingRuntimeContractError) return clone(error.publicError);
|
||||
if (error instanceof PiSessionProjectionError) {
|
||||
@@ -524,7 +535,7 @@ function runtimeFailure(error: unknown): CodingRuntimePublicError {
|
||||
if (error.code === 'PI_RPC_PROTOCOL_ERROR') {
|
||||
return {
|
||||
code: 'CODING_RUNTIME_PROTOCOL_ERROR',
|
||||
message: 'The local Agent protocol failed',
|
||||
message: '本地 Agent 通信异常,当前对话已停止。',
|
||||
recoverable: true,
|
||||
};
|
||||
}
|
||||
@@ -545,7 +556,7 @@ function runtimeFailure(error: unknown): CodingRuntimePublicError {
|
||||
}
|
||||
return {
|
||||
code: 'CODING_RUNTIME_START_FAILED',
|
||||
message: 'The local Agent is unavailable',
|
||||
message: '本地 Agent 服务暂不可用。',
|
||||
recoverable: true,
|
||||
};
|
||||
}
|
||||
@@ -639,7 +650,10 @@ export class PiConversationRuntime implements CodingConversationRuntime {
|
||||
});
|
||||
}
|
||||
this.interactions = new PiInteractionStore(this.pool, (interaction) => {
|
||||
this.emit(interaction.conversationId, { op: 'interaction.upsert', interaction }, interaction.runId);
|
||||
this.emit(interaction.conversationId, {
|
||||
op: 'interaction.remove',
|
||||
interactionId: interaction.id,
|
||||
}, interaction.runId);
|
||||
});
|
||||
this.extensionUi = new PiExtensionUiProjector({
|
||||
getDraftRevision: options.getDraftRevision ?? (() => 0),
|
||||
@@ -677,7 +691,10 @@ export class PiConversationRuntime implements CodingConversationRuntime {
|
||||
));
|
||||
this.resetProjector(input.conversationId);
|
||||
} else {
|
||||
this.emit(input.conversationId, { op: 'worker.state', state: publicWorkerState(worker) });
|
||||
const nextWorker = publicWorkerState(worker);
|
||||
if (!samePublicWorkerState(this.snapshot(input.conversationId).worker, nextWorker)) {
|
||||
this.emit(input.conversationId, { op: 'worker.state', state: nextWorker });
|
||||
}
|
||||
}
|
||||
if (isNewState) {
|
||||
try {
|
||||
@@ -1464,6 +1481,8 @@ export class PiConversationRuntime implements CodingConversationRuntime {
|
||||
run: {
|
||||
status: 'idle',
|
||||
runId: event.runId,
|
||||
...(current.mode ? { mode: current.mode } : {}),
|
||||
...(current.startedAt !== undefined ? { startedAt: current.startedAt } : {}),
|
||||
settledAt: this.now(),
|
||||
terminalReason: 'completed',
|
||||
},
|
||||
@@ -1624,6 +1643,8 @@ export class PiConversationRuntime implements CodingConversationRuntime {
|
||||
run: {
|
||||
status: 'error',
|
||||
runId,
|
||||
...(current.mode ? { mode: current.mode } : {}),
|
||||
...(current.startedAt !== undefined ? { startedAt: current.startedAt } : {}),
|
||||
settledAt: this.now(),
|
||||
terminalReason: 'failed',
|
||||
error: publicError,
|
||||
|
||||
Reference in New Issue
Block a user