@jjh32456/longlive 2.0.0 → 2.2.0
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/CHANGELOG.md +58 -4
- package/QUICKSTART.md +7 -7
- package/README.en.md +4 -4
- package/README.md +34 -22
- package/SPEC.md +3 -3
- package/build-info.json +85 -60
- package/cordis.patch.yml +1 -0
- package/docs/ANSWER-GUARD.md +1 -1
- package/docs/ARCHITECTURE.md +3 -3
- package/docs/AUTO-RECALL-WIRING.md +5 -3
- package/docs/AUTO-RECALL.md +9 -3
- package/docs/CONFIG.md +7 -4
- package/docs/ERRORS.md +1 -1
- package/docs/FAQ.md +6 -6
- package/docs/FEATURES.md +36 -12
- package/docs/OPERATIONS.md +3 -3
- package/docs/PRIVACY.md +1 -1
- package/docs/QUICKSTART.md +4 -4
- package/docs/README.en.md +3 -3
- package/docs/TOOLS.md +1 -1
- package/docs/TROUBLESHOOTING.md +3 -3
- package/package.json +1 -1
- package/src/config.js +7 -0
- package/src/features.js +25 -0
- package/src/gate/action-gate.js +356 -0
- package/src/index.js +2 -2
- package/src/memory/consolidate.js +441 -26
- package/src/memory/index.js +33 -4
- package/src/memory/maintenance.js +127 -6
- package/src/memory/memory-reader.mjs +1003 -0
- package/src/memory/recall-v2.js +5 -3
- package/src/memory/recall.js +10 -4
- package/src/recall/brain.mjs +47 -5
- package/src/recall/continuity-log.mjs +435 -0
- package/src/recall/continuity-volatile.mjs +1065 -0
- package/src/recall/index.js +349 -8
- package/src/recall/link-fastpath.mjs +662 -0
- package/src/recall/recall-core.mjs +27 -0
- package/src/tools.js +46 -1
package/src/tools.js
CHANGED
|
@@ -58,6 +58,8 @@ import { normalizeTiering, buildTierHint, DEFAULT_TIERING } from './memory/tiers
|
|
|
58
58
|
import { liveUpdate, liveList, liveGet, livePrune } from './live.js';
|
|
59
59
|
import { sessionIdOfLogFile } from './live-target.js';
|
|
60
60
|
import { privacyScan } from './recall/privacy.mjs';
|
|
61
|
+
import { appendGateLog } from './recall/gate-log.mjs';
|
|
62
|
+
import { ACTION_KEYWORDS } from './gate/action-gate.js';
|
|
61
63
|
import { searchEventsFts, searchEventsReadOnly } from './memory/event-index.js';
|
|
62
64
|
import {
|
|
63
65
|
buildTurnItems,
|
|
@@ -2019,6 +2021,49 @@ function memoryTool(name, fn) {
|
|
|
2019
2021
|
};
|
|
2020
2022
|
}
|
|
2021
2023
|
|
|
2024
|
+
/**
|
|
2025
|
+
* 2.2.0 动作前回忆门(lane-C):memory_recall 命中动作类查询、且结果里带回 procedure 卡时,
|
|
2026
|
+
* 往 gate-log 写一条 gate='action' / decision='ok' 的显式回执行,作为「执行前回忆过」的凭据。
|
|
2027
|
+
* 只读召回本身不变(不写卡、不建 INDEX);回执写失败一律 fail-open,绝不影响召回结果。
|
|
2028
|
+
*/
|
|
2029
|
+
function withActionGateReceipt(name, invoke) {
|
|
2030
|
+
return (args, config) => {
|
|
2031
|
+
const result = invoke(args, config);
|
|
2032
|
+
try {
|
|
2033
|
+
writeActionGateReceipt(name, args, result, config);
|
|
2034
|
+
} catch {
|
|
2035
|
+
/* 回执写失败不影响召回:动作门会按「无回执」处理 */
|
|
2036
|
+
}
|
|
2037
|
+
return result;
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
function writeActionGateReceipt(name, args, result, config) {
|
|
2042
|
+
if (!result || result.ok !== true || !Array.isArray(result.results)) return;
|
|
2043
|
+
const query = typeof args?.query === 'string' ? args.query : '';
|
|
2044
|
+
if (query.trim() === '') return;
|
|
2045
|
+
const lowerQuery = query.toLowerCase();
|
|
2046
|
+
if (!ACTION_KEYWORDS.some((keyword) => lowerQuery.includes(keyword.toLowerCase()))) return;
|
|
2047
|
+
const procedures = result.results
|
|
2048
|
+
.filter((row) => row && typeof row.path === 'string' && row.path.startsWith('procedures/'))
|
|
2049
|
+
.map((row) => (typeof row.title === 'string' && row.title.trim() !== '' ? row.title.trim() : row.path));
|
|
2050
|
+
if (procedures.length === 0) return;
|
|
2051
|
+
if (!isPlainObject(config)) return;
|
|
2052
|
+
const memoryRoot = memRoot(config, process.env);
|
|
2053
|
+
if (typeof memoryRoot !== 'string' || memoryRoot === '') return;
|
|
2054
|
+
const sessionId = resolveCallerSessionId(config).id;
|
|
2055
|
+
appendGateLog(memoryRoot, {
|
|
2056
|
+
sessionId,
|
|
2057
|
+
gate: 'action',
|
|
2058
|
+
decision: 'ok',
|
|
2059
|
+
reason: `recall-tool:${name}`,
|
|
2060
|
+
evidence: [
|
|
2061
|
+
'source=memory_recall_tool',
|
|
2062
|
+
`procedureNames=${procedures.slice(0, 2).join('|')}`,
|
|
2063
|
+
],
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2022
2067
|
/**
|
|
2023
2068
|
* M10 双路由:写类 memory 工具的落盘门委托。
|
|
2024
2069
|
* 新路径 = memory/land.mjs(批次 B,当前 fail-closed 骨架);land 未实现时如实回退到旧路径,
|
|
@@ -2953,7 +2998,7 @@ export const TOOLS = [
|
|
|
2953
2998
|
archive: { type: 'boolean', description: 'archive:true 走冷档 fail-closed 检索(2.0.0 W3b):返回 {ok, archived:true, items, manifestSha, stats};冷档离线/坏 state 抛 E_HG_ARCHIVE_OFFLINE,manifest schema/index 不符抛 E_HG_ARCHIVE_MIGRATE_MISMATCH;未配置冷档则静默空。默认 false(本地卡召回)。' },
|
|
2954
2999
|
},
|
|
2955
3000
|
output: { schema: { type: 'object', additionalProperties: true }, render: (_a, value) => OUTPUT_TEXT(value) },
|
|
2956
|
-
invoke: memoryTool('memory_recall', memoryRecall),
|
|
3001
|
+
invoke: withActionGateReceipt('memory_recall', memoryTool('memory_recall', memoryRecall)),
|
|
2957
3002
|
},
|
|
2958
3003
|
{
|
|
2959
3004
|
name: 'memory_recall_v2',
|