@hua-labs/tap 0.5.1 → 0.6.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.
Files changed (47) hide show
  1. package/AI_GUIDE.md +165 -0
  2. package/CHANGELOG.md +67 -0
  3. package/README.md +201 -12
  4. package/dist/bridges/codex-app-server-auth-gateway.mjs +16 -1
  5. package/dist/bridges/codex-app-server-auth-gateway.mjs.map +1 -1
  6. package/dist/bridges/codex-app-server-bridge.d.mts +105 -12
  7. package/dist/bridges/codex-app-server-bridge.mjs +3149 -251
  8. package/dist/bridges/codex-app-server-bridge.mjs.map +1 -1
  9. package/dist/bridges/codex-bridge-runner.d.mts +4 -1
  10. package/dist/bridges/codex-bridge-runner.mjs +512 -58
  11. package/dist/bridges/codex-bridge-runner.mjs.map +1 -1
  12. package/dist/bridges/codex-remote-ipc-relay.d.mts +1 -0
  13. package/dist/bridges/codex-remote-ipc-relay.mjs +1912 -0
  14. package/dist/bridges/codex-remote-ipc-relay.mjs.map +1 -0
  15. package/dist/bridges/gemini-ide-companion-runner.mjs.map +1 -1
  16. package/dist/cli.mjs +30944 -8415
  17. package/dist/cli.mjs.map +1 -1
  18. package/dist/codex-a2a/index.d.mts +2 -0
  19. package/dist/codex-a2a/index.mjs +416 -0
  20. package/dist/codex-a2a/index.mjs.map +1 -0
  21. package/dist/codex-health/index.d.mts +76 -0
  22. package/dist/codex-health/index.mjs +153 -0
  23. package/dist/codex-health/index.mjs.map +1 -0
  24. package/dist/codex-ipc/index.d.mts +2 -0
  25. package/dist/codex-ipc/index.mjs +1834 -0
  26. package/dist/codex-ipc/index.mjs.map +1 -0
  27. package/dist/index-D4Khz2Mh.d.mts +206 -0
  28. package/dist/index-DMToLyGd.d.mts +256 -0
  29. package/dist/index.d.mts +763 -8
  30. package/dist/index.mjs +11600 -3449
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/mcp-server.mjs +8838 -811
  33. package/dist/mcp-server.mjs.map +1 -1
  34. package/dist/types-FWvKrFUt.d.mts +43 -0
  35. package/examples/01-logic-battle-known-broken.md +46 -0
  36. package/examples/02-cross-model-review-root-cause.md +37 -0
  37. package/examples/03-convergence-pattern.md +42 -0
  38. package/examples/04-tower-broadcast.md +41 -0
  39. package/examples/05-self-awareness-paradox.md +49 -0
  40. package/examples/06-session-resurrection.md +37 -0
  41. package/examples/07-ghost-agent.md +31 -0
  42. package/examples/08-naming-creates-identity.md +36 -0
  43. package/examples/09-ceo-as-middleware.md +52 -0
  44. package/examples/10-files-as-interface.md +67 -0
  45. package/examples/README.md +34 -0
  46. package/examples/tap-profile-pack.example.json +71 -0
  47. package/package.json +21 -3
