import { createStore } from "/js/AlpineStore.js"; import { toastFrontendError, toastFrontendSuccess, toastFrontendWarning, toastFrontendInfo } from "/components/notifications/notification-store.js"; export const store = createStore("a0SoftwareOrchestratorStore", { status: "idle", projectState: null, modelRouting: {}, toolCapabilities: {}, auditStatus: {}, init() { this.status = "initialized"; }, onOpen() { this.status = "active"; this.loadStatus(); }, cleanup() { this.status = "idle"; }, async loadStatus() { try { this.status = "loading"; // In v0.1, load from API endpoints // TODO: wire to actual API calls toastFrontendInfo("Orchestrator status loaded", "A0 Software Orchestrator"); } catch (e) { toastFrontendError(e.message, "A0 Software Orchestrator"); } finally { this.status = "active"; } }, async saveModelRouting(role, preset) { try { const response = await fetch("/api/plugins/a0_software_orchestrator/model_routing_save", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ role, preset }) }); const data = await response.json(); if (data.ok) { toastFrontendSuccess(`Model routing updated: ${role} -> ${preset}`, "A0 Software Orchestrator"); } else { toastFrontendError(data.error || "Save failed", "A0 Software Orchestrator"); } } catch (e) { toastFrontendError(e.message, "A0 Software Orchestrator"); } } });