@mylasecurity/gate 0.2.1 → 0.3.1

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 (3) hide show
  1. package/README.md +63 -41
  2. package/bin/gate.mjs +1906 -31
  3. package/package.json +15 -3
package/README.md CHANGED
@@ -1,63 +1,85 @@
1
1
  # @mylasecurity/gate
2
2
 
3
- One command to put the Myla Gate in front of a coding agent. It fetches a one-time claim, **merges**
4
- its hooks into your per-user settings file (never replaces the file), **backs up first**, writes
5
- atomically, and prints exactly what it changed — so a non-developer never has to find a hidden folder
6
- or merge JSON by hand.
3
+ Put the [Myla](https://mylasecurity.app) Gate in front of the AI agents on your machine, so a tool
4
+ call is judged before it runs instead of explained afterwards.
7
5
 
8
- ```
6
+ Two ways in, depending on what the agent is:
7
+
8
+ ```bash
9
+ # A coding agent (Claude Code, Cursor, Codex): merges the Gate into its hooks
9
10
  npx @mylasecurity/gate install <claim-code>
11
+
12
+ # Any MCP client (Claude Desktop and friends): puts the Gate in front of its MCP servers
13
+ npx @mylasecurity/gate mcp install <claim-code>
10
14
  ```
11
15
 
16
+ The claim code comes from Myla, where you add the agent. It works once. Everything else the command
17
+ needs, it works out for itself: there is no folder to find and no JSON to merge by hand.
18
+
19
+ ## What it does to your machine
20
+
21
+ * It **merges**, never replaces. Your own hooks, and hooks pointing anywhere else, are kept.
22
+ * It **backs up every file before it changes it**, and writes atomically.
23
+ * It **prints exactly what it changed**, file by file and server by server.
24
+ * A reinstall is idempotent: a previous Myla entry is replaced, not duplicated.
25
+ * If a file it needs is not valid JSON, it stops, names the problem, and changes nothing.
26
+ * It **never prints your credential**: not in `--dry-run`, not in an error, not in `doctor`. The
27
+ credential is stored owner-read only in your home folder, and never passed on a command line,
28
+ where any process on the machine could read it.
29
+
12
30
  ## Commands
13
31
 
14
32
  | Command | What it does |
15
33
  | --- | --- |
16
- | `install <code>` | The whole job: fetch → validate → back up → merge → write → report. Also reports any **other** Myla configs it finds in the places the client reads (project/ancestor/managed), without touching them. |
17
- | `install <code> --dry-run` | Fetch, validate, print exactly what *would* be written and where. Writes nothing. The config is printed with the credential **masked**. |
18
- | `doctor` | Check the hook is installed, which host it points at, and — with one **read-only** authenticated call to the Gate — whether the token is actually **recognised** (a reissue/revoke leaves a config pointing at a dead token while calls still return 200). Also reports any other Myla configs on the machine. Writes nothing; the token is sent only in the auth header, never printed. |
19
- | `uninstall` | Remove **only** Myla's hook entries, keep everything else, back up first. |
34
+ | `install <code>` | Put the Gate in front of a coding agent: fetch, validate, back up, merge, write, report. Also names any other Myla config it finds on the machine, without touching it. |
35
+ | `install <code> --dry-run` | Print exactly what would be written, with the credential masked. Writes nothing. |
36
+ | `doctor` | Is the hook installed, which host does it point at, and does the Gate still recognise the token? One read-only call. Writes nothing. |
37
+ | `uninstall` | Remove only Myla's hook entries, backing up first. |
38
+ | `mcp` | What is behind the Gate on this machine and what is not, per app, with the files it read. Read-only. |
39
+ | `mcp install <code>` | Put every MCP server configured in Claude Desktop, Claude Code and Cursor behind the Gate, as its own agent. |
40
+ | `mcp uninstall` | Put those servers back exactly as they were. |
41
+ | `offline on` | Keep deciding when Myla cannot be reached (see below). `offline off` explains the way back. |
42
+ | `sync` | Hand over anything decided offline, and take a fresh copy of the rules. |
43
+ | `log` | What this machine decided and the rules it used. Reads only your home folder, works with no network. `--html` writes a self-contained page. |
44
+ | `serve` | The same, live, as a page at `127.0.0.1`. Nothing leaves the machine. |
45
+ | `ask` | Ask about one call from any agent: `{"tool","args"}` on stdin, a verdict on stdout. For scripts and agents with no hooks. |
20
46
 
21
- ### Flags
47
+ Flags: `--client claude-code|cursor|codex` (default `claude-code`), `--origin <url>` to install
48
+ against a staging deployment, `--dry-run`, `--help`.
22
49
 
23
- - `--client claude-code\|cursor\|codex` — which agent (default `claude-code`).
24
- - `--origin <url>` — which Myla deployment (default the production host). Needed to install against a
25
- staging or local deployment.
26
- - `--dry-run` — `install`/`uninstall`: don't write, just show.
50
+ ## When the network is gone
27
51
 
28
- ## Guarantees
52
+ By default every decision is Myla's: the hook asks her and waits. `offline on` adds the Gate itself
53
+ to the machine, and from then on:
29
54
 
30
- - **It never prints the credential.** Not in `--dry-run`, not in an error, not in `doctor`. The mask is
31
- the install sheet's own `CONFIG_TOKEN_MASK`, reused — there is no second masker.
32
- - **It never drops a hook you wrote.** A hook entry is removed only when every URL inside it points at
33
- the Myla origin. Your own hooks, and hooks pointing anywhere else, are kept.
34
- - **It never clobbers a malformed file.** If the settings file isn't valid JSON, it stops, names the
35
- line, and changes nothing — no write, no backup.
36
- - **A reinstall is idempotent.** A prior Myla block is replaced, not duplicated.
55
+ 1. Myla is still asked first, with a short timeout. Her answer wins whenever she can be reached.
56
+ 2. When she cannot, the signed copy of the rules on the machine decides, instead of the call going
57
+ through unchecked.
58
+ 3. What was decided offline is recorded there and handed over on the next `sync`, marked as having
59
+ been decided on the machine.
37
60
 
38
- ## Running it before it's published
61
+ The rules are signed and have a life of their own: past it, a decision made from them is marked
62
+ stale rather than presented as current. `gate log` and `gate serve` read that record with no
63
+ network at all, so the one moment you most want to see what your agents did is not the moment the
64
+ product stops working.
39
65
 
40
- This package is **not published to npm** (that's the owner's call, a separate step). Until it is, run it
41
- from the repo. It has no dependencies.
66
+ The cost, plainly: for Claude Code, the hook today is an HTTP call and nothing runs on your machine.
67
+ `offline on` runs a command on every tool call instead. For Cursor and Codex the hook already runs a
68
+ command, so it swaps one for another.
42
69
 
43
- ```bash
44
- # From the repo root — same tsx the rest of the repo's scripts use:
45
- npx tsx packages/gate-cli/src/cli.ts install <claim-code>
46
- npx tsx packages/gate-cli/src/cli.ts install <claim-code> --dry-run
47
- npx tsx packages/gate-cli/src/cli.ts doctor
48
- ```
70
+ ## Requirements
49
71
 
50
- Or build the standalone, dependency-free bin and run that:
72
+ Node 18 or newer. No dependencies, and no network access except to your Myla deployment.
51
73
 
52
- ```bash
53
- cd packages/gate-cli && npm run build # esbuild → bin/gate.mjs (a single file, no node_modules)
54
- node packages/gate-cli/bin/gate.mjs doctor
55
- ```
74
+ ## Developing
56
75
 
57
- `bin/gate.mjs` is a build artifact (git-ignored); regenerate it with `npm run build`. The source in
58
- `src/` is the single source of truth, and the tests run against the source, not the bundle.
76
+ The source in `src/` is the single source of truth. `bin/gate.mjs` is a build artifact
77
+ (git-ignored, rebuilt on publish):
59
78
 
60
- ## Tests
79
+ ```bash
80
+ cd packages/gate-cli && npm run build # esbuild, one file, no node_modules
81
+ node bin/gate.mjs doctor
82
+ ```
61
83
 
62
- Fixture-driven, offline, no real credential: `scripts/security-gate-cli-test.ts`, wired as
63
- `npm run check:gate-cli` and picked up by `npm run check:all`.
84
+ Tests are fixture-driven and offline, and run against the source rather than the bundle:
85
+ `npm run check:gate-cli`, `check:offline`, `check:offline-view`, `check:ask`, `check:mcp-proxy`.