Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-inbox-upload-docx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Word documents (`.docx`) can be dropped onto the Inbox or linked: headings, paragraphs, bulleted and numbered lists and tables become markdown, and the document title names the item. The file is read in Go (`archive/zip`, `encoding/xml`) with zip-bomb caps (1000 entries, 200 MiB inflated, 50 MiB per part, 100:1 ratio) and an XML decoder that refuses DTDs and unknown entities, so XXE payloads are rejected; legacy `.doc` is still refused with "save it as .docx or PDF".
26 changes: 17 additions & 9 deletions dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -38633,7 +38633,7 @@
"Knowledge"
],
"summary": "Add dropped files to the Inbox",
"description": "Owner or read-write. Each multipart `file` field is typed by its content (magic bytes, UTF-8 validation and a parse check), never by its name or client MIME type alone. Markdown, text, JSON, JSON Lines, YAML, CSV and TSV become `upload` Inbox items with extracted markdown, stored under `connector-state/uploads/<id>/` (0700 directory, 0600 files) and written as a Knowledge fact with the text inside an `<untrusted-inbox-data>` envelope. Limits come from `inbox.uploads` (`max_file_bytes`, default 25 MiB; `max_files_per_drop`, default 20; `quota_bytes`, default 2 GiB). Requests marked `Sec-Fetch-Site: cross-site` are refused. Every file is audited as `inbox_upload` with its outcome.",
"description": "Owner or read-write. Each multipart `file` field is typed by its content (magic bytes, UTF-8 validation and a parse check), never by its name or client MIME type alone. Markdown, text, JSON, JSON Lines, YAML, CSV, TSV, HTML and Word (.docx, read with zip-bomb caps and no DTDs or external entities) become `upload` Inbox items with extracted markdown, stored under `connector-state/uploads/<id>/` (0700 directory, 0600 files) and written as a Knowledge fact with the text inside an `<untrusted-inbox-data>` envelope. Limits come from `inbox.uploads` (`max_file_bytes`, default 25 MiB; `max_files_per_drop`, default 20; `quota_bytes`, default 2 GiB). Requests marked `Sec-Fetch-Site: cross-site` are refused. Every file is audited as `inbox_upload` with its outcome.",
"requestBody": {
"required": true,
"content": {
Expand Down Expand Up @@ -38694,7 +38694,8 @@
"yaml",
"csv",
"tsv",
"html"
"html",
"docx"
]
},
"code": {
Expand Down Expand Up @@ -38760,7 +38761,8 @@
"yaml",
"csv",
"tsv",
"html"
"html",
"docx"
]
},
"code": {
Expand Down Expand Up @@ -38826,7 +38828,8 @@
"yaml",
"csv",
"tsv",
"html"
"html",
"docx"
]
},
"code": {
Expand Down Expand Up @@ -38898,7 +38901,8 @@
"yaml",
"csv",
"tsv",
"html"
"html",
"docx"
]
},
"code": {
Expand Down Expand Up @@ -38964,7 +38968,8 @@
"yaml",
"csv",
"tsv",
"html"
"html",
"docx"
]
},
"code": {
Expand Down Expand Up @@ -39030,7 +39035,8 @@
"yaml",
"csv",
"tsv",
"html"
"html",
"docx"
]
},
"code": {
Expand Down Expand Up @@ -39096,7 +39102,8 @@
"yaml",
"csv",
"tsv",
"html"
"html",
"docx"
]
},
"code": {
Expand Down Expand Up @@ -39865,7 +39872,8 @@
"yaml",
"csv",
"tsv",
"html"
"html",
"docx"
]
},
"code": {
Expand Down
2 changes: 1 addition & 1 deletion src/docs/api-reference/knowledge.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `GET` | `/api/inbox/transcriptions` | Dashboard auth | Live progress of queued and running transcriptions in queue order (`{active: [{source, id, state}]}` with `phase`, `progress`, `estimated`, `started_at`, `audio_seconds`, `processed_seconds`, `eta_seconds`, `queue_position`); reads no source, so the Inbox polls it every 3 s while a job runs; `Cache-Control: no-store`; see [inbox-transcription.md](../inbox-transcription.md) | `pkg/dashboard/api_inbox.go:34` |
| `GET` | `/api/inbox/{source}/{id}/audio` | Owner or read-write | Mint a fresh short-lived audio/video link for one item (`{url, expires_at}`; Plaud: presigned, 24h; Zoom: audio-only or video `download_url` with a one-hour download token; Webex: the recording's temporary direct audio (else MP4) download link, valid 3 hours; Teams and Google Meet: 404, no browser-playable link; Slack huddles: 404, Slack keeps no huddle audio; Otter: the conversation's MP3 download link (`GET /conversations/{id}/audio`), minted per click; Granola: 404, Granola keeps no meeting audio; Limitless: 404, Pendant audio is served only behind the API key; Fathom: the signed url of a recording download (`POST /recordings/{id}/download`, audio-only recordings complete at once, video is polled), valid about 24 hours; Fireflies: the transcript's hashed `audio_url` (else `video_url`), valid 24 hours, Pro plan or higher); never stored by the hive, replied with `Cache-Control: no-store`, audited as `inbox_audio` (403 role, 404 unknown item or no audio, 502 source unreachable) | `pkg/dashboard/api_inbox.go:30` |
| `GET` | `/api/inbox/{source}/{id}/audio/stream` | Owner or read-write | Stream one item's audio from the dashboard origin, for the Inbox player (the CSP refuses cross-origin media). The hive mints the link as above, fetches it server-side and copies the bytes with the media `Content-Type` (from storage, else the link's extension); a single `Range: bytes=…` is passed through (206 + `Content-Range`; 200 whole file when storage ignores it; 416 passed through). The link stays in memory for one playback's Range requests (10 min, never past expiry), is never logged, returned or stored, and is re-minted once when storage refuses it; nothing is written to disk. `Cache-Control: no-store`; audited as `inbox_audio_stream` once per minted link (403 role, 404 unknown item or no audio, 413 over the 2 GiB cap, 502 source or storage unreachable, or link refused/expired) | `pkg/dashboard/api_inbox.go:31` |
| `POST` | `/api/inbox/uploads` | Owner or read-write | Add dropped files to the Inbox: `multipart/form-data` with one or more `file` fields (at most `inbox.uploads.max_files_per_drop`, default 20, each up to `inbox.uploads.max_file_bytes`, default 25 MiB). Each file is typed by content (magic bytes, UTF-8, a parse check), never by name or client MIME alone; md, txt, json, jsonl, yaml, csv, tsv and html become `upload` items with extracted markdown and a Knowledge fact. One file: 201 `{results: [{filename, ok, source, item_id, title, kind}]}` or its refusal (400 `empty`/`too_many_files`, 413 `too_large`, 415 `unsupported_type`, 422 `parse_failed`, 507 `quota_exceeded`, each with `code` and `error`); several files: 200 with per-file results unless all failed. Cross-site requests are refused; every file is audited as `inbox_upload` (403 role, 404 no upload store); see [inbox-uploads.md](../inbox-uploads.md) | `pkg/dashboard/api_inbox_uploads.go:27` |
| `POST` | `/api/inbox/uploads` | Owner or read-write | Add dropped files to the Inbox: `multipart/form-data` with one or more `file` fields (at most `inbox.uploads.max_files_per_drop`, default 20, each up to `inbox.uploads.max_file_bytes`, default 25 MiB). Each file is typed by content (magic bytes, UTF-8, a parse check), never by name or client MIME alone; md, txt, json, jsonl, yaml, csv, tsv, html and docx become `upload` items with extracted markdown and a Knowledge fact. One file: 201 `{results: [{filename, ok, source, item_id, title, kind}]}` or its refusal (400 `empty`/`too_many_files`, 413 `too_large`, 415 `unsupported_type`, 422 `parse_failed`, 507 `quota_exceeded`, each with `code` and `error`); several files: 200 with per-file results unless all failed. Cross-site requests are refused; every file is audited as `inbox_upload` (403 role, 404 no upload store); see [inbox-uploads.md](../inbox-uploads.md) | `pkg/dashboard/api_inbox_uploads.go:27` |
| `POST` | `/api/inbox/uploads/url` | Owner or read-write | Add a link: `{url}`. The hive fetches it under the SSRF guard (http/https only, no credentials, its own DNS lookup with the connection pinned to the checked address, private/loopback/link-local/CGNAT/multicast/ULA/metadata ranges refused, every redirect re-checked, at most 3, body capped at `inbox.uploads.max_file_bytes`, 60 s) and runs the body through the upload type pipeline (an HTML page becomes readable markdown titled by its `<title>`). 201 `{results: [{filename: host, ok, source, item_id, title, kind}]}`; 400 `link_refused`, 413, 415, 422, 502 `fetch_failed`, 507; audited as `inbox_upload` with `origin=link` and the host (403 role, 404 no upload store) | `pkg/dashboard/api_inbox_uploads.go:28` |
| `POST` | `/api/inbox/recordings` | Owner or read-write | Start a dashboard recording (● Record): `{title, mime: audio/webm\|audio/mp4, consent_version, includes_tab_audio}`. `consent_version` must name the current consent notice; it is stored with the user in the recording's metadata. One recording per user at a time. 201 `{id, max_chunk_bytes, max_seconds, retention_days, transcribes}`; audited as `inbox_recording_start` (400 consent missing or stale, 403 role, 409 `{active_id}` already recording, 412 `inbox.recording.enabled` off, 415 other media types, 507 `inbox.recording.quota_bytes` used up); see [inbox-recording.md](../inbox-recording.md) | `pkg/dashboard/api_inbox_recordings.go:20` |
| `POST` | `/api/inbox/recordings/{id}/chunks` | The recorder (owner or read-write) | Store one MediaRecorder chunk `?seq=N`, the raw bytes as the body (at most `max_chunk_bytes`, 512 KiB). In order only; each part is fsynced before the 200 `{id, seq, next_seq, bytes, duplicate?}`. The first chunk must start with a WebM or MP4 signature; the hive never decodes audio. A re-send with the same bytes is acknowledged again (`duplicate: true`) (400 bad seq, 403 someone else's, 409 `{expected_seq}` gap, other bytes for a stored seq, or already ended, 413 chunk over 512 KiB or past `max_bytes` / `max_seconds`, 415 not WebM/MP4, 507 quota) | `pkg/dashboard/api_inbox_recordings.go:21` |
Expand Down
6 changes: 4 additions & 2 deletions src/docs/inbox-uploads.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ the browser's MIME type alone: it checks magic bytes first (an executable,
archive, PDF, Office or media file renamed to `.txt` is refused), then that
the file is UTF-8 text, then that it parses as the format its extension asks
for. A file without an extension is read as JSON when it parses as JSON and
as plain text otherwise.
as plain text otherwise. A zip archive is refused unless it is named `.docx`
and opens as a Word document.

| Type | Extensions | What the item shows |
| --- | --- | --- |
Expand All @@ -29,6 +30,7 @@ as plain text otherwise.
| JSON Lines | `.jsonl`, `.ndjson` | the record count and the first 20 records in a fenced block; every line is validated |
| YAML | `.yaml`, `.yml` | a one-line summary and the document in a fenced `yaml` block (parsed with `gopkg.in/yaml.v3`) |
| CSV / TSV | `.csv`, `.tsv`, `.tab` | row and column counts and a markdown table of the first 20 rows (20 columns at most) |
| Word | `.docx` | headings (Title and Heading 1 to 6 styles) as `#`, paragraphs, bulleted and numbered lists (by level) as `-` items, and tables as markdown tables; deleted text and field codes are left out; the title comes from the document properties, else the first heading. Read in Go with `archive/zip` and `encoding/xml` (standard library): at most 1000 zip entries, 200 MiB declared uncompressed in all, 50 MiB per part (checked while inflating, not only from the header) and a 100:1 compression ratio per entry; a part with a DOCTYPE or an entity the decoder does not know is refused (XXE), and nothing is fetched |
| HTML | `.html`, `.htm`, and web pages behind a link | readable markdown: the `<title>` names the item; the `<article>` or `<main>` (else `<body>`) is kept with headings, paragraphs, lists, quotes, code, tables, link targets and image alt text; scripts, styles, forms, navigation, footers, asides and hidden elements are dropped. Parsed with `golang.org/x/net/html` (BSD-3-Clause); nothing is executed and nothing the page references is loaded |

Text is validated as UTF-8 (a UTF-8 BOM is dropped; UTF-16 is refused with
Expand All @@ -40,7 +42,7 @@ Not supported (the item is refused with a message saying what to do):

| File | Message |
| --- | --- |
| PDF, Word `.docx` | not supported yet |
| PDF | not supported yet |
| Legacy Word `.doc` (and `.xls`, `.ppt`) | save it as .docx or PDF and try again |
| RTF, OpenDocument `.odt` | save it as .docx, PDF or plain text |
| PowerPoint `.pptx` | export the slides as PDF |
Expand Down
5 changes: 4 additions & 1 deletion src/docs/security-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ timeout and size caps; the original, the extracted text and the meta are
stored 0600 in a 0700 directory per upload, never executed or served raw, and
bounded by a per-hive quota. The extracted text is fenced in the same
`<untrusted-inbox-data>` envelope in its Knowledge fact and before any agent
prompt ([inbox-uploads.md](inbox-uploads.md)). Links dropped onto the Inbox are
prompt ([inbox-uploads.md](inbox-uploads.md)). Word documents are read in
Go with zip-bomb caps (entry count, declared and actual inflated size,
compression ratio) and an XML decoder that refuses DTDs and unknown entities
(no XXE). Links dropped onto the Inbox are
fetched by the hive under an SSRF guard: http/https only, no credentials in
the URL, the hive's own DNS lookup with the connection pinned to the checked
address (any private, loopback, link-local, CGNAT, multicast, ULA or metadata
Expand Down
1 change: 1 addition & 0 deletions src/pkg/inbox/link_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ var linkTypeExtensions = map[string]string{
"text/x-yaml": ".yaml",
"text/csv": ".csv",
"text/tab-separated-values": ".tsv",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": ".docx",
}

// linkPipelineName picks the file name the type pipeline sniffs a fetched
Expand Down
Loading
Loading