agent-memory-hub 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +41 -2
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +256 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/approval.d.ts +23 -0
- package/dist/core/approval.js +18 -0
- package/dist/core/approval.js.map +1 -0
- package/dist/core/atomic.d.ts +6 -0
- package/dist/core/atomic.js +37 -0
- package/dist/core/atomic.js.map +1 -0
- package/dist/core/errors.d.ts +17 -0
- package/dist/core/errors.js +22 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/frontmatter.d.ts +20 -0
- package/dist/core/frontmatter.js +248 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/hub.d.ts +25 -0
- package/dist/core/hub.js +119 -0
- package/dist/core/hub.js.map +1 -0
- package/dist/core/ids.d.ts +13 -0
- package/dist/core/ids.js +45 -0
- package/dist/core/ids.js.map +1 -0
- package/dist/core/inject.d.ts +44 -0
- package/dist/core/inject.js +60 -0
- package/dist/core/inject.js.map +1 -0
- package/dist/core/journal.d.ts +25 -0
- package/dist/core/journal.js +73 -0
- package/dist/core/journal.js.map +1 -0
- package/dist/core/ledger.d.ts +32 -0
- package/dist/core/ledger.js +35 -0
- package/dist/core/ledger.js.map +1 -0
- package/dist/core/lock.d.ts +50 -0
- package/dist/core/lock.js +104 -0
- package/dist/core/lock.js.map +1 -0
- package/dist/core/registry.d.ts +44 -0
- package/dist/core/registry.js +85 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/search.d.ts +59 -0
- package/dist/core/search.js +189 -0
- package/dist/core/search.js.map +1 -0
- package/dist/core/store.d.ts +84 -0
- package/dist/core/store.js +255 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/time.d.ts +5 -0
- package/dist/core/time.js +21 -0
- package/dist/core/time.js.map +1 -0
- package/dist/core/transcript.d.ts +42 -0
- package/dist/core/transcript.js +77 -0
- package/dist/core/transcript.js.map +1 -0
- package/dist/core/types.d.ts +47 -0
- package/dist/core/types.js +10 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/transport/http.d.ts +11 -0
- package/dist/transport/http.js +45 -0
- package/dist/transport/http.js.map +1 -0
- package/dist/transport/mcp.d.ts +27 -0
- package/dist/transport/mcp.js +469 -0
- package/dist/transport/mcp.js.map +1 -0
- package/dist/transport/panel.d.ts +6 -0
- package/dist/transport/panel.js +86 -0
- package/dist/transport/panel.js.map +1 -0
- package/dist/transport/server.d.ts +21 -0
- package/dist/transport/server.js +211 -0
- package/dist/transport/server.js.map +1 -0
- package/package.json +60 -4
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { appendFileSync, readFileSync, unlinkSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { ErrorCode, HubError } from '../core/errors.js';
|
|
4
|
+
import { isHubInitialized, readHubConfig } from '../core/hub.js';
|
|
5
|
+
import { appendLedger, ledgerPath, readSequences, writeSequences, } from '../core/ledger.js';
|
|
6
|
+
import { acquireLock, assertFencing, heartbeatLock, lockInfo, releaseLock, } from '../core/lock.js';
|
|
7
|
+
import { registerWorkspace, resolveWorkspace } from '../core/registry.js';
|
|
8
|
+
import { buildIndex, emptyMetrics, searchWithMetrics, } from '../core/search.js';
|
|
9
|
+
import { commitKnowledge, createProposal, findTitleConflict, getEntry, listProposals, } from '../core/store.js';
|
|
10
|
+
import { requireApproval } from '../core/approval.js';
|
|
11
|
+
import { preflight } from '../core/inject.js';
|
|
12
|
+
import { appendJournal, readJournal } from '../core/journal.js';
|
|
13
|
+
import { detectDejaVu, indexTranscript, readTranscriptIndex } from '../core/transcript.js';
|
|
14
|
+
/**
|
|
15
|
+
* MCP stdio transport — zero-dependency JSON-RPC 2.0. The protocol surface is
|
|
16
|
+
* small (initialize / tools/list / tools/call), so we implement it directly
|
|
17
|
+
* (dependency policy) with the same tool contract as the CLI (one behavior,
|
|
18
|
+
* one implementation — tests are shared).
|
|
19
|
+
*/
|
|
20
|
+
const SUPPORTED_PROTOCOL_VERSIONS = ['2024-11-05', '2025-03-26', '2025-06-18'];
|
|
21
|
+
const SERVER_INFO = { name: 'memhub', version: '0.1.0' };
|
|
22
|
+
export function createState(hubRoot, workspaceArg) {
|
|
23
|
+
if (!isHubInitialized(hubRoot)) {
|
|
24
|
+
throw new HubError(ErrorCode.E_HUB_NOT_INITIALIZED, `hub not initialized at ${hubRoot} — run \`memhub init --root ${hubRoot}\``, { hubRoot });
|
|
25
|
+
}
|
|
26
|
+
const workspace = resolveWorkspace(process.cwd(), workspaceArg);
|
|
27
|
+
const index = buildIndex(hubRoot, () => new Date().toISOString());
|
|
28
|
+
return { hubRoot, workspace, index, metrics: emptyMetrics(index) };
|
|
29
|
+
}
|
|
30
|
+
export const TOOLS = {
|
|
31
|
+
memory_search: {
|
|
32
|
+
description: 'Search accepted knowledge by keywords or a natural-language intent. Scope-filtered: the workspace sees itself + global. Ranked results; default detail (L1) returns summaries — pass detail=L2 only when the full body is needed.',
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
query: { type: 'string' },
|
|
37
|
+
detail: { type: 'string', enum: ['L0', 'L1', 'L2'] },
|
|
38
|
+
limit: { type: 'number' },
|
|
39
|
+
minScore: { type: 'number' },
|
|
40
|
+
types: { type: 'array', items: { type: 'string' } },
|
|
41
|
+
},
|
|
42
|
+
required: ['query'],
|
|
43
|
+
},
|
|
44
|
+
handler: (state, args) => {
|
|
45
|
+
const hits = searchWithMetrics(state.index, state.metrics, String(args['query']), {
|
|
46
|
+
workspaceId: state.workspace.workspaceId,
|
|
47
|
+
detail: args['detail'] ?? 'L1',
|
|
48
|
+
limit: typeof args['limit'] === 'number' ? args['limit'] : undefined,
|
|
49
|
+
minScore: typeof args['minScore'] === 'number' ? args['minScore'] : 0,
|
|
50
|
+
types: args['types'],
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
hits,
|
|
54
|
+
workspace: workspaceStatus(state.workspace),
|
|
55
|
+
metrics: metricsSnapshot(state.metrics),
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
memory_get: {
|
|
60
|
+
description: 'Read one knowledge entry by ID. Returns metadata + summary by default; pass full=true (or section=<heading>) only when the whole body is needed.',
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
id: { type: 'string' },
|
|
65
|
+
full: { type: 'boolean' },
|
|
66
|
+
section: { type: 'string' },
|
|
67
|
+
},
|
|
68
|
+
required: ['id'],
|
|
69
|
+
},
|
|
70
|
+
handler: (state, args) => {
|
|
71
|
+
const entry = getEntry(state.hubRoot, String(args['id']));
|
|
72
|
+
const full = args['full'] === true;
|
|
73
|
+
const section = typeof args['section'] === 'string' ? args['section'] : undefined;
|
|
74
|
+
let body;
|
|
75
|
+
if (section !== undefined) {
|
|
76
|
+
const marker = `# ${section}`;
|
|
77
|
+
const start = entry.body.indexOf(marker);
|
|
78
|
+
body = start === -1 ? undefined : entry.body.slice(start, entry.body.indexOf('\n# ', start + 1));
|
|
79
|
+
}
|
|
80
|
+
else if (full) {
|
|
81
|
+
body = entry.body;
|
|
82
|
+
}
|
|
83
|
+
return { frontmatter: entry.frontmatter, body, path: entry.path };
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
memory_status: {
|
|
87
|
+
description: 'Read-only self check: hub root, workspace identity (exact flag is honest — false means synthetic fallback), writer lock holder, metrics, pending count.',
|
|
88
|
+
inputSchema: { type: 'object', properties: {} },
|
|
89
|
+
handler: (state) => ({
|
|
90
|
+
hubRoot: state.hubRoot,
|
|
91
|
+
initialized: true,
|
|
92
|
+
workspace: workspaceStatus(state.workspace),
|
|
93
|
+
lock: lockInfo(state.hubRoot),
|
|
94
|
+
metrics: metricsSnapshot(state.metrics),
|
|
95
|
+
proposals: listProposals(state.hubRoot).length,
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
memory_propose: {
|
|
99
|
+
description: 'Create a pending candidate (pending/PRO-*.md). This NEVER writes knowledge/ directly — a human must approve via the panel or `memhub inbox`. Always include sourceRefs evidence.',
|
|
100
|
+
inputSchema: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
type: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
enum: ['decision', 'constraint', 'knowledge', 'api-catalog', 'process', 'open-questions', 'runtime-base', 'playbooks', 'assets'],
|
|
106
|
+
},
|
|
107
|
+
title: { type: 'string' },
|
|
108
|
+
summary: { type: 'string' },
|
|
109
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
110
|
+
body: { type: 'string' },
|
|
111
|
+
sourceRefs: { type: 'array', items: { type: 'string' } },
|
|
112
|
+
},
|
|
113
|
+
required: ['type', 'title', 'summary', 'body'],
|
|
114
|
+
},
|
|
115
|
+
handler: (state, args) => withWriteLock(state, () => {
|
|
116
|
+
const proposal = createProposal(state.hubRoot, {
|
|
117
|
+
type: args['type'],
|
|
118
|
+
title: String(args['title']),
|
|
119
|
+
summary: String(args['summary']),
|
|
120
|
+
scope: scopeFor(state.workspace),
|
|
121
|
+
tags: args['tags'],
|
|
122
|
+
body: String(args['body']),
|
|
123
|
+
sourceRefs: args['sourceRefs'] ?? [],
|
|
124
|
+
actor: 'model',
|
|
125
|
+
}, {
|
|
126
|
+
readSequences,
|
|
127
|
+
writeSequences,
|
|
128
|
+
appendLedger: (root, record) => appendLedger(ledgerPath(root), record),
|
|
129
|
+
});
|
|
130
|
+
registerWorkspaceIfNew(state);
|
|
131
|
+
return {
|
|
132
|
+
proposalId: proposal.id,
|
|
133
|
+
path: proposal.path,
|
|
134
|
+
nextStep: 'human approval via panel or `memhub inbox approve`',
|
|
135
|
+
};
|
|
136
|
+
}),
|
|
137
|
+
},
|
|
138
|
+
memory_commit: {
|
|
139
|
+
description: 'Move an approved candidate into knowledge/. Only a human-carried channel can pass: over MCP this tool ALWAYS fails closed with E_APPROVAL_REQUIRED — use the panel or `memhub inbox approve <ID>`.',
|
|
140
|
+
inputSchema: {
|
|
141
|
+
type: 'object',
|
|
142
|
+
properties: {
|
|
143
|
+
proposalId: { type: 'string' },
|
|
144
|
+
channel: { type: 'string' },
|
|
145
|
+
},
|
|
146
|
+
required: ['proposalId'],
|
|
147
|
+
},
|
|
148
|
+
handler: (state, args) => withWriteLock(state, () => {
|
|
149
|
+
const proposalId = String(args['proposalId']);
|
|
150
|
+
requireApproval(args['channel'] ?? 'mcp-model', {
|
|
151
|
+
id: proposalId,
|
|
152
|
+
ledgerAppend: (record) => appendLedger(ledgerPath(state.hubRoot), record),
|
|
153
|
+
});
|
|
154
|
+
return commitFromProposal(state, proposalId);
|
|
155
|
+
}),
|
|
156
|
+
},
|
|
157
|
+
memory_cite: {
|
|
158
|
+
description: 'Record that a knowledge entry influenced the current task (audit + aging signal). Cite after actually using an entry — search hits are not citations.',
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: 'object',
|
|
161
|
+
properties: {
|
|
162
|
+
id: { type: 'string' },
|
|
163
|
+
purpose: { type: 'string' },
|
|
164
|
+
},
|
|
165
|
+
required: ['id', 'purpose'],
|
|
166
|
+
},
|
|
167
|
+
handler: (state, args) => {
|
|
168
|
+
const id = String(args['id']);
|
|
169
|
+
getEntry(state.hubRoot, id); // must exist
|
|
170
|
+
appendLedger(ledgerPath(state.hubRoot), {
|
|
171
|
+
type: 'citation.added',
|
|
172
|
+
id,
|
|
173
|
+
purpose: String(args['purpose']),
|
|
174
|
+
at: new Date().toISOString(),
|
|
175
|
+
});
|
|
176
|
+
return { cited: id };
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
memory_close_task: {
|
|
180
|
+
description: 'Close the current task with a writeback assessment (proposed / no_new_knowledge / needs_evidence / deferred). Bookkeeping only.',
|
|
181
|
+
inputSchema: {
|
|
182
|
+
type: 'object',
|
|
183
|
+
properties: {
|
|
184
|
+
assessment: { type: 'string', enum: ['proposed', 'no_new_knowledge', 'needs_evidence', 'deferred'] },
|
|
185
|
+
note: { type: 'string' },
|
|
186
|
+
},
|
|
187
|
+
required: ['assessment'],
|
|
188
|
+
},
|
|
189
|
+
handler: (state, args) => {
|
|
190
|
+
appendLedger(ledgerPath(state.hubRoot), {
|
|
191
|
+
type: 'task.closed',
|
|
192
|
+
assessment: args['assessment'],
|
|
193
|
+
note: typeof args['note'] === 'string' ? args['note'] : undefined,
|
|
194
|
+
at: new Date().toISOString(),
|
|
195
|
+
});
|
|
196
|
+
return { closed: true };
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
memory_duplicates: {
|
|
200
|
+
description: 'Read-only near-duplicate check for a candidate title. Never writes files.',
|
|
201
|
+
inputSchema: {
|
|
202
|
+
type: 'object',
|
|
203
|
+
properties: { title: { type: 'string' } },
|
|
204
|
+
required: ['title'],
|
|
205
|
+
},
|
|
206
|
+
handler: (state, args) => {
|
|
207
|
+
const conflict = findTitleConflict(state.hubRoot, String(args['title']));
|
|
208
|
+
return {
|
|
209
|
+
conflict: conflict === null ? null : { id: conflict.frontmatter.id, title: conflict.frontmatter.title },
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
memory_preflight: {
|
|
214
|
+
description: 'Build the L0 static pack for this turn: top-3 hits (replay-calibrated), one line each, with a documented token estimate. Records a preflight.recorded event. Inject the pack only when status=ready.',
|
|
215
|
+
inputSchema: {
|
|
216
|
+
type: 'object',
|
|
217
|
+
properties: {
|
|
218
|
+
intent: { type: 'string' },
|
|
219
|
+
limit: { type: 'number' },
|
|
220
|
+
types: { type: 'array', items: { type: 'string' } },
|
|
221
|
+
},
|
|
222
|
+
required: ['intent'],
|
|
223
|
+
},
|
|
224
|
+
handler: (state, args) => {
|
|
225
|
+
const result = preflight(state.index, state.hubRoot, state.workspace.workspaceId, String(args['intent']), {
|
|
226
|
+
limit: typeof args['limit'] === 'number' ? args['limit'] : undefined,
|
|
227
|
+
types: args['types'],
|
|
228
|
+
});
|
|
229
|
+
state.metrics.queryCount += 1;
|
|
230
|
+
return result;
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
memory_journal: {
|
|
234
|
+
description: 'Episodic layer: append (action=append; auto-capture is fine here — journal is disposable and never becomes knowledge) or read (action=read; optional day=YYYY-MM-DD local stamp).',
|
|
235
|
+
inputSchema: {
|
|
236
|
+
type: 'object',
|
|
237
|
+
properties: {
|
|
238
|
+
action: { type: 'string', enum: ['append', 'read'] },
|
|
239
|
+
text: { type: 'string' },
|
|
240
|
+
sessionId: { type: 'string' },
|
|
241
|
+
day: { type: 'string' },
|
|
242
|
+
},
|
|
243
|
+
required: ['action'],
|
|
244
|
+
},
|
|
245
|
+
handler: (state, args) => {
|
|
246
|
+
const action = String(args['action']);
|
|
247
|
+
if (action === 'append') {
|
|
248
|
+
const text = String(args['text'] ?? '');
|
|
249
|
+
if (text === '')
|
|
250
|
+
throw new HubError(ErrorCode.E_VALIDATION, 'journal append requires text');
|
|
251
|
+
return withWriteLock(state, () => appendJournal(state.hubRoot, { sessionId: args['sessionId'], text }));
|
|
252
|
+
}
|
|
253
|
+
return { entries: readJournal(state.hubRoot, args['day']) };
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
memory_dejavu: {
|
|
257
|
+
description: 'Day-zero deja-vu check: was a similar conversation already had? Index a session transcript (action=index; tokens + preview only — the body stays with the host) or query overlaps (action=check).',
|
|
258
|
+
inputSchema: {
|
|
259
|
+
type: 'object',
|
|
260
|
+
properties: {
|
|
261
|
+
action: { type: 'string', enum: ['index', 'check'] },
|
|
262
|
+
sessionId: { type: 'string' },
|
|
263
|
+
text: { type: 'string' },
|
|
264
|
+
location: { type: 'string' },
|
|
265
|
+
query: { type: 'string' },
|
|
266
|
+
threshold: { type: 'number' },
|
|
267
|
+
},
|
|
268
|
+
required: ['action'],
|
|
269
|
+
},
|
|
270
|
+
handler: (state, args) => {
|
|
271
|
+
const action = String(args['action']);
|
|
272
|
+
if (action === 'index') {
|
|
273
|
+
const sessionId = args['sessionId'];
|
|
274
|
+
const text = String(args['text'] ?? '');
|
|
275
|
+
const location = String(args['location'] ?? '');
|
|
276
|
+
if (sessionId === undefined || text === '' || location === '') {
|
|
277
|
+
throw new HubError(ErrorCode.E_VALIDATION, 'dejavu index requires sessionId, text and location');
|
|
278
|
+
}
|
|
279
|
+
return withWriteLock(state, () => indexTranscript(state.hubRoot, { sessionId, text, location }));
|
|
280
|
+
}
|
|
281
|
+
const query = String(args['query'] ?? '');
|
|
282
|
+
if (query === '')
|
|
283
|
+
throw new HubError(ErrorCode.E_VALIDATION, 'dejavu check requires query');
|
|
284
|
+
return {
|
|
285
|
+
sessions: readTranscriptIndex(state.hubRoot).length,
|
|
286
|
+
dejaVu: detectDejaVu(state.hubRoot, query, typeof args['threshold'] === 'number' ? args['threshold'] : undefined),
|
|
287
|
+
};
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
// ---------------------------------------------------------------------------
|
|
292
|
+
// Write-lock + helpers
|
|
293
|
+
// ---------------------------------------------------------------------------
|
|
294
|
+
function withWriteLock(state, fn) {
|
|
295
|
+
const acquired = acquireLock(state.hubRoot);
|
|
296
|
+
if (!acquired.ok) {
|
|
297
|
+
throw new HubError(ErrorCode.E_READONLY, 'another writer holds the lease (read-only for this process)', {
|
|
298
|
+
holder: acquired.holder,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
// acquired.ok guarantees a lock with a token; '' would fail fencing loudly anyway.
|
|
302
|
+
const token = acquired.lock?.token ?? '';
|
|
303
|
+
state.lockToken = token;
|
|
304
|
+
try {
|
|
305
|
+
assertFencing(state.hubRoot, token);
|
|
306
|
+
return fn();
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
releaseLock(state.hubRoot, token);
|
|
310
|
+
state.lockToken = undefined;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function scopeFor(workspace) {
|
|
314
|
+
return { level: 'project', workspaceId: workspace.workspaceId };
|
|
315
|
+
}
|
|
316
|
+
function workspaceStatus(workspace) {
|
|
317
|
+
return {
|
|
318
|
+
workspaceId: workspace.workspaceId,
|
|
319
|
+
name: workspace.name,
|
|
320
|
+
path: workspace.path,
|
|
321
|
+
exact: workspace.exact,
|
|
322
|
+
origin: workspace.origin,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
function metricsSnapshot(metrics) {
|
|
326
|
+
const { indexedCount, queryCount, totalHits, lastHitCount, lastQuery, builtAt } = metrics;
|
|
327
|
+
return {
|
|
328
|
+
indexedCount,
|
|
329
|
+
queryCount,
|
|
330
|
+
avgHits: queryCount === 0 ? 0 : Math.round((totalHits / queryCount) * 100) / 100,
|
|
331
|
+
lastHitCount,
|
|
332
|
+
lastQuery,
|
|
333
|
+
builtAt,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function registerWorkspaceIfNew(state) {
|
|
337
|
+
registerWorkspace(state.hubRoot, state.workspace, () => new Date().toISOString(), readHubConfig, (root, content) => {
|
|
338
|
+
appendFileSync(join(root, 'hub.yaml'), content, 'utf8');
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
function commitFromProposal(state, proposalId) {
|
|
342
|
+
const proposal = listProposals(state.hubRoot).find((p) => p.id === proposalId);
|
|
343
|
+
if (proposal === undefined) {
|
|
344
|
+
throw new HubError(ErrorCode.E_NOT_FOUND, `pending proposal not found: ${proposalId}`, { proposalId });
|
|
345
|
+
}
|
|
346
|
+
const committed = commitKnowledge(state.hubRoot, {
|
|
347
|
+
type: proposal.frontmatter.type,
|
|
348
|
+
title: proposal.frontmatter.title,
|
|
349
|
+
summary: proposal.frontmatter.summary,
|
|
350
|
+
scope: proposal.frontmatter.scope,
|
|
351
|
+
tags: proposal.frontmatter.tags,
|
|
352
|
+
body: readFileSync(proposal.path, 'utf8').split('---')[2]?.trim() ?? '',
|
|
353
|
+
actor: 'panel',
|
|
354
|
+
}, {
|
|
355
|
+
readSequences,
|
|
356
|
+
writeSequences,
|
|
357
|
+
appendLedger: (root, record) => appendLedger(ledgerPath(root), record),
|
|
358
|
+
});
|
|
359
|
+
unlinkSync(proposal.path);
|
|
360
|
+
appendLedger(ledgerPath(state.hubRoot), {
|
|
361
|
+
type: 'proposal.committed',
|
|
362
|
+
proposalId,
|
|
363
|
+
knowledgeId: committed.id,
|
|
364
|
+
channel: 'panel',
|
|
365
|
+
at: new Date().toISOString(),
|
|
366
|
+
});
|
|
367
|
+
state.index = buildIndex(state.hubRoot, () => new Date().toISOString());
|
|
368
|
+
state.metrics = emptyMetrics(state.index);
|
|
369
|
+
return { knowledgeId: committed.id, version: committed.version, path: committed.path };
|
|
370
|
+
}
|
|
371
|
+
export function heartbeat(state) {
|
|
372
|
+
return state.lockToken !== undefined && heartbeatLock(state.hubRoot, state.lockToken);
|
|
373
|
+
}
|
|
374
|
+
export function handleRpc(state, line) {
|
|
375
|
+
let request;
|
|
376
|
+
try {
|
|
377
|
+
request = JSON.parse(line);
|
|
378
|
+
}
|
|
379
|
+
catch {
|
|
380
|
+
return rpcError(null, -32700, 'Parse error');
|
|
381
|
+
}
|
|
382
|
+
const { id = null, method } = request;
|
|
383
|
+
if (method === undefined)
|
|
384
|
+
return rpcError(id, -32600, 'Invalid Request');
|
|
385
|
+
try {
|
|
386
|
+
switch (method) {
|
|
387
|
+
case 'initialize': {
|
|
388
|
+
const requested = String(request.params?.['protocolVersion'] ?? '');
|
|
389
|
+
const version = SUPPORTED_PROTOCOL_VERSIONS.includes(requested)
|
|
390
|
+
? requested
|
|
391
|
+
: SUPPORTED_PROTOCOL_VERSIONS[SUPPORTED_PROTOCOL_VERSIONS.length - 1];
|
|
392
|
+
return rpcResult(id, { protocolVersion: version, capabilities: { tools: {} }, serverInfo: SERVER_INFO });
|
|
393
|
+
}
|
|
394
|
+
case 'notifications/initialized':
|
|
395
|
+
return null; // notification: no response
|
|
396
|
+
case 'tools/list':
|
|
397
|
+
return rpcResult(id, {
|
|
398
|
+
tools: Object.entries(TOOLS).map(([name, def]) => ({
|
|
399
|
+
name,
|
|
400
|
+
description: def.description,
|
|
401
|
+
inputSchema: def.inputSchema,
|
|
402
|
+
})),
|
|
403
|
+
});
|
|
404
|
+
case 'tools/call': {
|
|
405
|
+
const name = String(request.params?.['name'] ?? '');
|
|
406
|
+
const tool = TOOLS[name];
|
|
407
|
+
if (tool === undefined)
|
|
408
|
+
return rpcError(id, -32602, `Unknown tool: ${name}`);
|
|
409
|
+
const args = request.params?.['arguments'] ?? {};
|
|
410
|
+
try {
|
|
411
|
+
const result = tool.handler(state, args);
|
|
412
|
+
return rpcResult(id, { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] });
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
const detail = error instanceof HubError ? { code: error.code, details: error.details } : undefined;
|
|
416
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
417
|
+
return rpcResult(id, {
|
|
418
|
+
content: [{ type: 'text', text: message }],
|
|
419
|
+
isError: true,
|
|
420
|
+
error: detail,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
case 'ping':
|
|
425
|
+
return rpcResult(id, {});
|
|
426
|
+
default:
|
|
427
|
+
return rpcError(id, -32601, `Method not found: ${method}`);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
432
|
+
return rpcError(id, -32603, message);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function rpcResult(id, result) {
|
|
436
|
+
return JSON.stringify({ jsonrpc: '2.0', id, result });
|
|
437
|
+
}
|
|
438
|
+
function rpcError(id, code, message) {
|
|
439
|
+
return JSON.stringify({ jsonrpc: '2.0', id, error: { code, message } });
|
|
440
|
+
}
|
|
441
|
+
/** Blocking stdio loop (server mode). Exits cleanly on EOF. */
|
|
442
|
+
export function serveStdio(state) {
|
|
443
|
+
process.stdin.setEncoding('utf8');
|
|
444
|
+
let data = '';
|
|
445
|
+
const lines = [];
|
|
446
|
+
process.stdin.on('data', (chunk) => {
|
|
447
|
+
data += chunk;
|
|
448
|
+
let newline = data.indexOf('\n');
|
|
449
|
+
while (newline !== -1) {
|
|
450
|
+
const line = data.slice(0, newline).trim();
|
|
451
|
+
data = data.slice(newline + 1);
|
|
452
|
+
if (line !== '')
|
|
453
|
+
lines.push(line);
|
|
454
|
+
newline = data.indexOf('\n');
|
|
455
|
+
}
|
|
456
|
+
while (lines.length > 0) {
|
|
457
|
+
const line = lines.shift();
|
|
458
|
+
if (line === undefined)
|
|
459
|
+
break;
|
|
460
|
+
const response = handleRpc(state, line);
|
|
461
|
+
if (response !== null)
|
|
462
|
+
process.stdout.write(`${response}\n`);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
process.stdin.on('end', () => {
|
|
466
|
+
process.exit(0);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/transport/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,QAAQ,EACR,WAAW,GACZ,MAAM,iBAAiB,CAAA;AACxB,OAA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,GAAa,EAAE,CAAA;IAC1B,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;QACzC,IAAI,IAAI,KAAK,CAAA;QACb,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAChC,OAAO,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;YAC1C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAA;YAC9B,IAAI,IAAI,KAAK,EAAE;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAA;YAC1B,IAAI,IAAI,KAAK,SAAS;gBAAE,MAAK;YAC7B,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YACvC,IAAI,QAAQ,KAAK,IAAI;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,IAAI,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;QAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency single-file panel (no build step). Graded approval inbox:
|
|
3
|
+
* decision/constraint/api-catalog require one-by-one approval; other types
|
|
4
|
+
* show a batch button. Human clicking approve = panel channel.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PANEL_HTML = "<!doctype html>\n<html lang=\"zh\">\n<head>\n<meta charset=\"utf-8\">\n<title>memhub panel</title>\n<style>\n :root { color-scheme: dark; }\n body { font-family: ui-sans-serif, system-ui; margin: 0; background: #0f1115; color: #e6e6e6; }\n header { padding: 14px 20px; border-bottom: 1px solid #262b36; display: flex; gap: 16px; align-items: baseline; }\n header h1 { font-size: 16px; margin: 0; }\n header span { color: #8b93a7; font-size: 12px; }\n main { max-width: 860px; margin: 0 auto; padding: 16px; }\n .card { border: 1px solid #262b36; border-radius: 10px; padding: 14px 16px; margin: 10px 0; background: #161a22; }\n .card h3 { margin: 0 0 6px; font-size: 14px; }\n .meta { color: #8b93a7; font-size: 12px; margin-bottom: 8px; }\n .grade { border-radius: 6px; padding: 1px 8px; font-size: 11px; }\n .grade.individual { background: #3a2a2a; color: #ff9e9e; }\n .grade.batch { background: #233a2c; color: #8ee39b; }\n button { border: 1px solid #2f3542; background: #1d2330; color: #e6e6e6; border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 13px; }\n button:hover { background: #262d3d; }\n button.primary { background: #245639; border-color: #2f7a4d; }\n button.danger { background: #5a2a2a; border-color: #7a3a3a; }\n .row { display: flex; gap: 8px; margin-top: 8px; }\n #status { font-size: 12px; color: #8b93a7; }\n pre { white-space: pre-wrap; font-size: 12px; color: #a9b1c2; }\n .empty { color: #8b93a7; padding: 30px 0; text-align: center; }\n #batchbar { display: none; margin: 10px 0; }\n</style>\n</head>\n<body>\n<header><h1>memhub panel</h1><span id=\"status\">loading\u2026</span></header>\n<main>\n <div id=\"batchbar\"><button class=\"primary\" onclick=\"approveBatch()\">\u6279\u51C6\u6240\u9009\u4F4E\u98CE\u9669\u6761\u76EE\uFF08\u6279\u91CF\uFF09</button></div>\n <div id=\"inbox\"><div class=\"empty\">\u52A0\u8F7D\u4E2D\u2026</div></div>\n <details><summary>\u53EA\u8BFB\u68C0\u7D22</summary>\n <div class=\"row\"><input id=\"q\" placeholder=\"\u67E5\u8BE2\u8BCD\u2026\" style=\"flex:1\"><button onclick=\"doSearch()\">\u641C\u7D22</button></div>\n <pre id=\"results\"></pre>\n </details>\n</main>\n<script>\nlet inbox = [];\nasync function j(url, opts) { const r = await fetch(url, opts); return { ok: r.ok, status: r.status, data: await r.json().catch(() => ({})) }; }\nasync function refresh() {\n const s = await j('/api/status'); const i = await j('/api/inbox');\n document.getElementById('status').textContent =\n (s.data.workspace ? s.data.workspace.workspaceId + (s.data.workspace.exact ? '' : ' (synthetic)') : '?') +\n ' \u00B7 accepted ' + (s.data.acceptedCount ?? 0) + ' \u00B7 pending ' + (i.data.proposals ?? []).length;\n inbox = i.data.proposals ?? [];\n const el = document.getElementById('inbox');\n if (inbox.length === 0) { el.innerHTML = '<div class=\"empty\">\u2713 inbox \u6E05\u7A7A\uFF0C\u65E0\u5F85\u5BA1\u6761\u76EE</div>'; }\n else {\n el.innerHTML = inbox.map(p => `\n <div class=\"card\" id=\"card-${p.id}\">\n <h3>${p.title} <span class=\"grade ${p.grade}\">${p.grade === 'individual' ? '\u9010\u6761\u5BA1\u6279' : '\u53EF\u6279\u91CF'}</span></h3>\n <div class=\"meta\">${p.id} \u00B7 ${p.type} \u00B7 ${(p.tags ?? []).join(', ')}</div>\n <div>${p.summary}</div>\n <div class=\"row\">\n <button class=\"primary\" onclick=\"approveOne('${p.id}')\">\u6279\u51C6</button>\n <button class=\"danger\" onclick=\"rejectOne('${p.id}')\">\u62D2\u7EDD</button>\n </div>\n </div>`).join('');\n }\n const batchables = inbox.filter(p => p.grade === 'batch');\n document.getElementById('batchbar').style.display = batchables.length > 1 ? 'block' : 'none';\n}\nasync function approveOne(id) { await j('/api/inbox/' + id + '/approve', { method: 'POST', headers: {'content-type':'application/json'}, body: '{}' }); refresh(); }\nasync function rejectOne(id) { await j('/api/inbox/' + id + '/reject', { method: 'POST', headers: {'content-type':'application/json'}, body: '{}' }); refresh(); }\nasync function approveBatch() {\n const ids = inbox.filter(p => p.grade === 'batch').map(p => p.id);\n await j('/api/inbox/approve', { method: 'POST', headers: {'content-type':'application/json'}, body: JSON.stringify({ ids }) });\n refresh();\n}\nasync function doSearch() {\n const r = await j('/api/search', { method: 'POST', headers: {'content-type':'application/json'}, body: JSON.stringify({ query: document.getElementById('q').value }) });\n document.getElementById('results').textContent = JSON.stringify(r.data.hits ?? r.data, null, 2);\n}\nrefresh();\n</script>\n</body>\n</html>";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency single-file panel (no build step). Graded approval inbox:
|
|
3
|
+
* decision/constraint/api-catalog require one-by-one approval; other types
|
|
4
|
+
* show a batch button. Human clicking approve = panel channel.
|
|
5
|
+
*/
|
|
6
|
+
export const PANEL_HTML = `<!doctype html>
|
|
7
|
+
<html lang="zh">
|
|
8
|
+
<head>
|
|
9
|
+
<meta charset="utf-8">
|
|
10
|
+
<title>memhub panel</title>
|
|
11
|
+
<style>
|
|
12
|
+
:root { color-scheme: dark; }
|
|
13
|
+
body { font-family: ui-sans-serif, system-ui; margin: 0; background: #0f1115; color: #e6e6e6; }
|
|
14
|
+
header { padding: 14px 20px; border-bottom: 1px solid #262b36; display: flex; gap: 16px; align-items: baseline; }
|
|
15
|
+
header h1 { font-size: 16px; margin: 0; }
|
|
16
|
+
header span { color: #8b93a7; font-size: 12px; }
|
|
17
|
+
main { max-width: 860px; margin: 0 auto; padding: 16px; }
|
|
18
|
+
.card { border: 1px solid #262b36; border-radius: 10px; padding: 14px 16px; margin: 10px 0; background: #161a22; }
|
|
19
|
+
.card h3 { margin: 0 0 6px; font-size: 14px; }
|
|
20
|
+
.meta { color: #8b93a7; font-size: 12px; margin-bottom: 8px; }
|
|
21
|
+
.grade { border-radius: 6px; padding: 1px 8px; font-size: 11px; }
|
|
22
|
+
.grade.individual { background: #3a2a2a; color: #ff9e9e; }
|
|
23
|
+
.grade.batch { background: #233a2c; color: #8ee39b; }
|
|
24
|
+
button { border: 1px solid #2f3542; background: #1d2330; color: #e6e6e6; border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 13px; }
|
|
25
|
+
button:hover { background: #262d3d; }
|
|
26
|
+
button.primary { background: #245639; border-color: #2f7a4d; }
|
|
27
|
+
button.danger { background: #5a2a2a; border-color: #7a3a3a; }
|
|
28
|
+
.row { display: flex; gap: 8px; margin-top: 8px; }
|
|
29
|
+
#status { font-size: 12px; color: #8b93a7; }
|
|
30
|
+
pre { white-space: pre-wrap; font-size: 12px; color: #a9b1c2; }
|
|
31
|
+
.empty { color: #8b93a7; padding: 30px 0; text-align: center; }
|
|
32
|
+
#batchbar { display: none; margin: 10px 0; }
|
|
33
|
+
</style>
|
|
34
|
+
</head>
|
|
35
|
+
<body>
|
|
36
|
+
<header><h1>memhub panel</h1><span id="status">loading…</span></header>
|
|
37
|
+
<main>
|
|
38
|
+
<div id="batchbar"><button class="primary" onclick="approveBatch()">批准所选低风险条目(批量)</button></div>
|
|
39
|
+
<div id="inbox"><div class="empty">加载中…</div></div>
|
|
40
|
+
<details><summary>只读检索</summary>
|
|
41
|
+
<div class="row"><input id="q" placeholder="查询词…" style="flex:1"><button onclick="doSearch()">搜索</button></div>
|
|
42
|
+
<pre id="results"></pre>
|
|
43
|
+
</details>
|
|
44
|
+
</main>
|
|
45
|
+
<script>
|
|
46
|
+
let inbox = [];
|
|
47
|
+
async function j(url, opts) { const r = await fetch(url, opts); return { ok: r.ok, status: r.status, data: await r.json().catch(() => ({})) }; }
|
|
48
|
+
async function refresh() {
|
|
49
|
+
const s = await j('/api/status'); const i = await j('/api/inbox');
|
|
50
|
+
document.getElementById('status').textContent =
|
|
51
|
+
(s.data.workspace ? s.data.workspace.workspaceId + (s.data.workspace.exact ? '' : ' (synthetic)') : '?') +
|
|
52
|
+
' · accepted ' + (s.data.acceptedCount ?? 0) + ' · pending ' + (i.data.proposals ?? []).length;
|
|
53
|
+
inbox = i.data.proposals ?? [];
|
|
54
|
+
const el = document.getElementById('inbox');
|
|
55
|
+
if (inbox.length === 0) { el.innerHTML = '<div class="empty">✓ inbox 清空,无待审条目</div>'; }
|
|
56
|
+
else {
|
|
57
|
+
el.innerHTML = inbox.map(p => \`
|
|
58
|
+
<div class="card" id="card-\${p.id}">
|
|
59
|
+
<h3>\${p.title} <span class="grade \${p.grade}">\${p.grade === 'individual' ? '逐条审批' : '可批量'}</span></h3>
|
|
60
|
+
<div class="meta">\${p.id} · \${p.type} · \${(p.tags ?? []).join(', ')}</div>
|
|
61
|
+
<div>\${p.summary}</div>
|
|
62
|
+
<div class="row">
|
|
63
|
+
<button class="primary" onclick="approveOne('\${p.id}')">批准</button>
|
|
64
|
+
<button class="danger" onclick="rejectOne('\${p.id}')">拒绝</button>
|
|
65
|
+
</div>
|
|
66
|
+
</div>\`).join('');
|
|
67
|
+
}
|
|
68
|
+
const batchables = inbox.filter(p => p.grade === 'batch');
|
|
69
|
+
document.getElementById('batchbar').style.display = batchables.length > 1 ? 'block' : 'none';
|
|
70
|
+
}
|
|
71
|
+
async function approveOne(id) { await j('/api/inbox/' + id + '/approve', { method: 'POST', headers: {'content-type':'application/json'}, body: '{}' }); refresh(); }
|
|
72
|
+
async function rejectOne(id) { await j('/api/inbox/' + id + '/reject', { method: 'POST', headers: {'content-type':'application/json'}, body: '{}' }); refresh(); }
|
|
73
|
+
async function approveBatch() {
|
|
74
|
+
const ids = inbox.filter(p => p.grade === 'batch').map(p => p.id);
|
|
75
|
+
await j('/api/inbox/approve', { method: 'POST', headers: {'content-type':'application/json'}, body: JSON.stringify({ ids }) });
|
|
76
|
+
refresh();
|
|
77
|
+
}
|
|
78
|
+
async function doSearch() {
|
|
79
|
+
const r = await j('/api/search', { method: 'POST', headers: {'content-type':'application/json'}, body: JSON.stringify({ query: document.getElementById('q').value }) });
|
|
80
|
+
document.getElementById('results').textContent = JSON.stringify(r.data.hits ?? r.data, null, 2);
|
|
81
|
+
}
|
|
82
|
+
refresh();
|
|
83
|
+
</script>
|
|
84
|
+
</body>
|
|
85
|
+
</html>`;
|
|
86
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel.js","sourceRoot":"","sources":["../../src/transport/panel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA+ElB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readHubConfig } from '../core/hub.js';
|
|
2
|
+
import { getEntry } from '../core/store.js';
|
|
3
|
+
import { type SearchIndex, type SearchMetrics } from '../core/search.js';
|
|
4
|
+
import { type ResolvedWorkspace } from '../core/registry.js';
|
|
5
|
+
import type { KnowledgeType } from '../core/types.js';
|
|
6
|
+
export type ApprovalGrade = 'individual' | 'batch';
|
|
7
|
+
export declare function gradeFor(type: KnowledgeType): ApprovalGrade;
|
|
8
|
+
export interface ApiState {
|
|
9
|
+
hubRoot: string;
|
|
10
|
+
workspace: ResolvedWorkspace;
|
|
11
|
+
index: SearchIndex;
|
|
12
|
+
metrics: SearchMetrics;
|
|
13
|
+
}
|
|
14
|
+
export declare function createApiState(hubRoot: string, workspaceArg?: string): ApiState;
|
|
15
|
+
export interface ApiResponse {
|
|
16
|
+
status: number;
|
|
17
|
+
body: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** Route one API request. `body` is the parsed JSON body or undefined. */
|
|
20
|
+
export declare function handleApi(state: ApiState, method: string, path: string, body?: Record<string, unknown>): ApiResponse;
|
|
21
|
+
export { getEntry, readHubConfig };
|