@runuai/host 0.8.24 → 0.8.25
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/lib/agent.ts +27 -1
- package/package.json +1 -1
package/lib/agent.ts
CHANGED
|
@@ -178,9 +178,13 @@ async function runAgent<T extends z.ZodTypeAny>(
|
|
|
178
178
|
if (parsed) {
|
|
179
179
|
const failure = FailureEnvelope.safeParse(parsed);
|
|
180
180
|
if (failure.success) {
|
|
181
|
+
// Prefer the actual tool output over the bash envelope's generic
|
|
182
|
+
// "agent step failed" — the docker/git/apt error is what the operator
|
|
183
|
+
// needs, and it must reach the cloud, not just the host log.
|
|
184
|
+
const detail = toolStderrDetail(stderrBuf);
|
|
181
185
|
throw new AgentError(
|
|
182
186
|
failure.data.error.code,
|
|
183
|
-
failure.data.error.message,
|
|
187
|
+
detail || failure.data.error.message,
|
|
184
188
|
{
|
|
185
189
|
step: failure.data.error.step,
|
|
186
190
|
exitCode: failure.data.error.exit_code ?? exitCode,
|
|
@@ -236,6 +240,28 @@ function tryParseLastJsonLine(buf: string): unknown {
|
|
|
236
240
|
return null;
|
|
237
241
|
}
|
|
238
242
|
|
|
243
|
+
/**
|
|
244
|
+
* The FAILING TOOL's output from a script's stderr — the docker/git/apt lines
|
|
245
|
+
* that actually say WHY a step failed, dropping our own `[uai-agent] step:`
|
|
246
|
+
* breadcrumbs and the `{"ok":false,…}` envelope. The bash envelope's message
|
|
247
|
+
* is generic ("agent step failed"); this is what makes it specific so the
|
|
248
|
+
* reason reaches the cloud UI instead of only the host log — useless when the
|
|
249
|
+
* host is a remote user's machine (live 2026-07-22, "compose_up_failed" with
|
|
250
|
+
* no why). Bounded to the last few lines so a build log doesn't flood the UI.
|
|
251
|
+
*/
|
|
252
|
+
export function toolStderrDetail(stderr: string): string {
|
|
253
|
+
const lines = stderr
|
|
254
|
+
.split(/\r?\n/)
|
|
255
|
+
.map((l) => l.replace(/\s+$/, ""))
|
|
256
|
+
.filter((l) => l.trim().length > 0)
|
|
257
|
+
.filter((l) => !l.startsWith("[uai-agent"))
|
|
258
|
+
.filter((l) => !l.trimStart().startsWith('{"ok"'));
|
|
259
|
+
return lines
|
|
260
|
+
.slice(-6)
|
|
261
|
+
.map((l) => (l.length > 300 ? `${l.slice(0, 300)}…` : l))
|
|
262
|
+
.join("\n");
|
|
263
|
+
}
|
|
264
|
+
|
|
239
265
|
// ---------------------------------------------------------------------------
|
|
240
266
|
// Public API. One function per agent command.
|
|
241
267
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED