@adhd/apigen-plugin-health 0.1.1 โ†’ 0.1.3

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 ADDED
@@ -0,0 +1,24 @@
1
+ ## 0.1.3 (2026-07-23)
2
+
3
+
4
+ ### ๐Ÿš€ Features
5
+
6
+ - session batch โ€” dispatch tool-exec + provider routing, publish hygiene, agent/env/apigen fixes
7
+
8
+ - **release:** nx release independent versioning + verify-dist-load publish gate (Agent 2)
9
+
10
+
11
+ ### ๐Ÿฉน Fixes
12
+
13
+ - resolve build errors from workspace-cleanup merge โ€” unterminated strings, path mappings, lint
14
+
15
+ - **apigen:** update remaining stale @adhd/apigen-errors, core, logical refs
16
+
17
+ - **environment:** correct agent-mcp plugins at: classification (build->runtime)
18
+
19
+ - **apigen:** externalize real npm deps in vite builds โ€” 10 packages shipped broken dist bundles (__filename/timeOrigin crash)
20
+
21
+
22
+ ### โค๏ธ Thank You
23
+
24
+ - pseudosky
package/README.md CHANGED
@@ -1,13 +1,123 @@
1
1
  # @adhd/apigen-plugin-health
2
2
 
3
- apigen **mount plugin** โ€” adds a health endpoint to a generated server. Activate with `--use`.
3
+ **Mount plugin** โ€” adds a `GET /_meta/health` endpoint to any apigen server. Reports runtime readiness for load balancers, orchestrators, and the apigen gateway (ยง13).
4
4
 
5
- Part of [apigen](../../README.md). Driven via [`@adhd/apigen-cli`](../../cli).
5
+ Part of [apigen](../README.md). Driven via [`@adhd/apigen-cli`](../../../entrypoint/apigen-cli/README.md).
6
+
7
+ ---
8
+
9
+ ## What it adds
10
+
11
+ When loaded via `--use`, the health plugin contributes a synthetic `_meta/health` operation that returns:
12
+
13
+ ```json
14
+ GET /_meta/health
15
+ โ†’ {"status":"ok","host":"ts"}
16
+ ```
17
+
18
+ The gateway (ยง13.1) routes a host's operations only after this endpoint reports `ready`. For an in-process runtime (non-gateway), it always reports `ok` โ€” if the handler can respond, the runtime is alive.
19
+
20
+ ---
21
+
22
+ ## CLI usage
23
+
24
+ ```bash
25
+ # Fastify with health check
26
+ npx @adhd/apigen-cli run --source api.ts --type api-fastify --opt port=3000 --use health
27
+
28
+ # MCP with health check (SSE transport)
29
+ npx @adhd/apigen-cli run --source api.ts --type mcp --opt transport=sse --opt port=3000 --use health
30
+
31
+ # With custom metadata in the response
32
+ npx @adhd/apigen-cli run --source api.ts --type api-fastify --use health \
33
+ --opt 'useOptions={"health":{"meta":{"version":"1.0","region":"us-east"}}}'
34
+ ```
35
+
36
+ After startup:
6
37
 
7
38
  ```bash
8
- npx @adhd/apigen-cli run --source ./api.ts --type api-fastify --use @adhd/apigen-plugin-health
39
+ curl http://localhost:3000/_meta/health
40
+ # โ†’ {"status":"ok","host":"ts","meta":{"version":"1.0","region":"us-east"}}
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Programmatic usage
46
+
47
+ ```ts
48
+ import { extract, composeSchemas } from '@adhd/apigen-core-client';
49
+ import { apiFastifyPlugin } from '@adhd/apigen-plugin-api-fastify';
50
+ import { healthPlugin } from '@adhd/apigen-plugin-health';
51
+
52
+ const ops = await extract({ sourceFile: './api.ts', namespace: 'api' });
53
+ const schemas = composeSchemas(
54
+ {
55
+ metadata: { namespace: 'api', phase: '' },
56
+ schemas: Object.fromEntries(
57
+ ops.filter(o => o.kind === 'action').map(op => [
58
+ op.path[op.path.length - 1].raw,
59
+ { input: op.input, output: op.output, hasCtx: op.hasCtx, 'x-apigen-safe': op.safe },
60
+ ])
61
+ ),
62
+ },
63
+ []
64
+ );
65
+ const mod = await import('./api.ts');
66
+
67
+ const abort = new AbortController();
68
+ process.on('SIGINT', () => abort.abort());
69
+
70
+ await apiFastifyPlugin.run({
71
+ packages: [{ id: 'api', schemas, importPath: './api.ts', fns: mod, createClient: async () => ({}) }],
72
+ outputDir: '',
73
+ options: {
74
+ port: 3000,
75
+ host: '0.0.0.0',
76
+ usePlugins: [
77
+ healthPlugin, // โ† mounts GET /_meta/health
78
+ ],
79
+ // With custom metadata:
80
+ // useOptions: { health: { meta: { version: '1.0', region: 'us-east' } } },
81
+ },
82
+ signal: abort.signal,
83
+ operations: ops,
84
+ });
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Options
90
+
91
+ ```ts
92
+ import { type HealthOptions } from '@adhd/apigen-plugin-health';
9
93
  ```
