@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.
- package/.env.example +11 -0
- package/CHANGELOG.md +100 -0
- package/LICENSE +21 -0
- package/README.md +229 -2
- package/SECURITY.md +49 -0
- package/SPEC.md +304 -0
- package/docs/api.md +332 -0
- package/docs/inputs-and-limits.md +78 -0
- package/docs/usage.md +351 -0
- package/examples/custody-architecture.md +27 -0
- package/package.json +67 -4
- package/src/api/server.js +591 -0
- package/src/api/web.js +38 -0
- package/src/application.js +32 -0
- package/src/assessments.js +37 -0
- package/src/assets/BDOGrotesk-Bold.ttf +0 -0
- package/src/assets/BDOGrotesk-Regular.ttf +0 -0
- package/src/assets/OFL.txt +93 -0
- package/src/assets/README.md +10 -0
- package/src/cli.js +224 -0
- package/src/client.js +88 -0
- package/src/config.js +105 -0
- package/src/doctor.js +128 -0
- package/src/engine/credentials.js +31 -0
- package/src/engine/download.js +135 -0
- package/src/engine/engine.js +783 -0
- package/src/engine/errors.js +23 -0
- package/src/engine/generation.js +121 -0
- package/src/engine/ingest.js +444 -0
- package/src/engine/pdf-layout.js +204 -0
- package/src/engine/pdf-report.js +573 -0
- package/src/engine/prompts.js +82 -0
- package/src/engine/providers.js +476 -0
- package/src/engine/references.js +112 -0
- package/src/engine/report.js +200 -0
- package/src/engine/schema.js +267 -0
- package/src/engine/store.js +115 -0
- package/src/engine/validate.js +397 -0
- package/src/engine/zip.js +70 -0
- package/src/index.js +5 -0
- package/src/source-input.js +32 -0
- package/src/token.js +59 -0
- package/src/tui/app.js +694 -0
- package/src/tui/editor.js +34 -0
- package/src/tui/file-picker.js +111 -0
- package/src/tui/logo.js +8 -0
- package/src/tui/progress.js +90 -0
- package/src/tui/report-reader.js +105 -0
- package/src/tui/select.js +63 -0
- package/src/tui/workbench.js +377 -0
- package/src/version.js +5 -0
- package/src/web/app.js +729 -0
- package/src/web/assets/BDOGrotesk-Bold.woff2 +0 -0
- package/src/web/assets/BDOGrotesk-Medium.woff2 +0 -0
- package/src/web/assets/BDOGrotesk-Regular.woff2 +0 -0
- package/src/web/assets/README.md +5 -0
- package/src/web/assets/aitm-mark.svg +12 -0
- package/src/web/assets/oak-white.svg +166 -0
- package/src/web/html.js +32 -0
- package/src/web/index.html +26 -0
- package/src/web/markdown.js +48 -0
- package/src/web/styles.css +1450 -0
- package/src/web/views.js +254 -0
package/SPEC.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# AiTM v2 specification
|
|
2
|
+
|
|
3
|
+
This replaces the former desktop architecture. AiTM (AI Threat Modeller) is a
|
|
4
|
+
reusable engine implementing the original TRACE workflow. `aitm` runs the engine,
|
|
5
|
+
terminal UI and local API in a single process. `aitm web` starts the same engine/API
|
|
6
|
+
and opens its browser workbench. The original specification is
|
|
7
|
+
retained in docs/original-spec.md.
|
|
8
|
+
|
|
9
|
+
## Runtime boundary
|
|
10
|
+
|
|
11
|
+
One Node ESM package contains the headless engine, HTTP API, Ink TUI and static browser workbench. The TUI
|
|
12
|
+
calls the engine directly and subscribes to its change events. The API exposes the
|
|
13
|
+
same instance to external clients; no HTTP handshake or polling is needed by the
|
|
14
|
+
TUI. The package root exports Engine, Providers, phases, reports and startServer.
|
|
15
|
+
The engine owns all mutations, persistence and phase transitions. Interfaces never
|
|
16
|
+
write project storage or expose credentials.
|
|
17
|
+
|
|
18
|
+
The CLI owns the lifetime of all three components. Quit, Ctrl+C and SIGTERM cancel
|
|
19
|
+
unfinished work, save completed artifacts and close the engine and API. Opening
|
|
20
|
+
the same source resumes its saved assessment. No detached child, PID file, server
|
|
21
|
+
attachment or stop command. `aitm serve` provides a foreground API without the TUI.
|
|
22
|
+
The API serves the web UI at `/`; `aitm web [source]` opens the browser and
|
|
23
|
+
`--no-open` prints its URL. Browser disconnects do not cancel engine jobs.
|
|
24
|
+
Only loopback binding is supported; this is a local, single-user application.
|
|
25
|
+
Each API request must carry the private access token (see Persistence and API).
|
|
26
|
+
`aitm doctor` checks the local setup without changing it. `aitm token` prints the
|
|
27
|
+
access token, and `--rotate` replaces it.
|
|
28
|
+
|
|
29
|
+
## Inputs and provenance
|
|
30
|
+
|
|
31
|
+
Both interfaces open a project chooser by default, with no implicit source intake.
|
|
32
|
+
Create/open named projects and import multiple sources: public HTTPS URLs, document
|
|
33
|
+
files or repository ZIPs. Each project owns its sources, settings, runs and reports.
|
|
34
|
+
Import dialogs support file selection and explicit URLs/paths; empty input never
|
|
35
|
+
selects the current directory. Renaming, closing, deleting and JSON import are supported.
|
|
36
|
+
Switching projects leaves engine jobs active. A failed batch import preserves the
|
|
37
|
+
entire prior project. Replacing one source preserves its ID and position and all others.
|
|
38
|
+
An optional explicit CLI path/URL opens the most recent project containing that
|
|
39
|
+
source without re-ingestion or AI calls, or creates a named assessment with default
|
|
40
|
+
scope. `--project ID` opens saved work directly.
|
|
41
|
+
The reusable engine and API also accept inline text, combined sources and synced
|
|
42
|
+
file snapshots for integrations. UTF-8 code/text, PDF and DOCX are ingested. A source stores
|
|
43
|
+
ID, kind, locator when local, label, collection time, commit when Git, SHA-256, file
|
|
44
|
+
IDs/hashes/extracted text/line counts and limitations. Temporary clones are removed.
|
|
45
|
+
Image-only PDFs need OCR before ingestion. Binary images/audio/video are not
|
|
46
|
+
understood as text. These limitations are explicit, not empty successes.
|
|
47
|
+
ZIP extraction is sequential and bounded to 8 MiB compressed, 32 MiB expanded and
|
|
48
|
+
10,000 entries; accepted files follow the normal text limits and ignore rules.
|
|
49
|
+
Reject unsafe/ambiguous paths, encrypted entries and special devices. Skip symlinks
|
|
50
|
+
and nested archives; remove temporary extraction files even on failure/cancellation.
|
|
51
|
+
Accepted extracted text is preserved in full, never sliced to fit a prompt. Reject
|
|
52
|
+
oversized direct documents explicitly; show skipped folder files in Scope diagnostics.
|
|
53
|
+
Classification is a quick inventory/scope pass, without candidate extraction. TRACE
|
|
54
|
+
model construction reads all accepted text in sequential source batches, carrying
|
|
55
|
+
its accumulated draft and stable object IDs forward. Ask for new or changed objects
|
|
56
|
+
only, and retain unchanged objects in the engine. Publish the validated model only
|
|
57
|
+
after all batches finish. STRIDE, trees, coordination and report synthesis use
|
|
58
|
+
completed artifacts, without rereading source batches. Record the input basis and
|
|
59
|
+
full source coverage in generation metadata.
|
|
60
|
+
The engine merges omitted earlier keyed objects into each new draft before
|
|
61
|
+
validation. Keep updated fields from the new batch, retain absent earlier items
|
|
62
|
+
(including nested tree nodes), and record retained paths. Omission alone must not
|
|
63
|
+
cause a provider retry or failure. Schema, evidence, references and structure
|
|
64
|
+
remain validated on the complete merged result.
|
|
65
|
+
|
|
66
|
+
Document downloads use public HTTPS addresses, checked at DNS resolution and on
|
|
67
|
+
every redirect. Downloads are bounded to 8 MiB, 30 seconds and three redirects.
|
|
68
|
+
HTML pages are stored in full as inert source. No page scripts, embedded-resource
|
|
69
|
+
fetching or web crawling; a PDF behind a page requires its direct download URL.
|
|
70
|
+
|
|
71
|
+
Remote clients can push text or base64 document snapshots and replace them by source
|
|
72
|
+
ID. Explicit sync re-reads local inputs or re-clones the Git default branch. Changed
|
|
73
|
+
hashes or extracted text clear generated artifacts and inventory approval. Unchanged sync preserves
|
|
74
|
+
analysis. This iteration has explicit synchronization, not a background file watcher.
|
|
75
|
+
Legacy truncated snapshots are automatically re-read from their original locator
|
|
76
|
+
before running; portable truncated snapshots require replacement with the complete
|
|
77
|
+
original. Rebuild analysis affected by either stored truncation or old prompt excerpts.
|
|
78
|
+
Single-phase reruns of these assessments require a complete pipeline run first.
|
|
79
|
+
|
|
80
|
+
## TRACE artifacts and execution
|
|
81
|
+
|
|
82
|
+
| Phase | Artifact | Gate | Optionality |
|
|
83
|
+
| -------------- | ---------------------------------------------------------------------------------------------------- | -------------- | ---------------------------------------- |
|
|
84
|
+
| 0 scope | Assessment boundary and source inventory | No gate | Required |
|
|
85
|
+
| 1 ingest | Provisional inventory/scope summary and domain/pillar classification | No gate | Required |
|
|
86
|
+
| 2 model | Threat actors, roles, protected assets, critical invariants, components, typed edges and questions | Human approval | Required |
|
|
87
|
+
| 3 stride | Ranked threats, six STRIDE categories, controls, confidence, coverage rationale | Human approval | Required |
|
|
88
|
+
| 4 trees | Top-threat attack trees, AND/OR branches, assumptions, prerequisites, leaf mitigations and omissions | Human approval | On by default |
|
|
89
|
+
| 5 coordination | Actor combinations, thresholds, incentives, shared dependencies, consequences and mitigations | Human approval | Auto from profile/model; on/off override |
|
|
90
|
+
| 6 report | Executive summary, linked mitigation roadmap, residual risks, questions and next steps | Human approval | Required |
|
|
91
|
+
|
|
92
|
+
Each phase produces schema-validated data. TRACE objects require exact evidence
|
|
93
|
+
quotes/line references or explicit inferred assumptions. Before validation,
|
|
94
|
+
generated line ranges may be relocated to a unique,
|
|
95
|
+
exact quote in the claimed file; corrections are recorded in generation metadata.
|
|
96
|
+
Unmatched evidence is removed from verified citations and its claim is retained
|
|
97
|
+
as an explicit unverified assumption with a review note, without another provider
|
|
98
|
+
call. Rejected citations are retained in diagnostic metadata. Generation schemas
|
|
99
|
+
constrain downstream references to canonical model IDs. Unambiguous identity/name
|
|
100
|
+
matches can repair references locally; unresolved optional links are removed from
|
|
101
|
+
the link arrays and explicitly recorded for review without discarding the claim.
|
|
102
|
+
Required broken relationships and malformed structure get one bounded repair.
|
|
103
|
+
Threats reference existing objects; risk is likelihood (1–5) × impact (1–5). Every asset, invariant and edge has
|
|
104
|
+
a coverage row with linked threats or an explanation. Trees have one root, no cycles,
|
|
105
|
+
valid parent links, AND/OR operators and mitigated leaves. Top threats without a tree
|
|
106
|
+
have a documented reason in configurable draft/review runs. Full pipeline mode
|
|
107
|
+
requires trees for each of the top three threats, or all threats if fewer than three
|
|
108
|
+
exist; omissions cannot replace them. Ranking uses likelihood × impact, then ID
|
|
109
|
+
for ties. Roadmap entries link to model/threat/tree/coordination IDs.
|
|
110
|
+
|
|
111
|
+
The engine derives generated coverage links from the actual threat references,
|
|
112
|
+
records corrected mappings, and flags unaddressed objects as coverage gaps for
|
|
113
|
+
human review. This prevents a separate AI-generated index from claiming unsupported
|
|
114
|
+
coverage. Human-edited and imported artifacts still undergo full consistency validation.
|
|
115
|
+
|
|
116
|
+
Review mode pauses at every enabled gate. The first gate is the TRACE model: the
|
|
117
|
+
scope and the ingest classification are inputs that the user wrote or can read in
|
|
118
|
+
the model, and they need no approval. Human approval records time, optional reviewer and
|
|
119
|
+
notes. It requires upstream gates to be approved. The final event of a run says what
|
|
120
|
+
the run did: a single-step run names the step, and only a run through all phases
|
|
121
|
+
announces the report. Draft mode runs through gates while
|
|
122
|
+
leaving generated artifacts unapproved. Full mode also bypasses review pauses,
|
|
123
|
+
enables trees with a limit of three and automatic coordination when it was off.
|
|
124
|
+
It reuses existing model/STRIDE analysis and regenerates incompatible trees and
|
|
125
|
+
downstream artifacts. No mode invents review history.
|
|
126
|
+
|
|
127
|
+
Runs are durable jobs with ordered replayable progress events, phase state, token
|
|
128
|
+
usage and terminal status. Source/config edits are rejected while a job is running.
|
|
129
|
+
Resume reuses saved artifacts and retries the unfinished phase. Restart clears
|
|
130
|
+
generated artifacts. Individual phases can be regenerated with prerequisite checks.
|
|
131
|
+
Cancelling aborts provider I/O and retains only completed artifacts. Interrupted jobs
|
|
132
|
+
are marked on server restart. A disconnected UI does not cancel work.
|
|
133
|
+
Before every provider call, a durable request event identifies the model, attempt
|
|
134
|
+
and current/total source batches.
|
|
135
|
+
Events distinguish waiting, streaming, validation, retry, artifact publication and
|
|
136
|
+
reuse. Run and phase start times support elapsed indicators before the first token.
|
|
137
|
+
|
|
138
|
+
## Providers
|
|
139
|
+
|
|
140
|
+
OpenAI Responses uses streamed strict JSON-schema output and `store:false`.
|
|
141
|
+
Anthropic Messages uses streamed `output_config.format` structured JSON and preserves
|
|
142
|
+
its default reasoning behavior. Provider choice, fast/deep model IDs and effort are
|
|
143
|
+
per-project. STRIDE and coordination use the deep model; other calls use the fast
|
|
144
|
+
model. Refusals, output truncation, malformed streams, invalid schemas and network
|
|
145
|
+
errors must be visible. An invalid artifact gets one bounded correction attempt;
|
|
146
|
+
usage includes completed rejected calls. Citation problems become review notes.
|
|
147
|
+
Without a structurally valid draft, an unsuccessful step remains resumable with
|
|
148
|
+
its earlier artifacts preserved. Provider key tests are bounded small requests.
|
|
149
|
+
|
|
150
|
+
Keys come from saved `~/.config/aitm/keys.json` settings, then environment, then
|
|
151
|
+
private `.env.local`, in that precedence order. They never appear in API state.
|
|
152
|
+
TUI Settings can add or replace each key with masked input. Blank preserves the
|
|
153
|
+
existing key and Escape cancels. Save atomically with mode 0600 before updating the
|
|
154
|
+
active provider; failed writes preserve the old credentials. Replacements apply to
|
|
155
|
+
subsequent requests without a restart and do not invalidate artifacts. Keep both
|
|
156
|
+
old and current credentials redacted for in-flight responses. Files use OS
|
|
157
|
+
permissions; encryption is not claimed. CLI `aitm configure` uses the same store.
|
|
158
|
+
Multi-workspace Anthropic keys use a saved workspace ID or the process's
|
|
159
|
+
`ANTHROPIC_WORKSPACE_ID` setting. A saved empty value clears the environment default.
|
|
160
|
+
Startup, source import and existing report exports work without a provider key;
|
|
161
|
+
starting analysis without the selected provider's key fails before a run is created.
|
|
162
|
+
When no provider key is configured, both interfaces start on Settings. Settings is
|
|
163
|
+
reachable without an open project in both interfaces.
|
|
164
|
+
A project created without a provider or model choice uses the first provider that
|
|
165
|
+
has a key (OpenAI, then Anthropic), or OpenAI when none has one. The engine never
|
|
166
|
+
changes the provider of a saved project.
|
|
167
|
+
Model defaults and the offline catalog live in `src/engine/schema.js`. For Claude
|
|
168
|
+
models that have safety classifiers, requests opt in to the server-side refusal
|
|
169
|
+
fallback. A fallback after partial output fails the phase, because the two parts
|
|
170
|
+
cannot form one valid document. Record the model that produced each result.
|
|
171
|
+
Anthropic schemas convey unsupported bounds in descriptions; the engine still
|
|
172
|
+
enforces the original complete schemas locally.
|
|
173
|
+
No source material leaves the device until a user starts an AI run.
|
|
174
|
+
|
|
175
|
+
## Persistence and API
|
|
176
|
+
|
|
177
|
+
Private data directory, atomic JSON project documents, one process lock. Project
|
|
178
|
+
updates carry a revision; conflicting edits return 409. Exports contain evidence,
|
|
179
|
+
artifacts and review/job history without credentials. Imports validate source and
|
|
180
|
+
artifact structure, create a new project ID and require fresh reviews. Local source
|
|
181
|
+
paths become portable snapshots on import. Existing v1 data is left untouched.
|
|
182
|
+
|
|
183
|
+
HTTP resources are versioned under `/v1`; `/v1/openapi.json` provides schemas and
|
|
184
|
+
`/v1/meta` the phase registry. Jobs return immediately with HTTP 202. SSE supports
|
|
185
|
+
replay with Last-Event-ID or after. Errors have a stable code and safe message.
|
|
186
|
+
Validate body sizes, path IDs, Host, Origin and browser fetch metadata.
|
|
187
|
+
|
|
188
|
+
Authentication: one random 256-bit token per user, saved with mode 0600 next to the
|
|
189
|
+
keys and stable across restarts. Accept it as a bearer token or as the
|
|
190
|
+
`HttpOnly`, `SameSite=Strict` cookie that `GET /?token=` sets. Compare in constant
|
|
191
|
+
time. Only `/v1/health` (service name and versions) and the static workbench files
|
|
192
|
+
answer without it. The reason: source intake reads local paths, so an open
|
|
193
|
+
loopback API would let other users and processes of the host read the operator's
|
|
194
|
+
files, replace provider keys and spend provider credit. `--allowed-host` adds
|
|
195
|
+
loopback names to the Host allowlist for SSH forwards; it never admits other names.
|
|
196
|
+
|
|
197
|
+
## Terminal and reports
|
|
198
|
+
|
|
199
|
+
The terminal starts at Projects. `n` creates a project; `o` opens the Projects menu;
|
|
200
|
+
`i` adds sources; `b` manages individual sources. Import uses URL/path entry or a
|
|
201
|
+
file browser with Enter navigation and Space multi-file selection. Escape cancels
|
|
202
|
+
without importing anything. Project dialogs offer open, rename, close, delete and
|
|
203
|
+
JSON import. Explicit source/ID launch arguments open that assessment directly.
|
|
204
|
+
Within an assessment it offers full-pipeline run, phase inspection, review/edit,
|
|
205
|
+
provider settings, cancellation, source refresh and Markdown/PDF/JSON export.
|
|
206
|
+
`s` opens Settings for API keys and model configuration. `p` opens a provider list,
|
|
207
|
+
then fast and deep model lists, using account discovery with offline defaults.
|
|
208
|
+
The engine owns model discovery; the API exposes the same catalog. Save provider
|
|
209
|
+
and both models atomically only after the final choice. Escape at any step leaves
|
|
210
|
+
the saved configuration and analysis unchanged. Support paging for long lists.
|
|
211
|
+
Scope and optional phases are editable in settings. External editors are launched
|
|
212
|
+
without a shell while Ink relinquishes the terminal. The complete five-line ASCII logo remains visible during and after runs, including
|
|
213
|
+
80×24 terminals. Its metadata sits beside it to preserve reading space. Narrow terminals use a stacked layout; short terminals use a compact identity.
|
|
214
|
+
The frame reserves a cursor row and bounds report/body height so reopening or
|
|
215
|
+
paging a completed report cannot scroll the controls out of the viewport.
|
|
216
|
+
|
|
217
|
+
The full-pipeline action is prominent. Progress comes directly from engine events,
|
|
218
|
+
with a spinner, phase count, elapsed times, provider/model, activity and output
|
|
219
|
+
counts. The progress bar counts ready phases, not an estimated time percentage.
|
|
220
|
+
The CLI also accepts `--full` to start/resume immediately after opening its source.
|
|
221
|
+
|
|
222
|
+
The artifact pane follows each new TRACE stage automatically while still allowing
|
|
223
|
+
manual inspection. Recoverable citation issues appear as source-review notes. If a
|
|
224
|
+
step cannot complete, show its name and Continue/Details actions; raw validator
|
|
225
|
+
paths belong in the run log, not the main status banner.
|
|
226
|
+
|
|
227
|
+
The report phase offers the full assembled document in a reader spanning the
|
|
228
|
+
terminal width. Reports open only on explicit `v`; opening a completed or imported
|
|
229
|
+
project keeps the phase menu. Escape closes the reader and returns to the menu.
|
|
230
|
+
Support line/page scrolling, section navigation and first/last page.
|
|
231
|
+
Preserve draft labels, evidence, assumptions and review notes. Render tables as
|
|
232
|
+
labelled records so wide columns cannot hide report content. Up/Down still selects
|
|
233
|
+
TRACE phases. Label `v` explicitly as View Markdown. Viewing creates no files and
|
|
234
|
+
never calls an AI provider. PDF is generated only by an explicit export choice.
|
|
235
|
+
`x` offers Markdown, PDF and JSON with a destination path. Help shows the actual
|
|
236
|
+
data directory; reports are assembled on demand from persisted project artifacts.
|
|
237
|
+
Provider connection testing uses `V`.
|
|
238
|
+
|
|
239
|
+
Report assembly is deterministic from validated artifacts. Include scope, provenance,
|
|
240
|
+
TRACE model, ranked threats, coverage, enabled optional analyses, roadmap, unresolved
|
|
241
|
+
questions and review records. Never include disabled-phase content. The report is
|
|
242
|
+
marked draft until all enabled review gates are approved. PDF embeds BDO Grotesk
|
|
243
|
+
under its separate SIL Open Font License. Render structured artifacts directly in
|
|
244
|
+
an A4 layout with readable text, page numbers, clickable contents and bookmarks.
|
|
245
|
+
Include likelihood/impact and STRIDE charts, ranked threats, connected attack-tree
|
|
246
|
+
diagrams, a time-grouped mitigation roadmap, and linked evidence/source appendices.
|
|
247
|
+
Preserve full cited quotes and source metadata with pagination that avoids clipping;
|
|
248
|
+
full source snapshots remain available through JSON export. Re-exporting existing
|
|
249
|
+
artifacts applies the current layout without provider calls or state changes.
|
|
250
|
+
Do not hard-code a personal author name. State prominently: Generated by AiTM using
|
|
251
|
+
AI. This report was not authored, reviewed or endorsed by Oak Security. It needs
|
|
252
|
+
expert judgement and is not a code audit or a warranty. Retain explicit human review
|
|
253
|
+
records. Omit a generic Source limitations section; show routine import diagnostics
|
|
254
|
+
in Scope and preserve meaningful unresolved questions and unverified claims in the
|
|
255
|
+
report. Legacy analyses using incomplete text need a brief notice until rebuilt.
|
|
256
|
+
|
|
257
|
+
## Browser workbench
|
|
258
|
+
|
|
259
|
+
Use the original main-branch workbench's visual language: black project/phase
|
|
260
|
+
sidebar, light paper workspace, bundled BDO Grotesk and gold/magenta accents. The
|
|
261
|
+
browser is a same-origin client of the existing versioned API. No Electron runtime,
|
|
262
|
+
second engine, frontend daemon, CDN dependencies or separate provider adapters.
|
|
263
|
+
|
|
264
|
+
The opening screen lists projects with New project and Open project actions.
|
|
265
|
+
Add sources offers multi-file document/ZIP uploads or one explicit URL/path per
|
|
266
|
+
line. No current-folder default. Each source can be replaced, refreshed or removed
|
|
267
|
+
individually. Portable JSON imports create new projects requiring fresh review.
|
|
268
|
+
Keep Run full pipeline in the persistent toolbar on every project view. It autoruns
|
|
269
|
+
all phases with top-three attack trees and no approval pauses. The import dialog
|
|
270
|
+
offers an explicit Run full pipeline after import checkbox. Display classification
|
|
271
|
+
separately from file import, retain batch/model progress through streaming updates,
|
|
272
|
+
and show time since the last update. Overlapping live refreshes must always finish
|
|
273
|
+
rendering a new route, even if the project revision did not change.
|
|
274
|
+
Overview presents full-pipeline and review-gated runs. All TRACE phases are
|
|
275
|
+
inspectable, with evidence links into complete numbered source files, ranked threat
|
|
276
|
+
filters, hierarchical AND/OR trees and coordination details. Scope and common
|
|
277
|
+
artifact fields have form editors; complete artifacts have validated JSON editing.
|
|
278
|
+
Approvals record a timestamp and optional notes; no reviewer name is required.
|
|
279
|
+
Optional named reviews from API clients remain supported. Respect engine prerequisites.
|
|
280
|
+
|
|
281
|
+
Persistent navigation/status must remain outside the scrolling content. Support
|
|
282
|
+
small screens, keyboard controls, labelled forms and modal dialogs. Display live
|
|
283
|
+
job activity, phase, elapsed time and output counts over SSE; reconnect and reload
|
|
284
|
+
must restore the current run. Global events notify changes made through other
|
|
285
|
+
interfaces. Do not replace unsaved form input during live updates. Use captured
|
|
286
|
+
project revisions when submitting edits; expose conflicts without losing text.
|
|
287
|
+
|
|
288
|
+
Provide masked key entry, provider/model dropdowns using the engine catalog,
|
|
289
|
+
connection testing and project model/phase settings. Never return key values or
|
|
290
|
+
persist them in browser storage. Saving credentials must not erase pending model
|
|
291
|
+
selections or invalidate analysis. Markdown reports are complete and readable, with
|
|
292
|
+
section navigation and an exact source view. HTML/images/links in source/model
|
|
293
|
+
text remain inert. All downloads are explicit; report reading never generates PDF.
|
|
294
|
+
Static assets have an explicit allowlist and CSP and use existing Host/Origin/fetch
|
|
295
|
+
metadata restrictions. Browser tests use synthetic sources and deterministic
|
|
296
|
+
providers with the real engine/API; live-provider verification remains separate.
|
|
297
|
+
|
|
298
|
+
## Acceptance evidence
|
|
299
|
+
|
|
300
|
+
Required: syntax/package checks; automated engine, API, provider-protocol, ingestion,
|
|
301
|
+
semantic-validation, interactive TUI and browser end-to-end tests; an actual terminal smoke test; PDF
|
|
302
|
+
rendering inspection; and full live pipelines using supplied OpenAI/Anthropic keys.
|
|
303
|
+
Use the previous Dividend repository/whitepaper if located. If unavailable, disclose
|
|
304
|
+
the alternative source. Live-provider success cannot be inferred from mocked tests.
|
package/docs/api.md
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
# AiTM engine API
|
|
2
|
+
|
|
3
|
+
Start `aitm [source]`, `aitm web [source]` or `aitm serve` and connect to `http://127.0.0.1:8790`. The API is local and
|
|
4
|
+
single-user. It binds only to loopback, and each request needs the private access token.
|
|
5
|
+
The normal TUI calls the same engine directly. Independent clients should use this
|
|
6
|
+
API instead of reading project files. Closing AiTM also closes its API; `aitm serve`
|
|
7
|
+
runs the engine and API without a TUI.
|
|
8
|
+
|
|
9
|
+
`GET /v1/openapi.json` is the generated contract. `GET /v1/meta` gives the TRACE
|
|
10
|
+
phase registry, default scope and artifact JSON schemas. Provider keys are configured in the owning process;
|
|
11
|
+
`GET /v1/providers` exposes only configuration booleans and default model IDs.
|
|
12
|
+
It also includes `keySource` (saved settings, environment, `.env.local` or session),
|
|
13
|
+
never the key value. TUI Settings (`s`) and browser Settings save replacements privately and update the
|
|
14
|
+
shared provider immediately. Credentials are not project settings and are not
|
|
15
|
+
accepted through project PATCH/import operations. `aitm configure` uses the same
|
|
16
|
+
private store; saved keys take precedence over environment values on startup.
|
|
17
|
+
|
|
18
|
+
`GET /v1/providers/:provider/models` returns `{ source, models: [{ id }], notice }`.
|
|
19
|
+
It queries the provider account with a bounded timeout and filters for the pipeline's
|
|
20
|
+
reasoning/structured-output workflow. `source: "defaults"` and a notice indicate
|
|
21
|
+
missing credentials, lookup failure or no matching models; `source: "account"`
|
|
22
|
+
indicates a successful catalog lookup. OpenAI's listing does not provide full
|
|
23
|
+
capability metadata, so its model families are filtered locally. A listed model
|
|
24
|
+
is not a guarantee of account generation access; the existing connection test
|
|
25
|
+
checks the selected model with a small structured request.
|
|
26
|
+
|
|
27
|
+
## Authentication
|
|
28
|
+
|
|
29
|
+
Send the access token on each request:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
AUTH="Authorization: Bearer $(aitm token)"
|
|
33
|
+
curl -fsS -H "$AUTH" http://127.0.0.1:8790/v1/projects
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`aitm token` prints the token of the current user. It is saved in
|
|
37
|
+
`~/.config/aitm/token` (mode 600), stays the same across restarts, and changes
|
|
38
|
+
only with `aitm token --rotate`. A request without a valid token gets HTTP 401
|
|
39
|
+
with code `unauthorized`. Only `GET /v1/health` and the static workbench files
|
|
40
|
+
under `/ui/` answer without it.
|
|
41
|
+
|
|
42
|
+
Browsers use a cookie. `GET /?token=TOKEN` answers 303 to `/` and sets
|
|
43
|
+
`aitm_token_<port>` as an `HttpOnly`, `SameSite=Strict` cookie. `aitm web` opens
|
|
44
|
+
that URL for you. `GET /` without a valid cookie returns a 401 page with
|
|
45
|
+
instructions and no data.
|
|
46
|
+
|
|
47
|
+
`ApiClient` from `@oaksecurity/aitm/client` takes the token as an option. When
|
|
48
|
+
you omit it, the client uses `AITM_TOKEN`, then the token file of the current user:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import { ApiClient } from '@oaksecurity/aitm/client';
|
|
52
|
+
const client = new ApiClient('http://127.0.0.1:8790');
|
|
53
|
+
const projects = await client.get('/v1/projects');
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`startServer(engine, options)` accepts `token` and `allowedHosts`. Without a
|
|
57
|
+
`token`, it creates a random one for that server and returns it as `token`;
|
|
58
|
+
`webUrl()` returns the browser URL that carries it.
|
|
59
|
+
|
|
60
|
+
## Start a project and run
|
|
61
|
+
|
|
62
|
+
All request bodies use `Content-Type: application/json`.
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
curl -s -H "$AUTH" http://127.0.0.1:8790/v1/projects \
|
|
66
|
+
-H 'Content-Type: application/json' \
|
|
67
|
+
-d '{"name":"Custody review","scope":"Assess signer and release authority"}'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The result is a project document with `id`, `revision`, `config`, `sources`,
|
|
71
|
+
`artifacts`, `runs` and `audit`. Use its `id` as `PROJECT_ID` below.
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
curl -s -H "$AUTH" http://127.0.0.1:8790/v1/projects/PROJECT_ID/sources \
|
|
75
|
+
-H 'Content-Type: application/json' \
|
|
76
|
+
-d '{"kind":"text","label":"Architecture","text":"The vault holds deposits. Two of three signers authorize releases."}'
|
|
77
|
+
|
|
78
|
+
curl -s -H "$AUTH" http://127.0.0.1:8790/v1/projects/PROJECT_ID/runs \
|
|
79
|
+
-H 'Content-Type: application/json' \
|
|
80
|
+
-d '{"mode":"full"}'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
A successful run request returns HTTP 202 with a job ID. If the provider of the
|
|
84
|
+
project has no key, it returns HTTP 422 with code `missing_key` before creating a
|
|
85
|
+
job. The message names a provider that has a key, if there is one.
|
|
86
|
+
|
|
87
|
+
`mode: "review"` is the default; it pauses at human review gates. `draft` bypasses gates without approving artifacts.
|
|
88
|
+
`full` runs the complete pipeline without review pauses, enables trees with
|
|
89
|
+
`treeLimit: 3`, and changes coordination from `off` to `auto` when needed. Trees are
|
|
90
|
+
required for every one of the top three STRIDE threats (risk = likelihood × impact;
|
|
91
|
+
ties sort by ID), or all threats if fewer than three exist. Omission notes cannot
|
|
92
|
+
replace these trees. Saved model/STRIDE artifacts are reused; incompatible trees
|
|
93
|
+
and dependent artifacts are regenerated. All generated outputs remain drafts.
|
|
94
|
+
`resume: true` is the default; `resume: false` clears generated artifacts before
|
|
95
|
+
starting again. `phase: "stride"` (or another generated phase ID) regenerates only
|
|
96
|
+
that phase after checking prerequisites and clearing dependent artifacts. `full`
|
|
97
|
+
cannot be combined with a single `phase`.
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
curl -N -H "$AUTH" http://127.0.0.1:8790/v1/projects/PROJECT_ID/runs/RUN_ID/events
|
|
101
|
+
curl -s -H "$AUTH" http://127.0.0.1:8790/v1/projects/PROJECT_ID/runs/RUN_ID
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
SSE events have increasing integer IDs. Reconnect with `Last-Event-ID: 12` or
|
|
105
|
+
`?after=12` to replay later events. Event types include `running`, `request`, `progress`,
|
|
106
|
+
`validating`, `batch_complete`, `artifact`, `validation_retry`, `repair_fallback` (legacy), `evidence_review`, `reference_review`, `reused`, `skipped`, `awaiting_review`, `completed`, `failed`,
|
|
107
|
+
`cancelled`, and `interrupted`. Terminal events close the stream. The server keeps
|
|
108
|
+
working if a progress subscriber disconnects. Progress exposes character/token counts,
|
|
109
|
+
not raw provider text. Completed phase output is available in project state.
|
|
110
|
+
`request` is emitted before waiting for the provider and includes `provider`, `model`
|
|
111
|
+
and `attempt` (1 or 2 within each batch), plus `batch` and `batches` (current/total).
|
|
112
|
+
`progress` and `validating` also carry the batch and model fields, so streaming
|
|
113
|
+
updates retain progress context. `batch_complete` records each completed source
|
|
114
|
+
batch and the number of earlier findings retained automatically.
|
|
115
|
+
`validating` precedes evidence/reference checks; `reused`
|
|
116
|
+
identifies a saved phase. Jobs expose `startedAt` and `phaseStartedAt` so clients can
|
|
117
|
+
show elapsed time even before the first streamed output arrives.
|
|
118
|
+
`evidence_review` means unresolved citation claims were saved as unverified
|
|
119
|
+
assumptions without another provider call; the job continues. `reference_review`
|
|
120
|
+
marks unresolved optional model links; claims retain valid links and explicit
|
|
121
|
+
uncertainty. `repair_fallback` is retained in historical runs from the former
|
|
122
|
+
citation-retry workflow. Artifacts expose a
|
|
123
|
+
derived `reviewNotes` array (`path`, `claim`, `note`). Rejected citations are kept in
|
|
124
|
+
`generation.evidenceWarnings`, rather than in the artifact's valid evidence fields.
|
|
125
|
+
`source_refresh` reports recovery of legacy truncated snapshots or rebuilding
|
|
126
|
+
analysis previously made from prompt excerpts. Original local/Git/URL sources are
|
|
127
|
+
re-read when required; portable incomplete snapshots need replacement via PUT.
|
|
128
|
+
A single-phase run requiring this migration returns 409 `source_refresh_required`
|
|
129
|
+
with instructions to run the full pipeline.
|
|
130
|
+
|
|
131
|
+
Classification uses the source inventory and scope. The model phase reads every
|
|
132
|
+
accepted source character across sequential batches. Later batches receive the
|
|
133
|
+
accumulated draft and return new or updated objects; the engine retains unchanged
|
|
134
|
+
keyed findings. `generation.retainedFindings` records retained paths. No partial
|
|
135
|
+
model is published. STRIDE, trees, coordination and report consume completed
|
|
136
|
+
artifacts without repeated raw-source passes. Generation metadata records
|
|
137
|
+
`sourceCoverage: { complete, files, characters, batches }` for model construction,
|
|
138
|
+
`{ fromInventory: true }` for classification and `{ fromArtifacts: true }` downstream.
|
|
139
|
+
Coverage records delivery, not an assurance of exhaustive AI understanding.
|
|
140
|
+
|
|
141
|
+
Generated downstream reference fields are restricted to canonical model IDs by the
|
|
142
|
+
provider schema. Local, unambiguous identity repairs are recorded in
|
|
143
|
+
`generation.referenceCorrections`; unresolved optional links are recorded in
|
|
144
|
+
`generation.referenceWarnings` and removed from valid link arrays with explicit
|
|
145
|
+
review notes. No missing model objects are invented. Structurally invalid required
|
|
146
|
+
relationships still trigger a single bounded repair before a failed phase.
|
|
147
|
+
|
|
148
|
+
## Resources
|
|
149
|
+
|
|
150
|
+
| Method and path | Behavior |
|
|
151
|
+
| ------------------------------------------------ | ----------------------------------------------------------------- |
|
|
152
|
+
| `GET /v1/health` | Service name, version and API version. Needs no token |
|
|
153
|
+
| `GET /v1/instance` | Version, PID, storage directory and key file path |
|
|
154
|
+
| `GET /v1/meta` | Phase registry and artifact schemas |
|
|
155
|
+
| `GET /v1/providers` | Provider configuration status and model defaults |
|
|
156
|
+
| `GET /v1/providers/:provider/models` | Account model choices, or defaults with a notice |
|
|
157
|
+
| `POST /v1/providers/:provider/test` | Real connection test; body `{ "model": "..." }` |
|
|
158
|
+
| `GET /v1/projects` | Project summaries |
|
|
159
|
+
| `POST /v1/projects` | Create from name, scope and optional config |
|
|
160
|
+
| `GET /v1/projects/:id` | Complete project state |
|
|
161
|
+
| `PATCH /v1/projects/:id` | Edit name, scope or complete config; `revision` required |
|
|
162
|
+
| `DELETE /v1/projects/:id` | Delete an idle project |
|
|
163
|
+
| `GET /v1/projects/:id/phases` | Enabled phases, including classification-derived defaults |
|
|
164
|
+
| `POST /v1/projects/:id/sources` | Ingest a new source |
|
|
165
|
+
| `POST /v1/projects/:id/sources/import` | Atomically add a batch of explicit sources |
|
|
166
|
+
| `PUT /v1/projects/:id/sources/:sourceId` | Replace a source using the same input formats |
|
|
167
|
+
| `POST /v1/projects/:id/sources/:sourceId/sync` | Re-read a local, Git or URL source; body `{}` |
|
|
168
|
+
| `DELETE /v1/projects/:id/sources/:sourceId` | Remove source and invalidate analysis |
|
|
169
|
+
| `PUT /v1/projects/:id/artifacts/:phase` | Validated edit: `{ "revision": 12, "data": {...} }` |
|
|
170
|
+
| `POST /v1/projects/:id/artifacts/:phase/approve` | `{ "revision": 12, "notes": "..." }`; reviewer and notes optional |
|
|
171
|
+
| `POST /v1/projects/:id/runs` | Start/resume a job |
|
|
172
|
+
| `GET /v1/projects/:id/runs/:runId` | Status, usage, errors and event history |
|
|
173
|
+
| `GET /v1/projects/:id/runs/:runId/events` | SSE progress and replay |
|
|
174
|
+
| `POST /v1/projects/:id/runs/:runId/cancel` | Cancel provider I/O; body `{}` |
|
|
175
|
+
| `GET /v1/projects/:id/report?format=markdown` | Full Markdown report |
|
|
176
|
+
| `GET /v1/projects/:id/report?format=pdf` | PDF report |
|
|
177
|
+
| `GET /v1/projects/:id/export` | Portable JSON envelope |
|
|
178
|
+
| `POST /v1/projects/import` | Validate/import that envelope as a new unreviewed project |
|
|
179
|
+
|
|
180
|
+
## Source formats
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{ "kind": "local", "path": "/absolute/path/to/repo-or-document", "label": "Optional label" }
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{ "kind": "git", "url": "https://github.com/organisation/repository" }
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{ "kind": "url", "url": "https://example.org/whitepaper.pdf" }
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Public URLs support code/text, HTML pages, PDF, DOCX and repository ZIPs. Downloads allow public HTTPS
|
|
195
|
+
addresses only, including DNS results and redirect targets, and are bounded to
|
|
196
|
+
8 MiB, 30 seconds and three redirects. HTML is preserved as source without running
|
|
197
|
+
scripts, crawling links or fetching embedded resources. Use the direct document
|
|
198
|
+
link to assess a PDF/DOCX linked from a page.
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{ "kind": "text", "label": "Workshop notes", "text": "..." }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"kind": "files",
|
|
207
|
+
"label": "Editor sync",
|
|
208
|
+
"files": [
|
|
209
|
+
{ "path": "src/vault.sol", "content": "...", "encoding": "utf8" },
|
|
210
|
+
{ "path": "design.pdf", "content": "BASE64_CONTENT", "encoding": "base64" }
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
For editor integration, create a `files` source once and `PUT` the current file set
|
|
216
|
+
to that source ID when it changes. Each PUT replaces the whole source snapshot.
|
|
217
|
+
Paths must be relative and cannot traverse directories or name credential files.
|
|
218
|
+
Text/file sources are refreshed by PUT; local/Git/URL sources also support explicit sync.
|
|
219
|
+
Inputs are snapshotted atomically; a failed ingest leaves project evidence unchanged.
|
|
220
|
+
To add several sources to an existing project, use
|
|
221
|
+
`POST /v1/projects/:id/sources/import` with `{ "sources": [...] }`. Each item is an
|
|
222
|
+
explicit path/HTTPS URL string or one of the SourceInput objects above. The batch
|
|
223
|
+
is limited to 100 sources and saves once after every import succeeds. Any error or
|
|
224
|
+
cancellation leaves all existing sources and analysis unchanged. Empty strings and
|
|
225
|
+
empty batches are rejected; no route implicitly reads the current directory.
|
|
226
|
+
`PUT /v1/projects/:id/sources/:sourceId` also accepts `{ "source": "/path/or/url" }`
|
|
227
|
+
and preserves the replaced source's position and ID.
|
|
228
|
+
|
|
229
|
+
Local `.zip` paths, ZIP URLs and base64 `.zip` file entries expand into evidence
|
|
230
|
+
files. Archives are limited to 8 MiB compressed, 32 MiB expanded and 10,000 entries.
|
|
231
|
+
Unsafe/ambiguous paths, encrypted entries and special devices fail the import;
|
|
232
|
+
symlinks, dependencies, credentials and nested archives are skipped. Nested ignore
|
|
233
|
+
rules apply. Temporary extraction files are removed after success or failure.
|
|
234
|
+
|
|
235
|
+
Accepted files retain their complete extracted text. Size caps reject inputs or
|
|
236
|
+
record skipped folder files instead of saving truncated excerpts. Inline `text`
|
|
237
|
+
inputs accept up to 500,000 characters; use local documents or file snapshots for
|
|
238
|
+
larger inputs within the file limits.
|
|
239
|
+
|
|
240
|
+
## Report storage and viewing
|
|
241
|
+
|
|
242
|
+
Project documents are stored as `<project-id>.json` in the configured data directory
|
|
243
|
+
(default `~/.local/share/aitm-v2`, exposed by `/v1/instance`). They contain all report
|
|
244
|
+
artifacts; Markdown is assembled on demand by the report endpoint and TUI's `v`
|
|
245
|
+
reader. Viewing never writes PDF or Markdown files. The PDF endpoint generates a
|
|
246
|
+
response only when requested; the TUI's `x` export requires an explicit format and
|
|
247
|
+
destination. Reports identify AiTM as the generating tool and disclaim Oak Security
|
|
248
|
+
authorship, review and endorsement, with no hard-coded personal author name.
|
|
249
|
+
|
|
250
|
+
The PDF is rendered directly from saved structured artifacts, with a risk matrix,
|
|
251
|
+
STRIDE charts, attack-tree diagrams, roadmap and linked evidence appendix. It has
|
|
252
|
+
clickable contents, bookmarks and page numbers; enabled optional phases determine
|
|
253
|
+
which sections appear. Export makes no provider calls and does not change project
|
|
254
|
+
state. Re-export saved projects to apply the current layout. The response uses
|
|
255
|
+
`application/pdf` and an attachment filename; Markdown uses `text/markdown`.
|
|
256
|
+
Portable JSON exports include full source snapshots; PDFs include cited quotes
|
|
257
|
+
and source metadata, not every source file's complete text.
|
|
258
|
+
|
|
259
|
+
## Configuration and reviews
|
|
260
|
+
|
|
261
|
+
Project config has `provider`, `fastModel`, `deepModel`, `effort` (`low|medium|high`),
|
|
262
|
+
`trees` (boolean), `coordination` (`auto|on|off`) and `treeLimit` (1–10). A project
|
|
263
|
+
created without `provider` and without model IDs uses the first provider that has
|
|
264
|
+
a key (`openai`, then `anthropic`), or `openai` when no key is configured. Fetch a
|
|
265
|
+
project, modify its config, and PATCH it with the fetched revision. When switching
|
|
266
|
+
provider, select that provider's default models from `/v1/providers` or your own
|
|
267
|
+
model IDs. Changing config invalidates generated analysis.
|
|
268
|
+
|
|
269
|
+
Review phases use `model`, `stride`, `trees`, `coordination`, `report`. The `scope`
|
|
270
|
+
and `ingest` artifacts have no review gate: an approval request for them returns
|
|
271
|
+
HTTP 409 with code `no_review_gate`. Reviewer identity is optional (omitted/empty names
|
|
272
|
+
are accepted); approvals still record a timestamp. Upstream gates must be approved before a downstream
|
|
273
|
+
approval. Editing generated JSON resets that artifact's review and deletes later
|
|
274
|
+
artifacts. A report remains marked draft until every enabled gate is approved.
|
|
275
|
+
|
|
276
|
+
## Errors and limits
|
|
277
|
+
|
|
278
|
+
Errors are `{ "error": { "code": "revision_conflict", "message": "..." } }`.
|
|
279
|
+
HTTP 400 means malformed JSON, 401 a missing or invalid access token, 403 disallowed browser origin/host, 404 unknown
|
|
280
|
+
resource, 409 busy project / revision conflict / missing review, 413 oversized body,
|
|
281
|
+
415 wrong media type and 422 invalid input. Provider failures after a job starts
|
|
282
|
+
appear in the job's status/error, not in the already-returned 202 response.
|
|
283
|
+
|
|
284
|
+
Request bodies are capped at 16 MiB. Ingestion has additional file/content caps
|
|
285
|
+
documented in README.md. Calls never execute source files. Repository intake is
|
|
286
|
+
restricted to public HTTPS GitHub, GitLab and Bitbucket URLs. API state is private
|
|
287
|
+
to the local operator; it contains assessment evidence and should be handled as such.
|
|
288
|
+
|
|
289
|
+
Provider output receives schema and semantic validation before publication. An
|
|
290
|
+
invalid artifact gets one bounded correction attempt; usage includes both calls.
|
|
291
|
+
Persistent citation mismatches become explicit unverified assumptions and review
|
|
292
|
+
notes without stopping the sequential pipeline. The original citation is not
|
|
293
|
+
treated as evidence. Imports/edits still validate supplied evidence strictly, and
|
|
294
|
+
review notes are derived again from retained assumptions on import. Structural
|
|
295
|
+
errors still require a coherent draft before dependent phases can run. Earlier
|
|
296
|
+
completed artifacts remain available if no valid draft can be produced.
|
|
297
|
+
|
|
298
|
+
## Browser workbench
|
|
299
|
+
|
|
300
|
+
`GET /` serves the bundled web UI; its modules, CSS, fonts and marks live under
|
|
301
|
+
`/ui/`. Only explicitly registered assets are public. Static responses have CSP,
|
|
302
|
+
`nosniff` and frame restrictions and pass the same Host/Origin/fetch-metadata checks
|
|
303
|
+
as API requests. The engine remains loopback-only and single-user. The `Host`
|
|
304
|
+
header must be the server's own loopback address and port, or a loopback name
|
|
305
|
+
given with `--allowed-host` for an SSH forward to a different local port.
|
|
306
|
+
|
|
307
|
+
`aitm web` starts the engine/API and opens the Projects screen without importing
|
|
308
|
+
anything. An explicit `[source]` opens or reuses that source at the project's
|
|
309
|
+
Overview. `--project ID` opens an existing project without ingestion.
|
|
310
|
+
`--no-open` prints the link without starting a browser. `aitm serve` and the normal
|
|
311
|
+
TUI also serve the workbench. All clients use the same engine instance.
|
|
312
|
+
|
|
313
|
+
Additional resources used by the workbench:
|
|
314
|
+
|
|
315
|
+
| Method and path | Behavior |
|
|
316
|
+
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
317
|
+
| `POST /v1/projects/open` | Body `{ "source": "/path/or/https-url" }` or `{ "source": <SourceInput> }`; source is required. Returns `{ project, reused }`. Local/Git/URL sources reopen the most recent project containing that source; uploads create a new assessment. Failed ingestion removes its empty project. |
|
|
318
|
+
| `PUT /v1/projects/:id/source` | Body `{ "source": "/path/or/https-url" }`; replaces the primary source using CLI normalization. Multiple-source imports must remove extra snapshots before using this shortcut. |
|
|
319
|
+
| `PUT /v1/providers/:provider/credentials` | Body with `apiKey` and/or Anthropic `workspaceId`; saves through the owning provider's credential writer before changing active credentials, and returns provider status only. Empty keys are rejected; omit a key to keep it. Empty workspace ID explicitly clears it. |
|
|
320
|
+
| `GET /v1/events` | Global SSE stream of `{ projectId }`; `null` signals connection/provider changes. Refetch current state on connection/reconnection. Disconnect releases the listener. Use the existing per-run event stream for detailed progress/replay. |
|
|
321
|
+
|
|
322
|
+
Do not place credentials in a URL, project document or browser storage. The normal
|
|
323
|
+
CLI wires the credential writer to private mode-600 `keys.json`; programmatic
|
|
324
|
+
hosts without a writer keep replacements only in their provider session.
|
|
325
|
+
Configuration status indicates which source is active. Key changes do not mutate
|
|
326
|
+
assessment artifacts. Global change events contain only project IDs.
|
|
327
|
+
|
|
328
|
+
Closing a tab does not cancel a job. The UI reattaches to a running job after reload
|
|
329
|
+
and refetches saved state at artifact boundaries and terminal events. Source and
|
|
330
|
+
model text are escaped before rendering; report HTML/images and external links
|
|
331
|
+
remain inert text. Markdown/PDF export uses the existing report endpoint only
|
|
332
|
+
when explicitly selected, with browser download destinations.
|