argsbarg 6.1.5 → 6.1.6
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 +8 -3
- package/docs/http-server.md +3 -3
- package/examples/full-example/docs/cli-schema.json +9 -9
- package/examples/full-example/docs/cli.md +9 -9
- package/examples/full-example/docs/http.md +3 -3
- package/examples/full-example/docs/openapi.json +6 -35
- package/package.json +1 -1
- package/src/builtins/http.ts +1 -1
- package/src/docs/http-guide.ts +3 -3
- package/src/http/openapi.ts +20 -12
- package/src/http/server.ts +1 -1
- package/src/test/integration/http.test.ts +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,20 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.1.6] - 2026-07-24
|
|
11
|
+
|
|
12
|
+
|
|
10
13
|
## [6.1.5] - 2026-07-24
|
|
11
14
|
|
|
12
15
|
### Changed
|
|
13
16
|
|
|
14
17
|
- **`httpServer.pathPrefix`** — configurable URL prefix for user routes (default `""`; routes at server root, e.g. `/workspaces`). Set `"/api"` for prefixed paths.
|
|
18
|
+
- **Health probes** — removed `GET /health` liveness alias; use `GET /health/liveness`. OpenAPI descriptions clarify liveness (online) vs readiness (online + checks passed).
|
|
15
19
|
|
|
16
20
|
## [6.1.4] - 2026-07-24
|
|
17
21
|
|
|
18
22
|
### Changed
|
|
19
23
|
|
|
20
24
|
- **`GET /swagger`** — Swagger UI API reference (replaces `GET /openapi-browser` and Scalar).
|
|
21
|
-
- **`GET /openapi.json`** — documents `/health
|
|
25
|
+
- **`GET /openapi.json`** — documents `/health/liveness` and `/health/readiness` probe endpoints under a **Health** tag.
|
|
22
26
|
- **OpenAPI tags** — user `/api/*` routes are grouped by top-level command key (router `description` becomes the tag description).
|
|
23
|
-
- **Health probe paths** — `GET /health/liveness` and `GET /health/readiness` replace `/health/live` and `/health/ready
|
|
27
|
+
- **Health probe paths** — `GET /health/liveness` and `GET /health/readiness` replace `/health/live` and `/health/ready`.
|
|
24
28
|
- **`httpServer.pathPrefix`** — configurable URL prefix for user routes (default `""`; routes at server root, e.g. `/workspaces`). Set `"/api"` for prefixed paths.
|
|
25
29
|
|
|
26
30
|
## [6.1.3] - 2026-07-24
|
|
@@ -849,7 +853,8 @@ const cli = { ... } satisfies CliProgram; // or : CliProgram
|
|
|
849
853
|
- Migrate schemas: rename every `children` property to **`commands`**; move positional definitions to **`CliPositional`** objects on `positionals` and strip `positional` / `argMin` / `argMax` from flag definitions under `options` (flags only carry `name`, `description`, `kind`, and optional `shortName`).
|
|
850
854
|
- Imports: use `CliPositional` where needed; replace `CliOptionDef` with `CliOption` or `CliPositional` as appropriate.
|
|
851
855
|
|
|
852
|
-
[Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v6.1.
|
|
856
|
+
[Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v6.1.6...HEAD
|
|
857
|
+
[6.1.6]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.6
|
|
853
858
|
[6.1.5]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.5
|
|
854
859
|
[6.1.4]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.4
|
|
855
860
|
[6.1.3]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.3
|
package/docs/http-server.md
CHANGED
|
@@ -76,8 +76,8 @@ Per-surface exposure: `http.enabled: false` removes a leaf from the route table;
|
|
|
76
76
|
|
|
77
77
|
| Method | Path | Purpose |
|
|
78
78
|
| --- | --- | --- |
|
|
79
|
-
| `GET` | `/health
|
|
80
|
-
| `GET` | `/health/readiness` | Readiness — config
|
|
79
|
+
| `GET` | `/health/liveness` | Liveness — server is online and accepting requests |
|
|
80
|
+
| `GET` | `/health/readiness` | Readiness — online plus config and optional `program.readiness` checks passed |
|
|
81
81
|
| `GET` | `/openapi.json` | OpenAPI 3.1 REST paths (includes `/health/*` and user routes) |
|
|
82
82
|
| `GET` | `/swagger` | Interactive Swagger UI API reference (CDN) |
|
|
83
83
|
| `*` | `/{command}/...` | Invoke user commands (method per route; optional `pathPrefix`) |
|
|
@@ -88,7 +88,7 @@ Per-surface exposure: `http.enabled: false` removes a leaf from the route table;
|
|
|
88
88
|
## Examples
|
|
89
89
|
|
|
90
90
|
```bash
|
|
91
|
-
curl -s http://127.0.0.1:3000/health
|
|
91
|
+
curl -s http://127.0.0.1:3000/health/liveness
|
|
92
92
|
curl -s http://127.0.0.1:3000/health/readiness
|
|
93
93
|
curl -s http://127.0.0.1:3000/openapi.json
|
|
94
94
|
open http://127.0.0.1:3000/swagger
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
{
|
|
192
192
|
"key": "http",
|
|
193
193
|
"description": "HTTP API server for tools.",
|
|
194
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
194
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
195
195
|
"options": [
|
|
196
196
|
{
|
|
197
197
|
"name": "host",
|
|
@@ -424,7 +424,7 @@
|
|
|
424
424
|
{
|
|
425
425
|
"key": "http",
|
|
426
426
|
"description": "HTTP API server for tools.",
|
|
427
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
427
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
428
428
|
"options": [
|
|
429
429
|
{
|
|
430
430
|
"name": "host",
|
|
@@ -679,7 +679,7 @@
|
|
|
679
679
|
{
|
|
680
680
|
"key": "http",
|
|
681
681
|
"description": "HTTP API server for tools.",
|
|
682
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
682
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
683
683
|
"options": [
|
|
684
684
|
{
|
|
685
685
|
"name": "host",
|
|
@@ -916,7 +916,7 @@
|
|
|
916
916
|
{
|
|
917
917
|
"key": "http",
|
|
918
918
|
"description": "HTTP API server for tools.",
|
|
919
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
919
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
920
920
|
"options": [
|
|
921
921
|
{
|
|
922
922
|
"name": "host",
|
|
@@ -1149,7 +1149,7 @@
|
|
|
1149
1149
|
{
|
|
1150
1150
|
"key": "http",
|
|
1151
1151
|
"description": "HTTP API server for tools.",
|
|
1152
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
1152
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
1153
1153
|
"options": [
|
|
1154
1154
|
{
|
|
1155
1155
|
"name": "host",
|
|
@@ -1386,7 +1386,7 @@
|
|
|
1386
1386
|
{
|
|
1387
1387
|
"key": "http",
|
|
1388
1388
|
"description": "HTTP API server for tools.",
|
|
1389
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
1389
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
1390
1390
|
"options": [
|
|
1391
1391
|
{
|
|
1392
1392
|
"name": "host",
|
|
@@ -1619,7 +1619,7 @@
|
|
|
1619
1619
|
{
|
|
1620
1620
|
"key": "http",
|
|
1621
1621
|
"description": "HTTP API server for tools.",
|
|
1622
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
1622
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
1623
1623
|
"options": [
|
|
1624
1624
|
{
|
|
1625
1625
|
"name": "host",
|
|
@@ -1852,7 +1852,7 @@
|
|
|
1852
1852
|
{
|
|
1853
1853
|
"key": "http",
|
|
1854
1854
|
"description": "HTTP API server for tools.",
|
|
1855
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
1855
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
1856
1856
|
"options": [
|
|
1857
1857
|
{
|
|
1858
1858
|
"name": "host",
|
|
@@ -2085,7 +2085,7 @@
|
|
|
2085
2085
|
{
|
|
2086
2086
|
"key": "http",
|
|
2087
2087
|
"description": "HTTP API server for tools.",
|
|
2088
|
-
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
2088
|
+
"notes": "HTTP tool server on http://127.0.0.1:3000.\n\nEndpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*\n\nConfigure app settings:\n\n full-example configure\n\nFull setup guide: full-example docs http",
|
|
2089
2089
|
"options": [
|
|
2090
2090
|
{
|
|
2091
2091
|
"name": "host",
|
|
@@ -213,7 +213,7 @@ HTTP API server for tools.
|
|
|
213
213
|
|
|
214
214
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
215
215
|
>
|
|
216
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
216
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
217
217
|
>
|
|
218
218
|
> Configure app settings:
|
|
219
219
|
>
|
|
@@ -426,7 +426,7 @@ HTTP API server for tools.
|
|
|
426
426
|
|
|
427
427
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
428
428
|
>
|
|
429
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
429
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
430
430
|
>
|
|
431
431
|
> Configure app settings:
|
|
432
432
|
>
|
|
@@ -667,7 +667,7 @@ HTTP API server for tools.
|
|
|
667
667
|
|
|
668
668
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
669
669
|
>
|
|
670
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
670
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
671
671
|
>
|
|
672
672
|
> Configure app settings:
|
|
673
673
|
>
|
|
@@ -890,7 +890,7 @@ HTTP API server for tools.
|
|
|
890
890
|
|
|
891
891
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
892
892
|
>
|
|
893
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
893
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
894
894
|
>
|
|
895
895
|
> Configure app settings:
|
|
896
896
|
>
|
|
@@ -1103,7 +1103,7 @@ HTTP API server for tools.
|
|
|
1103
1103
|
|
|
1104
1104
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
1105
1105
|
>
|
|
1106
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1106
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1107
1107
|
>
|
|
1108
1108
|
> Configure app settings:
|
|
1109
1109
|
>
|
|
@@ -1327,7 +1327,7 @@ HTTP API server for tools.
|
|
|
1327
1327
|
|
|
1328
1328
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
1329
1329
|
>
|
|
1330
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1330
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1331
1331
|
>
|
|
1332
1332
|
> Configure app settings:
|
|
1333
1333
|
>
|
|
@@ -1540,7 +1540,7 @@ HTTP API server for tools.
|
|
|
1540
1540
|
|
|
1541
1541
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
1542
1542
|
>
|
|
1543
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1543
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1544
1544
|
>
|
|
1545
1545
|
> Configure app settings:
|
|
1546
1546
|
>
|
|
@@ -1753,7 +1753,7 @@ HTTP API server for tools.
|
|
|
1753
1753
|
|
|
1754
1754
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
1755
1755
|
>
|
|
1756
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1756
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1757
1757
|
>
|
|
1758
1758
|
> Configure app settings:
|
|
1759
1759
|
>
|
|
@@ -1966,7 +1966,7 @@ HTTP API server for tools.
|
|
|
1966
1966
|
|
|
1967
1967
|
> HTTP tool server on http://127.0.0.1:3000.
|
|
1968
1968
|
>
|
|
1969
|
-
> Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1969
|
+
> Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, /*
|
|
1970
1970
|
>
|
|
1971
1971
|
> Configure app settings:
|
|
1972
1972
|
>
|
|
@@ -16,8 +16,8 @@ Bind is localhost-only in v0 — use a reverse proxy for remote access.
|
|
|
16
16
|
|
|
17
17
|
| Method | Path | Purpose |
|
|
18
18
|
| --- | --- | --- |
|
|
19
|
-
| `GET` | `/health
|
|
20
|
-
| `GET` | `/health/readiness` | Readiness
|
|
19
|
+
| `GET` | `/health/liveness` | Liveness — server is online and accepting requests |
|
|
20
|
+
| `GET` | `/health/readiness` | Readiness — online plus config and `program.readiness` checks passed |
|
|
21
21
|
| `GET` | `/openapi.json` | OpenAPI 3.1 REST paths |
|
|
22
22
|
| `GET` | `/swagger` | Interactive Swagger UI API reference |
|
|
23
23
|
| * | `/*` | Invoke user commands (method per route) |
|
|
@@ -28,7 +28,7 @@ Discover paths from `openapi.json` (`/*`). Query binds options; POST/PUT/PATCH b
|
|
|
28
28
|
## Examples
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
curl -s http://127.0.0.1:3000/health
|
|
31
|
+
curl -s http://127.0.0.1:3000/health/liveness
|
|
32
32
|
curl -s http://127.0.0.1:3000/health/readiness
|
|
33
33
|
curl -s http://127.0.0.1:3000/openapi.json
|
|
34
34
|
curl -s http://127.0.0.1:3000/workspaces
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"tags": [
|
|
9
9
|
{
|
|
10
10
|
"name": "health",
|
|
11
|
-
"description": "
|
|
11
|
+
"description": "Orchestrator health probes — liveness (online) vs readiness (online + checks passed)."
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"name": "echo",
|
|
@@ -28,36 +28,6 @@
|
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
30
|
"paths": {
|
|
31
|
-
"/health": {
|
|
32
|
-
"get": {
|
|
33
|
-
"tags": [
|
|
34
|
-
"health"
|
|
35
|
-
],
|
|
36
|
-
"operationId": "health",
|
|
37
|
-
"summary": "Liveness probe (alias of /health/liveness)",
|
|
38
|
-
"responses": {
|
|
39
|
-
"200": {
|
|
40
|
-
"description": "Server is listening",
|
|
41
|
-
"content": {
|
|
42
|
-
"application/json; charset=utf-8": {
|
|
43
|
-
"schema": {
|
|
44
|
-
"type": "object",
|
|
45
|
-
"properties": {
|
|
46
|
-
"ok": {
|
|
47
|
-
"type": "boolean",
|
|
48
|
-
"const": true
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"required": [
|
|
52
|
-
"ok"
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
31
|
"/health/liveness": {
|
|
62
32
|
"get": {
|
|
63
33
|
"tags": [
|
|
@@ -65,9 +35,10 @@
|
|
|
65
35
|
],
|
|
66
36
|
"operationId": "health_liveness",
|
|
67
37
|
"summary": "Liveness probe",
|
|
38
|
+
"description": "Returns 200 when the HTTP server is online and accepting requests. Does not run config or readiness checks — use for orchestrator liveness probes only.",
|
|
68
39
|
"responses": {
|
|
69
40
|
"200": {
|
|
70
|
-
"description": "Server is
|
|
41
|
+
"description": "Server is online",
|
|
71
42
|
"content": {
|
|
72
43
|
"application/json; charset=utf-8": {
|
|
73
44
|
"schema": {
|
|
@@ -95,10 +66,10 @@
|
|
|
95
66
|
],
|
|
96
67
|
"operationId": "health_readiness",
|
|
97
68
|
"summary": "Readiness probe",
|
|
98
|
-
"description": "
|
|
69
|
+
"description": "Returns 200 when the server is online and all readiness checks pass (config file, required app config, and optional program.readiness). Returns 503 when any check fails — use for orchestrator readiness probes before routing traffic.",
|
|
99
70
|
"responses": {
|
|
100
71
|
"200": {
|
|
101
|
-
"description": "
|
|
72
|
+
"description": "Online and ready to serve traffic",
|
|
102
73
|
"content": {
|
|
103
74
|
"application/json; charset=utf-8": {
|
|
104
75
|
"schema": {
|
|
@@ -187,7 +158,7 @@
|
|
|
187
158
|
}
|
|
188
159
|
},
|
|
189
160
|
"503": {
|
|
190
|
-
"description": "
|
|
161
|
+
"description": "Online but not ready (one or more checks failed)",
|
|
191
162
|
"content": {
|
|
192
163
|
"application/json; charset=utf-8": {
|
|
193
164
|
"schema": {
|
package/package.json
CHANGED
package/src/builtins/http.ts
CHANGED
|
@@ -39,7 +39,7 @@ export function cliBuiltinHttpCommand(program: CliProgram): CliRouter {
|
|
|
39
39
|
const lines = [
|
|
40
40
|
`HTTP tool server on http://${hostname}:${port}.`,
|
|
41
41
|
"",
|
|
42
|
-
`Endpoints: GET /health, GET /health/readiness, GET /openapi.json, GET /swagger, ${userGlob}`,
|
|
42
|
+
`Endpoints: GET /health/liveness, GET /health/readiness, GET /openapi.json, GET /swagger, ${userGlob}`,
|
|
43
43
|
"",
|
|
44
44
|
];
|
|
45
45
|
if (caps.configure) {
|
package/src/docs/http-guide.ts
CHANGED
|
@@ -51,8 +51,8 @@ export function generateHttpGuide(root: CliProgram): string {
|
|
|
51
51
|
"",
|
|
52
52
|
"| Method | Path | Purpose |",
|
|
53
53
|
"| --- | --- | --- |",
|
|
54
|
-
"| `GET` | `/health
|
|
55
|
-
"| `GET` | `/health/readiness` | Readiness
|
|
54
|
+
"| `GET` | `/health/liveness` | Liveness — server is online and accepting requests |",
|
|
55
|
+
"| `GET` | `/health/readiness` | Readiness — online plus config and `program.readiness` checks passed |",
|
|
56
56
|
"| `GET` | `/openapi.json` | OpenAPI 3.1 REST paths |",
|
|
57
57
|
"| `GET` | `/swagger` | Interactive Swagger UI API reference |",
|
|
58
58
|
`| * | \`${userGlob}\` | Invoke user commands (method per route) |`,
|
|
@@ -63,7 +63,7 @@ export function generateHttpGuide(root: CliProgram): string {
|
|
|
63
63
|
"## Examples",
|
|
64
64
|
"",
|
|
65
65
|
"```bash",
|
|
66
|
-
`curl -s ${baseUrl}/health`,
|
|
66
|
+
`curl -s ${baseUrl}/health/liveness`,
|
|
67
67
|
`curl -s ${baseUrl}/health/readiness`,
|
|
68
68
|
`curl -s ${baseUrl}/openapi.json`,
|
|
69
69
|
`curl -s ${baseUrl}${sampleWorkspaces}`,
|
package/src/http/openapi.ts
CHANGED
|
@@ -150,13 +150,15 @@ function jsonResponseEntry(description: string, schema: Record<string, unknown>)
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
function livenessGetOp(
|
|
153
|
+
function livenessGetOp(): Record<string, unknown> {
|
|
154
154
|
return {
|
|
155
155
|
tags: [HEALTH_TAG],
|
|
156
|
-
operationId,
|
|
157
|
-
summary,
|
|
156
|
+
operationId: "health_liveness",
|
|
157
|
+
summary: "Liveness probe",
|
|
158
|
+
description:
|
|
159
|
+
"Returns 200 when the HTTP server is online and accepting requests. Does not run config or readiness checks — use for orchestrator liveness probes only.",
|
|
158
160
|
responses: {
|
|
159
|
-
"200": jsonResponseEntry("Server is
|
|
161
|
+
"200": jsonResponseEntry("Server is online", livenessResponseSchema),
|
|
160
162
|
},
|
|
161
163
|
};
|
|
162
164
|
}
|
|
@@ -164,21 +166,19 @@ function livenessGetOp(operationId: string, summary: string): Record<string, unk
|
|
|
164
166
|
/** Framework health probe paths served alongside user command routes. */
|
|
165
167
|
function buildHealthPaths(): Record<string, unknown> {
|
|
166
168
|
return {
|
|
167
|
-
"/health": {
|
|
168
|
-
get: livenessGetOp("health", "Liveness probe (alias of /health/liveness)"),
|
|
169
|
-
},
|
|
170
169
|
"/health/liveness": {
|
|
171
|
-
get: livenessGetOp(
|
|
170
|
+
get: livenessGetOp(),
|
|
172
171
|
},
|
|
173
172
|
"/health/readiness": {
|
|
174
173
|
get: {
|
|
175
174
|
tags: [HEALTH_TAG],
|
|
176
175
|
operationId: "health_readiness",
|
|
177
176
|
summary: "Readiness probe",
|
|
178
|
-
description:
|
|
177
|
+
description:
|
|
178
|
+
"Returns 200 when the server is online and all readiness checks pass (config file, required app config, and optional program.readiness). Returns 503 when any check fails — use for orchestrator readiness probes before routing traffic.",
|
|
179
179
|
responses: {
|
|
180
|
-
"200": jsonResponseEntry("
|
|
181
|
-
"503": jsonResponseEntry("
|
|
180
|
+
"200": jsonResponseEntry("Online and ready to serve traffic", readinessResponseSchema),
|
|
181
|
+
"503": jsonResponseEntry("Online but not ready (one or more checks failed)", readinessResponseSchema),
|
|
182
182
|
},
|
|
183
183
|
},
|
|
184
184
|
},
|
|
@@ -278,7 +278,15 @@ export function generateOpenApi(program: CliProgram): Record<string, unknown> {
|
|
|
278
278
|
description: program.description,
|
|
279
279
|
},
|
|
280
280
|
...(program.httpServer?.enabled
|
|
281
|
-
? {
|
|
281
|
+
? {
|
|
282
|
+
tags: [
|
|
283
|
+
{
|
|
284
|
+
name: HEALTH_TAG,
|
|
285
|
+
description: "Orchestrator health probes — liveness (online) vs readiness (online + checks passed).",
|
|
286
|
+
},
|
|
287
|
+
...commandTags,
|
|
288
|
+
],
|
|
289
|
+
}
|
|
282
290
|
: {}),
|
|
283
291
|
paths,
|
|
284
292
|
};
|
package/src/http/server.ts
CHANGED
|
@@ -112,7 +112,7 @@ export async function handleApiRequest(
|
|
|
112
112
|
const root = cli.program;
|
|
113
113
|
const path = url.pathname;
|
|
114
114
|
|
|
115
|
-
if (request.method === "GET" &&
|
|
115
|
+
if (request.method === "GET" && path === "/health/liveness") {
|
|
116
116
|
return finish(jsonResponse(200, { ok: true }));
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -289,8 +289,8 @@ describe("HTTP API routes", () => {
|
|
|
289
289
|
expect(body.error).toBe("An unexpected error occurred.");
|
|
290
290
|
});
|
|
291
291
|
|
|
292
|
-
test("GET /health includes CORS headers", async () => {
|
|
293
|
-
const res = await apiRequest(program, new Request("http://127.0.0.1/health"));
|
|
292
|
+
test("GET /health/liveness includes CORS headers", async () => {
|
|
293
|
+
const res = await apiRequest(program, new Request("http://127.0.0.1/health/liveness"));
|
|
294
294
|
expect(res.status).toBe(200);
|
|
295
295
|
expect(res.headers.get("access-control-allow-origin")).toBe("*");
|
|
296
296
|
expect(await res.json()).toEqual({ ok: true });
|
|
@@ -449,9 +449,9 @@ describe("HTTP API routes", () => {
|
|
|
449
449
|
const doc = (await res.json()) as { openapi: string; paths: Record<string, unknown> };
|
|
450
450
|
expect(doc.openapi).toBe("3.1.0");
|
|
451
451
|
expect(doc.paths["/stat/owner/lookup"]).toBeDefined();
|
|
452
|
-
expect(doc.paths["/health"]).toBeDefined();
|
|
453
452
|
expect(doc.paths["/health/liveness"]).toBeDefined();
|
|
454
453
|
expect(doc.paths["/health/readiness"]).toBeDefined();
|
|
454
|
+
expect(doc.paths["/health"]).toBeUndefined();
|
|
455
455
|
});
|
|
456
456
|
|
|
457
457
|
test("GET /swagger returns Swagger UI HTML", async () => {
|
|
@@ -480,13 +480,17 @@ test("generateOpenApi includes health probe paths", () => {
|
|
|
480
480
|
{
|
|
481
481
|
get: {
|
|
482
482
|
tags: string[];
|
|
483
|
+
summary: string;
|
|
483
484
|
responses: Record<string, { content: Record<string, { schema: Record<string, unknown> }> }>;
|
|
484
485
|
};
|
|
485
486
|
}
|
|
486
487
|
>;
|
|
487
488
|
};
|
|
488
489
|
expect(doc.tags.some((t) => t.name === "health")).toBe(true);
|
|
489
|
-
expect(doc.paths["/health"]
|
|
490
|
+
expect(doc.paths["/health"]).toBeUndefined();
|
|
491
|
+
expect(doc.paths["/health/liveness"]?.get.tags).toContain("health");
|
|
492
|
+
expect(doc.paths["/health/liveness"]?.get.summary).toBe("Liveness probe");
|
|
493
|
+
expect(doc.paths["/health/readiness"]?.get.summary).toBe("Readiness probe");
|
|
490
494
|
expect(doc.paths["/health/liveness"]?.get.responses["200"]).toBeDefined();
|
|
491
495
|
expect(doc.paths["/health/readiness"]?.get.responses["200"]).toBeDefined();
|
|
492
496
|
expect(doc.paths["/health/readiness"]?.get.responses["503"]).toBeDefined();
|