@11agents/cli 0.1.16 → 0.1.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@11agents/cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "11agents local runtime and telemetry CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  import { spawn } from 'node:child_process'
2
2
  import { createHash } from 'node:crypto'
3
- import { readFileSync } from 'node:fs'
3
+ import { appendFileSync, readFileSync } from 'node:fs'
4
4
  import { appendFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises'
5
5
  import os from 'node:os'
6
6
  import { dirname, resolve } from 'node:path'
@@ -20,7 +20,7 @@ function sleep(ms) {
20
20
  return new Promise(resolve => setTimeout(resolve, ms))
21
21
  }
22
22
 
23
- export function runProcess(command, args, { input = '', cwd = process.cwd(), env = process.env } = {}) {
23
+ export function runProcess(command, args, { input = '', cwd = process.cwd(), env = process.env, onStdoutChunk } = {}) {
24
24
  return new Promise(resolve => {
25
25
  let settled = false
26
26
  const child = spawn(command, args, { cwd, env, stdio: ['pipe', 'pipe', 'pipe'] })
@@ -31,7 +31,10 @@ export function runProcess(command, args, { input = '', cwd = process.cwd(), env
31
31
  settled = true
32
32
  resolve(result)
33
33
  }
34
- child.stdout.on('data', chunk => { stdout += chunk })
34
+ child.stdout.on('data', chunk => {
35
+ stdout += chunk
36
+ if (onStdoutChunk) onStdoutChunk(chunk)
37
+ })
35
38
  child.stderr.on('data', chunk => { stderr += chunk })
36
39
  child.on('error', error => {
37
40
  settle({ code: 127, stdout, stderr: error.message })
@@ -1012,7 +1015,10 @@ async function runCodex({ task, prompt, flags = {}, deps }) {
1012
1015
  })
1013
1016
  deps.log(JSON.stringify({ running: 'codex exec', command: commandLine, workdir }, null, 2))
1014
1017
  const taskEnv = task.execution_context?.env || process.env
1015
- let result = await deps.runProcess(codexBin, args, { input: `/goal ${prompt}`, cwd: workdir, env: taskEnv })
1018
+ const stdoutLogPath = runDir ? path.join(runDir, 'stdout.log') : ''
1019
+ if (stdoutLogPath) await writeRunFile(runDir, 'stdout.log', '')
1020
+ const onStdoutChunk = stdoutLogPath ? (chunk) => { try { appendFileSync(stdoutLogPath, chunk) } catch {} } : undefined
1021
+ let result = await deps.runProcess(codexBin, args, { input: `/goal ${prompt}`, cwd: workdir, env: taskEnv, onStdoutChunk })
1016
1022
 
1017
1023
  // When --codex-sandbox is set but bwrap is unavailable in the container (missing CAP_NET_ADMIN),
1018
1024
  // fall back to --yolo exec which runs commands directly without bwrap.
@@ -1023,7 +1029,8 @@ async function runCodex({ task, prompt, flags = {}, deps }) {
1023
1029
  const fallbackLine = [codexBin, ...fallbackArgs].map(v => JSON.stringify(String(v))).join(' ')
1024
1030
  deps.log(JSON.stringify({ warning: 'bwrap unavailable in this environment, retrying without sandbox', fallback_command: fallbackLine }))
1025
1031
  await updateRunMeta(runDir, { bwrap_fallback: true, fallback_command_line: fallbackLine })
1026
- result = await deps.runProcess(codexBin, fallbackArgs, { input: `/goal ${prompt}`, cwd: workdir, env: taskEnv })
1032
+ if (stdoutLogPath) await writeRunFile(runDir, 'stdout.log', '')
1033
+ result = await deps.runProcess(codexBin, fallbackArgs, { input: `/goal ${prompt}`, cwd: workdir, env: taskEnv, onStdoutChunk })
1027
1034
  }
1028
1035
  }
1029
1036
  const rawStdout = String(result.stdout || '')
@@ -1106,10 +1113,14 @@ async function runClaude({ task, prompt, flags = {}, deps }) {
1106
1113
 
1107
1114
  deps.log(JSON.stringify({ running: 'claude --print', command: commandLine, workdir }, null, 2))
1108
1115
 
1116
+ const stdoutLogPath = runDir ? path.join(runDir, 'stdout.log') : ''
1117
+ if (stdoutLogPath) await writeRunFile(runDir, 'stdout.log', '')
1118
+ const onStdoutChunk = stdoutLogPath ? (chunk) => { try { appendFileSync(stdoutLogPath, chunk) } catch {} } : undefined
1109
1119
  const result = await deps.runProcess(claudeBin, args, {
1110
1120
  input: prompt,
1111
1121
  cwd: workdir,
1112
1122
  env: task.execution_context?.env || process.env,
1123
+ onStdoutChunk,
1113
1124
  })
1114
1125
 
1115
1126
  const rawStdout = String(result.stdout || '')