import { createStore } from "./store.js";
export const appStateStore = createStore({
    busy: false,
    currentRunId: null,
    currentTaskId: null,
    transcriptCount: 0,
    cache: {
        hitTokens: 0,
        missTokens: 0,
        rate: "n/a",
        observedRuns: 0,
    },
    permissions: {
        allowShell: false,
        allowBrowser: false,
        profile: "safe",
    },
});
export function setBusy(busy, runId) {
    appStateStore.setState((previous) => ({
        ...previous,
        busy,
        currentRunId: runId === undefined ? previous.currentRunId : runId,
    }));
}
export function updatePermissions(input) {
    appStateStore.setState((previous) => ({
        ...previous,
        permissions: {
            ...previous.permissions,
            ...input,
        },
    }));
}
