Refactor UI modules and harden run/API behavior
This commit is contained in:
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
|
||||
import { mkdtemp, readFile, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
import { parseEnvFile, writeEnvFileUpdates } from "../src/ui/env-store.js";
|
||||
import { parseEnvFile, writeEnvFileUpdates } from "../src/store/env-store.js";
|
||||
|
||||
test("parseEnvFile handles missing files", async () => {
|
||||
const root = await mkdtemp(resolve(tmpdir(), "ai-ops-env-store-"));
|
||||
|
||||
@@ -148,7 +148,7 @@ test("rejects legacy edge trigger aliases", () => {
|
||||
|
||||
assert.throws(
|
||||
() => parseAgentManifest(manifest),
|
||||
/unsupported event "onValidationFail"/,
|
||||
/Invalid option/,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { parseActorExecutionResultFromModelOutput } from "../src/ui/provider-executor.js";
|
||||
import { parseActorExecutionResultFromModelOutput } from "../src/agents/provider-executor.js";
|
||||
|
||||
test("parseActorExecutionResultFromModelOutput parses strict JSON payload", () => {
|
||||
const parsed = parseActorExecutionResultFromModelOutput({
|
||||
@@ -64,3 +64,42 @@ test("parseActorExecutionResultFromModelOutput falls back when response is not J
|
||||
assert.equal(parsed.status, "success");
|
||||
assert.equal(parsed.payload?.assistantResponse, "Implemented update successfully.");
|
||||
});
|
||||
|
||||
test("parseActorExecutionResultFromModelOutput preserves status when optional fields are malformed", () => {
|
||||
const parsed = parseActorExecutionResultFromModelOutput({
|
||||
rawText: JSON.stringify({
|
||||
status: "failure",
|
||||
payload: {
|
||||
reason: "hard failure",
|
||||
},
|
||||
stateFlags: {
|
||||
retryable: false,
|
||||
invalid_flag: "nope",
|
||||
},
|
||||
stateMetadata: "not-an-object",
|
||||
events: [
|
||||
{
|
||||
type: "validation_failed",
|
||||
payload: {
|
||||
summary: "failed",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 123,
|
||||
},
|
||||
],
|
||||
failureKind: "not-valid",
|
||||
failureCode: 403,
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(parsed.status, "failure");
|
||||
assert.equal(parsed.payload?.reason, "hard failure");
|
||||
assert.equal(parsed.stateFlags?.retryable, false);
|
||||
assert.equal(parsed.stateFlags && "invalid_flag" in parsed.stateFlags, false);
|
||||
assert.equal(parsed.stateMetadata, undefined);
|
||||
assert.equal(parsed.events?.length, 1);
|
||||
assert.equal(parsed.events?.[0]?.type, "validation_failed");
|
||||
assert.equal(parsed.failureKind, undefined);
|
||||
assert.equal(parsed.failureCode, undefined);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
|
||||
import { mkdtemp, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
import { UiRunService, readRunMetaBySession } from "../src/ui/run-service.js";
|
||||
import { UiRunService, readRunMetaBySession } from "../src/runs/run-service.js";
|
||||
|
||||
async function waitForTerminalRun(
|
||||
runService: UiRunService,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
import { mkdtemp } from "node:fs/promises";
|
||||
import { buildSessionGraphInsight, buildSessionSummaries } from "../src/ui/session-insights.js";
|
||||
import { buildSessionGraphInsight, buildSessionSummaries } from "../src/telemetry/session-insights.js";
|
||||
import { parseAgentManifest } from "../src/agents/manifest.js";
|
||||
|
||||
function createManifest() {
|
||||
@@ -155,13 +155,13 @@ test("buildSessionGraphInsight maps attempts, edge visits, and sandbox payload",
|
||||
assert.equal(graph.status, "success");
|
||||
assert.equal(graph.nodes.length, 2);
|
||||
|
||||
const node2 = graph.nodes.find((node) => node.nodeId === "n2");
|
||||
const node2 = graph.nodes.find((node: any) => node.nodeId === "n2");
|
||||
assert.ok(node2);
|
||||
assert.equal(node2.attemptCount, 2);
|
||||
assert.equal(node2.subtaskCount, 1);
|
||||
assert.equal(node2.sandboxPayload?.phase, "n2");
|
||||
|
||||
const edge = graph.edges.find((entry) => entry.from === "n1" && entry.to === "n2");
|
||||
const edge = graph.edges.find((entry: any) => entry.from === "n1" && entry.to === "n2");
|
||||
assert.ok(edge);
|
||||
assert.equal(edge.visited, true);
|
||||
assert.equal(edge.trigger, "event:validation_failed");
|
||||
|
||||
Reference in New Issue
Block a user