Merge pull request 'fix: parse session_id from stderr — hermes --quiet writes it there' (#348) from fix/348-session-id-stderr into main
This commit is contained in:
@@ -43,7 +43,7 @@ export function buildHermesPrompt(ctx: AgentContext): string {
|
|||||||
return parts.join("\n");
|
return parts.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnHermesChat(prompt: string): Promise<string> {
|
function spawnHermesChat(prompt: string): Promise<{ stdout: string; stderr: string }> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const args = [
|
const args = [
|
||||||
"chat",
|
"chat",
|
||||||
@@ -76,7 +76,7 @@ function spawnHermesChat(prompt: string): Promise<string> {
|
|||||||
|
|
||||||
child.on("close", (code) => {
|
child.on("close", (code) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
resolve(stdout);
|
resolve({ stdout, stderr });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const detail = stderr.trim() !== "" ? ` stderr=${stderr.trim()}` : "";
|
const detail = stderr.trim() !== "" ? ` stderr=${stderr.trim()}` : "";
|
||||||
@@ -87,10 +87,11 @@ function spawnHermesChat(prompt: string): Promise<string> {
|
|||||||
|
|
||||||
async function runHermes(ctx: AgentContext): Promise<AgentRunResult> {
|
async function runHermes(ctx: AgentContext): Promise<AgentRunResult> {
|
||||||
const fullPrompt = buildHermesPrompt(ctx);
|
const fullPrompt = buildHermesPrompt(ctx);
|
||||||
const rawOutput = await spawnHermesChat(fullPrompt);
|
const { stdout, stderr } = await spawnHermesChat(fullPrompt);
|
||||||
const { store } = ctx;
|
const { store } = ctx;
|
||||||
|
|
||||||
const sessionId = parseSessionIdFromStdout(rawOutput);
|
// --quiet mode: session_id may be on stdout or stderr
|
||||||
|
const sessionId = parseSessionIdFromStdout(stderr) ?? parseSessionIdFromStdout(stdout);
|
||||||
if (sessionId !== null) {
|
if (sessionId !== null) {
|
||||||
const session = await loadHermesSession(sessionId);
|
const session = await loadHermesSession(sessionId);
|
||||||
if (session !== null) {
|
if (session !== null) {
|
||||||
@@ -99,8 +100,8 @@ async function runHermes(ctx: AgentContext): Promise<AgentRunResult> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const detailHash = await storeHermesRawOutput(store, rawOutput);
|
const detailHash = await storeHermesRawOutput(store, stdout);
|
||||||
return { output: rawOutput, detailHash };
|
return { output: stdout, detailHash };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Agent CLI factory: parses argv, runs Hermes, extracts output, writes StepNode. */
|
/** Agent CLI factory: parses argv, runs Hermes, extracts output, writes StepNode. */
|
||||||
|
|||||||
Reference in New Issue
Block a user