package/AI_GUIDE.md ADDED
@@ -0,0 +1,165 @@
1
+ # @hua-labs/tap AI Guide
2
+
3
+ This guide is for AI operators using the public `@hua-labs/tap` package without
4
+ access to HUA's private monorepo notes.
5
+
6
+ ## Release Boundary
7
+
8
+ `0.6.x` is an advanced operator preview. It helps AI runtimes produce durable
9
+ communication evidence and inspect setup state, but it does not guarantee live
10
+ model execution in every app surface.
11
+
12
+ Keep these boundaries explicit:
13
+
14
+ - Inbox, projection, uplink, and review files are durable evidence.
15
+ - Receiver/promoter delivery is the portable CLI/TUI/headless backbone.
16
+ - Codex App / Desktop live delivery is strict-gated by runtime health and route
17
+ freshness.
18
+ - `tap reviews register` is explicit; automatic registration from every writer
19
+ path is a later follow-up.
20
+ - Profile packs are data-only validation inputs in `0.6.x`; tap does not run
21
+ commands from a pack.
22
+
23
+ ## First-Run Path
24
+
25
+ Run from a git repository:
26
+
27
+ ```bash
28
+ git init
29
+ npx @hua-labs/tap setup --profile codex-cli --dry-run --json
30
+ npx @hua-labs/tap setup --profile codex-cli --apply --json
31
+ npx @hua-labs/tap doctor --setup --profile codex-cli --json
32
+ npx @hua-labs/tap status --json
33
+ npx @hua-labs/tap add codex --name agent-a
34
+ npx @hua-labs/tap ready --surface codex-cli --agent agent-a --apply --json
35
+ npx @hua-labs/tap comms-doctor --all-known --json
36
+ ```
37
+
38
+ Use concrete agent names such as `agent-a`, `operator-a`, or `diagnostic-a`.
39
+ Avoid broad role words such as `codex`, `reviewer`, `implementer`,
40
+ `implementation`, and `tower` as assignment targets unless a reviewed role map
41
+ makes them unambiguous.
42
+
43
+ ## Expected Fresh-Install Results
44
+
45
+ - `tap setup --apply --json` should return setup evidence without starting
46
+ receiver, projection, uplink, app-server, or remote-panel processes.
47
+ - `tap status --json` may show zero installed instances until `tap add` runs.
48
+ - `tap ready --surface codex-cli --agent agent-a --apply --json` should publish
49
+ readiness for the concrete `agent-a` lane.
50
+ - `tap comms-doctor --all-known --json` should diagnose locally installed or
51
+ observed agents. Bundled operator profile surfaces require explicit
52
+ `--include-profile-pack`.
53
+ - In an auth-free container or fresh desktop, app/live delivery can remain
54
+ blocked while inbox/receiver evidence is healthy.
55
+
56
+ ## Profile Pack Template
57
+
58
+ A generic example is shipped with the package:
59
+
60
+ ```bash
61
+ cp node_modules/@hua-labs/tap/examples/tap-profile-pack.example.json ./tap-profile-pack.json
62
+ npx @hua-labs/tap setup --profile codex-cli --profile-pack ./tap-profile-pack.json --json
63
+ npx @hua-labs/tap doctor --setup --profile codex-cli --profile-pack ./tap-profile-pack.json --json
64
+ ```
65
+
66
+ If you are using `npx` without a local install, create `tap-profile-pack.json`
67
+ from the example shape below or install the package as a dev dependency first.
68
+
69
+ Profile-pack paths are not auto-corrected because each operator may keep the
70
+ repo, comms directory, state directory, and runtime surfaces in different
71
+ places. Use paths that are valid on the machine where the command runs:
72
+
73
+ - `paths.repoRoot`: the repository where tap commands run;
74
+ - `paths.commsDir`: the durable comms directory for inbox/projection/evidence;
75
+ - command snippets: reviewed operator hints only; tap validates them but does
76
+ not execute them in `0.6.x`.
77
+
78
+ If the pack is invalid, `tap setup --apply` blocks before writing setup
79
+ artifacts. Repair the reported JSON path, or rerun without `--profile-pack`.
80
+
81
+ ## Minimal Generic Profile Pack
82
+
83
+ ```json
84
+ {
85
+ "schemaVersion": "tap-profile-pack.v0",
86
+ "packId": "local.public.example",
87
+ "label": "Local public profile pack example",
88
+ "profiles": [
89
+ {
90
+ "id": "local-agent-a-cli",
91
+ "label": "Local Agent A CLI",
92
+ "agent": "agent-a",
93
+ "runtimeSurface": "codex-cli",
94
+ "paths": {
95
+ "repoRoot": ".",
96
+ "commsDir": "./tap-comms"
97
+ },
98
+ "capabilities": {
99
+ "ready": true,
100
+ "status": true,
101
+ "apply": false
102
+ },
103
+ "status": {
104
+ "kind": "codex-cli"
105
+ },
106
+ "ready": {
107
+ "surface": "codex-cli",
108
+ "commandRef": "ready-check"
109
+ },
110
+ "commands": {
111
+ "ready-check": {
112
+ "shell": "npx @hua-labs/tap ready --surface codex-cli --agent agent-a --json",
113
+ "risk": "read-only",
114
+ "reviewRequired": true,
115
+ "defaultEnabled": false
116
+ }
117
+ }
118
+ }
119
+ ]
120
+ }
121
+ ```
122
+
123
+ ## Troubleshooting
124
+
125
+ ### `tap doctor --setup` reports `.mcp.json` cwd warning
126
+
127
+ Rerun current `tap setup --profile codex-cli --apply --json`. The reviewed
128
+ setup apply path writes guarded tap-managed `.mcp.json` entries with a `cwd`
129
+ field. If an existing user-managed MCP entry is ambiguous, tap fails closed
130
+ instead of overwriting it.
131
+
132
+ ### `tap comms-doctor --all-known` shows app/live blockers
133
+
134
+ That can be expected on a fresh auth-free machine. Check whether inbox and
135
+ receiver evidence are healthy before claiming live delivery is broken. App live
136
+ delivery needs runtime health and route freshness that package setup cannot
137
+ invent.
138
+
139
+ ### Profile-pack validation passes but nothing starts
140
+
141
+ That is expected in `0.6.x`. Profile packs are data-only. Commands in a pack
142
+ must be reviewed manually and remain `defaultEnabled: false`.
143
+
144
+ ### A command lists a bundled operator profile you do not recognize
145
+
146
+ Treat it as a compatibility profile, not a public default. Some legacy helper
147
+ surfaces remain discoverable for operators who already own those local runbooks,
148
+ paths, and process managers. For a new install, use neutral concrete agents
149
+ such as `agent-a`, or provide a reviewed local profile pack. Do not copy a
150
+ profile command unless you own every path, host, and process name it references.
151
+
152
+ ### Profile-pack paths are wrong after moving machines
153
+
154
+ Edit the pack for the current machine. Prefer repo-relative paths when the
155
+ comms directory is inside the repo, and absolute paths when the comms directory
156
+ is shared outside the repo. Do not copy another machine's host paths blindly.
157
+
158
+ ### Source package says `0.6.0` but npm shows an older version
159
+
160
+ Treat `package.json` version and public npm registry state separately. Verify
161
+ the registry with:
162
+
163
+ ```bash
164
+ npm view @hua-labs/tap version time.modified --json
165
+ ```
package/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # @hua-labs/tap
2
+
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Ship the tap 0.6 advanced operator preview.
8
+ - Make `tap setup` and `tap doctor --setup` the first-run path for public
9
+ profiles (`codex-cli`, `codex-app`, and `claude-channel`), with dry-run-first
10
+ reports, guarded tap-managed `.mcp.json` apply behavior, and data-only
11
+ profile-pack validation.
12
+ - Position receiver/promoter delivery as the portable CLI/TUI/headless
13
+ backbone. Receiver promotion is idle-only for live turn start; active targets
14
+ leave queued/blocked evidence instead of silently steering or passing through.
15
+ - Add surface-first diagnostics across setup, status, comms-doctor, flow-doctor,
16
+ and review registration so AI operators can distinguish durable inbox
17
+ evidence, receiver/promoter delivery, return-uplink evidence, and experimental
18
+ live App delivery.
19
+ - Persist displayed-notification dedupe with receiver-scoped marker files so
20
+ restarts do not replay already displayed inbox items while broadcasts can
21
+ still be shown once per receiving runtime.
22
+ - Register formal review outcomes through the explicit
23
+ `tap reviews register` stream, including provenance-only handling for review
24
+ requests and stale review-meta chatter.
25
+ - Guard broad role aliases such as `codex`, `reviewer`, `implementer`,
26
+ `implementation`, and `tower` when multiple candidates exist. Release
27
+ coordination should use concrete agents or reviewed structured targets.
28
+
29
+ ### Preview Boundaries
30
+
31
+ - `0.6.0` is an advanced operator preview, not a universal one-click runtime
32
+ installer.
33
+ - HUA machine topology, tmux sessions, one-character agent names, mission
34
+ governance, and private profile packs are examples or profile-pack inputs;
35
+ they are not public defaults.
36
+ - Some advanced/HUA helper surfaces still expose existing named profiles for
37
+ compatibility. Portable first-run docs use explicit neutral agents and
38
+ profiles instead of relying on those helper defaults.
39
+ - Codex App consent-drive / IPC remains experimental and strict-gated. A
40
+ conversation id or route tuple alone is not authority for live injection.
41
+ - Durable inbox, projection, uplink, and review files are evidence records; they
42
+ are not proof that a target runtime executed work.
43
+ - Automatic registration from every tap reply/review writer remains a follow-up.
44
+ Use explicit `tap reviews register` for the 0.6 preview evidence stream.
45
+ - Archive-audit commands remain available for compatibility, but they are not
46
+ part of the first-run release story.
47
+
48
+ ## 0.5.2
49
+
50
+ ### Patch Changes
51
+
52
+ - Fix doctor onboarding false failures and remove DEP0190 shell deprecation warnings.
53
+ - doctor: empty inbox treated as warning instead of failure on fresh setup
54
+ - doctor: recognize npx package launcher as valid MCP entry
55
+ - runtime: remove shell: true from command probes to eliminate Node 24 DEP0190 warnings
56
+ - README: add git init to Quick Start
57
+
58
+ ## 0.5.1
59
+
60
+ ### Patch Changes
61
+
62
+ - c931481: Gen 25 trust-layer repair and delivery hardening.
63
+ - split shared state (`TAP_STATE_DIR`) from per-bridge runtime state (`TAP_RUNTIME_STATE_DIR`) so headless restarts and later attached TUI sessions keep the correct identity
64
+ - rebind attached TUI identity from runtime heartbeat and agent-name files instead of relying on one-shot session env injection
65
+ - align bridge status, runtime heartbeat, and presence surfaces so `tap status`, bridge state, and plugin-visible presence report the same runtime truth
66
+ - deduplicate bridge-dispatched broadcast notifications
67
+ - rate-limit peer DM auto-replies to stop acknowledgement loops from flooding the inbox
package/README.md CHANGED
@@ -2,29 +2,85 @@
2
2
 
