umans-gate 0.1.2 → 0.1.5

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 (59) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/LICENSE +1 -1
  3. package/README.md +258 -48
  4. package/npm-shim.cjs +71 -0
  5. package/package.json +16 -80
  6. package/dashboard/dist/assets/alert-dialog-DlhAyxD3.js +0 -2
  7. package/dashboard/dist/assets/alert-dialog-DlhAyxD3.js.map +0 -1
  8. package/dashboard/dist/assets/clear-confirm-dialog-BOcl93wD.js +0 -2
  9. package/dashboard/dist/assets/clear-confirm-dialog-BOcl93wD.js.map +0 -1
  10. package/dashboard/dist/assets/config-tab-pnBjiSyC.js +0 -4
  11. package/dashboard/dist/assets/config-tab-pnBjiSyC.js.map +0 -1
  12. package/dashboard/dist/assets/economics-tab-BJXa5ydD.js +0 -2
  13. package/dashboard/dist/assets/economics-tab-BJXa5ydD.js.map +0 -1
  14. package/dashboard/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  15. package/dashboard/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  16. package/dashboard/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  17. package/dashboard/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  18. package/dashboard/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  19. package/dashboard/dist/assets/headers-viewer-C9FKdG-_.js +0 -2
  20. package/dashboard/dist/assets/headers-viewer-C9FKdG-_.js.map +0 -1
  21. package/dashboard/dist/assets/index-72wCsW4_.js +0 -3
  22. package/dashboard/dist/assets/index-72wCsW4_.js.map +0 -1
  23. package/dashboard/dist/assets/index-DFhG4t-C.css +0 -1
  24. package/dashboard/dist/assets/json-viewer-CXkZMoVn.js +0 -2
  25. package/dashboard/dist/assets/json-viewer-CXkZMoVn.js.map +0 -1
  26. package/dashboard/dist/assets/mode-toggle-BxkGFiYG.js +0 -2
  27. package/dashboard/dist/assets/mode-toggle-BxkGFiYG.js.map +0 -1
  28. package/dashboard/dist/assets/models-tab-Deqk3WT3.js +0 -2
  29. package/dashboard/dist/assets/models-tab-Deqk3WT3.js.map +0 -1
  30. package/dashboard/dist/assets/performance-meter-Bd152C4C.js +0 -2
  31. package/dashboard/dist/assets/performance-meter-Bd152C4C.js.map +0 -1
  32. package/dashboard/dist/assets/select-mZPf2BR3.js +0 -2
  33. package/dashboard/dist/assets/select-mZPf2BR3.js.map +0 -1
  34. package/dashboard/dist/assets/sheet-BgQXtbdw.js +0 -2
  35. package/dashboard/dist/assets/sheet-BgQXtbdw.js.map +0 -1
  36. package/dashboard/dist/assets/sonner-DGu1DGeO.js +0 -2
  37. package/dashboard/dist/assets/sonner-DGu1DGeO.js.map +0 -1
  38. package/dashboard/dist/assets/sse-viewer-BHnn3FcY.js +0 -3
  39. package/dashboard/dist/assets/sse-viewer-BHnn3FcY.js.map +0 -1
  40. package/dashboard/dist/assets/use-capture-done-listener-u5RxfYQP.js +0 -2
  41. package/dashboard/dist/assets/use-capture-done-listener-u5RxfYQP.js.map +0 -1
  42. package/dashboard/dist/assets/use-models-B4MLkfpt.js +0 -2
  43. package/dashboard/dist/assets/use-models-B4MLkfpt.js.map +0 -1
  44. package/dashboard/dist/assets/use-polling-resource-D_vWHFwW.js +0 -2
  45. package/dashboard/dist/assets/use-polling-resource-D_vWHFwW.js.map +0 -1
  46. package/dashboard/dist/assets/vendor-CVKsgXJU.js +0 -312
  47. package/dashboard/dist/assets/vendor-CVKsgXJU.js.map +0 -1
  48. package/dashboard/dist/assets/vendor-DtX4s2-2.css +0 -1
  49. package/dashboard/dist/assets/vendor-react-Dtud3GyP.js +0 -41
  50. package/dashboard/dist/assets/vendor-react-Dtud3GyP.js.map +0 -1
  51. package/dashboard/dist/assets/vision-calls-BquNiDzm.js +0 -3
  52. package/dashboard/dist/assets/vision-calls-BquNiDzm.js.map +0 -1
  53. package/dashboard/dist/index.html +0 -34
  54. package/dist/cli.d.ts +0 -1
  55. package/dist/cli.js +0 -6788
  56. package/dist/cli.js.map +0 -1
  57. package/dist/index.d.ts +0 -1094
  58. package/dist/index.js +0 -6443
  59. package/dist/index.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,205 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.5] - 2026-07-14
