@shuind/dsh-codex-harness 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  - **精简 Codex coding-agent 提示词**:使用精简版系统提示词;身份、模型和工作目录由 `dsh-persona` 提供,避免重复的 Harness 身份说明,同时保留必要的工具契约和编码工作流。
8
8
  - **Codex 工具**:`exec_command`、`write_stdin`、`apply_patch`、`update_plan`;`apply_patch` 匹配失败时会显示文件、hunk、行号、可见空白和附近文件内容,便于修正上下文。
9
+ - **后台任务**:`exec_command` 支持 `run_in_background: true`,立即返回 DSH `job_id`;使用 `job_output` 读取输出、`job_kill` 停止任务。任务完成时,忙碌中的 agent 会在下一步收到 inbox 注入;空闲 agent 默认保持安静,等下一次唤醒时再处理完成消息。
9
10
  - **GPT 能力补全**:为 GPT 系列模型补充图片输入和思考强度选项;不会覆盖用户已有的显式配置。
10
11
  - **Fast**:仅在 Codex preset 的模型选择菜单中显示,开启后向 Responses 请求发送 `service_tier: "priority"`。
11
12
  - **旧版 Web 兼容**:在未提供新版模型设置/上下文设置 slot 的 DSH Web 中,Fast 和上下文容量会自动回退到旧版 composer slot;client 注入不依赖纯类型 slot 包。
@@ -16,7 +17,7 @@
16
17
  ## 安装
17
18
 
18
19
  ```sh
19
- dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.21
20
+ dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.22
20
21
  ```
21
22
 
22
23
  重启 Web,创建新会话,在模式菜单中选择 **Codex 模式**。
@@ -83,6 +84,11 @@ Codex 等待模型首个输出时,Web 输入框上方会显示 `正在等待
83
84
  name: '@shuind/dsh-codex-harness'
84
85
  config:
85
86
  collaborationPrompt: true
87
+
88
+ - id: codex-jobs
89
+ name: '@deepseek-ai/dsh-tool-jobs'
90
+ config:
91
+ completionDelivery: quiet
86
92
  ```
87
93
 
88
94
  再写入 `preset.yml`,让 Web 中显示更清晰的名称:
@@ -93,7 +99,7 @@ description: 使用 Codex 工具并开启可选协作提示词。
93
99
  order: 10
