feat: upgrade investigation and presentation runtime
This commit is contained in:
@@ -6,14 +6,13 @@ type FrontendActionArgs = Record<string, unknown> & {
|
||||
};
|
||||
|
||||
type FrontendActionBridgeResult = {
|
||||
version: "frontend-action-result@1";
|
||||
version: "frontend-action-result@2";
|
||||
status: "succeeded" | "failed" | "rejected" | "cancelled" | "expired";
|
||||
output?: unknown;
|
||||
error?: { code?: string; message?: string };
|
||||
};
|
||||
|
||||
export const executeFrontendAction = async (
|
||||
name: "render_scada_analysis" | "clear_scada_analysis" | "locate_features" | "zoom_to_map" | "show_chart" | "view_history",
|
||||
args: FrontendActionArgs,
|
||||
context: { sessionID: string; callID?: string },
|
||||
) => {
|
||||
@@ -22,7 +21,7 @@ export const executeFrontendAction = async (
|
||||
if (!callId) {
|
||||
throw new Error("frontend action bridge did not inject the OpenCode call ID");
|
||||
}
|
||||
const { __frontend_action_call_id: _callId, reason, ...params } = args;
|
||||
const { __frontend_action_call_id: _callId, reason, command } = args;
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetch(`${internalBaseUrl}/internal/frontend-actions/request`, {
|
||||
@@ -34,8 +33,7 @@ export const executeFrontendAction = async (
|
||||
body: JSON.stringify({
|
||||
session_id: context.sessionID,
|
||||
call_id: callId,
|
||||
name,
|
||||
params,
|
||||
command,
|
||||
fallback_text: reason,
|
||||
}),
|
||||
});
|
||||
@@ -60,7 +58,7 @@ export const unwrapFrontendActionResult = (text: string) => {
|
||||
} catch {
|
||||
throw new Error("frontend action bridge returned invalid JSON");
|
||||
}
|
||||
if (result.version !== "frontend-action-result@1" || typeof result.status !== "string") {
|
||||
if (result.version !== "frontend-action-result@2" || typeof result.status !== "string") {
|
||||
throw new Error("frontend action bridge returned an invalid result");
|
||||
}
|
||||
if (result.status !== "succeeded") {
|
||||
|
||||
Reference in New Issue
Block a user