diff --git a/.changeset/install-and-runtime-defaults.md b/.changeset/install-and-runtime-defaults.md new file mode 100644 index 00000000..dbe51008 --- /dev/null +++ b/.changeset/install-and-runtime-defaults.md @@ -0,0 +1,5 @@ +--- +"@reelsaw/server": minor +--- + +Safer defaults for new installs and the runtime. The installers now write `SIGNUP_MODE=approval` (the first account is still the admin), publish the web port on `127.0.0.1` only (`BIND_ADDRESS`, `REELSAW_BIND` when installing; existing installs keep listening as before), leave `LLM_TRACE` off, and require the generated database password instead of falling back to `reelsaw`. The development compose file publishes MinIO on `127.0.0.1`. Postgres connections get a statement timeout (`DB_STATEMENT_TIMEOUT_SECONDS`, default 300 s) and boot migrations a 10 s lock timeout. Hosted models' answers are capped at `LLM_MAX_OUTPUT_TOKENS` (default 16384) tokens. diff --git a/.env.example b/.env.example index fbc57002..8c6e9a28 100644 --- a/.env.example +++ b/.env.example @@ -42,8 +42,10 @@ APP_URL=http://localhost:3000 # UPDATE_CHECK_HOURS=6 # Postgres connection string. Compose sets it; set it yourself when running from source. # DATABASE_URL=postgres://reelsaw:reelsaw@localhost:5432/reelsaw -# Connections in each process's Postgres pool (minimum 4). Unset: 10, and a worker process grows its pool to half its job slots plus 4 (logged at boot as "postgres pool sized to the job slots"). The app and every worker process hold their own, so keep the total under Postgres' max_connections. Set explicitly, the value is used as is, and the boot log warns when the job slots are more than twice it. Model-call slots use a separate small pool, and connections time out after 10 s to connect and 5 minutes idle inside a transaction. +# Connections in each process's Postgres pool (minimum 4). Unset: 10, and a worker process grows its pool to half its job slots plus 4 (logged at boot as "postgres pool sized to the job slots"). The app and every worker process hold their own, so keep the total under Postgres' max_connections. Set explicitly, the value is used as is, and the boot log warns when the job slots are more than twice it. Model-call slots use a separate small pool, and connections time out after 10 s to connect and 5 minutes idle inside a transaction (statements: DB_STATEMENT_TIMEOUT_SECONDS). # DB_POOL_MAX= +# A query running longer than this is cancelled by Postgres, so a runaway one gives its pool connection back (0 = never). Migrations at boot are not bounded by it; they give up after waiting 10 s for a table lock instead, so a deploy never queues the app's queries behind one. +# DB_STATEMENT_TIMEOUT_SECONDS=300 # 32+ random characters (openssl rand -base64 32). Signs sessions and encrypts the provider keys admins enter in Settings; rotating it makes those keys unreadable. BETTER_AUTH_SECRET=change-me-to-a-long-random-string # Working directory for uploads, per-project scratch files, the local storage driver and caches. @@ -174,6 +176,8 @@ TRANSCRIBE_CHUNK_SECONDS=600 # ANALYZE_CONCURRENCY=0 # Longest one model call may take (all its HTTP attempts together) before the step is stopped and retried. 0 = auto: 120 s for a hosted model, 600 s for a self-hosted one (Ollama, a compatible server), and for a self-hosted transcription at least twice the chunk's audio length. Time spent waiting for a provider slot (PROVIDER_CONCURRENCY) does not count. A slow CPU-only model may need more. Runtime setting: admins can change it under Settings → System without a restart. # LLM_CALL_TIMEOUT_SECONDS=0 +# Longest answer a hosted model may give, in tokens, sent as the call's output limit (0 = the provider's own maximum). Every step's answer is a short JSON object, far under the default; the limit stops a runaway answer from running to the provider's maximum and being billed for. Self-hosted servers (the compatible server, openai with OPENAI_BASE_URL) are not given one: some refuse a limit larger than the room left in their context. +# LLM_MAX_OUTPUT_TOKENS=16384 # A stage made of checkpointed steps (finding moments) is stopped when no step has finished for this long; Retry continues where it stopped. 0 = auto: 1.5 times the model call timeout. Runtime setting: admins can change it under Settings → System without a restart. # STAGE_IDLE_TIMEOUT_MINUTES=0 # Model calls in flight per provider across every app and worker process, e.g. compat=2,openai=2 (compat = the compatible provider's name). Unset providers: 2 for a self-hosted compatible server, 1 for openai with OPENAI_BASE_URL (a local whisper uses every core per call), unlimited for cloud. Time a call waits here does not count against its time limit. diff --git a/README.md b/README.md index fe11e5bf..5e81029d 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,10 @@ providers (OpenAI, Anthropic, Google, Groq, Vercel AI Gateway) are a choice in t key is asked for and never echoed, and Anthropic and Google pair with local Speaches for speech-to-text. Without a terminal, or with `REELSAW_YES=1`, the proposed answers are taken; `REELSAW_AI`, `REELSAW_LLM`, `REELSAW_PORT` and friends answer in advance and `REELSAW_DRY_RUN=1` -prints the plan and stops (every option is listed at the top of the script). +prints the plan and stops (every option is listed at the top of the script). The installed app +listens on 127.0.0.1 (`REELSAW_BIND`, or `BIND_ADDRESS` in its `.env`), sign-ups after the first +account wait for the admin's approval (`SIGNUP_MODE=approval`), and model-call logging +(`LLM_TRACE`) is off. Manual setup: [deploy/README.md](deploy/README.md). The scripts are [deploy/install.sh](deploy/install.sh) and [deploy/install.ps1](deploy/install.ps1); they are served from `main` (see [docs/RELEASING.md](docs/RELEASING.md)). diff --git a/SECURITY.md b/SECURITY.md index ecf27348..604749dd 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -46,7 +46,8 @@ should follow the update check (Settings → System) or watch releases. ## Hardening an instance -- Set `SIGNUP_MODE=closed` or `approval` after creating the first account. +- Set `SIGNUP_MODE=closed` or `approval` after creating the first account (the installers write + `approval` and publish the port on `127.0.0.1` only). - Keep `BETTER_AUTH_SECRET` long and private; rotating it invalidates sessions and the provider keys stored in Settings. - Leave `ALLOW_PRIVATE_SOURCE_URLS` off unless the instance must read from a NAS. diff --git a/apps/server/scripts/docs-meta.ts b/apps/server/scripts/docs-meta.ts index f1332b3d..90584c93 100644 --- a/apps/server/scripts/docs-meta.ts +++ b/apps/server/scripts/docs-meta.ts @@ -28,9 +28,13 @@ export const DOCS: Record = { PORT: ["core", "Port the HTTP server listens on."], APP_URL: ["core", "Public URL people open in the browser; used for auth cookies, CORS, the OAuth issuer and links in emails."], DATABASE_URL: ["core", "Postgres connection string. Compose sets it; set it yourself when running from source."], + DB_STATEMENT_TIMEOUT_SECONDS: [ + "core", + "A query running longer than this is cancelled by Postgres, so a runaway one gives its pool connection back (0 = never). Migrations at boot are not bounded by it; they give up after waiting 10 s for a table lock instead, so a deploy never queues the app's queries behind one.", + ], DB_POOL_MAX: [ "core", - "Connections in each process's Postgres pool (minimum 4). Unset: 10, and a worker process grows its pool to half its job slots plus 4 (logged at boot as \"postgres pool sized to the job slots\"). The app and every worker process hold their own, so keep the total under Postgres' `max_connections`. Set explicitly, the value is used as is, and the boot log warns when the job slots are more than twice it. Model-call slots use a separate small pool, and connections time out after 10 s to connect and 5 minutes idle inside a transaction.", + "Connections in each process's Postgres pool (minimum 4). Unset: 10, and a worker process grows its pool to half its job slots plus 4 (logged at boot as \"postgres pool sized to the job slots\"). The app and every worker process hold their own, so keep the total under Postgres' `max_connections`. Set explicitly, the value is used as is, and the boot log warns when the job slots are more than twice it. Model-call slots use a separate small pool, and connections time out after 10 s to connect and 5 minutes idle inside a transaction (statements: `DB_STATEMENT_TIMEOUT_SECONDS`).", ], BETTER_AUTH_SECRET: [ "core", @@ -223,6 +227,10 @@ export const DOCS: Record = { "Model calls in flight per provider across every app and worker process, e.g. `compat=2,openai=2` (`compat` = the compatible provider's name). Unset providers: 2 for a self-hosted compatible server, 1 for openai with OPENAI_BASE_URL (a local whisper uses every core per call), unlimited for cloud. Time a call waits here does not count against its time limit.", ], ANALYZE_CONCURRENCY: ["pipeline", "Parallel LLM calls while finding and scoring moments. 0 = auto: 1 for a self-hosted model, 4 for cloud."], + LLM_MAX_OUTPUT_TOKENS: [ + "pipeline", + "Longest answer a hosted model may give, in tokens, sent as the call's output limit (0 = the provider's own maximum). Every step's answer is a short JSON object, far under the default; the limit stops a runaway answer from running to the provider's maximum and being billed for. Self-hosted servers (the compatible server, `openai` with `OPENAI_BASE_URL`) are not given one: some refuse a limit larger than the room left in their context.", + ], LLM_CALL_TIMEOUT_SECONDS: [ "pipeline", "Longest one model call may take (all its HTTP attempts together) before the step is stopped and retried. 0 = auto: 120 s for a hosted model, 600 s for a self-hosted one (Ollama, a compatible server), and for a self-hosted transcription at least twice the chunk's audio length. Time spent waiting for a provider slot (PROVIDER_CONCURRENCY) does not count. A slow CPU-only model may need more.", diff --git a/apps/server/scripts/test-env.d.mts b/apps/server/scripts/test-env.d.mts new file mode 100644 index 00000000..cc067ff7 --- /dev/null +++ b/apps/server/scripts/test-env.d.mts @@ -0,0 +1 @@ +export function testEnv(env: Record): { env: Record; removed: string[] }; diff --git a/apps/server/scripts/test-env.mjs b/apps/server/scripts/test-env.mjs new file mode 100644 index 00000000..38bcf8e7 --- /dev/null +++ b/apps/server/scripts/test-env.mjs @@ -0,0 +1,16 @@ +// The environment the stack-free tests run in: the host's without model-provider credentials. A developer's shell +// often exports ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN or a provider key for their own tools; the provider +// packages read those at call time, so a test that builds a real provider would send requests to that endpoint with +// that token, or fail on what it points at, instead of behaving the same as in CI. +const PROVIDER_VAR = + /^(ANTHROPIC|OPENAI|OPENAI_COMPATIBLE|GOOGLE_GENERATIVE_AI|GOOGLE_VERTEX|GROQ|DEEPGRAM|ASSEMBLYAI|AI_GATEWAY|OPENCODE|LANGFUSE)_|^VERCEL_OIDC_TOKEN$/; + +/** @param {Record} env @returns {{ env: Record, removed: string[] }} */ +export function testEnv(env) { + const removed = Object.keys(env) + .filter((k) => PROVIDER_VAR.test(k)) + .sort(); + const out = { ...env }; + for (const k of removed) delete out[k]; + return { env: out, removed }; +} diff --git a/apps/server/scripts/unit-tests.mjs b/apps/server/scripts/unit-tests.mjs index 0601d1d8..16d124d6 100644 --- a/apps/server/scripts/unit-tests.mjs +++ b/apps/server/scripts/unit-tests.mjs @@ -6,6 +6,7 @@ import { readdirSync, readFileSync } from "node:fs"; import { spawnSync } from "node:child_process"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import { testEnv } from "./test-env.mjs"; const stack = process.argv.includes("--stack"); const root = path.join(path.dirname(fileURLToPath(import.meta.url)), ".."); @@ -19,5 +20,8 @@ const files = readdirSync(dir) console.log(`${files.length} ${stack ? "stack" : "stack-free"} test files`); // the stack files share one app and one Postgres: same concurrency as `pnpm test` const args = ["--import", "tsx", "--test", ...(stack ? ["--test-concurrency=2"] : []), ...files]; -const r = spawnSync(process.execPath, args, { cwd: root, stdio: "inherit" }); +// stack-free files never reach a model: the host's provider credentials stay out (test-env.mjs) +const { env, removed } = stack ? { env: process.env, removed: [] } : testEnv(process.env); +if (removed.length) console.log(`left out of the tests' environment: ${removed.join(", ")}`); +const r = spawnSync(process.execPath, args, { cwd: root, stdio: "inherit", env }); process.exit(r.status ?? 1); diff --git a/apps/server/src/ai/registry.ts b/apps/server/src/ai/registry.ts index b1a0ff5b..d81fa74d 100644 --- a/apps/server/src/ai/registry.ts +++ b/apps/server/src/ai/registry.ts @@ -140,6 +140,25 @@ const lenientJsonSchema: LanguageModelMiddleware = { }), }; +/** + * A ceiling on every answer's length (LLM_MAX_OUTPUT_TOKENS, OWASP LLM10). Without one a degenerate answer runs to the + * provider's own maximum (64k tokens and more for current models) or the call timeout, and is billed for. A call that + * asks for less (the model test asks for 8) keeps its own number. + */ +export function outputCap(max: number): LanguageModelMiddleware { + return { transformParams: async ({ params }) => ({ ...params, maxOutputTokens: Math.min(params.maxOutputTokens ?? max, max) }) }; +} + +/** + * Whether answers from this provider get `outputCap`: hosted providers only. A self-hosted server (the compatible + * server, or "openai" pointed at OPENAI_BASE_URL) costs nothing per token, and some (vLLM, llama.cpp) refuse a + * max_tokens larger than the room left in their context, which would fail every long prompt. + */ +export function capsOutput(provider: string, o: { compatName: string; baseUrl: string | undefined; max: number }): boolean { + if (o.max <= 0) return false; + return !(provider === o.compatName || (provider === "openai" && !!o.baseUrl)); +} + export function createAi( config: Config, log: Logger, @@ -426,8 +445,12 @@ export function createAi( const model = (await resolve("language", id)) as Exclude; // every model handed out: lenient OpenAI schemas, then LLM_TRACE capture (logs / Langfuse) when on const chain = middleware ? [lenientJsonSchema, middleware] : [lenientJsonSchema]; + // outside the trace, so the captured settings show the ceiling the provider was sent + const provider = providerOf(id); + const max = config.LLM_MAX_OUTPUT_TOKENS; + if (capsOutput(provider, { compatName: compat, baseUrl: credentials.get(provider).baseUrl, max })) chain.unshift(outputCap(max)); // the provider gate goes outermost, so a call's traced latency doesn't include its wait for a slot - if (gate) chain.unshift(gate.middleware(providerOf(id))); + if (gate) chain.unshift(gate.middleware(provider)); return wrapLanguageModel({ model: model as Parameters[0]["model"], middleware: chain }) as LanguageModel; }, transcriptionModel: async (id = current().transcription) => (await resolve("transcription", id)) as TranscriptionModel, diff --git a/apps/server/src/config.ts b/apps/server/src/config.ts index b0dd2f3a..2bffbee3 100644 --- a/apps/server/src/config.ts +++ b/apps/server/src/config.ts @@ -47,6 +47,7 @@ export const envSchema = z.object({ * its job slots (workers.ts). Model-call slots (ai/gate.ts) use their own small pool. */ DB_POOL_MAX: z.coerce.number().int().min(4).optional(), + DB_STATEMENT_TIMEOUT_SECONDS: z.coerce.number().int().min(0).max(86_400).default(300), BETTER_AUTH_SECRET: z.string().min(16), DATA_DIR: z.string().default(path.resolve(process.cwd(), "data")), WEB_DIST: z.string().optional(), @@ -134,6 +135,8 @@ export const envSchema = z.object({ ANALYZE_CONCURRENCY: z.coerce.number().int().min(0).max(16).default(0), // one model call (all its HTTP attempts) may take this long; 0 = auto: 120 s hosted, 600 s self-hosted LLM_CALL_TIMEOUT_SECONDS: z.coerce.number().int().min(0).max(86_400).default(0), + /** Longest answer a hosted model may give, in tokens (0 = the provider's own maximum). Self-hosted servers keep theirs. */ + LLM_MAX_OUTPUT_TOKENS: z.coerce.number().int().min(0).max(1_000_000).default(16_384), // a checkpointed stage that finishes no unit of work for this long is stopped (it resumes on retry); 0 = auto: 1.5 x the call timeout STAGE_IDLE_TIMEOUT_MINUTES: z.coerce.number().int().min(0).max(1440).default(0), /** Model calls in flight per provider across every process ("ollama=2,openai=16"; 0 = unlimited). Unset: 2 for self-hosted (the compatible server, openai with a base URL), unlimited for cloud. See ai/gate.ts. */ diff --git a/apps/server/src/db/index.ts b/apps/server/src/db/index.ts index b4af4846..bd169026 100644 --- a/apps/server/src/db/index.ts +++ b/apps/server/src/db/index.ts @@ -44,9 +44,17 @@ const MIGRATE_LOCK = 727_011; const CONNECT_TIMEOUT_MS = 10_000; /** * A session left inside a transaction this long is ended by Postgres (its locks and snapshot are freed). - * Set per connection, not as a global `statement_timeout`: migrations and bulk updates may run long. + * Set per connection, like the statement timeout (DB_STATEMENT_TIMEOUT_SECONDS), never in the server's own config. */ const IDLE_IN_TRANSACTION_MS = 5 * 60_000; +/** The statement timeout when none is given (DB_STATEMENT_TIMEOUT_SECONDS' default): a runaway query gives its connection back. */ +export const DEFAULT_STATEMENT_TIMEOUT_MS = 5 * 60_000; +/** + * How long a migration may wait for a table lock. A DDL statement queued behind a long transaction holds every later + * query on that table behind it, so on a live database it gives up instead, and the boot fails with the reason (the + * next start tries again). Its own work (an index build) is not bounded. + */ +const MIGRATE_LOCK_TIMEOUT = "10s"; /** * A pool's connections when something went wrong: "timeout exceeded when trying to connect" with every connection @@ -56,22 +64,29 @@ export function poolCounts(pool: pg.Pool): { poolTotal: number; poolIdle: number return { poolTotal: pool.totalCount, poolIdle: pool.idleCount, poolWaiting: pool.waitingCount, poolMax: pool.options.max }; } -function makePool(connectionString: string, max: number, log: Logger): pg.Pool { +/** The per-connection settings every pooled connection starts with (and a migration's connection goes back to). */ +const sessionSql = (statementTimeoutMs: number) => + `set idle_in_transaction_session_timeout = ${IDLE_IN_TRANSACTION_MS}; set statement_timeout = ${statementTimeoutMs}`; + +function makePool(connectionString: string, max: number, log: Logger, statementTimeoutMs: number): pg.Pool { const pool = new pg.Pool({ connectionString, max, connectionTimeoutMillis: CONNECT_TIMEOUT_MS }); // an idle client's connection dropped; the pool discards it and opens another, so this recovers by itself pool.on("error", (err) => log.warn({ err, ...poolCounts(pool) }, "pg pool error")); // queued ahead of the first query the pool hands out on this connection pool.on("connect", (client) => { - client - .query(`set idle_in_transaction_session_timeout = ${IDLE_IN_TRANSACTION_MS}`) - .catch((err) => log.warn({ err }, "could not set idle_in_transaction_session_timeout")); + client.query(sessionSql(statementTimeoutMs)).catch((err) => log.warn({ err }, "could not set the connection's timeouts")); }); return pool; } -export function createDatabase(connectionString: string, log: Logger, opts: { poolMax?: number | undefined } = {}): Database { +export function createDatabase( + connectionString: string, + log: Logger, + opts: { poolMax?: number | undefined; statementTimeoutMs?: number | undefined } = {}, +): Database { const poolMax = opts.poolMax ?? 10; - const pool = makePool(connectionString, poolMax, log); + const statementTimeoutMs = Math.max(0, Math.round(opts.statementTimeoutMs ?? DEFAULT_STATEMENT_TIMEOUT_MS)); + const pool = makePool(connectionString, poolMax, log, statementTimeoutMs); gauge( "reelsaw.db.pool.connections", "{connection}", @@ -112,10 +127,22 @@ export function createDatabase(connectionString: string, log: Logger, opts: { po // app and every scaled worker boot at once after a pull; one migrates, the rest wait and find nothing to do const client = await pool.connect(); try { + // waiting for the process that migrates, and a long index build, are not runaway queries + await client.query("set statement_timeout = 0"); await client.query("select pg_advisory_lock($1)", [MIGRATE_LOCK]); + await client.query(`set lock_timeout = '${MIGRATE_LOCK_TIMEOUT}'`); await migrate(drizzle(client, { schema }), { migrationsFolder: folder }); + } catch (err) { + if (lockTimedOut(err)) + throw new Error( + `a migration waited more than ${MIGRATE_LOCK_TIMEOUT} for a table another transaction holds; it was stopped so queries do not queue behind it. Start again once that transaction ends.`, + { cause: err }, + ); + throw err; } finally { await client.query("select pg_advisory_unlock($1)", [MIGRATE_LOCK]).catch(() => {}); + // back to what every pooled connection runs with + await client.query(`reset lock_timeout; ${sessionSql(statementTimeoutMs)}`).catch(() => {}); client.release(); } }, @@ -126,7 +153,7 @@ export function createDatabase(connectionString: string, log: Logger, opts: { po if (max > pool.options.max) pool.options.max = max; }, extraPool(max) { - const extra = makePool(connectionString, max, log); + const extra = makePool(connectionString, max, log, statementTimeoutMs); extraPools.add(extra); return extra; }, @@ -137,6 +164,16 @@ export function createDatabase(connectionString: string, log: Logger, opts: { po }; } +/** Postgres' lock_not_available (55P03), anywhere in the error's causes (drizzle wraps the driver's error). */ +function lockTimedOut(err: unknown): boolean { + let e = err; + for (let i = 0; i < 5 && e && typeof e === "object"; i++) { + if ("code" in e && e.code === "55P03") return true; + e = "cause" in e ? e.cause : undefined; + } + return false; +} + function safeUrl(u: string) { try { const url = new URL(u); diff --git a/apps/server/src/services.ts b/apps/server/src/services.ts index 4b6f4ae4..0a1a7cf2 100644 --- a/apps/server/src/services.ts +++ b/apps/server/src/services.ts @@ -298,7 +298,10 @@ export async function createServices(env: NodeJS.ProcessEnv = process.env): Prom }); const database = await step("database", async () => { - const d = createDatabase(config.DATABASE_URL, log.child({ module: "db" }), { poolMax: config.DB_POOL_MAX }); + const d = createDatabase(config.DATABASE_URL, log.child({ module: "db" }), { + poolMax: config.DB_POOL_MAX, + statementTimeoutMs: config.DB_STATEMENT_TIMEOUT_SECONDS * 1000, + }); await d.check(); await d.migrate(); return d; diff --git a/apps/server/test/db-timeouts.test.ts b/apps/server/test/db-timeouts.test.ts new file mode 100644 index 00000000..90db446a --- /dev/null +++ b/apps/server/test/db-timeouts.test.ts @@ -0,0 +1,44 @@ +/** + * The pool's connection timeouts (db/index.ts): a runaway statement is cancelled after DB_STATEMENT_TIMEOUT_SECONDS, + * and the boot migration runs without that bound but with a lock timeout, then hands its connection back with the + * pool's settings. Before, no statement timeout was set at all, so one stuck query held a pool connection for good. + * Needs Postgres (TEST_DATABASE_URL, migrated to this checkout). + */ +import { after, describe, it } from "node:test"; +import assert from "node:assert/strict"; +import { createDatabase, DEFAULT_STATEMENT_TIMEOUT_MS } from "../src/db/index.js"; +import { createLogger } from "../src/log.js"; +import { dotenv } from "./helpers.js"; + +const url = process.env.TEST_DATABASE_URL ?? `postgres://reelsaw:${dotenv().POSTGRES_PASSWORD ?? "reelsaw"}@127.0.0.1:5432/reelsaw`; +const log = createLogger({ LOG_LEVEL: "fatal", LOG_FORMAT: "json" }); +const show = async (pool: import("pg").Pool, name: string) => (await pool.query(`show ${name}`)).rows[0][name] as string; + +describe("database timeouts", () => { + const opened: Array> = []; + const open = (opts: Parameters[2]) => { + const d = createDatabase(url, log, opts); + opened.push(d); + return d; + }; + after(() => Promise.all(opened.map((d) => d.close()))); + + it("every pooled connection has a statement timeout, five minutes unless configured", async () => { + assert.equal(DEFAULT_STATEMENT_TIMEOUT_MS, 300_000); + assert.equal(await show(open({ poolMax: 1 }).pool, "statement_timeout"), "5min"); + assert.equal(await show(open({ poolMax: 1, statementTimeoutMs: 0 }).pool, "statement_timeout"), "0"); + }); + + it("cancels a statement that runs past it", async () => { + const d = open({ poolMax: 1, statementTimeoutMs: 200 }); + await assert.rejects(d.pool.query("select pg_sleep(2)"), (e: { code?: string }) => e.code === "57014"); + assert.equal((await d.pool.query("select 1 as ok")).rows[0].ok, 1, "the connection is usable afterwards"); + }); + + it("migrates without the statement bound, then hands the connection back with the pool's settings", async () => { + const d = open({ poolMax: 1, statementTimeoutMs: 1500 }); + await d.migrate(); + assert.equal(await show(d.pool, "statement_timeout"), "1500ms"); + assert.equal(await show(d.pool, "lock_timeout"), "0"); + }); +}); diff --git a/apps/server/test/installer-defaults.test.ts b/apps/server/test/installer-defaults.test.ts new file mode 100644 index 00000000..1f003a9c --- /dev/null +++ b/apps/server/test/installer-defaults.test.ts @@ -0,0 +1,62 @@ +/** + * What the installers (deploy/install.sh, deploy/install.ps1) write for a new install, and what the development + * compose file publishes. A VPS install is reachable from the internet between `compose up` and the operator's first + * sign-up, so the defaults must hold on their own: sign-ups after the first account (the admin) wait for approval, + * the web port listens on 127.0.0.1, the database password has no fallback, model prompts (transcript text) are not + * logged, and the MinIO console is not on the LAN. Reads the scripts as text; no Docker needed. + * node --import tsx --test test/installer-defaults.test.ts + */ +import { describe, it } from "node:test"; +import assert from "node:assert/strict"; +import fs from "node:fs"; +import path from "node:path"; + +const root = path.join(import.meta.dirname, "..", "..", ".."); +const read = (p: string) => fs.readFileSync(path.join(root, p), "utf8"); +const sh = read("deploy/install.sh"); +const ps = read("deploy/install.ps1"); +const between = (s: string, start: RegExp, end: RegExp) => { + const a = s.search(start); + assert.ok(a >= 0, `no ${start}`); + const rest = s.slice(a); + const b = rest.slice(1).search(end); + return rest.slice(0, b < 0 ? undefined : b + 1); +}; +/** the generated .env (bash heredocs from `umask 077` to `> .env`; the PowerShell `$lines` up to Write-Lf '.env') */ +const envOf = { + "install.sh": between(sh, /umask 077/, /\} > \.env/), + "install.ps1": between(ps, /\$lines = @\(/, /Write-Lf '\.env'/), +}; +const composeOf = { + "install.sh": between(sh, /cat > docker-compose\.yml <<'YAML'/, /^YAML$/m), + "install.ps1": between(ps, /\$composeYaml = @'/, /^'@$/m), +}; +const active = (text: string, re: RegExp) => text.split("\n").filter((l) => re.test(l) && !/^\s*['"]?#/.test(l)); + +describe("installer defaults", () => { + for (const [name, env] of Object.entries(envOf)) { + it(`${name}: sign-ups wait for approval and model prompts are not logged`, () => { + assert.match(env, /SIGNUP_MODE=approval/); + assert.doesNotMatch(env, /SIGNUP_MODE=open/); + assert.deepEqual(active(env, /LLM_TRACE=(logs|langfuse)/), [], "LLM_TRACE stays off unless the operator turns it on"); + assert.match(env, /BIND_ADDRESS=\$Bind|BIND_ADDRESS=\$BIND/); + }); + } + it("both installers listen on 127.0.0.1 unless told otherwise", () => { + assert.match(sh, /BIND="\$\{REELSAW_BIND:-127\.0\.0\.1\}"/); + assert.match(ps, /\$Bind\s+= Opt 'REELSAW_BIND' '127\.0\.0\.1'/); + }); + for (const [name, compose] of Object.entries(composeOf)) { + it(`${name}: the compose file binds the web port to BIND_ADDRESS and has no default database password`, () => { + assert.match(compose, /"\$\{BIND_ADDRESS:\+\$\{BIND_ADDRESS:-\}:\}\$\{PORT:-3000\}:3000"/); + assert.doesNotMatch(compose, /POSTGRES_PASSWORD:-/); + assert.match(compose, /POSTGRES_PASSWORD:\?/); + }); + } + it("the development compose file publishes MinIO on 127.0.0.1 only", () => { + const minio = between(read("docker-compose.yml"), /^ {2}minio:$/m, /^ {2}\w[\w-]*:$/m); + const ports = active(minio, /^\s+- "[^"]*:900[01]"$/); + assert.equal(ports.length, 2); + for (const p of ports) assert.match(p, /"127\.0\.0\.1:/); + }); +}); diff --git a/apps/server/test/llm-output-cap.test.ts b/apps/server/test/llm-output-cap.test.ts new file mode 100644 index 00000000..dc97ff41 --- /dev/null +++ b/apps/server/test/llm-output-cap.test.ts @@ -0,0 +1,52 @@ +/** + * The ceiling on a model's answer (ai/registry.ts outputCap, LLM_MAX_OUTPUT_TOKENS). Before, no call set + * maxOutputTokens, so a degenerate answer ran to the provider's own maximum. Hosted providers get the ceiling; a + * self-hosted server does not (some refuse a limit larger than their remaining context); a call asking for less keeps it. + */ +import { describe, it } from "node:test"; +import assert from "node:assert/strict"; +import { generateText, wrapLanguageModel } from "ai"; +import { MockLanguageModelV4 } from "ai/test"; +import { capsOutput, outputCap } from "../src/ai/registry.js"; +import { loadConfig } from "../src/config.js"; + +function recorder() { + const seen: Array = []; + const model = new MockLanguageModelV4({ + doGenerate: async (opts) => { + seen.push(opts.maxOutputTokens); + return { + content: [{ type: "text", text: "ok" }], + finishReason: { unified: "stop", raw: "stop" }, + usage: { inputTokens: { total: 1, noCache: 1, cacheRead: 0, cacheWrite: 0 }, outputTokens: { total: 1, text: 1, reasoning: 0 } }, + warnings: [], + }; + }, + }); + return { seen, model }; +} + +describe("model output ceiling", () => { + it("sends the ceiling when a call gives none, and keeps a smaller one", async () => { + const { seen, model } = recorder(); + const capped = wrapLanguageModel({ model, middleware: outputCap(1000) }); + await generateText({ model: capped, prompt: "hi" }); + await generateText({ model: capped, prompt: "hi", maxOutputTokens: 8 }); + await generateText({ model: capped, prompt: "hi", maxOutputTokens: 50_000 }); + assert.deepEqual(seen, [1000, 8, 1000]); + }); + + it("applies to hosted providers, not to a self-hosted server, and not when set to 0", () => { + const o = { compatName: "ollama", baseUrl: undefined, max: 16_384 }; + assert.equal(capsOutput("anthropic", o), true); + assert.equal(capsOutput("openai", o), true); + assert.equal(capsOutput("ollama", o), false); + assert.equal(capsOutput("openai", { ...o, baseUrl: "http://speaches:8000/v1" }), false); + assert.equal(capsOutput("anthropic", { ...o, max: 0 }), false); + }); + + it("defaults to 16384 tokens", () => { + const config = loadConfig({ DATABASE_URL: "postgres://x@localhost/x", BETTER_AUTH_SECRET: "x".repeat(32), AI_MODEL: "openai:gpt-4o-mini" }); + assert.equal(config.LLM_MAX_OUTPUT_TOKENS, 16_384); + }); +}); diff --git a/apps/server/test/test-env.test.ts b/apps/server/test/test-env.test.ts new file mode 100644 index 00000000..126ed8cf --- /dev/null +++ b/apps/server/test/test-env.test.ts @@ -0,0 +1,40 @@ +/** + * The stack-free tests run without the host's model-provider credentials (scripts/test-env.mjs, used by + * scripts/unit-tests.mjs). Before, a shell exporting ANTHROPIC_BASE_URL= (empty) failed 15 transcription tests with + * "baseURL must be a non-empty string", and an exported key or base URL would have been used by any test that builds a + * real provider. + */ +import { describe, it } from "node:test"; +import assert from "node:assert/strict"; +import fs from "node:fs"; +import path from "node:path"; +import { testEnv } from "../scripts/test-env.mjs"; + +describe("unit test environment", () => { + it("drops provider keys, tokens and base URLs and keeps everything else", () => { + const { env, removed } = testEnv({ + ANTHROPIC_BASE_URL: "", + ANTHROPIC_AUTH_TOKEN: "t", + ANTHROPIC_API_KEY: "k", + OPENAI_API_KEY: "k", + OPENAI_BASE_URL: "http://x", + OPENAI_COMPATIBLE_BASE_URL: "http://y", + GOOGLE_GENERATIVE_AI_API_KEY: "k", + AI_GATEWAY_API_KEY: "k", + VERCEL_OIDC_TOKEN: "t", + OPENCODE_API_KEY: "k", + PATH: "/bin", + HOME: "/home/x", + TEST_DATABASE_URL: "postgres://x", + AI_MODEL: "openai:gpt", + }); + assert.deepEqual(Object.keys(env).sort(), ["AI_MODEL", "HOME", "PATH", "TEST_DATABASE_URL"]); + assert.equal(removed.length, 10); + }); + + it("is what unit-tests.mjs hands the test processes", () => { + const src = fs.readFileSync(path.join(import.meta.dirname, "..", "scripts", "unit-tests.mjs"), "utf8"); + assert.match(src, /import \{ testEnv \} from "\.\/test-env\.mjs"/); + assert.match(src, /spawnSync\(process\.execPath, args, \{[^}]*\benv\b/); + }); +}); diff --git a/deploy/.env.example b/deploy/.env.example index a736766b..905f5484 100644 --- a/deploy/.env.example +++ b/deploy/.env.example @@ -33,8 +33,10 @@ APP_URL=http://localhost:3000 # UPDATE_CHECK_URL=https://api.github.com/repos/osbytes/reelsaw/releases/latest # Hours between update checks (1–168). "Check now" in Settings asks at most once a minute. # UPDATE_CHECK_HOURS=6 -# Connections in each process's Postgres pool (minimum 4). Unset: 10, and a worker process grows its pool to half its job slots plus 4 (logged at boot as "postgres pool sized to the job slots"). The app and every worker process hold their own, so keep the total under Postgres' max_connections. Set explicitly, the value is used as is, and the boot log warns when the job slots are more than twice it. Model-call slots use a separate small pool, and connections time out after 10 s to connect and 5 minutes idle inside a transaction. +# Connections in each process's Postgres pool (minimum 4). Unset: 10, and a worker process grows its pool to half its job slots plus 4 (logged at boot as "postgres pool sized to the job slots"). The app and every worker process hold their own, so keep the total under Postgres' max_connections. Set explicitly, the value is used as is, and the boot log warns when the job slots are more than twice it. Model-call slots use a separate small pool, and connections time out after 10 s to connect and 5 minutes idle inside a transaction (statements: DB_STATEMENT_TIMEOUT_SECONDS). # DB_POOL_MAX= +# A query running longer than this is cancelled by Postgres, so a runaway one gives its pool connection back (0 = never). Migrations at boot are not bounded by it; they give up after waiting 10 s for a table lock instead, so a deploy never queues the app's queries behind one. +# DB_STATEMENT_TIMEOUT_SECONDS=300 # 32+ random characters (openssl rand -base64 32). Signs sessions and encrypts the provider keys admins enter in Settings; rotating it makes those keys unreadable. BETTER_AUTH_SECRET= # Stable name for this process on Settings → System → Workers. Unset: hostname:pid. Set it to the pod or container name when scaling workers so each replica stays recognisable. Two live processes must not share an id (they would overwrite each other's heartbeat and disk leases): if a process with the same id beat in the last 30 s, the new one appends - and four hex characters and logs a warning, so a pinned id on docker compose --scale worker=N still works. @@ -157,6 +159,8 @@ KLIPY_API_KEY= # ANALYZE_CONCURRENCY=0 # Longest one model call may take (all its HTTP attempts together) before the step is stopped and retried. 0 = auto: 120 s for a hosted model, 600 s for a self-hosted one (Ollama, a compatible server), and for a self-hosted transcription at least twice the chunk's audio length. Time spent waiting for a provider slot (PROVIDER_CONCURRENCY) does not count. A slow CPU-only model may need more. Runtime setting: admins can change it under Settings → System without a restart. # LLM_CALL_TIMEOUT_SECONDS=0 +# Longest answer a hosted model may give, in tokens, sent as the call's output limit (0 = the provider's own maximum). Every step's answer is a short JSON object, far under the default; the limit stops a runaway answer from running to the provider's maximum and being billed for. Self-hosted servers (the compatible server, openai with OPENAI_BASE_URL) are not given one: some refuse a limit larger than the room left in their context. +# LLM_MAX_OUTPUT_TOKENS=16384 # A stage made of checkpointed steps (finding moments) is stopped when no step has finished for this long; Retry continues where it stopped. 0 = auto: 1.5 times the model call timeout. Runtime setting: admins can change it under Settings → System without a restart. # STAGE_IDLE_TIMEOUT_MINUTES=0 # Model calls in flight per provider across every app and worker process, e.g. compat=2,openai=2 (compat = the compatible provider's name). Unset providers: 2 for a self-hosted compatible server, 1 for openai with OPENAI_BASE_URL (a local whisper uses every core per call), unlimited for cloud. Time a call waits here does not count against its time limit. diff --git a/deploy/README.md b/deploy/README.md index 1ec67453..8f9eda1a 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -49,7 +49,7 @@ It prints a plan and, in a terminal, asks three questions: Without a terminal (CI, `ssh host 'curl … | bash'`) or with `REELSAW_YES=1` the proposed answers are taken and nothing is installed beyond containers; `REELSAW_DRY_RUN=1` prints the plan and stops. Every answer can be given in advance (`REELSAW_AI`, `REELSAW_LLM`, `REELSAW_WHISPER`, `REELSAW_PORT`, -`REELSAW_DIR`, `REELSAW_IMAGE`, `REELSAW_PROJECT`; see the top of the script). +`REELSAW_DIR`, `REELSAW_IMAGE`, `REELSAW_PROJECT`, `REELSAW_BIND`; see the top of the script). What it does with the answers: @@ -110,6 +110,15 @@ On Docker Desktop (Windows), `gpu` may show `/dev/dxg` rather than a named card, `nvidia-smi` is usually not in the app image — trust `video encoder: h264_nvenc` instead. macOS has no CUDA in Docker: run Ollama natively (Metal) and leave Speaches on the CPU. +## Reaching it from other machines + +The installer publishes the web app on `127.0.0.1` only (`BIND_ADDRESS` in `.env`; `REELSAW_BIND` +when installing), matching its `APP_URL=http://localhost:`. To use it from elsewhere, put a +reverse proxy with HTTPS in front, or set `BIND_ADDRESS=0.0.0.0` and `APP_URL` to the address +people use, then `docker compose up -d`. An install from before `BIND_ADDRESS` keeps listening on +every interface. `LLM_TRACE` is off in a new install: `LLM_TRACE=logs` puts model prompts, which +carry transcript text, into the logs and issue reports. + ## Configuration `.env.example` lists every variable with its default and meaning; the same list as a table is @@ -117,7 +126,8 @@ macOS has no CUDA in Docker: run Ollama natively (Metal) and leave Speaches on t ## Accounts -The first account is the admin. `SIGNUP_MODE=open|approval|closed` in `.env` controls sign-ups; +The first account is the admin. `SIGNUP_MODE=open|approval|closed` in `.env` controls sign-ups +(the installer writes `approval`, so nobody who finds the address gets in without you); with `approval`, new people wait until you approve them on the **Users** page (or `docker compose exec app reelsaw approve them@example.com`). Set `EMAIL_DRIVER` to get an email when someone is waiting. Locked out: `docker compose exec app reelsaw make-admin you@example.com`. diff --git a/deploy/install.ps1 b/deploy/install.ps1 index f0e61df2..36ca0f50 100644 --- a/deploy/install.ps1 +++ b/deploy/install.ps1 @@ -21,6 +21,7 @@ # hosted: provider:model, e.g. anthropic:claude-sonnet-4-5 # REELSAW_WHISPER= Speaches model (default faster-whisper-small; medium/large-v3 on a GPU) # REELSAW_PORT=3000 port for the web app (a busy port moves to the next free one) +# REELSAW_BIND=127.0.0.1 host address the web app listens on (0.0.0.0: every interface) # REELSAW_DIR=$HOME\reelsaw where to install # REELSAW_IMAGE=ghcr.io/osbytes/reelsaw:latest # REELSAW_PROJECT=reelsaw compose project name (containers/volumes prefix) @@ -35,6 +36,7 @@ function Opt($name, $default) { $v = [Environment]::GetEnvironmentVariable($name $Dir = Opt 'REELSAW_DIR' (Join-Path $HOME 'reelsaw') $Image = Opt 'REELSAW_IMAGE' 'ghcr.io/osbytes/reelsaw:latest' $Port = [int](Opt 'REELSAW_PORT' '3000') +$Bind = Opt 'REELSAW_BIND' '127.0.0.1' $Project = Opt 'REELSAW_PROJECT' 'reelsaw' $Yes = [bool](Opt 'REELSAW_YES' '') $Dry = [bool](Opt 'REELSAW_DRY_RUN' '') @@ -134,6 +136,7 @@ $Existing = Test-Path $EnvFile if ($Existing) { $p = EnvGet 'PORT'; if ($p) { $Port = [int]$p } $pinned = EnvGet 'REELSAW_IMAGE'; if ($pinned) { $Image = $pinned } + $Bind = EnvGet 'BIND_ADDRESS' # an install from before BIND_ADDRESS listens on every interface, as it did } # Volumes outlive a deleted folder or .env: a database from an earlier install under the same project # name keeps the password it was created with. The installer keeps that data and resets the password @@ -386,7 +389,7 @@ services: restart: unless-stopped environment: POSTGRES_USER: reelsaw - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-reelsaw} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is missing from .env} POSTGRES_DB: reelsaw volumes: - pgdata:/var/lib/postgresql/data @@ -399,14 +402,15 @@ services: app: <<: *app environment: - DATABASE_URL: postgres://reelsaw:${POSTGRES_PASSWORD:-reelsaw}@db:5432/reelsaw + DATABASE_URL: postgres://reelsaw:${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is missing from .env}@db:5432/reelsaw PORT: "3000" DATA_DIR: /data LOG_FILE: /data/logs/reelsaw.log RUN_HTTP: "true" RUN_WORKERS: "true" + # BIND_ADDRESS (.env; the installer writes 127.0.0.1) is the host address the port listens on; unset = every interface ports: - - "${PORT:-3000}:3000" + - "${BIND_ADDRESS:+${BIND_ADDRESS:-}:}${PORT:-3000}:3000" speaches: image: ${SPEACHES_IMAGE:-ghcr.io/speaches-ai/speaches:latest-cpu} # :latest-cuda with an NVIDIA GPU @@ -471,7 +475,10 @@ if ($Existing) { "APP_URL=http://localhost:$Port", "PORT=$Port", "REELSAW_IMAGE=$Image", - 'SIGNUP_MODE=open') + '# the web app listens on this machine only; 0.0.0.0 (with APP_URL set to the address people use) opens it to the network', + "BIND_ADDRESS=$Bind", + '# the first account is the admin; later sign-ups wait for your approval on the Users page (closed: none, open: anyone)', + 'SIGNUP_MODE=approval') if ($GpuCompose) { $lines += 'COMPOSE_FILE=docker-compose.yml;docker-compose.gpu.yml' } $lines += '' if ($Ai -eq 'local') { @@ -485,7 +492,10 @@ if ($Existing) { } else { $lines += @("# speech-to-text: $Ai", "TRANSCRIPTION_MODEL=$Stt") } - $lines += @('', '# model calls go to the log so "Report an issue" can include them (prompts contain transcript text)', 'LLM_TRACE=logs') + $lines += @('', + '# logs: model calls go to the log, so "Report an issue" can include them. Off by default: the prompts carry every', + "# account's transcript text, kept with the logs for 7 days", + '# LLM_TRACE=logs') Write-Lf '.env' (($lines -join "`n") + "`n") } @@ -540,7 +550,10 @@ for ($i = 0; $i -lt 120; $i++) { Say "Reelsaw is running: http://localhost:$Port" Write-Host @" - Create your account, then set SIGNUP_MODE=closed (or approval) in $Dir\.env and restart. + Create your account first: it becomes the admin. Later sign-ups wait for your approval on the Users + page (SIGNUP_MODE=approval in $Dir\.env; closed turns sign-ups off). The app listens on + $(if ($Bind) { $Bind } else { 'every interface' }); to reach it from other machines put a reverse proxy in front, or set BIND_ADDRESS=0.0.0.0 + and APP_URL in .env, then restart. Models and providers can be changed later under Settings -> System -> Models, no restart needed. cd $Dir diff --git a/deploy/install.sh b/deploy/install.sh index 4457c809..2dd14447 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -22,6 +22,7 @@ # hosted: provider:model, e.g. anthropic:claude-sonnet-4-5 # REELSAW_WHISPER= Speaches model (default faster-whisper-small; medium/large-v3 on a GPU) # REELSAW_PORT=3000 port for the web app (a busy port moves to the next free one) +# REELSAW_BIND=127.0.0.1 host address the web app listens on (0.0.0.0: every interface) # REELSAW_DIR=~/reelsaw where to install # REELSAW_IMAGE=ghcr.io/osbytes/reelsaw:latest # REELSAW_PROJECT=reelsaw compose project name (containers/volumes prefix) @@ -37,6 +38,7 @@ for a in "$@"; do case "$a" in -y|--yes) REELSAW_YES=1 ;; --dry-run) REELSAW_DRY DIR="${REELSAW_DIR:-$HOME/reelsaw}" IMAGE="${REELSAW_IMAGE:-ghcr.io/osbytes/reelsaw:latest}" PORT="${REELSAW_PORT:-3000}" +BIND="${REELSAW_BIND:-127.0.0.1}" PROJECT="${REELSAW_PROJECT:-reelsaw}" YES="${REELSAW_YES:-}" DRY="${REELSAW_DRY_RUN:-}" @@ -134,6 +136,7 @@ if [ -f "$ENV_FILE" ]; then EXISTING=1 PORT=$(envget PORT); PORT=${PORT:-3000} pinned=$(envget REELSAW_IMAGE); [ -n "$pinned" ] && IMAGE="$pinned" + BIND=$(envget BIND_ADDRESS) # an install from before BIND_ADDRESS listens on every interface, as it did fi # Volumes outlive a deleted folder or .env: a database from an earlier install under the same project # name keeps the password it was created with. The installer keeps that data and resets the password @@ -443,7 +446,7 @@ services: restart: unless-stopped environment: POSTGRES_USER: reelsaw - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-reelsaw} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is missing from .env} POSTGRES_DB: reelsaw volumes: - pgdata:/var/lib/postgresql/data @@ -456,14 +459,15 @@ services: app: <<: *app environment: - DATABASE_URL: postgres://reelsaw:${POSTGRES_PASSWORD:-reelsaw}@db:5432/reelsaw + DATABASE_URL: postgres://reelsaw:${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is missing from .env}@db:5432/reelsaw PORT: "3000" DATA_DIR: /data LOG_FILE: /data/logs/reelsaw.log RUN_HTTP: "true" RUN_WORKERS: "true" + # BIND_ADDRESS (.env; the installer writes 127.0.0.1) is the host address the port listens on; unset = every interface ports: - - "${PORT:-3000}:3000" + - "${BIND_ADDRESS:+${BIND_ADDRESS:-}:}${PORT:-3000}:3000" speaches: image: ${SPEACHES_IMAGE:-ghcr.io/speaches-ai/speaches:latest-cpu} # :latest-cuda with an NVIDIA GPU @@ -530,7 +534,10 @@ POSTGRES_PASSWORD=$(rand 24) APP_URL=http://localhost:$PORT PORT=$PORT REELSAW_IMAGE=$IMAGE -SIGNUP_MODE=open +# the web app listens on this machine only; 0.0.0.0 (with APP_URL set to the address people use) opens it to the network +BIND_ADDRESS=$BIND +# the first account is the admin; later sign-ups wait for your approval on the Users page (closed: none, open: anyone) +SIGNUP_MODE=approval ENV [ -n "$GPU_COMPOSE" ] && echo "COMPOSE_FILE=docker-compose.yml:docker-compose.gpu.yml" echo @@ -566,8 +573,9 @@ ENV fi cat <<'ENV' -# model calls go to the log so "Report an issue" can include them (prompts contain transcript text) -LLM_TRACE=logs +# logs: model calls go to the log, so "Report an issue" can include them. Off by default: the prompts carry every +# account's transcript text, kept with the logs for 7 days +# LLM_TRACE=logs ENV } > .env umask 022 @@ -614,7 +622,10 @@ for _ in $(seq 1 120); do say "Reelsaw is running: http://localhost:$PORT" cat <