@oaksecurity/aitm 0.0.0-stage → 2.3.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 (63) hide show
  1. package/.env.example +11 -0
  2. package/CHANGELOG.md +100 -0
  3. package/LICENSE +21 -0
  4. package/README.md +229 -2
  5. package/SECURITY.md +49 -0
  6. package/SPEC.md +304 -0
  7. package/docs/api.md +332 -0
  8. package/docs/inputs-and-limits.md +78 -0
  9. package/docs/usage.md +351 -0
  10. package/examples/custody-architecture.md +27 -0
  11. package/package.json +67 -4
  12. package/src/api/server.js +591 -0
  13. package/src/api/web.js +38 -0
  14. package/src/application.js +32 -0
  15. package/src/assessments.js +37 -0
  16. package/src/assets/BDOGrotesk-Bold.ttf +0 -0
  17. package/src/assets/BDOGrotesk-Regular.ttf +0 -0
  18. package/src/assets/OFL.txt +93 -0
  19. package/src/assets/README.md +10 -0
  20. package/src/cli.js +224 -0
  21. package/src/client.js +88 -0
  22. package/src/config.js +105 -0
  23. package/src/doctor.js +128 -0
  24. package/src/engine/credentials.js +31 -0
  25. package/src/engine/download.js +135 -0
  26. package/src/engine/engine.js +783 -0
  27. package/src/engine/errors.js +23 -0
  28. package/src/engine/generation.js +121 -0
  29. package/src/engine/ingest.js +444 -0
  30. package/src/engine/pdf-layout.js +204 -0
  31. package/src/engine/pdf-report.js +573 -0
  32. package/src/engine/prompts.js +82 -0
  33. package/src/engine/providers.js +476 -0
  34. package/src/engine/references.js +112 -0
  35. package/src/engine/report.js +200 -0
  36. package/src/engine/schema.js +267 -0
  37. package/src/engine/store.js +115 -0
  38. package/src/engine/validate.js +397 -0
  39. package/src/engine/zip.js +70 -0
  40. package/src/index.js +5 -0
  41. package/src/source-input.js +32 -0
  42. package/src/token.js +59 -0
  43. package/src/tui/app.js +694 -0
  44. package/src/tui/editor.js +34 -0
  45. package/src/tui/file-picker.js +111 -0
  46. package/src/tui/logo.js +8 -0
  47. package/src/tui/progress.js +90 -0
  48. package/src/tui/report-reader.js +105 -0
  49. package/src/tui/select.js +63 -0
  50. package/src/tui/workbench.js +377 -0
  51. package/src/version.js +5 -0
  52. package/src/web/app.js +729 -0
  53. package/src/web/assets/BDOGrotesk-Bold.woff2 +0 -0
  54. package/src/web/assets/BDOGrotesk-Medium.woff2 +0 -0
  55. package/src/web/assets/BDOGrotesk-Regular.woff2 +0 -0
  56. package/src/web/assets/README.md +5 -0
  57. package/src/web/assets/aitm-mark.svg +12 -0
  58. package/src/web/assets/oak-white.svg +166 -0
  59. package/src/web/html.js +32 -0
  60. package/src/web/index.html +26 -0
  61. package/src/web/markdown.js +48 -0
  62. package/src/web/styles.css +1450 -0
  63. package/src/web/views.js +254 -0
