import { mkdirSync } from 'node:fs'; import { join } from 'node:path'; import { OFFICER_ROOT } from '@@/data-path'; /** * Where generated images and anything else durable live. * * `$OFFICER_ROOT/data/atelier/` — a sibling of the plugin's own directory, not inside it. A plugin * directory is a git clone that an update replaces, so artefacts kept there would vanish on upgrade * with nothing logging it. Same reasoning and same shape as `plugins/kiosk/artefacts.ts`, which solved * this first. */ export const DATA_DIR = join(OFFICER_ROOT, 'data', 'atelier'); export const IMAGES_DIR = join(DATA_DIR, 'images'); /** * Uploaded inputs for edits, kept separate from generated output. * * Only IMAGES_DIR is served: an edit's input is whatever the caller uploaded, and publishing it * because it happens to sit next to the results is not a decision anyone made. */ export const INPUTS_DIR = join(DATA_DIR, 'inputs'); mkdirSync(IMAGES_DIR, { recursive: true }); mkdirSync(INPUTS_DIR, { recursive: true }); /** * How many images may be in flight at OpenAI at once. * * A cap rather than unbounded parallelism: `n: 10` is ten HTTP requests, and several callers at once * multiply that. The work is all awaited I/O, so the process stays responsive either way — the * provider's rate limit is the real edge, and hitting it turns a slow job into a failed one. */ export const MAX_CONCURRENT_GENERATIONS = Number(process.env.ATELIER_MAX_CONCURRENCY ?? 3); /** For `crypto.ts`'s locally-generated at-rest key. Optional escape hatch, same as the standalone service. */ export const projectEnv = (key: string): string | undefined => process.env[key];