diff --git a/packages/respire-memory/README.md b/packages/respire-memory/README.md
index ba1053d..4855744 100644
--- a/packages/respire-memory/README.md
+++ b/packages/respire-memory/README.md
@@ -6,8 +6,16 @@ This supports agent self-evolution through reusable experience. It does not trai
## Install
+Install the [Respire CLI](https://github.com/risense-ai/respire-cli) first: this plugin is only the Magpie integration; the CLI provides the memory library and local Runtime. Follow the [npm installation guide](https://www.npmjs.com/package/rsrs-cli), or download your platform from [CLI Releases](https://github.com/risense-ai/respire-cli/releases).
+
~~~sh
-magpie plugin add @magpie-community/gateway-respire-memory
+npm install -g rsrs-cli
+~~~
+
+Prepare your account/model and start/unlock the local HTTP Runtime using the [Runtime guide](https://github.com/risense-ai/respire-cli/blob/main/docs/runtime.md). Check `rsrs --client-only status --json`, then install this plugin:
+
+~~~sh
+magpie plugin add respire-memory
~~~
Requires Magpie 0.1.1273+ and Bun 1.3.6+, with an existing unlocked local Respire HTTP Runtime. Page saves reaching hooks require Magpie 0.1.1531+. The magpie-key classification needs a newer host; older hosts may skip that origin. This plugin does not provision an engine, manage accounts/services or reuse private provider credentials.
diff --git a/packages/respire-memory/memory-tools.mjs b/packages/respire-memory/memory-tools.mjs
index b0215d5..1119d61 100644
--- a/packages/respire-memory/memory-tools.mjs
+++ b/packages/respire-memory/memory-tools.mjs
@@ -32,28 +32,32 @@ function boundedDiaryArgs(command, args) {
export async function readDiary(call, id, content, source) {
if (!validId(id) || !/^[a-f0-9]{64}$/.test(source ?? '') || !content.includes(source)) throw new Error('diary-readback-source');
- const found = await call(['diary-search', source, '--limit', '5', '--max-chars', '4000', '--mode', 'hybrid']);
+ // A turn hash is an exact locator, not a semantic history query.
+ const found = await call(['diary-search', source, '--limit', '5', '--max-chars', '4000', '--mode', 'lexical']);
if (Array.from(JSON.stringify(found.details ?? {})).length > 4000) throw new Error('diary-output-too-large');
- const candidate = found.details?.items?.find(item => item.source_id === id && !item.truncated && item.text?.includes(source));
- if (found.status !== 'ok' || !candidate?.fragment_id || !candidate.source_version) throw new Error('diary-readback-unconfirmed');
- const fragment = await call(['diary-fragment', id, candidate.fragment_id, '--neighbors', '1', '--max-chars', '4000']);
- if (Array.from(JSON.stringify(fragment.details ?? {})).length > 4000) throw new Error('diary-output-too-large');
- const items = fragment.details?.items;
- if (fragment.status !== 'ok' || !Array.isArray(items) || !items.some(item => item.fragment_id === candidate.fragment_id)
- || items.some(item => item.source_id !== id || item.source_version !== candidate.source_version || item.truncated || typeof item.text !== 'string'
- || !Number.isInteger(item.start) || !Number.isInteger(item.end) || item.end - item.start !== Array.from(item.text).length)) throw new Error('diary-readback-unconfirmed');
- const ordered = [...items].sort((a,b) => a.start - b.start);
- const start = ordered[0].start, text = Array.from(ordered[0].text);
- let end = ordered[0].end;
- for (const item of ordered.slice(1)) {
- const chars = Array.from(item.text), overlap = Math.min(end - item.start, chars.length);
- if (overlap < 0 || text.slice(item.start - start, item.start - start + overlap).join('') !== chars.slice(0, overlap).join('')) throw new Error('diary-readback-unconfirmed');
- text.push(...chars.slice(overlap)); end = Math.max(end, item.end);
+ const candidates = found.details?.items?.filter(item => item.source_id === id && !item.truncated && item.text?.includes(source) && item.fragment_id && item.source_version);
+ if (found.status !== 'ok' || !candidates?.length) throw new Error('diary-readback-unconfirmed');
+ for (const candidate of candidates) {
+ const fragment = await call(['diary-fragment', id, candidate.fragment_id, '--neighbors', '1', '--max-chars', '4000']);
+ if (Array.from(JSON.stringify(fragment.details ?? {})).length > 4000) throw new Error('diary-output-too-large');
+ const items = fragment.details?.items;
+ if (fragment.status !== 'ok' || !Array.isArray(items) || !items.some(item => item.fragment_id === candidate.fragment_id)
+ || items.some(item => item.source_id !== id || item.source_version !== candidate.source_version || item.truncated || typeof item.text !== 'string'
+ || !Number.isInteger(item.start) || !Number.isInteger(item.end) || item.end - item.start !== Array.from(item.text).length)) throw new Error('diary-readback-unconfirmed');
+ const ordered = [...items].sort((a,b) => a.start - b.start);
+ const start = ordered[0].start, text = Array.from(ordered[0].text);
+ let end = ordered[0].end;
+ for (const item of ordered.slice(1)) {
+ const chars = Array.from(item.text), overlap = Math.min(end - item.start, chars.length);
+ if (overlap < 0 || text.slice(item.start - start, item.start - start + overlap).join('') !== chars.slice(0, overlap).join('')) throw new Error('diary-readback-unconfirmed');
+ text.push(...chars.slice(overlap)); end = Math.max(end, item.end);
+ }
+ if (!text.join('').includes(content)) continue;
+ // Return only the verified write, never adjacent turns from the daily source.
+ return { status: 'ok', summary: { id }, details: { entry: { id, importance: 'trivial', content },
+ diaryReadback: { verified: true, fragments: ordered.map(({ source_id, fragment_id, source_version, start, end }) => ({ source_id, fragment_id, source_version, start, end })) } } };
}
- if (!text.join('').includes(content)) throw new Error('diary-readback-unconfirmed');
- // Return only the verified write, never adjacent turns from the daily source.
- return { status: 'ok', summary: { id }, details: { entry: { id, importance: 'trivial', content },
- diaryReadback: { verified: true, fragments: ordered.map(({ source_id, fragment_id, source_version, start, end }) => ({ source_id, fragment_id, source_version, start, end })) } } };
+ throw new Error('diary-readback-unconfirmed');
}
export function memoryTools(call, { readOnly = false, source } = {}) {
@@ -113,7 +117,7 @@ export function memoryTools(call, { readOnly = false, source } = {}) {
if (diary && error.message === 'diary-unsupported') diaryUnavailable = true
throw error
}
- if (diary && JSON.stringify(doc).length > 8000) throw new Error('diary-output-too-large')
+ if (diary && Array.from(JSON.stringify(doc.details ?? {})).length > Number(args[args.indexOf('--max-chars') + 1])) throw new Error('diary-output-too-large')
if (command === 'recall' && ['ok', 'skip'].includes(doc.status)) recalled = true
if (command === 'prompt') {
if (doc.status !== 'ok' || typeof doc.summary?.instructions !== 'string' || !doc.summary.instructions.trim()) throw new Error('invalid-engine-policy')
diff --git a/packages/respire-memory/package.json b/packages/respire-memory/package.json
index 0a7ae6e..e3d22fa 100644
--- a/packages/respire-memory/package.json
+++ b/packages/respire-memory/package.json
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/gateway-respire-memory",
- "version": "0.3.6",
+ "version": "0.3.10",
"description": "帮助 AI Agent 通过记忆召回、经验积累与后台归档持续自进化",
"type": "module",
"license": "MIT",
diff --git a/packages/respire-memory/page/settings.html b/packages/respire-memory/page/settings.html
index e11839d..c6127f3 100644
--- a/packages/respire-memory/page/settings.html
+++ b/packages/respire-memory/page/settings.html
@@ -7,6 +7,13 @@
+ 首次使用:先安装 Respire 本体
+ 此插件是 Magpie 的接入层,需要另行安装 Respire CLI(GitHub 安装说明)。它提供记忆库与本地 Runtime;只安装插件还不能读存记忆。
+ - 在自己的终端执行
npm install -g rsrs-cli,或从 CLI Releases 下载对应平台版本。
+ - 按 CLI Runtime 指南准备账号、模型,启动并解锁本地 HTTP Runtime。
+ - 执行
rsrs --client-only status --json 确认连接,再在下方配置 Runtime 地址及归档生成模型并保存。
+ 插件不会代装 CLI、启动 Runtime 或管理账号;登录与解锁请在 Respire 中完成,不要在此页面输入密码或密钥。
+
- 使用方式
召回自动执行。“/nomem”或“#nomem”只跳过本条召回;已开启的采集与后台归档仍可运行。存储是否成功以模型收到的引擎回执为准。
插件不安装或启动 Runtime。连接失败时原对话继续;共享网关的其他调用者无法使用此插件读取或保存记忆。
+ 使用方式
完成上方 Respire CLI 安装与配置后,召回自动执行。“/nomem”或“#nomem”只跳过本条召回;已开启的采集与后台归档仍可运行。存储是否成功以模型收到的引擎回执为准。
连接失败时先按 Respire CLI 说明检查本体与 Runtime;原对话会继续。共享网关的其他调用者无法使用此插件读取或保存记忆。