@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
@@ -0,0 +1,78 @@
1
+ # Inputs and limits
2
+
3
+ This page lists the sources that AiTM accepts, the size caps, and the checks that
4
+ connect each claim to its evidence.
5
+
6
+ ## Accepted inputs
7
+
8
+ - Local folders/repositories and individual UTF-8 code, config, text, Markdown,
9
+ HTML, CSV, JSON, YAML, and other readable text files.
10
+ - PDF and DOCX documents; scanned/image-only documents need OCR or a transcription.
11
+ - Public HTTPS repositories on GitHub, GitLab and Bitbucket. A shallow clone is
12
+ pinned to a commit, snapshotted and deleted; no hooks or submodules are run.
13
+ Use a local checkout for private repositories or other Git hosts.
14
+ - Public HTTPS code/text, HTML pages, PDF, DOCX and ZIP URLs (8 MiB, 30 seconds,
15
+ three redirects). A page is preserved as HTML source; AiTM does not execute page
16
+ scripts, crawl links or fetch embedded documents. Use a direct PDF/DOCX link to
17
+ assess the document itself.
18
+ - Repository ZIPs from local files, browser uploads or public URLs. Archives have
19
+ an 8 MiB compressed limit, 32 MiB expanded limit and at most 10,000 entries.
20
+ Extraction rejects unsafe/ambiguous paths, encrypted entries and special files;
21
+ skips symlinks, credentials and dependencies; and honors nested `.gitignore`.
22
+ Temporary extraction files are removed. Nested archives are skipped.
23
+ - Inline text and file snapshots pushed over the API. A file snapshot may contain
24
+ UTF-8 text or base64 PDF/DOCX/ZIP data; replacing it invalidates dependent analysis.
25
+
26
+ Folder ingestion honors nested `.gitignore` rules and skips dependencies, generated
27
+ folders, credential filenames, symlinks and unsupported binaries. Caps are 8 MiB per
28
+ file, 32 MiB / 1,000 files per source and 100 sources / 2,000 files per project.
29
+ Extracted text is bounded to 8 million characters (8 × 1024²) per file and
30
+ 32 million (32 × 1024²) per source/project. Accepted files are stored in full;
31
+ oversized inputs produce an explicit error or a recorded folder-skip diagnostic,
32
+ never a truncated document. Scope shows import diagnostics, including unreadable
33
+ or skipped files. Inline API text is limited to 500,000 characters per request.
34
+
35
+ ## How the pipeline reads sources
36
+
37
+ Classification quickly identifies a provisional profile from the inventory and scope.
38
+ TRACE model construction then reads **all accepted source text**, in sequential
39
+ batches of up to 180,000 numbered source characters. Later batches return new or
40
+ changed objects; the engine retains earlier findings and validates the merged model.
41
+ The model is saved only after every batch finishes. STRIDE, attack trees,
42
+ coordination and the report reason from the completed artifacts, without rereading
43
+ the repository at every step. Seven source batches therefore require 12 normal
44
+ provider calls for a full run with coordination, rather than 36.
45
+
46
+ Cross-phase references are constrained to existing model IDs. Citation mismatches
47
+ and unresolved optional links become explicit review notes without regenerating
48
+ whole responses. Broken required relationships still get one bounded repair.
49
+ Progress shows the current source batch during model construction. Complete source
50
+ delivery does not guarantee that an AI identifies every issue.
51
+
52
+ ## Older snapshots
53
+
54
+ Older saved snapshots marked as truncated are refreshed from their original local
55
+ file or URL before a new run, and affected analysis is rebuilt. Old analysis made
56
+ from prompt excerpts is also rebuilt. Portable snapshots need their complete
57
+ originals supplied again if they were truncated. Until rebuilt, affected reports
58
+ show a brief incomplete-source notice. Routine import diagnostics are not repeated
59
+ in a generic report section; actual unresolved questions and unverified claims remain.
60
+
61
+ ## Evidence checks
62
+
63
+ Snapshots have file IDs, hashes and line references. Model claims need matching
64
+ source quotes or explicit assumptions. The engine validates object references,
65
+ STRIDE coverage of assets/invariants/edges, tree connectivity and roadmap links.
66
+ If a generated quote occurs exactly once in its cited file, the engine can correct
67
+ mistaken line numbers and records the correction in generation metadata. It never
68
+ fuzzy-matches invented quotes; ambiguous references are not accepted as verified
69
+ evidence. A citation problem gets one automatic correction attempt. If it remains
70
+ unresolved, the claim is explicitly marked **Evidence review required** and the
71
+ sequential pipeline continues. Valid citations stay attached; rejected quotes are
72
+ retained only in diagnostic metadata. Review notes appear in the TUI and reports
73
+ and carry into downstream analysis as uncertainty. Citation retries cannot discard
74
+ an otherwise usable draft.
75
+ Coverage links are computed from the threats' object references. Missing coverage
76
+ is explicitly flagged for review, and corrections are retained in generation metadata.
77
+ These checks establish traceability; they cannot establish whether an AI judgement
78
+ is correct. Source text is treated as evidence, never instructions.
package/docs/usage.md ADDED
@@ -0,0 +1,351 @@
1
+ # Usage guide
2
+
3
+ This guide covers the terminal interface, the browser workbench, keys, storage
4
+ and reports. For installation, see the [README](../README.md).
5
+
6
+ ## One process, two interfaces
7
+
8
+ | Command | Starts | Checkout equivalent |
9
+ | ------------ | -------------------------------------- | ------------------- |
10
+ | `aitm` | Terminal UI, engine and API | `npm start` |
11
+ | `aitm web` | Engine and API, then opens the browser | `npm run web` |
12
+ | `aitm serve` | Foreground engine and API | `npm run server` |
13
+
14
+ All three modes serve the browser workbench. Run one instance per data directory;
15
+ open its URL to add a browser client. Pass checkout-script arguments after
16
+ `--`, for example `npm run web -- --no-open`.
17
+
18
+ Start with the project chooser, or give one explicit source:
19
+
20
+ ```sh
21
+ aitm # create or open a project
22
+ aitm --project PROJECT_ID # reopen a saved project
23
+ aitm ./my-repo # directory
24
+ aitm "./design notes.pdf" # one file
25
+ aitm https://github.com/organisation/repo # public repository
26
+ aitm https://example.org/whitepaper.pdf # direct document URL
27
+ aitm ./my-repo --full # immediately run the full pipeline
28
+ ```
29
+
30
+ Starting without a source imports nothing. Create a named project, then add any
31
+ combination of public URLs, documents and repository ZIPs through **Add sources**.
32
+ Projects keep separate sources, settings, reviews and reports. **Open project**
33
+ lists saved assessments; switching projects leaves running jobs active.
34
+
35
+ The optional explicit path/URL shortcut names a new assessment from that source
36
+ or reopens the most recent saved project containing it. It uses the saved snapshot,
37
+ including reviews and completed steps. Press `u` to refresh local/URL sources, or
38
+ manage each source individually. Unchanged content preserves analysis; changes
39
+ invalidate dependent results. An import batch either succeeds in full or leaves
40
+ the project unchanged.
41
+
42
+ The local API is available at `http://127.0.0.1:8790` while AiTM is open. **`q` saves
43
+ and closes the TUI, engine and API.** An unfinished phase is cancelled; completed
44
+ steps remain saved for the next launch. Ctrl+C and SIGTERM also close gracefully.
45
+ There is no background daemon or separate attach/stop workflow.
46
+
47
+ ```sh
48
+ aitm serve # engine + API without a TUI
49
+ aitm --port 8791 --data-dir /path/to/private-data
50
+ ```
51
+
52
+ `aitm serve` runs in the foreground and can be supervised by a process manager.
53
+ The API is single-user and binds only to loopback. Only one process may own a data
54
+ directory. Existing v2 assessments remain compatible; API clients can still list,
55
+ import and manage saved assessments independently.
56
+
57
+ ## Access token
58
+
59
+ Each API request needs the private access token. The browser gets it from the
60
+ URL that AiTM prints, and then keeps it in an `HttpOnly`, `SameSite=Strict`
61
+ cookie. Scripts send it as a bearer token:
62
+
63
+ ```sh
64
+ curl -fsS -H "Authorization: Bearer $(aitm token)" http://127.0.0.1:8790/v1/projects
65
+ ```
66
+
67
+ The token is saved in `~/.config/aitm/token` with mode 600 (`XDG_CONFIG_HOME`
68
+ changes the base directory). It stays the same across restarts.
69
+ `aitm token --rotate` replaces it; restart running instances and open the new URL
70
+ in each browser. A browser that has no valid cookie gets a page with instructions
71
+ and no data. Only `GET /v1/health` and the static files of the workbench answer
72
+ without the token.
73
+
74
+ ## Check the setup
75
+
76
+ `aitm doctor` reports the Node.js version, Git, the source of each provider key,
77
+ the key and token files, the data directory and its lock, and the port. It makes
78
+ no provider request unless you add `--live`, which sends one small request to each
79
+ configured provider. The exit status is 1 when a check fails.
80
+
81
+ ## Web workflow
82
+
83
+ ```sh
84
+ aitm web # open the project chooser in your browser
85
+ aitm web ./my-repo # open or reopen this source
86
+ aitm web ./whitepaper.pdf --full # start the pipeline immediately
87
+ aitm web --no-open # print the URL without opening a browser
88
+ ```
89
+
90
+ ```sh
91
+ aitm web # open the project chooser in your browser
92
+ aitm web ./my-repo # open or reopen this source
93
+ aitm web ./whitepaper.pdf --full # start the pipeline immediately
94
+ aitm web --no-open # print the URL without opening a browser
95
+ ```
96
+
97
+ The web workbench runs on the same loopback API, normally on port 8790. AiTM
98
+ prints a URL that contains the private access token; open that URL the first time.
99
+ The browser then keeps the token in a cookie. The workbench is also available
100
+ while `aitm` or `aitm serve` is running: press `?` in the terminal interface to
101
+ show its URL.
102
+ There is no separate web service, frontend build or duplicate engine. Closing a
103
+ browser tab leaves jobs running; Ctrl+C in the owning terminal closes the engine.
104
+
105
+ The workbench follows the original application's black sidebar and light workspace,
106
+ BDO Grotesk typography, and gold/magenta accents:
107
+
108
+ 1. **New project** creates a named assessment with an optional scope; **Open project**
109
+ or the sidebar project list reopens saved work. In **Sources & Scope**, **Add sources**
110
+ opens a file dialog for multiple documents or ZIP repositories, or accepts public
111
+ URLs/local paths, one per line. Nothing is imported from an empty field. Add more
112
+ sources at any time; **Replace source**, **Remove**, and **Refresh snapshot** act
113
+ on the selected source. Browser uploads support 8 MiB per file and 11 MiB combined;
114
+ use separate batches or an explicit local folder path for larger collections.
115
+ 2. **Run full pipeline** stays in the top toolbar on every project view and autoruns
116
+ all TRACE steps with top-three attack trees. The import dialog also offers
117
+ **Run full pipeline after import**. **Overview** offers a separate run with
118
+ explicit review gates. The persistent status bar shows the current step, waiting
119
+ or receiving activity, elapsed time and output counts. **Run history** provides
120
+ durable events. Batch counts remain visible while classifying/analysing source
121
+ files, including while receiving output. Cancel, reload and resume preserve completed artifacts.
122
+ 3. Navigate **Sources & Scope → TRACE Model → STRIDE → Attack Trees → Coordination
123
+ → Report**. Browse complete source files with line numbers, inspect evidence
124
+ links, filter ranked threats, and expand AND/OR attack paths. Common object and
125
+ threat fields have form editors; **Edit draft** exposes the complete validated
126
+ artifact as JSON. Changed upstream artifacts invalidate dependent analysis.
127
+ 4. **Approve review** records approval with optional notes; no name is required. The first
128
+ review gate is the TRACE model. Scope and source classification need no approval. The engine enforces the same
129
+ sequential gates as the terminal/API. Full runs leave outputs as drafts.
130
+ 5. **Report** renders the complete Markdown with section links and a raw Markdown
131
+ view. Downloads of Markdown, PDF and project JSON are explicit; PDF is never
132
+ exported automatically. Reports identify AiTM as their generator and state that
133
+ Oak Security did not author, review or endorse them. Downloads go to your
134
+ browser's chosen download location. **Import project JSON** opens v2 project exports.
135
+ 6. **Settings & models** provides masked OpenAI/Anthropic key replacement,
136
+ provider/model dropdowns, connection tests, reasoning effort and optional phases.
137
+ Settings is also in the sidebar when no project is open, and it is the first
138
+ screen when no key is saved. Credentials use the same private settings store as the TUI. A key replacement
139
+ alone preserves analysis. Saving changed model/phase settings clears dependent
140
+ results. Unsaved forms survive live updates; concurrent edits return a conflict.
141
+
142
+ Navigation stays outside the scrolling report. On small screens, the menu button
143
+ opens the sidebar. The UI uses same-origin HTTP/SSE and bundled assets only; source
144
+ and model text cannot execute HTML or load remote images in the report viewer.
145
+
146
+ ### Headless Linux over SSH
147
+
148
+ On the server, run `aitm web --no-open`. On your own computer, open a separate
149
+ terminal and forward the port (replace `USER@SERVER` with your SSH login):
150
+
151
+ ```sh
152
+ ssh -N -L 8790:127.0.0.1:8790 USER@SERVER
153
+ ```
154
+
155
+ Keep both sessions open and open the printed URL in your local browser.
156
+ No browser or display server is needed on the Linux host. Local source paths refer
157
+ to files on that host; browser uploads come from your own computer. Ctrl+C in the
158
+ server's AiTM terminal saves and stops the instance. Closing only the tunnel or
159
+ browser leaves the server process running while its terminal session remains open.
160
+
161
+ AiTM rejects a `Host` header that is not its own loopback address and port. To
162
+ forward to a different local port, start AiTM with
163
+ `--allowed-host 127.0.0.1:LOCALPORT` (repeat the option for more names) and use
164
+ that port in the URL. Only loopback names are accepted. Other users of the server
165
+ cannot use your instance, because they do not have the access token.
166
+
167
+ ## Provide API keys
168
+
169
+ AiTM opens without a provider key. You can create projects, import sources, and
170
+ read or export existing results. When no key is saved, the terminal interface and
171
+ the browser workbench start on Settings; Escape continues without a key.
172
+ Starting analysis requires a key for the project's selected provider;
173
+ a missing key produces a configuration message before creating a run. With
174
+ `--full`, that error ends the launch. Use `aitm configure` first, or configure
175
+ credentials through Settings and then start the run.
176
+ A new project uses the first provider that has a key (OpenAI, then Anthropic).
177
+ Models belong to the project: if a project uses a provider that has no key, select
178
+ the other provider with `p` in the terminal, or in **Settings & models** in the
179
+ browser followed by **Save assessment settings**.
180
+
181
+ In the TUI press **`s`** for Settings, in the project chooser or inside a project.
182
+ Inside a project, choose **API keys**. Then select **OpenAI** or
183
+ **Anthropic** with Up/Down and Enter. Paste a new key into the masked field to add
184
+ or replace it. Enter with an empty key keeps the existing value; Escape cancels.
185
+ Keys are saved privately to `~/.config/aitm/keys.json` (mode 0600) and become active
186
+ immediately. `XDG_CONFIG_HOME` overrides the default `~/.config` base directory.
187
+ Updating a key does not clear assessment results or change the other
188
+ provider's key. The picker shows whether each provider is configured and where its
189
+ active key came from; it never displays the key itself.
190
+
191
+ Outside the TUI, `aitm configure` provides hidden prompts for both providers.
192
+ Leave either blank to keep its current key. Reopen an already-running application
193
+ after CLI changes, or use its Settings menu to update without restarting.
194
+
195
+ A private environment file also works. Copy `.env.example` to `.env.local` in the
196
+ directory where you start AiTM, add the keys, and run `chmod 600 .env.local`.
197
+ AiTM refuses a credential file that other users can read. These files are
198
+ plaintext protected by OS permissions, not encrypted vaults. Do not paste keys
199
+ into chat, project notes or code.
200
+
201
+ AiTM loads keys in this order: saved `keys.json` settings, `OPENAI_API_KEY` /
202
+ `ANTHROPIC_API_KEY` environment variables, and `.env.local` in its working directory
203
+ (falling back to the installed package root). A saved replacement takes precedence
204
+ so an old environment value cannot silently override it. Restart after editing
205
+ environment files manually. Only configuration
206
+ status is returned to clients; key values do not appear in projects, reports or logs.
207
+
208
+ For an Anthropic key that spans workspaces, enter its optional `wrkspc_...` workspace
209
+ ID on the next Settings screen, or set `ANTHROPIC_WORKSPACE_ID` in the environment.
210
+ Workspace-bound keys do not need this setting. Clearing the saved workspace field
211
+ also overrides any environment workspace setting.
212
+
213
+ ### Models
214
+
215
+ Defaults are `gpt-6.2-sol` (fast) and `gpt-6.2-astra` (deep) for OpenAI, and
216
+ `claude-sonnet-5-5` (fast) and `claude-opus-5-5` (deep) for Anthropic. STRIDE and
217
+ coordination use the deep slot; the other phases use the fast slot, which reads
218
+ all source text. Press **`p`** (or Settings → Provider & models) to
219
+ pick a provider, fast model and deep model from lists. Up/Down selects, Page Up/Down
220
+ scrolls longer lists, and Enter advances. Choices are saved together at the final
221
+ step; Escape cancels without changing the assessment. Lists load account models
222
+ through the provider's Models API. Without a key, or after a failed lookup, AiTM
223
+ offers its built-in catalog with a notice. Current saved model IDs remain selectable.
224
+ Changing models clears dependent analysis; selecting the same settings preserves it.
225
+ Press `e` on Scope for reasoning effort, optional phases and tree count. `V` tests the selected
226
+ provider with a small real request. Availability depends on your provider account.
227
+
228
+ Current Claude models have safety classifiers that can decline security analysis.
229
+ For Claude Opus 5 and 5.5, Claude Sonnet 5.5 and Claude Fable 5, AiTM opts in to
230
+ Anthropic's server-side fallback: a declined request runs again on the model that
231
+ Anthropic recommends, and the run log records the model that produced each result.
232
+
233
+ ## Terminal workflow
234
+
235
+ 1. Launch `aitm` to create/open a project. Press **`n`** for New project, **`o`** for
236
+ Projects, **`s`** for Settings (API keys), **`i`** to Add sources, or **`b`** to Manage sources. The import dialog
237
+ accepts a public URL, an explicit file/folder path, or browsed files. In the file
238
+ browser, Enter opens a folder/imports a file; Space marks multiple files, then
239
+ select **Import N selected files**. Escape cancels. The Projects menu also supports
240
+ rename, close, delete and importing a saved JSON project. `aitm <path-or-URL>`
241
+ and `aitm --project ID` remain direct shortcuts.
242
+ 2. Press **`f`: Run full pipeline** to generate TRACE, ranked STRIDE threats,
243
+ attack trees for the **top three threats**, applicable coordination analysis,
244
+ and the final report. Results remain drafts and the run does not pause for review.
245
+ Fewer than three threats produce one tree per threat.
246
+ 3. Use Up/Down to inspect each phase. For a run that pauses at human review gates,
247
+ press `r`; `a` approves with optional notes, then `r` continues. The first
248
+ gate is the TRACE model; Scope and Ingest need no approval. `e` opens
249
+ the selected artifact in `$VISUAL`, `$EDITOR`, or `vi`. On Scope it edits scope
250
+ and settings.
251
+ 4. Completed assessments open on the menu. Press **`v`: View Markdown** to open
252
+ the complete report; Escape returns to the menu. Use `j`/`k` to scroll,
253
+ Page Up/Down (or Space) to turn pages, `[`/`]` to jump sections, and Home/End to
254
+ reach the beginning/end. Up/Down still selects TRACE phases. The reader includes
255
+ the entire report, including sources, TRACE objects, threats, trees and reviews;
256
+ tables wrap as labelled records.
257
+ Viewing Markdown makes no AI calls and creates no export files.
258
+ 5. Press `x` to explicitly export Markdown, PDF or portable JSON. PDF is never
259
+ generated automatically. Choose the destination in the export form; the default
260
+ is `aitm-<project-id>-<timestamp>.<extension>` in the directory where you launched AiTM.
261
+ Exports refuse to overwrite
262
+ an existing file. Press `q` to save and quit; reopen the project to continue.
263
+
264
+ The five-line ASCII logo stays visible on new, running and completed assessments,
265
+ including 80×24 terminals. Shorter terminals use a compact identity. Report controls
266
+ stay above the scrolling content, including when reopening a saved report.
267
+
268
+ The progress panel stays above the assessment: active phase, completed-phase bar,
269
+ elapsed run/phase time, provider/model, and live output counts. It distinguishes
270
+ waiting for a provider, receiving output, validating, and retrying. The bar counts
271
+ ready phases; it is not a time estimate. `l` opens durable event history; `c` cancels
272
+ the job and preserves completed artifacts. Source loading also shows an activity
273
+ indicator, including when files are supplied on the command line.
274
+ The artifact pane follows each new TRACE stage automatically. You can still inspect
275
+ earlier stages with Up/Down. If a step pauses, `f` continues from the saved progress;
276
+ `l` shows its technical details.
277
+
278
+ Full pipeline resumes saved analysis. It enables attack trees with a limit of three
279
+ and enables automatic coordination when it was off. If existing trees do not meet
280
+ the top-three requirement, it rebuilds trees and downstream results while retaining
281
+ the TRACE model and STRIDE analysis. All outputs remain **DRAFT** until reviewed.
282
+
283
+ | Key | Action |
284
+ | ------------------------- | ------------------------------------------------------ |
285
+ | Up / Down | Select TRACE phase |
286
+ | `o` / `n` | Projects menu / new project |
287
+ | `i` / `b` | Add sources / manage individual sources |
288
+ | `j` / `k`, Page Down / Up | Scroll artifact |
289
+ | `f` | Run/resume full pipeline with top-three attack trees |
290
+ | `r` | Run/resume with human review gates |
291
+ | `a` / `e` | Approve / edit selected artifact; Scope edits settings |
292
+ | `u` | Refresh the source snapshot |
293
+ | `s` | Settings, including adding/replacing API keys |
294
+ | `p` / `V` | Provider/model lists / verify connection |
295
+ | `v` | View the full Markdown report in the TUI |
296
+ | `[` / `]`, Home / End | Report section navigation / first and last page |
297
+ | `x` | Export Markdown, PDF or JSON |
298
+ | `c` | Cancel run; keep completed phases |
299
+ | `l` / `?` | Run log / help |
300
+ | Esc | Close form or return to artifact |
301
+ | `q` | Save and quit the whole application |
302
+
303
+ Advanced controls in `?`: `g` regenerates the selected phase; `F` restarts the full
304
+ pipeline after typing `RESTART`, clearing generated analysis and reviews.
305
+
306
+ ## Storage
307
+
308
+ The [API guide](docs/api.md) includes examples. The running server exposes
309
+ `GET /v1/openapi.json` with request schemas and artifact schemas; progress is SSE
310
+ with replay through `Last-Event-ID` or `?after=`. Jobs are independent of client
311
+ connections. Restarting after a crash marks unfinished runs `interrupted`; resume
312
+ retries the unfinished phase using saved artifacts.
313
+
314
+ State defaults to `$XDG_DATA_HOME/aitm-v2`, or `~/.local/share/aitm-v2` when unset
315
+ (`AITM_DATA_DIR` / `--data-dir` override). `AITM_PORT` / `--port` overrides port 8790.
316
+ Each project is an atomic JSON document with source snapshots, artifacts, jobs,
317
+ usage and review history. A process lock prevents multiple writers. The directory
318
+ uses mode 0700, project files 0600. v2 does not read or modify the old desktop store.
319
+ JSON imports create a new project ID, use portable snapshots and require fresh reviews.
320
+ The report's artifacts live inside `<project-id>.json`; Markdown is assembled from
321
+ them when viewed. There is no automatic `.md` or `.pdf` export. Press `?` in the TUI
322
+ to see the actual storage directory, or `x` to save a separate report to a chosen
323
+ path. PDFs cached by earlier versions under `reports/` remain untouched.
324
+
325
+ Reports carry no hard-coded personal author name and state prominently:
326
+ **Generated by AiTM using AI. This report was not authored, reviewed or endorsed
327
+ by Oak Security.** Explicit human review entries are still recorded when supplied.
328
+
329
+ ```sh
330
+ AUTH="Authorization: Bearer $(aitm token)"
331
+ curl -fsS -H "$AUTH" 'http://127.0.0.1:8790/v1/projects/PROJECT_ID/report?format=markdown' -o report.md
332
+ curl -fsS -H "$AUTH" 'http://127.0.0.1:8790/v1/projects/PROJECT_ID/report?format=pdf' -o report.pdf
333
+ curl -fsS -H "$AUTH" http://127.0.0.1:8790/v1/projects/PROJECT_ID/export -o project.json
334
+ ```
335
+
336
+ ## PDF reports
337
+
338
+ PDF exports use a dedicated A4 layout with embedded BDO Grotesk, readable body
339
+ text, page numbers, clickable contents and PDF bookmarks. They include:
340
+
341
+ - An executive summary, a 5×5 likelihood/impact matrix and STRIDE category charts.
342
+ - Ranked threat details, connected attack-tree diagrams and coordination analysis
343
+ when those phases are enabled.
344
+ - A mitigation roadmap grouped into immediate, 30-, 60- and 90-day actions.
345
+ - The TRACE model, coverage, linked evidence quotes, source inventory and review record.
346
+
347
+ The evidence appendix preserves full cited quotes and source metadata; large
348
+ assessments can produce long reports. The portable JSON export contains the
349
+ complete source snapshots. PDF export uses saved artifacts and makes no AI calls.
350
+ Re-export an existing assessment to use the current layout; no analysis rerun is
351
+ needed. Draft status remains until every enabled review gate is approved.
@@ -0,0 +1,27 @@
1
+ # Custody service architecture
2
+
3
+ The vault holds customer deposits. A release requires two of three committee signers.
4
+ Each signer is operated by a separate team, but independence of their cloud accounts
5
+ has not yet been established. No operator is intended to release deposits alone.
6
+
7
+ Customers authenticate through an external identity provider. The public API accepts
8
+ withdrawal requests and records an append-only audit event. A request must be approved
9
+ before the vault releases value. Idempotency keys prevent repeated processing.
10
+
11
+ The release service fetches approved requests from a queue and asks committee signers
12
+ for signatures. The vault verifies the threshold and recipient, then marks the request
13
+ consumed. Key custody, signature expiry and account recovery procedures are unspecified.
14
+
15
+ Maintainers deploy the release service using CI/CD. Production deployment is intended
16
+ to require a separate approver. The CI identity can update the service but must not
17
+ read signer keys. Cloud administrators can change runtime configuration.
18
+
19
+ Protected assets include deposits, signer keys, withdrawal authorization, audit records
20
+ and availability. Critical invariants include authorized releases only, no repeated
21
+ withdrawals, independent approval and preserved accountability.
22
+
23
+ Boundaries include customer-to-identity-provider, public-API-to-queue, queue-to-release-
24
+ service, release-service-to-signers, signers-to-vault and CI/CD-to-production.
25
+
26
+ This is a synthetic demonstration architecture, not a description of Dividend or any
27
+ other deployed system. Missing details should be retained as open assumptions.
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@oaksecurity/aitm",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.3.0",
4
+ "description": "TRACE threat modelling engine with local API, terminal and web interfaces.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.js",
8
+ "./client": "./src/client.js"
9
+ },
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/oak-security/aitm.git"
14
+ },
15
+ "bin": {
16
+ "aitm": "src/cli.js"
17
+ },
18
+ "files": [
19
+ "src",
20
+ "README.md",
21
+ "LICENSE",
22
+ "SPEC.md",
23
+ "CHANGELOG.md",
24
+ "SECURITY.md",
25
+ "docs/api.md",
26
+ "docs/usage.md",
27
+ "docs/inputs-and-limits.md",
28
+ "examples",
29
+ ".env.example"
30
+ ],
31
+ "engines": {
32
+ "node": ">=22.12.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "start": "node src/cli.js",
39
+ "aitm": "node src/cli.js",
40
+ "tui": "node src/cli.js",
41
+ "server": "node src/cli.js serve",
42
+ "check": "node scripts/check-syntax.js && prettier --check \"src/**/*.js\" \"test/**/*.js\" \"scripts/*.js\" \"src/web/**/*.{css,html}\" package.json",
43
+ "test": "node --test test/*.test.js",
44
+ "test:live": "node scripts/test-live.js",
45
+ "link:cli": "npm link",
46
+ "doctor": "node src/cli.js doctor",
47
+ "pack:check": "npm pack --dry-run",
48
+ "format": "prettier --write \"src/**/*.js\" \"test/**/*.js\" \"scripts/*.js\" \"src/web/**/*.{css,html}\" package.json .prettierrc.json README.md SPEC.md CONTRIBUTING.md CHANGELOG.md SECURITY.md \"docs/*.md\" .github/workflows/ci.yml",
49
+ "web": "node src/cli.js web",
50
+ "test:web": "node --test test/browser/*.test.js"
51
+ },
52
+ "dependencies": {
53
+ "ignore": "7.0.14",
54
+ "ink": "8.0.0",
55
+ "ink-text-input": "6.0.0",
56
+ "mammoth": "1.13.0",
57
+ "pdf-parse": "2.4.5",
58
+ "pdfkit": "0.20.2",
59
+ "proper-lockfile": "4.1.2",
60
+ "react": "19.3.1",
61
+ "yauzl": "3.4.0",
62
+ "zod": "4.6.7"
63
+ },
64
+ "devDependencies": {
65
+ "ink-testing-library": "4.0.0",
66
+ "playwright": "1.64.1",
67
+ "prettier": "3.9.10"
68
+ }
69
+ }