dsh-feiyu-memgate 0.0.0-stage → 0.1.1
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.md +238 -2
- package/README.zh.md +239 -0
- package/client/client.js +1324 -0
- package/cordis.patch.yml +7 -0
- package/docs/DETAIL.en.md +84 -0
- package/docs/DETAIL.md +84 -0
- package/icon.png +0 -0
- package/index.js +29 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +72 -4
- package/python/GATEWAY_VERSION.json +58 -0
- package/python/LICENSE +21 -0
- package/python/feiyu_memgate/__init__.py +17 -0
- package/python/feiyu_memgate/__main__.py +5 -0
- package/python/feiyu_memgate/backends/__init__.py +0 -0
- package/python/feiyu_memgate/backends/base.py +89 -0
- package/python/feiyu_memgate/backends/embedding.py +626 -0
- package/python/feiyu_memgate/backends/hybrid.py +314 -0
- package/python/feiyu_memgate/backends/inmemory.py +114 -0
- package/python/feiyu_memgate/backends/openviking.py +469 -0
- package/python/feiyu_memgate/backends/sqlite.py +501 -0
- package/python/feiyu_memgate/builtins.py +5 -0
- package/python/feiyu_memgate/cli.py +746 -0
- package/python/feiyu_memgate/client/__init__.py +11 -0
- package/python/feiyu_memgate/client/block.py +112 -0
- package/python/feiyu_memgate/client/http.py +313 -0
- package/python/feiyu_memgate/client/local.py +268 -0
- package/python/feiyu_memgate/client/query.py +99 -0
- package/python/feiyu_memgate/config.py +461 -0
- package/python/feiyu_memgate/core/__init__.py +0 -0
- package/python/feiyu_memgate/core/limits.py +183 -0
- package/python/feiyu_memgate/core/pool.py +209 -0
- package/python/feiyu_memgate/core/recall.py +370 -0
- package/python/feiyu_memgate/core/redact.py +266 -0
- package/python/feiyu_memgate/core/stages.py +394 -0
- package/python/feiyu_memgate/core/tidy.py +124 -0
- package/python/feiyu_memgate/core/watch.py +134 -0
- package/python/feiyu_memgate/core/write.py +135 -0
- package/python/feiyu_memgate/errors.py +31 -0
- package/python/feiyu_memgate/forgetting/__init__.py +12 -0
- package/python/feiyu_memgate/forgetting/archive.py +83 -0
- package/python/feiyu_memgate/forgetting/curve.py +56 -0
- package/python/feiyu_memgate/forgetting/engine.py +292 -0
- package/python/feiyu_memgate/forgetting/ledger.py +161 -0
- package/python/feiyu_memgate/forgetting/stage.py +109 -0
- package/python/feiyu_memgate/gateway/__init__.py +0 -0
- package/python/feiyu_memgate/gateway/app.py +992 -0
- package/python/feiyu_memgate/gateway/server.py +344 -0
- package/python/feiyu_memgate/model.py +103 -0
- package/python/feiyu_memgate/pieces.py +24 -0
- package/python/feiyu_memgate/registry.py +153 -0
- package/python/feiyu_memgate/tenants/__init__.py +0 -0
- package/python/feiyu_memgate/tenants/base.py +33 -0
- package/python/feiyu_memgate/tenants/directory.py +234 -0
- package/python/feiyu_memgate/tenants/keyfile.py +155 -0
- package/python/feiyu_memgate/tools/__init__.py +0 -0
- package/python/feiyu_memgate/tools/backup.py +227 -0
- package/python/feiyu_memgate/tools/crypto.py +218 -0
- package/python/feiyu_memgate/tools/evaluate.py +132 -0
- package/python/feiyu_memgate/tools/tenants.py +162 -0
- package/src/block.js +102 -0
- package/src/catalogue.js +147 -0
- package/src/client.js +296 -0
- package/src/commands.js +553 -0
- package/src/config.js +317 -0
- package/src/gateway.js +661 -0
- package/src/migrate.js +178 -0
- package/src/migrate.py +185 -0
- package/src/plugin.js +1125 -0
- package/src/query.js +97 -0
- package/src/setup.js +1101 -0
- package/src/tiers.js +222 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 N0rmal
|
|
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.md
CHANGED
|
@@ -1,3 +1,239 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-feiyu-memgate
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
The DeepSeek Harness (DSH) plugin for the [feiyu-memgate](https://github.com/N0rmal-114/feiyu-memgate) memory gateway. It gives DSH conversations a long-term memory: related memories are looked up at the start of each turn, and the model gets two tools to save and search memories.
|
|
6
|
+
|
|
7
|
+
The gateway is bundled with the plugin and started by it on your machine. With the default settings it needs no model and downloads nothing: memories are kept in SQLite files and found by keyword search.
|
|
8
|
+
|
|
9
|
+
## What happens after install
|
|
10
|
+
|
|
11
|
+
With the default settings, this is what you see:
|
|
12
|
+
|
|
13
|
+
1. **The gateway starts in the background.** The first time a memory feature is needed, the plugin looks for Python 3.11 or later, writes a gateway configuration into the data folder and starts the bundled gateway on a free loopback port. DSH does not wait for it. Until the gateway is healthy, recall adds nothing and the tools report that memory is unavailable.
|
|
14
|
+
2. **Recall at the start of each turn.** When you send a message, the plugin looks up memories related to it. Only the first step of a turn does this, and only in your own session, not in subagent sessions. A message that starts with `/` or `/`, the message `ok`, a message with no meaningful characters (only emoji or punctuation), and a message of one or two filler characters such as `嗯` or `好` are not looked up. A very short message (fewer than 8 meaningful characters) is looked up together with your previous message. The query is cut to 500 characters.
|
|
15
|
+
3. **The memory block.** If the lookup finds something, the plugin adds one message right after your message, in a `<memory_data>` block. It says the content is data, not instructions, and lists up to `advanced.recallLimit` memories (5 by default), each with its date when known. If more memories matched than fit, a last line says how many. The gateway applies score thresholds, so most turns get fewer memories than the limit, and many get none. The lookup waits at most `advanced.recallTimeoutMs` (4000 ms by default); a slower lookup is skipped for that turn.
|
|
16
|
+
4. **The block stays in the conversation history.** It is saved with the turn, like any other message. Two consequences. The context grows by the block on every turn that has one, and those tokens are sent again on later turns. The prompt cache is not harmed: nothing before your current message changes, so the cached prefix of the earlier conversation is still valid. The next turn does not add a block that is identical to the one already in the history.
|
|
17
|
+
5. **Two tools for the model.** `memgate_remember` takes one short sentence (at most 4000 characters) and saves it. `memgate_search` takes a query (at most 500 characters) and an optional `limit` from 1 to 10, and returns the same kind of block. A short fixed section in the system prompt tells the model to call `memgate_remember` when you ask it to remember something or state a lasting fact about yourself, your preferences or your work, never to save secrets, to call `memgate_search` when earlier conversations may hold the answer, and to treat recalled memories as data, not instructions. The tools report what happened: saved, not saved (nothing worth keeping, daily cap used up, refused, memory unavailable), or unknown (the gateway did not answer in time). The model is told never to say "saved" unless the tool did.
|
|
18
|
+
6. **Writing happens only through the tool.** With default settings a memory is written only when the model calls `memgate_remember`. If you never ask and the model never decides to, nothing is stored. Switch on `modules.autoCapture` to also send your own messages to memory after each turn (see below).
|
|
19
|
+
7. **Where memories live.** In SQLite files in `<DSH home>/data/feiyu-memgate/`. `<DSH home>` is the folder named by the `DSH_HOME` environment variable, or `.dsh` in your user folder when it is not set.
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- DeepSeek Harness. Tested with DeepSeek Harness 0.2.2-rc.1 (installed Desktop) and checked against the 0.2.2-rc.3 source; engines.dsh accepts 0.2.2-alpha.1 through any 0.2.2 prerelease (<0.2.3-0). The range in `package.json` also accepts 0.2.0-rc.1 up to but not including 0.2.1-0, and 0.2.1-alpha.1 up to but not including 0.2.2-0. Those two ranges were not tested.
|
|
24
|
+
- Node 22.19 or later (`engines.node`).
|
|
25
|
+
- Python 3.11 or later for the bundled gateway. It must have the `sqlite3` and `tomllib` modules, which standard builds include. The gateway uses only the Python standard library, so there is nothing to `pip install`. You do not need Python in external gateway mode.
|
|
26
|
+
|
|
27
|
+
The plugin looks for Python in this order and uses the first one that works:
|
|
28
|
+
|
|
29
|
+
1. The `gateway.python` setting, if it is not empty.
|
|
30
|
+
2. The Desktop app's bundled Python: the folder named by the `DSH_PRIMARY_RUNTIME` environment variable, if set (`dependencies/python/python.exe` on Windows, `dependencies/python/bin/python3` elsewhere).
|
|
31
|
+
3. The copy the Desktop app installs on first use: `<DSH home>/dsh-runtimes/dsh-primary-runtime/`, with the same file below it.
|
|
32
|
+
4. `python3` on the `PATH`.
|
|
33
|
+
5. `python` on the `PATH`.
|
|
34
|
+
6. `py -3` on the `PATH`.
|
|
35
|
+
|
|
36
|
+
A candidate is accepted only if it runs, is version 3.11 or later and has both modules. If none is found, the gateway does not start, a warning is logged, recall adds nothing and the tools report that memory is unavailable. DSH and your conversations are not affected. The result of the search is kept until DSH restarts; changing `gateway.python` searches again.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
From the Plugins page: install the package `dsh-feiyu-memgate`. The package brings its own configuration row with default settings, so there is nothing to edit.
|
|
41
|
+
|
|
42
|
+
From the command line, with the profile you use:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
dsh plugin --profile <name> add dsh-feiyu-memgate
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For the Desktop app the profile is `desktop`. Start Desktop once so that it creates its profile, then quit the application completely, run the command below, and start Desktop again:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
dsh plugin --profile desktop add dsh-feiyu-memgate
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Settings
|
|
55
|
+
|
|
56
|
+
Every setting can be changed in three ways. They write the same values.
|
|
57
|
+
|
|
58
|
+
- **The settings page.** On the Plugins page, open the row of this plugin. The page shows the settings and a status block (gateway, Python, store and memory count, retrieval tier, embedding add-on, copy progress). It depends on host interfaces that are still changing; if it does not work in your DSH version, use one of the other two ways.
|
|
59
|
+
- **The `/memgate` chat command.** See [The /memgate command](#the-memgate-command).
|
|
60
|
+
- **The profile's configuration file.** The row `feiyu-memgate` in the profile's `cordis.patch.yml`. The other two ways save their changes there. A home-level patch or a `--patch` overlay that sets the same row takes precedence, and a change they would override is refused.
|
|
61
|
+
|
|
62
|
+
Most settings take effect at once. A change of `gateway.mode`, `gateway.python`, `gateway.dataDir`, the retrieval tier or the endpoint settings in use, `advanced.profile`, `advanced.dailyWrites`, `advanced.redaction`, `advanced.newerFirst` or `advanced.forgetting` restarts the gateway. The count of the daily cap starts again then. Switching a module off removes what it registered in DSH. The gateway runs only while at least one of `modules.autoRecall`, `modules.rememberTool`, `modules.searchTool` and `modules.autoCapture` is on.
|
|
63
|
+
|
|
64
|
+
| Setting | What it does | Default | Notes |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| `modules.autoRecall` | Look up related memories at the start of each turn and add them after your message. | on | `/memgate on autoRecall` |
|
|
67
|
+
| `modules.rememberTool` | Give the model the `memgate_remember` tool. | on | |
|
|
68
|
+
| `modules.searchTool` | Give the model the `memgate_search` tool. | on | |
|
|
69
|
+
| `modules.promptSection` | Add the short fixed system prompt section about memory. | on | The text is the same whatever the other settings are, so it does not disturb the prompt cache. |
|
|
70
|
+
| `modules.autoCapture` | After each turn, send the messages you typed in that turn to memory, without asking the model. | off | Only your own messages, not recalled blocks, injected context or subagent turns. A message over 4000 characters is skipped, never cut. Each write counts against `advanced.dailyWrites`. |
|
|
71
|
+
| `modules.commands` | Register the `/memgate` chat command. | on | Needs a host that has chat commands. |
|
|
72
|
+
| `modules.migrateOnTierChange` | When a vector tier becomes active, copy the keyword memories into its store in the background. | on | See [Semantic search](#semantic-search-optional-add-on). |
|
|
73
|
+
| `retrieval.tier` | How the bundled gateway finds memories: `auto`, `keyword`, `endpoint` or `local`. | `auto` | `/memgate use <tier>`. Table below. |
|
|
74
|
+
| `retrieval.url` | `endpoint` tier: base URL of an OpenAI-compatible embeddings API, for example `http://127.0.0.1:11434/v1`. | empty | Must start with `http://` or `https://`. |
|
|
75
|
+
| `retrieval.model` | `endpoint` tier: the embeddings model name. | empty | A different model uses a new, empty store. |
|
|
76
|
+
| `retrieval.apiKey` | `endpoint` tier: the API key, if the endpoint needs one. | empty | Secret. Write-only: the settings page never shows it again. |
|
|
77
|
+
| `gateway.mode` | `managed` starts the bundled gateway. `external` uses a gateway you run. | `managed` | See [External gateway](#external-gateway). |
|
|
78
|
+
| `gateway.python` | `managed`: the Python to use (3.11 or later). Empty searches as described under Requirements. | empty | |
|
|
79
|
+
| `gateway.dataDir` | `managed`: folder for the memory stores, the generated gateway configuration and the log. | empty (`<DSH home>/data/feiyu-memgate`) | |
|
|
80
|
+
| `external.url` | `external`: the gateway address, for example `http://127.0.0.1:8080`. | empty | Must start with `http://` or `https://`. |
|
|
81
|
+
| `external.token` | `external`: the client token that gateway issued for this client. | empty | Secret. Write-only. |
|
|
82
|
+
| `advanced.recallLimit` | Most memories added per turn (1 to 10). Also the default number of `memgate_search` results. | 5 | Applies to a gateway you run yourself as well. |
|
|
83
|
+
| `advanced.recallTimeoutMs` | How long a turn waits for automatic recall (500 to 20000 ms). A slower lookup is skipped. | 4000 | |
|
|
84
|
+
| `advanced.language` | Language of the memory block, the tool replies and `/memgate`: `auto` (follow the system language), `zh` or `en`. | `auto` | Memories themselves are never translated. |
|
|
85
|
+
| `advanced.profile` | How strict the gateway is about what counts as related: `precise` or `broad`. | `precise` | `precise` returns fewer, closer matches and misses more. `broad` returns more matches and more noise. The measured numbers are in the [gateway's deployment tiers](https://github.com/N0rmal-114/feiyu-memgate#部署档位) (in Chinese); on the keyword store the gateway measured only a small gain from `broad`. Managed mode only. |
|
|
86
|
+
| `advanced.dailyWrites` | Most memories the gateway accepts per day (0 to 100000). 0 means no cap. | 50 | The day starts at local midnight. The count starts again whenever the gateway restarts. Managed mode only. |
|
|
87
|
+
| `advanced.redaction` | Remove secrets such as keys, tokens and passwords from memories when they are saved and when they are recalled. | on | Pattern based. It does not recognize a bare secret that has no keyword next to it. Managed mode only. |
|
|
88
|
+
| `advanced.newerFirst` | Among nearly equal matches, put newer memories first. | on | It looks only at dates. It does not detect that two memories contradict each other. Managed mode only. |
|
|
89
|
+
| `advanced.forgetting` | Experimental. Memories unused for a long time rank lower and are eventually archived and removed. | off | See below. Managed mode only. |
|
|
90
|
+
|
|
91
|
+
### Retrieval tiers
|
|
92
|
+
|
|
93
|
+
Each tier keeps its own store file in the data folder. `/memgate tiers` lists the tiers, whether each is available and what is missing. If the tier in use lacks something, the gateway does not start and memory stays off until it is provided.
|
|
94
|
+
|
|
95
|
+
| Tier | How it finds memories | Needs | Store file |
|
|
96
|
+
|---|---|---|---|
|
|
97
|
+
| `auto` | `local` while the `dsh-feiyu-memgate-embed` add-on has a model ready, otherwise `keyword`. | Nothing. | That of the tier it resolves to. |
|
|
98
|
+
| `keyword` | Keyword search over SQLite inside the gateway. No model, no network. | Nothing. | `memories.db` |
|
|
99
|
+
| `endpoint` | Semantic search through an OpenAI-compatible embeddings API. Memory texts and queries are sent to that API. | `retrieval.url` and `retrieval.model`, and `retrieval.apiKey` if the endpoint wants one. | `memories-endpoint-<model>.db` |
|
|
100
|
+
| `local` | Semantic search with a model the add-on runs on this machine. | The add-on installed, switched on, with a model ready. | `memories-local-<model>-<hash>.db` |
|
|
101
|
+
|
|
102
|
+
When the add-on goes away or its model changes, an `auto` or `local` gateway restarts with the new state.
|
|
103
|
+
|
|
104
|
+
### External gateway
|
|
105
|
+
|
|
106
|
+
With `gateway.mode` set to `external`, the plugin does not start anything. It talks to the gateway at `external.url` with the client token in `external.token`. If either is empty, memory is off and a warning is logged. `retrieval.*`, `gateway.python`, `gateway.dataDir`, the copy into a vector store and the gateway rules under `advanced` (`profile`, `dailyWrites`, `redaction`, `newerFirst`, `forgetting`) do nothing in this mode: the gateway follows its own configuration. `advanced.recallLimit`, `advanced.recallTimeoutMs` and `advanced.language` still apply.
|
|
107
|
+
|
|
108
|
+
Prefer it when several programs share one gateway, or when you want the store keys to stay out of the DSH process. The gateway speaks plain HTTP, so use it on the same machine or a network you trust, or put TLS in front of it. The plugin does not follow redirects, so the token is never sent to another address.
|
|
109
|
+
|
|
110
|
+
### Advanced: forgetting
|
|
111
|
+
|
|
112
|
+
`advanced.forgetting` is experimental and off by default. When on, the gateway ranks memories that have gone unused for a long time lower. With the gateway's defaults it archives and removes a memory after about 389 days without use, at most the larger of 5 and 2 percent of the store per sweep, with one sweep a day. Archived texts stay in the data folder, unencrypted, for 90 days and are then deleted. The first sweep runs 24 hours after the gateway starts. "Use" means being returned near the top of a recall; the plugin does not report which memories the model actually used. The feature has been tested only in the gateway's simulations. The plugin has no command to restore an archived memory.
|
|
113
|
+
|
|
114
|
+
### The /memgate command
|
|
115
|
+
|
|
116
|
+
A chat command for you, one line long. Keys are written as `group.key`; a bare key such as `recallLimit` works when it names one setting (`url` does not, it exists in `retrieval` and `external`). Keys are not case sensitive. Values for switches accept `on`, `off`, `true`, `false`, `yes`, `no`, `1` and `0`, and the Chinese words `开`, `关`, `是` and `否`. A secret you set is never repeated in the reply and the command line is not written to the session log.
|
|
117
|
+
|
|
118
|
+
| Subcommand | What it does | Example |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| `status` | Gateway state, Python found, store and memory count, retrieval tier, embedding add-on, copy progress, switched-on features. | `/memgate status` |
|
|
121
|
+
| `config` | Every setting with its current value and its default. Secrets show only as set or not set. | `/memgate config` |
|
|
122
|
+
| `set <key> <value>` | Change one setting. | `/memgate set advanced.recallLimit 3` |
|
|
123
|
+
| `reset <key>` | Return one setting to its default (this is also how to clear a text setting). | `/memgate reset retrieval.apiKey` |
|
|
124
|
+
| `on <feature>` | Switch a feature on. The features are the `modules.*` settings. | `/memgate on autoCapture` |
|
|
125
|
+
| `off <feature>` | Switch a feature off. | `/memgate off searchTool` |
|
|
126
|
+
| `tiers` | The retrieval tiers: available or not, which is active, what each needs. | `/memgate tiers` |
|
|
127
|
+
| `use <tier>` | Choose the retrieval tier: `auto`, `keyword`, `endpoint` or `local`. | `/memgate use keyword` |
|
|
128
|
+
| `models` | The local embedding models: download size, memory, languages, licence and state. | `/memgate models` |
|
|
129
|
+
| `install <model> [--accept-licence <licence name>] [--confirm]` | Download a model and enable it. Without the add-on, this installs the add-on first, which needs `--confirm` (the reply without it says what would be installed). | `/memgate install bge-small-zh-v1.5 --confirm` |
|
|
130
|
+
| `builds allow` / `builds deny` | Answer the install-script question of the add-on installation. | `/memgate builds deny` |
|
|
131
|
+
| `use <model>` | Switch to a downloaded model. | `/memgate use bge-m3` |
|
|
132
|
+
| `remove <model>` | Delete a downloaded model that is not in use. | `/memgate remove bge-m3` |
|
|
133
|
+
| `cancel` | Stop the running add-on installation or model download, or drop an unanswered install-script question. | `/memgate cancel` |
|
|
134
|
+
|
|
135
|
+
The model subcommands do the same as the buttons of the settings page; see [Installing from the settings page](#installing-from-the-settings-page).
|
|
136
|
+
|
|
137
|
+
`/memgate` with no argument, or `/memgate help`, prints the usage.
|
|
138
|
+
|
|
139
|
+
### The profile file
|
|
140
|
+
|
|
141
|
+
A row in the profile's `cordis.patch.yml` replaces the whole `config` of the row of the same `id`, so write every group you want to differ from the defaults, and leave the others out. For example, to use a larger recall limit and switch on automatic capture:
|
|
142
|
+
|
|
143
|
+
```yaml
|
|
144
|
+
- id: feiyu-memgate
|
|
145
|
+
config:
|
|
146
|
+
modules:
|
|
147
|
+
autoCapture: true
|
|
148
|
+
advanced:
|
|
149
|
+
recallLimit: 8
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Do not edit the package's own `cordis.patch.yml`. It only mounts the plugin with default settings.
|
|
153
|
+
|
|
154
|
+
## Semantic search (optional add-on)
|
|
155
|
+
|
|
156
|
+
Keyword search finds memories that share words with the question. To find reworded ones too, install the add-on [`dsh-feiyu-memgate-embed`](https://github.com/N0rmal-114/feiyu-memgate/tree/main/plugins/dsh-feiyu-memgate-embed). It runs a local embedding model on the CPU only, serves it on `127.0.0.1`, and offers it to this plugin. Models are downloaded only when you ask for it, and texts do not leave your machine. On Windows its engine needs the Microsoft Visual C++ 2015-2022 runtime (x64), which most Windows installations already have.
|
|
157
|
+
|
|
158
|
+
What installing it changes:
|
|
159
|
+
|
|
160
|
+
- With `retrieval.tier` set to `auto`, the plugin switches from `keyword` to `local` once a model is ready in the add-on. The gateway restarts with the new store. When the model is no longer ready, `auto` goes back to `keyword`.
|
|
161
|
+
- **Existing memories are copied into the vector store on first activation.** This is the migration module, switched by `modules.migrateOnTierChange`. After the gateway is running on a vector tier (`local` or `endpoint`), the plugin copies the memories of the keyword store (`memories.db`) into the vector store in the background, in bounded steps (at most 500 memories per step, 120 seconds per step) and repeats while each step makes progress. A state file `migration-<store id>.json` in the data folder records what was copied, so a copy that was interrupted resumes after a restart. The keyword store is only read, never changed.
|
|
162
|
+
- Watch the progress in `/memgate status` (the line "Copy from the keyword store": copied of total, and the number refused) or in the status block of the settings page. Until the copy has passed a memory, it is not found by semantic search.
|
|
163
|
+
- **A memory longer than the model's input is searched by its beginning only.** The gateway accepts up to 4000 characters per memory; the models take 512 tokens (the two bge-zh models, roughly 500 Chinese characters), 2048 (bge-m3) or 4095 (qwen3-embedding). By default the add-on embeds the part that fits, the way the gateway's calibration measured long texts, and the full text is still stored and returned. With the add-on's setting `model.overflow` at `reject`, such a text is refused instead: the copy counts it as refused, it stays only in the keyword store and is not offered to that vector store again. If the model accepts no text at all in a step, the copy stops and tries again when the gateway next starts.
|
|
164
|
+
- **Memories written under one tier are stored separately from those of another tier.** Each tier and each model has its own file. Texts saved under a vector tier are not copied back to the keyword store, and a new model starts with a copy of the keyword store only, not of the previous model's store. Switching back to a tier finds that tier's memories again.
|
|
165
|
+
|
|
166
|
+
The `endpoint` tier works the same way with an embeddings API you choose, for example a local Ollama or a cloud service. Memory texts and queries are then sent to that API (see the next section).
|
|
167
|
+
|
|
168
|
+
### Installing from the settings page
|
|
169
|
+
|
|
170
|
+
The settings page has a section "Local embedding models", shown whether or not the add-on is installed. Each row gives a model's tier, download size, memory while running, languages, licence and a one-line note, with a link to the [gateway's deployment tiers](https://github.com/N0rmal-114/feiyu-memgate#部署档位) for measured quality. The memory is what the add-on measured for the model process after loading (bge-small-zh-v1.5: a 48 MB file, about 190 MB while running), not the file size. Nothing is downloaded until you press a button. `/memgate models` and the other model subcommands do the same from chat.
|
|
171
|
+
|
|
172
|
+
What one press of "Download and enable" does:
|
|
173
|
+
|
|
174
|
+
1. **Without the add-on, the page first asks you to confirm** what is installed: the package `dsh-feiyu-memgate-embed` from npm, through the host's plugin manager, which adds a dependency with a native binary (`node-llama-cpp`, about 90 MB for the CPU build, up to about 740 MB on Windows and Linux x64, where pnpm also fetches the GPU builds). The model runs on the CPU only; on Windows the engine needs the Microsoft Visual C++ 2015-2022 runtime (x64). The host itself shows no dialog for this, so this confirmation is the only one.
|
|
175
|
+
2. **pnpm stops the install script of `node-llama-cpp` until you decide.** Nothing is installed at that point: the host puts the profile's `package.json` back and only writes the line `node-llama-cpp: set this to true or false` under `allowBuilds` in the profile's `pnpm-workspace.yaml`. The page asks whether to allow the script. According to the add-on's author both answers work, because the engine does not need the script.
|
|
176
|
+
- **Allow** records a lasting permission in this DSH profile, installs again and switches the add-on on.
|
|
177
|
+
- **Deny** has no button in DSH. The page names the file, `<DSH home>/profiles/<profile>/pnpm-workspace.yaml` (with the real path of your profile), and the line: change `node-llama-cpp: set this to true or false` to `node-llama-cpp: false`, save, then press "Download and enable" again. The add-on is then installed with the script skipped and switched on.
|
|
178
|
+
- Leaving the question unanswered changes nothing else: nothing of the add-on is installed or switched on, and the host reads that line only during a later installation. "Cancel" removes the question from the page.
|
|
179
|
+
|
|
180
|
+
The plugin never allows a script without your answer, and it does not edit the profile's files.
|
|
181
|
+
3. **The model downloads** with its progress shown; a model whose licence needs acceptance has a checkbox for it. When it is ready, `auto` switches to `local` and the keyword memories are copied as described above. The status block shows the tier and the copy.
|
|
182
|
+
|
|
183
|
+
If the add-on is already a dependency of the profile but not switched on, for example after a `dsh plugin add` that stopped at the install script, the button switches it on through the plugin manager instead of installing it again; if its files are gone, it is removed and installed anew.
|
|
184
|
+
|
|
185
|
+
The setup survives closing or reloading the page. After a DSH restart in the middle of a download, the add-on keeps the partial file and the row offers "Resume download". A failure is shown in plain words with what to do: no network or mirror unreachable, not enough disk space, a download that failed verification, an engine that cannot load (on Windows: install the Microsoft Visual C++ 2015-2022 Redistributable (x64), `vc_redist.x64.exe` from Microsoft, then restart DSH; the add-on's status shows the error `runtime-missing`), no Python for the gateway, a declined confirmation, an add-on the host cannot switch on, or a model pinned in the add-on's own settings. Only you can start an installation: the model's tools cannot, and the settings route accepts only the signed-in owner with an explicit confirmation.
|
|
186
|
+
|
|
187
|
+
## Data and privacy
|
|
188
|
+
|
|
189
|
+
- **Everything stays on your machine in the default mode.** The bundled gateway, the stores and the log are local. The plugin makes no network request other than to the loopback address of its own gateway. Nothing is downloaded unless you install the add-on or a model from the settings page or with `/memgate install`; the host's plugin manager then fetches the add-on from npm and the add-on fetches the model.
|
|
190
|
+
- **The files.** All of them are in the data folder, `<DSH home>/data/feiyu-memgate/` unless `gateway.dataDir` is set:
|
|
191
|
+
|
|
192
|
+
| File | What it is |
|
|
193
|
+
|---|---|
|
|
194
|
+
| `memories.db` | The keyword store. |
|
|
195
|
+
| `memories-endpoint-<model>.db`, `memories-local-<model>-<hash>.db` | The stores of the vector tiers, one per model. |
|
|
196
|
+
| `migration-<store id>.json` | Copy progress for a vector store: counts and references, no texts. |
|
|
197
|
+
| `model-setup.json` | Progress of a model setup started from the settings page or `/memgate install`: the model, its step, the install scripts waiting for your decision and the last failure code. |
|
|
198
|
+
| `forgetting-ledger-<store id>.db`, `forgetting-archive-<store id>.db` | Only with forgetting on. The archive holds the full text of removed memories, unencrypted. |
|
|
199
|
+
| `gateway.log`, `gateway.log.1` | The gateway log, rotated at about 1 MiB. |
|
|
200
|
+
| `gateway-<pid>-<n>.toml` | The gateway configuration of the running process, removed when it stops. It holds no token and no key. |
|
|
201
|
+
| `pycache/` | Python byte-code caches of the gateway. |
|
|
202
|
+
|
|
203
|
+
- **No encryption by the plugin.** The stores are plain SQLite files. Protect the folder as you would any file that holds personal notes.
|
|
204
|
+
- **The gateway is local only.** It listens on `127.0.0.1` on a random free port, chosen at each start. At each start the plugin makes a new random token (32 bytes) that exists only in memory and in the gateway's environment; it is never written to a file or a log. The gateway process gets a copy of DSH's environment without names that contain `KEY`, `PASSWORD`, `SECRET` or `TOKEN` and without names that start with `DSH_`, plus the token and, for `endpoint`, the key it needs. It exits when DSH exits.
|
|
205
|
+
- **Recalled memories go to your model provider.** A memory block is part of the prompt, so it is sent to whichever model service the conversation uses, like any other message.
|
|
206
|
+
- **What leaves the machine in `endpoint` mode.** The text of every memory that is saved or copied, and every recall query, go to the embeddings API you configured in `retrieval.url`. The API key is handed to the gateway through an environment variable, not a file. In `external` mode, requests go to the address in `external.url`.
|
|
207
|
+
- **Logs name kinds of failure only.** No query, memory text or token is logged by the plugin.
|
|
208
|
+
- **Delete all data.** Quit DSH (or switch the plugin off), then delete the data folder. If you changed `gateway.dataDir`, delete that folder. The folder also holds the add-on's models and state file when you use it with its default folder, so delete only the files you mean to.
|
|
209
|
+
|
|
210
|
+
## Limits and what is not verified
|
|
211
|
+
|
|
212
|
+
- **Keyword search does not find reworded questions.** In the gateway's own benchmark (240 memories, 160 questions, synthetic Chinese text) the keyword store delivered a right memory for 0 of 55 reworded questions at the default settings, and for 95.6% of 45 questions that use the memory's own words. Semantic search is much better on reworded questions. See the [benchmark](https://github.com/N0rmal-114/feiyu-memgate#基准测试) (in Chinese). Languages other than Chinese were not measured.
|
|
213
|
+
- **The memory block stays in the history.** The context grows with every turn that gets a block (see step 4 above).
|
|
214
|
+
- **Only memories that the model chose to save exist**, unless you switch on `modules.autoCapture`. The gateway stores the text as it is passed, with secrets removed when redaction is on. It does not extract facts, merge memories or mark old ones as outdated. A newer memory is only ranked before an older one.
|
|
215
|
+
- **The daily write cap is counted in memory, per DSH process.** It starts again whenever the gateway restarts, and a second DSH process has its own gateway and its own count.
|
|
216
|
+
- **One store per tier.** The plugin uses a single gateway client and a single store per tier. It does not keep separate memories per user or per project.
|
|
217
|
+
- **The settings page depends on host UI interfaces that are still changing.** The plugin works without it: every setting can be changed with `/memgate` or in the profile file.
|
|
218
|
+
- **Forgetting is experimental** and has been tested only in simulations.
|
|
219
|
+
- **Real-host testing.** Tested in the installed DeepSeek Harness 0.2.2-rc.1 on Windows 11 with an isolated profile: the plugin loads, the bundled gateway starts with a Python from PATH, the settings page renders and saves, the status and model routes answer only to the owner session, the chat command works, and with the add-on and bge-small-zh-v1.5 the local tier is used and reworded questions find their memories. Installing the add-on from npm through the settings page was run too, with the dependency's install script refused: the add-on is installed and enabled, the model is downloaded and the local tier takes over (the path that allows the script was not run). Not tested: macOS and Linux desktops, the Desktop application's own window (the web profile of the same host was used), and a conversation with a real model (automatic recall and the two tools were exercised in tests and against the gateway, not in a live chat).
|
|
220
|
+
- **Other versions and systems.** Other DSH versions in the accepted ranges, other operating systems and other Python builds are not covered by a real-host test.
|
|
221
|
+
- This is version 0.1.1.
|
|
222
|
+
|
|
223
|
+
## Troubleshooting
|
|
224
|
+
|
|
225
|
+
Start with `/memgate status`. It shows the state of the gateway, the Python that was found, the store and its memory count, the retrieval tier, the embedding add-on and the copy progress.
|
|
226
|
+
|
|
227
|
+
- **No Python found.** `/memgate status` shows Python as not found. Install Python 3.11 or later, or set `gateway.python` to its full path. Changing the setting searches again; if you only installed Python, restart DSH, because the search result is kept until then. Or use an external gateway.
|
|
228
|
+
- **The gateway does not start or keeps stopping.** Read `gateway.log` in the data folder. The plugin writes lines such as "using Python", "gateway starting on port", "gateway healthy", "gateway did not become healthy in time" and "gateway exited", and the gateway's own output follows them. The plugin waits 20 seconds for a start. After a crash it restarts the gateway up to 5 times, with longer pauses (1 second, doubling, at most 30). Then the state is "stopped after repeated failures" until a change that restarts the gateway, or a restart of DSH.
|
|
229
|
+
- **Port or permission problems.** There is no fixed port to clash with: a free port on `127.0.0.1` is chosen at each start. A security tool that blocks starting Python or listening on the loopback address makes the log say "did not become healthy in time". If the plugin cannot create or write the data folder, DSH logs "cannot create the data folder" or "cannot write the gateway configuration" and memory is off; set `gateway.dataDir` to a folder you can write to.
|
|
230
|
+
- **The retrieval tier is not ready.** `/memgate tiers` names what is missing, for example `retrieval.url` for `endpoint`, or a ready model in the add-on for `local`. Memory stays off until it is provided. `/memgate use keyword` needs nothing.
|
|
231
|
+
- **The local model does not load.** The model list shows the reason and what to do. If the add-on's status (`/memgate-embed status`) shows `runtime-missing` on Windows, install the Microsoft Visual C++ 2015-2022 Redistributable (x64) from Microsoft and restart DSH. `auto` keeps using `keyword` meanwhile.
|
|
232
|
+
- **No memory appears in a turn.** Possible reasons: the store is empty; the message was too short or a command; the lookup took longer than `advanced.recallTimeoutMs`; the same block is already in the history; or keyword search could not match a reworded question.
|
|
233
|
+
- **The tool says "not saved: today's limit".** Raise `advanced.dailyWrites`, or set it to 0 for no cap.
|
|
234
|
+
- **Switch the plugin off.** On the Plugins page, turn off the row of the plugin. Or set `disabled: true` on the row `feiyu-memgate` in the profile's `cordis.patch.yml`.
|
|
235
|
+
- **Switch one module off.** `/memgate off <feature>`, or the switch on the settings page. For example `/memgate off autoRecall` keeps the tools and stops the automatic lookup.
|
|
236
|
+
|
|
237
|
+
## Licence
|
|
238
|
+
|
|
239
|
+
MIT, see [LICENSE](LICENSE). The bundled gateway in `python/` is the same author's project, [feiyu-memgate](https://github.com/N0rmal-114/feiyu-memgate), under the same licence ([python/LICENSE](python/LICENSE)). It is version 0.1.0 at commit `2f63e7512eec2091433bdc4e7650f28df23f2f11` as recorded in [python/GATEWAY_VERSION.json](python/GATEWAY_VERSION.json).
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# dsh-feiyu-memgate
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
[feiyu-memgate](https://github.com/N0rmal-114/feiyu-memgate) 记忆网关的 DeepSeek Harness(DSH)插件。它给 DSH 对话加上长期记忆:每轮开始时查找相关记忆,并给模型两个工具,用来记下和查找记忆。
|
|
6
|
+
|
|
7
|
+
网关随插件一起发布,由插件在你的电脑上启动。默认设置不需要任何模型,也不下载任何东西:记忆存在 SQLite 文件里,用关键词检索。
|
|
8
|
+
|
|
9
|
+
## 装上之后会发生什么
|
|
10
|
+
|
|
11
|
+
默认设置下,你会看到这些:
|
|
12
|
+
|
|
13
|
+
1. **网关在后台启动。** 第一次需要记忆功能时,插件查找 Python 3.11 或更新的版本,在数据文件夹里写一份网关配置,在一个空闲的回环端口上启动自带的网关。DSH 不会等它。网关就绪之前,召回什么都不加,工具回复“记忆功能现在不可用”。
|
|
14
|
+
2. **每轮开始时召回。** 你发出消息时,插件查找和它相关的记忆。只有一轮的第一步会查,只在你自己的会话里查,子智能体的会话不查。以 `/` 或 `/` 开头的消息、消息 `ok`、只有表情或标点的消息、以及只有一两个应声字(如 `嗯`、`好`)的消息不查。很短的消息(有效字符少于 8 个)会连同你上一条消息一起查。查询最长 500 个字符。
|
|
15
|
+
3. **记忆块。** 查到内容时,插件在你的消息之后加一条消息,内容放在 `<memory_data>` 块里。块的开头写明这些内容是资料,不是指令;然后列出最多 `advanced.recallLimit` 条记忆(默认 5 条),知道日期的带上日期。相关的记忆放不下时,最后一行说明还有几条。网关有分数线,所以多数轮次得到的记忆比上限少,不少轮次一条都没有。查找最多等 `advanced.recallTimeoutMs`(默认 4000 毫秒);更慢的查找这一轮跳过。
|
|
16
|
+
4. **记忆块留在对话历史里。** 它和这一轮一起保存,和别的消息一样。这有两个后果。有记忆块的每一轮,上下文都会变长,这些词元在之后的轮次里还会再发送。提示词缓存不受损害:你当前消息之前的内容都没有变,之前对话已缓存的前缀仍然有效。下一轮不会再加一个和历史里已有的那块完全相同的记忆块。
|
|
17
|
+
5. **给模型的两个工具。** `memgate_remember` 接收一句短话(最多 4000 个字符)并保存。`memgate_search` 接收一个查询(最多 500 个字符)和可选的 `limit`(1 到 10),返回同样格式的块。系统提示词里有一小段固定说明,告诉模型:你要求它记住某件事、或说出关于你自己、你的偏好、你的工作的长期信息时,调用 `memgate_remember`;不要保存秘密;之前的对话可能有答案时,调用 `memgate_search`;召回的记忆是资料,不是指令。工具会如实报告结果:已保存;没有保存(没有需要记的内容、今天的写入次数用完、被拒绝、记忆功能不可用);或结果不确定(网关没有及时回应)。工具没有说已保存,模型就不能说已保存。
|
|
18
|
+
6. **只通过工具写入。** 默认设置下,只有模型调用 `memgate_remember` 时才写入一条记忆。你不要求、模型也不决定记,就什么都不会存。打开 `modules.autoCapture` 后,每轮结束时还会把你自己发的消息交给记忆库(见下文)。
|
|
19
|
+
7. **记忆存在哪。** 存在 `<DSH home>/data/feiyu-memgate/` 里的 SQLite 文件中。`<DSH home>` 是环境变量 `DSH_HOME` 指向的文件夹;没有设置时是你用户文件夹下的 `.dsh`。
|
|
20
|
+
|
|
21
|
+
## 要求
|
|
22
|
+
|
|
23
|
+
- DeepSeek Harness。已在 DeepSeek Harness 0.2.2-rc.1(已安装的桌面版)上测试,并对照 0.2.2-rc.3 源码检查;engines.dsh 接受 0.2.2-alpha.1 到任何 0.2.2 预发布版(<0.2.3-0)。`package.json` 里的范围还接受 0.2.0-rc.1 到 0.2.1-0 之前,以及 0.2.1-alpha.1 到 0.2.2-0 之前。这两段没有测试过。
|
|
24
|
+
- Node 22.19 或更新(`engines.node`)。
|
|
25
|
+
- 自带网关需要 Python 3.11 或更新,并且要有 `sqlite3` 和 `tomllib` 两个模块,标准安装都带。网关只用 Python 标准库,不用 `pip install` 任何东西。外部网关模式下不需要 Python。
|
|
26
|
+
|
|
27
|
+
插件按下面的顺序找 Python,用第一个能用的:
|
|
28
|
+
|
|
29
|
+
1. 设置 `gateway.python`,不为空时。
|
|
30
|
+
2. 桌面版自带的 Python:环境变量 `DSH_PRIMARY_RUNTIME` 指向的文件夹(设置了的话),其下 Windows 是 `dependencies/python/python.exe`,其他系统是 `dependencies/python/bin/python3`。
|
|
31
|
+
3. 桌面版首次使用时安装的那一份:`<DSH home>/dsh-runtimes/dsh-primary-runtime/`,其下的文件路径同上。
|
|
32
|
+
4. `PATH` 里的 `python3`。
|
|
33
|
+
5. `PATH` 里的 `python`。
|
|
34
|
+
6. `PATH` 里的 `py -3`。
|
|
35
|
+
|
|
36
|
+
候选项必须能运行、版本是 3.11 或更新、并且有那两个模块才会被采用。一个都找不到时,网关不启动,日志里有一条警告,召回什么都不加,工具回复记忆功能不可用。DSH 和你的对话不受影响。查找结果在 DSH 重启之前一直保留;改动 `gateway.python` 会重新查找。
|
|
37
|
+
|
|
38
|
+
## 安装
|
|
39
|
+
|
|
40
|
+
在插件页面安装包 `dsh-feiyu-memgate`。包自带一行默认设置的配置,不需要自己编辑任何东西。
|
|
41
|
+
|
|
42
|
+
用命令行安装,对你使用的 profile 运行:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
dsh plugin --profile <name> add dsh-feiyu-memgate
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
桌面版的 profile 是 `desktop`。先启动一次桌面版,让它创建 profile,然后完全退出应用,运行下面的命令,再重新启动桌面版:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
dsh plugin --profile desktop add dsh-feiyu-memgate
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 设置
|
|
55
|
+
|
|
56
|
+
每项设置都有三种修改方式,写入的是同一份值。
|
|
57
|
+
|
|
58
|
+
- **设置页面。** 在插件页面打开本插件那一行。页面显示各项设置和一个状态块(网关、Python、存储和记忆条数、检索方式、向量插件、复制进度)。页面依赖宿主里仍在变化的界面接口;在你的 DSH 版本上用不了的话,用另外两种方式。
|
|
59
|
+
- **`/memgate` 聊天命令。** 见[/memgate 命令](#memgate-命令)。
|
|
60
|
+
- **profile 的配置文件。** profile 的 `cordis.patch.yml` 里的 `feiyu-memgate` 这一行。另外两种方式也把改动存在这里。家目录级的补丁或 `--patch` 覆盖层如果设置了同一行,它们优先;会被它们盖掉的改动会被拒绝。
|
|
61
|
+
|
|
62
|
+
多数设置立即生效。改动 `gateway.mode`、`gateway.python`、`gateway.dataDir`、检索方式或正在使用的向量接口设置、`advanced.profile`、`advanced.dailyWrites`、`advanced.redaction`、`advanced.newerFirst`、`advanced.forgetting` 会重启网关,每日写入上限的计数随之重新开始。关掉一项功能,它在 DSH 里注册的东西就被移除。只有 `modules.autoRecall`、`modules.rememberTool`、`modules.searchTool`、`modules.autoCapture` 中至少有一个开着时,网关才会运行。
|
|
63
|
+
|
|
64
|
+
| 设置 | 作用 | 默认值 | 备注 |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| `modules.autoRecall` | 每轮开始时查找相关记忆,放在你的消息之后。 | 开 | `/memgate on autoRecall` |
|
|
67
|
+
| `modules.rememberTool` | 给模型 `memgate_remember` 工具。 | 开 | |
|
|
68
|
+
| `modules.searchTool` | 给模型 `memgate_search` 工具。 | 开 | |
|
|
69
|
+
| `modules.promptSection` | 在系统提示词里加一小段关于记忆的固定说明。 | 开 | 不管其他设置怎样,这段文字都一样,所以不会扰乱提示词缓存。 |
|
|
70
|
+
| `modules.autoCapture` | 每轮结束后,把这一轮你输入的消息直接交给记忆库,不经过模型。 | 关 | 只有你自己的消息,不含召回的块、注入的上下文和子智能体的轮次。超过 4000 个字符的消息跳过,不截断。每次写入都计入 `advanced.dailyWrites`。 |
|
|
71
|
+
| `modules.commands` | 注册 `/memgate` 聊天命令。 | 开 | 需要支持聊天命令的宿主。 |
|
|
72
|
+
| `modules.migrateOnTierChange` | 向量检索启用时,在后台把关键词记忆复制到它的存储里。 | 开 | 见[语义检索](#语义检索可选插件)。 |
|
|
73
|
+
| `retrieval.tier` | 自带网关怎么查找记忆:`auto`、`keyword`、`endpoint` 或 `local`。 | `auto` | `/memgate use <方式>`。见下表。 |
|
|
74
|
+
| `retrieval.url` | `endpoint` 方式:OpenAI 兼容向量接口的基础地址,例如 `http://127.0.0.1:11434/v1`。 | 空 | 必须以 `http://` 或 `https://` 开头。 |
|
|
75
|
+
| `retrieval.model` | `endpoint` 方式:向量模型的名字。 | 空 | 换模型会用一个新的空存储。 |
|
|
76
|
+
| `retrieval.apiKey` | `endpoint` 方式:接口需要密钥时填写。 | 空 | 秘密。只写不读:设置页面保存后不再显示。 |
|
|
77
|
+
| `gateway.mode` | `managed` 启动自带的网关;`external` 使用你自己运行的网关。 | `managed` | 见[外部网关](#外部网关)。 |
|
|
78
|
+
| `gateway.python` | `managed`:使用哪个 Python(3.11 或更新)。留空时按“要求”一节的顺序查找。 | 空 | |
|
|
79
|
+
| `gateway.dataDir` | `managed`:存放记忆库、生成的网关配置和日志的文件夹。 | 空(`<DSH home>/data/feiyu-memgate`) | |
|
|
80
|
+
| `external.url` | `external`:网关地址,例如 `http://127.0.0.1:8080`。 | 空 | 必须以 `http://` 或 `https://` 开头。 |
|
|
81
|
+
| `external.token` | `external`:那个网关给这个客户端的令牌。 | 空 | 秘密。只写不读。 |
|
|
82
|
+
| `advanced.recallLimit` | 每轮最多加入几条记忆(1 到 10),也是 `memgate_search` 默认返回的条数。 | 5 | 你自己运行的网关同样适用。 |
|
|
83
|
+
| `advanced.recallTimeoutMs` | 每轮最多等自动召回多少毫秒(500 到 20000)。更慢的查找跳过。 | 4000 | |
|
|
84
|
+
| `advanced.language` | 记忆块、工具回复和 `/memgate` 用的语言:`auto`(跟随系统语言)、`zh` 或 `en`。 | `auto` | 记忆本身不会被翻译。 |
|
|
85
|
+
| `advanced.profile` | 网关判断“相关”的严格程度:`precise` 或 `broad`。 | `precise` | `precise` 返回的条数少、更贴题,漏得也多;`broad` 返回的条数多,杂讯也多。实测数字见网关文档的[部署档位](https://github.com/N0rmal-114/feiyu-memgate#部署档位);在关键词存储上,网关实测换成 `broad` 的收益很小。只用于 managed 模式。 |
|
|
86
|
+
| `advanced.dailyWrites` | 网关每天最多收下几条记忆(0 到 100000),0 表示不限。 | 50 | 一天从本地时间零点算起。网关每次重启,计数重新开始。只用于 managed 模式。 |
|
|
87
|
+
| `advanced.redaction` | 保存和召回记忆时,去掉密钥、令牌、密码这类秘密。 | 开 | 基于模式匹配,认不出旁边没有关键词提示的孤立秘密。只用于 managed 模式。 |
|
|
88
|
+
| `advanced.newerFirst` | 相关度差不多时,较新的记忆排在前面。 | 开 | 只看日期,不判断两条记忆是否矛盾。只用于 managed 模式。 |
|
|
89
|
+
| `advanced.forgetting` | 实验性。很久没用到的记忆排得更靠后,最终存档并删除。 | 关 | 见下文。只用于 managed 模式。 |
|
|
90
|
+
|
|
91
|
+
### 检索方式
|
|
92
|
+
|
|
93
|
+
每种方式在数据文件夹里各用一个存储文件。`/memgate tiers` 列出各种方式、是否可用、还缺什么。正在使用的方式缺东西时,网关不启动,记忆功能保持关闭,直到补齐。
|
|
94
|
+
|
|
95
|
+
| 方式 | 怎么查找记忆 | 需要 | 存储文件 |
|
|
96
|
+
|---|---|---|---|
|
|
97
|
+
| `auto` | `dsh-feiyu-memgate-embed` 插件有模型就绪时用 `local`,否则用 `keyword`。 | 无。 | 它所选方式的文件。 |
|
|
98
|
+
| `keyword` | 网关里基于 SQLite 的关键词检索。不需要模型,不需要网络。 | 无。 | `memories.db` |
|
|
99
|
+
| `endpoint` | 通过 OpenAI 兼容的向量接口做语义检索。记忆文本和查询会发给这个接口。 | `retrieval.url` 和 `retrieval.model`;接口需要密钥时还要 `retrieval.apiKey`。 | `memories-endpoint-<model>.db` |
|
|
100
|
+
| `local` | 用向量插件在本机运行的模型做语义检索。 | 安装并启用向量插件,并且有模型就绪。 | `memories-local-<model>-<hash>.db` |
|
|
101
|
+
|
|
102
|
+
向量插件消失或它的模型变了,`auto` 或 `local` 下的网关会按新状态重启。
|
|
103
|
+
|
|
104
|
+
### 外部网关
|
|
105
|
+
|
|
106
|
+
`gateway.mode` 设为 `external` 时,插件什么都不启动,只用 `external.token` 里的客户端令牌连接 `external.url` 的网关。两项有一项为空,记忆功能就关闭,并在日志里记一条警告。这个模式下,`retrieval.*`、`gateway.python`、`gateway.dataDir`、复制到向量存储,以及 `advanced` 里的网关规则(`profile`、`dailyWrites`、`redaction`、`newerFirst`、`forgetting`)都不起作用:网关按它自己的配置运行。`advanced.recallLimit`、`advanced.recallTimeoutMs`、`advanced.language` 仍然有效。
|
|
107
|
+
|
|
108
|
+
几个程序共用一个网关,或者你想让存储密钥不进 DSH 进程时,优先用它。网关说的是明文 HTTP,所以只在本机或可信的网络里用,或者在前面加 TLS。插件不跟随重定向,令牌不会发到别的地址。
|
|
109
|
+
|
|
110
|
+
### 高级:遗忘
|
|
111
|
+
|
|
112
|
+
`advanced.forgetting` 是实验性功能,默认关闭。打开后,网关把很久没用到的记忆排得更靠后。按网关的默认值,一条记忆大约 389 天没被用到就会存档并删除,每次清理每个存储最多删 5 条和库内条数 2% 中较大的那个,一天清理一次。存档的文本以明文保留在数据文件夹里 90 天,之后删除。第一次清理在网关启动 24 小时之后。“用到”指在一次召回里排在靠前的位置被返回;插件不会上报模型实际用了哪几条。这个功能只在网关的模拟里测过。插件没有恢复存档记忆的命令。
|
|
113
|
+
|
|
114
|
+
### /memgate 命令
|
|
115
|
+
|
|
116
|
+
给你用的聊天命令,只能写一行。键名写成 `group.key`;只写 `recallLimit` 这样的短键名,在它只对应一项设置时也可以(`url` 不行,`retrieval` 和 `external` 里都有)。键名不分大小写。开关的值接受 `on`、`off`、`true`、`false`、`yes`、`no`、`1`、`0`,以及 `开`、`关`、`是`、`否`。你设置的秘密不会在回复里重复,命令行也不会写进会话记录。
|
|
117
|
+
|
|
118
|
+
| 子命令 | 作用 | 示例 |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| `status` | 网关状态、找到的 Python、存储和记忆条数、检索方式、向量插件、复制进度、已开的功能。 | `/memgate status` |
|
|
121
|
+
| `config` | 每项设置的当前值和默认值。秘密只显示已设置或未设置。 | `/memgate config` |
|
|
122
|
+
| `set <键> <值>` | 修改一项设置。 | `/memgate set advanced.recallLimit 3` |
|
|
123
|
+
| `reset <键>` | 把一项设置恢复默认(要清空文本设置,也用它)。 | `/memgate reset retrieval.apiKey` |
|
|
124
|
+
| `on <功能>` | 打开一项功能。功能就是 `modules.*` 设置。 | `/memgate on autoCapture` |
|
|
125
|
+
| `off <功能>` | 关闭一项功能。 | `/memgate off searchTool` |
|
|
126
|
+
| `tiers` | 各种检索方式:是否可用、正在用哪个、各需要什么。 | `/memgate tiers` |
|
|
127
|
+
| `use <方式>` | 选择检索方式:`auto`、`keyword`、`endpoint` 或 `local`。 | `/memgate use keyword` |
|
|
128
|
+
| `models` | 本地向量模型:下载大小、内存、语言、许可和状态。 | `/memgate models` |
|
|
129
|
+
| `install <模型> [--accept-licence <许可名称>] [--confirm]` | 下载一个模型并启用。没有向量插件时会先安装插件,这一步需要 `--confirm`(不带它时,回复会说明将要安装什么)。 | `/memgate install bge-small-zh-v1.5 --confirm` |
|
|
130
|
+
| `builds allow` / `builds deny` | 回答插件安装时的安装脚本问题。 | `/memgate builds deny` |
|
|
131
|
+
| `use <模型>` | 切换到一个已下载的模型。 | `/memgate use bge-m3` |
|
|
132
|
+
| `remove <模型>` | 删除一个没在使用的已下载模型。 | `/memgate remove bge-m3` |
|
|
133
|
+
| `cancel` | 停止正在进行的插件安装或模型下载,或者去掉一个还没回答的安装脚本问题。 | `/memgate cancel` |
|
|
134
|
+
|
|
135
|
+
模型相关的子命令和设置页面上的按钮做的是同一件事,见[在设置页面安装](#在设置页面安装)。
|
|
136
|
+
|
|
137
|
+
不带参数的 `/memgate` 和 `/memgate help` 会打印用法。
|
|
138
|
+
|
|
139
|
+
### profile 配置文件
|
|
140
|
+
|
|
141
|
+
profile 的 `cordis.patch.yml` 里,一行会整个替换同一个 `id` 那一行的 `config`,所以要把想和默认值不同的各组都写上,不改的组不写。例如,调大召回条数并打开自动记录:
|
|
142
|
+
|
|
143
|
+
```yaml
|
|
144
|
+
- id: feiyu-memgate
|
|
145
|
+
config:
|
|
146
|
+
modules:
|
|
147
|
+
autoCapture: true
|
|
148
|
+
advanced:
|
|
149
|
+
recallLimit: 8
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
不要编辑包里自带的 `cordis.patch.yml`,它只负责用默认设置挂载插件。
|
|
153
|
+
|
|
154
|
+
## 语义检索(可选插件)
|
|
155
|
+
|
|
156
|
+
关键词检索只能找到和问题有共同用词的记忆。想连换了说法的也找到,就安装附加插件 [`dsh-feiyu-memgate-embed`](https://github.com/N0rmal-114/feiyu-memgate/tree/main/plugins/dsh-feiyu-memgate-embed)。它只在 CPU 上运行一个本地向量模型,在 `127.0.0.1` 上提供服务,再提供给本插件。模型只在你要求时才下载,文本不离开你的电脑。在 Windows 上,它的引擎需要 Microsoft Visual C++ 2015-2022 运行库(x64),大多数 Windows 已经装有。
|
|
157
|
+
|
|
158
|
+
安装它会带来这些变化:
|
|
159
|
+
|
|
160
|
+
- `retrieval.tier` 为 `auto` 时,向量插件里有模型就绪后,本插件从 `keyword` 切换到 `local`,网关用新的存储重启。模型不再就绪时,`auto` 退回 `keyword`。
|
|
161
|
+
- **已有的记忆在第一次启用时复制到向量存储。** 这是迁移模块,由 `modules.migrateOnTierChange` 控制。网关在向量检索(`local` 或 `endpoint`)下运行起来后,插件在后台把关键词存储(`memories.db`)里的记忆复制过去,分批进行(每批最多 500 条、最长 120 秒),只要每批都有进展就接着复制。数据文件夹里的状态文件 `migration-<store id>.json` 记录已复制的内容,所以中断的复制在重启后接着做。关键词存储只读,不会被改动。
|
|
162
|
+
- 进度看 `/memgate status`(“从关键词存储复制”一行:已复制 / 总数,以及被拒收的条数),或设置页面的状态块。复制还没走到的记忆,语义检索找不到。
|
|
163
|
+
- **比模型输入上限长的记忆,只按开头部分被检索到。** 网关每条记忆最多收 4000 个字符;模型的上限是 512 个词元(两个 bge-zh 模型,大约 500 个汉字)、2048(bge-m3)或 4095(qwen3-embedding)。默认情况下,向量插件只对放得下的部分做向量,网关校准时长文本也是这样测的,记忆全文照样保存和返回。把向量插件的设置 `model.overflow` 改成 `reject` 后,这样的文本会被拒收:复制时记为拒收,只留在关键词存储里,不会再交给这个向量存储。某一批里模型一条都不收时,复制停下,等网关下次启动再试。
|
|
164
|
+
- **在一种检索方式下写的记忆,和另一种方式的记忆分开存放。** 每种方式、每个模型各有自己的文件。在向量检索下保存的文本不会复制回关键词存储;换一个新模型时,它得到的只是关键词存储的复制,不含上一个模型存储里的内容。切回某种方式,仍能找到那种方式下的记忆。
|
|
165
|
+
|
|
166
|
+
`endpoint` 方式用的是你自己选的向量接口,例如本机的 Ollama 或云端服务,复制的做法相同。这时记忆文本和查询会发给那个接口(见下一节)。
|
|
167
|
+
|
|
168
|
+
### 在设置页面安装
|
|
169
|
+
|
|
170
|
+
设置页面有一节“本地向量模型”,不管向量插件装没装都会显示。每一行给出模型的档位、下载大小、运行内存、语言、许可和一句说明,并链接到[网关的部署档位](https://github.com/N0rmal-114/feiyu-memgate#部署档位),那里有实测效果。运行内存是向量插件实测的模型进程加载后的内存(bge-small-zh-v1.5:文件 48 MB,运行时约 190 MB),不是文件大小。不按按钮就什么都不下载。在对话里用 `/memgate models` 等模型子命令也一样。
|
|
171
|
+
|
|
172
|
+
按一次“下载并启用”会发生这些事:
|
|
173
|
+
|
|
174
|
+
1. **没有向量插件时,页面先请你确认要安装的东西**:通过宿主的插件管理器从 npm 安装 `dsh-feiyu-memgate-embed`,它会带来一个含原生二进制的依赖(`node-llama-cpp`,CPU 版约 90 MB;在 Windows 和 Linux x64 上 pnpm 还会取 GPU 版本,最多约 740 MB)。模型只在 CPU 上运行;在 Windows 上,引擎需要 Microsoft Visual C++ 2015-2022 运行库(x64)。宿主本身不会为此弹出对话框,所以这是唯一的一次确认。
|
|
175
|
+
2. **pnpm 会先拦下 `node-llama-cpp` 的安装脚本,等你决定。** 这时什么都还没装:宿主把配置的 `package.json` 恢复原样,只在配置的 `pnpm-workspace.yaml` 的 `allowBuilds` 下写一行 `node-llama-cpp: set this to true or false`。页面会问你是否允许这个脚本。据插件作者测试,两种选择都能用,因为引擎不需要这个脚本。
|
|
176
|
+
- **允许**:在这个 DSH 配置里留下长期许可,重新安装并启用插件。
|
|
177
|
+
- **拒绝**:DSH 里没有按钮。页面会说出文件 `<DSH home>/profiles/<配置名>/pnpm-workspace.yaml`(显示你配置的实际路径)和要改的那一行:把 `node-llama-cpp: set this to true or false` 改成 `node-llama-cpp: false`,保存,然后再按一次“下载并启用”。插件会跳过这个脚本装好并启用。
|
|
178
|
+
- 不回答也不会改动别的东西:插件的任何部分都没有安装或启用,宿主只在以后的安装里才读那一行。按“取消”会把问题从页面上去掉。
|
|
179
|
+
|
|
180
|
+
没有你的回答,插件绝不替你允许脚本,也不改配置里的文件。
|
|
181
|
+
3. **下载模型**,并显示进度;许可需要接受的模型会有一个勾选框。模型就绪后,`auto` 切换到 `local`,关键词记忆按上文所述复制过去。状态块会显示检索方式和复制进度。
|
|
182
|
+
|
|
183
|
+
如果向量插件已经是配置的依赖但没有启用,比如一次停在安装脚本上的 `dsh plugin add` 之后,这个按钮会通过插件管理器启用它,而不是再装一次;如果它的文件已经不在了,就先移除再重新安装。
|
|
184
|
+
|
|
185
|
+
关掉或刷新页面不会打断设置。下载途中 DSH 重启的话,向量插件会保留已下载的部分,这一行会显示“继续下载”。失败会用平常话说明,并告诉你该怎么做:没有网络或镜像连不上、磁盘空间不够、下载文件校验失败、引擎加载不了(在 Windows 上:从微软安装 Microsoft Visual C++ 2015-2022 运行库(x64),即 `vc_redist.x64.exe`,然后重启 DSH;向量插件的状态会显示错误 `runtime-missing`)、网关找不到 Python、你没有确认安装、宿主启用不了插件、或者模型在向量插件自己的设置里被固定了。只有你能开始安装:模型的工具做不到,设置页面的接口也只接受已登录的所有者,并且要带上明确的确认。
|
|
186
|
+
|
|
187
|
+
## 数据与隐私
|
|
188
|
+
|
|
189
|
+
- **默认模式下一切都留在你的电脑上。** 自带的网关、存储和日志都在本地。插件除了访问自己网关的回环地址,不发出任何网络请求。除非你在设置页面或用 `/memgate install` 安装向量插件或模型,否则不下载任何东西;那时由宿主的插件管理器从 npm 取向量插件,再由向量插件下载模型。
|
|
190
|
+
- **文件。** 都在数据文件夹里,没有设置 `gateway.dataDir` 时是 `<DSH home>/data/feiyu-memgate/`:
|
|
191
|
+
|
|
192
|
+
| 文件 | 是什么 |
|
|
193
|
+
|---|---|
|
|
194
|
+
| `memories.db` | 关键词存储。 |
|
|
195
|
+
| `memories-endpoint-<model>.db`、`memories-local-<model>-<hash>.db` | 向量检索的存储,每个模型一个。 |
|
|
196
|
+
| `migration-<store id>.json` | 向量存储的复制进度:只有数量和引用,没有文本。 |
|
|
197
|
+
| `model-setup.json` | 从设置页面或 `/memgate install` 开始的模型设置进度:模型、进行到哪一步、等你决定的安装脚本、上次失败的代码。 |
|
|
198
|
+
| `forgetting-ledger-<store id>.db`、`forgetting-archive-<store id>.db` | 只在打开遗忘时出现。存档里是被删记忆的全文,没有加密。 |
|
|
199
|
+
| `gateway.log`、`gateway.log.1` | 网关日志,大约 1 MiB 轮转一次。 |
|
|
200
|
+
| `gateway-<pid>-<n>.toml` | 正在运行的进程的网关配置,进程停止时删除。里面没有令牌,也没有密钥。 |
|
|
201
|
+
| `pycache/` | 网关的 Python 字节码缓存。 |
|
|
202
|
+
|
|
203
|
+
- **插件不做加密。** 存储是普通的 SQLite 文件。像保护任何存着个人笔记的文件一样保护这个文件夹。
|
|
204
|
+
- **网关只在本机。** 它监听 `127.0.0.1`,端口每次启动时随机选一个空闲的。每次启动,插件生成一个新的随机令牌(32 字节),只存在内存里和网关的环境变量里,从不写进文件或日志。网关进程拿到的是 DSH 环境变量的副本,去掉名字含 `KEY`、`PASSWORD`、`SECRET`、`TOKEN` 的,也去掉以 `DSH_` 开头的,再加上它需要的令牌,以及 `endpoint` 方式下需要的密钥。DSH 退出时它也退出。
|
|
205
|
+
- **召回的记忆会发给你的模型服务商。** 记忆块是提示词的一部分,所以它和别的消息一样,会发给这段对话使用的模型服务。
|
|
206
|
+
- **`endpoint` 模式下离开电脑的内容。** 每条保存或复制的记忆的文本,以及每次召回的查询,都会发给你在 `retrieval.url` 里配置的向量接口。接口密钥通过环境变量交给网关,不写进文件。`external` 模式下,请求发往 `external.url` 里的地址。
|
|
207
|
+
- **日志只记失败的种类。** 插件不会在日志里写查询、记忆文本或令牌。
|
|
208
|
+
- **删除全部数据。** 退出 DSH(或把插件关掉),然后删除数据文件夹。改过 `gateway.dataDir` 的,删除那个文件夹。如果你让向量插件用它默认的文件夹,这个文件夹里也有向量插件的模型和状态文件,所以只删你想删的文件。
|
|
209
|
+
|
|
210
|
+
## 限制与没有验证的部分
|
|
211
|
+
|
|
212
|
+
- **关键词检索找不到换了说法的问题。** 在网关自己的基准测试里(240 条记忆、160 个问题、合成的中文文本),关键词存储在默认设置下,55 个换了说法的问题一个都没有交出正确的记忆;45 个用了记忆原话的问题里交出了 95.6%。语义检索在换了说法的问题上好得多。见[基准测试](https://github.com/N0rmal-114/feiyu-memgate#基准测试)。中文以外的语言没有测过。
|
|
213
|
+
- **记忆块留在历史里。** 每个得到记忆块的轮次都会让上下文变长(见上面第 4 点)。
|
|
214
|
+
- **只有模型选择保存的记忆才存在**,除非你打开 `modules.autoCapture`。网关按传入的原文存储,打开脱敏时去掉秘密。它不抽取事实,不归并记忆,也不把旧记忆标成过时。较新的记忆只是排在较旧的前面。
|
|
215
|
+
- **每日写入上限在内存里计数,按 DSH 进程计。** 网关每次重启就重新开始;第二个 DSH 进程有它自己的网关和自己的计数。
|
|
216
|
+
- **每种检索方式只有一个存储。** 插件只用一个网关客户端和每种方式一个存储,不按用户或项目分开保存记忆。
|
|
217
|
+
- **设置页面依赖宿主里仍在变化的界面接口。** 没有它插件照样能用:每项设置都能用 `/memgate` 或在 profile 文件里修改。
|
|
218
|
+
- **遗忘是实验性的**,只在模拟里测过。
|
|
219
|
+
- **真实环境测试。** 在 Windows 11 上已安装的 DeepSeek Harness 0.2.2-rc.1 里,用一个隔离的配置测过:插件能加载,自带网关用 PATH 上的 Python 启动,设置页面能显示和保存,状态接口和模型接口只回应所有者的会话,聊天命令可用;装上向量插件和 bge-small-zh-v1.5 后用的是 local 检索方式,换了说法的问题能找到对应的记忆。通过设置页面从 npm 安装向量插件也测过,测的是拒绝依赖的安装脚本这条路:向量插件装好并启用,模型下载完成,检索方式换成 local(允许脚本的那条路没有跑过)。没有测过:macOS 和 Linux 桌面、桌面应用自己的窗口(用的是同一宿主的 web 配置)、和真实模型的对话(自动召回和两个工具只在测试里和对着网关测过,没有在实际聊天里用过)。
|
|
220
|
+
- **其他版本和系统。** 可接受范围内的其他 DSH 版本、其他操作系统和其他 Python 构建,都没有在真实宿主里测过。
|
|
221
|
+
- 当前版本是 0.1.1。
|
|
222
|
+
|
|
223
|
+
## 故障排查
|
|
224
|
+
|
|
225
|
+
先看 `/memgate status`。它显示网关的状态、找到的 Python、存储和记忆条数、检索方式、向量插件和复制进度。
|
|
226
|
+
|
|
227
|
+
- **找不到 Python。** `/memgate status` 里 Python 显示没有找到。安装 Python 3.11 或更新的版本,或者把 `gateway.python` 设成它的完整路径。改动设置会重新查找;如果只是装了 Python,要重启 DSH,因为查找结果在那之前一直保留。也可以改用外部网关。
|
|
228
|
+
- **网关启动不了,或不断停止。** 看数据文件夹里的 `gateway.log`。插件会写下“using Python”“gateway starting on port”“gateway healthy”“gateway did not become healthy in time”“gateway exited”这样的行,网关自己的输出紧跟其后。插件等一次启动最多 20 秒。网关崩溃后,插件最多重启它 5 次,间隔越来越长(1 秒,每次翻倍,最长 30 秒)。之后状态是“多次失败后已停止”,直到一次会重启网关的设置改动,或者 DSH 重启。
|
|
229
|
+
- **端口或权限问题。** 没有固定端口可冲突:每次启动在 `127.0.0.1` 上选一个空闲端口。有安全软件拦截 Python 的启动或回环地址的监听时,日志里会是 “did not become healthy in time”。插件不能创建或写入数据文件夹时,DSH 日志里会有 “cannot create the data folder” 或 “cannot write the gateway configuration”,记忆功能关闭;把 `gateway.dataDir` 设成你能写入的文件夹。
|
|
230
|
+
- **检索方式没有就绪。** `/memgate tiers` 会说缺什么,例如 `endpoint` 缺 `retrieval.url`,或 `local` 缺向量插件里就绪的模型。补齐之前记忆功能保持关闭。`/memgate use keyword` 什么都不需要。
|
|
231
|
+
- **本地模型加载不了。** 模型列表会说明原因和怎么办。在 Windows 上,如果向量插件的状态(`/memgate-embed status`)显示 `runtime-missing`,从微软安装 Microsoft Visual C++ 2015-2022 运行库(x64),然后重启 DSH。在此期间 `auto` 继续用 `keyword`。
|
|
232
|
+
- **某一轮没有出现记忆。** 可能的原因:存储是空的;消息太短,或是命令;查找用的时间超过了 `advanced.recallTimeoutMs`;同样的块已经在历史里;或者关键词检索没能匹配上换了说法的问题。
|
|
233
|
+
- **工具说“没有保存:今天写入记忆的次数已经用完”。** 调高 `advanced.dailyWrites`,或设为 0 表示不限。
|
|
234
|
+
- **关掉整个插件。** 在插件页面关掉本插件那一行。或者在 profile 的 `cordis.patch.yml` 里给 `feiyu-memgate` 这一行加 `disabled: true`。
|
|
235
|
+
- **只关掉一项功能。** `/memgate off <功能>`,或设置页面上的开关。例如 `/memgate off autoRecall` 保留工具,只停掉自动查找。
|
|
236
|
+
|
|
237
|
+
## 许可
|
|
238
|
+
|
|
239
|
+
MIT,见 [LICENSE](LICENSE)。`python/` 里自带的网关是同一作者的项目 [feiyu-memgate](https://github.com/N0rmal-114/feiyu-memgate),许可相同([python/LICENSE](python/LICENSE))。版本是 0.1.0,提交是 `2f63e7512eec2091433bdc4e7650f28df23f2f11`,记录在 [python/GATEWAY_VERSION.json](python/GATEWAY_VERSION.json) 里。
|