3
3
  Zero-dependency CLI for cross-model AI agent communication setup.
4
4
 
5
- One command to connect Claude, Codex, and Gemini agents through a shared file-based communication layer.
5
+ tap connects Claude, Codex, and other agent runtimes through a shared
6
+ file-backed communication layer, with setup reports that keep runtime surfaces,
7
+ durable evidence, and optional live adapters separate.
8
+
9
+ ## Requirements
10
+
11
+ - **Node.js ≥ 22.6.0** — tap uses the global `WebSocket` API (stable in Node 22+). Node 20 and earlier are not supported; run with `fnm use 22` or `nvm use 22`.
6
12
 
7
13
  ## Quick Start
8
14
 
9
15
  > `npx @hua-labs/tap` ships a bundled managed MCP server entry and runs that bundled `.mjs` with `node`. `bun` is only required when tap falls back to repo-local TypeScript sources during monorepo or local-dev workflows.
10
16
 
11
17
  ```bash
12
- # 1. Initialize comms directory and state
13
- npx @hua-labs/tap init
18
+ # 1. Start in a git repo
19
+ git init
14
20
 
15
- # 2. Add runtimes
16
- npx @hua-labs/tap add claude
17
- npx @hua-labs/tap add codex
18
- npx @hua-labs/tap add gemini
21
+ # 2. Generate a dry-run setup report for your runtime surface
22
+ npx @hua-labs/tap setup --profile codex-cli --dry-run --json
19
23
 
20
- # 3. Check status
21
- npx @hua-labs/tap status
24
+ # 3. Apply only reviewed setup-safe changes
25
+ npx @hua-labs/tap setup --profile codex-cli --apply --json
26
+
27
+ # 4. Re-check setup readiness and surface status
28
+ npx @hua-labs/tap doctor --setup --profile codex-cli --json
29
+ npx @hua-labs/tap status --json
30
+
31
+ # 5. Add a concrete runtime only when you are ready to patch that runtime
32
+ npx @hua-labs/tap add codex --name agent-a
33
+ npx @hua-labs/tap ready --surface codex-cli --agent agent-a --apply --json
34
+
35
+ # 6. Diagnose delivery separately from setup
36
+ npx @hua-labs/tap comms-doctor --all-known --json
22
37
  ```
23
38
 
24
- Your agents can now communicate through the shared comms directory.
39
+ `tap setup` is dry-run by default. The current reviewed apply path creates
40
+ tap-owned directories, an initial tap state file, and guarded tap-managed repo
41
+ `.mcp.json` entries. It does not start receiver, projection, uplink, bridge,
42
+ app-server, headless runner, or remote panel processes, and it does not publish
43
+ presence, repair route tuples, send messages, or read credentials.
44
+
45
+ Supported public setup profiles:
46
+
47
+ | Profile | Use when |
48
+ | ---------------- | ----------------------------------------------------------------------- |
49
+ | `codex-cli` | Codex CLI or headless CLI will use MCP tools plus inbox/receiver paths. |
50
+ | `codex-app` | Codex App/Desktop route readiness should be inspected read-only. |
51
+ | `claude-channel` | Claude/channel readiness should be inspected read-only. |
52
+
53
+ HUA-specific machine names, paths, tmux sessions, one-character Korean agent
54
+ names, and private profile packs are examples, not package defaults.
55
+
56
+ For the `0.6.x` preview, release-facing commands use neutral agents such as
57
+ `agent-a` and `agent-b`. HUA profiles and paths can be supplied through a
58
+ reviewed profile pack or HUA runbook, but they are not package defaults.
25
59
 
26
60
  ## Commands
27
61
 
62
+ ### `setup`
63
+
64
+ Generate a dry-run-first setup report for public tap deployment.
65
+
66
+ ```bash
67
+ npx @hua-labs/tap setup --profile codex-cli --dry-run --json
68
+ npx @hua-labs/tap setup --profile codex-cli --apply --json
69
+ TAP_AGENT=agent-a
70
+ npx @hua-labs/tap setup --profile codex-app --agent "$TAP_AGENT" --json
71
+ npx @hua-labs/tap setup --profile claude-channel --agent "$TAP_AGENT" --json
72
+ npx @hua-labs/tap setup --profile codex-cli --profile-pack ./tap-profile-pack.json --json
73
+ ```
74
+
75
+ `--apply` is intentionally narrow: create reviewed tap-owned directories, an
76
+ initial tap state file, and guarded tap-managed repo `.mcp.json` changes only.
77
+ User-managed or ambiguous MCP entries fail closed before mutation.
78
+
79
+ Profile packs are data-only validation inputs in `0.6.x`; tap reports their
80
+ shape and blocks invalid packs before setup mutation, but it does not execute
81
+ pack commands. A generic example is shipped at
82
+ `examples/tap-profile-pack.example.json`.
83
+
28
84
  ### `init`
29
85
 
30
86
  Initialize the comms directory and `.tap-comms/` state.
@@ -47,7 +103,41 @@ Add a runtime. Probes config, plans patches, applies, and verifies.
47
103
  npx @hua-labs/tap add claude
