mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
Machine-produced by `pnpm run rescope-vendor --apply` plus the regeneration it prints: `pnpm install` for the lockfile, `pnpm run gen-third-party-notices`, `verify-translation-pairing --write` for the touched bilingual pairs, `gen-doc-graphs`, and one typert snapshot whose ids embed character offsets. `pnpm run rescope-vendor --check` verifies the result. Renames nine vendored packages (cordis, cosmokit, schemastery and the six @cordisjs plugins) and every reference that resolves them: manifest names and dependency keys, module specifiers including declare-module merges, cordis.yml plugin names, tsconfig paths, every Markdown fence, and `docs/` prose. Directory names, upstream versions, and dependency ranges are unchanged, so vendor/README.md still reads as an upstream snapshot; its manifest table gains an upstream-name column so THIRD_PARTY_NOTICES keeps MIT attribution pointed at each fork's origin. The tutorial tier follows the rename end to end: its yaml fences named plugins the Loader can no longer resolve, its `ts ignore-check` fences disagreed with the compiled fences beside them, and its prose quoted both. The contracts that told readers to keep upstream names — the root convention and the vendoring cookbook's tree comment and manifest invariant — now say to rescope instead. Two rules read `@deepseek-ai/` as "another workspace plugin": the client bundle purity gate now names the vendored libraries a browser bundle inlines, and the files where a bare `cordis` is an agent-preset id keep that product data.
102 lines
3.0 KiB
TypeScript
102 lines
3.0 KiB
TypeScript
/**
|
|
* Fixed Codex one-shot subagent provider. Every accepted run starts a fresh
|
|
* official `codex app-server --stdio` process in the delegating Session's
|
|
* workspace and publishes only after an ephemeral thread exists.
|
|
*
|
|
* @module @deepseek-ai/dsh-subagent-codex
|
|
*/
|
|
|
|
import type { Context } from '@deepseek-ai/cordis'
|
|
import z from '@deepseek-ai/schemastery'
|
|
import { MAX_TIMER_DELAY_MS } from '@deepseek-ai/dsh-timeout'
|
|
import {
|
|
assertPositiveFinite,
|
|
NO_START_CAPABILITIES,
|
|
resolveChildCwd,
|
|
type ResolvedSubagentStartRequest,
|
|
type SubagentCapabilities,
|
|
type SubagentProvider,
|
|
} from '@deepseek-ai/dsh-subagent'
|
|
import {
|
|
DEFAULT_DISPOSE_GRACE_MS,
|
|
startCodexRun,
|
|
type CodexRunSpec,
|
|
} from './run.ts'
|
|
|
|
export const name = 'subagent-codex'
|
|
export const inject = ['subagents', 'subprocess']
|
|
|
|
/** Deployment-owned environment and process-release bound. */
|
|
export interface Config {
|
|
/**
|
|
* Explicit environment entries layered over the subprocess seam's
|
|
* credential-scrubbed parent environment.
|
|
*/
|
|
env?: Record<string, string>
|
|
/** Grace in milliseconds for app-server process-tree termination. */
|
|
disposeGraceMs?: number
|
|
}
|
|
|
|
export const Config: z<Config> = z.object({
|
|
env: z.dict(z.string()).default({}),
|
|
disposeGraceMs: z.number().default(DEFAULT_DISPOSE_GRACE_MS),
|
|
})
|
|
|
|
type ResolvedConfig = Required<Config>
|
|
|
|
class CodexProvider implements SubagentProvider {
|
|
readonly name = 'codex'
|
|
readonly capabilities: SubagentCapabilities = NO_START_CAPABILITIES
|
|
readonly inheritsParentContext = false
|
|
|
|
constructor(
|
|
private readonly ctx: Context,
|
|
private readonly config: ResolvedConfig,
|
|
) {}
|
|
|
|
start(request: ResolvedSubagentStartRequest) {
|
|
const parentCwd = request.parent.session.header.cwd
|
|
if (parentCwd === undefined) {
|
|
throw new Error(
|
|
'subagent-codex: no working directory for the child — delegate from a parent session that has one',
|
|
)
|
|
}
|
|
const spec: CodexRunSpec = {
|
|
cwd: resolveChildCwd(
|
|
'subagent-codex',
|
|
undefined,
|
|
parentCwd,
|
|
),
|
|
env: this.config.env,
|
|
disposeGraceMs: this.config.disposeGraceMs,
|
|
spawn: spawnSpec => this.ctx.subprocess.spawn(spawnSpec),
|
|
onError: (error, stopReason) => {
|
|
this.ctx.logger.warn(
|
|
`subagent-codex: child run failed (${stopReason}): ${error.message}`,
|
|
)
|
|
},
|
|
}
|
|
return startCodexRun(request, spec)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register the fixed `codex` provider.
|
|
* @param ctx - context carrying shared subagent and subprocess services.
|
|
* @param config - explicit child environment and disposal grace.
|
|
*/
|
|
export function apply(ctx: Context, config: Config): void {
|
|
const resolved = config as ResolvedConfig
|
|
assertPositiveFinite(
|
|
'subagent-codex',
|
|
'disposeGraceMs',
|
|
resolved.disposeGraceMs,
|
|
)
|
|
if (resolved.disposeGraceMs > MAX_TIMER_DELAY_MS) {
|
|
throw new Error(
|
|
`subagent-codex: disposeGraceMs must be no greater than ${MAX_TIMER_DELAY_MS}`,
|
|
)
|
|
}
|
|
ctx.subagents.registerProvider(new CodexProvider(ctx, resolved))
|
|
}
|