10
94
 
95
+ | Option | Type | Default | Description |
96
+ |--------|------|---------|-------------|
97
+ | `meta` | `Record<string, string \| number \| boolean \| null>` | `undefined` | Extra metadata included in every health response payload |
98
+
99
+ ---
100
+
101
+ ## Response shape
102
+
103
+ ```ts
104
+ interface HealthResponse {
105
+ status: 'ok';
106
+ host: string; // language runtime tag (e.g. 'ts')
107
+ meta?: Record<string, string | number | boolean | null>;
108
+ }
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Exports
114
+
115
+ | Export | Kind |
116
+ |--------|------|
117
+ | `healthPlugin` | v2 `Plugin<HealthOptions>` โ€” mount capability only |
118
+ | `HealthOptions` | TypeScript interface |
119
+ | `HealthResponse` | TypeScript interface |
120
+
11
121
  ```ts
12
- import { healthPlugin, type HealthOptions } from '@adhd/apigen-plugin-health'
122
+ import { healthPlugin, type HealthOptions, type HealthResponse } from '@adhd/apigen-plugin-health';
13
123
  ```
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function s(e){return{raw:e,words:[e]}}function n(e,t={}){return[{id:"_meta/health",host:e.host,namespace:s("meta"),path:[s("health")],kind:"query",async:!1,streaming:!1,safe:!0,input:{},output:{type:"object",required:["status","host"],properties:{status:{const:"ok"},host:{type:"string"},meta:{type:"object"}}},envelope:{},typeText:null,transports:["http","grpc"],handler:i=>{const a={status:"ok",host:e.host};return t.meta!==void 0&&Object.keys(t.meta).length>0&&(a.meta=t.meta),a}}]}const o={id:"health",description:"Mount plugin: exposes GET /meta/health for gateway readiness (SPEC ยง13.1)",optionsSchema:{type:"object",properties:{meta:{type:"object",description:"Extra metadata included in the health response"}},additionalProperties:!1},capabilities:{mount:{operations(e,t){return n(e,t)}}}};exports.default=o;exports.healthPlugin=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function s(e){return{raw:e,words:[e]}}function o(e,t={}){return[{id:"_meta/health",host:e.host,namespace:s("meta"),path:[s("health")],kind:"query",async:!1,streaming:!1,safe:!0,input:{},output:{type:"object",required:["status","host"],properties:{status:{const:"ok"},host:{type:"string"},meta:{type:"object"}}},envelope:{},typeText:null,transports:["http","grpc"],handler:i=>{const a={status:"ok",host:e.host};return t.meta!==void 0&&Object.keys(t.meta).length>0&&(a.meta=t.meta),a}}]}const n={id:"health",description:"Mount plugin: exposes GET /meta/health for gateway readiness (SPEC ยง13.1)",language:"ts",optionsSchema:{type:"object",properties:{meta:{type:"object",description:"Extra metadata included in the health response"}},additionalProperties:!1},capabilities:{mount:{operations(e,t){return o(e,t)}}}};exports.default=n;exports.healthPlugin=n;
package/index.mjs CHANGED
@@ -45,17 +45,24 @@ function n(t, e = {}) {
45
45
  const r = {
46
46
  id: "health",
47
47
  description: "Mount plugin: exposes GET /meta/health for gateway readiness (SPEC ยง13.1)",
48
+ language: "ts",
48
49
  optionsSchema: {
49
50
  type: "object",
50
51
  properties: {
51
- meta: { type: "object", description: "Extra metadata included in the health response" }
52
+ meta: {
53
+ type: "object",
54
+ description: "Extra metadata included in the health response"
55
+ }
52
56
  },
53
57
  additionalProperties: !1
54
58
  },
55
59
  capabilities: {
56
60
  mount: {
57
61
  operations(t, e) {
58
- return n(t, e);
62
+ return n(
63
+ t,
64
+ e
65
+ );
59
66
  }
60
67
  }
61
68
  }
package/lib/plugin.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from '@adhd/apigen-core';
1
+ import { Plugin } from '@adhd/apigen-core-client';
2
2
 
3
3
  /** Options accepted by the health mount plugin. */
4
4
  export interface HealthOptions {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@adhd/apigen-plugin-health",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "main": "./index.js",
5
5
  "dependencies": {
6
- "@adhd/apigen-core": "^0.1.0"
6
+ "@adhd/apigen-core-client": "^0.1.1"
7
7
  },
8
8
  "publishConfig": {
9
9
  "access": "public"