Multiplayer agent harness for work.
Support web-only and Slack-only dev instances (#1262)
Regan Bell3c62c210a275
diff --git a/.codex/skills/dev-instance/SKILL.md b/.codex/skills/dev-instance/SKILL.mdindex fb421a47c..3f4901021 100644--- a/.codex/skills/dev-instance/SKILL.md+++ b/.codex/skills/dev-instance/SKILL.md@@ -1,12 +1,12 @@---name: dev-instance-description: Run the current worktree as a production-shaped local dev instance — core, Slack, web UI, admin, portal, on a real Pi LLM + Postgres — reachable in Slack as your own bot. Each developer uses their own set of Slack apps from their own machine's pool store, so many worktrees (yours and a teammate's) can run reachable at once without colliding. Use when asked to /dev-instance, "spin this up so I can QA it in Slack", or "let me test your branch end to end".+description: Run the current worktree as a production-shaped local dev instance with web, Slack, or both, on a real LLM + Postgres. Each developer uses their own set of Slack apps from their own machine's pool store, so many worktrees (yours and a teammate's) can run reachable at once without colliding. Use when asked to /dev-instance, "spin this up so I can QA it in Slack", or "let me test your branch end to end".---# dev-instance-`dev-instance` runs the current worktree as a full, production-shaped stack on your-machine and makes it reachable in Slack as one of _your_ bots. It is the way to QA a+`dev-instance` runs the current worktree with the surfaces needed for the task.+Choose web for browser/admin work, Slack for bot work, and both only for cross-surface QA. It is the way to QA abranch end to end: real LLM turns, a real sandbox, a real local Postgres (empty bydefault; opt in to prod data), and the real Slack/web/admin surfaces.@@ -14,7 +14,9 @@ Use the repo-root launcher (a thin wrapper over the TypeScript CLI in `scripts/devery command accepts `--json` for machine-readable output):```bash-bash scripts/dev-instance.sh up+bash scripts/dev-instance.sh up --surface web+bash scripts/dev-instance.sh up --surface slack+bash scripts/dev-instance.sh up --surface bothbash scripts/dev-instance.sh statusbash scripts/dev-instance.sh downbash scripts/dev-instance.sh doctor@@ -27,22 +29,29 @@ bash scripts/dev-instance.sh logs [child] [-f]`npm run dev-instance:doctor` are equivalent. The Codex-visible skill copy lives at`.codex/skills/dev-instance/SKILL.md`; keep the two skill descriptions equivalent.+New instances default to web only. `npm run dev-instance:web`,+`npm run dev-instance:slack`, and `npm run dev-instance:both` select a surface explicitly.+Bare `up` preserves the mode of an existing instance. Explicitly selecting a different+surface tears down and boots the worktree again, claiming the appropriate slot.+`--no-slack` (and `DEV_INSTANCE_NO_SLACK=1`) remain aliases for web only.+## What `up` Starts-`up` claims one free Slack app slot from **this machine's** pool store (see "Slack reach"+`up --surface slack` and `up --surface both` claim one free Slack app slot from **this machine's** pool store (see "Slack reach"below), then spawns a **per-slot supervisor daemon** that owns the production-shaped stack:-- core API + workers-- Slack Socket Mode plugin (connected as the claimed app's bot)-- web UI surface-- admin surface-- portal front door proxying `/web-ui/` and `/admin/`+- core API + workers in every mode+- Slack Socket Mode plugin in `slack` and `both`+- web UI, admin, and portal front door in `web` and `both`++Web-only instances need no Slack app or pool credentials. Slack-only instances skip+web dependencies, builds, and web/portal processes.The supervisor restarts crashed children with backoff, waits for a port to actually freebefore respawning (no more EADDRINUSE), health-probes everything every 10s, and writes aheartbeat so slot reclaim can tell "actively in use" from "abandoned".-**`up` only prints success after proving the bot is reachable**: the Slack socket must be+**When Slack is enabled, `up` only prints success after proving the bot is reachable**: the Slack socket must bethe app's _only_ connection (`num_connections == 1`, read from the hello frame) and — whenthe slot has a `CANARY_CHANNEL` — a posted canary message must arrive back over that samesocket. If Slack reports multiple connections, `up` flags the slot for 30 minutes and@@ -172,7 +181,7 @@ self-API calls can reach your local core. None of that runs on the default local## After Startup-Report the slot, portal URL, Slack handle, and log directory. To test Slack-specific+Report the slot, enabled surfaces, their URLs or Slack handle, and log directory. To test Slack-specificbehavior, DM the printed `@<handle>` (on Alice's machine that's one of `@bot1 … @bot10`)in `example.slack.com`; for admin and web behavior, open the printed portal URL. Tear downwith `bash scripts/dev-instance.sh down` when QA is finished.diff --git a/README.md b/README.mdindex cc3b12ba1..13fe21927 100644--- a/README.md+++ b/README.md@@ -68,9 +68,11 @@ flowchart LR```For durability, set `DATABASE_URL` and `SESSION_STORE=postgres` — without it, sessions-live in process memory and vanish on restart. To exercise a branch end to end — core,-Slack, web, admin, portal, against a real model and real Postgres — run-`npm run dev-instance`.+live in process memory and vanish on restart. To exercise a branch against a real model and real Postgres, run+`npm run dev-instance:web` for web/admin or `npm run dev-instance:slack` for Slack.+Use `npm run dev-instance:both` when testing both surfaces together. Bare+`npm run dev-instance` defaults to web for new instances and preserves the surface+on reload. Switch an existing instance with an explicit surface command.## Architecturediff --git a/cli/src/cli.ts b/cli/src/cli.tsindex 28b90d17c..b8fc89239 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -165,7 +165,7 @@ ${bold("DEPLOY (operator)")} ${dim("— runs in the deployment directory")}--sandbox-dir <path> path to the sandbox layer dir (default: sandbox/ in the deploy dir)${bold("DEVELOP (contributor)")} ${dim("— runs in the QM repo")}- dev up [--org <id>] · dev down · dev status · dev restart · dev canary · dev logs · dev doctor [options]+ dev up [--surface web|slack|both] [--org <id>] · dev down · dev status · dev restart · dev canary · dev logs · dev doctor [options]run the supervised contributor engine in scripts/dev/dev --ci [up|down] CI mode: core only (Slack in-process), no pool lease (live-e2e)@@ -303,6 +303,8 @@ async function dispatch(argv: string[]): Promise<void> {"follow","fix","sandbox",+ "surface",+ "no-slack","no-watch","org",]);diff --git a/cli/test/e2e/dev.e2e.test.ts b/cli/test/e2e/dev.e2e.test.tsindex dc5ea7a98..16b211ed9 100644--- a/cli/test/e2e/dev.e2e.test.ts+++ b/cli/test/e2e/dev.e2e.test.ts@@ -40,15 +40,23 @@ test("delegated dev commands reject extra arguments and irrelevant flags beforeassert.equal(extra.code, 2);assert.match(extra.out, /unexpected argument: "garbage"/);+ const invalidSurface = runCli(["dev", "up", "--surface", "invalid"], { cwd: repoRoot });+ assert.equal(invalidSurface.code, 2);+ assert.match(invalidSurface.out, /--surface must be web, slack, or both/);++ const conflictingSurface = runCli(["dev", "up", "--surface", "slack", "--no-slack"], { cwd: repoRoot });+ assert.equal(conflictingSurface.code, 2);+ assert.match(conflictingSurface.out, /--no-slack conflicts with --surface slack/);+const irrelevant = runCli(["dev", "status", "--rotate"], { cwd: repoRoot });assert.equal(irrelevant.code, 2);assert.match(irrelevant.out, /status does not support --rotate/);});-test("dev up accepts an org override before entering the canonical pool path", (t) => {+test("dev up forwards a Slack surface and org override to the canonical pool path", (t) => {const store = tmp("dev-org-pool");t.after(() => rmDir(store));- const result = runCli(["dev", "up", "--org", "beta"], {+ const result = runCli(["dev", "up", "--surface", "slack", "--org", "beta"], {cwd: repoRoot,env: { QM_POOL_STORE: store, DEV_INSTANCE_WAIT: "0" },});diff --git a/package.json b/package.jsonindex 1903789f8..39ec066a5 100644--- a/package.json+++ b/package.json@@ -13,6 +13,9 @@"start": "node --env-file-if-exists=.env src/index.ts","dev": "SHUTDOWN_DRAIN_MS=2000 node --env-file-if-exists=.env --watch src/index.ts","dev-instance": "bash scripts/dev-instance.sh up",+ "dev-instance:web": "bash scripts/dev-instance.sh up --surface web",+ "dev-instance:slack": "bash scripts/dev-instance.sh up --surface slack",+ "dev-instance:both": "bash scripts/dev-instance.sh up --surface both","dev-instance:no-slack": "bash scripts/dev-instance.sh up --no-slack","dev-instance:status": "bash scripts/dev-instance.sh status","dev-instance:down": "bash scripts/dev-instance.sh down",diff --git a/scripts/dev/cli.ts b/scripts/dev/cli.tsindex 2ecc2c3ed..3a524af0e 100644--- a/scripts/dev/cli.ts+++ b/scripts/dev/cli.ts@@ -58,6 +58,7 @@ function parseCli() {follow: { type: "boolean", short: "f", default: false },fix: { type: "boolean", default: false },sandbox: { type: "string", default: "auto" },+ surface: { type: "string" },"no-slack": { type: "boolean", default: false },"no-watch": { type: "boolean", default: false },org: { type: "string" },@@ -75,7 +76,7 @@ const command = positionals[0] ?? "up";const store = poolStore();const commandOptions: Record<string, readonly string[]> = {- up: ["json", "force", "strict", "rotate", "sandbox", "no-slack", "no-watch", "org"],+ up: ["json", "force", "strict", "rotate", "sandbox", "surface", "no-slack", "no-watch", "org"],down: ["json"],status: ["json"],restart: ["json"],@@ -116,7 +117,18 @@ function emitJson(payload: unknown): void {}const orgId = opts.org ?? process.env.DEV_INSTANCE_ORG_ID ?? "acme";-const withSlack = !opts["no-slack"] && process.env.DEV_INSTANCE_NO_SLACK !== "1";+const requestedSurface =+ opts.surface ?? (opts["no-slack"] || process.env.DEV_INSTANCE_NO_SLACK === "1" ? "web" : undefined);+if (requestedSurface !== undefined && !["web", "slack", "both"].includes(requestedSurface)) {+ console.error("dev: --surface must be web, slack, or both");+ process.exit(EXIT.usage);+}+if (opts.surface && opts["no-slack"] && opts.surface !== "web") {+ console.error("dev: --no-slack conflicts with --surface " + opts.surface);+ process.exit(EXIT.usage);+}+let withSlack = requestedSurface === "slack" || requestedSurface === "both";+let withWeb = requestedSurface !== "slack";const devCallerEnv = (): Record<string, string> => ({ ...callerEnvSnapshot(), DEV_INSTANCE_ORG_ID: orgId });async function legacyTeardown(lease: LeaseInfo): Promise<void> {@@ -219,6 +231,7 @@ async function bootOnSlot(slot: string, worktree: string, branch: string): Promi`admin_port=${ports.admin}`,`portal_port=${ports.portal}`,`slack=${withSlack ? "1" : "0"}`,+ `web=${withWeb ? "1" : "0"}`,"booting=1",`owner_pid=${process.pid}`,`created_epoch=${nowEpoch()}`,@@ -249,6 +262,7 @@ async function bootOnSlot(slot: string, worktree: string, branch: string): PromicanaryChannel,strict: opts.strict,slack: withSlack,+ web: withWeb,},null,2,@@ -305,14 +319,17 @@ function printSuccess(result: BootResult, branch: string): void {: `[ok] dev instance up -- slot ${result.slot} (browser only -- Slack off)`,);out(` branch : ${branch}`);- out(` portal : http://localhost:${ports.portal} -> prod-style front door: the assistant at / and /admin`);+ if (result.webEnabled !== false)+ out(` portal : http://localhost:${ports.portal} -> prod-style front door: the assistant at / and /admin`);out(` core : http://localhost:${ports.core} (org=${orgId}, session_store=${meta.session_store}, run_store=${meta.run_store})`,);if (slackLive) out(` slack : @${result.handle} -> mention it in example.slack.com to test`);- out(` web : http://localhost:${ports.portal}/ (direct: http://localhost:${ports.web})`);- out(` admin : http://localhost:${ports.portal}/admin/ (direct: http://localhost:${ports.web}/admin/)`);- out(` logs : ${lock}/{core,web,portal,supervisor}.log`);+ if (result.webEnabled !== false)+ out(` web : http://localhost:${ports.portal}/ (direct: http://localhost:${ports.web})`);+ if (result.webEnabled !== false)+ out(` admin : http://localhost:${ports.portal}/admin/ (direct: http://localhost:${ports.web}/admin/)`);+ out(` logs : ${lock}`);out(` status : dev status | diagnose: dev doctor | apply env/code changes: dev up (reloads in place)`);out(` down : dev down (auto-reaped if this worktree is removed)`);}@@ -325,9 +342,16 @@ async function cmdUp(): Promise<number> {const mine = myLease(worktree, store);if (mine) {+ if (requestedSurface === undefined) {+ withSlack = mine.meta.slack !== "0";+ withWeb = mine.meta.web !== "0";+ }const sock = resolveSocketPath(mine.lockDir);if (await supervisorReachable(sock)) {- if (opts.rotate) {+ if (withSlack !== (mine.meta.slack !== "0") || withWeb !== (mine.meta.web !== "0")) {+ out(`switching surfaces on ${mine.slot}...`);+ await teardownLease(mine);+ } else if (opts.rotate) {out(`rotating away from ${mine.slot}...`);writeSlotFlag(mine.slot, { reason: "manual rotate", at: nowEpoch() }, store);await teardownLease(mine);@@ -642,10 +666,15 @@ async function main(): Promise<number> {case "logs":return await cmdLogs();case "doctor":- return await runDoctor({ json: opts.json, fix: opts.fix, store, slack: withSlack });+ return await runDoctor({+ json: opts.json,+ fix: opts.fix,+ store,+ slack: requestedSurface === undefined ? myLease(repoRoot(), store)?.meta.slack === "1" : withSlack,+ });default:console.error(- "usage: dev [up|down|status|restart|canary|logs|doctor] [--json] [--force] [--rotate] [--strict] [--sandbox local|sprites|smolmachines|e2b|porter|agent37|auto] [--no-slack] [--no-watch] [--org id] [--fix]",+ "usage: dev [up|down|status|restart|canary|logs|doctor] [--json] [--force] [--rotate] [--strict] [--sandbox local|sprites|smolmachines|e2b|porter|agent37|auto] [--surface web|slack|both] [--no-slack] [--no-watch] [--org id] [--fix]",);return EXIT.usage;}diff --git a/scripts/dev/commands/doctor.ts b/scripts/dev/commands/doctor.tsindex 956d5d936..539a62081 100644--- a/scripts/dev/commands/doctor.ts+++ b/scripts/dev/commands/doctor.ts@@ -75,7 +75,7 @@ export async function runDoctor(opts: { json: boolean; fix: boolean; store: stri});if (reachable) {const status = (await supervisorRequest(sock, "GET", "/status", undefined, 8000)).body as StatusReport;- for (const name of CHILD_ORDER) {+ for (const name of status.webEnabled === false ? ["core"] : CHILD_ORDER) {const child = status.children[name];checks.push({id: `child:${name}`,diff --git a/scripts/dev/lib/deps.ts b/scripts/dev/lib/deps.tsindex e4bbe8ac1..e61469d3b 100644--- a/scripts/dev/lib/deps.ts+++ b/scripts/dev/lib/deps.ts@@ -14,10 +14,11 @@ async function npmInstall(dir: string, logLabel: string, log: (msg: string) => vexport async function ensureDeps(worktree: string,- opts: { watch: boolean; webUiBasePath: string },+ opts: { web?: boolean; watch: boolean; webUiBasePath: string },log: (msg: string) => void,): Promise<void> {if (!existsSync(join(worktree, "node_modules/emoji-datasource"))) await npmInstall(worktree, "core", log);+ if (opts.web === false) return;if (!existsSync(join(worktree, "plugins/web-ui/node_modules/vite")))await npmInstall(join(worktree, "plugins/web-ui"), "web-ui plugin", log);if (!opts.watch) {diff --git a/scripts/dev/lib/types.ts b/scripts/dev/lib/types.tsindex 7c5f167f1..354697832 100644--- a/scripts/dev/lib/types.ts+++ b/scripts/dev/lib/types.ts@@ -68,6 +68,7 @@ export interface BootPhaseEvent {export interface BootResult {ok: boolean;+ webEnabled?: boolean;slackEnabled?: boolean;reason?: string;slot: string;@@ -95,6 +96,7 @@ export interface StatusReport {sandbox: { backend: string; detail: string };durability: { sessionStore: string; runStore: string; databaseUrl: boolean };harness: string;+ webEnabled?: boolean;slackEnabled: boolean;watch: boolean;turnsLive: boolean;@@ -112,6 +114,7 @@ export interface BootSpec {canaryChannel?: string;strict: boolean;slack?: boolean;+ web?: boolean;}export interface LeaseInfo {diff --git a/scripts/dev/supervisor/main.ts b/scripts/dev/supervisor/main.tsindex 0ac399604..66c7eff1d 100644--- a/scripts/dev/supervisor/main.ts+++ b/scripts/dev/supervisor/main.ts@@ -276,6 +276,7 @@ function writeLegacyMeta(booting: boolean): void {run_store: durability.runStore,watch: watch ? "1" : "0",slack: slackOn(readBootSpec()) ? "1" : "0",+ web: readBootSpec().web === false ? "0" : "1",created_epoch: String(startedAt),created: new Date(startedAt * 1000).toISOString().replace("T", " ").slice(0, 19),};@@ -325,7 +326,11 @@ async function assembleAndPrepare(spec: BootSpec): Promise<SpecInputs> {phase("env", "ok", harnessDetail);phase("deps", "start");- await ensureDeps(worktree, { watch: spec.watch, webUiBasePath: spec.callerEnv.DEV_INSTANCE_WEB_UI_BASE || "/" }, log);+ await ensureDeps(+ worktree,+ { web: spec.web, watch: spec.watch, webUiBasePath: spec.callerEnv.DEV_INSTANCE_WEB_UI_BASE || "/" },+ log,+ );phase("deps", "ok");phase("sandbox", "start");@@ -403,6 +408,7 @@ async function assembleAndPrepare(spec: BootSpec): Promise<SpecInputs> {ports,baseEnv: assembled.env,watch: spec.watch,+ web: spec.web,webUiBasePath: spec.callerEnv.DEV_INSTANCE_WEB_UI_BASE || "/",...(tokens ? { slack: { botToken: tokens.botToken, appToken: tokens.appToken } } : {}),sessionStore,@@ -482,7 +488,14 @@ async function boot(): Promise<void> {phase("verify", "ok", "Slack off -- nothing to verify");}bootedAt = nowEpoch();- bootResult = { ok: true, slackEnabled: slackOn(spec), slot, handle, ...verified.result } as BootResult;+ bootResult = {+ ok: true,+ webEnabled: spec.web !== false,+ slackEnabled: slackOn(spec),+ slot,+ handle,+ ...verified.result,+ } as BootResult;writeLegacyMeta(false);persistState();finishBoot();@@ -687,7 +700,8 @@ async function reload(body: Record<string, unknown>): Promise<Record<string, unk});const dryEnvSha = computeEnvSha(assembled.env);const allHealthy =- children.size === CHILD_ORDER.length && [...children.values()].every((c) => c.state === "healthy");+ children.size === (spec.web === false ? 1 : CHILD_ORDER.length) &&+ [...children.values()].every((c) => c.state === "healthy");return {ok: true,noop: dryEnvSha === currentEnvSha && allHealthy,@@ -703,7 +717,7 @@ async function reload(body: Record<string, unknown>): Promise<Record<string, unkconst newGitSha = gitHead(worktree);const noopEligible =newEnvSha === currentEnvSha &&- children.size === CHILD_ORDER.length &&+ children.size === (spec.web === false ? 1 : CHILD_ORDER.length) &&[...children.values()].every((c) => c.state === "healthy");if (!force && noopEligible) {return {@@ -781,6 +795,7 @@ async function statusReport(): Promise<StatusReport> {},harness,slackEnabled,+ webEnabled: readBootSpec().web !== false,watch,turnsLive: harness !== "mock",publicApiUrl: sandbox?.publicApiUrl ?? null,diff --git a/scripts/dev/supervisor/specs.ts b/scripts/dev/supervisor/specs.tsindex d162937a7..d974f0ca7 100644--- a/scripts/dev/supervisor/specs.ts+++ b/scripts/dev/supervisor/specs.ts@@ -6,6 +6,7 @@ export interface SpecInputs {ports: SlotPorts;baseEnv: Record<string, string>;watch: boolean;+ web?: boolean;webUiBasePath: string;slack?: { botToken: string; appToken: string };sessionStore: string;@@ -27,7 +28,7 @@ export function buildChildSpecs(i: SpecInputs): ChildSpec[] {siblingBase.CODEX_AUTH_FILE = "";const orgId = i.baseEnv.DEV_INSTANCE_ORG_ID || "acme";const signing: Record<string, string> = i.coreSigningSecret ? { CORE_SIGNING_SECRET: i.coreSigningSecret } : {};- return [+ const specs: ChildSpec[] = [{name: "core",cwd: i.worktree,@@ -40,7 +41,7 @@ export function buildChildSpecs(i: SpecInputs): ChildSpec[] {PORT: String(i.ports.core),...(i.databaseUrl ? { DATABASE_URL: i.databaseUrl } : {}),...(i.adminGrantsSeed ? { ADMIN_GRANTS: i.adminGrantsSeed } : {}),- PUBLIC_WEB_URL: `http://localhost:${i.ports.portal}`,+ PUBLIC_WEB_URL: i.web === false ? "" : `http://localhost:${i.ports.portal}`,...(i.slack? {SLACK_BOT_TOKEN: i.slack.botToken,@@ -48,7 +49,8 @@ export function buildChildSpecs(i: SpecInputs): ChildSpec[] {DEV_INTROSPECTION: "1",DEV_HEALTH_PORT: String(i.ports.slackHealth),}- : {}),+ : { SLACK_BOT_TOKEN: "", SLACK_APP_TOKEN: "" }),+ DEV_INSTANCE_NO_SLACK: i.slack ? "0" : "1",CORE_ORG_ID: orgId,SHUTDOWN_DRAIN_MS: "2000",},@@ -101,4 +103,5 @@ export function buildChildSpecs(i: SpecInputs): ChildSpec[] {stopGraceMs: 5_000,},];+ return i.web === false ? specs.filter((spec) => spec.name === "core") : specs;}diff --git a/src/config.ts b/src/config.tsindex 858c42723..2aeade5dd 100644--- a/src/config.ts+++ b/src/config.ts@@ -1179,7 +1179,7 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): Config {throw new Error("SECURITY_SCREEN_TIMEOUT_MS must be a positive integer no greater than 2147483647");}const publicApiUrl = env.PUBLIC_API_URL ?? env.AGENT_API_URL;- const publicUrl = env.PUBLIC_WEB_URL ?? publicApiUrl;+ const publicUrl = env.PUBLIC_WEB_URL || publicApiUrl;const deployProvider = env.DEPLOY_PROVIDER ?? "docker";if (deployProvider !== "aws" &&diff --git a/src/slack/config.ts b/src/slack/config.tsindex 90b97bb44..a32e7b924 100644--- a/src/slack/config.ts+++ b/src/slack/config.ts@@ -61,6 +61,7 @@ export function slackPluginConfigFromEnv(env: Record<string, string | undefined>,receiverFactory?: SlackPluginConfig["receiverFactory"],): SlackPluginConfig | null {+ if (env.DEV_INSTANCE_NO_SLACK === "1") return null;const eventsMode = env.SLACK_EVENTS_MODE?.trim() === "http" ? "http" : "socket";if (!env.SLACK_BOT_TOKEN) return null;if (!receiverFactory && eventsMode === "socket" && !env.SLACK_APP_TOKEN) return null;@@ -113,6 +114,7 @@ export function normalizeSlackApiUrl(raw: string): string {}export function slackAccountConfigsFromEnv(env: Record<string, string | undefined>): SlackPluginConfig[] {+ if (env.DEV_INSTANCE_NO_SLACK === "1") return [];const raw = env.SLACK_ACCOUNTS?.trim();if (!raw) return [];let parsed: unknown;diff --git a/test/config.test.ts b/test/config.test.tsindex 7e88d6c40..198819b3a 100644--- a/test/config.test.ts+++ b/test/config.test.ts@@ -337,6 +337,11 @@ test("PUBLIC_API_URL is not treated as the human-facing web URL", () => {assert.equal(apiOnly.publicUrl, "https://agent-api.example");assert.equal(apiOnly.publicWebUrl, undefined);+ const disabledWeb = loadConfig({ PUBLIC_API_URL: "https://agent-api.example", PUBLIC_WEB_URL: "" });+ assert.equal(disabledWeb.apiBaseUrl, "https://agent-api.example");+ assert.equal(disabledWeb.publicUrl, "https://agent-api.example");+ assert.equal(disabledWeb.publicWebUrl, undefined);+const web = loadConfig({ PUBLIC_API_URL: "https://agent-api.example", PUBLIC_WEB_URL: "https://portal.example" });assert.equal(web.apiBaseUrl, "https://agent-api.example");assert.equal(web.publicUrl, "https://portal.example");diff --git a/test/dev-cli-lib.test.ts b/test/dev-cli-lib.test.tsindex edadc0770..530173333 100644--- a/test/dev-cli-lib.test.ts+++ b/test/dev-cli-lib.test.ts@@ -1,6 +1,8 @@import { test } from "node:test";import assert from "node:assert/strict";import { chmodSync, mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";+import { spawnSync } from "node:child_process";+import { ensureDeps } from "../scripts/dev/lib/deps.ts";import { tmpdir } from "node:os";import { join } from "node:path";import { envSha, errMessage, formatAge, readEnvFile } from "../scripts/dev/lib/util.ts";@@ -442,11 +444,11 @@ test("supervised children share the selected dev org", () => {assert.equal(buildChildSpecs(inputs).find((spec) => spec.name === "core")!.env.ORG_ID, "acme");});-test("child specs omit Slack env when no Slack tokens are supplied", () => {+test("child specs disable environment Slack tokens when no Slack tokens are supplied", () => {const inputs: SpecInputs = {worktree: "/tmp/worktree",ports: slotPorts("pool1"),- baseEnv: {},+ baseEnv: { SLACK_BOT_TOKEN: "inherited-bot", SLACK_APP_TOKEN: "inherited-app" },watch: false,webUiBasePath: "/",sessionStore: "memory",@@ -459,11 +461,27 @@ test("child specs omit Slack env when no Slack tokens are supplied", () => {sandboxEnv: {},};const core = buildChildSpecs(inputs).find((spec) => spec.name === "core")!;- assert.equal(core.env.SLACK_BOT_TOKEN, undefined);- assert.equal(core.env.SLACK_APP_TOKEN, undefined);+ assert.equal(core.env.DEV_INSTANCE_NO_SLACK, "1");+ assert.equal(core.env.SLACK_BOT_TOKEN, "");+ assert.equal(core.env.SLACK_APP_TOKEN, "");assert.equal(core.env.DEV_INTROSPECTION, undefined);assert.equal(core.env.DEV_HEALTH_PORT, undefined);assert.equal(core.env.CORE_ORG_ID, "acme");+ inputs.web = false;+ inputs.slack = { botToken: "xoxb-test", appToken: "xapp-test" };+ const slackOnly = buildChildSpecs(inputs);+ assert.deepEqual(+ slackOnly.map((spec) => spec.name),+ ["core"],+ );+ assert.equal(slackOnly[0]!.env.SLACK_BOT_TOKEN, "xoxb-test");+ assert.equal(slackOnly[0]!.env.DEV_INSTANCE_NO_SLACK, "0");+ assert.equal(slackOnly[0]!.env.PUBLIC_WEB_URL, "");+ inputs.web = true;+ assert.deepEqual(+ buildChildSpecs(inputs).map((spec) => spec.name),+ ["core", "web", "portal"],+ );});test("formatAge renders the bash-compatible shapes", () => {@@ -478,3 +496,28 @@ test("dev errors preserve messages without calling custom object stringifiers",assert.equal(errMessage(unsafe), "Unknown error");assert.equal(errMessage({ ...unsafe, message: "actionable failure" }), "actionable failure");});++test("Slack-only dependency preparation needs no web installation or build", async () => {+ const worktree = mkdtempSync(join(tmpdir(), "qm-dev-deps-"));+ try {+ mkdirSync(join(worktree, "node_modules/emoji-datasource"), { recursive: true });+ await ensureDeps(worktree, { web: false, watch: false, webUiBasePath: "/" }, () => {+ assert.fail("Slack-only startup must not install or build web dependencies");+ });+ } finally {+ rmSync(worktree, { recursive: true, force: true });+ }+});++test("dev CLI rejects invalid or conflicting surface selection before startup", () => {+ for (const args of [+ ["up", "--surface", "invalid"],+ ["up", "--surface", "slack", "--no-slack"],+ ["up", "--surface", "both", "--no-slack"],+ ["status", "--surface", "web"],+ ]) {+ const result = spawnSync(process.execPath, ["scripts/dev/cli.ts", ...args], { encoding: "utf8" });+ assert.equal(result.status, 2, result.stderr);+ assert.match(result.stderr, /surface/);+ }+});diff --git a/test/slack-allow-from.test.ts b/test/slack-allow-from.test.tsindex 185dd9b92..78fb917a9 100644--- a/test/slack-allow-from.test.ts+++ b/test/slack-allow-from.test.ts@@ -1,7 +1,7 @@import assert from "node:assert/strict";import { test } from "node:test";import { createActorGate, createDenyResponder, normalizeAllowFrom, parseAllowFrom } from "../src/slack/allow-from.ts";-import { slackAccountConfigsFromEnv } from "../src/slack/config.ts";+import { slackAccountConfigsFromEnv, slackPluginConfigFromEnv } from "../src/slack/config.ts";test("parseAllowFrom splits, lowercases, strips @-prefixes, and dedupes", () => {assert.deepEqual(parseAllowFrom("[email protected], @example.org example.org\[email protected]"), [@@ -104,3 +104,22 @@ test("createDenyResponder throttles repeats per key but not across keys", () =>assert.equal(r.shouldSend("C1:U3"), true);assert.equal(r.shouldSend("D9:U2"), true);});++test("web-only dev instances disable Slack from environment, stored installations, and extra accounts", () => {+ const env = {+ DEV_INSTANCE_NO_SLACK: "1",+ SLACK_BOT_TOKEN: "xoxb-stored",+ SLACK_APP_TOKEN: "xapp-stored",+ SLACK_ACCOUNTS: JSON.stringify([{ id: "extra", botToken: "xoxb-extra", appToken: "xapp-extra" }]),+ };+ assert.equal(slackPluginConfigFromEnv(env), null);+ assert.equal(+ slackPluginConfigFromEnv(env, () => {+ throw new Error("disabled receiver must not start");+ }),+ null,+ );+ assert.deepEqual(slackAccountConfigsFromEnv(env), []);+ assert.ok(slackPluginConfigFromEnv({ ...env, DEV_INSTANCE_NO_SLACK: "0" }));+ assert.equal(slackAccountConfigsFromEnv({ ...env, DEV_INSTANCE_NO_SLACK: "0" }).length, 1);+});