@deepseek-ai/dsh-deepseek-chat-import 0.0.0-stage → 0.2.2-rc.4
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/LICENSE +21 -0
- package/README.i18n.yaml +70 -0
- package/README.md +178 -2
- package/README.zh.md +179 -0
- package/cordis.patch.yml +6 -0
- package/docs/DETAIL.md +9 -0
- package/docs/DETAIL.zh.md +9 -0
- package/icon.svg +11 -0
- package/lib/client.js +5 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +1725 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +68 -0
- package/lib/typert.remote-client.d.ts +25 -0
- package/lib/typert.remote-client.d.ts.map +1 -0
- package/lib/typert.remote-client.js +33 -0
- package/lib/types/archive.d.ts +106 -0
- package/lib/types/archive.d.ts.map +1 -0
- package/lib/types/archive.js.map +1 -0
- package/lib/types/client/ImportSessions.d.ts +37 -0
- package/lib/types/client/ImportSessions.d.ts.map +1 -0
- package/lib/types/client/ImportSessions.js.map +1 -0
- package/lib/types/client/index.d.ts +19 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/index.js.map +1 -0
- package/lib/types/client/locales.d.ts +278 -0
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/locales.js.map +1 -0
- package/lib/types/client/mount.d.ts +13 -0
- package/lib/types/client/mount.d.ts.map +1 -0
- package/lib/types/client/mount.js.map +1 -0
- package/lib/types/client/upload.d.ts +32 -0
- package/lib/types/client/upload.d.ts.map +1 -0
- package/lib/types/client/upload.js.map +1 -0
- package/lib/types/conversation.d.ts +68 -0
- package/lib/types/conversation.d.ts.map +1 -0
- package/lib/types/conversation.js.map +1 -0
- package/lib/types/format.d.ts +168 -0
- package/lib/types/format.d.ts.map +1 -0
- package/lib/types/format.js.map +1 -0
- package/lib/types/importer.d.ts +101 -0
- package/lib/types/importer.d.ts.map +1 -0
- package/lib/types/importer.js.map +1 -0
- package/lib/types/index.d.ts +53 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/protocol.d.ts +9 -0
- package/lib/types/protocol.d.ts.map +1 -0
- package/lib/types/protocol.js.map +1 -0
- package/lib/types/types.d.ts +65 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/types.js.map +1 -0
- package/lib/types/upload.d.ts +52 -0
- package/lib/types/upload.d.ts.map +1 -0
- package/lib/types/upload.js.map +1 -0
- package/locale/de.json +7 -0
- package/locale/en.json +7 -0
- package/locale/es.json +7 -0
- package/locale/fr.json +7 -0
- package/locale/ja.json +7 -0
- package/locale/pt.json +7 -0
- package/locale/ru.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +130 -3
- package/src/archive.ts +312 -0
- package/src/client/ImportSessions.module.css +166 -0
- package/src/client/ImportSessions.tsx +273 -0
- package/src/client/index.ts +25 -0
- package/src/client/locales.ts +287 -0
- package/src/client/mount.ts +65 -0
- package/src/client/upload.ts +314 -0
- package/src/conversation.ts +488 -0
- package/src/css-modules.d.ts +5 -0
- package/src/format.ts +147 -0
- package/src/importer.ts +598 -0
- package/src/index.ts +133 -0
- package/src/protocol.ts +10 -0
- package/src/types.ts +73 -0
- package/src/upload.ts +196 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/experimental/deepseek-chat-import/README.md
|
|
5
|
+
/:
|
|
6
|
+
en: 68134bddc70ca270
|
|
7
|
+
zh: 56bbe0a3794ad728
|
|
8
|
+
/deepseek-ai-dsh-deepseek-chat-import:
|
|
9
|
+
en: 25b748a601692e3b
|
|
10
|
+
zh: 5c639272cfca4a71
|
|
11
|
+
/deepseek-ai-dsh-deepseek-chat-import/summary:
|
|
12
|
+
en: f06a7cd3d343e196
|
|
13
|
+
zh: ecb02ff15f6440c2
|
|
14
|
+
/deepseek-ai-dsh-deepseek-chat-import/table-of-contents:
|
|
15
|
+
en: b563e4ec4727d0de
|
|
16
|
+
zh: 44c7102c1efbf197
|
|
17
|
+
/deepseek-ai-dsh-deepseek-chat-import/use-this-package:
|
|
18
|
+
en: d03624fa0de6f49f
|
|
19
|
+
zh: 785f75ed1ca4e7f7
|
|
20
|
+
/deepseek-ai-dsh-deepseek-chat-import/use-this-package/import-a-chat-export:
|
|
21
|
+
en: b7c739f34052a302
|
|
22
|
+
zh: e39bdb3d4f41fbc7
|
|
23
|
+
/deepseek-ai-dsh-deepseek-chat-import/use-this-package/configuration:
|
|
24
|
+
en: beea8ad32b34feb4
|
|
25
|
+
zh: 267e1ede6fd13b7b
|
|
26
|
+
/deepseek-ai-dsh-deepseek-chat-import/use-this-package/import-results:
|
|
27
|
+
en: cc7e1dbbff7fcbf1
|
|
28
|
+
zh: f11aeec38ce7d23f
|
|
29
|
+
/deepseek-ai-dsh-deepseek-chat-import/use-this-package/failures:
|
|
30
|
+
en: 4902099a5445983d
|
|
31
|
+
zh: 32cbb073284032b9
|
|
32
|
+
/deepseek-ai-dsh-deepseek-chat-import/understand-the-implementation:
|
|
33
|
+
en: 42b15ac6321706aa
|
|
34
|
+
zh: e15901d8462ec7c7
|
|
35
|
+
/deepseek-ai-dsh-deepseek-chat-import/understand-the-implementation/modules:
|
|
36
|
+
en: 29729f79e3034582
|
|
37
|
+
zh: 15b9cb9842b7ee37
|
|
38
|
+
/deepseek-ai-dsh-deepseek-chat-import/understand-the-implementation/upload:
|
|
39
|
+
en: e8515279f51bac3a
|
|
40
|
+
zh: 12e0d7960a2625c1
|
|
41
|
+
/deepseek-ai-dsh-deepseek-chat-import/understand-the-implementation/event-mapping:
|
|
42
|
+
en: 05ade59232b3604b
|
|
43
|
+
zh: 3174025d9eb3173b
|
|
44
|
+
/deepseek-ai-dsh-deepseek-chat-import/understand-the-implementation/writes:
|
|
45
|
+
en: 9c5d86f4f1e864f5
|
|
46
|
+
zh: 9e884134234b89c8
|
|
47
|
+
/deepseek-ai-dsh-deepseek-chat-import/further-exploration:
|
|
48
|
+
en: f71d6e6824792caf
|
|
49
|
+
zh: ac6ff901fad93a6e
|
|
50
|
+
/deepseek-ai-dsh-deepseek-chat-import/model-experience:
|
|
51
|
+
en: 215e7ba838619b7b
|
|
52
|
+
zh: a311da3843709f90
|
|
53
|
+
/deepseek-ai-dsh-deepseek-chat-import/model-experience/imported-history:
|
|
54
|
+
en: 9cdfa5c1981e07c4
|
|
55
|
+
zh: 89aa74f317ed5862
|
|
56
|
+
/deepseek-ai-dsh-deepseek-chat-import/model-experience/imported-history/what-the-model-sees:
|
|
57
|
+
en: 8c7f74983502dea6
|
|
58
|
+
zh: 3ce28fe38df55485
|
|
59
|
+
/deepseek-ai-dsh-deepseek-chat-import/model-experience/imported-history/token-effect:
|
|
60
|
+
en: 4089ec9e1b4dff0d
|
|
61
|
+
zh: 39019590c45a13a1
|
|
62
|
+
/deepseek-ai-dsh-deepseek-chat-import/model-experience/imported-history/kv-cache-effect:
|
|
63
|
+
en: e1e24cae9826663a
|
|
64
|
+
zh: dfe9c44dba9edd8d
|
|
65
|
+
/deepseek-ai-dsh-deepseek-chat-import/known-limitations-and-deferred-work:
|
|
66
|
+
en: 73fe50a3fda57690
|
|
67
|
+
zh: 22f4f4b867d56b71
|
|
68
|
+
/deepseek-ai-dsh-deepseek-chat-import/known-limitations-and-deferred-work/dev-note:
|
|
69
|
+
en: c48fda408d6da0e1
|
|
70
|
+
zh: 4c484c202694553c
|
package/README.md
CHANGED
|
@@ -1,3 +1,179 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
description: "Import DeepSeek website chat exports: upload a deepseek_data ZIP from the browser and store its recent conversations as Sessions in a chosen Workspace."
|
|
3
|
+
kind: "package-bundle"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# @deepseek-ai/dsh-deepseek-chat-import
|
|
7
|
+
|
|
8
|
+
English | [中文](README.zh.md)
|
|
9
|
+
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
Bring the chats exported from the DeepSeek website (chat.deepseek.com) into DSH and continue them. After you enable this optional bundle, a button right of "New session" uploads the `deepseek_data-*.zip` file to the Host, which stores the most recent conversations as Sessions in the Workspace you choose. Imported Sessions keep their original titles and times and show the original questions with their attached files, reasoning, web search cards, read links, and answers. The [Agent Note](../../../.agents/notes/implemented/feature/2026-11-11-deepseek-chat-export-import.md) records the design and its trade-offs.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Model Experience](#model-experience)
|
|
20
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
21
|
+
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
<a id="use-this-package"></a>
|
|
25
|
+
## Use this package
|
|
26
|
+
|
|
27
|
+
In the GUI, open the Plugins page, click "More" to open "Experimental plugins", and switch on "DeepSeek chat import". The installation ships the bundle switched off; the [plugin manager page](../../client/ui-plugin-manager/README.md#use-this-package) owns how More bundles are listed and enabled. Switching it off removes the button and the upload route; imported Sessions stay.
|
|
28
|
+
|
|
29
|
+
The bundle inserts one Host row, which an explicit composition can also mount:
|
|
30
|
+
|
|
31
|
+
```yaml
|
|
32
|
+
- id: deepseek-chat-import
|
|
33
|
+
name: '@deepseek-ai/dsh-deepseek-chat-import'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The Host half injects `typert`, `connection`, `sessionPersistence`, and `workspaceRegistry`, and reads `sessionProjectionCache` and `attachments` when they are mounted. The browser half injects `remote`, `slots`, `locale`, and `sessions`, and wraps the ui-sidebar New Session row through its `sidebar.session.action` HOC slot: it returns the row content followed by its own button, or the content alone for a Peer that may not import. Only the owner imports: the upload route admits only owner Peers, `limits()` refuses every other principal, and the button shows only for a Peer that may call `deepseekChatImport/limits`.
|
|
37
|
+
|
|
38
|
+
### Import a chat export
|
|
39
|
+
|
|
40
|
+
1. On the DeepSeek website, export all chats and download the `deepseek_data-*.zip` file.
|
|
41
|
+
2. Click the upload-arrow button right of "New session".
|
|
42
|
+
3. Under "Export file", choose the ZIP file. Under "Workspace", keep the preselected Workspace of the current Session, pick another one, or choose "Add workspace…" to add a directory.
|
|
43
|
+
4. Click "Import". On a served page the progress bar shows the upload percentage; a page that carries the archive over its own transport has no byte progress, so the bar starts with the Host reading the archive. Both then show "Importing n/K" while Sessions are written; closing the dialog cancels the request.
|
|
44
|
+
5. The dialog reports how many Sessions it imported into which Workspace, how many older conversations exceeded the limit, and how many conversations it could not import. However the attempt ends, the Session list refreshes, so Sessions written before a failure or cancellation appear.
|
|
45
|
+
|
|
46
|
+
### Configuration
|
|
47
|
+
|
|
48
|
+
| Field | Default | Meaning |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `maxSessions` | `1000` | Most Sessions one import writes, choosing the conversations the export index lists as most recently updated. |
|
|
51
|
+
| `maxUploadBytes` | `536870912` (512 MiB) | Largest export archive one upload may carry; the whole archive is held in memory while it is imported. |
|
|
52
|
+
| `maxEntryBytes` | `268435456` (256 MiB) | Largest declared uncompressed size of one archive entry; a larger entry is never decompressed. |
|
|
53
|
+
| `maxTitleBytes` | `80` | Largest UTF-8 size of an imported title; keep it equal to the session-title `maxTitleBytes` of the composition. |
|
|
54
|
+
|
|
55
|
+
### Import results
|
|
56
|
+
|
|
57
|
+
- Each website conversation becomes one Session. The imported chain ends at the message named by `current_message_id`; when that field is absent, null, or names no message, it ends at the message with the largest id. Other branches are dropped.
|
|
58
|
+
- `chat_session_index.json` selects the conversations: the newest `maxSessions` by its `updated_at` (ties by `inserted_at`, then id) are imported in archive order, one at a time. When one of them fails, the next older conversation the index lists takes its place.
|
|
59
|
+
- Titles keep the original title with whitespace collapsed and truncated to `maxTitleBytes`, pinned as a user title, so no title generation runs. A title that is empty after normalization writes no title. Event times follow the export and never decrease; the `elapsed_secs` of reasoning advances the time of the following steps.
|
|
60
|
+
- A user message without text, a stored image, or a file keeps one empty text block: the row renders, and DeepSeek request serialization drops it like any other empty user message, so that turn's question is absent from the model context (a first turn without text therefore starts the request with the assistant message).
|
|
61
|
+
- Images in user messages become image attachments when the export contains the file (png, jpg, jpeg, webp, or gif) and the attachment service stores it. Other images and every non-image file become a synthetic file card that shows a file-type icon, the name, and the exported size; the card cannot be opened, holds no bytes, and reaches the model as a file handle whose named path holds no bytes. The Host log records why each image was not stored.
|
|
62
|
+
- Web searches become `web_search` calls and opened pages become `web_fetch` calls, shown as the standard search and fetch cards. A search the export records as failed becomes an error result. A search still in progress, an opened page without an address, and an image search are left out, as the website leaves them out of the reply.
|
|
63
|
+
- A `READ_LINK` record becomes one Markdown link line per linked page, `[title](url)`, with the URL as its own text when the title is missing and the title alone when the URL is missing. A `PARTIAL_FILE_READ`, `TOOL_FIND`, `TIP`, or `CONTENT_RISK` record is left out, as the website shows none of them as reply text.
|
|
64
|
+
- A question whose reply was withdrawn by content filtering (`CONTENT_FILTER`) is left out together with the reply: neither appears, and the model never sees them. A conversation with no other turn is not imported.
|
|
65
|
+
- Other replies whose status is not `FINISHED`, template replies, and replies without importable content stay out of the model context; their turn ends with an error row that shows the reason and a fixed `DEEPSEEK_EXPORT_*` code. The question stays.
|
|
66
|
+
- Importing the same export again writes another set of Sessions.
|
|
67
|
+
|
|
68
|
+
### Failures
|
|
69
|
+
|
|
70
|
+
Failures detected before the streaming pass write nothing. Each conversation is fully converted and seed-validated with `Session.create` before it is written; a conversation that fails is skipped and does not stop the others. An archive whose structure breaks during the pass fails as `unreadable-archive` after the Sessions delivered before the break were written, and the response does not list them. The dialog shows the localized explanation of each reason; a `too-large` failure reported by the Host instead shows the Host's own message, which names the limit it applied.
|
|
71
|
+
|
|
72
|
+
| Reason | When |
|
|
73
|
+
|---|---|
|
|
74
|
+
| `too-large` | The file exceeds `maxUploadBytes`, or an entry declares or stores more than `maxEntryBytes` (including `manifest.json` and `chat_session_index.json`); the browser checks the file size first, the Host stops reading at `maxUploadBytes`, and an entry over `maxEntryBytes` is never decompressed. |
|
|
75
|
+
| `unreadable-archive` | The file is not a readable ZIP archive, `manifest.json` is damaged, a stored entry declares a size other than the bytes it holds, or two central-directory entries share a name. |
|
|
76
|
+
| `missing-manifest` | The archive has no `manifest.json`. |
|
|
77
|
+
| `missing-index` | The archive has no readable `chat_session_index.json`. |
|
|
78
|
+
| `unsupported-version` | `manifest.json` does not declare `export_format_version` 3. |
|
|
79
|
+
| `no-conversations` | `chat_session_index.json` lists no conversation. |
|
|
80
|
+
| `workspace-not-found` | The chosen Workspace no longer exists. During an import, the import stops and keeps the Sessions already written. |
|
|
81
|
+
| `busy` | Another import is running on this Host. |
|
|
82
|
+
|
|
83
|
+
A conversation file that is oversized, damaged, cannot be parsed or converted, or whose Session cannot be stored, is skipped and counted in the result; the Host log names the defect. An image the archive cannot deliver becomes a file card and is named in the Host log. Cancelling keeps the Sessions already written.
|
|
84
|
+
|
|
85
|
+
-----
|
|
86
|
+
|
|
87
|
+
<a id="understand-the-implementation"></a>
|
|
88
|
+
## Understand the implementation
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary>Implementation internals — click to expand</summary>
|
|
92
|
+
|
|
93
|
+
### Modules
|
|
94
|
+
|
|
95
|
+
| File | Responsibility |
|
|
96
|
+
|---|---|
|
|
97
|
+
| [`src/protocol.ts`](src/protocol.ts) | The upload path `/api/deepseek-chat-import/archive` and its document-relative form |
|
|
98
|
+
| [`src/upload.ts`](src/upload.ts) | `createUploadRoute()`: request validation, bounded in-memory buffering, the streamed NDJSON answer, and cancellation |
|
|
99
|
+
| [`src/archive.ts`](src/archive.ts) | `openExportArchive()`: the ZIP central directory, streaming passes that inflate only the entries they are asked for within `maxEntryBytes`, and a by-name read |
|
|
100
|
+
| [`src/format.ts`](src/format.ts) | zod validation of `manifest.json`, conversation files, and the fragment types this package maps |
|
|
101
|
+
| [`src/conversation.ts`](src/conversation.ts) | Pure `selectBranch()` and `convertConversation()`: message tree to seed events |
|
|
102
|
+
| [`src/importer.ts`](src/importer.ts) | `importDeepseekChatExport()`: index selection, the image pass, the conversation pass, writes, and Workspace attachment |
|
|
103
|
+
| [`src/index.ts`](src/index.ts) | `DeepseekChatImportService`, its `Config`, the single import slot, the route registration, and `@Remote limits()` |
|
|
104
|
+
| [`src/client/`](src/client/index.ts) | Button, dialog, browser upload over the page carrier or XHR, and locale dictionaries |
|
|
105
|
+
| [`cordis.patch.yml`](cordis.patch.yml) | The optional bundle row |
|
|
106
|
+
|
|
107
|
+
### Upload
|
|
108
|
+
|
|
109
|
+
The browser calls `limits()` and rejects a file over `maxUploadBytes` before sending it. A served page posts the file with `XMLHttpRequest` (for upload progress) to `api/deepseek-chat-import/archive?workspaceId=…`, resolved against the document base. A page whose Host runs in another execution context, such as the static Cloudflare Pages preview, supplies `__DSH_TRANSPORT__.fetch` instead: the archive goes through that carrier, which reports no byte progress, so the dialog moves straight to the reading and importing phases. The Host registers this path as an exact route on `ctx.connection.fetch`, which only owner Peers reach. The route requires `application/octet-stream`, takes the service's single import slot, resolves the Workspace, and reads the streaming body into one buffer sized from `content-length` until it ends or exceeds the limit. The upload is never written to disk. The answer is `application/x-ndjson`: `{ type: 'progress', done, total }` lines while Sessions are written, then one `{ type: 'outcome', outcome }` line whose `outcome` is `{ ok: true, value }` or `{ ok: false, error: { reason, message } }`; the browser reads complete lines as they arrive and settles the answer as invalid at the first line that is not a valid protocol value, cancelling the rest of the stream so a later outcome cannot replace it. Closing the dialog, a dropped connection, or unloading the plugin aborts the import, and unloading completes only after the import stops writing.
|
|
110
|
+
|
|
111
|
+
### Event mapping
|
|
112
|
+
|
|
113
|
+
Each USER message opens a turn: `turn/start`, `step/start`, `user/message`. The first turn also writes an empty `system/message` before its `user/message` as the protected surface head, which a resumed Agent replaces with the real system prompt; it adds no model message and no visible row. A finished reply is split into steps in fragment order: THINK and RESPONSE append to the current step's `assistant/message`, and web search and opened pages append tool calls. Tool calls that carry a `stage_id` share one step while the value stays the same, and a different value starts a new step; a step opened by text adopts the stage of the first call that joins it, so a step that is not last always has a call. Reasoning or text after a tool call starts a new step. The turn ends with `turn/end { kind: 'completed' }`. An excluded reply writes no `assistant/message` and ends with `turn/end { kind: 'error' }`. Assistant messages carry the source `deepseek-chat-export` / `deepseek-chat-export`, an empty `stream`, and no `usage`, request header, or model selection. The [Agent Note](../../../.agents/notes/implemented/feature/2026-11-11-deepseek-chat-export-import.md) owns the complete fragment and status tables.
|
|
114
|
+
|
|
115
|
+
### Writes
|
|
116
|
+
|
|
117
|
+
The import creates no live Agent and holds one conversation at a time. The index selects the conversations; one streaming pass stores the images of every chosen conversation before any conversation is parsed, and a second converts and writes each chosen conversation as it arrives. The conversation pass looks the stored references up, so archive entry order does not matter and no image is read by name on the main path. An image that is missing, oversized, damaged, of an unsupported type, or rejected by the attachment service becomes a synthetic file card with one Host warning. Before writing, it checks that the Workspace is still registered and its directory exists. `Session.create()` then runs the same seed validation as a live Session; `sessionPersistence.create()` writes the header and events, and the handle is flushed and closed. `coldSnapshot()` on the projection cache refreshes the title and activity time the sidebar reads, and `attachSession()` adds the Session to the Workspace. The header's `createdAt` is the time of the first event, and `cwd` is the Workspace's canonical path. The stored log has no `session/end-seed`; the ordinary resume path appends it on first open. The import yields to the event loop between conversations. A cold write emits no `session/created`, so the browser calls `sessions.refresh()` after every attempt.
|
|
118
|
+
|
|
119
|
+
</details>
|
|
120
|
+
|
|
121
|
+
-----
|
|
122
|
+
|
|
123
|
+
<a id="further-exploration"></a>
|
|
124
|
+
## Further Exploration
|
|
125
|
+
|
|
126
|
+
- [Design Agent Note](../../../.agents/notes/implemented/feature/2026-11-11-deepseek-chat-export-import.md) — format differences, mappings, alternatives, and consequences.
|
|
127
|
+
- [Session persistence](../../session/session-persistence/README.md) — the store the import writes.
|
|
128
|
+
- [Workspace registry](../../workspace/workspace/README.md) — Workspace membership.
|
|
129
|
+
- [Web tools](../../web/tool-web/README.md) — the search and fetch results and cards that imported calls reuse.
|
|
130
|
+
|
|
131
|
+
-----
|
|
132
|
+
|
|
133
|
+
<a id="model-experience"></a>
|
|
134
|
+
## Model Experience
|
|
135
|
+
|
|
136
|
+
### Imported history
|
|
137
|
+
|
|
138
|
+
#### What the model sees
|
|
139
|
+
|
|
140
|
+
The import sends no model request. When the user continues an imported Session, the model sees the imported questions, reasoning, `web_search` / `web_fetch` calls and results, answers, Markdown link lines of read-link records, and the file handles of synthetic cards, whose bytes do not exist; content-filtered rounds, excluded replies, template text, tips, page finds, partial-read notices, and `CONTENT_RISK` disclaimers are absent. A synthetic file card enters the context as the file handle that names the file and its size and points at a path that holds nothing; a question without any content sends no message. A fetch result holds only the page title, URL, and a note that the page body is not in the export.
|
|
141
|
+
|
|
142
|
+
#### Token effect
|
|
143
|
+
|
|
144
|
+
The first request after resume sends the whole imported history. Imported reasoning is sent as unsigned thinking and increases that request's input tokens; imported images are sent on image-capable routes and replaced by the general omission note elsewhere.
|
|
145
|
+
|
|
146
|
+
#### KV Cache effect
|
|
147
|
+
|
|
148
|
+
The first request after resume has no reusable cached prefix; later requests extend it like any other Session.
|
|
149
|
+
|
|
150
|
+
## Known Limitations and Deferred Work
|
|
151
|
+
|
|
152
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
153
|
+
|
|
154
|
+
- **Archive held in memory** — the whole upload stays in Host memory during the import, bounded by `maxUploadBytes`, plus one converted conversation, one image entry at a time, and the references of the images stored so far; one Host runs one import at a time. Conversations and images the index does not select are never inflated.
|
|
155
|
+
- **Synchronous inflation** — the streaming pass inflates each selected entry synchronously with fflate's `UnzipInflate`. An entry that declares a small `originalSize` but carries highly compressed data keeps inflating until the entry ends, and `maxEntryBytes` only stops those bytes being kept. A crafted archive can occupy the Host for a long time before the entry is rejected.
|
|
156
|
+
- **Duplicate local file headers** — duplicate detection covers the central directory only. A second local file header renamed to an existing entry name is not detected, so an archive can deliver more conversations than the index lists, and the write count is not additionally guarded.
|
|
157
|
+
- **Partial writes on a corrupted archive** — an archive whose structure breaks after some entries were delivered fails as `unreadable-archive` after those Sessions were written, and the failure response does not list them.
|
|
158
|
+
- **`read()` truncates** — `ExportArchive.read` returns at most the size an entry declares, truncating one that inflates to more, while `stream` reports that condition as a size failure. The manifest, the index, and a replacement conversation are read by name, so one of them can arrive truncated. Each by-name read also re-parses the whole central directory: the manifest and the index pay it once each, and a replacement conversation pays once more.
|
|
159
|
+
- **No upload percentage on the carrier path** — a page that carries the archive through `__DSH_TRANSPORT__.fetch` reports no byte progress; the dialog shows only the reading and importing phases.
|
|
160
|
+
- **One export structure** — the importer targets the 2026-11-12 structure: `current_message_id`, `stage_id`, the tool statuses, the link and find fields, and the new record types. The fields that structure added are read as optional, so an older v3 archive still imports, but it is not a supported target.
|
|
161
|
+
- **ZIP upload only** — an extracted export directory or a Host path cannot be imported.
|
|
162
|
+
- **Re-import duplicates** — importing the same export again writes new Sessions; the import does not track which conversations it already imported.
|
|
163
|
+
- **Synthetic file cards** — images the export lacks, of an unsupported type, over `maxEntryBytes`, or rejected by the attachment service (for example over its size limit), and every non-image file, become cards without bytes: they show the name and the exported size, cannot be opened, and name no stored object, so a model that reads the named path finds nothing. Non-image file bodies are not in the export.
|
|
164
|
+
- **Images without a referencing event** — the image pass stores every image entry of a selected conversation before any conversation is parsed. Images of a withdrawn round, of a branch the import drops, and of a conversation whose conversion or `Session.create` seed validation later fails stay as attachments that no event references. Neither `SessionPersistence` nor the attachment store offers a removal, so those bytes remain.
|
|
165
|
+
- **Stored but not attached** — when adding a written Session to the Workspace fails, `SessionPersistence` offers no removal, so the Session stays stored outside the Workspace; the result lists it in `skipped` with its id.
|
|
166
|
+
- **Separate title limit** — the session-title service does not expose its `maxTitleBytes`, so a composition that changes it sets this package's `maxTitleBytes` to the same value.
|
|
167
|
+
- **Content not imported** — other branches, content-filtered rounds, `CONTENT_RISK` disclaimers, `TIP`, `TOOL_FIND`, and `PARTIAL_FILE_READ` records, encrypted `READ_LINK` bodies (only the exported URL and title are shown), search-result `snippet` and `site_name`, the `pinned` flag, per-token times, and `accumulated_token_usage`.
|
|
168
|
+
- **English diagnostics** — the explanations of excluded replies and of a failed search are fixed English text in the log and the tool result, and a `too-large` failure reported by the Host shows its English message in the dialog.
|
|
169
|
+
- **Inferred tool records** — imported `web_search` / `web_fetch` calls have no matching request-header tool record, and the fetch card's `statusCode: 200` is inferred from a successful open.
|
|
170
|
+
|
|
171
|
+
<a id="dev-note"></a>
|
|
172
|
+
### Dev Note
|
|
173
|
+
|
|
174
|
+
<details>
|
|
175
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
176
|
+
|
|
177
|
+
`tests/conversation.host.spec.ts` covers the mapping rules, `tests/archive.host.spec.ts` the archive view, `tests/upload.host.spec.ts` the route, `tests/importer.host.spec.ts` the orchestration with synthesized ZIPs, `tests/resume.host.spec.ts` continuing through the production agent loop, `tests/composition.host.spec.ts` the Loader composition, and `tests/*.client.spec.*` the button, dialog, upload, and mounting. The keyless Web snapshot `snapshots/web/deepseek-chat-import/` (driver `apps/web/tests/deepseek-chat-import.e2e.ts`) imports a synthetic export through the route and continues one imported Session with one recorded model turn. When the fragment mapping changes, update the Agent Note's mapping tables in the same change.
|
|
178
|
+
|
|
179
|
+
</details>
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "DeepSeek 官网会话导出导入:在浏览器中上传 deepseek_data ZIP,把其中最近的会话存为所选工作区中的会话。"
|
|
3
|
+
kind: "package-bundle"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @deepseek-ai/dsh-deepseek-chat-import
|
|
7
|
+
|
|
8
|
+
[English](README.md) | 中文
|
|
9
|
+
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
把 DeepSeek 官网(chat.deepseek.com)导出的会话带进 DSH 并继续对话。启用这个可选 bundle 后,“新建会话”右侧的按钮把 `deepseek_data-*.zip` 文件上传到 Host,Host 把最近的会话存为你所选工作区中的会话。导入的会话保留原始标题和时间,显示原有的提问及其附带文件、思考、联网搜索卡片、阅读链接和回答。设计与取舍见 [Agent Note](../../../.agents/notes/implemented/feature/2026-11-11-deepseek-chat-export-import.zh.md)。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [了解实现](#understand-the-implementation)
|
|
18
|
+
- [深入探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与待办工作](#known-limitations-and-deferred-work)
|
|
21
|
+
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
<a id="use-this-package"></a>
|
|
25
|
+
## 使用本包
|
|
26
|
+
|
|
27
|
+
在 GUI 中打开插件页,点击“更多”进入“实验性插件”,打开“DeepSeek 会话导入”。安装包默认附带该 bundle 但处于关闭状态;“更多”列表中 bundle 的展示与启用方式见[插件管理页面](../../client/ui-plugin-manager/README.zh.md#use-this-package)。关闭后按钮与上传路由随之移除,已导入的会话保留。
|
|
28
|
+
|
|
29
|
+
该 bundle 插入一个 Host 行,显式组合也可以直接挂载:
|
|
30
|
+
|
|
31
|
+
```yaml
|
|
32
|
+
- id: deepseek-chat-import
|
|
33
|
+
name: '@deepseek-ai/dsh-deepseek-chat-import'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Host 半包注入 `typert`、`connection`、`sessionPersistence` 和 `workspaceRegistry`,挂载了 `sessionProjectionCache` 与 `attachments` 时读取它们。浏览器半包注入 `remote`、`slots`、`locale` 和 `sessions`,通过 ui-sidebar 的 `sidebar.session.action` HOC 插槽包裹新建会话行:原样返回行内容并追加自己的按钮,对不能导入的 Peer 则只返回行内容。只有 owner 能导入:上传路由只接受 owner Peer,`limits()` 拒绝其他所有 principal,按钮也只对能调用 `deepseekChatImport/limits` 的 Peer 显示。
|
|
37
|
+
|
|
38
|
+
### 导入会话导出
|
|
39
|
+
|
|
40
|
+
1. 在 DeepSeek 官网导出全部会话,下载 `deepseek_data-*.zip` 文件。
|
|
41
|
+
2. 点击“新建会话”右侧的上传箭头按钮。
|
|
42
|
+
3. 在“导出文件”中选择该 ZIP 文件。在“工作区”中保留预选的当前会话所在工作区,或选择其他工作区,或选择“添加工作区…”添加一个目录。
|
|
43
|
+
4. 点击“导入”。在服务页面上,进度条显示上传百分比;如果页面通过自己的传输通道携带压缩包,则没有字节进度,进度条直接从 Host 读取压缩包开始。两种情况下随后都显示写入会话时的“正在导入 n/K”;关闭对话框会取消请求。
|
|
44
|
+
5. 对话框报告导入了多少个会话、导入到哪个工作区、多少个较早的会话超出上限、多少个会话无法导入。无论导入以何种方式结束,会话列表都会刷新,失败或取消之前已写入的会话随之出现。
|
|
45
|
+
|
|
46
|
+
### 配置
|
|
47
|
+
|
|
48
|
+
| 字段 | 默认值 | 含义 |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `maxSessions` | `1000` | 一次导入最多写入的会话数,按导出索引中最近更新的顺序取会话。 |
|
|
51
|
+
| `maxUploadBytes` | `536870912`(512 MiB) | 一次上传可携带的最大导出压缩包;导入期间整个压缩包保存在内存中。 |
|
|
52
|
+
| `maxEntryBytes` | `268435456`(256 MiB) | 压缩包中单个条目声明的最大解压后大小;更大的条目永远不会被解压。 |
|
|
53
|
+
| `maxTitleBytes` | `80` | 导入标题的最大 UTF-8 字节数;应与组合中 session-title 的 `maxTitleBytes` 保持一致。 |
|
|
54
|
+
|
|
55
|
+
### 导入结果
|
|
56
|
+
|
|
57
|
+
- 每个官网会话生成一个会话。导入的链以 `current_message_id` 指定的消息结尾;该字段缺失、为 `null` 或指向不存在的消息时,以 id 最大的消息结尾。其他分支丢弃。
|
|
58
|
+
- 会话由 `chat_session_index.json` 选出:按其中的 `updated_at`(相同则按 `inserted_at`,再按 id)取最新的 `maxSessions` 个,按压缩包顺序逐个导入。其中某个会话失败时,由索引中下一个更旧的会话补位。
|
|
59
|
+
- 标题沿用原标题,折叠空白并截断到 `maxTitleBytes`,固定为用户标题,导入后不触发标题生成。规范化后为空的标题不写入。事件时间沿用导出时间且单调不减;思考的 `elapsed_secs` 计入后续 step 的时间。
|
|
60
|
+
- 没有文本、已保存图片和文件的用户消息保留一个空文本块:这一行照常显示,但 DeepSeek 请求序列化会像对待其它空用户消息一样把它丢掉,该轮提问因此不在模型上下文里(首轮没有文本时,请求会直接从 assistant 消息开始)。
|
|
61
|
+
- 导出包含图片文件(png、jpg、jpeg、webp 或 gif)且附件服务保存成功时,用户消息中的图片成为图片附件。其余图片与所有非图片文件成为合成的文件卡片,显示文件类型图标、名称和导出中的大小;卡片不能打开、没有字节,也不指向任何已保存对象,因此模型按句柄里的路径去读什么也读不到。Host 日志记录每张图片未保存的原因。
|
|
62
|
+
- 联网搜索写成 `web_search` 调用,打开的网页写成 `web_fetch` 调用,显示为标准搜索与抓取卡片。导出记录为失败的搜索写成错误结果。仍在进行中的搜索、没有地址的打开网页和以图搜图都略去,官网的回复里也不显示它们。
|
|
63
|
+
- `READ_LINK` 记录按链接页面逐行写成 Markdown 链接 `[title](url)`;缺少标题时以 URL 作为链接文本,缺少 URL 时只写标题。`PARTIAL_FILE_READ`、`TOOL_FIND`、`TIP` 和 `CONTENT_RISK` 记录不导入,官网同样不把它们显示为回答正文。
|
|
64
|
+
- 回答被内容过滤撤回(`CONTENT_FILTER`)的提问与该回答一起略去:两者都不显示,模型也看不到。没有其他 turn 的会话不导入。
|
|
65
|
+
- 其他状态不是 `FINISHED` 的回答、模板回答以及没有可导入内容的回答不进入模型上下文;该 turn 以错误行结束,显示原因与固定的 `DEEPSEEK_EXPORT_*` 代码。提问保留。
|
|
66
|
+
- 再次导入同一导出会再写入一组会话。
|
|
67
|
+
|
|
68
|
+
### 失败
|
|
69
|
+
|
|
70
|
+
在流式扫描之前检测到的失败不写入任何内容。每个会话在写入前都完成转换,并经 `Session.create` 校验种子;失败的会话被跳过,不影响其他会话。压缩包结构在扫描中途损坏时,会以 `unreadable-archive` 失败,而在那之前交付的会话已经写入;失败应答不会列出它们。对话框显示每种原因的本地化说明;Host 报告的 `too-large` 失败改为显示 Host 自己的说明,其中给出它所应用的上限。
|
|
71
|
+
|
|
72
|
+
| 原因 | 何时出现 |
|
|
73
|
+
|---|---|
|
|
74
|
+
| `too-large` | 文件超过 `maxUploadBytes`,或某条目声明或实际存储的字节数超过 `maxEntryBytes`(包括 `manifest.json` 与 `chat_session_index.json`);浏览器先检查文件大小,Host 读到 `maxUploadBytes` 即停止,超过 `maxEntryBytes` 的条目永远不会被解压。 |
|
|
75
|
+
| `unreadable-archive` | 文件不是可读取的 ZIP 压缩包,`manifest.json` 已损坏,未压缩(stored)条目声明的大小与其实际字节数不一致,或有两个中央目录条目同名。 |
|
|
76
|
+
| `missing-manifest` | 压缩包中没有 `manifest.json`。 |
|
|
77
|
+
| `missing-index` | 压缩包中没有可读取的 `chat_session_index.json`。 |
|
|
78
|
+
| `unsupported-version` | `manifest.json` 声明的 `export_format_version` 不是 3。 |
|
|
79
|
+
| `no-conversations` | `chat_session_index.json` 没有列出任何会话。 |
|
|
80
|
+
| `workspace-not-found` | 所选工作区已不存在。导入过程中出现时,导入停止,已写入的会话保留。 |
|
|
81
|
+
| `busy` | 该 Host 上已有另一个导入正在进行。 |
|
|
82
|
+
|
|
83
|
+
超过上限、已损坏、无法解析或转换的会话文件,以及无法存储的会话,会被跳过并计入结果;Host 日志写明原因。压缩包无法提供的图片成为文件卡片,Host 日志同样写明。取消时已写入的会话保留。
|
|
84
|
+
|
|
85
|
+
-----
|
|
86
|
+
|
|
87
|
+
<a id="understand-the-implementation"></a>
|
|
88
|
+
## 了解实现
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary>实现细节——点击展开</summary>
|
|
92
|
+
|
|
93
|
+
### 模块
|
|
94
|
+
|
|
95
|
+
| 文件 | 职责 |
|
|
96
|
+
|---|---|
|
|
97
|
+
| [`src/protocol.ts`](src/protocol.ts) | 上传路径 `/api/deepseek-chat-import/archive` 及其相对文档的形式 |
|
|
98
|
+
| [`src/upload.ts`](src/upload.ts) | `createUploadRoute()`:请求校验、有界的内存缓存、流式 NDJSON 应答与取消 |
|
|
99
|
+
| [`src/archive.ts`](src/archive.ts) | `openExportArchive()`:ZIP 中央目录、只解压调用方所需条目(受 `maxEntryBytes` 约束)的流式扫描,以及按名读取单个条目 |
|
|
100
|
+
| [`src/format.ts`](src/format.ts) | zod 校验 `manifest.json`、会话文件和本包映射的 fragment 类型 |
|
|
101
|
+
| [`src/conversation.ts`](src/conversation.ts) | 纯函数 `selectBranch()` 与 `convertConversation()`:消息树到种子事件 |
|
|
102
|
+
| [`src/importer.ts`](src/importer.ts) | `importDeepseekChatExport()`:索引选择、图片扫描、会话扫描、写入与附加工作区 |
|
|
103
|
+
| [`src/index.ts`](src/index.ts) | `DeepseekChatImportService`、它的 `Config`、单一导入槽位、路由注册与 `@Remote limits()` |
|
|
104
|
+
| [`src/client/`](src/client/index.ts) | 按钮、对话框、经页面载体或 XHR 的浏览器上传,以及 locale 字典 |
|
|
105
|
+
| [`cordis.patch.yml`](cordis.patch.yml) | 可选 bundle 的行 |
|
|
106
|
+
|
|
107
|
+
### 上传
|
|
108
|
+
|
|
109
|
+
浏览器先调用 `limits()`,大于 `maxUploadBytes` 的文件不发送。服务页面用 `XMLHttpRequest`(以获得上传进度)把文件 POST 到相对文档基址解析的 `api/deepseek-chat-import/archive?workspaceId=…`。Host 跑在页面之外执行上下文中的页面(例如静态 Cloudflare Pages 预览)改为提供 `__DSH_TRANSPORT__.fetch`:压缩包经该载体传输,不报告字节进度,因此对话框直接进入读取与导入阶段。Host 在 `ctx.connection.fetch` 上把该路径注册为精确路由,只有 owner Peer 能访问。路由要求 `application/octet-stream`,占用服务的单一导入槽位,解析工作区,把流式请求体读入一个按 `content-length` 分配的缓冲区,直到读完或超过上限。上传内容从不写入磁盘。应答为 `application/x-ndjson`:写入会话期间是 `{ type: 'progress', done, total }` 行,最后是一行 `{ type: 'outcome', outcome }`,其中 `outcome` 为 `{ ok: true, value }` 或 `{ ok: false, error: { reason, message } }`;浏览器在完整的行到达时读取;遇到第一行不是合法协议值时立即结算为无效应答,并取消余下的流,后续 outcome 无法覆盖它。关闭对话框、连接断开或卸载插件都会中止导入,卸载只有在导入停止写入后才完成。
|
|
110
|
+
|
|
111
|
+
### 事件映射
|
|
112
|
+
|
|
113
|
+
每个 USER 消息开一个 turn:`turn/start`、`step/start`、`user/message`。第一个 turn 还在 `user/message` 之前写入一条空的 `system/message` 作为受保护的 surface 头,恢复的 Agent 会用真实的系统提示替换它;它不产生模型消息,也没有可见的行。正常完成的回答按 fragment 顺序切成 step:THINK 和 RESPONSE 追加到当前 step 的 `assistant/message`,联网搜索与打开网页追加为工具调用。带 `stage_id` 的工具调用在取值不变时同属一个 step,取值不同时开新 step;由正文开启的 step 采用第一个加入它的调用的 stage,因此不是最后一个 step 一定带有调用。工具调用之后再出现思考或正文就开新 step。turn 以 `turn/end { kind: 'completed' }` 结束。被排除的回答不写 `assistant/message`,以 `turn/end { kind: 'error' }` 结束。assistant 消息来源为 `deepseek-chat-export` / `deepseek-chat-export`,`stream` 为空,不写 `usage`、请求头或模型选择。完整的 fragment 与状态映射表见 [Agent Note](../../../.agents/notes/implemented/feature/2026-11-11-deepseek-chat-export-import.zh.md)。
|
|
114
|
+
|
|
115
|
+
### 写入
|
|
116
|
+
|
|
117
|
+
导入不创建 live Agent,一次只处理一个会话。索引选出会话后,第一遍流式扫描在任何会话被解析之前保存每个选中会话的图片,第二遍在会话到达时逐个转换并写入。会话扫描只查已保存的引用,因此压缩包条目顺序不影响结果,主路径也不再按名读取任何图片。缺失、超限、损坏、类型不支持或被附件服务拒绝的图片成为合成的文件卡片,并记一条 Host 警告。写入前检查工作区仍已登记且目录存在。随后 `Session.create()` 做与 live 会话相同的种子校验;`sessionPersistence.create()` 写入 header 与事件,句柄 flush 后关闭。投影缓存的 `coldSnapshot()` 刷新侧栏读取的标题与活动时间,`attachSession()` 把会话加入工作区。header 的 `createdAt` 是第一个事件的时间,`cwd` 是工作区的规范路径。存储的日志不含 `session/end-seed`;首次打开时普通恢复路径追加它。导入在会话之间让出事件循环。冷写入不发 `session/created`,所以浏览器在每次尝试后都调用 `sessions.refresh()`。
|
|
118
|
+
|
|
119
|
+
</details>
|
|
120
|
+
|
|
121
|
+
-----
|
|
122
|
+
|
|
123
|
+
<a id="further-exploration"></a>
|
|
124
|
+
## 深入探索
|
|
125
|
+
|
|
126
|
+
- [设计 Agent Note](../../../.agents/notes/implemented/feature/2026-11-11-deepseek-chat-export-import.zh.md)——格式差异、映射、备选方案与后果。
|
|
127
|
+
- [Session 持久化](../../session/session-persistence/README.zh.md)——导入写入的存储。
|
|
128
|
+
- [工作区注册表](../../workspace/workspace/README.zh.md)——工作区成员关系。
|
|
129
|
+
- [联网工具](../../web/tool-web/README.zh.md)——导入的调用复用的搜索与抓取结果和卡片。
|
|
130
|
+
|
|
131
|
+
-----
|
|
132
|
+
|
|
133
|
+
<a id="model-experience"></a>
|
|
134
|
+
## 模型体验
|
|
135
|
+
|
|
136
|
+
### 导入的历史
|
|
137
|
+
|
|
138
|
+
#### 模型看到什么
|
|
139
|
+
|
|
140
|
+
导入本身不发送模型请求。用户在导入的会话中继续对话时,模型看到导入的提问、思考、`web_search` / `web_fetch` 调用与结果、回答,阅读链接记录的 Markdown 链接行,以及合成文件卡片的文件句柄——后者对应的字节并不存在;被内容过滤的轮次、被排除的回答、模板文本、提示、页内查找、部分读取说明和 `CONTENT_RISK` 免责声明不出现。合成的文件卡片以文件句柄进入上下文,句柄写明文件名与大小,但它给出的路径没有任何字节;没有任何内容的提问不发送消息。抓取结果只有页面标题、URL 和“页面正文未包含在导出中”的说明。
|
|
141
|
+
|
|
142
|
+
#### Token 影响
|
|
143
|
+
|
|
144
|
+
恢复后的首个请求发送全部导入的历史。导入的思考按无签名 thinking 发送,增加该请求的输入 token;导入的图片在支持图片的路由上发送,在其他路由上替换为通用的省略说明。
|
|
145
|
+
|
|
146
|
+
#### KV Cache 影响
|
|
147
|
+
|
|
148
|
+
恢复后的首个请求没有可复用的缓存前缀;此后的请求与普通会话一样在此基础上延伸。
|
|
149
|
+
|
|
150
|
+
## 已知限制与待办工作
|
|
151
|
+
|
|
152
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
153
|
+
|
|
154
|
+
- **压缩包保存在内存中**——导入期间整个上传内容保存在 Host 内存中,受 `maxUploadBytes` 约束,另加一个转换后的会话、同一时间的一张图片条目,以及已保存图片的引用;同一 Host 一次只运行一个导入。索引未选中的会话和图片都不会被解压。
|
|
155
|
+
- **同步解压**——流式扫描用 fflate 的 `UnzipInflate` 同步解压每个选中的条目。声明很小的 `originalSize` 却携带高压缩比数据的条目会一直解压到条目结束,`maxEntryBytes` 只阻止这些字节被保留。构造出来的压缩包可以让 Host 长时间忙于解压,之后该条目才被拒绝。
|
|
156
|
+
- **重复的本地文件头**——重复检测只覆盖中央目录。第二个本地文件头改成已有条目名时不会被发现,因此压缩包可以交付比索引列出的更多的会话,写入数量也没有额外限制。
|
|
157
|
+
- **压缩包损坏时的部分写入**——压缩包结构在部分条目交付之后损坏时,会以 `unreadable-archive` 失败,而那些会话已经写入;失败应答不会列出它们。
|
|
158
|
+
- **`read()` 截断**——`ExportArchive.read` 最多返回条目声明的大小,解压结果更大时截断到该大小;`stream` 把同一情况报告为大小失败。manifest、索引与补位会话按名读取,因此其中一项可能被截断。每次按名读取还会重新解析整个中央目录:manifest 与索引各付一次,补位会话再付一次。
|
|
159
|
+
- **通道形态下没有上传百分比**——页面经 `__DSH_TRANSPORT__.fetch` 携带压缩包时不报告字节进度,对话框只显示读取与导入阶段。
|
|
160
|
+
- **只支持一种导出结构**——导入器针对 2026-11-12 结构:`current_message_id`、`stage_id`、工具状态、链接与查找字段以及新的记录类型。该结构新增的字段按可选读取,因此更旧的 v3 压缩包仍能导入,但它不是支持目标。
|
|
161
|
+
- **只支持上传 ZIP**——不能导入解压后的导出目录或 Host 路径。
|
|
162
|
+
- **重复导入产生重复会话**——再次导入同一导出会写入新的会话;导入不记录哪些会话已经导入过。
|
|
163
|
+
- **合成文件卡片**——导出中缺失、类型不支持、超过 `maxEntryBytes` 或被附件服务拒绝(例如超过大小上限)的图片,以及所有非图片文件,都成为没有字节的卡片:不能打开,也不指向任何已保存对象。非图片文件的本体不在导出中。
|
|
164
|
+
- **没有事件引用的图片**——第一遍图片扫描会在任何会话被解析之前保存每个选中会话的所有图片条目。被撤回轮次的图片、导入丢弃的分支的图片,以及转换或 `Session.create` 种子校验后来失败的会话的图片,都会成为没有任何事件引用的附件。`SessionPersistence` 与附件存储都不提供删除接口,因此这些字节会保留。
|
|
165
|
+
- **已存储但未附加**——把写入的会话加入工作区失败时,`SessionPersistence` 不提供删除,该会话留在存储中、不属于该工作区;结果在 `skipped` 中列出它及其 id。
|
|
166
|
+
- **单独的标题上限**——session-title 服务不公开它的 `maxTitleBytes`,修改该值的组合需要把本包的 `maxTitleBytes` 设为相同的值。
|
|
167
|
+
- **未导入的内容**——其他分支、被内容过滤的轮次、`CONTENT_RISK` 免责声明、`TIP`、`TOOL_FIND` 和 `PARTIAL_FILE_READ` 记录、`READ_LINK` 的加密正文(只显示导出的 url 与 title)、搜索结果的 `snippet` 与 `site_name`、`pinned` 标记、逐 token 时间和 `accumulated_token_usage`。
|
|
168
|
+
- **英文诊断**——被排除回答和失败搜索的说明是写入日志与工具结果的固定英文文本;Host 报告的 `too-large` 失败在对话框中显示其英文说明。
|
|
169
|
+
- **推断的工具记录**——导入的 `web_search` / `web_fetch` 调用没有对应的请求头工具记录,抓取卡片的 `statusCode: 200` 由“打开成功”推断。
|
|
170
|
+
|
|
171
|
+
<a id="dev-note"></a>
|
|
172
|
+
### 开发备注
|
|
173
|
+
|
|
174
|
+
<details>
|
|
175
|
+
<summary>维护者工作上下文——点击展开</summary>
|
|
176
|
+
|
|
177
|
+
`tests/conversation.host.spec.ts` 覆盖映射规则,`tests/archive.host.spec.ts` 覆盖压缩包视图,`tests/upload.host.spec.ts` 覆盖路由,`tests/importer.host.spec.ts` 用合成 ZIP 覆盖编排,`tests/resume.host.spec.ts` 覆盖经生产 agent loop 继续对话,`tests/composition.host.spec.ts` 覆盖 Loader 组合,`tests/*.client.spec.*` 覆盖按钮、对话框、上传与挂载。keyless Web 快照 `snapshots/web/deepseek-chat-import/`(驱动为 `apps/web/tests/deepseek-chat-import.e2e.ts`)经路由导入一个合成导出,并以一轮录制的模型回复继续其中一个导入的会话。修改 fragment 映射时,在同一变更中更新 Agent Note 中的映射表。
|
|
178
|
+
|
|
179
|
+
</details>
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Optional DeepSeek chat export import: the sidebar action after New session,
|
|
2
|
+
# the owner-only upload route, and the limits Remote. Shipped profiles do not
|
|
3
|
+
# include this layer.
|
|
4
|
+
- insert:
|
|
5
|
+
- id: deepseek-chat-import
|
|
6
|
+
name: '@deepseek-ai/dsh-deepseek-chat-import'
|
package/docs/DETAIL.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Import the chats you exported from chat.deepseek.com into a workspace and keep talking to them.
|
|
2
|
+
|
|
3
|
+
Turn the plugin on in Plugins → More (experimental), then click the upload arrow beside New session, choose the `deepseek_data-*.zip` file and the workspace that should receive the chats, and press Import. The dialog shows the upload, then how many chats it has imported.
|
|
4
|
+
|
|
5
|
+
Each exported chat becomes one Session: the branch you were viewing, its original title and times, its reasoning, its web search and page cards, and its images. Replies that were withdrawn, failed, or answered by a template appear as an error row and stay out of the model context; a chat whose questions were all withdrawn is skipped.
|
|
6
|
+
|
|
7
|
+
Importing needs ZIP files only and works for the owner: a shared guest does not see the button. One import writes at most `maxSessions` chats (1000 by default), accepts at most `maxUploadBytes` (512 MiB) and at most `maxEntryBytes` (256 MiB) per archive entry, and truncates titles to `maxTitleBytes` (80). Importing the same file twice creates a second workspace copy of every chat.
|
|
8
|
+
|
|
9
|
+
The package README covers the failure reasons, the event mapping and the known limitations.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
把从 chat.deepseek.com 导出的会话导入到一个工作区,然后继续对话。
|
|
2
|
+
|
|
3
|
+
在插件页的「更多」(实验性插件)里打开这个插件,再点「新会话」旁的上传箭头,选择 `deepseek_data-*.zip` 文件和接收会话的工作区,按「导入」。对话框会先显示上传,再显示导入了多少个会话。
|
|
4
|
+
|
|
5
|
+
每个导出会话生成一个会话:你当时停留的那条分支、原标题与时间、思考、联网搜索与网页卡片、以及图片。被撤回、失败或由模板回答的回复显示为错误行,不进入模型上下文;如果一个会话的提问全部被撤回,就跳过该会话。
|
|
6
|
+
|
|
7
|
+
导入只接受 ZIP 文件,且只对 owner 开放:共享访客看不到这个按钮。一次导入最多写入 `maxSessions` 个会话(默认 1000),单个压缩包最大 `maxUploadBytes`(512 MiB),单个条目解压后最大 `maxEntryBytes`(256 MiB),标题按 `maxTitleBytes`(80)截断。同一个文件导入两次会得到两份会话副本。
|
|
8
|
+
|
|
9
|
+
失败原因、事件映射和已知限制见包的 README。
|
package/icon.svg
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M10 8H26C27.66 8 29 9.34 29 11V21C29 22.66 27.66 24 26 24H15.5L11 28V24H10C8.34 24 7 22.66 7 21V11C7 9.34 8.34 8 10 8Z" fill="url(#deepseek-chat-import-bubble)" fill-opacity="0.85" />
|
|
3
|
+
<path d="M18 11V18.2M14.8 15L18 18.2L21.2 15" stroke="#FFFFFF" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" />
|
|
4
|
+
<path d="M13.5 21H22.5" stroke="#45D9E7" stroke-width="2.2" stroke-linecap="round" />
|
|
5
|
+
<defs>
|
|
6
|
+
<linearGradient id="deepseek-chat-import-bubble" x1="18" y1="8" x2="18" y2="28" gradientUnits="userSpaceOnUse">
|
|
7
|
+
<stop stop-color="#7AC2FF" />
|
|
8
|
+
<stop offset="1" stop-color="#4A65E8" />
|
|
9
|
+
</linearGradient>
|
|
10
|
+
</defs>
|
|
11
|
+
</svg>
|