## Summary The web page can now import a Trajectory Export, a Bug Report Package or a trajectory report and read it as a read-only conversation, transcript and trajectory both. It is meant for developers reading a bug report they received, and for looking at a conversation from another machine. It builds on #948 (export package v1, the trajectory view on by default, and the conversation menu's availability predicate). - **Import store** (`raven/trajectory/imported_package.py`, `imported.py`). Three kinds are accepted: a `raven_trajectory_export` v1 export, a `bug_report_package` v1, and a `raven trajectory report` tarball. A file that is not gzip is "not a package Raven can import", an unknown version asks for an update, anything else is "damaged or unsafe". Packages are unpacked member by member on `package_check`'s bounded layer, with one budget shared by both layers: 100 MiB per package, 1 GiB unpacked for an export and 256 MiB for the report kinds, 100k members; traversal, absolute names, backslashes, symlinks, hard links, devices, FIFOs, sparse members, repeats, directories with data and oversized extended headers are refused, and every file is created with `open(..., "xb")`. The package's session record is held to 32 MiB and 50,000 records before anything reads it (the import and every open load it whole), or the package is refused as `transcript_too_large`. The result is normalized into one trace store: export v2 shells stay as they are, report v1 model inputs become v2 shells that resolve to exactly the original payload (so long conversations read whole), and a pointer that maps to nothing in the package becomes null and reads as not recorded. Each import lives in `<raven home>/imports/<uuid>/` with a `meta.json` (source file name, import time, title, kind, sha256); it is unpacked under `.staging/` and renamed into place, removed whole on failure or cancel, and stale staging is swept at startup. Default titles: an export takes the original conversation's title or its first user input, a bug report the first line of its description or its report id, a trajectory report the original title or its id. One import runs at a time on a dedicated worker thread that owns the slot; there is no queue, a closed page does not free the slot early, and gateway shutdown stops and waits for it. - **RPC and server-side guard.** New `imported.upload` (base64, under the same 100 MiB limit as `fs.upload`) answers `imported` or `duplicate` (by sha256), and imports another copy with `force`. New error codes: -32029 `imported_read_only`, -32030 `imported_package_invalid` (`data.reason` carries a stable refusal code), -32031 `imported_busy`. An Imported Conversation's key is `imported:<uuid>`. `session.list` appends imported rows when asked for the `imported` channel (never in the archived list); `session.resume`, `session.title` and `session.delete` read and write `imports/` directly and never touch the SessionManager. A dispatcher guard allows only a vetted list of read methods on an imported key (any of the four session parameter names, or `channel: imported`) and refuses every other method with -32029, including methods added later. The SessionManager refuses to save or fork an imported key and `/file` answers 404 for one, so an imported conversation never lands in `<workspace>/sessions/`. The trajectory methods read an import from its own trace store; the indexer registry gains an LRU cap (four foreign stores), idle eviction covers every indexer, and deleting an import drops its indexer. - **Web page.** "Import conversation" in the left menu picks a file and uploads it; while it runs the button shows the file name and is disabled, every refusal has its own message, and a repeated package offers "Open existing" or "Import anyway" (the confirm dialog gains an optional second action). An "Imported" group below Recent (hidden when empty) lists the imports with only Rename (inline) and Delete, and the source file name in the tooltip; search mode matches, and "delete all" in settings leaves imports alone. An open import is read-only: no input box (and no transcript mask left behind for it), no title editing in the header, no Branch, the conversation menu hidden with its slot kept, no working-directory tag. Sub-agent panes, DAG runs, attachments, delivered files and generated images show as unavailable without sending requests the server would refuse; a package without a transcript says so and the trajectory view still opens; `[REDACTED:...]` placeholders are shown as they are. - **Docs and tests.** The webui page (English and Chinese) gains "Import a conversation"; `CONTEXT.md` (Imported Conversation) and `ui-web/CONTEXT.md` define the term. Unit tests cover every refusal of the unpacker, normalization, meta and titles, duplicates and `force`, runner admission and cleanup, the guard (checked against every registered method), and the imported branches of `session.*` and `trajectory.*`; vitest covers the import entry, the rail and the read-only mode. A new integration test imports packages made by the real writers into a second raven home and reads them back, and covers duplicates, rename, delete, refused writes, and damaged or hostile packages (an oversized upload and a decompression bomb built at the shipped limits). ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification - The branch merges the current `main` (merge commits, no conflicts; the generated RPC bindings and i18n catalogue still match their sources); everything below ran on the merged tree unless noted. - `uv run pytest tests/ -q` (full suite): 10 failed / 31918 passed / 188 skipped. All 10 (proxy environment, IPv6 prefix resolution, node runtime) also fail on `main` on this machine; none is introduced by this branch. - `uv run pytest -m integration tests/integration/test_imported_conversation_e2e.py tests/integration/test_web_traj_export_e2e.py tests/integration/test_web_bugreport_e2e.py -q`: 16 passed. - Changed-line coverage over the feature's tests (before the merge), `scripts/coverage_gate.py diff --base-ref origin/main --threshold 90`: 97.75% (955/977). - `uv run ruff check`, `uv run ruff format --check`, `make lint-imports`, `make lint-types`: pass. - ui-web (the merge touches no frontend, i18n or RPC contract file): `npm run gen:check` (240 methods), `npm run lint`, `npm run type-check`, `npx vitest run` (248 files / 3923 passed), `npm run build` and `python3 ui-web/build.py` (both boot snapshots match), `check-page.mjs`, `check-css.mjs`, `check-class-namespace.mjs`: pass. - ui-tui: `npm run lint`, `npm run lint:rpc`, `npm run lint:i18n`, `npm run type-check`, `npm test` (144 files / 2111 passed), `npm run build`: pass. - `uv run --group docs mkdocs build -f docs-site/mkdocs.yml --strict`: pass. - `make check-source-language check-large-files check-commits`: pass. - Headless Chromium against a real gateway (`raven web --foreground` on a fresh raven home, at 1280 and 360 px): imported a real export and a real bug report through the page, opened both read-only, read a 122-message model input to its end in the trajectory view, used both duplicate choices, renamed and reloaded, deleted, and uploaded a text file; no page errors. The same flow on the built page with offline fixtures. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk - `imported.upload` takes untrusted archives. The unpacker is bounded and refuses unsafe members, the guard is an allow-list, and the SessionManager refuses imported keys as a backstop; the import directory is under the raven home, which `fs.*` and `/file` already refuse to serve. - An export is not redacted, so importing someone else's export gives you its raw contents; the docs say so. - Two processes sharing one raven home (for example `raven serve` and `raven web`) do not see each other's import slot, so importing the same package in both at once can leave two copies; the extra one can be deleted. - Rollback: revert the squash commit. Imported data stays in `<raven home>/imports/`, which older versions ignore and which can be removed by hand. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A --------- Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
109 lines
5.9 KiB
JavaScript
109 lines
5.9 KiB
JavaScript
/* What each fixture responder is called with, for the two gates next door.
|
|
*
|
|
* Every offline responder is exercised, so every one of them needs a call that
|
|
* makes sense: an id the library really holds, a name one of its rows really
|
|
* has. The defaults are `{}` -- a responder that ignores its params needs no
|
|
* entry -- and a method absent from the library is skipped by the gates rather
|
|
* than listed here, so adding a domain does not mean editing this file first.
|
|
*/
|
|
|
|
/** One call per method. Anything not named here is called with `{}`. */
|
|
export const PARAMS = {
|
|
'system.hello': { client_version: '0.1.0', surface: 'page' },
|
|
'config.get': { keys: ['language', 'permissions.mode'] },
|
|
'config.set': { key: 'language', value: 'en' },
|
|
'config.unset': { key: 'language' },
|
|
'settings.set': { key: 'tools.disabledTools', value: ['write_file'] },
|
|
'settings.usage': { session_key: null },
|
|
'settings.everosSet': { section: 'memory', clear: true },
|
|
'session.list': { channels: ['tui', 'cron', 'imported'] },
|
|
'session.resume': { session_id: 'a' },
|
|
'imported.upload': { name: 'report.tar.gz', content_b64: 'AAAA' },
|
|
'session.title': { session_id: 'a', title: 'renamed' },
|
|
'session.pin': { session_id: 'a', pinned: true },
|
|
'session.archive': { session_id: 'f', archived: true },
|
|
'session.delete': { session_id: 'd' },
|
|
'session.clear': { session_id: 'c' },
|
|
'session.compress': { session_id: 'b' },
|
|
'session.branch': { session_id: 'b' },
|
|
'session.set_mode': { session_key: 'b', mode: 'max' },
|
|
'turn.subscribe': { session_key: 'a' },
|
|
'turn.unsubscribe': { subscription_id: 'sub-1' },
|
|
'turn.send': { session_key: 'a', content: 'look at the market' },
|
|
'turn.cancel': { session_key: 'a' },
|
|
'deliverables.list': { session_key: 'a' },
|
|
'dag.get': { run_id: '20260821T004119Z-4c1d8ea2', session_key: 'a' },
|
|
'dag.node': { run_id: '20260821T004119Z-4c1d8ea2', node: 'compare', session_key: 'a' },
|
|
'cron.runs': { id: 'j1' },
|
|
'cron.set_enabled': { id: 'j2', enabled: true },
|
|
'cron.delete': { id: 'j4' },
|
|
'cron.save': { id: 'j1', name: 'j1', message: 'do it', kind: 'cron', expr: '0 8 * * *' },
|
|
'cron.run_now': { id: 'j1' },
|
|
'channels.configure': { name: 'slack', fields: { bot_token: 'x' }, enabled: true },
|
|
'channels.qr': { name: 'weixin' },
|
|
'skillhub.search': { query: '', page: 1, limit: 24 },
|
|
'skillhub.detail': { id: 'sh-code-review' },
|
|
'skillhub.install': { id: 'sh-meeting-notes' },
|
|
'skillhub.remove': { name: 'SQL 规范' },
|
|
'plughub.search': { q: '', category: '' },
|
|
'plughub.detail': { id: 'github' },
|
|
'plug.install': { id: 'notion', form: {} },
|
|
'plug.remove': { name: 'notion' },
|
|
'plug.toggle': { name: 'github', enabled: false },
|
|
'plug.auth': { name: 'github' },
|
|
'plug.retry': { name: 'github' },
|
|
'plug.revoke': { name: 'websearch' },
|
|
'plug.configure': { name: 'github', form: { token: 'x' } },
|
|
'skills.manage': { action: 'list' },
|
|
'subagents.list': { probe: false },
|
|
'subagents.add': { preset: 'codex', name: 'codex' },
|
|
'subagents.update': { name: 'claude_code', description: 'x' },
|
|
'subagents.toggle': { name: 'codex', enabled: true },
|
|
'subagents.remove': { name: 'codex' },
|
|
'subagents.build': { name: 'Raven-PPT' },
|
|
'subagents.test': { name: 'claude_code', source: 'config' },
|
|
'subagents.test_cancel': { name: 'claude_code' },
|
|
'subagents.probe': { names: ['claude_code'] },
|
|
'subagents.instances': { session_key: 'a' },
|
|
'subagents.instance.history': { session_key: 'a', agent: 'raven', handle: 'h' },
|
|
'subagent.list': { session_id: 'a' },
|
|
'memory.list': { kind: 'episodes', page: 1, page_size: 20, q: null },
|
|
'trajectory.list': { session_key: 'gui:demo' },
|
|
'trajectory.changes': { session_key: 'gui:demo', epoch: 'demo-1', after_revision: 8 },
|
|
'trajectory.detail': { session_key: 'gui:demo', entry_id: 't:tool1:tool.output' },
|
|
'trajectory.block': { session_key: 'gui:demo', entry_id: 't:tool1:tool.output', entry_revision: 6, epoch: 'demo-1', block_id: 'error' },
|
|
'trajectory.turns': { session_key: 'gui:demo' },
|
|
'trajectory.export': { session_key: 'gui:demo', trace_ids: ['trace-demo-1'], file_name: 'demo.tar.gz' },
|
|
'trajectory.export_status': { job_id: 'exj-demo' },
|
|
'trajectory.export_cancel': { job_id: 'exj-demo' },
|
|
'bugreport.start': { session_key: 'gui:demo', trace_ids: ['trace-demo-1'], problem: { description: 'the reply was wrong' } },
|
|
'bugreport.status': { report_id: 'rs-demo' },
|
|
'bugreport.item': { report_id: 'rs-demo', item_id: 'tok1' },
|
|
'bugreport.decide': { report_id: 'rs-demo', decisions: [{ item_id: 'tok1', action: 'kept' }, { item_id: 'jwt1', action: 'redacted' }], acknowledged: ['pk1'] },
|
|
'bugreport.upload': { report_id: 'rs-demo', risk_accepted: true },
|
|
'bugreport.retry_upload': { report_id: 'rs-demo' },
|
|
'bugreport.cancel': { report_id: 'rs-demo' },
|
|
'model.save_key': { slug: 'openai', api_key: 'sk-x' },
|
|
'model.disconnect': { slug: 'openai' },
|
|
'model.reveal_key': { slug: 'anthropic' },
|
|
'model.add_model': { slug: 'openai', model: 'gpt-5.2' },
|
|
'model.remove_model': { slug: 'openai', model: 'gpt-5.1' },
|
|
'model.fetch_models': { slug: 'openai' },
|
|
'model.set_protocol': { slug: 'openai', model: 'gpt-5.1', protocol: 'responses' },
|
|
'model.add_models': { slug: 'openai', models: ['gpt-5.2'] },
|
|
'model.set_fields': { slug: 'openai', fields: { api_base: 'https://api.openai.com/v1' } },
|
|
'model.oauth_login': { slug: 'minimax_global' },
|
|
'fs.upload': { name: 'notes.md', content_b64: '' },
|
|
'fs.reveal': { path: 'research/gtm-compare.md', session: 'a' },
|
|
'fs.open': { path: 'research/gtm-compare.md', session: 'a' },
|
|
'browser.open': { url: 'https://example.invalid' },
|
|
'browser.tabs': { session_key: 'a' },
|
|
'browser.mode': { mode: 'read' },
|
|
'browser.input': { action: 'click', ref: 'r1' },
|
|
'browser.watch': { on: true },
|
|
'browser.frame': { quality: 60 },
|
|
'browser.read': { session_key: 'a' },
|
|
'knowledge.documents.list': { base_id: 'kb1' },
|
|
'knowledge.search': { query: 'x' },
|
|
}
|