import { storeJson } from '../fileModels/storeJson' import { sdk } from '../sdk' import { randomSessionSecret } from '../utils' // Generate a strong PLATFORM_SESSION_SECRET once, if absent. The app otherwise // falls back to a weak hardcoded default. Idempotent; reads with .once(). export const taskSessionSecret = sdk.setupOnInit(async (effects) => { const existing = await storeJson.read((s) => s.sessionSecret).once() if (existing) return await storeJson.merge( effects, { sessionSecret: randomSessionSecret() }, { allowWriteAfterConst: true }, ) })