Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline (Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/* packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import type { MessageBlock } from "@rakazo/contracts";
|
|
|
|
export function cloudAgentHttpsUrl(value: string | null | undefined): string | undefined {
|
|
if (!value) return undefined;
|
|
try {
|
|
const url = new URL(value);
|
|
return url.protocol === "https:" && !url.username && !url.password ? value : undefined;
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
export function cloudAgentBlockFromPayload(
|
|
payload: Record<string, unknown>,
|
|
): Extract<MessageBlock, { kind: "cloud_agent" }> {
|
|
const status = payload.status;
|
|
return {
|
|
kind: "cloud_agent",
|
|
agentId: String(payload.agentId ?? ""),
|
|
title: String(payload.title ?? "Cloud agent"),
|
|
status:
|
|
status === "finished" || status === "failed" || status === "cancelled" ? status : "running",
|
|
url: cloudAgentHttpsUrl(String(payload.url ?? "")) ?? "",
|
|
...(payload.branch ? { branch: String(payload.branch) } : {}),
|
|
...(cloudAgentHttpsUrl(String(payload.prUrl ?? "")) ? { prUrl: String(payload.prUrl) } : {}),
|
|
...(payload.latestRunId ? { latestRunId: String(payload.latestRunId) } : {}),
|
|
};
|
|
}
|