15c227cebf
完善Codex CLI、App Server、ConPTY与进程会话在Windows下的发现、启动、恢复和退出行为 修复Agent Runtime、Provider重试、项目写锁及工具交接账本的并发与跨测试串线问题 补齐配置目录、路径脱敏、原子写入、浏览器探测和本地Provider smoke的跨平台兼容 增强Goal Contract、自动策略、资源生成及运行态恢复的契约和回归测试 更新AI游戏创作智能体App技术文档中的Windows稳定性说明 验证AGC开发态、Release打包、打包后GUI运行及完整agc:check门禁
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
export function buildProcessSessionFixtureSource({
|
|
readyPrefix,
|
|
echoPrefix,
|
|
stoppedMarker,
|
|
}) {
|
|
for (const [name, value] of Object.entries({
|
|
readyPrefix,
|
|
echoPrefix,
|
|
stoppedMarker,
|
|
})) {
|
|
if (
|
|
typeof value !== 'string' ||
|
|
value.length === 0 ||
|
|
/[\r\n]/u.test(value)
|
|
) {
|
|
throw new Error(`invalid process fixture marker: ${name}`);
|
|
}
|
|
}
|
|
|
|
return [
|
|
"import { randomBytes } from 'node:crypto';",
|
|
'',
|
|
`const readyPrefix = ${JSON.stringify(readyPrefix)};`,
|
|
`const echoPrefix = ${JSON.stringify(echoPrefix)};`,
|
|
`const stoppedMarker = ${JSON.stringify(stoppedMarker)};`,
|
|
"const challenge = randomBytes(18).toString('hex');",
|
|
'let echoed = false;',
|
|
'let stopping = false;',
|
|
'',
|
|
'function stop() {',
|
|
' if (stopping) return;',
|
|
' stopping = true;',
|
|
' console.log(stoppedMarker);',
|
|
' process.exit(0);',
|
|
'}',
|
|
"for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.on(signal, stop);",
|
|
"console.log(readyPrefix + ' challenge=' + challenge);",
|
|
'',
|
|
"process.stdin.setEncoding('utf8');",
|
|
"let buffered = '';",
|
|
"process.stdin.on('data', (chunk) => {",
|
|
' buffered += chunk;',
|
|
' const lines = buffered.split(/\\r?\\n/u);',
|
|
" buffered = lines.pop() ?? '';",
|
|
' for (const line of lines) {',
|
|
' if (!echoed && line === challenge) {',
|
|
' echoed = true;',
|
|
" console.log(echoPrefix + ' ' + challenge);",
|
|
" } else if (line === challenge + ':stop') {",
|
|
' stop();',
|
|
' }',
|
|
' }',
|
|
'});',
|
|
'process.stdin.resume();',
|
|
'',
|
|
].join('\n');
|
|
}
|