@capyclaw/wall-suite 0.0.0-stage → 0.1.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 +20 -2
- package/composition.lock.json +48 -0
- package/contract/wall-contract.json +8 -0
- package/cordis.patch.yml +6 -0
- package/dsh-suite.json +128 -0
- package/lib/index.mjs +6 -0
- package/node_modules/@capyclaw/asset-service/README.md +48 -0
- package/node_modules/@capyclaw/asset-service/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/asset-service/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/asset-service/lib/host.mjs +14 -0
- package/node_modules/@capyclaw/asset-service/package.json +59 -0
- package/node_modules/@capyclaw/asset-service/src/index.mjs +310 -0
- package/node_modules/@capyclaw/foundation/README.md +51 -0
- package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +88 -0
- package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
- package/node_modules/@capyclaw/foundation/abi/index.mjs +50 -0
- package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +352 -0
- package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +258 -0
- package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
- package/node_modules/@capyclaw/foundation/abi/version.mjs +140 -0
- package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
- package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
- package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +72 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +120 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
- package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +38 -0
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +88 -0
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +54 -0
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +187 -0
- package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +195 -0
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +115 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +198 -0
- package/node_modules/@capyclaw/foundation/package.json +53 -0
- package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
- package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
- package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
- package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
- package/node_modules/@capyclaw/plugin-kit/package.json +71 -0
- package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
- package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +60 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
- package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
- package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
- package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +664 -0
- package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
- package/node_modules/@capyclaw/portal/README.md +70 -0
- package/node_modules/@capyclaw/portal/lib/index.mjs +387 -0
- package/node_modules/@capyclaw/portal/lib/ledger.mjs +194 -0
- package/node_modules/@capyclaw/portal/lib/portal-agent.ps1 +811 -0
- package/node_modules/@capyclaw/portal/lib/portal-darwin.mjs +183 -0
- package/node_modules/@capyclaw/portal/package.json +40 -0
- package/node_modules/@capyclaw/service-broker/README.md +104 -0
- package/node_modules/@capyclaw/service-broker/cordis.patch.yml +8 -0
- package/node_modules/@capyclaw/service-broker/dsh-suite.json +21 -0
- package/node_modules/@capyclaw/service-broker/lib/control.mjs +209 -0
- package/node_modules/@capyclaw/service-broker/lib/discovery.mjs +109 -0
- package/node_modules/@capyclaw/service-broker/lib/engine.mjs +1290 -0
- package/node_modules/@capyclaw/service-broker/lib/host.mjs +187 -0
- package/node_modules/@capyclaw/service-broker/lib/manifest.mjs +262 -0
- package/node_modules/@capyclaw/service-broker/lib/recovery.mjs +275 -0
- package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +48 -0
- package/node_modules/@capyclaw/service-broker/lib/spec.mjs +78 -0
- package/node_modules/@capyclaw/service-broker/package.json +65 -0
- package/node_modules/@capyclaw/service-broker/server.mjs +81 -0
- package/node_modules/@capyclaw/service-broker/service.schema.json +62 -0
- package/node_modules/@capyclaw/service-broker/services.json +3 -0
- package/node_modules/@capyclaw/service-host/README.md +86 -0
- package/node_modules/@capyclaw/service-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/service-host/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/service-host/lib/host.mjs +22 -0
- package/node_modules/@capyclaw/service-host/package.json +60 -0
- package/node_modules/@capyclaw/service-host/src/index.mjs +570 -0
- package/node_modules/@capyclaw/service-host/src/tuning.mjs +63 -0
- package/node_modules/@capyclaw/tool-host/README.md +56 -0
- package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +46 -0
- package/node_modules/@capyclaw/tool-host/package.json +59 -0
- package/node_modules/@capyclaw/tool-host/src/admit-images.mjs +80 -0
- package/node_modules/@capyclaw/tool-host/src/caller-session.mjs +25 -0
- package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
- package/node_modules/@capyclaw/tool-host/src/index.mjs +461 -0
- package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +272 -0
- package/node_modules/@capyclaw/wall-workbench/README.md +58 -0
- package/node_modules/@capyclaw/wall-workbench/contract/wall-contract.json +8 -0
- package/node_modules/@capyclaw/wall-workbench/lib/host.mjs +1 -0
- package/node_modules/@capyclaw/wall-workbench/package.json +63 -0
- package/node_modules/@capyclaw/wall-workbench/plugin.mjs +13 -0
- package/node_modules/@capyclaw/wall-workbench/server/activate-log.mjs +66 -0
- package/node_modules/@capyclaw/wall-workbench/server/constants.mjs +12 -0
- package/node_modules/@capyclaw/wall-workbench/server/contract.mjs +12 -0
- package/node_modules/@capyclaw/wall-workbench/server/embedded-host.mjs +162 -0
- package/node_modules/@capyclaw/wall-workbench/server/infra/http.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/infra/tuning.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/relay.mjs +68 -0
- package/node_modules/@capyclaw/wall-workbench/server/routes/claim.mjs +46 -0
- package/node_modules/@capyclaw/wall-workbench/server/routes/workbench.mjs +29 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/SHARED_MANIFEST.json +70 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/asset-service.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/editor-host.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/editor/lease.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/service/api.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/service/http.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/service/mcp-http.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/tools/validate.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/tuning.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/util/fs-lock.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/service-host.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/tool-host.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/tuning.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/tools/capabilities/index.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/tools/index.mjs +12 -0
- package/node_modules/@capyclaw/wall-workbench/server/tools.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/workbench-framework.mjs +339 -0
- package/node_modules/@capyclaw/wall-workbench/ui/app.js +225 -0
- package/node_modules/@capyclaw/wall-workbench/ui/index.html +20 -0
- package/node_modules/@capyclaw/wall-workbench/ui/style.css +77 -0
- package/package.json +72 -4
- package/services.json +3 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** 公共服务 API 契约:插件之间只通过这份描述判断兼容性。 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} name 服务名(ctx.<name>)
|
|
5
|
+
* @param {string} version API 版本(semver;major 变化 = 不兼容)
|
|
6
|
+
* @param {string[]} capabilities 能力标签
|
|
7
|
+
*/
|
|
8
|
+
export function createServiceApi(name, version = '1.0.0', capabilities = []) {
|
|
9
|
+
if (!name) throw new Error('createServiceApi 需要 name')
|
|
10
|
+
return Object.freeze({
|
|
11
|
+
name,
|
|
12
|
+
version,
|
|
13
|
+
capabilities: Object.freeze([...capabilities]),
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 断言一个已注入的服务对象满足消费者要求。
|
|
19
|
+
* 缺失服务或 major 不一致时抛出明确错误,避免“看起来能跑”的静默不兼容。
|
|
20
|
+
* @param {object} service
|
|
21
|
+
* @param {{ name: string, major?: number|string, version?: string }} expected
|
|
22
|
+
*/
|
|
23
|
+
export function assertServiceApi(service, expected = {}) {
|
|
24
|
+
const name = expected.name
|
|
25
|
+
if (!name) throw new Error('assertServiceApi 需要 expected.name')
|
|
26
|
+
const major = String(expected.major ?? String(expected.version || '1').split('.')[0])
|
|
27
|
+
if (!service) throw new Error(`缺少公共服务: ctx.${name}`)
|
|
28
|
+
const api = service.api
|
|
29
|
+
if (!api || typeof api !== 'object') {
|
|
30
|
+
throw new Error(`服务 ctx.${name} 没有声明 api 契约;请升级提供方插件`)
|
|
31
|
+
}
|
|
32
|
+
if (api.name !== name) {
|
|
33
|
+
throw new Error(`服务 ctx.${name} 的 api.name=${api.name},与消费者期望的 ${name} 不一致`)
|
|
34
|
+
}
|
|
35
|
+
const gotMajor = String(api.version || '').split('.')[0]
|
|
36
|
+
if (gotMajor !== major) {
|
|
37
|
+
throw new Error(`服务 ctx.${name} API major=${gotMajor},消费者要求 major=${major}(提供方版本 ${api.version})`)
|
|
38
|
+
}
|
|
39
|
+
return api
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function serviceApiSummary(service) {
|
|
43
|
+
const api = service?.api
|
|
44
|
+
return api ? { name: api.name, version: api.version, capabilities: [...(api.capabilities || [])] } : null
|
|
45
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** 本机插件 HTTP 传输:安全响应头、body 上限、查询解析、loopback 监听。 */
|
|
2
|
+
import http from 'node:http'
|
|
3
|
+
import { tuning } from '../tuning.mjs'
|
|
4
|
+
|
|
5
|
+
export const SECURITY_HEADERS = {
|
|
6
|
+
'x-content-type-options': 'nosniff',
|
|
7
|
+
'referrer-policy': 'no-referrer',
|
|
8
|
+
'cache-control': 'no-store, no-cache, must-revalidate',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** 客户端已断开时放弃写入:长请求(截图/长轮询)在 handler 完成前客户端超时
|
|
12
|
+
* 断连是常态,写已销毁的 socket 会触发无人监听的 'error' 事件打崩进程。 */
|
|
13
|
+
function resDead(res) {
|
|
14
|
+
return res.destroyed || res.writableEnded
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function send(req, res, code, obj, extraHeaders = {}) {
|
|
18
|
+
if (resDead(res)) return
|
|
19
|
+
const body = obj === undefined ? '' : JSON.stringify(obj)
|
|
20
|
+
try {
|
|
21
|
+
res.writeHead(code, {
|
|
22
|
+
'content-type': 'application/json',
|
|
23
|
+
'content-length': Buffer.byteLength(body),
|
|
24
|
+
...SECURITY_HEADERS,
|
|
25
|
+
...extraHeaders,
|
|
26
|
+
})
|
|
27
|
+
res.end(req.method === 'HEAD' ? undefined : body)
|
|
28
|
+
} catch { /* socket 已死:响应无人接收,静默放弃 */ }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function sendText(req, res, code, text, contentType = 'text/plain; charset=utf-8', extraHeaders = {}) {
|
|
32
|
+
if (resDead(res)) return
|
|
33
|
+
const body = text === undefined || text === null ? '' : String(text)
|
|
34
|
+
try {
|
|
35
|
+
res.writeHead(code, {
|
|
36
|
+
'content-type': contentType,
|
|
37
|
+
'content-length': Buffer.byteLength(body),
|
|
38
|
+
...SECURITY_HEADERS,
|
|
39
|
+
...extraHeaders,
|
|
40
|
+
})
|
|
41
|
+
res.end(req.method === 'HEAD' ? undefined : body)
|
|
42
|
+
} catch { /* socket 已死:响应无人接收,静默放弃 */ }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function bodyError(code, message) {
|
|
46
|
+
const error = new Error(message)
|
|
47
|
+
error.code = code
|
|
48
|
+
return error
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function readBody(req, limit = 10 * 1024 * 1024) {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
let size = 0
|
|
54
|
+
const chunks = []
|
|
55
|
+
let settled = false
|
|
56
|
+
const fail = (error) => {
|
|
57
|
+
if (settled) return
|
|
58
|
+
settled = true
|
|
59
|
+
reject(error)
|
|
60
|
+
}
|
|
61
|
+
req.on('data', (chunk) => {
|
|
62
|
+
if (settled) return
|
|
63
|
+
size += chunk.length
|
|
64
|
+
if (size > limit) {
|
|
65
|
+
/* 先让路由回 413;立即 destroy 会让客户端只看到 connection reset。 */
|
|
66
|
+
fail(bodyError('BODY_TOO_LARGE', 'body too large'))
|
|
67
|
+
req.resume()
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
chunks.push(chunk)
|
|
71
|
+
})
|
|
72
|
+
req.on('end', () => {
|
|
73
|
+
if (settled) return
|
|
74
|
+
settled = true
|
|
75
|
+
const raw = Buffer.concat(chunks).toString('utf8')
|
|
76
|
+
if (!raw) return resolve({})
|
|
77
|
+
try { resolve(JSON.parse(raw)) } catch { reject(bodyError('BAD_JSON', 'bad json')) }
|
|
78
|
+
})
|
|
79
|
+
req.on('error', (error) => fail(error))
|
|
80
|
+
/* 客户端中途断连且未触发 error/aborted 时(如 curl -m 超时),close 兜底,
|
|
81
|
+
否则 promise 永远 pending,handler 泄漏。 */
|
|
82
|
+
req.on('close', () => {
|
|
83
|
+
if (!req.readableEnded) fail(bodyError('CLIENT_ABORTED', 'client aborted'))
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function intQ(url, name) {
|
|
89
|
+
const value = parseInt(url.searchParams.get(name) || '0', 10)
|
|
90
|
+
return Number.isFinite(value) && value >= 0 ? value : 0
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function listen(port, opts = {}) {
|
|
94
|
+
const defaults = tuning()
|
|
95
|
+
const {
|
|
96
|
+
host = '127.0.0.1',
|
|
97
|
+
requestTimeoutMs = defaults.requestTimeoutMs,
|
|
98
|
+
headersTimeoutMs = defaults.headersTimeoutMs,
|
|
99
|
+
keepAliveTimeoutMs = defaults.keepAliveTimeoutMs,
|
|
100
|
+
handler,
|
|
101
|
+
} = opts
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
const server = handler ? http.createServer(handler) : http.createServer()
|
|
104
|
+
server.requestTimeout = requestTimeoutMs
|
|
105
|
+
server.headersTimeout = headersTimeoutMs
|
|
106
|
+
server.keepAliveTimeout = keepAliveTimeoutMs
|
|
107
|
+
server.on('clientError', (error, socket) => {
|
|
108
|
+
if (socket.writable) socket.end('HTTP/1.1 400 Bad Request\r\n\r\n')
|
|
109
|
+
})
|
|
110
|
+
server.on('error', reject)
|
|
111
|
+
server.listen(port, host, () => resolve(server))
|
|
112
|
+
})
|
|
113
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用 MCP Streamable HTTP 处理器。
|
|
3
|
+
*
|
|
4
|
+
* 只实现工具面所需的最小协议:initialize / ping / tools/list / tools/call。
|
|
5
|
+
* 所有工具调用在进入业务实现前先经过 validateToolArguments。
|
|
6
|
+
*/
|
|
7
|
+
import { readBody, send } from './http.mjs'
|
|
8
|
+
import { validateToolArguments } from '../tools/validate.mjs'
|
|
9
|
+
import { normalizeToolResult } from '../tools/result.mjs'
|
|
10
|
+
|
|
11
|
+
const DEFAULT_PROTOCOL = '2024-11-05'
|
|
12
|
+
|
|
13
|
+
function rpcError(id, code, message, data) {
|
|
14
|
+
const error = { code, message }
|
|
15
|
+
if (data !== undefined) error.data = data
|
|
16
|
+
return { jsonrpc: '2.0', id: id ?? null, error }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function reply(id, result) {
|
|
20
|
+
return { jsonrpc: '2.0', id, result }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createMcpHandler({
|
|
24
|
+
tools = [], callTool, serverInfo, instructions,
|
|
25
|
+
maxBodyBytes = 10 * 1024 * 1024, maxBatch = 100, listChanged = false,
|
|
26
|
+
} = {}) {
|
|
27
|
+
/* tools 可以是静态数组,或一个返回当前数组的函数(活引用)。活引用让
|
|
28
|
+
* tools/list 每次读到最新工具集——registry 动态增删工具后无需重建 handler。 */
|
|
29
|
+
const liveProvider = typeof tools === 'function' ? tools : null
|
|
30
|
+
if (!liveProvider && !Array.isArray(tools)) throw new Error('createMcpHandler: tools 必须是数组或返回数组的函数')
|
|
31
|
+
if (typeof callTool !== 'function') throw new Error('createMcpHandler: callTool 必须是函数')
|
|
32
|
+
|
|
33
|
+
const currentTools = () => {
|
|
34
|
+
const list = liveProvider ? liveProvider() : tools
|
|
35
|
+
return Array.isArray(list) ? list : []
|
|
36
|
+
}
|
|
37
|
+
const toolMapNow = () => new Map(currentTools().map((tool) => [tool.name, tool]))
|
|
38
|
+
|
|
39
|
+
return async function handle(req, res) {
|
|
40
|
+
/* 长工具调用(如截图)期间客户端可能超时断连;socket 的 'error' 事件
|
|
41
|
+
无人监听会打崩进程。挂空处理器,配合 send() 的断连防护。 */
|
|
42
|
+
res.on('error', () => {})
|
|
43
|
+
if (req.method !== 'POST') {
|
|
44
|
+
if (res.destroyed) return
|
|
45
|
+
res.writeHead(405, { allow: 'POST', 'content-type': 'text/plain; charset=utf-8' })
|
|
46
|
+
return res.end('MCP endpoint: POST only')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let msg
|
|
50
|
+
try {
|
|
51
|
+
msg = await readBody(req, maxBodyBytes)
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error?.code === 'BODY_TOO_LARGE') {
|
|
54
|
+
return send(req, res, 413, rpcError(null, -32600, 'Request body too large'))
|
|
55
|
+
}
|
|
56
|
+
return send(req, res, 400, rpcError(null, -32700, 'Parse error'))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!msg || typeof msg !== 'object') {
|
|
60
|
+
return send(req, res, 400, rpcError(null, -32600, 'Invalid Request'))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const batch = Array.isArray(msg)
|
|
64
|
+
if (batch && msg.length === 0) {
|
|
65
|
+
return send(req, res, 400, rpcError(null, -32600, 'Invalid Request'))
|
|
66
|
+
}
|
|
67
|
+
if (batch && msg.length > maxBatch) {
|
|
68
|
+
return send(req, res, 400, rpcError(null, -32600, `Batch too large (max ${maxBatch})`))
|
|
69
|
+
}
|
|
70
|
+
const messages = batch ? msg : [msg]
|
|
71
|
+
const replies = []
|
|
72
|
+
for (const message of messages) {
|
|
73
|
+
const result = await handleOne(message, req)
|
|
74
|
+
if (result !== null) replies.push(result)
|
|
75
|
+
}
|
|
76
|
+
if (!replies.length) {
|
|
77
|
+
if (res.destroyed) return
|
|
78
|
+
res.writeHead(202, { 'content-length': 0 })
|
|
79
|
+
return res.end()
|
|
80
|
+
}
|
|
81
|
+
return send(req, res, 200, batch ? replies : replies[0])
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function handleOne(message, req) {
|
|
85
|
+
if (!message || typeof message !== 'object' || Array.isArray(message)) {
|
|
86
|
+
return rpcError(null, -32600, 'Invalid Request')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const { id, method, params } = message
|
|
90
|
+
const isNotification = id === undefined || id === null
|
|
91
|
+
|
|
92
|
+
if (typeof method !== 'string' || !method) {
|
|
93
|
+
return isNotification ? null : rpcError(id, -32600, 'Invalid Request')
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (method === 'initialize') {
|
|
97
|
+
const result = {
|
|
98
|
+
protocolVersion: String(params?.protocolVersion || DEFAULT_PROTOCOL),
|
|
99
|
+
capabilities: { tools: { listChanged: !!listChanged } },
|
|
100
|
+
serverInfo: serverInfo || { name: 'dsh-plugin', version: '0.0.0' },
|
|
101
|
+
}
|
|
102
|
+
if (typeof instructions === 'string' && instructions) result.instructions = instructions
|
|
103
|
+
return isNotification ? null : reply(id, result)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (method === 'notifications/initialized' || method === 'initialized') return null
|
|
107
|
+
if (method === 'notifications/cancelled' || method === 'notifications/cancel') return null
|
|
108
|
+
if (method === 'ping') return isNotification ? null : reply(id, {})
|
|
109
|
+
|
|
110
|
+
if (method === 'tools/list') {
|
|
111
|
+
return isNotification ? null : reply(id, { tools: currentTools() })
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (method === 'tools/call') {
|
|
115
|
+
const name = params?.name
|
|
116
|
+
const args = params?.arguments && typeof params.arguments === 'object' ? params.arguments : {}
|
|
117
|
+
const tool = toolMapNow().get(name)
|
|
118
|
+
if (!tool) {
|
|
119
|
+
if (isNotification) return null
|
|
120
|
+
return reply(id, {
|
|
121
|
+
content: [{ type: 'text', text: `未知工具: ${String(name)}` }],
|
|
122
|
+
isError: true,
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const check = validateToolArguments(tool, args)
|
|
127
|
+
if (!check.ok) {
|
|
128
|
+
if (isNotification) return null
|
|
129
|
+
return reply(id, {
|
|
130
|
+
content: [{ type: 'text', text: '参数不合法:' + check.errors.join(';') }],
|
|
131
|
+
isError: true,
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
const out = await callTool(name, args, { req })
|
|
137
|
+
/* 归一化保留纯字符串/空 text/对象,不再用 `|| 'ok'` 丢成无信息占位符(B 轴 P0-5)。 */
|
|
138
|
+
return reply(id, normalizeToolResult(out))
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (isNotification) return null
|
|
141
|
+
return reply(id, {
|
|
142
|
+
content: [{ type: 'text', text: '工具失败:' + String((error && error.message) || error) }],
|
|
143
|
+
isError: true,
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return isNotification ? null : rpcError(id, -32601, `Method not found: ${method}`)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 独立 HTTP 服务通用启动器:loopback bind、标准 healthz、HTTP 超时与关闭。
|
|
3
|
+
* 业务路由/认证/静态文件白名单仍由服务自己实现。
|
|
4
|
+
*/
|
|
5
|
+
import { listen, send } from './http.mjs'
|
|
6
|
+
|
|
7
|
+
const LOOPBACK = new Set(['127.0.0.1', 'localhost', '::1', '[::1]'])
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} options
|
|
11
|
+
* @param {string} options.service 服务 id(broker spec.id)
|
|
12
|
+
* @param {number} [options.port=0] 0 表示让 OS 分配端口
|
|
13
|
+
* @param {string} [options.host='127.0.0.1'] 仅允许 loopback
|
|
14
|
+
* @param {(req: import('node:http').IncomingMessage, res: import('node:http').ServerResponse) => any} options.handler 业务路由
|
|
15
|
+
* @param {() => object|Promise<object>} [options.health] healthz 的额外字段
|
|
16
|
+
* @param {string} [options.healthPath='/healthz']
|
|
17
|
+
*/
|
|
18
|
+
export async function startStandaloneService(options = {}) {
|
|
19
|
+
const {
|
|
20
|
+
service,
|
|
21
|
+
port = 0,
|
|
22
|
+
host = '127.0.0.1',
|
|
23
|
+
handler,
|
|
24
|
+
health = () => ({}),
|
|
25
|
+
healthPath = '/healthz',
|
|
26
|
+
requestTimeoutMs,
|
|
27
|
+
headersTimeoutMs,
|
|
28
|
+
keepAliveTimeoutMs,
|
|
29
|
+
} = options
|
|
30
|
+
|
|
31
|
+
if (typeof service !== 'string' || !service.trim()) throw new Error('startStandaloneService 需要 service id')
|
|
32
|
+
if (!LOOPBACK.has(host)) throw new Error(`服务只能绑定 loopback 地址,收到: ${host}`)
|
|
33
|
+
if (!Number.isInteger(Number(port)) || Number(port) < 0 || Number(port) > 65535) {
|
|
34
|
+
throw new Error(`port 必须是 0-65535 整数: ${port}`)
|
|
35
|
+
}
|
|
36
|
+
if (typeof handler !== 'function') throw new Error('startStandaloneService 需要 handler')
|
|
37
|
+
if (typeof health !== 'function') throw new Error('health 必须是函数')
|
|
38
|
+
|
|
39
|
+
let actualPort = Number(port)
|
|
40
|
+
const server = await listen(actualPort, {
|
|
41
|
+
host,
|
|
42
|
+
requestTimeoutMs,
|
|
43
|
+
headersTimeoutMs,
|
|
44
|
+
keepAliveTimeoutMs,
|
|
45
|
+
handler: async (req, res) => {
|
|
46
|
+
let pathname
|
|
47
|
+
try { pathname = new URL(req.url, `http://${host}`).pathname } catch { pathname = '' }
|
|
48
|
+
if (req.method === 'GET' && pathname === healthPath) {
|
|
49
|
+
try {
|
|
50
|
+
const extra = await health({ service, host, port: actualPort })
|
|
51
|
+
send(req, res, 200, {
|
|
52
|
+
...(extra && typeof extra === 'object' ? extra : {}),
|
|
53
|
+
ok: true,
|
|
54
|
+
service,
|
|
55
|
+
pid: process.pid,
|
|
56
|
+
port: actualPort,
|
|
57
|
+
})
|
|
58
|
+
} catch (error) {
|
|
59
|
+
send(req, res, 503, {
|
|
60
|
+
ok: false,
|
|
61
|
+
service,
|
|
62
|
+
pid: process.pid,
|
|
63
|
+
port: actualPort,
|
|
64
|
+
error: String(error?.message || error),
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
return handler(req, res)
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const address = server.address()
|
|
74
|
+
actualPort = address && typeof address === 'object' ? address.port : actualPort
|
|
75
|
+
let closePromise
|
|
76
|
+
const close = () => {
|
|
77
|
+
if (closePromise) return closePromise
|
|
78
|
+
closePromise = new Promise((resolve, reject) => {
|
|
79
|
+
if (!server.listening) return resolve()
|
|
80
|
+
server.close((error) => error ? reject(error) : resolve())
|
|
81
|
+
server.closeIdleConnections?.()
|
|
82
|
+
})
|
|
83
|
+
return closePromise
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
server,
|
|
88
|
+
service,
|
|
89
|
+
host,
|
|
90
|
+
port: actualPort,
|
|
91
|
+
url: `http://${host.includes(':') && !host.startsWith('[') ? `[${host}]` : host}:${actualPort}`,
|
|
92
|
+
close,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Standalone entrypoint helper for broker-managed services. Call this only from
|
|
98
|
+
* the executable entrypoint, never from a Cordis apply().
|
|
99
|
+
*/
|
|
100
|
+
export function installServiceSignalHandlers(instance, {
|
|
101
|
+
processRef = process,
|
|
102
|
+
logger = console,
|
|
103
|
+
exit = (code) => processRef.exit(code),
|
|
104
|
+
timeoutMs = 3000,
|
|
105
|
+
} = {}) {
|
|
106
|
+
if (!instance || typeof instance.close !== 'function') throw new Error('需要 startStandaloneService 返回的 instance')
|
|
107
|
+
let closing = false
|
|
108
|
+
const handlers = new Map()
|
|
109
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
110
|
+
const handler = () => {
|
|
111
|
+
if (closing) return
|
|
112
|
+
closing = true
|
|
113
|
+
logger.info?.(`[${instance.service}] 收到 ${signal},正在关闭`)
|
|
114
|
+
const timer = setTimeout(() => exit(1), timeoutMs)
|
|
115
|
+
timer.unref?.()
|
|
116
|
+
Promise.resolve(instance.close()).then(() => {
|
|
117
|
+
clearTimeout(timer)
|
|
118
|
+
exit(0)
|
|
119
|
+
}, (error) => {
|
|
120
|
+
clearTimeout(timer)
|
|
121
|
+
logger.error?.(`[${instance.service}] 关闭失败: ${error.message}`)
|
|
122
|
+
exit(1)
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
handlers.set(signal, handler)
|
|
126
|
+
processRef.once(signal, handler)
|
|
127
|
+
}
|
|
128
|
+
return () => {
|
|
129
|
+
for (const [signal, handler] of handlers) processRef.removeListener(signal, handler)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 静态文件服务公共核心(P2-13a)。
|
|
3
|
+
*
|
|
4
|
+
* service-host 与 editor-host 各有一套静态文件服务,其中「路径穿越防护 / 挂载前缀
|
|
5
|
+
* 归一与命中 / 相对路径解码 / files 显式映射 / 基础响应头」这几段逻辑逐字重复。
|
|
6
|
+
* 这里把它们收敛成一组纯函数作为单一真源,两个宿主都 import 本文件,不再各写一份。
|
|
7
|
+
*
|
|
8
|
+
* 边界(刻意不收敛的部分):本文件只做「无 IO 的路径/头部计算」,不碰响应政策。
|
|
9
|
+
* 两宿主的行为差异必须各自保留——
|
|
10
|
+
* - 畸形百分号编码:service-host 回 400,editor-host 交还路由链(return false);
|
|
11
|
+
* - 目录入口补尾斜杠 301、ETag/gzip/304/vary:仅 editor-host;
|
|
12
|
+
* - content-type 取值:service-host 用 mimeFor(请求 rel) + explicitType,
|
|
13
|
+
* editor-host 用 mimeFor(落盘文件路径);
|
|
14
|
+
* - 读盘策略:service-host 每次 readFileSync,editor-host 走 (size,mtime) 缓存。
|
|
15
|
+
* 因此 decodeStaticRel 畸形时返回 null(而非抛错/替宿主回响应),由调用方决定 400 还是放行。
|
|
16
|
+
*
|
|
17
|
+
* 只依赖 node 内置(node:path),不 import 本包其它文件,不成环(与 util/http.mjs 同风格)。
|
|
18
|
+
*/
|
|
19
|
+
import path from 'node:path'
|
|
20
|
+
|
|
21
|
+
/** 路径穿越防护:只允许落在 root 内(含 root 自身),越界返回 null。两宿主共用。 */
|
|
22
|
+
export function safeJoin(root, rel) {
|
|
23
|
+
const target = path.resolve(root, `.${path.sep}${rel}`)
|
|
24
|
+
const base = path.resolve(root)
|
|
25
|
+
return target === base || target.startsWith(base + path.sep) ? target : null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 挂载前缀归一:'/' → ''(挂全部);其余去掉尾斜杠。空/缺省按 '' 处理。 */
|
|
29
|
+
export function cleanStaticPrefix(prefix) {
|
|
30
|
+
return prefix === '/' ? '' : String(prefix || '').replace(/\/+$/, '')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 前缀命中:空前缀命中一切;非空须精确等于前缀或其子路径。 */
|
|
34
|
+
export function staticPrefixHit(pathname, prefix) {
|
|
35
|
+
return !prefix || pathname === prefix || pathname.startsWith(prefix + '/')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 去掉挂载前缀后的原始相对路径(未解码)。 */
|
|
39
|
+
export function staticRelRaw(pathname, prefix) {
|
|
40
|
+
return prefix ? pathname.slice(prefix.length) : pathname
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 解码相对路径:空/'/' 落到 index;其余去掉 leading 斜杠后 decodeURIComponent。
|
|
45
|
+
* 畸形百分号编码(URIError)返回 null——由宿主决定回 400(service-host)还是
|
|
46
|
+
* 交还路由链(editor-host),本核心不替宿主做响应政策。
|
|
47
|
+
*/
|
|
48
|
+
export function decodeStaticRel(relRaw, index = 'index.html') {
|
|
49
|
+
try {
|
|
50
|
+
return relRaw === '' || relRaw === '/' ? index : decodeURIComponent(relRaw.replace(/^\/+/, ''))
|
|
51
|
+
} catch {
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** files 显式映射查表:relRaw 为空时用 '/' 键;未命中返回 null(宿主交还路由链)。 */
|
|
57
|
+
export function staticFileHit(files, relRaw) {
|
|
58
|
+
if (!files) return null
|
|
59
|
+
return files[relRaw === '' ? '/' : relRaw] || files[relRaw] || null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** 映射条目 → [文件名, 显式 content-type(可空)]。字符串条目无显式 type。 */
|
|
63
|
+
export function staticHitNameType(hit) {
|
|
64
|
+
return Array.isArray(hit) ? [hit[0], hit[1]] : [hit, undefined]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 静态 200 基础响应头:content-type/length + 安全与缓存政策(两宿主一致的五项)。
|
|
69
|
+
* no-cache = 允许缓存但每次回源校验;editor-host 会在此之上追加 etag/vary。
|
|
70
|
+
*/
|
|
71
|
+
export function staticBaseHeaders(type, length) {
|
|
72
|
+
return {
|
|
73
|
+
'content-type': type,
|
|
74
|
+
'content-length': length,
|
|
75
|
+
'x-content-type-options': 'nosniff',
|
|
76
|
+
'referrer-policy': 'no-referrer',
|
|
77
|
+
'cache-control': 'no-cache',
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** 通用 skill provider:从目录扫描 kebab-case SKILL.md,按需加载正文。 */
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import { isAbsolute, join, sep } from 'node:path'
|
|
5
|
+
|
|
6
|
+
const NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
|
|
7
|
+
const RANK = 600
|
|
8
|
+
|
|
9
|
+
function parseSkill(raw, path) {
|
|
10
|
+
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u.exec(raw)
|
|
11
|
+
if (!frontmatter?.[1]) throw new Error(`skill ${path} 缺少 YAML frontmatter`)
|
|
12
|
+
const meta = {}
|
|
13
|
+
for (const line of frontmatter[1].split(/\r?\n/)) {
|
|
14
|
+
const match = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line)
|
|
15
|
+
if (match) meta[match[1]] = match[2].replace(/^['"]|['"]$/g, '').trim()
|
|
16
|
+
}
|
|
17
|
+
if (!meta.name || !meta.description) throw new Error(`skill ${path} 缺少 name/description`)
|
|
18
|
+
if (!NAME_RE.test(meta.name)) throw new Error(`skill ${path} name 必须是 kebab-case`)
|
|
19
|
+
return {
|
|
20
|
+
name: meta.name,
|
|
21
|
+
description: meta.description,
|
|
22
|
+
whenToUse: meta.whenToUse || undefined,
|
|
23
|
+
content: raw.slice(frontmatter[0].length).trim(),
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {{
|
|
29
|
+
* assetRoot: string,
|
|
30
|
+
* skillDirs: string[],
|
|
31
|
+
* providerName?: string,
|
|
32
|
+
* contractRoot?: string,
|
|
33
|
+
* contractNote?: (version: string) => string
|
|
34
|
+
* }} config
|
|
35
|
+
*/
|
|
36
|
+
export function createSkillProvider(config) {
|
|
37
|
+
const assetRoot = config.assetRoot
|
|
38
|
+
if (!assetRoot || !isAbsolute(assetRoot)) throw new Error('createSkillProvider: assetRoot 必须是绝对路径')
|
|
39
|
+
let contract = null
|
|
40
|
+
if (config.contractRoot) {
|
|
41
|
+
try {
|
|
42
|
+
contract = JSON.parse(readFileSync(join(config.contractRoot, config.contractFile || 'contract.json'), 'utf8'))
|
|
43
|
+
} catch { /* 非技能包可以没有契约快照 */ }
|
|
44
|
+
}
|
|
45
|
+
const dirs = config.skillDirs || []
|
|
46
|
+
if (!dirs.length) throw new Error('createSkillProvider: skillDirs 不能为空')
|
|
47
|
+
const candidates = dirs.map((dir) => {
|
|
48
|
+
const directory = join(assetRoot, dir)
|
|
49
|
+
const locator = join(directory, 'SKILL.md')
|
|
50
|
+
const parsed = parseSkill(readFileSync(locator, 'utf8'), locator)
|
|
51
|
+
if (parsed.name !== dir) throw new Error(`skill ${locator} name 必须是 ${dir}`)
|
|
52
|
+
return {
|
|
53
|
+
name: parsed.name,
|
|
54
|
+
description: parsed.description,
|
|
55
|
+
whenToUse: parsed.whenToUse,
|
|
56
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
57
|
+
provider: config.providerName || 'dsh-plugin',
|
|
58
|
+
source: 'bundled',
|
|
59
|
+
rank: RANK,
|
|
60
|
+
resourceBase: { kind: 'directory', path: directory.split(sep).join('/') },
|
|
61
|
+
locator,
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
const byName = new Map(candidates.map((candidate) => [candidate.name, candidate]))
|
|
65
|
+
const noteFor = (name) => (contract && config.contractNote
|
|
66
|
+
? config.contractNote(contract.contractVersion, name)
|
|
67
|
+
: '')
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
name: config.providerName || 'dsh-plugin',
|
|
71
|
+
list: () => Promise.resolve(candidates),
|
|
72
|
+
async get(candidate, options = {}) {
|
|
73
|
+
const hit = byName.get(candidate.name)
|
|
74
|
+
if (!hit) throw new Error(`未知 skill ${candidate.name}`)
|
|
75
|
+
const raw = await readFile(hit.locator, { encoding: 'utf8', signal: options.signal })
|
|
76
|
+
const parsed = parseSkill(raw, hit.locator)
|
|
77
|
+
const { rank: _rank, locator: _locator, ...summary } = hit
|
|
78
|
+
const note = noteFor(candidate.name)
|
|
79
|
+
return { ...summary, content: parsed.content + (note ? `\n\n---\n\n${note}` : '') }
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
}
|