dsh-memory-bond 0.3.0-beta.0 → 1.0.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 +6 -7
- package/README.md +125 -91
- package/README.zh-CN.md +122 -92
- package/SECURITY.md +29 -0
- package/dist/audit.js +155 -80
- package/dist/automatic.js +10 -2
- package/dist/client.js +2035 -0
- package/dist/command-scope.js +4 -4
- package/dist/commands.js +15 -9
- package/dist/consolidation-store.js +87 -20
- package/dist/consolidation.js +2 -6
- package/dist/domain.js +8 -4
- package/dist/encoder.js +46 -5
- package/dist/file-import-store.js +120 -0
- package/dist/file-import.js +265 -0
- package/dist/foreground-attempts.js +91 -0
- package/dist/guidance.js +133 -92
- package/dist/host.js +13 -0
- package/dist/index-policy.js +91 -48
- package/dist/index.js +102 -40
- package/dist/knowledge-hooks.js +70 -27
- package/dist/knowledge.js +2 -3
- package/dist/maintenance-store.js +38 -4
- package/dist/maintenance.js +29 -5
- package/dist/personal.js +37 -0
- package/dist/policy.js +45 -47
- package/dist/prompt-copy.js +93 -0
- package/dist/proposal-receipts.js +70 -0
- package/dist/proposal-review.js +656 -0
- package/dist/propose-contract.js +32 -36
- package/dist/question-answers.js +86 -29
- package/dist/retrieval.js +25 -8
- package/dist/scope-narrowing.js +49 -0
- package/dist/search-index.js +93 -13
- package/dist/semantic.js +69 -207
- package/dist/service.js +633 -204
- package/dist/sharing.js +7 -13
- package/dist/sources.js +28 -3
- package/dist/store.js +432 -96
- package/dist/tool-experience.js +87 -0
- package/dist/turn-review-store.js +83 -16
- package/dist/turn-review.js +155 -59
- package/dist/ui.js +128 -26
- package/dist/vector-index.js +69 -33
- package/docs/architecture.zh-CN.md +52 -0
- package/docs/benchmark.zh-CN.md +60 -0
- package/docs/benchmarks/repository-tasks.json +5355 -0
- package/docs/images/bond-memory-principle-en.svg +644 -0
- package/docs/images/bond-memory-principle-zh.svg +644 -0
- package/docs/images/bond-memory-principle.drawio +644 -0
- package/docs/images/memory-settings-en.png +0 -0
- package/docs/images/memory-settings-zh.png +0 -0
- package/docs/images/memory-turn-recalled-en.png +0 -0
- package/docs/images/memory-turn-recalled-zh.png +0 -0
- package/docs/images/memory-turn-saved-en.png +0 -0
- package/docs/images/memory-turn-saved-zh.png +0 -0
- package/docs/media/memory-bond-name-en.gif +0 -0
- package/docs/media/memory-bond-name-en.mp4 +0 -0
- package/docs/media/memory-bond-name-zh.gif +0 -0
- package/docs/media/memory-bond-name-zh.mp4 +0 -0
- package/locale/detail.en.md +5 -1
- package/locale/detail.zh.md +5 -1
- package/locale/en.json +338 -0
- package/locale/zh.json +338 -0
- package/native/embeddings/NOTICE.md +2 -2
- package/package.json +39 -19
- package/scripts/benchmark-bond.mjs +72 -0
- package/scripts/benchmark-conditions.mjs +144 -0
- package/scripts/benchmark-example.mjs +37 -0
- package/scripts/benchmark-scale.mjs +119 -0
- package/scripts/benchmark-scenarios.mjs +57 -0
- package/scripts/benchmark-tasks.mjs +244 -0
- package/src/audit.ts +144 -85
- package/src/automatic.ts +12 -2
- package/src/command-scope.ts +4 -4
- package/src/commands.ts +12 -8
- package/src/consolidation-store.ts +80 -18
- package/src/consolidation.ts +2 -6
- package/src/domain.ts +9 -4
- package/src/encoder.ts +46 -6
- package/src/file-import-store.ts +139 -0
- package/src/file-import.ts +256 -0
- package/src/foreground-attempts.ts +97 -0
- package/src/guidance.ts +138 -102
- package/src/host.ts +22 -2
- package/src/index-policy.ts +93 -46
- package/src/index.ts +87 -43
- package/src/knowledge-hooks.ts +71 -29
- package/src/knowledge.ts +2 -3
- package/src/maintenance-store.ts +37 -4
- package/src/maintenance.ts +25 -5
- package/src/personal.ts +36 -0
- package/src/policy.ts +55 -52
- package/src/prompt-copy.ts +99 -0
- package/src/proposal-receipts.ts +59 -0
- package/src/proposal-review.ts +614 -0
- package/src/propose-contract.ts +31 -35
- package/src/question-answers.ts +99 -29
- package/src/retrieval.ts +26 -9
- package/src/scope-narrowing.ts +58 -0
- package/src/search-index.ts +94 -14
- package/src/semantic.ts +67 -188
- package/src/service.ts +595 -210
- package/src/sharing.ts +7 -14
- package/src/sources.ts +26 -4
- package/src/store.ts +434 -97
- package/src/tool-experience.ts +93 -0
- package/src/turn-review-store.ts +86 -15
- package/src/turn-review.ts +142 -60
- package/src/ui.ts +122 -27
- package/src/vector-index.ts +57 -29
- package/client/index.js +0 -1186
- package/design/dsh-memory-plugin-design.md +0 -46
- package/design/dsh-memory-plugin-evaluation.md +0 -135
- package/design/evaluations/locomo-conv-26-2026-12-03.json +0 -252
- package/design/evaluations/locomo-conv-26-paired-2026-12-03.json +0 -549
- package/design/evaluations/locomo-conv-26-write-replay-2026-12-03.json +0 -289
- package/design/evaluations/project-memory-tasks-2026-12-03.json +0 -1059
- package/design/memory-lifecycle-consolidation.excalidraw +0 -1212
- package/design/memory-lifecycle-consolidation.mobile.excalidraw +0 -1083
- package/design/memory-lifecycle-consolidation.mobile.svg +0 -2
- package/design/memory-lifecycle-consolidation.mobile.zh-CN.excalidraw +0 -1083
- package/design/memory-lifecycle-consolidation.mobile.zh-CN.svg +0 -94
- package/design/memory-lifecycle-consolidation.svg +0 -2
- package/design/memory-lifecycle-consolidation.zh-CN.excalidraw +0 -1212
- package/design/memory-lifecycle-consolidation.zh-CN.svg +0 -94
- package/design/memory-lifecycle.excalidraw +0 -2105
- package/design/memory-lifecycle.mobile.excalidraw +0 -1896
- package/design/memory-lifecycle.mobile.svg +0 -95
- package/design/memory-lifecycle.mobile.zh-CN.excalidraw +0 -1896
- package/design/memory-lifecycle.mobile.zh-CN.svg +0 -97
- package/design/memory-lifecycle.svg +0 -95
- package/design/memory-lifecycle.zh-CN.excalidraw +0 -2105
- package/design/memory-lifecycle.zh-CN.svg +0 -97
- package/native/embeddings/LICENSE +0 -21
- package/native/embeddings/en/model.onnx +0 -4
- package/native/embeddings/en/vocab.txt +0 -30522
- package/native/embeddings/runtime/LICENSE +0 -21
- package/native/embeddings/runtime/ThirdPartyNotices.txt +0 -6156
- package/native/embeddings/runtime/ort-wasm-simd-threaded.mjs +0 -70
- package/native/embeddings/runtime/ort-wasm-simd-threaded.wasm +0 -0
- package/native/embeddings/runtime/ort.wasm.min.mjs +0 -7
- package/native/embeddings/worker.mjs +0 -97
- package/native/embeddings/zh/model.onnx +0 -0
- package/native/embeddings/zh/vocab.txt +0 -21128
package/dist/sharing.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { containsCredential } from "./automatic.js";
|
|
1
2
|
import { randomUUID } from 'node:crypto';
|
|
2
3
|
import { existsSync, rmSync, lstatSync, mkdirSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
3
|
-
import { dirname, join
|
|
4
|
-
import { digest, projectPath } from "./domain.js";
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { digest, projectPath, projectRelative } from "./domain.js";
|
|
5
6
|
import { StoreError } from "./store.js";
|
|
6
7
|
import { isPersonalSlot } from "./personal.js";
|
|
7
8
|
import { snapshotHash, publishExport, withExportTarget } from "./export-files.js";
|
|
@@ -23,13 +24,6 @@ const leadingMarker = /^(?:[-*+>#]|\d+[.)]|`{3,}|~{3,})/u;
|
|
|
23
24
|
function escapeLeadingMarker(s) {
|
|
24
25
|
return leadingMarker.test(s) ? String.fromCharCode(0x200b) + s : s;
|
|
25
26
|
}
|
|
26
|
-
// Runbook steps never pass through policy.ts's redact()/automatic.ts's secret (knowledge ingestion
|
|
27
|
-
// calls neither), so this is the only guard before a team-shared file. Mirrors their token coverage
|
|
28
|
-
// (plus the host's own dsh-client-ui-secret-mask format list, since this reaches a wider, more
|
|
29
|
-
// persistent audience than that UI masking does) without importing from either module. A bare
|
|
30
|
-
// `\btoken` cannot match inside access_token (the `_` is a word character), so compounds are named
|
|
31
|
-
// explicitly instead of relying on one word boundary.
|
|
32
|
-
const credentialPattern = /-----BEGIN [^\n]*PRIVATE KEY-----|\b(?:sk-[a-zA-Z0-9_-]{12,}|AIza[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9_]{16,}|github_pat_[A-Za-z0-9_]{20,}|glpat-[A-Za-z0-9_-]{16,}|npm_[A-Za-z0-9]{20,}|hf_[A-Za-z0-9]{20,}|xoxb-[A-Za-z0-9-]{10,}|sk_live_[A-Za-z0-9]{10,}|rk_test_[A-Za-z0-9]{10,}|whsec_[A-Za-z0-9]{10,}|(?:AKIA|ASIA)[A-Z0-9]{16}|(?:LTAI|AKID)[A-Za-z0-9]{12,}|eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.)\b|[a-z][a-z0-9+.-]*:\/\/[^\s/:@]+:[^\s/@]+@|(?:密码|口令|密钥|私钥|助记词|验证码|访问令牌|安全码)|\b(?:password|passwd|passphrase|secret|private[ _-]?key|api[_-]?key|access[_-]?token|refresh[_-]?token|token|authorization)\b\s*[:=]\s*\S+/iu;
|
|
33
27
|
// The rule ID travels with the exported SKILL.md, so ownership can be checked in any checkout.
|
|
34
28
|
const ownerMarker = /(?:^|\n)dsh-memory-id:[ \t]*(\S+)/u;
|
|
35
29
|
function skillOwner(text) {
|
|
@@ -116,11 +110,11 @@ function content(domain, rule, format, slug) {
|
|
|
116
110
|
].join('\n');
|
|
117
111
|
}
|
|
118
112
|
// Only the public wording is exported. Neither receipts nor local evidence belong in team files.
|
|
119
|
-
if (
|
|
113
|
+
if (containsCredential(addition) ||
|
|
120
114
|
/(?:\/Users\/|\/home\/[^/\s]+\/|[A-Z]:\\Users\\|file:\/\/|[\u0000-\u0008])/iu.test(addition))
|
|
121
115
|
throw new StoreError('private_content');
|
|
122
116
|
const path = projectPath(domain, target);
|
|
123
|
-
if (
|
|
117
|
+
if (projectRelative(domain.root, path) !== target)
|
|
124
118
|
throw new StoreError('invalid_path');
|
|
125
119
|
let before = null;
|
|
126
120
|
if (existsSync(path)) {
|
|
@@ -205,7 +199,7 @@ export function exportCommand(memory, agent, input) {
|
|
|
205
199
|
if (!target || target !== offer.target)
|
|
206
200
|
throw new StoreError('invalid_preview');
|
|
207
201
|
const path = projectPath(d, target);
|
|
208
|
-
if (
|
|
202
|
+
if (projectRelative(d.root, path) !== target)
|
|
209
203
|
throw new StoreError('invalid_path');
|
|
210
204
|
const check = () => {
|
|
211
205
|
const actual = memory.rootDomain(agent, true);
|
|
@@ -255,7 +249,7 @@ export function exportCommand(memory, agent, input) {
|
|
|
255
249
|
throw new StoreError('invalid_export', '用法:export agents ID@版本 或 export skill ID@版本 skill-name');
|
|
256
250
|
const target = format === 'agents' ? 'AGENTS.md' : '.dsh/skills/' + slug + '/SKILL.md';
|
|
257
251
|
const path = projectPath(d, target);
|
|
258
|
-
if (
|
|
252
|
+
if (projectRelative(d.root, path) !== target)
|
|
259
253
|
throw new StoreError('invalid_path');
|
|
260
254
|
const plan = withExportTarget(path, () => {
|
|
261
255
|
const rule = memory.current(d, hit[1], Number(hit[2]));
|
package/dist/sources.js
CHANGED
|
@@ -4,7 +4,7 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { refusesAutomaticMemory, skipsAutomaticMemory } from "./automatic.js";
|
|
6
6
|
import { digest, projectPath } from "./domain.js";
|
|
7
|
-
import {
|
|
7
|
+
import { questionForm, standingRequest } from "./question-answers.js";
|
|
8
8
|
const BINDING = 'plugin:project-memory/source';
|
|
9
9
|
// At most one warning per process: sourceStore() runs on every captured message and every
|
|
10
10
|
// propose()/manual()/read() call, far too often to log on each occurrence.
|
|
@@ -43,6 +43,15 @@ export function bindSource(session, seq, domain, storeId, generation, append, wa
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
export function boundSourceDomain(session, storeId, turnId, seq) {
|
|
47
|
+
const domains = new Set();
|
|
48
|
+
for (const { type, data } of session.snapshotEvents().slice(session.inheritedEventCount)) {
|
|
49
|
+
if (type === BINDING && data.sourceSeq === seq && data.storeId === storeId && data.turnId === turnId && data.domainId)
|
|
50
|
+
domains.add(data.domainId);
|
|
51
|
+
}
|
|
52
|
+
if (domains.size === 1)
|
|
53
|
+
return { id: [...domains][0] };
|
|
54
|
+
}
|
|
46
55
|
export function sources(session, domain, storeId, turnId) {
|
|
47
56
|
const events = session.snapshotEvents().slice(session.inheritedEventCount);
|
|
48
57
|
const bindings = new Map();
|
|
@@ -55,11 +64,26 @@ export function sources(session, domain, storeId, turnId) {
|
|
|
55
64
|
? null : generation);
|
|
56
65
|
}
|
|
57
66
|
}
|
|
67
|
+
const forms = new Map(events.filter(e => bindings.has(e.seq) && e.type === 'tool/result' && String(e.data.turn) === turnId)
|
|
68
|
+
.map(e => [e.seq, questionForm(session, e)]));
|
|
69
|
+
const choices = new Map();
|
|
70
|
+
for (const [seq, form] of forms) {
|
|
71
|
+
for (const choice of form?.selected ?? []) {
|
|
72
|
+
if (bindings.get(seq) == null || bindings.get(seq) !== bindings.get(choice.userSeq))
|
|
73
|
+
continue;
|
|
74
|
+
const selected = choices.get(choice.userSeq) ?? [];
|
|
75
|
+
selected.push(choice);
|
|
76
|
+
choices.set(choice.userSeq, selected);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
58
79
|
return events.filter((e) => bindings.has(e.seq)).flatMap((e) => {
|
|
59
80
|
const identity = { domainId: domain.id, storeId, sessionId: session.id, seq: e.seq,
|
|
60
81
|
memoryGeneration: bindings.get(e.seq) };
|
|
61
82
|
if (e.type === 'tool/result' && String(e.data.turn) === turnId) {
|
|
62
|
-
const
|
|
83
|
+
const form = forms.get(e.seq);
|
|
84
|
+
if (form?.refusedBy !== undefined && bindings.has(form.refusedBy))
|
|
85
|
+
return [{ ...identity, refused: true, text: '' }];
|
|
86
|
+
const answers = (form?.custom ?? []).filter(answer => bindings.has(answer.userSeq));
|
|
63
87
|
if (answers.some(answer => refusesAutomaticMemory(answer.text)))
|
|
64
88
|
return [{ ...identity, refused: true, text: '' }];
|
|
65
89
|
return answers.filter(answer => !skipsAutomaticMemory(answer.text))
|
|
@@ -75,7 +99,8 @@ export function sources(session, domain, storeId, turnId) {
|
|
|
75
99
|
// Offsets use DSH's text-only message projection. Matching is per contiguous block,
|
|
76
100
|
// so text on opposite sides of an image or another content block cannot become a quote.
|
|
77
101
|
const text = part.text ?? '';
|
|
78
|
-
const
|
|
102
|
+
const formSelections = standingRequest(text) && choices.get(e.seq);
|
|
103
|
+
const source = { ...identity, text, block, offset, ...(formSelections && { formSelections }) };
|
|
79
104
|
offset += text.length + 1;
|
|
80
105
|
return [source];
|
|
81
106
|
});
|