@terreno/api-health 57.20.0 → 57.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -20,6 +20,56 @@ Upgrade notes for consumer action live in [`mcp-server/src/docs/upgrades/`](mcp-
20
20
 
21
21
  Unreleased changes live in [`changelog/unreleased/`](changelog/unreleased/). Add one Markdown file per feature (see that directory's README) instead of editing this section.
22
22
 
23
+ ## [57.21.0] - 2026-11-01
24
+
25
+ Upgrade note: [`mcp-server/src/docs/upgrades/57.21.0.md`](mcp-server/src/docs/upgrades/57.21.0.md).
26
+
27
+ ### Breaking
28
+
29
+ - The `terreno-scan` plugin is now `terreno-loop`, and its skills are renamed from `terreno-scan-*` to `terreno-loop-*`. The resident loop `terreno-scan-loop` is now `terreno-loop-run`: `/terreno-loop:run` in Claude Code, `/terreno-loop-run` in Cursor, `$terreno-loop-run` in Codex. Claude Code moves existing installs over through the marketplace `renames` entry. In Cursor and Codex, uninstall `terreno-scan` and install `terreno-loop`. Campaign state stays at `.terreno/scan/<goal>.json`, so campaigns already in progress resume.
30
+
31
+ ### Added
32
+
33
+ - `@terreno/admin-spa` serves an MCP OAuth consent screen at `/console/oauth/consent`, so a backend with no product frontend can set `mcpOAuth.consentUrl` to `${issuer}/console/oauth/consent`. Any signed-in user can approve or deny a request with their Better Auth session; signed-out users sign in and return through the login screen's new `returnTo` parameter, which accepts only in-app paths.
34
+ - Claude Code plugins now publish to npm with every release, as `@terreno/agent-plugin` and `@terreno/agent-plugin-loop`. A new `terreno-releases` marketplace installs them at the latest stable release. To pin one release, add `TerrenoLabs/terreno#<version>` instead. See [Install agent skills](docs/how-to/install-agent-skills.md#pick-a-channel).
35
+ - The generated Claude plugin manifest no longer pins `version`. Before this change, plugins installed from the `TerrenoLabs/terreno` marketplace stayed on the `2.12.0` copy, because their version never changed. They now update on every commit. Run `/plugin update terreno@terreno-plugins` once to leave `2.12.0`.
36
+ - The `terreno-planning` lifecycle plugin (2.13.0) plans e2e tests and manual regression cases in every IP:
37
+
38
+ - Grow requires `## E2E tests` and `## Regression cases` sections (either may be `None — <reason>`), read from the e2e guide at `docs/testing/e2e.md` or a `## Testing conventions` override in AGENTS.md or CLAUDE.md.
39
+ - Regression cases stay minimal: most features add none. A case is only for what a developer or QA must check by hand, such as push notifications, and Roast fails one that repeats an existing case.
40
+ - Pick writes each planned spec in the task that delivers it, and Roast runs it; a missing or failing row is `FAIL`.
41
+ - Brew gates on every planned spec and merges regression cases into `docs/regression/<area>.md` with the next free ID.
42
+ - Taste re-checks both sections after behaviour-changing fixes and renumbers regression ID collisions with `master`.
43
+ - `bun run check:lifecycle-skills` enforces these phrases in every stage.
44
+ - New `backfill-regression` skill proposes manual regression cases one area at a time and writes only the sets the human approves.
45
+ - A consumer opts out of manual regression suites with `Regression suites | none` in its `## Testing conventions` table.
46
+ - The `terreno-planning` lifecycle plugin (2.14.0) grows an end-user guide with every feature:
47
+
48
+ - Every IP has a `## User guide` section listing the guide pages it adds, updates, or retires, or `None — <reason>`. Pages live in `docs/user-guide/<area>/<feature>.md`, one feature per page, with `title`, `audience`, `platforms`, and `questions` frontmatter that chat agents use to answer "how do I…" questions.
49
+ - Pick writes each page in the task that ships the feature, Roast checks it against the shipped screens, Brew gates on it and the index, and Taste keeps it current after fixes.
50
+ - A repo opts out with `| User guide | none — <reason> |` in a `## User guide conventions` table in AGENTS.md or CLAUDE.md.
51
+ - New `backfill-user-guide` skill drafts pages for features that shipped without one, one area at a time, and writes only the pages the human approves.
52
+ - `bun run check:user-guide` validates the pages and index (CI `repo-policies`); `--uncovered <app dir>` lists screens no page names.
53
+ - Terreno's own guide covers the example app's main features.
54
+ - `@terreno/api`: opt-in `mcpRequestLog` on `TerrenoApp` records one metadata-only `McpRequestLog` row per MCP tool call (tool, user, credential, service token or OAuth client, duration, outcome, error class; never arguments, results, or error text), expiring after `retentionDays` (default 30).
55
+ - `@terreno/api`: opt-in `mcpToolSettings` on `TerrenoApp` registers every MCP tool in `McpToolSetting` at startup; tools an admin switches off are hidden from `tools/list` and rejected by `tools/call`.
56
+ - `@terreno/api`: deleting an `McpOAuthToken` row revokes its whole connection (token family) and keeps the rows. New `McpOAuthToken.revokeAllForUser` and `McpServiceToken.revokeAllForUser`.
57
+ - `@terreno/admin-backend`: `mcpAdminModels()` adds MCP admin screens (service tokens, OAuth clients, OAuth connections, request log, tool switches), `mcpAdminStatements` for RBAC, and `mcpAdminScripts()` adds `mcp-sign-out-everywhere`. See [Manage MCP from the admin panel](docs/how-to/manage-mcp-in-admin.md).
58
+ - Docs: [Expose an MCP server safely](docs/how-to/expose-mcp-server-safely.md) (OAuth, service tokens, Cloudflare Tunnel, Access) and the `bootstrap-mcp-server` skill for a single-binary MCP server with the admin console embedded.
59
+ - Every workspace package has a real-process smoke test and an e2e page:
60
+
61
+ - Each package's `e2e/smoke.ts` (or `smoke.spec.ts` for browser packages) runs its built output through its public entry: a server on a real port, the compiled binary, or a page in Chromium. `bun run --cwd <package> smoke` runs one; `bun run smoke` runs them all and prints each package's time. The CircleCI `smoke` job runs them on every package change.
62
+ - `@terreno/test` adds the smoke helpers `smokeMongoUri()`, `spawnUntilReady()`, `spawnExampleBackend()`, `runBin()`, and `freePort()`.
63
+ - The [E2E testing guide](docs/testing/e2e.md) explains the test tiers and links one page per package under `docs/testing/e2e/`.
64
+ - Manual regression cases live in `docs/regression/<area>.md`, one file per area, and `bun run check:regression-suites` validates them.
65
+ - example-frontend's smoke serves a web export that `bun run --cwd example-frontend export:smoke` builds once with a placeholder API URL; the smoke swaps in a `freePort()` API URL as it serves the bundle, so the 30 s smoke no longer rebuilds the export. `spawnUntilReady()` takes `stopGraceMs`, and `spawnExampleBackend()` stops example-backend after 0.5 s instead of 5 s.
66
+ - Every workspace package has a `typecheck` script that runs `tsc` over source and test files through a new `tsconfig.typecheck.json`. Root `bun run lint` ends with `bun run typecheck`, and CircleCI runs it in a new `typecheck` job. Test files that had type errors were fixed.
67
+
68
+ ### Changed
69
+
70
+ - `@terreno/api`: deleting an `McpOAuthToken` row with document or query `deleteOne` now revokes that row's whole token family (the connection) and keeps the rows instead of removing one pair. `deleteMany` is unchanged.
71
+ - `@terreno/ui`: new `theme.field` tokens (`background`, `backgroundDisabled`, `border`, `borderFocus`, `borderError`, `borderDisabled`) style form inputs. `TextField`, `SelectField`, `DateTimeField`, `HeightField`, and `OtpField` read them instead of `surface.base` and `border.dark`. Defaults equal the old colors, but overriding `surface` or `border` no longer recolors those fields; use `setTheme({field: ...})`.
72
+
23
73
  ## [57.20.0] - 2026-10-30
24
74
 
25
75
  Upgrade note: [`mcp-server/src/docs/upgrades/57.20.0.md`](mcp-server/src/docs/upgrades/57.20.0.md).
package/biome.jsonc CHANGED
@@ -7,6 +7,7 @@
7
7
  "package.json",
8
8
  "src/**/*.ts",
9
9
  "src/**/*.tsx",
10
+ "e2e/**/*.ts",
10
11
  "!!**/node_modules",
11
12
  "!!node_modules",
12
13
  "!!**/dist",
package/e2e/smoke.ts ADDED
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Real-process smoke for @terreno/api-health. Run `bun e2e/smoke.ts` after `bun run compile`.
3
+ *
4
+ * The smoke re-runs this file with `serve` as a child process: an Express server on a free port
5
+ * that registers the compiled `HealthApp` plugin twice, with defaults and with a check that reports
6
+ * a dependency down. The parent then checks over real HTTP that the default route is healthy and
7
+ * that a failing check answers 503, the status load balancers and probes act on. Exits non-zero
8
+ * on the first failed check.
9
+ */
10
+ import {freePort, type SpawnedProcess, spawnUntilReady} from "@terreno/test";
11
+
12
+ const SERVE_ARG = "serve";
13
+ const DOWN_DETAIL = "smoke-down";
14
+
15
+ interface HealthBody {
16
+ healthy: boolean;
17
+ details?: {dependency?: string};
18
+ }
19
+
20
+ /**
21
+ * Child: a plain Express server with the compiled plugin registered, the way `TerrenoApp`
22
+ * registers it. The plugin is imported here, not at the top, so the parent never loads it.
23
+ */
24
+ const serve = async (): Promise<void> => {
25
+ const {HealthApp} = await import("@terreno/api-health");
26
+ const {default: express} = await import("express");
27
+
28
+ const app = express();
29
+ new HealthApp().register(app);
30
+ new HealthApp({
31
+ check: () => ({details: {dependency: DOWN_DETAIL}, healthy: false}),
32
+ path: "/health/down",
33
+ }).register(app);
34
+
35
+ app.listen(Number(process.env.PORT), "127.0.0.1", () => {
36
+ console.info(`[apiHealthSmoke] serving on port ${process.env.PORT}`);
37
+ });
38
+ };
39
+
40
+ const expectHealth = async ({
41
+ baseUrl,
42
+ path,
43
+ status,
44
+ healthy,
45
+ dependency,
46
+ }: {
47
+ baseUrl: string;
48
+ path: string;
49
+ status: number;
50
+ healthy: boolean;
51
+ dependency?: string;
52
+ }): Promise<void> => {
53
+ const res = await fetch(`${baseUrl}${path}`);
54
+ const text = await res.text();
55
+ if (res.status !== status) {
56
+ throw new Error(`GET ${path}: expected ${status}, got ${res.status}: ${text}`);
57
+ }
58
+ const body = JSON.parse(text) as HealthBody;
59
+ if (body.healthy !== healthy) {
60
+ throw new Error(`GET ${path}: expected healthy ${healthy}, got ${text}`);
61
+ }
62
+ if (body.details?.dependency !== dependency) {
63
+ throw new Error(`GET ${path}: expected details.dependency ${dependency}, got ${text}`);
64
+ }
65
+ };
66
+
67
+ /** Parent: boots the child and checks both health routes over HTTP. */
68
+ const run = async (): Promise<void> => {
69
+ const startedAt = performance.now();
70
+ const port = await freePort();
71
+ const baseUrl = `http://127.0.0.1:${port}`;
72
+ let server: SpawnedProcess | undefined;
73
+
74
+ try {
75
+ server = await spawnUntilReady({
76
+ cmd: [process.execPath, __filename, SERVE_ARG],
77
+ env: {PORT: String(port)},
78
+ timeoutMs: 20000,
79
+ url: `${baseUrl}/health`,
80
+ });
81
+
82
+ await expectHealth({baseUrl, healthy: true, path: "/health", status: 200});
83
+ console.info("✅ GET /health is healthy with the default plugin");
84
+
85
+ await expectHealth({
86
+ baseUrl,
87
+ dependency: DOWN_DETAIL,
88
+ healthy: false,
89
+ path: "/health/down",
90
+ status: 503,
91
+ });
92
+ console.info("✅ GET /health/down answers 503 when its check fails");
93
+ } catch (error: unknown) {
94
+ if (server) {
95
+ console.error(`--- server output ---\n${server.output()}`);
96
+ }
97
+ throw error;
98
+ } finally {
99
+ await server?.stop();
100
+ }
101
+
102
+ console.info(`api-health smoke passed in ${Math.round(performance.now() - startedAt)} ms`);
103
+ };
104
+
105
+ const main = process.argv[2] === SERVE_ARG ? serve : run;
106
+ main().then(
107
+ () => {
108
+ if (main === run) {
109
+ process.exit(0);
110
+ }
111
+ },
112
+ (error: unknown) => {
113
+ console.error(`❌ ${error instanceof Error ? error.message : String(error)}`);
114
+ process.exit(1);
115
+ }
116
+ );
package/package.json CHANGED
@@ -4,12 +4,13 @@
4
4
  "url": "https://github.com/TerrenoLabs/terreno/issues"
5
5
  },
6
6
  "dependencies": {
7
- "@terreno/api": "57.20.0",
7
+ "@terreno/api": "57.21.0",
8
8
  "express": "^5.2.1"
9
9
  },
10
10
  "description": "Health check plugin for @terreno/api — part of Terreno, the batteries-included TypeScript framework for universal apps.",
11
11
  "devDependencies": {
12
12
  "@biomejs/biome": "^2.3.6",
13
+ "@terreno/test": "57.21.0",
13
14
  "@types/bun": "^1.4.0",
14
15
  "@types/express": "^5.0.6",
15
16
  "@types/supertest": "^7.2.0",
@@ -37,13 +38,15 @@
37
38
  "compile": "bun tsc",
38
39
  "compile:watch": "bun tsc -w",
39
40
  "dev": "bun tsc -w",
40
- "lint": "biome check ./src",
41
- "lint:fix": "biome check --write ./src",
41
+ "lint": "biome check ./src ./e2e",
42
+ "lint:fix": "biome check --write ./src ./e2e",
43
+ "smoke": "bun e2e/smoke.ts",
42
44
  "test": "bun test src/",
43
45
  "test:agent": "AGENT=1 bun test --only-failures src/",
44
46
  "test:ci": "bun test src/",
45
- "test:coverage": "bun run ../scripts/check-coverage.ts"
47
+ "test:coverage": "bun run ../scripts/check-coverage.ts",
48
+ "typecheck": "tsc -p tsconfig.typecheck.json"
46
49
  },
47
50
  "types": "dist/index.d.ts",
48
- "version": "57.20.0"
51
+ "version": "57.21.0"
49
52
  }
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "composite": false,
6
+ "incremental": false,
7
+ "declaration": false,
8
+ "declarationMap": false,
9
+ "types": [
10
+ "node",
11
+ "bun"
12
+ ]
13
+ },
14
+ "exclude": [
15
+ "node_modules",
16
+ "dist"
17
+ ]
18
+ }