macro-memory 0.0.0-stage → 0.9.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 +386 -2
- package/bin/macro-memory.mjs +735 -0
- package/docs/CHANGELOG.md +268 -0
- package/docs/MAC.md +156 -0
- package/docs/images/_architecture.svg +70 -0
- package/docs/images/_memory-flow.svg +75 -0
- package/docs/images/_token-budget.svg +40 -0
- package/docs/images/architecture.png +0 -0
- package/docs/images/hero.png +0 -0
- package/docs/images/memory-flow.png +0 -0
- package/docs/images/src/graph.html +78 -0
- package/docs/images/src/hero.html +88 -0
- package/docs/images/src/panel.html +63 -0
- package/docs/images/src/pipeline.html +97 -0
- package/docs/images/token-budget.png +0 -0
- package/lib/client.js +3811 -0
- package/lib/core/agents-file.js +95 -0
- package/lib/core/client.js +313 -0
- package/lib/core/compat/dsh-llm.js +78 -0
- package/lib/core/config.js +117 -0
- package/lib/core/engine.js +456 -0
- package/lib/core/fence.js +109 -0
- package/lib/core/index.js +102 -0
- package/lib/core/migrate.js +70 -0
- package/lib/core/mini-host.js +324 -0
- package/lib/core/owner.js +347 -0
- package/lib/core/paths.js +95 -0
- package/lib/core/serve.js +378 -0
- package/lib/core/trust.js +173 -0
- package/lib/index.js +567 -0
- package/lib/macro/brand.js +82 -0
- package/lib/macro/bridge.js +158 -0
- package/lib/macro/chain.js +206 -0
- package/lib/macro/contract.js +471 -0
- package/lib/macro/cost.js +164 -0
- package/lib/macro/defs/admin.js +528 -0
- package/lib/macro/defs/dream.js +24 -0
- package/lib/macro/defs/link.js +408 -0
- package/lib/macro/defs/project.js +237 -0
- package/lib/macro/defs/read.js +160 -0
- package/lib/macro/defs/remember.js +411 -0
- package/lib/macro/defs/search.js +899 -0
- package/lib/macro/defs/update.js +161 -0
- package/lib/macro/dreamledger.js +1398 -0
- package/lib/macro/facade.js +135 -0
- package/lib/macro/fusion.js +188 -0
- package/lib/macro/injectledger.js +843 -0
- package/lib/macro/linkflow.js +391 -0
- package/lib/macro/links.js +448 -0
- package/lib/macro/neighbor.js +1083 -0
- package/lib/macro/panel.js +96 -0
- package/lib/macro/platform.js +134 -0
- package/lib/macro/prompt.js +139 -0
- package/lib/macro/provenance.js +148 -0
- package/lib/macro/render.js +35 -0
- package/lib/macro/revisions.js +253 -0
- package/lib/macro/shared.js +113 -0
- package/lib/macro/shortid.js +114 -0
- package/lib/macro/snapshot.js +700 -0
- package/lib/macro/spend.js +312 -0
- package/lib/macro/store.js +238 -0
- package/lib/macro/supersede.js +197 -0
- package/lib/macro/tokencost.js +90 -0
- package/lib/macro/tools.js +67 -0
- package/lib/mcp/server.js +201 -0
- package/lib/mcp/stdio.js +151 -0
- package/lib/ui/page.js +300 -0
- package/lib/ui/server.js +226 -0
- package/package.json +56 -4
- package/vendor/VENDOR.json +39 -0
- package/vendor/cosmokit/LICENSE +21 -0
- package/vendor/cosmokit/README.md +30 -0
- package/vendor/cosmokit/lib/index.js +418 -0
- package/vendor/cosmokit/lib/types/array.d.ts +15 -0
- package/vendor/cosmokit/lib/types/array.d.ts.map +1 -0
- package/vendor/cosmokit/lib/types/index.d.ts +13 -0
- package/vendor/cosmokit/lib/types/index.d.ts.map +1 -0
- package/vendor/cosmokit/lib/types/misc.d.ts +41 -0
- package/vendor/cosmokit/lib/types/misc.d.ts.map +1 -0
- package/vendor/cosmokit/lib/types/string.d.ts +89 -0
- package/vendor/cosmokit/lib/types/string.d.ts.map +1 -0
- package/vendor/cosmokit/lib/types/time.d.ts +19 -0
- package/vendor/cosmokit/lib/types/time.d.ts.map +1 -0
- package/vendor/cosmokit/lib/types/types.d.ts +42 -0
- package/vendor/cosmokit/lib/types/types.d.ts.map +1 -0
- package/vendor/cosmokit/lib/types/volatile.d.ts +40 -0
- package/vendor/cosmokit/lib/types/volatile.d.ts.map +1 -0
- package/vendor/cosmokit/package.json +32 -0
- package/vendor/cosmokit/src/array.ts +42 -0
- package/vendor/cosmokit/src/index.ts +12 -0
- package/vendor/cosmokit/src/misc.ts +78 -0
- package/vendor/cosmokit/src/string.ts +113 -0
- package/vendor/cosmokit/src/time.ts +92 -0
- package/vendor/cosmokit/src/types.ts +168 -0
- package/vendor/cosmokit/src/volatile.ts +86 -0
- package/vendor/dsh-memory-nebula/CONTRIBUTING.md +48 -0
- package/vendor/dsh-memory-nebula/LICENSE +21 -0
- package/vendor/dsh-memory-nebula/README.en.md +203 -0
- package/vendor/dsh-memory-nebula/README.md +253 -0
- package/vendor/dsh-memory-nebula/SECURITY.md +43 -0
- package/vendor/dsh-memory-nebula/SUPPORT.md +33 -0
- package/vendor/dsh-memory-nebula/cordis.patch.yml +4 -0
- package/vendor/dsh-memory-nebula/lib/client.js +105 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/index.js +279 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/ingest.js +230 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/meow.js +320 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/notes.js +305 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/sqlite.js +287 -0
- package/vendor/dsh-memory-nebula/lib/host/adapters/util.js +231 -0
- package/vendor/dsh-memory-nebula/lib/host/bridge.js +351 -0
- package/vendor/dsh-memory-nebula/lib/host/compress.js +97 -0
- package/vendor/dsh-memory-nebula/lib/host/demo.js +357 -0
- package/vendor/dsh-memory-nebula/lib/host/diagnostics.js +125 -0
- package/vendor/dsh-memory-nebula/lib/host/doctor.js +270 -0
- package/vendor/dsh-memory-nebula/lib/host/entities.js +230 -0
- package/vendor/dsh-memory-nebula/lib/host/graph.js +1762 -0
- package/vendor/dsh-memory-nebula/lib/host/graphcache.js +290 -0
- package/vendor/dsh-memory-nebula/lib/host/http.js +993 -0
- package/vendor/dsh-memory-nebula/lib/host/injectcfg.js +95 -0
- package/vendor/dsh-memory-nebula/lib/host/ledger.js +175 -0
- package/vendor/dsh-memory-nebula/lib/host/live.js +204 -0
- package/vendor/dsh-memory-nebula/lib/host/nebula.js +2105 -0
- package/vendor/dsh-memory-nebula/lib/host/page.js +75 -0
- package/vendor/dsh-memory-nebula/lib/host/path.js +83 -0
- package/vendor/dsh-memory-nebula/lib/host/recall.js +526 -0
- package/vendor/dsh-memory-nebula/lib/host/share.js +633 -0
- package/vendor/dsh-memory-nebula/lib/host/sources.js +266 -0
- package/vendor/dsh-memory-nebula/lib/host/store.js +333 -0
- package/vendor/dsh-memory-nebula/lib/host/text.js +410 -0
- package/vendor/dsh-memory-nebula/lib/host/transcripts.js +396 -0
- package/vendor/dsh-memory-nebula/lib/index.js +782 -0
- package/vendor/dsh-memory-nebula/lib/standalone.mjs +315 -0
- package/vendor/dsh-memory-nebula/lib/web/api.js +426 -0
- package/vendor/dsh-memory-nebula/lib/web/app.js +4172 -0
- package/vendor/dsh-memory-nebula/lib/web/i18n.js +580 -0
- package/vendor/dsh-memory-nebula/lib/web/index.html +174 -0
- package/vendor/dsh-memory-nebula/lib/web/nav.js +132 -0
- package/vendor/dsh-memory-nebula/lib/web/render.js +1890 -0
- package/vendor/dsh-memory-nebula/lib/web/space3d.js +1883 -0
- package/vendor/dsh-memory-nebula/lib/web/style.css +1402 -0
- package/vendor/dsh-memory-nebula/locale/en.json +7 -0
- package/vendor/dsh-memory-nebula/locale/zh.json +7 -0
- package/vendor/dsh-memory-nebula/market/assets/icon-180.png +0 -0
- package/vendor/dsh-memory-nebula/market/assets/icon.svg +40 -0
- package/vendor/dsh-memory-nebula/market/index.json +101 -0
- package/vendor/dsh-memory-nebula/package.json +87 -0
- package/vendor/dsh-memory-nebula/sidecar.ps1 +119 -0
- package/vendor/meow-memory/LICENSE +21 -0
- package/vendor/meow-memory/README.en.md +192 -0
- package/vendor/meow-memory/README.md +174 -0
- package/vendor/meow-memory/README.pt-br.md +180 -0
- package/vendor/meow-memory/cordis.patch.yml +7 -0
- package/vendor/meow-memory/lib/client.js +3354 -0
- package/vendor/meow-memory/lib/client.js.map +7 -0
- package/vendor/meow-memory/lib/index.js +13500 -0
- package/vendor/meow-memory/lib/index.js.map +7 -0
- package/vendor/meow-memory/lib/prompts/README.md +65 -0
- package/vendor/meow-memory/lib/prompts/en/dream-atomic.md +36 -0
- package/vendor/meow-memory/lib/prompts/en/dream-header.md +9 -0
- package/vendor/meow-memory/lib/prompts/en/dream-project-summary.md +12 -0
- package/vendor/meow-memory/lib/prompts/en/dream-topic.md +27 -0
- package/vendor/meow-memory/lib/prompts/en/external-memory-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/en/first-create-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/en/labels.md +104 -0
- package/vendor/meow-memory/lib/prompts/en/reflect.md +31 -0
- package/vendor/meow-memory/lib/prompts/en/system-guide.md +121 -0
- package/vendor/meow-memory/lib/prompts/en/tools.md +83 -0
- package/vendor/meow-memory/lib/prompts/en/welcome-guide.md +12 -0
- package/vendor/meow-memory/lib/prompts/pt-br/dream-atomic.md +36 -0
- package/vendor/meow-memory/lib/prompts/pt-br/dream-header.md +9 -0
- package/vendor/meow-memory/lib/prompts/pt-br/dream-project-summary.md +12 -0
- package/vendor/meow-memory/lib/prompts/pt-br/dream-topic.md +27 -0
- package/vendor/meow-memory/lib/prompts/pt-br/external-memory-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/pt-br/first-create-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/pt-br/labels.md +104 -0
- package/vendor/meow-memory/lib/prompts/pt-br/reflect.md +31 -0
- package/vendor/meow-memory/lib/prompts/pt-br/system-guide.md +121 -0
- package/vendor/meow-memory/lib/prompts/pt-br/tools.md +83 -0
- package/vendor/meow-memory/lib/prompts/pt-br/welcome-guide.md +12 -0
- package/vendor/meow-memory/lib/prompts/zh/dream-atomic.md +36 -0
- package/vendor/meow-memory/lib/prompts/zh/dream-header.md +9 -0
- package/vendor/meow-memory/lib/prompts/zh/dream-project-summary.md +19 -0
- package/vendor/meow-memory/lib/prompts/zh/dream-topic.md +27 -0
- package/vendor/meow-memory/lib/prompts/zh/external-memory-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/zh/first-create-notice.md +8 -0
- package/vendor/meow-memory/lib/prompts/zh/labels.md +104 -0
- package/vendor/meow-memory/lib/prompts/zh/reflect.md +30 -0
- package/vendor/meow-memory/lib/prompts/zh/system-guide.md +119 -0
- package/vendor/meow-memory/lib/prompts/zh/tools.md +83 -0
- package/vendor/meow-memory/lib/prompts/zh/welcome-guide.md +12 -0
- package/vendor/meow-memory/package.json +64 -0
- package/vendor/schemastery/LICENSE +21 -0
- package/vendor/schemastery/README.md +393 -0
- package/vendor/schemastery/lib/index.cjs +635 -0
- package/vendor/schemastery/lib/index.mjs +637 -0
- package/vendor/schemastery/lib/types/index.d.ts +211 -0
- package/vendor/schemastery/lib/types/index.d.ts.map +1 -0
- package/vendor/schemastery/package.json +39 -0
- package/vendor/schemastery/src/index.ts +962 -0
package/lib/ui/server.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 管理界面(PLAN §10 / P2-1):`macro-memory ui`。
|
|
3
|
+
*
|
|
4
|
+
* 三条纪律写在门口,别在下游再松:
|
|
5
|
+
*
|
|
6
|
+
* 1. **只听 `127.0.0.1`**,端口由系统挑(`port: 0`);令牌一次性、进 URL、不落盘。
|
|
7
|
+
* 它不是网络服务,是你自己机器上的一扇窗。
|
|
8
|
+
* 2. **界面不直连库**(PLAN 原话:它是 `serve` 的客户端)。探到现成的 serve 就借它的;
|
|
9
|
+
* 探不到就在本进程里临时起一个——`publish: false`,**不写发现文件、不撤别人的**,
|
|
10
|
+
* 关界面就一起停。这样「开着界面」永远不会把一个共享服务变成两个写者。
|
|
11
|
+
* 3. **关掉之后进程与端口全消失**:`close()` 里先关 HTTP,再关临时 serve(引擎跟着关)。
|
|
12
|
+
*
|
|
13
|
+
* 页面本身在 `page.js` 里,一个常量。
|
|
14
|
+
*/
|
|
15
|
+
import http from 'node:http'
|
|
16
|
+
import path from 'node:path'
|
|
17
|
+
import fs from 'node:fs'
|
|
18
|
+
import crypto from 'node:crypto'
|
|
19
|
+
import { discover, request as askServe } from '../core/client.js'
|
|
20
|
+
import { startServe } from '../core/serve.js'
|
|
21
|
+
import { resolveDataDir } from '../core/engine.js'
|
|
22
|
+
import { PAGE_HTML } from './page.js'
|
|
23
|
+
|
|
24
|
+
const VERSION = (() => {
|
|
25
|
+
try {
|
|
26
|
+
return String(JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version ?? '0.0.0')
|
|
27
|
+
} catch {
|
|
28
|
+
return '0.0.0'
|
|
29
|
+
}
|
|
30
|
+
})()
|
|
31
|
+
|
|
32
|
+
function jsonRes(res, code, obj) {
|
|
33
|
+
const body = JSON.stringify(obj)
|
|
34
|
+
res.writeHead(code, { 'content-type': 'application/json; charset=utf-8', 'content-length': Buffer.byteLength(body) })
|
|
35
|
+
res.end(body)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function textRes(res, code, text, type = 'text/plain; charset=utf-8') {
|
|
39
|
+
res.writeHead(code, { 'content-type': type, 'content-length': Buffer.byteLength(text) })
|
|
40
|
+
res.end(text)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function readJson(req) {
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
const chunks = []
|
|
46
|
+
let size = 0
|
|
47
|
+
req.on('data', (c) => {
|
|
48
|
+
size += c.length
|
|
49
|
+
if (size > 4 * 1024 * 1024) {
|
|
50
|
+
req.destroy()
|
|
51
|
+
resolve({})
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
chunks.push(c)
|
|
55
|
+
})
|
|
56
|
+
req.on('end', () => {
|
|
57
|
+
const raw = Buffer.concat(chunks).toString('utf8')
|
|
58
|
+
if (raw.trim() === '') return resolve({})
|
|
59
|
+
try {
|
|
60
|
+
resolve(JSON.parse(raw))
|
|
61
|
+
} catch {
|
|
62
|
+
resolve({})
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
req.on('error', () => resolve({}))
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 起一扇窗。
|
|
71
|
+
*
|
|
72
|
+
* @param {object} opts
|
|
73
|
+
* @param {string} [opts.dataDir] 数据目录(默认走 `resolveDataDir`)
|
|
74
|
+
* @param {string} [opts.cwd] 打开时看哪个工作区(默认当前目录)
|
|
75
|
+
* @param {string} [opts.agent] 界面自己报的 agent 名(默认 `ui`)
|
|
76
|
+
* @param {number} [opts.port] 想固定端口就传(默认 0 = 系统挑)
|
|
77
|
+
* @returns {Promise<{url:string, port:number, token:string, upstream:string, dataDir:string, cwd:string, server:object, close:Function}>}
|
|
78
|
+
*/
|
|
79
|
+
export async function startUi(opts = {}) {
|
|
80
|
+
const dataDir = resolveDataDir({ dir: opts.dataDir })
|
|
81
|
+
const cwd = path.resolve(opts.cwd ?? process.cwd())
|
|
82
|
+
const agent = typeof opts.agent === 'string' && opts.agent.length > 0 ? opts.agent : 'ui'
|
|
83
|
+
|
|
84
|
+
const found = await discover(dataDir)
|
|
85
|
+
let upstream
|
|
86
|
+
if (found.mode === 'shared' && found.info) {
|
|
87
|
+
upstream = { mode: 'shared', info: found.info, note: `写交给已在跑的服务,pid ${found.info.pid}`, own: null }
|
|
88
|
+
} else {
|
|
89
|
+
const own = await startServe({
|
|
90
|
+
dataDir,
|
|
91
|
+
cwd,
|
|
92
|
+
defaultCwd: cwd,
|
|
93
|
+
port: 0,
|
|
94
|
+
publish: false,
|
|
95
|
+
...(opts.homeDir ? { homeDir: opts.homeDir } : {}),
|
|
96
|
+
...(opts.projectDir ? { projectDir: opts.projectDir } : {}),
|
|
97
|
+
})
|
|
98
|
+
upstream = {
|
|
99
|
+
mode: 'local',
|
|
100
|
+
info: own.info,
|
|
101
|
+
note: `没探到在跑的服务,界面自己临时起了一个(pid ${process.pid},不写发现文件,关界面就停)`,
|
|
102
|
+
own,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const token = crypto.randomBytes(18).toString('hex')
|
|
107
|
+
|
|
108
|
+
const server = http.createServer((req, res) => {
|
|
109
|
+
void (async () => {
|
|
110
|
+
const urlPath = (req.url ?? '/').split('?')[0]
|
|
111
|
+
const query = new URLSearchParams((req.url ?? '').split('?')[1] ?? '')
|
|
112
|
+
const given = String(req.headers['x-mm-token'] ?? query.get('t') ?? '')
|
|
113
|
+
if (given !== token) {
|
|
114
|
+
return textRes(res, 401, '令牌不对:请用启动时打印的那条带 t= 的地址打开这一页。')
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
if (req.method === 'GET' && (urlPath === '/' || urlPath === '/index.html')) {
|
|
119
|
+
return textRes(res, 200, PAGE_HTML, 'text/html; charset=utf-8')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (req.method === 'GET' && urlPath === '/api/state') {
|
|
123
|
+
const [cen, st, inj] = await Promise.all([
|
|
124
|
+
askServe(upstream.info, 'GET', `/census?cwd=${encodeURIComponent(cwd)}`, undefined, { timeout: 8000 }),
|
|
125
|
+
askServe(upstream.info, 'GET', '/stats', undefined, { timeout: 8000 }),
|
|
126
|
+
askServe(upstream.info, 'GET', '/inject', undefined, { timeout: 8000 }),
|
|
127
|
+
])
|
|
128
|
+
return jsonRes(res, 200, {
|
|
129
|
+
ok: true,
|
|
130
|
+
version: VERSION,
|
|
131
|
+
dataDir,
|
|
132
|
+
cwd,
|
|
133
|
+
agent,
|
|
134
|
+
upstream: { mode: upstream.mode, note: upstream.note, pid: upstream.info.pid ?? null },
|
|
135
|
+
census: cen.json ?? null,
|
|
136
|
+
stats: st.json ?? null,
|
|
137
|
+
injectChars: inj.json?.chars ?? 0,
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (req.method === 'GET' && urlPath === '/api/census') {
|
|
142
|
+
const out = await askServe(upstream.info, 'GET', `/census?cwd=${encodeURIComponent(query.get('cwd') ?? cwd)}`, undefined, { timeout: 8000 })
|
|
143
|
+
return jsonRes(res, out.status === 200 ? 200 : 502, out.json ?? { ok: false, error: out.text })
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (req.method === 'GET' && urlPath === '/api/inject') {
|
|
147
|
+
const cap = query.get('maxChars')
|
|
148
|
+
const p = cap && Number(cap) > 0 ? `/inject?maxChars=${encodeURIComponent(cap)}` : '/inject'
|
|
149
|
+
const out = await askServe(upstream.info, 'GET', p, undefined, { timeout: 8000 })
|
|
150
|
+
return jsonRes(res, out.status === 200 ? 200 : 502, out.json ?? { ok: false, error: out.text })
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (req.method === 'GET' && urlPath === '/api/search') {
|
|
154
|
+
const qs = new URLSearchParams()
|
|
155
|
+
qs.set('q', query.get('q') ?? '')
|
|
156
|
+
for (const key of ['k', 'mode']) {
|
|
157
|
+
const v = query.get(key)
|
|
158
|
+
if (v !== null && v !== '') qs.set(key, v)
|
|
159
|
+
}
|
|
160
|
+
qs.set('cwd', query.get('cwd') ?? cwd)
|
|
161
|
+
qs.set('agent', agent)
|
|
162
|
+
const out = await askServe(upstream.info, 'GET', `/search?${qs.toString()}`, undefined, { timeout: 30000 })
|
|
163
|
+
return jsonRes(res, out.status === 200 ? 200 : 502, out.json ?? { ok: false, error: out.text })
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (req.method === 'GET' && urlPath === '/api/read') {
|
|
167
|
+
const qs = new URLSearchParams()
|
|
168
|
+
qs.set('id', query.get('id') ?? '')
|
|
169
|
+
qs.set('cwd', query.get('cwd') ?? cwd)
|
|
170
|
+
qs.set('agent', agent)
|
|
171
|
+
const out = await askServe(upstream.info, 'GET', `/read?${qs.toString()}`, undefined, { timeout: 15000 })
|
|
172
|
+
return jsonRes(res, out.status === 200 ? 200 : 502, out.json ?? { ok: false, error: out.text })
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (req.method === 'POST' && urlPath === '/api/call') {
|
|
176
|
+
const body = await readJson(req)
|
|
177
|
+
if (typeof body.tool !== 'string' || body.tool.length === 0) {
|
|
178
|
+
return jsonRes(res, 400, { ok: false, error: '要给 tool(比如 memory_admin)' })
|
|
179
|
+
}
|
|
180
|
+
const out = await askServe(
|
|
181
|
+
upstream.info,
|
|
182
|
+
'POST',
|
|
183
|
+
'/call',
|
|
184
|
+
{ tool: body.tool, args: body.args ?? {}, cwd: body.cwd ?? cwd, agent, requestId: body.requestId },
|
|
185
|
+
{ timeout: 120000 },
|
|
186
|
+
)
|
|
187
|
+
return jsonRes(res, out.status === 200 ? 200 : 502, out.json ?? { ok: false, error: out.text })
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return jsonRes(res, 404, { ok: false, error: '没有这个端点' })
|
|
191
|
+
} catch (err) {
|
|
192
|
+
return jsonRes(res, 500, { ok: false, error: String(err?.message ?? err) })
|
|
193
|
+
}
|
|
194
|
+
})()
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
await new Promise((resolve, reject) => {
|
|
198
|
+
server.once('error', reject)
|
|
199
|
+
server.listen({ host: '127.0.0.1', port: Number.isInteger(opts.port) ? opts.port : 0 }, () => {
|
|
200
|
+
server.removeListener('error', reject)
|
|
201
|
+
resolve()
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
const addr = server.address()
|
|
206
|
+
const port = typeof addr === 'object' && addr ? Number(addr.port) : 0
|
|
207
|
+
const url = `http://127.0.0.1:${port}/?t=${token}`
|
|
208
|
+
|
|
209
|
+
let closed = false
|
|
210
|
+
async function close(reason = 'ui-close') {
|
|
211
|
+
if (closed) return { reason, already: true }
|
|
212
|
+
closed = true
|
|
213
|
+
await new Promise((resolve) => server.close(() => resolve()))
|
|
214
|
+
let own = null
|
|
215
|
+
if (upstream.own) {
|
|
216
|
+
try {
|
|
217
|
+
own = await upstream.own.close(reason)
|
|
218
|
+
} catch {
|
|
219
|
+
// 临时服务停不下来也不该拖住「界面已关」
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return { reason, upstream: upstream.mode, own }
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return { url, port, token, upstream: upstream.mode, dataDir, cwd, agent, server, close }
|
|
226
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "macro-memory",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.9.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "一套记忆,所有 agent:以 meow-memory 的库为主库、dsh-memory-nebula 的星图为索引,合成 8 个 memory_* 统一工具 + 一段最小注入。可作 MCP 服务器、CLI、core 库或本地管理界面用;装 DSH 是体验最好的路,但不是唯一的路。",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/hanhan9999999999999999999/dsh-macro-memory.git",
|
|
11
|
+
"directory": "."
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/hanhan9999999999999999999/dsh-macro-memory#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/hanhan9999999999999999999/dsh-macro-memory/issues"
|
|
16
|
+
},
|
|
17
|
+
"main": "./lib/core/index.js",
|
|
18
|
+
"bin": {
|
|
19
|
+
"macro-memory": "./bin/macro-memory.mjs"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./lib/core/index.js",
|
|
23
|
+
"./core": "./lib/core/index.js",
|
|
24
|
+
"./mcp": "./lib/mcp/stdio.js",
|
|
25
|
+
"./cli": "./bin/macro-memory.mjs",
|
|
26
|
+
"./ui": "./lib/ui/server.js",
|
|
27
|
+
"./dsh": "./lib/index.js",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin",
|
|
32
|
+
"lib",
|
|
33
|
+
"vendor",
|
|
34
|
+
"docs/images",
|
|
35
|
+
"docs/MAC.md",
|
|
36
|
+
"docs/CHANGELOG.md",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=24.0.0"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"memory",
|
|
45
|
+
"agent-memory",
|
|
46
|
+
"mcp",
|
|
47
|
+
"model-context-protocol",
|
|
48
|
+
"codex",
|
|
49
|
+
"claude-code",
|
|
50
|
+
"cursor",
|
|
51
|
+
"macro",
|
|
52
|
+
"meow-memory",
|
|
53
|
+
"memory-nebula",
|
|
54
|
+
"unified-tools",
|
|
55
|
+
"universal",
|
|
56
|
+
"deepseek-harness"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"note": "vendor 账本:这里的源码是从上游拷贝进来的(不是 npm 依赖)。改了就重跑 tools/make-vendor-manifest.mjs;doctor 会核对。",
|
|
3
|
+
"generatedBy": "tools/make-vendor-manifest.mjs",
|
|
4
|
+
"hashedBy": "tools/vendor-hash.mjs",
|
|
5
|
+
"vendors": [
|
|
6
|
+
{
|
|
7
|
+
"dir": "vendor/meow-memory",
|
|
8
|
+
"name": "meow-memory",
|
|
9
|
+
"version": "0.32.8",
|
|
10
|
+
"files": 44,
|
|
11
|
+
"bytes": 2225638,
|
|
12
|
+
"sha256": "f5641a54eda71c59c2d129e6e39ee5ab928bba51bcab3c4a3156af6ce3069d61"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"dir": "vendor/dsh-memory-nebula",
|
|
16
|
+
"name": "dsh-memory-nebula",
|
|
17
|
+
"version": "1.11.74",
|
|
18
|
+
"files": 52,
|
|
19
|
+
"bytes": 1043581,
|
|
20
|
+
"sha256": "85d0b5027b900d4f8f510022fc42db9babfaf5d4f88475cabe47fb9921d73768"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"dir": "vendor/schemastery",
|
|
24
|
+
"name": "@deepseek-ai/schemastery",
|
|
25
|
+
"version": "3.19.0",
|
|
26
|
+
"files": 8,
|
|
27
|
+
"bytes": 118714,
|
|
28
|
+
"sha256": "8dd8321a2d89ec10de6d277098025cec1afc543f72caa49fe10c4417d3f5c40a"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"dir": "vendor/cosmokit",
|
|
32
|
+
"name": "@deepseek-ai/cosmokit",
|
|
33
|
+
"version": "1.9.0",
|
|
34
|
+
"files": 25,
|
|
35
|
+
"bytes": 65942,
|
|
36
|
+
"sha256": "0ead94a0ff258bdd259c0baf38f409ef57987c67227dc5c95e5cd1bc6fd8e94d"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Shigma
|
|
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.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# cosmokit
|
|
2
|
+
|
|
3
|
+
[](https://codecov.io/gh/shigma/cosmokit)
|
|
4
|
+
[](https://www.npmjs.com/package/cosmokit)
|
|
5
|
+
|
|
6
|
+
A collection of common utilities.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
### Node.js
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install cosmokit
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import cosmokit from 'cosmokit'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Deno
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import cosmokit from 'npm:cosmokit@latest'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Config references
|
|
27
|
+
|
|
28
|
+
`Volatile<T>` exposes `get()` for immutable data snapshots. `createVolatile()` copies and freezes validated data; framework-owned `updateVolatile()` transfers a candidate snapshot into an existing reference. Framework-owned `volatileEntries()` enumerates references and their paths through plain config containers, stopping at snapshots and opaque objects. The shared symbol protocol recognizes references across ESM/CJS copies. Plugin consumers import the type from Cordis and retain the reference rather than caching values between operations.
|
|
29
|
+
|
|
30
|
+
`deepEqual()` treats two volatile references as equal regardless of their snapshots. Strict comparisons distinguish null from undefined recursively, compare URLs by normalized `href` and other opaque objects by identity, and treat distinct cyclic structures as unequal. Array comparison visits every index and treats holes as undefined. Snapshot-change detection must compare `.get()` results separately.
|