package/.env.example ADDED
@@ -0,0 +1,11 @@
1
+ # Optional. The usual setup is `aitm configure`, which saves keys to
2
+ # ~/.config/aitm/keys.json (mode 600). Saved keys take precedence over this file.
3
+ # To use this file, copy it to .env.local in the directory where you start AiTM
4
+ # and run: chmod 600 .env.local
5
+ OPENAI_API_KEY=
6
+ ANTHROPIC_API_KEY=
7
+ # Required only for an Anthropic key that is not bound to one workspace.
8
+ # ANTHROPIC_WORKSPACE_ID=wrkspc_...
9
+ # Server settings, optional. The server binds to loopback only.
10
+ # AITM_DATA_DIR=/absolute/path/to/private/data
11
+ # AITM_PORT=8790
package/CHANGELOG.md ADDED
@@ -0,0 +1,100 @@
1
+ # Changelog
2
+
3
+ ## 2.3.0 (2026-11-26)
4
+
5
+ ### Added
6
+
7
+ - AiTM is on the npm registry. Install it with
8
+ `npm install --global @oaksecurity/aitm`. The README and the release procedure
9
+ in `CONTRIBUTING.md` describe the npm package and the release channels.
10
+
11
+ ### Changed
12
+
13
+ - **Breaking for library users:** the package name is now `@oaksecurity/aitm`
14
+ (was `@oak-security/aitm`), to agree with the npm organization. Change imports
15
+ to `@oaksecurity/aitm` and `@oaksecurity/aitm/client`. A release tarball is
16
+ now `oaksecurity-aitm-<version>.tgz`. The `aitm` command and the GitHub
17
+ repository do not change.
18
+ - `package.json` has a `repository` field and `publishConfig.access` is
19
+ `public`.
20
+
21
+ ## 2.2.0 (2026-11-26)
22
+
23
+ ### Changed
24
+
25
+ - **Breaking for API clients:** the scope and source inventory step is no longer
26
+ a review gate. A review run now goes through ingestion and stops first at the
27
+ TRACE model. An approval request for `scope` or `ingest` returns HTTP 409 with
28
+ code `no_review_gate`. A report no longer needs a scope approval to show as
29
+ reviewed.
30
+
31
+ ### Fixed
32
+
33
+ - The final message of a run now says what the run did. A single-step run (for
34
+ example ingestion) showed "Pipeline complete. Your report is ready." in the
35
+ browser. It now names the step, and a pause names the step to review.
36
+
37
+ - A new project now uses a provider that has a key. Before this change, each new
38
+ project used OpenAI, and a run failed with `missing_key` when only an Anthropic
39
+ key was configured.
40
+ - The `missing_key` message now names the provider that has a key and the
41
+ setting to change. It no longer refers to a terminal shortcut in the browser.
42
+ - The browser Settings page no longer shows a model form that cannot be saved
43
+ when no assessment is open. With an assessment open, it shows a warning while
44
+ the selected provider is not saved.
45
+
46
+ ## 2.1.0 (2026-11-26)
47
+
48
+ ### Security
49
+
50
+ - **Breaking for API clients:** each API request now needs a private access
51
+ token. Before this change, any process or user on the host could call the
52
+ loopback API, import local paths, export their content, replace provider keys
53
+ and start paid runs. Send `Authorization: Bearer "$(aitm token)"`. `ApiClient`
54
+ reads the token file by default. Browsers sign in through the URL that AiTM
55
+ prints.
56
+ - `GET /v1/health` no longer returns the PID or file paths. The new
57
+ authenticated `GET /v1/instance` returns them.
58
+
59
+ ### Added
60
+
61
+ - `aitm doctor [--live]` checks Node.js, Git, keys, storage and the port.
62
+ - `aitm token [--rotate]` prints or replaces the access token.
63
+ - `--allowed-host HOST:PORT` accepts an SSH forward to a different local port.
64
+ - Settings is available in the terminal project chooser (`s`). Before, it was
65
+ available only inside a project.
66
+ - With no provider key, the terminal interface and the browser workbench start
67
+ on Settings.
68
+ - `aitm serve` and `aitm web` print the source of each provider key.
69
+ - Requests to current Claude models opt in to Anthropic's server-side refusal
70
+ fallback, so a classifier decline does not stop a run. The run metadata
71
+ records the model that produced each result.
72
+ - `AITM_BROWSER_CHANNEL=chrome` runs the browser tests in an installed Chrome.
73
+
74
+ ### Changed
75
+
76
+ - Minimum Node.js is 22.12 (was 26.13). The npm version requirement is removed.
77
+ - Default models: OpenAI `gpt-6.2-sol` (fast) and `gpt-6.2-astra` (deep);
78
+ Anthropic `claude-sonnet-5-5` (fast) and `claude-opus-5-5` (deep). Saved
79
+ projects keep the models they have.
80
+ - Without an account model list, AiTM offers a catalog of four current models
81
+ for each provider. The OpenAI filter no longer lists the retired `o3` and
82
+ `o4` families.
83
+ - The CLI and API read the version from `package.json`.
84
+ - The README is short. The details moved to `docs/usage.md` and
85
+ `docs/inputs-and-limits.md`.
86
+
87
+ ### Removed
88
+
89
+ - `scripts/configure-keys.py`. Use `aitm configure`.
90
+ - `AGENT.md`, `docs/verification.md` and `docs/implementation-plan.md`.
91
+ `CONTRIBUTING.md` replaces them.
92
+
93
+ ### Fixed
94
+
95
+ - The browser test suite no longer hangs when the browser is not installed.
96
+
97
+ ## 2.0.0 (2026-10-30)
98
+
99
+ AiTM v2 replaced the desktop application with a local Node.js TRACE engine that
100
+ has a terminal interface, a browser workbench and an HTTP/SSE API in one process.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oak Security
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,230 @@
1
- # Temporary Holding Version
1
+ # AiTM: AI Threat Modeller
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ```text
4
+ _ ___ _____ __ __
5
+ / \ |_ _|_ _| \/ | o-----o
6
+ / _ \ | | | | | |\/| | |\ /|
7
+ / ___ \ | | | | | | | | | o-o |
8
+ /_/ \_\___| |_| |_| |_| o-----o
9
+ ```
10
+
11
+ A reusable engine for the [TRACE methodology](https://github.com/oak-security/TRACE/blob/main/METHODOLOGY.md),
12
+ with a terminal interface, a browser workbench and a local API.
13
+
14
+ AiTM was developed by Dr. Stefan Beyer as a reference implementation for
15
+ AI-assisted tooling that supports his TRACE threat hunting methodology.
16
+
17
+ Give AiTM a repository, a folder or design documents. It builds a TRACE model,
18
+ ranks STRIDE threats, draws attack trees for the top threats, analyses collusion,
19
+ and assembles a report with a mitigation roadmap. Each claim links to a source
20
+ quote. Each output is a draft until a person reviews it.
21
+
22
+ ## Install
23
+
24
+ AiTM needs [Node.js](https://nodejs.org) 22.12 or later. Git is needed only to
25
+ import repository URLs.
26
+
27
+ ```sh
28
+ npm install --global @oaksecurity/aitm
29
+ aitm doctor
30
+ ```
31
+
32
+ `aitm doctor` checks Node.js, Git, keys, storage and the port, and tells you what
33
+ to correct. If a global install needs root on your system, add
34
+ `--prefix "$HOME/.local"` to the command and put `~/.local/bin` on your `PATH`.
35
+
36
+ To get a new version, run `npm install --global @oaksecurity/aitm@latest`. To run
37
+ AiTM without an install, use `npx @oaksecurity/aitm`.
38
+
39
+ ### From a checkout
40
+
41
+ ```sh
42
+ git clone https://github.com/oak-security/aitm.git
43
+ cd aitm
44
+ npm ci
45
+ npm link
46
+ ```
47
+
48
+ `npm link` puts the `aitm` command on your `PATH` and points it at this checkout.
49
+ To run without a link, use `npm start` in the checkout. If `npm link` needs root
50
+ on your system, run `npm_config_prefix="$HOME/.local" npm link`.
51
+
52
+ ### From a release tarball
53
+
54
+ Each [GitHub release](https://github.com/oak-security/aitm/releases) has the
55
+ package tarball. It is the same file as the npm package.
56
+
57
+ ```sh
58
+ npm install --global ./oaksecurity-aitm-2.3.0.tgz
59
+ ```
60
+
61
+ Versions up to 2.2.0 had the package name `@oak-security/aitm`. If you installed
62
+ one of them, remove it first with `npm uninstall --global @oak-security/aitm`.
63
+ The two packages supply the same `aitm` command.
64
+
65
+ ## First run
66
+
67
+ ```sh
68
+ aitm configure # enter an OpenAI or Anthropic key (hidden input)
69
+ aitm # terminal interface
70
+ aitm web # browser workbench
71
+ ```
72
+
73
+ You can skip `aitm configure`. When no key is saved, each interface starts on
74
+ its Settings screen, where you can add one. You can create projects, import
75
+ sources and read saved reports without a key. A run needs the key of the
76
+ provider that the project uses.
77
+
78
+ Then:
79
+
80
+ 1. Create a project and give it a name. A scope is optional.
81
+ 2. Add sources: a local folder or file, a public repository URL, a document URL,
82
+ or a repository ZIP.
83
+ 3. Start **Run full pipeline** (`f` in the terminal).
84
+ 4. Read the report (`v`), then export Markdown, PDF or JSON (`x`).
85
+
86
+ Shortcuts for a single source:
87
+
88
+ ```sh
89
+ aitm ./my-repo # open or reopen a folder
90
+ aitm "./design notes.pdf" --full # import and run immediately
91
+ aitm web https://github.com/org/repository # public repository, in the browser
92
+ aitm --project PROJECT_ID # reopen a saved project
93
+ ```
94
+
95
+ AI runs send source content to the provider you select. Nothing leaves your
96
+ computer before you start a run.
97
+
98
+ ## Commands
99
+
100
+ | Command | Purpose |
101
+ | ----------------------- | ---------------------------------------------------------- |
102
+ | `aitm [source]` | Terminal interface, with the engine and API |
103
+ | `aitm web [source]` | Engine and API, then opens the browser workbench |
104
+ | `aitm serve` | Engine and API in the foreground, for scripts |
105
+ | `aitm configure` | Save provider keys with hidden prompts |
106
+ | `aitm doctor [--live]` | Check the setup. `--live` sends one small provider request |
107
+ | `aitm token [--rotate]` | Print, or replace, the private API access token |
108
+
109
+ Options: `--full`, `--project ID`, `--port NUMBER`, `--data-dir DIR`, `--no-open`,
110
+ `--allowed-host HOST:PORT`. Run `aitm --help` for details.
111
+
112
+ One process runs the engine, the API and the interface. `q` or Ctrl+C saves and
113
+ closes all of them. Completed steps stay saved; an unfinished step is cancelled
114
+ and resumes on the next run. There is no background daemon.
115
+
116
+ ## Keys and models
117
+
118
+ `aitm configure` and the Settings screens save keys to `~/.config/aitm/keys.json`
119
+ with mode 600. Environment variables (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`) and
120
+ a private `.env.local` also work; a saved key takes precedence. `aitm doctor`
121
+ shows which source is active.
122
+
123
+ | Provider | Fast model (intake, model, trees, report) | Deep model (STRIDE, coordination) |
124
+ | --------- | ----------------------------------------- | --------------------------------- |
125
+ | OpenAI | `gpt-6.2-sol` | `gpt-6.2-astra` |
126
+ | Anthropic | `claude-sonnet-5-5` | `claude-opus-5-5` |
127
+
128
+ Each project can select other models from your account's model list (`p` in the
129
+ terminal, **Settings & models** in the browser).
130
+
131
+ ## Access token
132
+
133
+ The API accepts only loopback connections, and each request must carry a private
134
+ access token. Without the token, another user or process on the same host could
135
+ read your files through source import.
136
+
137
+ - `aitm web` opens a URL that contains the token. The browser then keeps it in a
138
+ cookie, so a bookmark to `http://127.0.0.1:8790/` continues to work.
139
+ - Scripts send `Authorization: Bearer "$(aitm token)"`.
140
+ - The token is saved in `~/.config/aitm/token` (mode 600) and stays the same
141
+ across restarts. `aitm token --rotate` replaces it.
142
+
143
+ ## Headless server over SSH
144
+
145
+ On the server:
146
+
147
+ ```sh
148
+ aitm web --no-open
149
+ ```
150
+
151
+ On your computer, forward the port, then open the URL that the server printed:
152
+
153
+ ```sh
154
+ ssh -N -L 8790:127.0.0.1:8790 USER@SERVER
155
+ ```
156
+
157
+ If you forward to a different local port, tell AiTM to accept it:
158
+
159
+ ```sh
160
+ aitm web --no-open --allowed-host 127.0.0.1:9000 # server
161
+ ssh -N -L 9000:127.0.0.1:8790 USER@SERVER # your computer
162
+ ```
163
+
164
+ Then replace `8790` with `9000` in the printed URL.
165
+
166
+ ## Documentation
167
+
168
+ - [Usage guide](docs/usage.md): terminal and browser workflows, keys, storage, reports.
169
+ - [Inputs and limits](docs/inputs-and-limits.md): accepted sources, size caps, evidence checks.
170
+ - [API guide](docs/api.md): HTTP and SSE resources, with examples.
171
+ - [Specification](SPEC.md): the engine contract.
172
+ - [Security policy](SECURITY.md) and [changelog](CHANGELOG.md).
173
+ - [Contributing](CONTRIBUTING.md): development setup, tests and invariants.
174
+
175
+ ## Use the engine in your code
176
+
177
+ ```js
178
+ import { Engine, Providers, startServer } from '@oaksecurity/aitm';
179
+
180
+ const engine = await Engine.open({
181
+ dataDir: '/private/path/aitm',
182
+ providers: new Providers({ keys: { anthropic: process.env.ANTHROPIC_API_KEY } }),
183
+ });
184
+ const project = engine.create({ name: 'My system', config: { provider: 'anthropic' } });
185
+ await engine.addSource(project.id, { kind: 'local', path: '/path/to/source' });
186
+ engine.run(project.id, { mode: 'full' });
187
+
188
+ // Optional HTTP interface to the same engine. It returns its access token.
189
+ const api = await startServer(engine, { port: 8790 });
190
+ console.log(api.webUrl());
191
+ // On shutdown: await engine.close(); await api.close();
192
+ ```
193
+
194
+ HTTP clients can import `ApiClient` from `@oaksecurity/aitm/client`.
195
+
196
+ ## Releases
197
+
198
+ Each version is published in two places with the same content:
199
+
200
+ - npm: [`@oaksecurity/aitm`](https://www.npmjs.com/package/@oaksecurity/aitm).
201
+ - GitHub: a [release](https://github.com/oak-security/aitm/releases) with the tag
202
+ `vX.Y.Z` and the tarball `oaksecurity-aitm-X.Y.Z.tgz`.
203
+
204
+ The [changelog](CHANGELOG.md) lists the changes of each version. The npm
205
+ organization is `oaksecurity`. The GitHub organization is `oak-security`.
206
+ Versions up to 2.2.0 are not on npm.
207
+
208
+ To make sure that the two files are the same, compare the SHA-256 digest that
209
+ GitHub shows for the release asset with the digest of the npm file:
210
+
211
+ ```sh
212
+ npm pack @oaksecurity/aitm@2.3.0
213
+ shasum -a 256 oaksecurity-aitm-2.3.0.tgz
214
+ ```
215
+
216
+ The repository refuses force pushes to `main` and changes to `v*` tags, so a
217
+ published tag always points at the same commit. The release procedure is in
218
+ [CONTRIBUTING.md](CONTRIBUTING.md#releases).
219
+
220
+ ## License
221
+
222
+ [MIT](LICENSE). Copyright (c) 2026 Oak Security.
223
+
224
+ Bundled BDO Grotesk fonts retain their [SIL Open Font License 1.1](src/assets/OFL.txt)
225
+ and [font attribution](src/assets/README.md). Dependencies retain their licenses.
226
+ The TRACE methodology is by Dr. Stefan Beyer at Oak Security and has its own
227
+ [CC BY 4.0 license](https://github.com/oak-security/TRACE/blob/main/LICENSE.md).
228
+
229
+ Reports state that they were generated by AiTM using AI and that Oak Security
230
+ did not author, review or endorse them.
package/SECURITY.md ADDED
@@ -0,0 +1,49 @@
1
+ # Security policy
2
+
3
+ ## Report a vulnerability
4
+
5
+ Open a private security advisory in this repository on GitHub (Security →
6
+ Report a vulnerability). Do not open a public issue for a vulnerability.
7
+ Include the version (`aitm --version`), the steps to reproduce, and the impact.
8
+
9
+ Only the latest release gets security fixes.
10
+
11
+ ## Security model
12
+
13
+ AiTM is a local, single-user tool. It reads source material that you select and
14
+ sends it to the AI provider that you select when you start a run.
15
+
16
+ - **Network.** The server binds only to loopback. It rejects requests whose
17
+ `Host`, `Origin` or fetch metadata do not match its own address, which stops
18
+ cross-site requests and DNS rebinding.
19
+ - **Access token.** Each API request needs a random 256-bit token, as a bearer
20
+ token or as an `HttpOnly`, `SameSite=Strict` cookie. The token is saved in
21
+ `~/.config/aitm/token` with mode 600. This stops other users and processes of
22
+ the same host from using your instance. Source import reads local paths, so an
23
+ open loopback API would expose your files.
24
+ - **Credentials.** Provider keys are stored in plaintext files that only your OS
25
+ user can read. They are not encrypted. AiTM refuses a credential file that
26
+ other users can read, never returns a key through the API, and redacts keys
27
+ from errors and output.
28
+ - **Sources.** Ingestion is bounded. It skips symlinks, credential files and
29
+ dependencies, validates archive paths, and never executes source code or Git
30
+ hooks. The workbench renders source and model text as inert text.
31
+ - **Model output.** Source text is evidence, never instructions. A model can
32
+ still be wrong or be influenced by hostile source content. Each output is a
33
+ draft until a person reviews it.
34
+
35
+ ## Out of scope
36
+
37
+ - An attacker who already runs code as your OS user. That attacker can read the
38
+ token and key files.
39
+ - The data handling of the AI provider that you select.
40
+ - The correctness of AI analysis. Citations make claims traceable; they do not
41
+ make them true.
42
+
43
+ ## Known limits
44
+
45
+ - The launch URL contains the access token. It appears in the terminal and can
46
+ appear in the browser history. Do not share it. `aitm token --rotate` replaces
47
+ the token.
48
+ - Browsers scope cookies by host and not by port. Another service on
49
+ `127.0.0.1`, opened in the same browser, can receive the cookie.