48
104
  npx @hua-labs/tap add codex
49
105
  npx @hua-labs/tap add gemini
50
- npx @hua-labs/tap add claude --force # re-install
106
+ npx @hua-labs/tap add claude --force # re-install
107
+ npx @hua-labs/tap add codex --name agent-a --port 4520 # explicit port
108
+ npx @hua-labs/tap add codex --name agent-b # portMap lookup, else auto-assign
109
+ ```
110
+
111
+ For Codex app-server instances, `--name agent-a` is the concrete agent identity
112
+ used by `tap ready --agent agent-a`; the managed instance id remains
113
+ `codex-agent-a`.
114
+
115
+ Codex instances bind to an app-server port. Resolution order:
116
+
117
+ 1. `--port <n>` — explicit override.
118
+ 2. `portMap[<instanceId>]` from `tap-config.json` / `tap-config.local.json` when the
119
+ entry is free (no state claim, TCP-available on loopback).
120
+ 3. Auto-assign — scan from 4501 upward for the first free port.
121
+
122
+ `portMap` is a hint, not a hard requirement: a missing entry or a conflict
123
+ silently drops through to auto-assign. Convention:
124
+
125
+ | Port | Instance | Role |
126
+ | ---- | --------------- | ------------------ |
127
+ | 4510 | `codex-agent-a` | Agent A |
128
+ | 4511 | `codex-agent-b` | Agent B |
129
+ | 4512 | `codex-agent-c` | Agent C |
130
+ | 4520 | `codex-agent-d` | Agent D |
131
+ | 4530 | `codex-probe` | Diagnostic / probe |
132
+
133
+ ```json
134
+ {
135
+ "portMap": {
136
+ "codex-agent-a": 4510,
137
+ "codex-agent-b": 4511,
138
+ "codex-agent-d": 4520
139
+ }
140
+ }
51
141
  ```
52
142
 
53
143
  ### `remove <runtime>`
@@ -65,6 +155,7 @@ Show installed runtimes and their status.
65
155
 
66
156
  ```bash
67
157
  npx @hua-labs/tap status
158
+ npx @hua-labs/tap status --json
68
159
  ```
69
160
 
70
161
  Output shows three status levels:
@@ -75,13 +166,65 @@ Output shows three status levels:
75
166
 
76
167
  ### `doctor`
77
168
 
78
- Diagnose config drift, bridge health, managed MCP wiring, and runtime state. Use `--fix` to repair common config drift, including Codex `approval_mode` mismatches.
169
+ Diagnose config drift, bridge health, managed MCP wiring, and runtime state.
170
+ Use `--setup` for setup/config/warm-up readiness. Use the plain doctor for
171
+ broader infrastructure checks.
79
172
 
80
173
  ```bash
81
174
  npx @hua-labs/tap doctor
82
175
  npx @hua-labs/tap doctor --fix
