orquesta-agent 0.2.294 → 0.2.296
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/dist/cli-auth-detect.d.ts.map +1 -1
- package/dist/cli-auth-detect.js +3 -1
- package/dist/cli-auth-detect.js.map +1 -1
- package/dist/engine-stream.d.ts +8 -0
- package/dist/engine-stream.d.ts.map +1 -0
- package/dist/engine-stream.js +114 -0
- package/dist/engine-stream.js.map +1 -0
- package/dist/executor.d.ts +18 -4
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +229 -44
- package/dist/executor.js.map +1 -1
- package/dist/git-app-auth.d.ts +1 -1
- package/dist/git-app-auth.d.ts.map +1 -1
- package/dist/git-app-auth.js +8 -4
- package/dist/git-app-auth.js.map +1 -1
- package/dist/index.js +28 -11
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +4 -0
- package/dist/sandbox.js.map +1 -1
- package/dist/stream-engine.d.ts +4 -4
- package/dist/stream-engine.d.ts.map +1 -1
- package/dist/stream-engine.js +4 -3
- package/dist/stream-engine.js.map +1 -1
- package/dist/supabase.d.ts +18 -8
- package/dist/supabase.d.ts.map +1 -1
- package/dist/supabase.js +31 -1
- package/dist/supabase.js.map +1 -1
- package/dist/ui/manager.js +1 -1
- package/dist/ui/manager.js.map +1 -1
- package/dist/ui/onboarding.js +1 -1
- package/dist/ui/onboarding.js.map +1 -1
- package/dist/ui/public/app.js +4 -0
- package/dist/ui/public/index.html +2 -0
- package/dist/ui/public/style.css +2 -0
- package/dist/ui/public/welcome.html +4 -0
- package/dist/ui/server.d.ts +1 -1
- package/dist/ui/server.d.ts.map +1 -1
- package/dist/ui/server.js +2 -2
- package/dist/ui/server.js.map +1 -1
- package/dist/ui/types.d.ts +1 -1
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ws-client.d.ts +1 -1
- package/dist/ws-client.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/executor.js
CHANGED
|
@@ -137,6 +137,7 @@ import { uploadPromptArtifacts } from './artifacts.js';
|
|
|
137
137
|
import { autostashConflicted, buildPullArgs, classifyPullFailure, describePullFailure, PullFailureLedger } from './auto-pull.js';
|
|
138
138
|
import { usageFromResultEvent } from './claude-usage.js';
|
|
139
139
|
import { streamEngine, engineFlags } from './stream-engine.js';
|
|
140
|
+
import { jsonlTranslator } from './engine-stream.js';
|
|
140
141
|
import { startTranscriptTail, readTranscriptHistory, claudeChatSessionMode } from './claude-transcript.js';
|
|
141
142
|
import { createThinkingLog, createToolCallLog, createToolResultLog, createOutputLog, createErrorLog, createSystemLog, createProgressLog, } from './types/agent-logs.js';
|
|
142
143
|
/**
|
|
@@ -1293,6 +1294,109 @@ export function checkKiroAuth() {
|
|
|
1293
1294
|
return cache({ available: true, authenticated: true, method: null });
|
|
1294
1295
|
}
|
|
1295
1296
|
}
|
|
1297
|
+
// Codex (`@openai/codex`) and Gemini CLI (`@google/gemini-cli`) are npm globals,
|
|
1298
|
+
// so the usual miss is a daemon whose PATH lacks the nvm bin dir. Node's own bin
|
|
1299
|
+
// dir covers that case. Order: <ENV>_PATH → on PATH → node's bin dir →
|
|
1300
|
+
// ~/.npm-global/bin → ~/.local/bin.
|
|
1301
|
+
const npmCliCache = new Map();
|
|
1302
|
+
function resolveNpmCli(name, envVar) {
|
|
1303
|
+
const now = Date.now();
|
|
1304
|
+
const cached = npmCliCache.get(name);
|
|
1305
|
+
if (cached && cacheFresh(cached, cached.path !== null, now))
|
|
1306
|
+
return cached.path;
|
|
1307
|
+
let resolved = null;
|
|
1308
|
+
const envPath = process.env[envVar];
|
|
1309
|
+
if (envPath) {
|
|
1310
|
+
try {
|
|
1311
|
+
fs.accessSync(envPath, fs.constants.X_OK);
|
|
1312
|
+
resolved = envPath;
|
|
1313
|
+
}
|
|
1314
|
+
catch { /* bad override */ }
|
|
1315
|
+
}
|
|
1316
|
+
if (!resolved) {
|
|
1317
|
+
try {
|
|
1318
|
+
execSync(`${name} --version`, { stdio: 'pipe', timeout: 15000 });
|
|
1319
|
+
resolved = name;
|
|
1320
|
+
}
|
|
1321
|
+
catch { /* not on PATH */ }
|
|
1322
|
+
}
|
|
1323
|
+
if (!resolved && process.platform !== 'win32') {
|
|
1324
|
+
const dirs = [path.dirname(process.execPath), path.join(os.homedir(), '.npm-global', 'bin'), path.join(os.homedir(), '.local', 'bin')];
|
|
1325
|
+
for (const dir of dirs) {
|
|
1326
|
+
const candidate = path.join(dir, name);
|
|
1327
|
+
try {
|
|
1328
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
1329
|
+
resolved = candidate;
|
|
1330
|
+
break;
|
|
1331
|
+
}
|
|
1332
|
+
catch { /* not installed there */ }
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
npmCliCache.set(name, { path: resolved, at: now });
|
|
1336
|
+
return resolved;
|
|
1337
|
+
}
|
|
1338
|
+
export function resolveCodexBinary() {
|
|
1339
|
+
return resolveNpmCli('codex', 'CODEX_CLI_PATH');
|
|
1340
|
+
}
|
|
1341
|
+
export function isCodexCliAvailable() {
|
|
1342
|
+
return resolveCodexBinary() !== null;
|
|
1343
|
+
}
|
|
1344
|
+
export function resolveGeminiBinary() {
|
|
1345
|
+
return resolveNpmCli('gemini', 'GEMINI_CLI_PATH');
|
|
1346
|
+
}
|
|
1347
|
+
export function isGeminiCliAvailable() {
|
|
1348
|
+
return resolveGeminiBinary() !== null;
|
|
1349
|
+
}
|
|
1350
|
+
// Is codex LOGGED IN? `codex login status` says so for ChatGPT and API-key
|
|
1351
|
+
// logins alike. Same contract as checkKiroAuth: only the logged-out wording
|
|
1352
|
+
// flips the flag. An expired ChatGPT session still reads as logged in here; the
|
|
1353
|
+
// run itself then fails with "sign in again".
|
|
1354
|
+
let codexAuthCache = null;
|
|
1355
|
+
export function checkCodexAuth() {
|
|
1356
|
+
const now = Date.now();
|
|
1357
|
+
if (codexAuthCache && now - codexAuthCache.at < CLI_DETECTION_TTL_MS)
|
|
1358
|
+
return codexAuthCache.result;
|
|
1359
|
+
const cache = (result) => {
|
|
1360
|
+
codexAuthCache = { result, at: now };
|
|
1361
|
+
return result;
|
|
1362
|
+
};
|
|
1363
|
+
const binary = resolveCodexBinary();
|
|
1364
|
+
if (!binary)
|
|
1365
|
+
return cache({ available: false, authenticated: false, method: null });
|
|
1366
|
+
try {
|
|
1367
|
+
const out = execSync(`"${binary}" login status 2>&1`, { stdio: ['ignore', 'pipe', 'pipe'], timeout: 15000, encoding: 'utf-8' });
|
|
1368
|
+
if (isLoggedOutMessage(out))
|
|
1369
|
+
return cache({ available: true, authenticated: false, method: null });
|
|
1370
|
+
return cache({ available: true, authenticated: true, method: /api key/i.test(out) ? 'api_key' : 'subscription' });
|
|
1371
|
+
}
|
|
1372
|
+
catch (error) {
|
|
1373
|
+
const err = error;
|
|
1374
|
+
const combined = `${err.stdout ?? ''}${err.stderr ?? ''}`;
|
|
1375
|
+
if (isLoggedOutMessage(combined))
|
|
1376
|
+
return cache({ available: true, authenticated: false, method: null });
|
|
1377
|
+
return cache({ available: true, authenticated: true, method: null });
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
// Gemini CLI has no status command, so login is read from where it can come
|
|
1381
|
+
// from: a key in the environment, a cached Google login, or an auth type chosen
|
|
1382
|
+
// in settings (Vertex AI, for one, keeps no file of its own). Files are only
|
|
1383
|
+
// tested for existence; nothing reads a credential.
|
|
1384
|
+
export function checkGeminiAuth() {
|
|
1385
|
+
if (!isGeminiCliAvailable())
|
|
1386
|
+
return { available: false, authenticated: false, method: null };
|
|
1387
|
+
if (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY)
|
|
1388
|
+
return { available: true, authenticated: true, method: 'api_key' };
|
|
1389
|
+
const dir = path.join(os.homedir(), '.gemini');
|
|
1390
|
+
if (fs.existsSync(path.join(dir, 'oauth_creds.json')))
|
|
1391
|
+
return { available: true, authenticated: true, method: 'subscription' };
|
|
1392
|
+
try {
|
|
1393
|
+
const settings = fs.readFileSync(path.join(dir, 'settings.json'), 'utf-8');
|
|
1394
|
+
if (/"selectedType"\s*:\s*"[^"]+"/.test(settings))
|
|
1395
|
+
return { available: true, authenticated: true, method: null };
|
|
1396
|
+
}
|
|
1397
|
+
catch { /* no settings yet */ }
|
|
1398
|
+
return { available: true, authenticated: false, method: null };
|
|
1399
|
+
}
|
|
1296
1400
|
// Dedupe the fallback warning: selectCli() runs on every heartbeat (the agent
|
|
1297
1401
|
// reports activeCli), so logging unconditionally spammed thousands of identical
|
|
1298
1402
|
// WARN lines. Only log when the message actually changes.
|
|
@@ -1303,22 +1407,40 @@ function warnCliOnce(msg) {
|
|
|
1303
1407
|
lastCliWarn = msg;
|
|
1304
1408
|
logger.warn(msg);
|
|
1305
1409
|
}
|
|
1410
|
+
// These CLIs have no system-prompt flag, so the capabilities block stays inline.
|
|
1411
|
+
const NO_SYSTEM_PROMPT_FLAG = ['kimi', 'cursor', 'kiro', 'codex', 'gemini'];
|
|
1412
|
+
// Env each engine needs through strict sandbox's allowlist. Per engine, so a
|
|
1413
|
+
// run of another CLI does not get to read these keys.
|
|
1414
|
+
const ENGINE_ENV = {
|
|
1415
|
+
codex: ['OPENAI_API_KEY', 'CODEX_API_KEY', 'CODEX_HOME'],
|
|
1416
|
+
gemini: ['GEMINI_API_KEY', 'GOOGLE_API_KEY', 'GOOGLE_CLOUD_PROJECT', 'GOOGLE_CLOUD_LOCATION', 'GOOGLE_GENAI_USE_VERTEXAI', 'GEMINI_CLI_TRUST_WORKSPACE'],
|
|
1417
|
+
};
|
|
1418
|
+
// Gemini CLI exits 55 in a folder it has not been told to trust, and the agent
|
|
1419
|
+
// runs unattended in a folder the project owner already chose. The env var
|
|
1420
|
+
// exists on every version; --skip-trust does not.
|
|
1421
|
+
function applyEngineEnv(env, cli) {
|
|
1422
|
+
if (cli === 'gemini')
|
|
1423
|
+
env.GEMINI_CLI_TRUST_WORKSPACE = 'true';
|
|
1424
|
+
}
|
|
1306
1425
|
// Preference order when nothing is pinned, and the order a fallback walks when
|
|
1307
1426
|
// the pinned CLI turns out not to be installed. Table-driven rather than a nest
|
|
1308
1427
|
// of pairwise ifs: every CLI added here otherwise costs another N branches, and
|
|
1309
1428
|
// the pair that got missed is exactly how a preference silently no-ops.
|
|
1310
|
-
const CLI_AUTO_ORDER = ['orquesta', 'claude', 'kimi', 'cursor', 'kiro'];
|
|
1429
|
+
const CLI_AUTO_ORDER = ['orquesta', 'claude', 'kimi', 'cursor', 'kiro', 'codex', 'gemini'];
|
|
1311
1430
|
const CLI_AUTO_REASON = {
|
|
1312
1431
|
orquesta: 'Auto: orquesta available (local LLM)',
|
|
1313
1432
|
claude: 'Auto: claude available (Anthropic API)',
|
|
1314
1433
|
kimi: 'Auto: kimi available',
|
|
1315
1434
|
cursor: 'Auto: cursor-agent available',
|
|
1316
1435
|
kiro: 'Auto: kiro-cli available',
|
|
1436
|
+
codex: 'Auto: codex available',
|
|
1437
|
+
gemini: 'Auto: gemini available',
|
|
1317
1438
|
};
|
|
1318
1439
|
/** Forget every cached detection, hit or miss. */
|
|
1319
1440
|
export function resetCliDetectionCache() {
|
|
1320
1441
|
orquestaCliCache = claudeCliCache = kimiCliCache = null;
|
|
1321
1442
|
claudeBinaryCache = kimiBinaryCache = cursorBinaryCache = kiroBinaryCache = null;
|
|
1443
|
+
npmCliCache.clear();
|
|
1322
1444
|
}
|
|
1323
1445
|
// Select which CLI to use based on availability and preference
|
|
1324
1446
|
export function selectCli() {
|
|
@@ -1328,6 +1450,8 @@ export function selectCli() {
|
|
|
1328
1450
|
kimi: isKimiCliAvailable(),
|
|
1329
1451
|
cursor: isCursorCliAvailable(),
|
|
1330
1452
|
kiro: isKiroCliAvailable(),
|
|
1453
|
+
codex: isCodexCliAvailable(),
|
|
1454
|
+
gemini: isGeminiCliAvailable(),
|
|
1331
1455
|
};
|
|
1332
1456
|
if (!CLI_AUTO_ORDER.some(cli => available[cli])) {
|
|
1333
1457
|
return { cli: null, reason: `No CLI found (${CLI_AUTO_ORDER.join(', ')})` };
|
|
@@ -2638,6 +2762,7 @@ ${userRequestBody}`;
|
|
|
2638
2762
|
const installed = {
|
|
2639
2763
|
orquesta: isOrquestaCliAvailable, claude: isClaudeCliAvailable, kimi: isKimiCliAvailable,
|
|
2640
2764
|
cursor: isCursorCliAvailable, kiro: isKiroCliAvailable,
|
|
2765
|
+
codex: isCodexCliAvailable, gemini: isGeminiCliAvailable,
|
|
2641
2766
|
};
|
|
2642
2767
|
if (installed[engine.cli]()) {
|
|
2643
2768
|
selectedCli = engine.cli;
|
|
@@ -2693,9 +2818,13 @@ ${userRequestBody}`;
|
|
|
2693
2818
|
? (resolveCursorBinary() || 'cursor-agent')
|
|
2694
2819
|
: cliCommand === 'kiro'
|
|
2695
2820
|
? (resolveKiroBinary() || 'kiro-cli')
|
|
2696
|
-
: cliCommand === '
|
|
2697
|
-
? (
|
|
2698
|
-
:
|
|
2821
|
+
: cliCommand === 'codex'
|
|
2822
|
+
? (resolveCodexBinary() || 'codex')
|
|
2823
|
+
: cliCommand === 'gemini'
|
|
2824
|
+
? (resolveGeminiBinary() || 'gemini')
|
|
2825
|
+
: cliCommand === 'claude'
|
|
2826
|
+
? (resolveClaudeBinary() || 'claude')
|
|
2827
|
+
: (cliCommand || 'claude');
|
|
2699
2828
|
const cwd = workingDirectory || process.cwd();
|
|
2700
2829
|
// Which branch this prompt runs on — captured up front so it's persisted even
|
|
2701
2830
|
// if the run fails, and broadcast live below once sendSpecialEvent exists.
|
|
@@ -2707,7 +2836,11 @@ ${userRequestBody}`;
|
|
|
2707
2836
|
let detectedCommitSha = null;
|
|
2708
2837
|
let detectedCommitUrl = null;
|
|
2709
2838
|
logger.info(`CLI Selection: ${cliCommand} (${reason})`);
|
|
2710
|
-
|
|
2839
|
+
applyEngineEnv(env, cliCommand);
|
|
2840
|
+
// kiro-cli and codex take the prompt as a subcommand's positional arg; the
|
|
2841
|
+
// others as the value of -p.
|
|
2842
|
+
const promptVerb = cliCommand === 'kiro' ? 'chat' : cliCommand === 'codex' ? 'exec' : '-p';
|
|
2843
|
+
logger.info(`Spawning: ${cliBinary} ${promptVerb} "${fullContent.slice(0, 50)}..." in ${cwd}${currentBranch ? ` on branch ${currentBranch}` : ''}`);
|
|
2711
2844
|
// Hoist the static block into the CLI system prompt (claude/orquesta support
|
|
2712
2845
|
// --append-system-prompt-file; kimi has no such flag and stays inline). On any
|
|
2713
2846
|
// write failure we fall back to the inline fullContent, so a dispatched prompt
|
|
@@ -2723,9 +2856,9 @@ ${userRequestBody}`;
|
|
|
2723
2856
|
const inlineContent = session.useMessage ? `${staticSystemBlock}\n\n[User Request]\n${requestBody}` : fullContent;
|
|
2724
2857
|
let promptContent = inlineContent;
|
|
2725
2858
|
let sysPromptFilePath = null;
|
|
2726
|
-
// kimi, cursor-agent
|
|
2727
|
-
// their static context stays inline
|
|
2728
|
-
if (cliCommand
|
|
2859
|
+
// kimi, cursor-agent, kiro-cli, codex and gemini have no
|
|
2860
|
+
// --append-system-prompt-file, so their static context stays inline.
|
|
2861
|
+
if (!NO_SYSTEM_PROMPT_FLAG.includes(cliCommand)) {
|
|
2729
2862
|
try {
|
|
2730
2863
|
const promptDir = process.platform === 'win32'
|
|
2731
2864
|
? os.tmpdir()
|
|
@@ -2763,13 +2896,18 @@ ${userRequestBody}`;
|
|
|
2763
2896
|
// --no-interactive answers once and exits, --wrap
|
|
2764
2897
|
// never stops it re-flowing the answer to the
|
|
2765
2898
|
// (absent) terminal width.
|
|
2766
|
-
: cliCommand === '
|
|
2767
|
-
? '--
|
|
2768
|
-
//
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2899
|
+
: cliCommand === 'codex'
|
|
2900
|
+
? '--json --skip-git-repo-check' // Codex: JSONL, see engine-stream.ts. A
|
|
2901
|
+
// project folder need not be a git repo.
|
|
2902
|
+
: cliCommand === 'gemini'
|
|
2903
|
+
? '--output-format stream-json' // Gemini: JSONL, see engine-stream.ts.
|
|
2904
|
+
: cliCommand === 'kimi'
|
|
2905
|
+
? '--output-format text' // Kimi: plain text. NOTE: -p (one-shot) CANNOT be
|
|
2906
|
+
// combined with -y ("Cannot combine --prompt with
|
|
2907
|
+
// --yolo"), so dispatched kimi prompts respond as
|
|
2908
|
+
// chat (no autonomous tool use). Interactive kimi
|
|
2909
|
+
// sessions DO get -y (see ptyArgs below).
|
|
2910
|
+
: '--verbose --output-format stream-json'; // Claude: stream-json format
|
|
2773
2911
|
// Kimi has no --dangerously-skip-permissions, and -p forbids -y. Cursor spells
|
|
2774
2912
|
// the same thing --force (alias --yolo); kiro spells it --trust-all-tools.
|
|
2775
2913
|
let readOnlySettingsPath = null;
|
|
@@ -2790,14 +2928,18 @@ ${userRequestBody}`;
|
|
|
2790
2928
|
? '--force'
|
|
2791
2929
|
: cliCommand === 'kiro'
|
|
2792
2930
|
? '--trust-all-tools'
|
|
2793
|
-
: '
|
|
2931
|
+
: cliCommand === 'codex'
|
|
2932
|
+
? '--dangerously-bypass-approvals-and-sandbox'
|
|
2933
|
+
: cliCommand === 'gemini'
|
|
2934
|
+
? '--yolo'
|
|
2935
|
+
: '--dangerously-skip-permissions';
|
|
2794
2936
|
// Per-project endpoint override (orquesta CLI only). Single-quoted for the
|
|
2795
2937
|
// shell-wrapped (Linux) path; pushed as a separate arg on Win/macOS below.
|
|
2796
|
-
const {
|
|
2938
|
+
const { cliModel, endpoint: effectiveEndpoint } = engineFlags(cliCommand, engine, globalCliEndpoint);
|
|
2797
2939
|
const useEndpoint = !!effectiveEndpoint;
|
|
2798
2940
|
const endpointFlag = useEndpoint ? `--endpoint '${effectiveEndpoint.replace(/'/g, "'\\''")}'` : '';
|
|
2799
|
-
// Workstream model pin
|
|
2800
|
-
const modelFlag =
|
|
2941
|
+
// Workstream model pin (stream-engine.ts validated the charset).
|
|
2942
|
+
const modelFlag = cliModel ? `--model '${cliModel}'` : '';
|
|
2801
2943
|
// Static context hoisted to the CLI system prompt (Linux shell-string form).
|
|
2802
2944
|
const sysPromptFlag = sysPromptFilePath
|
|
2803
2945
|
? `--append-system-prompt-file '${sysPromptFilePath.replace(/'/g, "'\\''")}'`
|
|
@@ -2807,7 +2949,6 @@ ${userRequestBody}`;
|
|
|
2807
2949
|
// paths so Claude's Read tool can pick them up.
|
|
2808
2950
|
// kiro-cli has no `-p`: the one-shot form is `kiro-cli chat "<prompt>"` with
|
|
2809
2951
|
// --no-interactive (baseFlags), the prompt as the verb's positional arg.
|
|
2810
|
-
const promptVerb = cliCommand === 'kiro' ? 'chat' : '-p';
|
|
2811
2952
|
const sessionFlag = session.args.join(' ');
|
|
2812
2953
|
command = `${cliBinary} ${promptVerb} '${escapedContent}' ${permFlags} ${baseFlags} ${endpointFlag} ${modelFlag} ${sysPromptFlag} ${sessionFlag}`;
|
|
2813
2954
|
if (imageReferences.length > 0) {
|
|
@@ -2822,7 +2963,8 @@ ${userRequestBody}`;
|
|
|
2822
2963
|
const isDarwin = process.platform === 'darwin';
|
|
2823
2964
|
let claude;
|
|
2824
2965
|
if (isWindows || isDarwin) {
|
|
2825
|
-
|
|
2966
|
+
// Gemini takes piped input only without -p: a bare -p is a usage error.
|
|
2967
|
+
const args = isWindows && cliCommand === 'gemini' ? [] : [promptVerb];
|
|
2826
2968
|
// Windows cmd.exe caps the whole command line at ~8191 chars. The prompt is
|
|
2827
2969
|
// prefixed with large context blocks (capabilities, project CLAUDE.md,
|
|
2828
2970
|
// coordination…), so passing it as an argv overflows that limit and the CLI
|
|
@@ -2841,8 +2983,8 @@ ${userRequestBody}`;
|
|
|
2841
2983
|
args.push(...baseFlags.split(/\s+/).filter(Boolean));
|
|
2842
2984
|
if (useEndpoint)
|
|
2843
2985
|
args.push('--endpoint', effectiveEndpoint);
|
|
2844
|
-
if (
|
|
2845
|
-
args.push('--model',
|
|
2986
|
+
if (cliModel)
|
|
2987
|
+
args.push('--model', cliModel);
|
|
2846
2988
|
if (sysPromptArgs.length)
|
|
2847
2989
|
args.push(...sysPromptArgs);
|
|
2848
2990
|
if (session.args.length)
|
|
@@ -2860,6 +3002,12 @@ ${userRequestBody}`;
|
|
|
2860
3002
|
}
|
|
2861
3003
|
catch { /* stdin closed early — failure surfaces via exit code */ }
|
|
2862
3004
|
}
|
|
3005
|
+
else if (cliCommand === 'codex' || cliCommand === 'gemini') {
|
|
3006
|
+
// Both append piped stdin to the prompt, so an open pipe never finishes:
|
|
3007
|
+
// `codex exec` sits on "Reading additional input from stdin..." for good.
|
|
3008
|
+
// Under Linux `script` stdin is a tty and neither waits.
|
|
3009
|
+
claude.stdin?.end();
|
|
3010
|
+
}
|
|
2863
3011
|
}
|
|
2864
3012
|
else {
|
|
2865
3013
|
// Sandbox wraps the `script` invocation in bwrap when active (Linux only);
|
|
@@ -2870,7 +3018,7 @@ ${userRequestBody}`;
|
|
|
2870
3018
|
}
|
|
2871
3019
|
claude = spawn(spawnFile, spawnArgs, {
|
|
2872
3020
|
cwd,
|
|
2873
|
-
env: sandboxEnv(env),
|
|
3021
|
+
env: sandboxEnv(env, ENGINE_ENV[cliCommand ?? ''] ?? []),
|
|
2874
3022
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
2875
3023
|
});
|
|
2876
3024
|
}
|
|
@@ -3260,13 +3408,18 @@ ${userRequestBody}`;
|
|
|
3260
3408
|
}, 5000).unref?.();
|
|
3261
3409
|
},
|
|
3262
3410
|
});
|
|
3411
|
+
const translateJsonl = cliCommand === 'codex' || cliCommand === 'gemini' ? jsonlTranslator(cliCommand) : null;
|
|
3412
|
+
// Where stderr has its own pipe (macOS, Windows) the same chatter arrives here.
|
|
3413
|
+
const filterStderr = cliCommand === 'codex' || cliCommand === 'gemini' ? jsonlTranslator(cliCommand) : null;
|
|
3263
3414
|
if (claude.stdout) {
|
|
3264
3415
|
claude.stdout.on('data', (data) => {
|
|
3265
|
-
const text =
|
|
3266
|
-
?
|
|
3267
|
-
: cliCommand === '
|
|
3268
|
-
?
|
|
3269
|
-
:
|
|
3416
|
+
const text = translateJsonl
|
|
3417
|
+
? translateJsonl(data.toString())
|
|
3418
|
+
: cliCommand === 'kimi'
|
|
3419
|
+
? cleanKimiText(data.toString())
|
|
3420
|
+
: cliCommand === 'kiro'
|
|
3421
|
+
? cleanKiroText(data.toString())
|
|
3422
|
+
: data.toString();
|
|
3270
3423
|
stallDetector.feed(data.toString());
|
|
3271
3424
|
// Skip logging if it looks like base64/binary data (long strings without spaces)
|
|
3272
3425
|
const preview = text.slice(0, 150);
|
|
@@ -3278,7 +3431,11 @@ ${userRequestBody}`;
|
|
|
3278
3431
|
logger.debug(`[STDOUT] ${text.slice(0, 100)}`);
|
|
3279
3432
|
}
|
|
3280
3433
|
// Parse stream-json and send formatted output
|
|
3281
|
-
|
|
3434
|
+
// Translated output is already plain text. A line of it can be valid JSON
|
|
3435
|
+
// (a tool printing a config), which parseStreamJson would swallow.
|
|
3436
|
+
const { output: parsed, hadValidJson, logs: structuredLogs, pendingLine } = translateJsonl
|
|
3437
|
+
? { output: text, hadValidJson: false, logs: [], pendingLine: '' }
|
|
3438
|
+
: parseStreamJson(text);
|
|
3282
3439
|
// Only fallback to raw text if it wasn't valid JSON
|
|
3283
3440
|
// If it was valid JSON but produced no output (e.g., system init), don't send anything
|
|
3284
3441
|
const outputToSend = hadValidJson ? parsed : rawChunkOutput(text, parsed, pendingLine);
|
|
@@ -3396,7 +3553,7 @@ ${userRequestBody}`;
|
|
|
3396
3553
|
claude.stderr.on('data', (data) => {
|
|
3397
3554
|
const raw = data.toString();
|
|
3398
3555
|
stallDetector.feed(raw);
|
|
3399
|
-
const text = stripAnsiCodes(raw);
|
|
3556
|
+
const text = filterStderr ? filterStderr(raw) : stripAnsiCodes(raw);
|
|
3400
3557
|
if (!text.trim())
|
|
3401
3558
|
return;
|
|
3402
3559
|
noteRawOutput(text);
|
|
@@ -3566,7 +3723,11 @@ ${userRequestBody}`;
|
|
|
3566
3723
|
? 'cursor-cli'
|
|
3567
3724
|
: cliCommand === 'kiro'
|
|
3568
3725
|
? 'kiro-cli'
|
|
3569
|
-
: '
|
|
3726
|
+
: cliCommand === 'codex'
|
|
3727
|
+
? 'codex-cli'
|
|
3728
|
+
: cliCommand === 'gemini'
|
|
3729
|
+
? 'gemini-cli'
|
|
3730
|
+
: 'claude-cli';
|
|
3570
3731
|
let modelForDb;
|
|
3571
3732
|
if (cliCommand === 'kimi')
|
|
3572
3733
|
modelForDb = 'kimi-for-coding';
|
|
@@ -3578,7 +3739,9 @@ ${userRequestBody}`;
|
|
|
3578
3739
|
else if (cliCommand === 'orquesta')
|
|
3579
3740
|
modelForDb = (effectiveEndpoint === 'batuta' || !effectiveEndpoint) ? 'batuta-auto' : effectiveEndpoint;
|
|
3580
3741
|
else if (cliCommand === 'claude')
|
|
3581
|
-
modelForDb =
|
|
3742
|
+
modelForDb = cliModel || process.env.ANTHROPIC_MODEL || undefined;
|
|
3743
|
+
else if (cliCommand === 'codex' || cliCommand === 'gemini')
|
|
3744
|
+
modelForDb = cliModel || undefined;
|
|
3582
3745
|
updatePromptStatus(promptId, status, summary || undefined, Object.keys(usage).length > 0 ? usage : undefined, finalResult, { cliType: cliTypeForDb, model: modelForDb, gitBranch: currentBranch || undefined, gitCommitSha: detectedCommitSha || undefined, gitCommitUrl: detectedCommitUrl || undefined }).catch(err => {
|
|
3583
3746
|
logger.error(`Failed to update prompt status: ${err}`);
|
|
3584
3747
|
});
|
|
@@ -4470,10 +4633,14 @@ export async function startSession(options) {
|
|
|
4470
4633
|
? (resolveCursorBinary() || 'cursor-agent')
|
|
4471
4634
|
: cliCommand === 'kiro'
|
|
4472
4635
|
? (resolveKiroBinary() || 'kiro-cli')
|
|
4473
|
-
: cliCommand === '
|
|
4474
|
-
? (
|
|
4475
|
-
: cliCommand
|
|
4476
|
-
|
|
4636
|
+
: cliCommand === 'codex'
|
|
4637
|
+
? (resolveCodexBinary() || 'codex')
|
|
4638
|
+
: cliCommand === 'gemini'
|
|
4639
|
+
? (resolveGeminiBinary() || 'gemini')
|
|
4640
|
+
: cliCommand === 'claude'
|
|
4641
|
+
? (resolveClaudeBinary() || 'claude')
|
|
4642
|
+
: cliCommand;
|
|
4643
|
+
const resolvedByPath = cliCommand !== 'claude' && cliCommand !== 'orquesta';
|
|
4477
4644
|
logger.info(`Interactive session CLI: ${cliCommand}${resolvedByPath ? ` (${cliBinary})` : ''}`);
|
|
4478
4645
|
// Best-effort model + cli label reported in session:started so the dashboard
|
|
4479
4646
|
// can tag the interactive prompt (same mapping dispatched prompts use on
|
|
@@ -4481,8 +4648,8 @@ export async function startSession(options) {
|
|
|
4481
4648
|
// back to ANTHROPIC_MODEL when set, else undefined.
|
|
4482
4649
|
const sessionModel = cliCommand === 'kimi'
|
|
4483
4650
|
? 'kimi-for-coding'
|
|
4484
|
-
: cliCommand === 'cursor' || cliCommand === 'kiro'
|
|
4485
|
-
//
|
|
4651
|
+
: cliCommand === 'cursor' || cliCommand === 'kiro' || cliCommand === 'codex' || cliCommand === 'gemini'
|
|
4652
|
+
// These use whatever model the user selected in their own
|
|
4486
4653
|
// account; it isn't knowable from the PTY, so report nothing rather than lie.
|
|
4487
4654
|
? undefined
|
|
4488
4655
|
: cliCommand === 'orquesta'
|
|
@@ -4492,12 +4659,15 @@ export async function startSession(options) {
|
|
|
4492
4659
|
: cliCommand === 'kimi' ? 'kimi'
|
|
4493
4660
|
: cliCommand === 'cursor' ? 'cursor'
|
|
4494
4661
|
: cliCommand === 'kiro' ? 'kiro'
|
|
4495
|
-
: '
|
|
4662
|
+
: cliCommand === 'codex' ? 'codex'
|
|
4663
|
+
: cliCommand === 'gemini' ? 'gemini'
|
|
4664
|
+
: 'claude';
|
|
4496
4665
|
// Filter undefined env values — node-pty requires Record<string, string>.
|
|
4497
4666
|
// In strict sandbox mode, sandboxEnv() first reduces to the allowlist so the
|
|
4498
4667
|
// interactive CLI can't read unrelated host secrets from its own env.
|
|
4499
4668
|
const ptyEnv = {};
|
|
4500
|
-
|
|
4669
|
+
applyEngineEnv(env, cliCommand);
|
|
4670
|
+
for (const [key, val] of Object.entries(sandboxEnv(env, ENGINE_ENV[cliCommand ?? ''] ?? []))) {
|
|
4501
4671
|
if (val !== undefined)
|
|
4502
4672
|
ptyEnv[key] = val;
|
|
4503
4673
|
}
|
|
@@ -4586,7 +4756,7 @@ export async function startSession(options) {
|
|
|
4586
4756
|
// `ps aux`. Default-off because a file unreadable inside bwrap would silently
|
|
4587
4757
|
// strip the system prompt (degraded session, not a crash) — flip the default
|
|
4588
4758
|
// only after E2E confirms the sandbox reads it. Rollback = unset the var.
|
|
4589
|
-
const wantSysPromptFile = cliCommand
|
|
4759
|
+
const wantSysPromptFile = !NO_SYSTEM_PROMPT_FLAG.includes(cliCommand) && ((process.platform === 'win32' && cliCommand === 'orquesta') ||
|
|
4590
4760
|
/^(1|true|yes|on)$/i.test(process.env.ORQUESTA_SYSPROMPT_FILE || ''));
|
|
4591
4761
|
if (wantSysPromptFile) {
|
|
4592
4762
|
try {
|
|
@@ -4620,6 +4790,21 @@ export async function startSession(options) {
|
|
|
4620
4790
|
logger.info('[Session] Resuming most recent conversation in this directory (--resume) for kiro');
|
|
4621
4791
|
}
|
|
4622
4792
|
}
|
|
4793
|
+
else if (cliCommand === 'codex') {
|
|
4794
|
+
// Codex reads AGENTS.md, and `resume` is a subcommand, so resume flags go
|
|
4795
|
+
// here too: the generic unshift below would put them before nothing valid.
|
|
4796
|
+
const bypass = '--dangerously-bypass-approvals-and-sandbox';
|
|
4797
|
+
ptyArgs = resumeSessionId ? ['resume', resumeSessionId, bypass] : resume ? ['resume', '--last', bypass] : [bypass];
|
|
4798
|
+
logger.info(`[Session] Codex session${resumeSessionId || resume ? ' (resume)' : ''}`);
|
|
4799
|
+
}
|
|
4800
|
+
else if (cliCommand === 'gemini') {
|
|
4801
|
+
// Gemini reads GEMINI.md. --resume takes an id or "latest".
|
|
4802
|
+
ptyArgs = ['--yolo'];
|
|
4803
|
+
if (resumeSessionId)
|
|
4804
|
+
ptyArgs.push('--resume', resumeSessionId);
|
|
4805
|
+
else if (resume)
|
|
4806
|
+
ptyArgs.push('--resume', 'latest');
|
|
4807
|
+
}
|
|
4623
4808
|
else if (cliCommand === 'cursor') {
|
|
4624
4809
|
// cursor-agent has no --append-system-prompt; it reads AGENTS.md / CLAUDE.md
|
|
4625
4810
|
// from the working dir (which the agent already syncs), so the capabilities
|
|
@@ -4643,7 +4828,7 @@ export async function startSession(options) {
|
|
|
4643
4828
|
// cli.ts) both reattach the latest session non-interactively; kimi has no
|
|
4644
4829
|
// resume flag, so the option is silently ignored there. Prepended so it's an
|
|
4645
4830
|
// unambiguous standalone flag, separate from --append-system-prompt's value.
|
|
4646
|
-
if ((resume || resumeSessionId) &&
|
|
4831
|
+
if ((resume || resumeSessionId) && !['kimi', 'kiro', 'codex', 'gemini'].includes(cliCommand)) {
|
|
4647
4832
|
// cursor-agent spells these the same way claude does (--continue / --resume <id>).
|
|
4648
4833
|
// claude can target a SPECIFIC past conversation by id (--resume <id>);
|
|
4649
4834
|
// orquesta-cli only reattaches the latest (--continue). So when a specific
|
|
@@ -4795,7 +4980,7 @@ export async function startSession(options) {
|
|
|
4795
4980
|
rogerthatWatcher: null,
|
|
4796
4981
|
transcriptTail: null,
|
|
4797
4982
|
conversationId: claudeTranscriptId
|
|
4798
|
-
?? (resumeSessionId &&
|
|
4983
|
+
?? (resumeSessionId && ['cursor', 'kiro', 'codex', 'gemini'].includes(cliCommand) ? resumeSessionId : null),
|
|
4799
4984
|
assisted,
|
|
4800
4985
|
};
|
|
4801
4986
|
sessions.set(sessionId, session);
|