mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
fix(subagent-codex): support Windows command shims
This commit is contained in:
@@ -24,6 +24,23 @@ import { CodexAppServerWire } from './wire.ts'
|
||||
/** Default POSIX grace between subprocess termination tiers. */
|
||||
export const DEFAULT_DISPOSE_GRACE_MS = 3_000
|
||||
|
||||
/**
|
||||
* Resolve the fixed app-server command for a platform.
|
||||
*
|
||||
* Windows npm and pnpm installs expose `codex.cmd`, which requires `cmd.exe`;
|
||||
* the argv is constant so no task or configuration text enters the
|
||||
* shell boundary.
|
||||
* @param platform - host platform used to select the executable boundary.
|
||||
* @returns argv for the fixed Codex app-server command.
|
||||
*/
|
||||
export function codexAppServerArgv(
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): string[] {
|
||||
return platform === 'win32'
|
||||
? ['cmd.exe', '/d', '/s', '/c', 'codex', 'app-server', '--stdio']
|
||||
: ['codex', 'app-server', '--stdio']
|
||||
}
|
||||
|
||||
/** Fully resolved inputs for one Codex app-server run. */
|
||||
export interface CodexRunSpec {
|
||||
/** Parent Session workspace, also supplied to `thread/start`. */
|
||||
@@ -106,7 +123,7 @@ export async function startCodexRun(
|
||||
}
|
||||
|
||||
const child = spec.spawn({
|
||||
argv: ['codex', 'app-server', '--stdio'],
|
||||
argv: codexAppServerArgv(),
|
||||
cwd: spec.cwd,
|
||||
stdio: { stdin: 'pipe', stdout: 'pipe', stderr: 'inherit' },
|
||||
graceMs: spec.disposeGraceMs,
|
||||
|
||||
@@ -15,6 +15,7 @@ import LocalSubprocessService from '@deepseek-ai/dsh-subprocess-local'
|
||||
import * as codex from '../src/index.ts'
|
||||
import * as invariant from '../src/invariant.ts'
|
||||
import {
|
||||
codexAppServerArgv,
|
||||
DEFAULT_DISPOSE_GRACE_MS,
|
||||
disposeCodexChild,
|
||||
startCodexRun,
|
||||
@@ -259,6 +260,19 @@ function turnCompleted(
|
||||
}
|
||||
|
||||
describe('task admission and package contracts', () => {
|
||||
it('resolves the fixed app-server command through the Windows npm shim boundary', () => {
|
||||
expect(codexAppServerArgv('win32')).toEqual([
|
||||
'cmd.exe',
|
||||
'/d',
|
||||
'/s',
|
||||
'/c',
|
||||
'codex',
|
||||
'app-server',
|
||||
'--stdio',
|
||||
])
|
||||
expect(codexAppServerArgv('linux')).toEqual(['codex', 'app-server', '--stdio'])
|
||||
})
|
||||
|
||||
it('accepts one or more text blocks and rejects empty or non-text tasks', () => {
|
||||
expect(textTask([
|
||||
{ type: 'text', text: 'one' },
|
||||
@@ -868,7 +882,7 @@ describe('run lifecycle and quiescence', () => {
|
||||
child.peer.respond(threadStart, { thread: { id: 'thread-1', ephemeral: true } })
|
||||
const run = await starting
|
||||
expect(spawn).toHaveBeenCalledWith({
|
||||
argv: ['codex', 'app-server', '--stdio'],
|
||||
argv: codexAppServerArgv(),
|
||||
cwd: process.cwd(),
|
||||
stdio: { stdin: 'pipe', stdout: 'pipe', stderr: 'inherit' },
|
||||
graceMs: DEFAULT_DISPOSE_GRACE_MS,
|
||||
|
||||
Reference in New Issue
Block a user