fix: 暴露 turn 活性与 steer 投递语义
This commit is contained in:
+35
-1
@@ -120,7 +120,41 @@ async function route({ method, url, body, store, sourceCommit, runnerJobDefaults
|
||||
return await store.listSessions(input) as unknown as JsonValue;
|
||||
}
|
||||
const sessionMatch = path.match(/^\/api\/v1\/sessions\/([^/]+)$/u);
|
||||
if (method === "GET" && sessionMatch) return await store.getSessionSummary(sessionMatch[1] ?? "", url.searchParams.get("readerId")) as unknown as JsonValue;
|
||||
if (method === "GET" && sessionMatch) {
|
||||
const summary = await store.getSessionSummary(sessionMatch[1] ?? "", url.searchParams.get("readerId"));
|
||||
const runId = summary.activeRunId ?? summary.lastRunId;
|
||||
if (!runId) return summary as unknown as JsonValue;
|
||||
const commandId = summary.activeCommandId ?? summary.lastCommandId ?? undefined;
|
||||
try {
|
||||
const result = await buildRunResult(store, runId, commandId);
|
||||
return {
|
||||
...summary,
|
||||
liveness: result.liveness ?? null,
|
||||
supervisor: {
|
||||
runId: result.runId,
|
||||
commandId: result.commandId,
|
||||
status: result.status,
|
||||
terminalStatus: result.terminalStatus,
|
||||
lastSeq: result.lastSeq,
|
||||
liveness: result.liveness ?? null,
|
||||
recoveryActions: typeof result.liveness === "object" && result.liveness !== null && !Array.isArray(result.liveness) ? (result.liveness as JsonRecord).recoveryActions ?? [] : [],
|
||||
...(result.steerDelivery ? { steerDelivery: result.steerDelivery } : {}),
|
||||
valuesPrinted: false,
|
||||
},
|
||||
} as unknown as JsonValue;
|
||||
} catch (error) {
|
||||
return {
|
||||
...summary,
|
||||
liveness: {
|
||||
phase: "unavailable",
|
||||
active: summary.active,
|
||||
failureKind: "infra-failed",
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
valuesPrinted: false,
|
||||
},
|
||||
} as unknown as JsonValue;
|
||||
}
|
||||
}
|
||||
const sessionTraceMatch = path.match(/^\/api\/v1\/sessions\/([^/]+)\/trace$/u);
|
||||
if (method === "GET" && sessionTraceMatch) {
|
||||
const input: SessionEventPageInput = { afterSeq: integerQuery(url, "afterSeq", 0), limit: integerQuery(url, "limit", 100) };
|
||||
|
||||
Reference in New Issue
Block a user