merge: integrate upstream main with local Makelore changes
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
spawn,
|
||||
type ChildProcessWithoutNullStreams,
|
||||
} from 'node:child_process';
|
||||
import { realpathSync } from 'node:fs';
|
||||
import { platform } from 'node:os';
|
||||
import { logger } from '../../utils/logger';
|
||||
import type { CodingRuntimeDisposeReason } from '../contracts';
|
||||
@@ -128,6 +129,9 @@ export const PI_CORE_TOOL_NAMES = Object.freeze([
|
||||
'task_state', 'changed_file', 'runtime_context',
|
||||
] as const);
|
||||
|
||||
/** Compatibility alias used by the shared Agent Server transport. */
|
||||
export const DEFAULT_PI_RPC_TOOLS = PI_CORE_TOOL_NAMES;
|
||||
|
||||
export function buildPiRpcArgs(
|
||||
sessionDir: string,
|
||||
additionalArgs: readonly string[] = [],
|
||||
@@ -164,6 +168,16 @@ export function sanitizePiDiagnostic(
|
||||
return sanitized;
|
||||
}
|
||||
|
||||
function diagnosticPathAliases(value: string | undefined): string[] {
|
||||
if (!value) return [];
|
||||
try {
|
||||
const canonical = realpathSync.native(value);
|
||||
return canonical === value ? [value] : [value, canonical];
|
||||
} catch {
|
||||
return [value];
|
||||
}
|
||||
}
|
||||
|
||||
export function buildPiWorkerEnvironment(
|
||||
configDir: string,
|
||||
overlay: NodeJS.ProcessEnv = {},
|
||||
@@ -265,8 +279,7 @@ export class PiWorkerProcess {
|
||||
DEFAULT_DIAGNOSTIC_BYTES,
|
||||
'diagnosticBytes',
|
||||
);
|
||||
this.diagnosticSensitiveValues = [...new Set([
|
||||
...(options.sensitiveValues ?? []),
|
||||
const diagnosticPaths = [
|
||||
options.cwd,
|
||||
options.cliPath,
|
||||
options.configDir,
|
||||
@@ -275,6 +288,10 @@ export class PiWorkerProcess {
|
||||
options.env?.USERPROFILE,
|
||||
options.env?.APPDATA,
|
||||
options.env?.LOCALAPPDATA,
|
||||
].flatMap(diagnosticPathAliases);
|
||||
this.diagnosticSensitiveValues = [...new Set([
|
||||
...(options.sensitiveValues ?? []),
|
||||
...diagnosticPaths,
|
||||
].filter((value): value is string => Boolean(value)))];
|
||||
}
|
||||
|
||||
@@ -472,7 +489,7 @@ export class PiWorkerProcess {
|
||||
private handleProtocolFailure(error: unknown): void {
|
||||
if (this.invalidation) return;
|
||||
const message = error instanceof Error ? error.message : 'Pi RPC protocol failure';
|
||||
this.appendDiagnostic('[stdout-protocol]\n');
|
||||
this.appendDiagnostic(`[stdout-protocol] ${message}\n`);
|
||||
const failure = new PiProcessError('PI_RPC_PROTOCOL_ERROR', message, {
|
||||
cause: error,
|
||||
generation: this.generationValue,
|
||||
|
||||
Reference in New Issue
Block a user