chore(integration): snapshot local main worktree
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';
|
||||
@@ -121,14 +122,16 @@ export type PiWorkerProcessOptions = {
|
||||
onLifecycleEvent?(event: PiWorkerLifecycleEvent): void;
|
||||
};
|
||||
|
||||
export const DEFAULT_PI_RPC_TOOLS = [
|
||||
'read', 'bash', 'edit', 'write', 'grep', 'find', 'ls', 'ask_user', 'subagent',
|
||||
'agent_browser', 'game_asset_browser', 'game_asset_review',
|
||||
'task_state', 'changed_file', 'runtime_context',
|
||||
] as const;
|
||||
|
||||
export function buildPiRpcArgs(
|
||||
sessionDir: string,
|
||||
additionalArgs: readonly string[] = [],
|
||||
tools: readonly string[] = [
|
||||
'read', 'bash', 'edit', 'write', 'grep', 'find', 'ls', 'ask_user', 'subagent',
|
||||
'agent_browser', 'game_asset_browser', 'game_asset_review',
|
||||
'task_state', 'changed_file', 'runtime_context',
|
||||
],
|
||||
tools: readonly string[] = DEFAULT_PI_RPC_TOOLS,
|
||||
): string[] {
|
||||
return [
|
||||
'--mode', 'rpc',
|
||||
@@ -161,6 +164,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 = {},
|
||||
@@ -262,8 +275,7 @@ export class PiWorkerProcess {
|
||||
DEFAULT_DIAGNOSTIC_BYTES,
|
||||
'diagnosticBytes',
|
||||
);
|
||||
this.diagnosticSensitiveValues = [...new Set([
|
||||
...(options.sensitiveValues ?? []),
|
||||
const diagnosticPaths = [
|
||||
options.cwd,
|
||||
options.cliPath,
|
||||
options.configDir,
|
||||
@@ -272,6 +284,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)))];
|
||||
}
|
||||
|
||||
@@ -469,7 +485,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