176
+ npx @hua-labs/tap doctor --setup --profile codex-cli --json
177
+ npx @hua-labs/tap doctor --setup --profile codex-cli --profile-pack ./tap-profile-pack.json --json
83
178
  ```
84
179
 
180
+ `tap doctor --setup --apply` reuses the same guarded setup apply plan as
181
+ `tap setup --apply`. It does not run the broad infrastructure fixer.
182
+
183
+ ### `comms-doctor`
184
+
185
+ Explain delivery by runtime surface. Use this when you need to separate live
186
+ delivery, durable inbox evidence, receiver/promoter paths, MCP/channel
187
+ visibility, and fallback evidence.
188
+
189
+ ```bash
190
+ npx @hua-labs/tap comms-doctor --all-known --json
191
+ TAP_AGENT=agent-b
192
+ npx @hua-labs/tap comms-doctor --agent "$TAP_AGENT" --plan-send --json
193
+ ```
194
+
195
+ ### `flow-doctor`
196
+
197
+ Diagnose one receiver/promoter lane without mutating process state. Use this
198
+ when an agent appears present but the operator needs one report for identity,
199
+ receiver dry-run, return-uplink evidence, central presence freshness,
200
+ active-turn queue state, and stale presence cleanup candidates.
201
+
202
+ ```bash
203
+ TAP_AGENT=agent-a
204
+ npx @hua-labs/tap flow-doctor --agent "$TAP_AGENT" --json
205
+ npx @hua-labs/tap flow-doctor --agent "$TAP_AGENT" --presence-source-comms-dir ./tap-comms --presence-target-comms-dir ./tap-comms --json
206
+ ```
207
+
208
+ `flow-doctor` is read-only by default. Its only reviewed cleanup mutation is
209
+ `--apply-stale-presence-cleanup`, which archives stale non-lane presence
210
+ records with a manifest and prunes matching stale heartbeat entries. It never
211
+ publishes stale presence, restarts processes, changes route tuples, or deletes
212
+ inbox/archive evidence.
213
+
214
+ ### `reviews register`
215
+
216
+ Register formal review outcomes into the review evidence stream. Use this when
217
+ review results should be discoverable outside the ordinary inbox flow.
218
+
219
+ ```bash
220
+ npx @hua-labs/tap reviews register --source ./tap-comms --dry-run --json
221
+ ```
222
+
223
+ The explicit registration path is part of the `0.6.x` preview boundary.
224
+ Automatic registration from every tap reply/review writer path is a future
225
+ follow-up, so release notes should name the explicit command as the current
226
+ workaround.
227
+
85
228
  ### `serve`
86
229
 
87
230
  Start the tap-comms MCP server (stdio). Convenience command for running the MCP server locally.
@@ -93,6 +236,18 @@ npx @hua-labs/tap serve --comms-dir /path/to/comms
93
236
 
94
237
  For npm installs, `serve` runs the bundled `mcp-server.mjs` entry with `node`. In monorepos or local checkouts, tap may fall back to repo-local `.ts` sources, which still require `bun`.
95
238
 
239
+ ### `bridge start|stop|restart`
240
+
241
+ Manage the Codex app-server bridge lifecycle.
242
+
243
+ ```bash
244
+ npx @hua-labs/tap bridge start codex --agent-name agent-c
245
+ npx @hua-labs/tap bridge stop codex --keep-server
246
+ npx @hua-labs/tap bridge restart codex
247
+ ```
248
+
249
+ `bridge stop --keep-server` leaves the managed app-server running and preserves its metadata in instance state so the next `bridge start` or `bridge restart` can reuse the existing session instead of forcing a fresh app-server.
250
+
96
251
  ## Supported Runtimes
97
252
 
98
253
  | Runtime | Config | Bridge | Mode |
@@ -174,6 +329,40 @@ Each runtime has an adapter that:
174
329
 
175
330
  The adapter contract (`RuntimeAdapter`) is the extension point for adding new runtimes.
176
331
 
332
+ ## Surface-First Delivery Model
333
+
334
+ tap does not route by display name alone. It asks which runtime surface is
335
+ available and what evidence exists:
336
+
337
+ - CLI/TUI surfaces use durable inbox files plus receiver/promoter loops.
338
+ - Claude/channel surfaces use channel readiness and durable inbox fallback.
339
+ - Codex App consent-drive / IPC is an experimental live adapter and must see
340
+ fresh explicit runtime health before it is treated as live-ready.
341
+ - Inbox and projection files are durable evidence, not proof of live model
342
+ execution.
343
+
344
+ Use `tap comms-doctor` to inspect these boundaries before claiming live
345
+ delivery.
346
+
347
+ ## 0.6 Preview Boundary
348
+
349
+ `0.6.x` should be described as an advanced operator preview:
350
+
351
+ - Public defaults use neutral profile ids and concrete agents.
352
+ - Receiver/promoter plus durable inbox/projection/uplink evidence is the
353
+ portable backbone for CLI/TUI/headless receive.
354
+ - Codex App consent-drive / IPC remains experimental and strict-gated.
355
+ - HUA machine topology, tmux sessions, one-character agent names, and
356
+ mission/devlog governance are examples or profile-pack inputs.
357
+ - Broad role aliases such as `codex`, `reviewer`, `implementer`,
358
+ `implementation`, and `tower` are unsafe assignment targets unless a reviewed
359
+ role mapping makes them unambiguous.
360
+ - Archive-audit commands remain preserved, but they are not part of the
361
+ first-run package story.
362
+
363
+ For AI-facing troubleshooting and first-run detail, read the package-local
364
+ [AI Guide](./AI_GUIDE.md).
365
+
177
366
  ## Recent Changes
178
367
 
179
368
  ### Config And Lifecycle
@@ -3,7 +3,7 @@ import {
3
3
  createServer
4
4
  } from "http";
5
5
  import { readFileSync } from "fs";
6
- import { resolve } from "path";
6
+ import { basename, resolve } from "path";
7
7
  import { pathToFileURL } from "url";
8
8
  import { timingSafeEqual } from "crypto";
9
9
  import { WebSocket, WebSocketServer } from "ws";
@@ -273,9 +273,15 @@ async function startGatewayServer(options) {
273
273
  closeSocket(client, CLOSE_UNAUTHORIZED, "Unauthorized");
274
274
  return;
275
275
  }
276
+ console.log(
277
+ `[auth-gateway] client authenticated from ${request.socket.remoteAddress ?? "unknown"} -> ${options.upstreamUrl}`
278
+ );
276
279
  const upstream = new WebSocket(options.upstreamUrl, {
277
280
  perMessageDeflate: false
278
281
  });
282
+ upstream.on("open", () => {
283
+ console.log(`[auth-gateway] upstream connected ${options.upstreamUrl}`);
284
+ });
279
285
  upstream.on("message", (data, isBinary) => {
280
286
  if (client.readyState === WebSocket.OPEN) {
281
287
  client.send(data, { binary: isBinary });
@@ -288,10 +294,16 @@ async function startGatewayServer(options) {
288
294
  });
289
295
  upstream.on("close", (code, reasonBuffer) => {
290
296
  const reason = reasonBuffer.toString() || "Upstream closed";
297
+ console.log(
298
+ `[auth-gateway] upstream closed code=${code || 1e3} reason=${reason}`
299
+ );
291
300
  closeSocket(client, code || 1e3, reason);
292
301
  });
293
302
  client.on("close", (code, reasonBuffer) => {
294
303
  const reason = reasonBuffer.toString() || "Client closed";
304
+ console.log(
305
+ `[auth-gateway] client closed code=${code || 1e3} reason=${reason}`
306
+ );
295
307
  closeSocket(upstream, code || 1e3, reason);
296
308
  });
297
309
  upstream.on("error", (error) => {
@@ -361,6 +373,9 @@ async function startGatewayServer(options) {
361
373
  function isDirectExecution() {
362
374
  const entry = process.argv[1];
363
375
  if (!entry) return false;
376
+ if (!basename(entry).startsWith("codex-app-server-auth-gateway")) {
377
+ return false;
378
+ }
364
379
  return import.meta.url === pathToFileURL(resolve(entry)).href;
365
380
  }
366
381
  if (isDirectExecution()) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bridges/codex-app-server-auth-gateway.ts","../../src/engine/bridge-app-server-health.ts"],"sourcesContent":["import {\n createServer,\n type IncomingMessage,\n type Server as HttpServer,\n type ServerResponse,\n} from \"node:http\";\nimport { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type { Duplex } from \"node:stream\";\nimport { pathToFileURL } from \"node:url\";\nimport { timingSafeEqual } from \"node:crypto\";\nimport { WebSocket, WebSocketServer, type RawData } from \"ws\";\nimport { checkManagedAppServerReady } from \"../engine/bridge-app-server-health.js\";\n\nconst AUTH_SUBPROTOCOL_PREFIX = \"tap-auth-\";\nconst CLOSE_UNAUTHORIZED = 4401;\nconst CLOSE_UPSTREAM_ERROR = 1013;\nexport const GATEWAY_READYZ_PATH = \"/readyz\";\n\nexport interface GatewayOptions {\n listenUrl: string;\n upstreamUrl: string;\n token: string;\n}\n\nexport interface GatewayRuntime {\n server: HttpServer;\n close(): Promise<void>;\n}\n\nfunction normalizeUrl(value: string): string {\n return value.replace(/\\/$/, \"\");\n}\n\nfunction closeSocket(\n socket: Pick<WebSocket, \"readyState\" | \"close\">,\n code: number,\n reason: string,\n): void {\n if (\n socket.readyState === WebSocket.CLOSING ||\n socket.readyState === WebSocket.CLOSED\n ) {\n return;\n }\n\n try {\n socket.close(code, reason);\n } catch {\n // Best-effort cleanup only.\n }\n}\n\nfunction readFlagValue(argv: string[], index: number, flag: string): string {\n const current = argv[index] ?? \"\";\n const eqIndex = current.indexOf(\"=\");\n if (eqIndex >= 0) {\n return current.slice(eqIndex + 1);\n }\n\n const next = argv[index + 1];\n if (!next || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n return next;\n}\n\nexport function buildGatewayOptions(argv: string[]): GatewayOptions {\n let listenUrl = process.env.TAP_GATEWAY_LISTEN_URL?.trim() || \"\";\n let upstreamUrl = process.env.TAP_GATEWAY_UPSTREAM_URL?.trim() || \"\";\n let tokenFile = process.env.TAP_GATEWAY_TOKEN_FILE?.trim() || \"\";\n let token = process.env.TAP_GATEWAY_TOKEN?.trim() || \"\";\n\n for (let index = 0; index < argv.length; index += 1) {\n const flag = argv[index] ?? \"\";\n const consumesNext = !flag.includes(\"=\");\n\n if (flag.startsWith(\"--listen-url\")) {\n listenUrl = readFlagValue(argv, index, \"--listen-url\").trim();\n if (consumesNext) index += 1;\n continue;\n }\n\n if (flag.startsWith(\"--upstream-url\")) {\n upstreamUrl = readFlagValue(argv, index, \"--upstream-url\").trim();\n if (consumesNext) index += 1;\n continue;\n }\n\n if (flag.startsWith(\"--token\")) {\n token = readFlagValue(argv, index, \"--token\").trim();\n if (consumesNext) index += 1;\n continue;\n }\n\n if (flag.startsWith(\"--token-file\")) {\n tokenFile = readFlagValue(argv, index, \"--token-file\").trim();\n if (consumesNext) index += 1;\n continue;\n }\n }\n\n if (tokenFile) {\n token = readFileSync(tokenFile, \"utf8\").trim();\n }\n\n if (!listenUrl) {\n throw new Error(\"Missing gateway listen URL\");\n }\n if (!upstreamUrl) {\n throw new Error(\"Missing gateway upstream URL\");\n }\n if (!token) {\n throw new Error(\"Missing gateway auth token\");\n }\n\n const listen = new URL(listenUrl);\n const upstream = new URL(upstreamUrl);\n if (!/^wss?:$/.test(listen.protocol)) {\n throw new Error(`Unsupported gateway listen protocol: ${listen.protocol}`);\n }\n if (!/^wss?:$/.test(upstream.protocol)) {\n throw new Error(\n `Unsupported gateway upstream protocol: ${upstream.protocol}`,\n );\n }\n\n return {\n listenUrl: normalizeUrl(listen.toString()),\n upstreamUrl: normalizeUrl(upstream.toString()),\n token,\n };\n}\n\nfunction tokensMatch(\n presentedToken: string | null,\n expectedToken: string,\n): boolean {\n if (!presentedToken) {\n return false;\n }\n\n const presented = Buffer.from(presentedToken, \"utf8\");\n const expected = Buffer.from(expectedToken, \"utf8\");\n if (presented.length !== expected.length) {\n return false;\n }\n\n return timingSafeEqual(presented, expected);\n}\n\nasync function main(): Promise<void> {\n const options = buildGatewayOptions(process.argv.slice(2));\n const runtime = await startGatewayServer(options);\n\n const shutdown = () => {\n void runtime.close().finally(() => {\n process.exit(0);\n });\n };\n\n process.on(\"SIGINT\", shutdown);\n process.on(\"SIGTERM\", shutdown);\n}\n\nfunction writeJson(\n response: ServerResponse,\n statusCode: number,\n body: Record<string, unknown>,\n): void {\n response.statusCode = statusCode;\n response.setHeader(\"Content-Type\", \"application/json\");\n response.end(JSON.stringify(body));\n}\n\nfunction writeUpgradeRequired(response: ServerResponse): void {\n response.statusCode = 426;\n response.setHeader(\"Connection\", \"Upgrade\");\n response.setHeader(\"Upgrade\", \"websocket\");\n response.end(\"Upgrade Required\");\n}\n\nfunction writeNotFound(response: ServerResponse): void {\n response.statusCode = 404;\n response.end(\"Not Found\");\n}\n\nfunction rejectUpgrade(socket: Duplex, statusCode: number): void {\n socket.write(\n `HTTP/1.1 ${statusCode} ${statusCode === 404 ? \"Not Found\" : \"Bad Request\"}\\r\\n\\r\\n`,\n );\n socket.destroy();\n}\n\n/**\n * Detect traversal sequences in any encoding: raw \"..\", percent-encoded\n * \"%2e%2e\", or mixed forms like \".%2e\" / \"%2e.\".\n */\nfunction containsTraversal(raw: string): boolean {\n if (raw.includes(\"..\")) return true;\n // Decode percent-encoded dots and recheck\n if (/%2e/i.test(raw) && raw.replace(/%2e/gi, \".\").includes(\"..\")) return true;\n return false;\n}\n\nfunction isUpgradePath(listenUrl: string, request: IncomingMessage): boolean {\n const requestUrl = new URL(\n request.url ?? \"/\",\n listenUrl.replace(/^ws/, \"http\"),\n );\n const listenPath = new URL(listenUrl).pathname;\n return requestUrl.pathname === (listenPath || \"/\");\n}\n\nasync function handleReadyzRequest(\n response: ServerResponse,\n options: GatewayOptions,\n): Promise<void> {\n const ready = await checkManagedAppServerReady(options.upstreamUrl);\n writeJson(response, ready ? 200 : 503, { ok: ready });\n}\n\nexport async function startGatewayServer(\n options: GatewayOptions,\n): Promise<GatewayRuntime> {\n const listen = new URL(options.listenUrl);\n const host = listen.hostname === \"localhost\" ? \"127.0.0.1\" : listen.hostname;\n const port = Number.parseInt(listen.port, 10);\n if (!Number.isFinite(port) || port <= 0) {\n throw new Error(\n `Gateway listen URL must include a valid port: ${options.listenUrl}`,\n );\n }\n\n const wsServer = new WebSocketServer({\n noServer: true,\n perMessageDeflate: false,\n });\n\n wsServer.on(\"connection\", (client: WebSocket, request: IncomingMessage) => {\n // Extract token from Sec-WebSocket-Protocol header (subprotocol auth).\n // Client sends: WebSocket(url, [\"tap-auth-<token>\"])\n // Falls back to query param for backward compatibility during migration.\n const protocols =\n request.headers[\"sec-websocket-protocol\"]\n ?.split(\",\")\n .map((s) => s.trim()) ?? [];\n const authProtocol = protocols.find((p) =>\n p.startsWith(AUTH_SUBPROTOCOL_PREFIX),\n );\n const subprotocolToken =\n authProtocol?.slice(AUTH_SUBPROTOCOL_PREFIX.length) ?? null;\n\n // Legacy fallback: query param (will be removed in future version)\n const requestUrl = new URL(request.url ?? \"/\", options.listenUrl);\n const queryToken = requestUrl.searchParams.get(\"tap_token\");\n\n const presentedToken = subprotocolToken ?? queryToken;\n if (!tokensMatch(presentedToken, options.token)) {\n closeSocket(client, CLOSE_UNAUTHORIZED, \"Unauthorized\");\n return;\n }\n\n const upstream = new WebSocket(options.upstreamUrl, {\n perMessageDeflate: false,\n });\n\n upstream.on(\"message\", (data: RawData, isBinary: boolean) => {\n if (client.readyState === WebSocket.OPEN) {\n client.send(data, { binary: isBinary });\n }\n });\n\n client.on(\"message\", (data: RawData, isBinary: boolean) => {\n if (upstream.readyState === WebSocket.OPEN) {\n upstream.send(data, { binary: isBinary });\n }\n });\n\n upstream.on(\"close\", (code: number, reasonBuffer: Buffer) => {\n const reason = reasonBuffer.toString() || \"Upstream closed\";\n closeSocket(client, code || 1000, reason);\n });\n\n client.on(\"close\", (code: number, reasonBuffer: Buffer) => {\n const reason = reasonBuffer.toString() || \"Client closed\";\n closeSocket(upstream, code || 1000, reason);\n });\n\n upstream.on(\"error\", (error: Error) => {\n console.error(`[auth-gateway] upstream error: ${String(error)}`);\n closeSocket(client, CLOSE_UPSTREAM_ERROR, \"Upstream unavailable\");\n closeSocket(upstream, CLOSE_UPSTREAM_ERROR, \"Upstream unavailable\");\n });\n\n client.on(\"error\", (error: Error) => {\n console.error(`[auth-gateway] client error: ${String(error)}`);\n closeSocket(upstream, 1011, \"Client error\");\n });\n });\n\n const listenPath = new URL(options.listenUrl).pathname || \"/\";\n\n const server = createServer(async (request, response) => {\n const requestUrl = new URL(\n request.url ?? \"/\",\n options.listenUrl.replace(/^ws/, \"http\"),\n );\n\n // Defense-in-depth: reject traversal sequences in any encoding.\n // Covers raw \"..\", percent-encoded \"%2e%2e\", and mixed forms.\n if (containsTraversal(request.url ?? \"\")) {\n writeNotFound(response);\n return;\n }\n\n if (\n request.method === \"GET\" &&\n requestUrl.pathname === GATEWAY_READYZ_PATH\n ) {\n await handleReadyzRequest(response, options);\n return;\n }\n\n if (requestUrl.pathname === listenPath) {\n writeUpgradeRequired(response);\n return;\n }\n\n writeNotFound(response);\n });\n\n server.on(\"upgrade\", (request, socket, head) => {\n // Block traversal in upgrade requests (raw + encoded)\n if (containsTraversal(request.url ?? \"\")) {\n rejectUpgrade(socket, 400);\n return;\n }\n\n if (!isUpgradePath(options.listenUrl, request)) {\n rejectUpgrade(socket, 404);\n return;\n }\n\n wsServer.handleUpgrade(request, socket, head, (client) => {\n wsServer.emit(\"connection\", client, request);\n });\n });\n\n await new Promise<void>((resolvePromise, rejectPromise) => {\n server.once(\"error\", rejectPromise);\n server.listen(port, host, () => {\n server.off(\"error\", rejectPromise);\n console.log(\n `[auth-gateway] listening ${options.listenUrl} -> ${options.upstreamUrl}`,\n );\n resolvePromise();\n });\n });\n\n return {\n server,\n close() {\n return new Promise<void>((resolvePromise) => {\n server.close(() => {\n wsServer.close(() => resolvePromise());\n });\n });\n },\n };\n}\n\nfunction isDirectExecution(): boolean {\n const entry = process.argv[1];\n if (!entry) return false;\n return import.meta.url === pathToFileURL(resolve(entry)).href;\n}\n\nif (isDirectExecution()) {\n main().catch((error) => {\n console.error(\n error instanceof Error ? (error.stack ?? error.message) : String(error),\n );\n process.exit(1);\n });\n}\n","import * as net from \"node:net\";\nimport type { AppServerState } from \"../types.js\";\nimport { getWebSocketCtor, delay } from \"./bridge-port-network.js\";\n\nexport interface WebSocketLike {\n addEventListener(\n type: \"open\" | \"error\" | \"close\",\n listener: () => void,\n options?: { once?: boolean },\n ): void;\n close(code?: number, reason?: string): void;\n}\n\nexport type WebSocketCtor = new (\n url: string,\n protocols?: string | string[],\n) => WebSocketLike;\n\nexport const APP_SERVER_HEALTH_TIMEOUT_MS = 1_500;\nexport const APP_SERVER_HEALTH_RETRY_MS = 250;\nexport const APP_SERVER_READYZ_PATH = \"/readyz\";\n\nexport const AUTH_SUBPROTOCOL_PREFIX = \"tap-auth-\";\n\nexport type AppServerReadyzStatus = \"ready\" | \"not-ready\" | \"unsupported\";\n\nexport async function checkAppServerHealth(\n url: string,\n timeoutMs: number = APP_SERVER_HEALTH_TIMEOUT_MS,\n gatewayToken?: string | null,\n): Promise<boolean> {\n const WebSocket = getWebSocketCtor();\n if (!WebSocket) {\n return false;\n }\n\n return new Promise<boolean>((resolve) => {\n let settled = false;\n let socket: WebSocketLike | null = null;\n\n const finish = (healthy: boolean) => {\n if (settled) {\n return;\n }\n settled = true;\n clearTimeout(timer);\n try {\n socket?.close();\n } catch {\n // Best-effort cleanup only.\n }\n resolve(healthy);\n };\n\n const timer = setTimeout(() => finish(false), timeoutMs);\n\n try {\n // Authenticate via WebSocket subprotocol when a gateway token is provided.\n const protocols = gatewayToken\n ? [`${AUTH_SUBPROTOCOL_PREFIX}${gatewayToken}`]\n : undefined;\n socket = new WebSocket(url, protocols);\n socket.addEventListener(\"open\", () => finish(true), { once: true });\n socket.addEventListener(\"error\", () => finish(false), { once: true });\n socket.addEventListener(\"close\", () => finish(false), { once: true });\n } catch {\n finish(false);\n }\n });\n}\n\nexport async function waitForAppServerHealth(\n url: string,\n timeoutMs: number,\n gatewayToken?: string | null,\n): Promise<boolean> {\n const deadline = Date.now() + timeoutMs;\n\n while (Date.now() < deadline) {\n if (\n await checkAppServerHealth(\n url,\n APP_SERVER_HEALTH_TIMEOUT_MS,\n gatewayToken,\n )\n ) {\n return true;\n }\n await delay(APP_SERVER_HEALTH_RETRY_MS);\n }\n\n return false;\n}\n\nexport function buildAppServerReadyzUrl(url: string): string | null {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n\n if (parsed.protocol === \"ws:\") {\n parsed.protocol = \"http:\";\n } else if (parsed.protocol === \"wss:\") {\n parsed.protocol = \"https:\";\n } else if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return null;\n }\n\n parsed.pathname = APP_SERVER_READYZ_PATH;\n parsed.search = \"\";\n parsed.hash = \"\";\n return parsed.toString();\n}\n\nexport async function checkAppServerReadyz(\n url: string,\n timeoutMs: number = APP_SERVER_HEALTH_TIMEOUT_MS,\n): Promise<AppServerReadyzStatus> {\n const readyzUrl = buildAppServerReadyzUrl(url);\n if (!readyzUrl) {\n return \"unsupported\";\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n\n try {\n const response = await fetch(readyzUrl, {\n method: \"GET\",\n signal: controller.signal,\n headers: {\n accept: \"application/json\",\n },\n });\n\n if (response.ok) {\n return \"ready\";\n }\n\n if (\n response.status === 400 ||\n response.status === 404 ||\n response.status === 405 ||\n response.status === 426 ||\n response.status === 501\n ) {\n return \"unsupported\";\n }\n\n return \"not-ready\";\n } catch {\n return \"not-ready\";\n } finally {\n clearTimeout(timer);\n }\n}\n\n/**\n * Check if a TCP port is accepting connections (without WebSocket upgrade).\n * Use this for managed startup health checks to avoid creating app-server sessions.\n */\nexport async function checkTcpPortListening(\n url: string,\n timeoutMs: number = APP_SERVER_HEALTH_TIMEOUT_MS,\n): Promise<boolean> {\n let hostname: string;\n let port: number;\n try {\n const parsed = new URL(url.replace(/^ws/, \"http\"));\n hostname = parsed.hostname;\n port = parseInt(parsed.port, 10);\n } catch {\n return false;\n }\n if (!port || !Number.isFinite(port)) return false;\n\n return new Promise<boolean>((resolve) => {\n const socket = net.createConnection({ host: hostname, port });\n const timer = setTimeout(() => {\n socket.destroy();\n resolve(false);\n }, timeoutMs);\n\n socket.once(\"connect\", () => {\n clearTimeout(timer);\n socket.destroy();\n resolve(true);\n });\n socket.once(\"error\", () => {\n clearTimeout(timer);\n socket.destroy();\n resolve(false);\n });\n });\n}\n\n/**\n * Wait for a TCP port to start accepting connections.\n * Does NOT open a WebSocket, so no app-server session is created.\n */\nexport async function waitForTcpPortListening(\n url: string,\n timeoutMs: number,\n): Promise<boolean> {\n const deadline = Date.now() + timeoutMs;\n\n while (Date.now() < deadline) {\n if (await checkTcpPortListening(url, APP_SERVER_HEALTH_TIMEOUT_MS)) {\n return true;\n }\n await delay(APP_SERVER_HEALTH_RETRY_MS);\n }\n\n return false;\n}\n\nexport async function checkManagedAppServerReady(\n url: string,\n timeoutMs: number = APP_SERVER_HEALTH_TIMEOUT_MS,\n): Promise<boolean> {\n const readyzStatus = await checkAppServerReadyz(url, timeoutMs);\n if (readyzStatus === \"ready\") {\n return true;\n }\n\n if (readyzStatus === \"unsupported\") {\n return checkTcpPortListening(url, timeoutMs);\n }\n\n return false;\n}\n\nexport async function waitForManagedAppServerReady(\n url: string,\n timeoutMs: number,\n): Promise<boolean> {\n const deadline = Date.now() + timeoutMs;\n\n while (Date.now() < deadline) {\n const remaining = Math.max(\n 1,\n Math.min(APP_SERVER_HEALTH_TIMEOUT_MS, deadline - Date.now()),\n );\n if (await checkManagedAppServerReady(url, remaining)) {\n return true;\n }\n await delay(APP_SERVER_HEALTH_RETRY_MS);\n }\n\n return false;\n}\n\nexport function markAppServerHealthy(\n appServer: AppServerState,\n): AppServerState {\n const checkedAt = new Date().toISOString();\n return {\n ...appServer,\n healthy: true,\n lastCheckedAt: checkedAt,\n lastHealthyAt: checkedAt,\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAIK;AACP,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AAExB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,WAAW,uBAAqC;;;ACXzD,YAAY,SAAS;AAkBd,IAAM,+BAA+B;AAErC,IAAM,yBAAyB;AA0E/B,SAAS,wBAAwB,KAA4B;AAClE,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,GAAG;AAAA,EACtB,QAAQ;AACN,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,aAAa,OAAO;AAC7B,WAAO,WAAW;AAAA,EACpB,WAAW,OAAO,aAAa,QAAQ;AACrC,WAAO,WAAW;AAAA,EACpB,WAAW,OAAO,aAAa,WAAW,OAAO,aAAa,UAAU;AACtE,WAAO;AAAA,EACT;AAEA,SAAO,WAAW;AAClB,SAAO,SAAS;AAChB,SAAO,OAAO;AACd,SAAO,OAAO,SAAS;AACzB;AAEA,eAAsB,qBACpB,KACA,YAAoB,8BACY;AAChC,QAAM,YAAY,wBAAwB,GAAG;AAC7C,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,IAAI,gBAAgB;AACvC,QAAM,QAAQ,WAAW,MAAM,WAAW,MAAM,GAAG,SAAS;AAE5D,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,WAAW;AAAA,MACtC,QAAQ;AAAA,MACR,QAAQ,WAAW;AAAA,MACnB,SAAS;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAED,QAAI,SAAS,IAAI;AACf,aAAO;AAAA,IACT;AAEA,QACE,SAAS,WAAW,OACpB,SAAS,WAAW,OACpB,SAAS,WAAW,OACpB,SAAS,WAAW,OACpB,SAAS,WAAW,KACp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