11
+
12
+ ### Added
13
+
14
+ - **Service persistence** (`umans-gate service`): install, uninstall,
15
+ start, stop, restart, status, and logs subcommands for running
16
+ umans-gate as a managed service that starts on boot and survives
17
+ restarts. Platform support:
18
+ - **Linux**: systemd user unit with `enable-linger` for boot-start
19
+ without login. `Restart=always` for crash recovery. `EnvironmentFile`
20
+ with `chmod 600` for API key (never inline).
21
+ - **macOS**: launchd LaunchAgent with `RunAtLoad=true` and
22
+ `KeepAlive=true` for unconditional restart (including dashboard
23
+ Restart button).
24
+ - **Windows**: Windows Service via NSSM (bundled in win32 platform
25
+ packages) with `SERVICE_AUTO_START` and 10 MB log rotation.
26
+ - Service PATH includes common runtime directories (`~/.bun/bin`,
27
+ `/opt/homebrew/bin`, `/usr/local/bin`, etc.) so the shebang resolves
28
+ in minimal-PATH service environments.
29
+ - Pre-install validation: config validation + port availability check
30
+ before writing service files.
31
+ - `npx` detection: `service install` from npx throws a clear error
32
+ with install instructions.
33
+ - `umans-gate update` now stops the service before updating and
34
+ restarts it after.
35
+ - `umans-gate uninstall` removes the service before cleaning up the
36
+ binary.
37
+ - Standalone binary self-update: `umans-gate update` auto-downloads
38
+ and replaces the binary from the latest GitHub Release (previously
39
+ only printed the URL).
40
+ - Dashboard Restart button works automatically when running as a
41
+ managed service.
42
+
43
+ ### Fixed
44
+
45
+ - **launchd KeepAlive**: changed from conditional dict
46
+ (`SuccessfulExit=false, Crashed=true`) to unconditional `true` so
47
+ the dashboard Restart button works on macOS (previously only worked
48
+ on Linux via `Restart=always`).
49
+ - **NSSM bundling**: `scripts/pack-npm.sh` now downloads and includes
50
+ `nssm.exe` in `@codegiveness/umans-gate-win32-*` packages so
51
+ `service install` works on Windows out of the box.
52
+ - **ESM compliance**: replaced `require("node:fs")` / `require("node:net")`
53
+ calls in `installer.ts` and `updater.ts` with static imports.
54
+
55
+ ## [0.1.4] - 2026-07-14
56
+
57
+ ### Changed
58
+
59
+ - **npm package naming**: platform binary packages renamed from unscoped
60
+ `umans-gate-<target>` to scoped `@codegiveness/umans-gate-<target>`
61
+ (e.g. `@codegiveness/umans-gate-darwin-arm64`). This follows the
62
+ industry convention used by `@esbuild/*`, `@rollup/rollup-*`, and
63
+ `@swc/core-*` for platform-specific binary packages. The main package
64
+ `umans-gate` is unchanged — `optionalDependencies` now reference the
65
+ scoped packages.
66
+ - **npm-shim.cjs**: updated binary resolution paths to find
67
+ `@codegiveness/umans-gate-<target>` in `node_modules/@codegiveness/`.
68
+ - **pack-npm.sh**: main package now includes README.md, LICENSE, and
69
+ CHANGELOG.md in the published files so npm registry pages display
70
+ the current README. Added keywords, homepage, and bugs fields to
71
+ the generated package.json.
72
+ - **Release workflow**: publish step globs updated to
73
+ `release/npm/@codegiveness/umans-gate-*/`.
74
+
75
+ ### Fixed
76
+
77
+ - **Release workflow awk extraction**: the awk command extracting per-version
78
+ release notes from CHANGELOG.md self-terminated on the matching header line,
79
+ producing only `## [VERSION] - DATE` as release notes. Fixed with corrected
80
+ awk logic that extracts the full version section body.
81
+ - **CodeQL workflow efficiency**: added `paths-ignore` for markdown, docs, and
82
+ LICENSE files — CodeQL no longer runs on doc-only changes (matching CI
83
+ workflow behavior).
84
+ - **CI workflow professionalization**: split monolithic CI into `quality` job
85
+ (typecheck + lint + build, 3-OS matrix: ubuntu/macos/windows) and `test` job
86
+ (ubuntu-only). Dropped Bun 1.1.0 from matrix (caused 158 test failures on
87
+ ubuntu). Added dashboard asset build step before tests (`src/embedded-assets.ts`
88
+ has static imports to gitignored `dashboard/dist/`). Replaced fragile
89
+ `sleep(900)` in test helper with health-check polling (`GET /health`).
90
+ Added `--timeout 30000` to test command (bunfig.toml `timeout` key is not
91
+ respected by Bun).
92
+ - **Stuck master CI runs**: `cancel-in-progress` was only enabled for
93
+ `pull_request` events — a stuck `in_progress` run held the concurrency
94
+ group lock indefinitely, blocking all master push runs (stayed `pending`
95
+ with 0 jobs). Fixed: `cancel-in-progress: true` for all events.
96
+ - **CI permissions hardening**: added `permissions: contents: read`
97
+ (least-privilege) and `timeout-minutes: 15` to both CI jobs.
98
+ - **Dependabot hardening**: configured major-version bump ignores for
99
+ critical dependencies (commander, lru-cache, @types/bun, react, react-dom,
100
+ lucide-react, @types/react, @types/react-dom, vite, tailwind-merge, sonner,
101
+ typescript, @vitejs/plugin-react, @base-ui/react). Closed 13 dangerous
102
+ major-bump PRs.
103
+ - **Release workflow**: `--notes-file CHANGELOG.md` dumped the entire
104
+ changelog as release notes — now extracts only the matching version
105
+ section. Added `--frozen-lockfile` to all `bun install` steps. Added
106
+ `timeout-minutes: 20` to prevent hung release builds.
107
+ - **Test helper singleton race condition**: `echo-upstream.ts` used a
108
+ module-level singleton server that would break under parallel test
109
+ execution. Refactored to per-instance servers with explicit lifecycle
110
+ management.
111
+ - **CI dependency drift**: added `--frozen-lockfile` to all `bun install`
112
+ steps in CI to fail fast on lockfile drift.
113
+ - **Stale draft releases**: deleted 5 stale draft releases from failed
114
+ release workflow runs.
115
+
116
+ ### Added
117
+
118
+ - **Branch protection** on master: requires 4 CI checks (Quality
119
+ ubuntu/macos/windows + Tests), 1 code-owner review, linear history,
120
+ stale review dismissal, no force pushes.
121
+ - **Repo settings professionalized**: squash-only merges, delete-branch-on-merge,
122
+ wiki disabled, discussions disabled, secret scanning enabled, push protection
123
+ enabled.
124
+ - **CODEOWNERS** (`.github/CODEOWNERS`) for automated review routing.
125
+ - **Dependabot update grouping**: minor and patch updates are now grouped into
126
+ a single PR per ecosystem (root npm, dashboard npm) to reduce PR noise.
127
+
128
+ ### Changed
129
+
130
+ - **ROADMAP**: updated Current State from v0.1.0 → v0.1.3 with npm distribution,
131
+ self-update, platform binaries, and provenance as completed items. Added
132
+ umans-open-stack cross-reference section.
133
+ - **CONTRIBUTING.md / GOVERNANCE.md**: fixed `main` → `master` branch references.
134
+ - **PRODUCT.md**: repositioned from "Bun-based" to "npm-installable (powered by Bun)"
135
+ with npm-first success criteria.
136
+ - **TROUBLESHOOTING.md**: added npm-first user commands alongside dev commands.
137
+ - **bug_report.yml**: added install method field (npm/npx/standalone/source); Bun
138
+ version now conditional on dev-from-source only.
139
+ - **ci.yml**: removed stale `main` from branch triggers (only `master` exists).
140
+ - **package.json keywords**: expanded from 10 → 18 keywords for npm discoverability
141
+ (added `claude`, `prompt-engineering`, `observability`, `sqlite`, `bun`,
142
+ `developer-tools`, `api-proxy`, `prompt-caching`).
143
+ - **ARCHITECTURE.md**: added umans-open-stack cross-reference with
144
+ playbook-to-implementation mapping table.
145
+
146
+ ### Security
147
+
148
+ - **SECURITY.md**: added account security section — 2FA requirement for npm
149
+ publisher + GitHub org admins, token rotation policy, quarterly access review.
150
+
151
+ ## [0.1.3] - 2026-07-14
152
+
153
+ ### Fixed
154
+
155
+ - **npm package republish**: v0.1.2 was published via the now-deleted
156
+ `publish.yml` workflow (raw `npm publish` on repo `package.json`), which
157
+ shipped `dist/cli.js` with a `#!/usr/bin/env bun` shebang and `engines: { bun:
158
+ ">=1.1.0" }` — **requiring Bun to run**. This contradicted the "no
159
+ prerequisites" promise. v0.1.3 republishes via `release.yml` which runs
160
+ `scripts/pack-npm.sh` to produce the correct shim-based package (`bin:
161
+ npm-shim.cjs` + 6 platform `optionalDependencies` with pre-compiled
162
+ standalone binaries). `npx umans-gate` now works without Bun installed.
163
+ - **ARCHITECTURE.md**: fixed wrong file paths in umans-open-stack mapping table
164
+ (`src/gate.ts` → `src/limiter/gate.ts`, `src/vision.ts` → `src/vision/handoff.ts`).
165
+ - **README.md**: removed misleading `.env.example` reference (file only has
166
+ `UMANS_API_KEY=`; reworded to reference config variables generally).
167
+ - **README.md**: fixed `vision_*` incorrectly listed as hot-reloadable — moved
168
+ to `restartRequired` (matches `RESTART_REQUIRED_FIELDS` in `src/config.ts`).
169
+ - **SECURITY.md**: softened "SLSA Level 3 provenance" to "npm provenance
170
+ attestation" for accuracy and consistency with ROADMAP.md.
171
+ - **docs/proxy-modifications.md**: fixed stale "24h TTL" → "7-day TTL" and
172
+ "transcoded to JPEG" → "transcoded to the configured format (PNG/JPEG)".
173
+ - **AGENTS.md**: fixed stale config field names `target` (removed from config)
174
+ and `stamp_cache_ttl` (replaced by `stamp_claude_code_enabled`).
175
+ - **CHANGELOG.md**: removed duplicate entries between [Unreleased] and [0.1.3].
176
+ - **MAINTAINERS.md**: populated template with actual maintainer (`@codegiveness`).
177
+ - **Startup banner** (`src/banner.ts`): version is now read from `package.json`
178
+ instead of being hardcoded at `v0.1.0`. Every prior release printed the wrong
179
+ version on startup.
180
+ - **`clean` script** (`package.json`): `capture.db` → `umans-gate.db` (3 file
181
+ suffixes). `bun run clean` now correctly removes the actual database.
182
+ - **`biome.json`**: `capture.db*` → `umans-gate.db*` (stale entry from DB rename).
183
+ - **ARCHITECTURE.md**: fixed ASCII diagram alignment after `capture.db` →
184
+ `umans-gate.db` rename (SQLite box widened to fit text, `┴` connector
185
+ aligned with proxy box `┬` above).
186
+ - **Benchmark result files**: untracked 36 stale files across three benchmark
187
+ directories (`benchmark/vision-handoff/results/`, `benchmark/proxy-optimizations/results/`,
188
+ and `benchmark/concurrency-gate/results.json`) — they contained old
189
+ `umans-ai/umans-gate` URLs in vision-test descriptions and a partially-redacted
190
+ API key (`sk-f1qgI...tmJI`). Updated `.gitignore` to also match `results.json`
191
+ files directly in benchmark directories (not just `results/` subdirectories).
192
+ - **README badge**: removed misleading "Runtime: Bun" badge (contradicts "No
193
+ prerequisites for npm/npx"). Added CodeQL badge.
194
+ - **CI lint failures**: added `src/embedded-assets.ts` to `biome.json` ignore
195
+ list (generated file with long import lines that Biome wanted to reformat).
196
+ Auto-fixed `package.json` `files` array formatting (Biome wanted inline).
197
+ These two pre-existing lint errors caused ALL CI runs and ALL Dependabot PRs
198
+ to fail.
199
+ - **Release workflow resilience**: `release.yml` now retries each npm publish
200
+ step 3 times with 15s delays. Platform package publish failures no longer
201
+ block the main shim from publishing (previously `win32-arm64` spam detection
202
+ failure prevented the entire release).
203
+
204
+ ### Added
205
+
206
+ - **CodeQL code scanning** (`.github/workflows/codeql.yml`) — weekly automated
207
+ security analysis for JavaScript/TypeScript.
208
+
10
209
  ## [0.1.2] - 2026-07-14
11
210
 
12
211
  ### Fixed
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Umans AI
3
+ Copyright (c) 2025 codegiveness
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,25 +1,35 @@
1
1
  # umans-gate
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/umans-gate.svg)](https://www.npmjs.com/package/umans-gate)
4
+ [![npm downloads](https://img.shields.io/npm/dm/umans-gate.svg)](https://www.npmjs.com/package/umans-gate)
4
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Runtime: Bun](https://img.shields.io/badge/Runtime-Bun-fbf0df.svg)](https://bun.sh)
6
- [![CI](https://github.com/umans-ai/umans-gate/actions/workflows/ci.yml/badge.svg)](https://github.com/umans-ai/umans-gate/actions/workflows/ci.yml)
6
+ [![CI](https://github.com/codegiveness/umans-gate/actions/workflows/ci.yml/badge.svg)](https://github.com/codegiveness/umans-gate/actions/workflows/ci.yml)
7
+ [![CodeQL](https://github.com/codegiveness/umans-gate/actions/workflows/codeql.yml/badge.svg)](https://github.com/codegiveness/umans-gate/actions/workflows/codeql.yml)
7
8
 
8
- > **Disclaimer:** This is a community project. The author is not an official
9
- > Umans developer just a contributor building tools around the Umans API.
10
- > "umans" and related marks belong to their respective owners.
9
+ > A capture proxy for LLM APIs. Point your harness at it, and every
10
+ > request/response is stored in SQLite with a live inspection dashboard.
11
+ >
12
+ > **Personal-use project.** This software is intended for personal use
13
+ > only. It is a community contribution and is not affiliated with,
14
+ > endorsed by, or an official product of Umans.
11
15
 
12
- LLM capture proxy with Anthropic `cache_control` TTL stamping, vision handoff,
13
- concurrency gating, rate limiting, and a live inspection dashboard.
16
+ **Setup in 30 seconds.**
14
17
 
15
- Point your LLM harness at `http://localhost:1945`, and every request/response is
16
- captured to SQLite with a live WebSocket-updating inspector UI at
17
- `http://localhost:1945/dashboard/`.
18
+ ```bash
19
+ npx umans-gate
20
+ ```
21
+
22
+ That's it. The proxy starts on `http://localhost:1945` and the inspector
23
+ dashboard opens at `http://localhost:1945/dashboard/`. Point any
24
+ Anthropic or OpenAI-compatible harness at the proxy URL — every
25
+ request and response is captured automatically.
18
26
 
19
27
  ## Table of Contents
20
28
 
21
- - [Features](#features)
29
+ - [Install](#install)
22
30
  - [Quick Start](#quick-start)
31
+ - [Updating](#updating)
32
+ - [Service Persistence](#service-persistence)
23
33
  - [Configuration](#configuration)
24
34
  - [Config Fields](#config-fields)
25
35
  - [Hot Reload and Restart](#hot-reload-and-restart)
@@ -32,50 +42,221 @@ captured to SQLite with a live WebSocket-updating inspector UI at
32
42
  - [Development](#development)
33
43
  - [Project Structure](#project-structure)
34
44
  - [Documentation](#documentation)
45
+ - [Related Projects](#related-projects)
35
46
  - [Contributing](#contributing)
36
47
  - [License](#license)
37
48
 
38
- ## Features
39
-
40
- - **Capture proxy**: intercepts all LLM API traffic (Anthropic, OpenAI-compatible) and stores it in SQLite with optional zstd compression
41
- - **Stamp pipeline**: unified stamping orchestrator that applies TTL, `top_k`, `max_tokens`, `thinking`, `output_config`, `context_management`, and `temperature` stamps in the correct order — toggled by a single `stamp_claude_code_enabled` switch
42
- - **Vision handoff**: replaces image blocks with text descriptions generated by a vision model (`umans-flash`), enabling text-only models to "see" images. Descriptions are cached (7-day TTL) with persistent SQLite storage
43
- - **Concurrency gate**: semaphore + circuit breaker with intention-based reservations (main vs vision), hard cap, soft limit driven by `/v1/usage`, queue timeout, and over-subscription fallback
44
- - **Rate limiting**: sliding-window weighted rate limiter for pro-tier request limits, auto-derived from `/v1/usage` or explicitly configured
45
- - **Connection warmer**: periodic `/v1/models` pings keep TLS warm, skipping when real traffic occurred recently
46
- - **Usage tracking**: fetches and reconciles `/v1/usage` to size concurrency limits, detect rate-boxing, and manage priority demotion
47
- - **Live inspector dashboard**: React + shadcn/ui dashboard with WebSocket live updates
48
- - **SSE rendering**: streaming responses are captured and rendered with expandable event previews
49
- - **Ring buffer storage**: keeps the last N captures (default 200) with WAL mode SQLite
50
- - **Write-behind queue**: batched database writes to minimize blocking during streaming
51
- - **Worker-based capture pipeline**: offloads capture writes to a worker thread for non-blocking streaming
52
- - **Hop-by-hop header stripping**: correct HTTP proxy behavior
53
- - **Protocol flexibility**: configurable upstream HTTP/1.1 (default) or HTTP/2
49
+ ## Install
54
50
 
55
- ## Quick Start
51
+ **npm (recommended for end users):**
56
52
 
57
53
  ```bash
58
- # Install
59
- bun install
54
+ npm install -g umans-gate
55
+ umans-gate
56
+ ```
57
+
58
+ **npx (no install, run once):**
59
+
60
+ ```bash
61
+ npx umans-gate
62
+ ```
60
63
 
61
- # Start the proxy (reads config.json + env overrides)
64
+ **Bun (for developers):**
65
+
66
+ ```bash
67
+ git clone https://github.com/codegiveness/umans-gate.git
68
+ cd umans-gate
69
+ bun install
62
70
  bun src/cli.ts
71
+ ```
72
+
73
+ > **No prerequisites for npm/npx.** The npm package bundles a pre-compiled
74
+ > standalone binary for your platform. For development from source,
75
+ > [Bun](https://bun.sh) ≥ 1.1.0 is required.
76
+
77
+ ### Platform Support
78
+
79
+ Pre-compiled binaries are published for:
80
+
81
+ | OS | Architecture | npm Package |
82
+ |----|-------------|-------------|
83
+ | macOS | arm64 (Apple Silicon) | `umans-gate-darwin-arm64` |
84
+ | macOS | x64 (Intel) | `umans-gate-darwin-x64` |
85
+ | Linux | x64 | `umans-gate-linux-x64` |
86
+ | Linux | arm64 | `umans-gate-linux-arm64` |
87
+ | Windows | x64 | `umans-gate-win32-x64` |
88
+ | Windows | arm64 | `umans-gate-win32-arm64` |
89
+
90
+ The main `umans-gate` package automatically detects your platform and
91
+ installs the correct binary.
92
+
93
+ ## Quick Start
94
+
95
+ 1. **Start the proxy:**
96
+
97
+ ```bash
98
+ umans-gate
99
+ ```
100
+
101
+ 2. **Point your harness** to `http://localhost:1945` as the base URL:
102
+
103
+ ```bash
104
+ # Anthropic API
105
+ export ANTHROPIC_BASE_URL=http://localhost:1945
106
+
107
+ # OpenAI-compatible API
108
+ export OPENAI_BASE_URL=http://localhost:1945
109
+ ```
110
+
111
+ 3. **Open the inspector dashboard** at `http://localhost:1945/dashboard/`
112
+
113
+ Every request and response is captured to SQLite with live WebSocket
114
+ updates. The dashboard shows full request/response bodies, streaming
115
+ SSE events, timing, token economics, and more.
116
+
117
+ 4. **Set your API key** (optional but recommended):
118
+
119
+ ```bash
120
+ # Option A: environment variable
121
+ export UMANS_API_KEY=your-key-here
122
+
123
+ # Option B: config.json (persists across restarts)
124
+ umans-gate config show # see current config + file path
125
+ # Edit config.json and set "umans_api_key"
126
+ # Or use the dashboard Config tab at /dashboard/
127
+ ```
128
+
129
+ Setting `UMANS_API_KEY` enables `/v1/usage` polling, concurrency gate
130
+ sizing, rate-limit validation, and vision handoff.
131
+
132
+ ### What It Does
133
+
134
+ | Feature | Description |
135
+ |---------|-------------|
136
+ | **Capture proxy** | Intercepts all LLM API traffic (Anthropic, OpenAI-compatible) and stores it in SQLite with optional zstd compression |
137
+ | **Stamp pipeline** | Applies TTL, `top_k`, `max_tokens`, `thinking`, `output_config`, `context_management`, and `temperature` stamps — toggled by a single switch |
138
+ | **Vision handoff** | Replaces image blocks with text descriptions from a vision model, enabling text-only models to "see" images. Descriptions are cached (7-day TTL) with persistent SQLite storage |
139
+ | **Concurrency gate** | Semaphore + circuit breaker with intention-based reservations, hard cap, soft limit driven by `/v1/usage`, queue timeout, and over-subscription fallback |
140
+ | **Rate limiting** | Sliding-window weighted rate limiter for pro-tier request limits, auto-derived from `/v1/usage` or explicitly configured |
141
+ | **Connection warmer** | Periodic `/v1/models` pings keep TLS warm, skipping when real traffic occurred recently |
142
+ | **Usage tracking** | Fetches and reconciles `/v1/usage` to size concurrency limits, detect rate-boxing, and manage priority demotion |
143
+ | **Live inspector** | React + shadcn/ui dashboard with WebSocket live updates |
144
+ | **SSE rendering** | Streaming responses are captured and rendered with expandable event previews |
145
+ | **Ring buffer storage** | Keeps the last N captures (default 200) with WAL mode SQLite |
146
+ | **Write-behind queue** | Batched database writes to minimize blocking during streaming |
147
+ | **Worker-based capture** | Offloads capture writes to a worker thread for non-blocking streaming |
148
+ | **Hop-by-hop header stripping** | Correct HTTP proxy behavior |
149
+ | **Protocol flexibility** | Configurable upstream HTTP/1.1 (default) or HTTP/2 |
150
+
151
+ ## Updating
152
+
153
+ ```bash
154
+ umans-gate update # self-update (npm global or standalone binary)
155
+ ```
63
156
 
64
- # Or after build:
65
- bun run build
66
- ./dist/cli.js
157
+ The updater detects your install method (npm global, standalone
158
+ executable, or dev) and performs the appropriate action. For npm global
159
+ installs, it runs `npm update -g umans-gate`. For standalone binaries,
160
+ it auto-downloads and replaces the binary from the latest GitHub Release.
161
+ If the proxy is running as a managed service, the updater stops the
162
+ service before updating and restarts it after.
163
+
164
+ To check for updates without installing:
165
+
166
+ ```bash
167
+ umans-gate update --check
168
+ ```
169
+
170
+ ### Uninstall
171
+
172
+ ```bash
173
+ umans-gate uninstall # removes service, config, database, and binary
174
+ ```
175
+
176
+ The uninstaller first removes any installed service (systemd, launchd,
177
+ or Windows service) before cleaning up the binary and config. Pass
178
+ `--keep-config` to preserve `config.json` and the database.
179
+
180
+ Or manually:
181
+
182
+ ```bash
183
+ npm uninstall -g umans-gate
184
+ rm -rf ~/.config/umans-gate
185
+ ```
186
+
187
+ ## Service Persistence
188
+
189
+ `umans-gate` can install itself as a managed service that starts on boot
190
+ and survives restarts — no external process manager required.
191
+
192
+ ### Install as a service
193
+
194
+ ```bash
195
+ umans-gate service install
196
+ ```
197
+
198
+ This creates a platform-appropriate service definition, enables it for
199
+ auto-start on boot, and starts it immediately:
200
+
201
+ | Platform | Service manager | Unit location |
202
+ |----------|----------------|---------------|
203
+ | Linux | systemd (user unit + linger) | `~/.config/systemd/user/umans-gate.service` |
204
+ | macOS | launchd (LaunchAgent) | `~/Library/LaunchAgents/com.umans.gate.plist` |
205
+ | Windows | Windows Service (via NSSM) | Registered with `sc.exe` |
206
+
207
+ The service runs with `WorkingDirectory` set to your home directory and
208
+ uses the same `config.json` as a foreground run. If an API key is set
209
+ via environment variable (not in config.json), it is stored securely:
210
+ systemd uses a separate `EnvironmentFile` with `chmod 600`; launchd
211
+ stores it in the plist (also `chmod 600`); NSSM stores it in the
212
+ Windows service registry. The key is never inlined in the systemd unit
213
+ file.
214
+
215
+ Use `--force` to overwrite an existing service definition:
216
+
217
+ ```bash
218
+ umans-gate service install --force
219
+ ```
220
+
221
+ ### Service lifecycle commands
222
+
223
+ ```bash
224
+ umans-gate service start # start the service
225
+ umans-gate service stop # stop the service
226
+ umans-gate service restart # restart the service
227
+ umans-gate service status # show service status (running, PID, uptime)
228
+ umans-gate service logs # tail service logs (follow mode)
229
+ umans-gate service logs -f # same as above (alias)
230
+ umans-gate service uninstall # stop, disable, and remove the service
67
231
  ```
68
232
 
69
- Point your harness base URL to `http://localhost:1945` and open the inspector at `http://localhost:1945/dashboard/`.
233
+ ### How it works
234
+
235
+ - **Linux**: A systemd user unit with `Restart=always` and
236
+ `loginctl enable-linger` so the service starts at boot without needing
237
+ to log in. The PATH includes common runtime directories (`/usr/local/bin`,
238
+ `~/.bun/bin`, `/opt/homebrew/bin`, etc.) so the shebang resolves.
239
+ - **macOS**: A launchd LaunchAgent with `RunAtLoad=true` and
240
+ `KeepAlive=true` for unconditional restart. Loaded via `launchctl load`.
241
+ - **Windows**: A Windows Service registered via NSSM (bundled in the
242
+ win32 platform package) with `SERVICE_AUTO_START` for boot-start and
243
+ automatic log rotation at 10 MB.
244
+
245
+ ### Dashboard restart button
246
+
247
+ When running as a managed service, the dashboard's **Restart** button
248
+ (`POST /dashboard/api/restart`) works automatically — the service
249
+ manager restarts the process after `process.exit(0)` thanks to
250
+ `Restart=always` / `KeepAlive`.
70
251
 
71
252
  ## Configuration
72
253
 
73
- > **⚠️ Dashboard-first:** The recommended way to change configuration is via
254
+ > **Dashboard-first:** The recommended way to change configuration is via
74
255
  > the **Config** tab in the dashboard at `http://localhost:1945/dashboard/`.
75
256
  > Editing `config.json` directly works, but the dashboard validates against
76
- > the upstream `/v1/usage` hard cap, shows field descriptions, and can hot-reload
77
- > or restart the server for you. If you do edit the file, restart the server
78
- > afterward (the dashboard auto-reloads on save).
257
+ > the upstream `/v1/usage` hard cap, shows field descriptions, and can
258
+ > hot-reload or restart the server for you. If you do edit the file,
259
+ > restart the server afterward (the dashboard auto-reloads on save).
79
260
 
80
261
  Configuration is loaded from a JSON file with environment variable overrides.
81
262
 
@@ -92,8 +273,8 @@ On first run, `loadConfig()` writes a `config.json` with defaults to the
92
273
  resolved path if it does not already exist. Existing configs are never
93
274
  overwritten.
94
275
 
95
- All env vars from `.env.example` have JSON equivalents using `snake_case`
96
- (e.g., `UPSTREAM_PROTOCOL` → `upstream_protocol`).
276
+ All configuration variables have JSON equivalents using `snake_case`
277
+ (e.g., `UPSTREAM_PROTOCOL` → `upstream_protocol` in `config.json`).
97
278
 
98
279
  ### Config Fields
99
280
 
@@ -149,13 +330,15 @@ hardcoded — not configurable.
149
330
 
150
331
  The dashboard's Config tab can save changes and trigger a hot reload
151
332
  via `POST /dashboard/api/config/reload`. Hot-reloadable fields (e.g.
152
- `stamp_claude_code_enabled`, `breaker_*`, `rate_limit_*`, `vision_*`)
333
+ `stamp_claude_code_enabled`, `breaker_*`, `rate_limit_*`)
153
334
  apply live; fields marked `restartRequired` (e.g. `port`, `db_path`,
154
- `upstream_protocol`) require a server restart.
335
+ `upstream_protocol`, `vision_*`) require a server restart.
155
336
 
156
337
  The dashboard also has a **Restart** button (`POST /dashboard/api/restart`)
157
- that calls `process.exit(0)`. This requires an external process manager
158
- to restart the server automatically:
338
+ that calls `process.exit(0)`. When running as a managed service
339
+ (`umans-gate service install`), the service manager restarts the
340
+ process automatically. Without a service manager, you need an external
341
+ process watcher:
159
342
 
160
343
  | Manager | Command |
161
344
  |---------|---------|
@@ -302,6 +485,7 @@ umans-gate/
302
485
  │ ├── model-policy.ts # model-aware stamping decisions
303
486
  │ ├── compress.ts # zstd body compression
304
487
  │ ├── vision-description-store.ts # persistent vision description storage
488
+ │ ├── updater.ts # self-update logic
305
489
  │ ├── helpers.ts # shared utilities
306
490
  │ ├── logger.ts # structured scoped logging
307
491
  │ ├── banner.ts # startup banner
@@ -318,7 +502,7 @@ umans-gate/
318
502
  │ │ ├── persistent-cache.ts # SQLite-backed description cache
319
503
  │ │ ├── transcode.ts # image transcoding
320
504
  │ │ ├── wrapper.ts # description wrapper + policy
321
- │ │ └── sink.ts # vision record sink
505
+ │ │ └── sink.ts # vision record sink
322
506
  │ ├── workers/ # worker-based capture pipeline
323
507
  │ └── shared/ # extracted domain helpers
324
508
  ├── dashboard/ # React + shadcn/ui dashboard
@@ -327,22 +511,33 @@ umans-gate/
327
511
  │ ├── ARCHITECTURE.md # system architecture
328
512
  │ ├── TROUBLESHOOTING.md # troubleshooting guide
329
513
  │ ├── BENCHMARKS.md # benchmark results
514
+ │ ├── PRODUCT.md # product positioning and users
330
515
  │ └── proxy-modifications.md # proxy modification inventory
331
- ├── benchmark/ # benchmark scripts + results
516
+ ├── benchmark/ # benchmark scripts
332
517
  ├── .github/ # issue templates, workflows, PR template
333
518
  └── dist/ # build output (gitignored)
334
519
  ```
335
520
 
336
521
  ## Documentation
337
522
 
523
+ - [Documentation Index](docs/README.md) — curated reading guide
338
524
  - [Architecture](docs/ARCHITECTURE.md) — system design and data flow
339
525
  - [Proxy Modifications](docs/proxy-modifications.md) — complete inventory of proxy modifications
340
526
  - [Troubleshooting](docs/TROUBLESHOOTING.md) — common issues and solutions
341
527
  - [Benchmarks](docs/BENCHMARKS.md) — benchmark methodology and results
528
+ - [Product](docs/PRODUCT.md) — product positioning and target users
342
529
  - [Dashboard Design System](dashboard/DESIGN.md) — design system documentation
343
530
  - [Changelog](CHANGELOG.md) — version history
344
531
  - [Contributing](CONTRIBUTING.md) — how to contribute
345
532
  - [Roadmap](ROADMAP.md) — future plans
533
+ - [Security Policy](SECURITY.md) — vulnerability reporting and security practices
534
+
535
+ ## Related Projects
536
+
537
+ - **[umans-open-stack](https://github.com/umans-ai/umans-open-stack)** — A
538
+ curated set of open source playbooks and tools tested with Umans. umans-gate
539
+ implements several patterns documented there: concurrency gating, vision
540
+ handoff, cache_control TTL stamping, and workflow orchestration.
346
541
 
347
542
  ## Contributing
348
543
 
@@ -351,4 +546,19 @@ testing, and release instructions.
351
546
 
352
547
  ## License
353
548
 
354
- MIT
549
+ MIT — see [LICENSE](LICENSE).
550
+
551
+ ## Usage Rights
552
+
553
+ This is a **personal-use project**. The source code is published under the MIT
554
+ license for transparency and educational purposes. While the MIT license
555
+ technically permits commercial use and redistribution, this project is not
556
+ actively maintained as a product and is not intended for production deployment.
557
+
558
+ **This is a community contribution and is not an official Umans product.**
559
+ It is not affiliated with, endorsed by, or supported by Umans AI. All upstream
560
+ service names, model names, and API endpoints referenced in this codebase
561
+ belong to their respective owners.
562
+
563
+ Use it, learn from it, fork it — but don't expect official support or
564
+ warranties of any kind.