Files
pastilhas f23ec1283b manifest, thin proxy router, and the sidecar backend
ported from the standalone officer-atelier service: providers (adapter-shaped, openai the only
adapter today), the generation queue, collections, and the database layer — kept on its own
Postgres database rather than folded into officer_db, since both collections and provider_settings
had rows on the machine this was extracted from.

what changed rather than just moved:
- images are served from an authenticated GET /files/:filename instead of an unauthenticated
  PUBLIC_URL-prefixed static route
- the OpenAI-key bootstrap fallback reads the secret store (getSecret) before .env, per-adapter
- provider_settings (the one-row-per-adapter shape providers replaced) did not come along — it has
  no callers left anywhere in the server code, only a migration script that also did not move

ping/echo (smoke-test routes with no caller) did not move either; the sidecar's own /_health covers
liveness.

not yet wired into the platform: sidecar/index.ts exists but nothing mounts it, and web/ has not
been written, so this is not yet a discoverable plugin.
2026-08-20 03:53:53 +00:00

39 lines
1.6 KiB
TypeScript

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];