import { Action, ActionPanel, Detail, Form, Icon, showToast, Toast, useNavigation, } from "@raycast/api"; import { getErrorMessage, runCommand, stringifyResult } from "./kody-client"; const DEFAULT_CODE = `import { kody } from 'kody:runtime' export default async function main() { return { ok: true, at: new Date().toISOString() } } `; export default function Command() { const { push } = useNavigation(); async function onSubmit(values: { code: string; paramsJson: string }) { try { let params: Record = {}; const raw = values.paramsJson?.trim() || "{}"; const parsed = JSON.parse(raw) as unknown; if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) { throw new Error("Params must be a JSON object."); } params = parsed as Record; const result = await runCommand({ code: values.code, params }); await showToast({ style: Toast.Style.Success, title: "Kody execute finished", }); push( , ); } catch (error) { await showToast({ style: Toast.Style.Failure, title: "Execute failed", message: getErrorMessage(error), }); } } return (
} > ); }