94
100
  ```
95
101
 
96
- 然后在 Web 的 **Agent 预设** 中选择 `My Codex`,再新建会话。这个 preset 会加载 Codex 工具,并开启协作提示词;网页搜索、远程压缩和 Skills 等其他功能需要在同一个 `agent.cordis.yml` 中按需添加。
102
+ 然后在 Web 的 **Agent 预设** 中选择 `My Codex`,再新建会话。这个 preset 会加载 Codex 工具,并开启协作提示词;网页搜索、远程压缩、后台任务控制和 Skills 等其他功能需要在同一个 `agent.cordis.yml` 中按需添加。
97
103
 
98
104
  ### 可选协作提示词(私货)
99
105
 
package/lib/index.js CHANGED
@@ -261,6 +261,7 @@ function renderExecResult(result) {
261
261
  sections.push(`Wall time: ${result.wall_time_seconds.toFixed(4)} seconds`);
262
262
  if (result.exit_code !== void 0) sections.push(`Process exited with code ${result.exit_code}`);
263
263
  if (result.session_id !== void 0) sections.push(`Process running with session ID ${result.session_id}`);
264
+ if (result.job_id !== void 0) sections.push(`Background job ID: ${result.job_id}`);
264
265
  if (result.original_token_count !== void 0) sections.push(`Original token count: ${result.original_token_count}`);
265
266
  sections.push("Output:", result.output);
266
267
  return sections.join("\n");
@@ -281,6 +282,17 @@ function terminalResult(result, maxBytes, startedAt) {
281
282
  ...result.sessionStatus.kind === "exited" ? { ...result.sessionStatus.exitCode === null ? {} : { exit_code: result.sessionStatus.exitCode } } : {}
282
283
  });
283
284
  }
285
+ /** Map a detached shell process onto the generic DSH job outcome contract. */
286
+ function backgroundOutcome(process) {
287
+ if (process.status === "killed") return {
288
+ status: "killed",
289
+ detail: process.signal !== null ? `signal: ${process.signal}` : "killed before exit"
290
+ };
291
+ return {
292
+ status: "completed",
293
+ detail: `exit code: ${process.exitCode ?? 0}`
294
+ };
295
+ }
284
296
  function sleep(ms, signal) {
285
297
  return new Promise((resolve) => {
286
298
  let timer;
@@ -334,6 +346,7 @@ async function runExecCommand(ctx, args, exec, config) {
334
346
  const maxBytes = outputLimit(config.maxOutputBytes, args.max_output_tokens);
335
347
  const workdir = sessionCwd$1(exec, args.workdir);
336
348
  const startedAt = performance.now();
349
+ if (args.run_in_background === true && args.tty === true) throw new Error("run_in_background is only supported for pipe-backed commands; omit tty");
337
350
  if (args.tty === true) {
338
351
  const agent = exec.agent;
339
352
  const terminals = ctx.get("terminals");
@@ -377,11 +390,42 @@ async function runExecCommand(ctx, args, exec, config) {
377
390
  login: args.login ?? true,
378
391
  ...workdir === void 0 ? {} : { workdir },
379
392
  stdoutMaxBytes: maxBytes,
380
- signal: exec.signal,
381
393
  ...dshEnv === void 0 ? {} : { dshEnv },
382
394
  ...policy === void 0 ? {} : { sandboxPolicy: policy }
383
395
  };
384
- const process = ctx.shell.start(ctx.shell.resolve(shellRequest));
396
+ if (args.run_in_background === true) {
397
+ const owner = exec.agent;
398
+ if (owner === void 0) throw new Error("run_in_background requires an owning agent session");
399
+ const jobs = ctx.get("jobs");
400
+ if (jobs === void 0) throw new Error("background jobs unavailable: load @deepseek-ai/dsh-jobs and @deepseek-ai/dsh-tool-jobs");
401
+ if (exec.signal.aborted) {
402
+ exec.signal.throwIfAborted();
403
+ throw new Error("tool call aborted");
404
+ }
405
+ const id = jobs.start({
406
+ kind: "bash",
407
+ label: args.cmd,
408
+ owner,
409
+ outputLimitBytes: maxBytes,
410
+ run: () => {
411
+ const process = ctx.shell.start(ctx.shell.resolve(shellRequest));
412
+ return {
413
+ cancel: () => void process.kill(),
414
+ done: process.done.then(() => backgroundOutcome(process)),
415
+ readOutput: () => readShellOutput(process.readOutput(), maxBytes)
416
+ };
417
+ }
418
+ });
419
+ return withChunkId({
420
+ wall_time_seconds: (performance.now() - startedAt) / 1e3,
421
+ job_id: id,
422
+ output: `Started background job ${id}. Use job_output with job_id "${id}" to read output.`
423
+ });
424
+ }
425
+ const process = ctx.shell.start(ctx.shell.resolve({
426
+ ...shellRequest,
427
+ signal: exec.signal
428
+ }));
385
429
  try {
386
430
  await waitForShell(process, normalizeWaitMs(args.yield_time_ms, config.defaultYieldTimeMs), exec.signal);
387
431
  const output = readShellOutput(process.readOutput(), maxBytes);
@@ -1017,7 +1061,7 @@ function normalizeCodexPromptAssembly(assembly) {
1017
1061
  function buildCodexSystemPrompt(config = {}) {
1018
1062
  return config.collaborationPrompt === true ? `${CODEX_BASE_PROMPT}\n\n${CODEX_COLLABORATION_PROMPT}` : CODEX_BASE_PROMPT;
1019
1063
  }
1020
- const EXEC_COMMAND_DESCRIPTION = "Runs a command in a PTY, returning output or a session ID for ongoing interaction.";
1064
+ const EXEC_COMMAND_DESCRIPTION = "Runs a command in a PTY, returning output, a session ID for ongoing interaction, or a background job ID when requested.";
1021
1065
  const WRITE_STDIN_DESCRIPTION = "Writes characters to an existing unified exec session and returns recent output.";
1022
1066
  const APPLY_PATCH_DESCRIPTION = "Edits files using Codex patch syntax with Begin/End Patch markers and file update directives. In hunk lines, the first character is the operation marker; repeat a source-leading marker when the source line itself starts with one.";
1023
1067
  const UPDATE_PLAN_DESCRIPTION = "Updates the task plan.\nProvide an optional explanation and a list of plan items, each with a step and status.\nAt most one step can be in_progress at a time.";
@@ -1165,6 +1209,10 @@ function registerExecTools(ctx, config) {
1165
1209
  type: "boolean",
1166
1210
  description: "True allocates a PTY for the command; false or omitted uses plain pipes."
1167
1211
  },
1212
+ run_in_background: {
1213
+ type: "boolean",
1214
+ description: "Run as a DSH background job and return its job id immediately; collect output with job_output and stop it with job_kill. Only supported for pipe-backed commands."
1215
+ },
1168
1216
  yield_time_ms: {
1169
1217
  type: "number",
1170
1218
  description: "Wait before yielding output. Defaults to 10000 ms; effective range is 250-30000 ms."
@@ -1194,6 +1242,7 @@ function registerExecTools(ctx, config) {
1194
1242
  },
1195
1243
  exit_code: { type: "number" },
1196
1244
  session_id: { type: "number" },
1245
+ job_id: { type: "string" },
1197
1246
  original_token_count: { type: "number" },
1198
1247
  output: {
1199
1248
  type: "string",
@@ -6,6 +6,7 @@ export interface ExecCommandArgs {
6
6
  cmd: string;
7
7
  workdir?: string;
8
8
  tty?: boolean;
9
+ run_in_background?: boolean;
9
10
  yield_time_ms?: number;
10
11
  max_output_tokens?: number;
11
12
  shell?: string;
@@ -24,6 +25,7 @@ export interface ExecResult {
24
25
  wall_time_seconds: number;
25
26
  output: string;
26
27
  session_id?: number;
28
+ job_id?: string;
27
29
  exit_code?: number;
28
30
  original_token_count?: number;
29
31
  }
package/lib/types/exec.js CHANGED
@@ -56,6 +56,8 @@ export function renderExecResult(result) {
56
56
  sections.push(`Process exited with code ${result.exit_code}`);
57
57
  if (result.session_id !== undefined)
58
58
  sections.push(`Process running with session ID ${result.session_id}`);
59
+ if (result.job_id !== undefined)
60
+ sections.push(`Background job ID: ${result.job_id}`);
59
61
  if (result.original_token_count !== undefined)
60
62
  sections.push(`Original token count: ${result.original_token_count}`);
61
63
  sections.push('Output:', result.output);
@@ -80,6 +82,16 @@ function terminalResult(result, maxBytes, startedAt) {
80
82
  } : {},
81
83
  });
82
84
  }
85
+ /** Map a detached shell process onto the generic DSH job outcome contract. */
86
+ function backgroundOutcome(process) {
87
+ if (process.status === 'killed') {
88
+ return {
89
+ status: 'killed',
90
+ detail: process.signal !== null ? `signal: ${process.signal}` : 'killed before exit',
91
+ };
92
+ }
93
+ return { status: 'completed', detail: `exit code: ${process.exitCode ?? 0}` };
94
+ }
83
95
  function sleep(ms, signal) {
84
96
  return new Promise(resolve => {
85
97
  let timer;
@@ -144,6 +156,9 @@ export async function runExecCommand(ctx, args, exec, config) {
144
156
  const maxBytes = outputLimit(config.maxOutputBytes, args.max_output_tokens);
145
157
  const workdir = sessionCwd(exec, args.workdir);
146
158
  const startedAt = performance.now();
159
+ if (args.run_in_background === true && args.tty === true) {
160
+ throw new Error('run_in_background is only supported for pipe-backed commands; omit tty');
161
+ }
147
162
  if (args.tty === true) {
148
163
  const agent = exec.agent;
149
164
  const terminals = ctx.get('terminals');
@@ -187,17 +202,53 @@ export async function runExecCommand(ctx, args, exec, config) {
187
202
  }
188
203
  const policy = ctx.get('sandboxPolicy')?.resolve(exec.agent === undefined ? {} : { session: exec.agent.session });
189
204
  const dshEnv = ctx.get('shellEnv')?.collect(exec);
205
+ // Background jobs intentionally omit the tool-call signal. Once this call
206
+ // returns, the job lifetime belongs to the jobs registry, not the request.
190
207
  const shellRequest = {
191
208
  command: commandFor(args),
192
209
  ...args.shell === undefined ? {} : { shell: args.shell },
193
210
  login: args.login ?? true,
194
211
  ...workdir === undefined ? {} : { workdir },
195
212
  stdoutMaxBytes: maxBytes,
196
- signal: exec.signal,
197
213
  ...dshEnv === undefined ? {} : { dshEnv },
198
214
  ...policy === undefined ? {} : { sandboxPolicy: policy },
199
215
  };
200
- const process = ctx.shell.start(ctx.shell.resolve(shellRequest));
216
+ if (args.run_in_background === true) {
217
+ const owner = exec.agent;
218
+ if (owner === undefined)
219
+ throw new Error('run_in_background requires an owning agent session');
220
+ const jobs = ctx.get('jobs');
221
+ if (jobs === undefined) {
222
+ throw new Error('background jobs unavailable: load @deepseek-ai/dsh-jobs and @deepseek-ai/dsh-tool-jobs');
223
+ }
224
+ if (exec.signal.aborted) {
225
+ exec.signal.throwIfAborted();
226
+ throw new Error('tool call aborted');
227
+ }
228
+ const id = jobs.start({
229
+ kind: 'bash',
230
+ label: args.cmd,
231
+ owner,
232
+ outputLimitBytes: maxBytes,
233
+ run: () => {
234
+ const process = ctx.shell.start(ctx.shell.resolve(shellRequest));
235
+ return {
236
+ cancel: () => void process.kill(),
237
+ done: process.done.then(() => backgroundOutcome(process)),
238
+ readOutput: () => readShellOutput(process.readOutput(), maxBytes),
239
+ };
240
+ },
241
+ });
242
+ return withChunkId({
243
+ wall_time_seconds: (performance.now() - startedAt) / 1000,
244
+ job_id: id,
245
+ output: `Started background job ${id}. Use job_output with job_id "${id}" to read output.`,
246
+ });
247
+ }
248
+ const process = ctx.shell.start(ctx.shell.resolve({
249
+ ...shellRequest,
250
+ signal: exec.signal,
251
+ }));
201
252
  try {
202
253
  await waitForShell(process, normalizeWaitMs(args.yield_time_ms, config.defaultYieldTimeMs), exec.signal);
203
254
  const output = readShellOutput(process.readOutput(), maxBytes);
@@ -194,7 +194,7 @@ export function buildCodexSystemPrompt(config = {}) {
194
194
  ? `${CODEX_BASE_PROMPT}\n\n${CODEX_COLLABORATION_PROMPT}`
195
195
  : CODEX_BASE_PROMPT;
196
196
  }
197
- const EXEC_COMMAND_DESCRIPTION = 'Runs a command in a PTY, returning output or a session ID for ongoing interaction.';
197
+ const EXEC_COMMAND_DESCRIPTION = 'Runs a command in a PTY, returning output, a session ID for ongoing interaction, or a background job ID when requested.';
198
198
  const WRITE_STDIN_DESCRIPTION = 'Writes characters to an existing unified exec session and returns recent output.';
199
199
  const APPLY_PATCH_DESCRIPTION = 'Edits files using Codex patch syntax with Begin/End Patch markers and file update directives. In hunk lines, the first character is the operation marker; repeat a source-leading marker when the source line itself starts with one.';
200
200
  const UPDATE_PLAN_DESCRIPTION = 'Updates the task plan.\nProvide an optional explanation and a list of plan items, each with a step and status.\nAt most one step can be in_progress at a time.';
@@ -306,6 +306,7 @@ function registerExecTools(ctx, config) {
306
306
  cmd: { type: 'string', required: true, description: 'Shell command to execute.' },
307
307
  workdir: { type: 'string', description: 'Working directory for the command. Defaults to the turn cwd.' },
308
308
  tty: { type: 'boolean', description: 'True allocates a PTY for the command; false or omitted uses plain pipes.' },
309
+ run_in_background: { type: 'boolean', description: 'Run as a DSH background job and return its job id immediately; collect output with job_output and stop it with job_kill. Only supported for pipe-backed commands.' },
309
310
  yield_time_ms: { type: 'number', description: 'Wait before yielding output. Defaults to 10000 ms; effective range is 250-30000 ms.' },
310
311
  max_output_tokens: { type: 'number', description: 'Output token budget. Defaults to 10000 tokens; larger requests may be capped by policy.' },
311
312
  shell: { type: 'string', description: "Shell binary to launch. Defaults to the user's default shell." },
@@ -320,6 +321,7 @@ function registerExecTools(ctx, config) {
320
321
  wall_time_seconds: { type: 'number', required: true },
321
322
  exit_code: { type: 'number' },
322
323
  session_id: { type: 'number' },
324
+ job_id: { type: 'string' },
323
325
  original_token_count: { type: 'number' },
324
326
  output: { type: 'string', required: true },
325
327
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "A Codex harness with a streamlined system prompt for GPT models that do not fit DSH's native interface, while remaining compatible with the DSH plugin ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -89,6 +89,7 @@
89
89
  "@deepseek-ai/dsh-credentials": ">=0.1.0-rc.8",
90
90
  "@deepseek-ai/dsh-fs": ">=0.0.1-rc.1",
91
91
  "@deepseek-ai/dsh-invariants": ">=0.0.1-rc.1",
92
+ "@deepseek-ai/dsh-jobs": ">=0.1.0-rc.8",
92
93
  "@deepseek-ai/dsh-llm": ">=0.1.0-rc.8",
93
94
  "@deepseek-ai/dsh-settings": ">=0.1.0-rc.8",
94
95
  "@deepseek-ai/dsh-sandbox": ">=0.0.1-rc.1",
@@ -99,6 +100,7 @@
99
100
  "@deepseek-ai/dsh-tool-web": ">=0.1.0-rc.8",
100
101
  "@deepseek-ai/dsh-tool-todo": ">=0.0.1-rc.1",
101
102
  "@deepseek-ai/dsh-terminal": ">=0.0.1-rc.3",
103
+ "@deepseek-ai/dsh-tool-jobs": ">=0.1.0-rc.8",
102
104
  "@deepseek-ai/dsh-tools": ">=0.0.1-rc.1"
103
105
  },
104
106
  "peerDependenciesMeta": {
@@ -132,6 +134,9 @@
132
134
  "@deepseek-ai/dsh-invariants": {
133
135
  "optional": true
134
136
  },
137
+ "@deepseek-ai/dsh-jobs": {
138
+ "optional": true
139
+ },
135
140
  "@deepseek-ai/dsh-llm": {
136
141
  "optional": true
137
142
  },
@@ -162,6 +167,9 @@
162
167
  "@deepseek-ai/dsh-terminal": {
163
168
  "optional": true
164
169
  },
170
+ "@deepseek-ai/dsh-tool-jobs": {
171
+ "optional": true
172
+ },
165
173
  "@deepseek-ai/dsh-tools": {
166
174
  "optional": true
167
175
  }
@@ -177,6 +185,7 @@
177
185
  "@deepseek-ai/dsh-credentials": "0.1.0-rc.8",
178
186
  "@deepseek-ai/dsh-fs": "0.1.0-rc.6",
179
187
  "@deepseek-ai/dsh-invariants": "0.1.0-rc.6",
188
+ "@deepseek-ai/dsh-jobs": "0.1.0-rc.8",
180
189
  "@deepseek-ai/dsh-llm": "0.1.0-rc.8",
181
190
  "@deepseek-ai/dsh-settings": "0.1.0-rc.8",
182
191
  "@deepseek-ai/dsh-sandbox": "0.1.0-rc.6",
@@ -187,6 +196,7 @@
187
196
  "@deepseek-ai/dsh-tool-web": "0.1.0-rc.8",
188
197
  "@deepseek-ai/dsh-tool-todo": "0.1.0-rc.6",
189
198
  "@deepseek-ai/dsh-terminal": "0.1.0-rc.6",
199
+ "@deepseek-ai/dsh-tool-jobs": "0.1.0-rc.8",
190
200
  "@deepseek-ai/dsh-tools": "0.1.0-rc.6",
191
201
  "@types/node": "^22.20.0",
192
202
  "@types/react": "~18.3.1",
@@ -21,6 +21,14 @@
21
21
  config:
22
22
  collaborationPrompt: false
23
23
 
24
+ # Background jobs use the host-plane registry. A busy agent receives a
25
+ # completion in its next step; an idle agent keeps it pending until the next
26
+ # user/tool wake, so finishing work never opens an unsolicited model turn.
27
+ - id: codex-jobs
28
+ name: '@deepseek-ai/dsh-tool-jobs'
29
+ config:
30
+ completionDelivery: quiet
31
+
24
32
  # The generic DSH pi-ai adapter still owns the user's configured provider,
25
33
  # endpoint, API key, and model. Codex's remote-first transport wrapper is
26
34
  # installed only in this Codex scope and falls back to the generic DSH path.
@@ -1,3 +1,3 @@
1
1
  name: Codex 模式
2
- description: 使用精简版 Codex 提示词、exec_command、write_stdin、apply_patch 和 update_plan,并保留 dsh Skills 与可插拔运行时。
2
+ description: 使用精简版 Codex 提示词、统一执行工具、后台任务控制和 dsh Skills
3
3
  order: 5