@twinsearth/dsh-fang 3.3.2 → 3.7.7
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/README.md +5 -5
- package/client.js +674 -60
- package/cordis.patch.yml +26 -20
- package/docs/APPROVAL-DRILL.md +42 -0
- package/docs/AUTO-WATCHDOG.md +46 -0
- package/docs/DECISION-LOSSLESS.md +36 -0
- package/docs/ESSENCE-AUTO-SYNC.md +32 -0
- package/docs/INBOX-SCROLL.md +33 -0
- package/docs/PACKAGE-RENAME-v3.3.3.md +40 -0
- package/docs/RESTART-CONFIRMATION.md +29 -0
- package/docs/TEST-STABILITY-v3.4.0.md +30 -0
- package/package.json +11 -7
- package/src/compose.mjs +4 -1
- package/src/contract/VENDOR.json +6 -5
- package/src/contract/constants.js +16 -1
- package/src/contract/relay.js +12 -6
- package/src/kernel/types.mjs +3 -1
- package/src/lib/accelerated-fork.mjs +813 -0
- package/src/lib/accelerated-install.mjs +295 -0
- package/src/lib/accelerated-web.mjs +103 -0
- package/src/lib/approval-drill.mjs +111 -0
- package/src/lib/boot-guard.mjs +6 -2
- package/src/lib/chat-import-delegation.mjs +47 -0
- package/src/lib/compat.mjs +5 -1
- package/src/lib/contract-delegation.mjs +161 -0
- package/src/lib/default-essence.mjs +7 -4
- package/src/lib/essence.mjs +113 -7
- package/src/lib/fork-config-lock.mjs +2 -2
- package/src/lib/fork-core-settings.mjs +95 -0
- package/src/lib/fork-export.mjs +85 -0
- package/src/lib/global-redline.mjs +164 -0
- package/src/lib/http-auth.mjs +36 -0
- package/src/lib/install-snapshot.mjs +77 -0
- package/src/lib/lsp-delegation.mjs +70 -0
- package/src/lib/lsp-provider.mjs +250 -0
- package/src/lib/main-gate.mjs +33 -28
- package/src/lib/mirror.mjs +115 -4
- package/src/lib/node-compat.mjs +24 -0
- package/src/lib/pro-delegation.mjs +185 -0
- package/src/lib/runtime-capture.mjs +11 -3
- package/src/lib/watch-guard.mjs +51 -0
- package/src/plugins/approver.mjs +5 -2
- package/src/plugins/auditor.mjs +125 -18
- package/src/plugins/decision-center.mjs +77 -34
- package/src/plugins/forker.mjs +258 -33
- package/src/plugins/orchestrator.mjs +1508 -65
- package/src/plugins/restart-guard.mjs +79 -2
- package/src/plugins/session-catalog.mjs +127 -40
- package/tools/approval-drill.mjs +21 -0
- package/tools/fangctl.mjs +21 -4
- package/tools/gate/main-city.mjs +1 -1
- package/tools/restart-supervisor.mjs +425 -0
- package/tools/restart-watchdog.mjs +568 -0
- package/vault/client.js +49 -0
- package/vault/cordis.patch.yml +3 -0
- package/vault/lib/vault.mjs +219 -0
- package/vault/package.json +29 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Global red line for every Fang fork: a fork process may write its own DSH_HOME,
|
|
3
|
+
// but never the mother profile/client install, mother data, or another fork home.
|
|
4
|
+
// This is an in-process guard, not an OS sandbox: a child process spawned by a
|
|
5
|
+
// plugin is outside its reach, so deploy-time ACL is still the hard boundary.
|
|
6
|
+
import fs from 'node:fs'
|
|
7
|
+
import os from 'node:os'
|
|
8
|
+
import path from 'node:path'
|
|
9
|
+
|
|
10
|
+
const MARK = Symbol.for('dsh-fang.global-redline')
|
|
11
|
+
const WRITE_FLAGS = /[wa+]/i
|
|
12
|
+
|
|
13
|
+
function norm(p) {
|
|
14
|
+
const value = path.resolve(String(p ?? ''))
|
|
15
|
+
try { return fs.realpathSync.native(value) } catch { /* may not exist */ }
|
|
16
|
+
let parent = path.dirname(value)
|
|
17
|
+
const tail = [path.basename(value)]
|
|
18
|
+
for (let i = 0; i < 20; i += 1) {
|
|
19
|
+
try {
|
|
20
|
+
const real = fs.realpathSync.native(parent)
|
|
21
|
+
return path.join(real, ...tail)
|
|
22
|
+
} catch {
|
|
23
|
+
const next = path.dirname(parent)
|
|
24
|
+
if (next === parent) break
|
|
25
|
+
tail.unshift(path.basename(parent))
|
|
26
|
+
parent = next
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return value
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isUnder(child, parent) {
|
|
33
|
+
const c = norm(child)
|
|
34
|
+
const p = norm(parent)
|
|
35
|
+
return c === p || c.startsWith(p.endsWith(path.sep) ? p : p + path.sep)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function installGlobalRedline({
|
|
39
|
+
ownHome,
|
|
40
|
+
motherData,
|
|
41
|
+
profilesRoot = path.join(os.homedir(), '.dsh', 'profiles'),
|
|
42
|
+
installRoot = path.dirname(process.execPath),
|
|
43
|
+
logger = null,
|
|
44
|
+
} = {}) {
|
|
45
|
+
if (globalThis[MARK]?.installed) return { ok: true, already: true, protected: globalThis[MARK].protected }
|
|
46
|
+
const own = String(ownHome ?? process.env.DSH_HOME ?? '')
|
|
47
|
+
if (!own) return { ok: false, error: 'own-home-missing' }
|
|
48
|
+
const mother = String(motherData ?? process.env.DSH_FANG_MOTHER ?? '')
|
|
49
|
+
const protectedRoots = [
|
|
50
|
+
profilesRoot,
|
|
51
|
+
installRoot,
|
|
52
|
+
mother ? path.join(mother, 'essences') : '',
|
|
53
|
+
mother ? path.join(mother, 'runtime') : '',
|
|
54
|
+
mother ? path.join(mother, 'forks') : '',
|
|
55
|
+
mother ? path.join(mother, '.plugin-manager') : '',
|
|
56
|
+
mother ? path.join(mother, 'mirror') : '',
|
|
57
|
+
mother ? path.join(mother, 'tasks') : '',
|
|
58
|
+
mother ? path.join(mother, 'endpoint.json') : '',
|
|
59
|
+
mother ? path.join(mother, 'tasks.json') : '',
|
|
60
|
+
mother ? path.join(mother, 'audit.jsonl') : '',
|
|
61
|
+
mother ? path.join(mother, 'fang-auth.json') : '',
|
|
62
|
+
mother ? path.join(mother, 'default-essence.json') : '',
|
|
63
|
+
mother ? path.join(mother, 'decision-center.json') : '',
|
|
64
|
+
].filter(Boolean)
|
|
65
|
+
|
|
66
|
+
const deny = (target, action) => {
|
|
67
|
+
const message = `[fang-global-redline] 分身禁止 ${action} 母体/客户端/其他分身路径:${target}`
|
|
68
|
+
const error = new Error(message)
|
|
69
|
+
error.code = 'EPERM'
|
|
70
|
+
error.fangRedline = true
|
|
71
|
+
try { logger?.error?.(message) } catch { /* ignore */ }
|
|
72
|
+
try {
|
|
73
|
+
const logDir = path.join(own, 'fang')
|
|
74
|
+
fs.mkdirSync(logDir, { recursive: true })
|
|
75
|
+
fs.appendFileSync(path.join(logDir, 'global-redline.log'), `${new Date().toISOString()} ${message}\n`)
|
|
76
|
+
} catch { /* ignore */ }
|
|
77
|
+
return error
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const check = (target, action) => {
|
|
81
|
+
if (typeof target !== 'string' && !(target instanceof URL)) return null
|
|
82
|
+
const value = target instanceof URL ? target.pathname : target
|
|
83
|
+
if (!value) return null
|
|
84
|
+
const resolved = path.resolve(String(value))
|
|
85
|
+
if (isUnder(resolved, own)) return null
|
|
86
|
+
for (const root of protectedRoots) {
|
|
87
|
+
if (isUnder(resolved, root)) return deny(resolved, action)
|
|
88
|
+
}
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const guardArgs = (action, indexes) => (args) => {
|
|
93
|
+
for (const index of indexes) {
|
|
94
|
+
const error = check(args[index], action)
|
|
95
|
+
if (error) throw error
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const wrap = (owner, name, action, indexes) => {
|
|
100
|
+
const original = owner?.[name]
|
|
101
|
+
if (typeof original !== 'function') return
|
|
102
|
+
const guard = guardArgs(action, indexes)
|
|
103
|
+
owner[name] = function guarded(...args) {
|
|
104
|
+
guard(args)
|
|
105
|
+
return original.apply(this, args)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const fsPromises = fs.promises
|
|
110
|
+
const syncSpecs = [
|
|
111
|
+
['writeFileSync', [0]], ['appendFileSync', [0]], ['renameSync', [0, 1]],
|
|
112
|
+
['copyFileSync', [1]], ['cpSync', [1]], ['unlinkSync', [0]], ['rmSync', [0]],
|
|
113
|
+
['rmdirSync', [0]], ['mkdirSync', [0]], ['symlinkSync', [1]], ['linkSync', [1]],
|
|
114
|
+
['chmodSync', [0]], ['truncateSync', [0]],
|
|
115
|
+
]
|
|
116
|
+
for (const [name, indexes] of syncSpecs) wrap(fs, name, name.replace(/Sync$/, ''), indexes)
|
|
117
|
+
const asyncSpecs = [
|
|
118
|
+
['writeFile', [0]], ['appendFile', [0]], ['rename', [0, 1]], ['copyFile', [1]],
|
|
119
|
+
['cp', [1]], ['unlink', [0]], ['rm', [0]], ['rmdir', [0]], ['mkdir', [0]],
|
|
120
|
+
['symlink', [1]], ['link', [1]], ['chmod', [0]], ['truncate', [0]],
|
|
121
|
+
]
|
|
122
|
+
for (const [name, indexes] of asyncSpecs) wrap(fs, name, name, indexes)
|
|
123
|
+
for (const [name, indexes] of asyncSpecs) wrap(fsPromises, name, `promises.${name}`, indexes)
|
|
124
|
+
|
|
125
|
+
const isWriteFlags = (flags) => {
|
|
126
|
+
if (flags === undefined) return true
|
|
127
|
+
if (typeof flags === 'number') {
|
|
128
|
+
const c = fs.constants
|
|
129
|
+
return (flags & (c.O_WRONLY | c.O_RDWR | c.O_CREAT | c.O_TRUNC | c.O_APPEND)) !== 0
|
|
130
|
+
}
|
|
131
|
+
return WRITE_FLAGS.test(String(flags))
|
|
132
|
+
}
|
|
133
|
+
const wrapOpen = (owner, name, label) => {
|
|
134
|
+
const original = owner?.[name]
|
|
135
|
+
if (typeof original !== 'function') return
|
|
136
|
+
owner[name] = function guardedOpen(target, flags, ...rest) {
|
|
137
|
+
if (isWriteFlags(flags)) {
|
|
138
|
+
const error = check(target, label)
|
|
139
|
+
if (error) throw error
|
|
140
|
+
}
|
|
141
|
+
return original.call(this, target, flags, ...rest)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
wrapOpen(fs, 'openSync', 'openSync')
|
|
145
|
+
wrapOpen(fs, 'open', 'open')
|
|
146
|
+
wrapOpen(fsPromises, 'open', 'promises.open')
|
|
147
|
+
|
|
148
|
+
const originalCreateWriteStream = fs.createWriteStream
|
|
149
|
+
if (typeof originalCreateWriteStream === 'function') {
|
|
150
|
+
fs.createWriteStream = function guardedCreateWriteStream(target, ...rest) {
|
|
151
|
+
const error = check(target, 'createWriteStream')
|
|
152
|
+
if (error) throw error
|
|
153
|
+
return originalCreateWriteStream.call(this, target, ...rest)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const state = { installed: true, protected: protectedRoots, ownHome: own }
|
|
158
|
+
globalThis[MARK] = state
|
|
159
|
+
return { ok: true, installed: true, protected: protectedRoots, ownHome: own }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function globalRedlineInstalled() {
|
|
163
|
+
return globalThis[MARK]?.installed === true
|
|
164
|
+
}
|
package/src/lib/http-auth.mjs
CHANGED
|
@@ -50,6 +50,22 @@ export function isLoopbackHost(host) {
|
|
|
50
50
|
return match[1] === 'localhost' || match[1] === '127.0.0.1'
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/** IPv4/IPv6 回环地址判定(含 IPv4-mapped ::ffff:127.0.0.1)。 */
|
|
54
|
+
export function isLoopbackAddress(address) {
|
|
55
|
+
const raw = String(address ?? '').trim().toLowerCase()
|
|
56
|
+
if (!raw) return false
|
|
57
|
+
if (raw === '::1' || raw === '0:0:0:0:0:0:0:1') return true
|
|
58
|
+
const mapped = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/.exec(raw)
|
|
59
|
+
if (mapped) return isLoopbackAddress(mapped[1])
|
|
60
|
+
const v4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(raw)
|
|
61
|
+
if (v4) {
|
|
62
|
+
const octets = v4.slice(1).map((part) => Number(part))
|
|
63
|
+
if (octets.some((part) => part > 255)) return false
|
|
64
|
+
return octets[0] === 127
|
|
65
|
+
}
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
/** Origin 是否允许(同源 loopback / dsh-app 壳 / 无 Origin)。 */
|
|
54
70
|
export function isAllowedOrigin(origin) {
|
|
55
71
|
const raw = String(origin ?? '').trim()
|
|
@@ -97,6 +113,26 @@ export function checkRequestAuth(req, options) {
|
|
|
97
113
|
if (site && site !== 'same-origin' && site !== 'same-site' && site !== 'none') {
|
|
98
114
|
return { ok: false, status: 403, code: 'cross-site' }
|
|
99
115
|
}
|
|
116
|
+
// v3.5.5(安全):bootstrap 路由(/fang/api/auth-token)收紧为「仅同源页面 + 本机回环 peer」:
|
|
117
|
+
// 拒绝对端非回环、拒绝 same-site(localhost 不同端口也属 same-site)、Origin 的 host:port 必须
|
|
118
|
+
// 与 Host 完全一致。浏览器跨站页面读不到响应(CORS),再加 Host/Origin 绑定。
|
|
119
|
+
// 注意:同机同用户进程仍可自行读 0600 token 文件——本层只收紧浏览器侧攻击面,不宣称进程隔离。
|
|
120
|
+
if (options?.bootstrap === true) {
|
|
121
|
+
const peer = String(req?.socket?.remoteAddress ?? req?.connection?.remoteAddress ?? '').trim()
|
|
122
|
+
if (peer && !isLoopbackAddress(peer)) return { ok: false, status: 403, code: 'non-loopback-peer' }
|
|
123
|
+
if (site && site !== 'same-origin' && site !== 'none') return { ok: false, status: 403, code: 'cross-site' }
|
|
124
|
+
if (origin) {
|
|
125
|
+
const raw = String(origin).trim()
|
|
126
|
+
if (!(raw === 'dsh-app://app' || raw.startsWith('dsh-app://'))) {
|
|
127
|
+
let parsed = null
|
|
128
|
+
try { parsed = new URL(raw) } catch { return { ok: false, status: 403, code: 'bad-origin' } }
|
|
129
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return { ok: false, status: 403, code: 'bad-origin' }
|
|
130
|
+
if (String(parsed.host).toLowerCase() !== String(host).toLowerCase()) {
|
|
131
|
+
return { ok: false, status: 403, code: 'origin-mismatch' }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
100
136
|
if (options?.publicRoute === true) return { ok: true }
|
|
101
137
|
const given = header(req, AUTH_HEADER) || (() => {
|
|
102
138
|
const auth = header(req, 'authorization')
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// src/lib/install-snapshot.mjs — P2:每版本独立、不可变的 DSH 安装快照。
|
|
3
|
+
//
|
|
4
|
+
// 目标:分身使用自己的安装副本,而不是 DSH Desktop 正在运行的 D:\DSH 安装树。
|
|
5
|
+
// 实现:在安装卷上创建 `.fang-installs/dsh-<version>-<hash>`,对安装文件做 hardlink
|
|
6
|
+
// (同卷零拷贝;安装升级写入新 inode,旧快照保持原版本)。每个分身的 CLI 指向自己的
|
|
7
|
+
// 快照路径,母体升级/替换安装文件不会改变运行中分身解析到的代码。
|
|
8
|
+
import fs from 'node:fs'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
import { createHash } from 'node:crypto'
|
|
11
|
+
import { ensureDir, exists, hardlinkTree } from '../kernel/index.mjs'
|
|
12
|
+
|
|
13
|
+
function sha256(text) {
|
|
14
|
+
return createHash('sha256').update(text).digest('hex')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Derive the install root from a `<root>/resources/runtime/cli/bin/dsh.cmd` path. */
|
|
18
|
+
export function installRootOf(cliPath) {
|
|
19
|
+
const resolved = path.resolve(String(cliPath ?? ''))
|
|
20
|
+
const resources = path.resolve(path.dirname(resolved), '../../..')
|
|
21
|
+
return path.dirname(resources)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function readMarker(file) {
|
|
25
|
+
try { return JSON.parse(fs.readFileSync(file, 'utf8')) } catch { return null }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Ensure an immutable install snapshot for the given launcher.
|
|
30
|
+
* @param {{cliPath:string, version:string, rootDir?:string, force?:boolean}} options
|
|
31
|
+
* @returns {{ok:boolean, cliPath:string, root:string|null, created:boolean, fallback:boolean, error?:string}}
|
|
32
|
+
*/
|
|
33
|
+
export function ensureInstallSnapshot({ cliPath, version, rootDir = '', force = false } = {}) {
|
|
34
|
+
const original = String(cliPath ?? '').trim()
|
|
35
|
+
if (!original) return { ok: false, cliPath: '', root: null, created: false, fallback: true, error: 'no-cli-path' }
|
|
36
|
+
let root
|
|
37
|
+
try { root = installRootOf(original) } catch { root = '' }
|
|
38
|
+
if (!root || !exists(original)) return { ok: false, cliPath: original, root: null, created: false, fallback: true, error: 'install-root-missing' }
|
|
39
|
+
const appAsar = path.join(root, 'resources', 'app.asar')
|
|
40
|
+
let stat = null
|
|
41
|
+
try { stat = fs.statSync(appAsar) } catch { /* non-asar install */ }
|
|
42
|
+
const fingerprint = sha256(`${version}:${stat?.size ?? 0}:${stat?.mtimeMs ?? 0}`).slice(0, 12)
|
|
43
|
+
const snapshotsDir = path.resolve(rootDir || path.join(root, '.fang-installs'))
|
|
44
|
+
const snapshotRoot = path.join(snapshotsDir, `dsh-${version}-${fingerprint}`)
|
|
45
|
+
const markerFile = path.join(snapshotRoot, '.fang-install-snapshot.json')
|
|
46
|
+
const marker = readMarker(markerFile)
|
|
47
|
+
if (!force && marker?.version === version && exists(path.join(snapshotRoot, 'resources', 'runtime', 'cli', 'bin', 'dsh.cmd'))) {
|
|
48
|
+
return { ok: true, cliPath: path.join(snapshotRoot, 'resources', 'runtime', 'cli', 'bin', 'dsh.cmd'), root: snapshotRoot, created: false, fallback: false }
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
ensureDir(snapshotsDir)
|
|
52
|
+
const tmp = `${snapshotRoot}.tmp-${process.pid}-${Date.now()}`
|
|
53
|
+
fs.rmSync(tmp, { recursive: true, force: true })
|
|
54
|
+
ensureDir(tmp)
|
|
55
|
+
// Copy the install root's top-level entries except the snapshot store itself.
|
|
56
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
|
|
57
|
+
if (entry.name === path.basename(snapshotsDir)) continue
|
|
58
|
+
const from = path.join(root, entry.name)
|
|
59
|
+
const to = path.join(tmp, entry.name)
|
|
60
|
+
if (entry.isDirectory()) {
|
|
61
|
+
ensureDir(to)
|
|
62
|
+
hardlinkTree(from, to)
|
|
63
|
+
} else if (entry.isFile()) {
|
|
64
|
+
ensureDir(path.dirname(to))
|
|
65
|
+
try { fs.linkSync(from, to) } catch { fs.copyFileSync(from, to) }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
fs.writeFileSync(path.join(tmp, '.fang-install-snapshot.json'), JSON.stringify({
|
|
69
|
+
at: new Date().toISOString(), version, fingerprint, sourceRoot: root, sourceCli: original,
|
|
70
|
+
}, null, 2) + '\n')
|
|
71
|
+
fs.rmSync(snapshotRoot, { recursive: true, force: true })
|
|
72
|
+
fs.renameSync(tmp, snapshotRoot)
|
|
73
|
+
return { ok: true, cliPath: path.join(snapshotRoot, 'resources', 'runtime', 'cli', 'bin', 'dsh.cmd'), root: snapshotRoot, created: true, fallback: false }
|
|
74
|
+
} catch (error) {
|
|
75
|
+
return { ok: false, cliPath: original, root: null, created: false, fallback: true, error: String(error?.message ?? error) }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (c) 2026 dsh-Fang contributors — see LICENSE-CORE.
|
|
3
|
+
// B-6:LSP 委托(fang.tool.invoke: lsp)——已按官方能力缝口径对齐。
|
|
4
|
+
// 官方 DSH LSP 能力缝(ctx.lsp)只提供 4 个只读操作:
|
|
5
|
+
// goToDefinition / findReferences / goToImplementation / hover,
|
|
6
|
+
// 契约侧动作名统一为 definition / references / implementation / hover。
|
|
7
|
+
// 官方能力缝刻意不提供 diagnostics / format / rename / symbols / 通用 JSON-RPC:
|
|
8
|
+
// - diagnostics 只允许 e2e 测试缝(FANG_CONTRACT_TEST_HOOKS=1),不对外 advertise;
|
|
9
|
+
// - format/rename 等写类动作对官方 provider 一律 contract-unsupported,审批门禁保留给未来自定义 provider。
|
|
10
|
+
// 接真实 provider 时按“实提供能力”advertise(见 lsp-provider.advertisedActionsFromSeam)。
|
|
11
|
+
// 执行提供方:母体 LSP provider(路线 A,优先);加速分身本地 provider(路线 B,增强)。
|
|
12
|
+
|
|
13
|
+
export const LSP_READ_ACTIONS = Object.freeze(['definition', 'references', 'implementation', 'hover'])
|
|
14
|
+
/** 官方能力缝只读;保留空数组让未来自定义 provider 显式登记写类动作。 */
|
|
15
|
+
export const LSP_WRITE_ACTIONS = Object.freeze([])
|
|
16
|
+
/** 仅 e2e 测试缝可用的动作(不进入能力目录、不对外 advertise)。 */
|
|
17
|
+
export const LSP_TEST_ACTIONS = Object.freeze(['diagnostics'])
|
|
18
|
+
export const LSP_ACTIONS = Object.freeze([...LSP_READ_ACTIONS, ...LSP_WRITE_ACTIONS, ...LSP_TEST_ACTIONS])
|
|
19
|
+
|
|
20
|
+
/** 契约动作 → 官方 seam 操作名。 */
|
|
21
|
+
export const LSP_ACTION_TO_OPERATION = Object.freeze({
|
|
22
|
+
definition: 'goToDefinition',
|
|
23
|
+
references: 'findReferences',
|
|
24
|
+
implementation: 'goToImplementation',
|
|
25
|
+
hover: 'hover',
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
/** 历史设计里出现过、但官方能力缝明确不提供的动作(用于可读拒绝)。 */
|
|
29
|
+
export const LSP_UNSUPPORTED_LEGACY_ACTIONS = Object.freeze(['format', 'rename', 'codeAction', 'apply'])
|
|
30
|
+
|
|
31
|
+
/** Pure: classify an lsp action (official seam is read-only; diagnostics is test-only). */
|
|
32
|
+
export function classifyLspAction(action) {
|
|
33
|
+
const text = String(action ?? '').trim()
|
|
34
|
+
if (LSP_READ_ACTIONS.includes(text)) return { ok: true, action: text, kind: 'read', approval: 'none', operation: LSP_ACTION_TO_OPERATION[text] }
|
|
35
|
+
if (LSP_WRITE_ACTIONS.includes(text)) return { ok: true, action: text, kind: 'write', approval: 'required' }
|
|
36
|
+
if (LSP_TEST_ACTIONS.includes(text)) return { ok: true, action: text, kind: 'test-only', approval: 'none' }
|
|
37
|
+
if (LSP_UNSUPPORTED_LEGACY_ACTIONS.includes(text)) {
|
|
38
|
+
return { ok: false, error: 'contract-unsupported', message: `official LSP seam is read-only; action '${text}' is not provided (no format/rename/codeAction/apply)` }
|
|
39
|
+
}
|
|
40
|
+
return { ok: false, error: 'contract-invalid-request', message: `unknown lsp action: ${text || '(empty)'}` }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Pure: validate the delegated tool.invoke params for the first batch (tool=lsp only).
|
|
44
|
+
* Position口径:line/character 是 **0-based 非负整数**(官方 seam 原生坐标,直接透传);
|
|
45
|
+
* 结果归一化时再转成 1-based 展示(locations: {path,line,character})。 */
|
|
46
|
+
export function validateToolInvoke(params) {
|
|
47
|
+
const input = params && typeof params === 'object' ? params : {}
|
|
48
|
+
const tool = String(input.tool ?? '').trim()
|
|
49
|
+
if (tool !== 'lsp') return { ok: false, error: 'contract-unsupported', message: `tool not supported in first batch: ${tool || '(empty)'}` }
|
|
50
|
+
const classified = classifyLspAction(input.action)
|
|
51
|
+
if (!classified.ok) return classified
|
|
52
|
+
const file = String(input.file ?? '').trim()
|
|
53
|
+
if (!file) return { ok: false, error: 'contract-invalid-request', message: 'lsp action requires a file' }
|
|
54
|
+
const line = Number(input.line)
|
|
55
|
+
const character = Number(input.character)
|
|
56
|
+
if (!Number.isInteger(line) || line < 0 || !Number.isInteger(character) || character < 0) {
|
|
57
|
+
return { ok: false, error: 'contract-invalid-request', message: 'lsp action requires non-negative 0-based line and character' }
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
ok: true,
|
|
61
|
+
tool: 'lsp',
|
|
62
|
+
action: classified.action,
|
|
63
|
+
kind: classified.kind,
|
|
64
|
+
approval: classified.approval,
|
|
65
|
+
operation: classified.operation ?? null,
|
|
66
|
+
file,
|
|
67
|
+
line,
|
|
68
|
+
character,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (c) 2026 dsh-Fang contributors — see LICENSE-CORE.
|
|
3
|
+
//
|
|
4
|
+
// B-6 执行提供方(路线 A 优先):母体 LSP provider 适配。
|
|
5
|
+
// 官方能力缝 ctx.lsp.query({operation, filePath, position, workspaceRoot}) 不需要 Agent Session,
|
|
6
|
+
// 因此母体 fang 插件可把委托请求直接映射到真实语言服务器查询。
|
|
7
|
+
// 路线 B(fork-local)作为增强:同一契约动作可在加速分身本地 provider 上执行,能力目录按 provider 区分。
|
|
8
|
+
import fs from 'node:fs'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
import { fileURLToPath } from 'node:url'
|
|
11
|
+
|
|
12
|
+
import { DELEGATE_ERROR } from './contract-delegation.mjs'
|
|
13
|
+
import { LSP_ACTION_TO_OPERATION, LSP_READ_ACTIONS } from './lsp-delegation.mjs'
|
|
14
|
+
|
|
15
|
+
export const LSP_PROVIDER_MOTHER = 'mother'
|
|
16
|
+
export const LSP_PROVIDER_FORK = 'fork-local'
|
|
17
|
+
export const LSP_PROVIDER_TEST = 'test-hook'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Derive the *actually provided* actions from a live seam.
|
|
21
|
+
* E6:官方 `LspService` 类型只有 registerProvider/query,没有 provider 枚举/能力列表 API;
|
|
22
|
+
* 因此 seam 存在时按闭集 advertise 四个只读操作。`supportedOperations`/`capabilities` 交集
|
|
23
|
+
* 仅作为未来自定义 provider 的前向兼容守卫(官方类型不会带这些字段)。 The official seam provides the four
|
|
24
|
+
* read operations; a custom provider may expose `supportedOperations`/`capabilities`, in which
|
|
25
|
+
* case we advertise only the intersection (never claim an action the provider cannot serve).
|
|
26
|
+
*/
|
|
27
|
+
export function advertisedActionsFromSeam(lspService) {
|
|
28
|
+
if (!lspService || typeof lspService.query !== 'function') return []
|
|
29
|
+
const declared = Array.isArray(lspService.supportedOperations)
|
|
30
|
+
? lspService.supportedOperations
|
|
31
|
+
: (Array.isArray(lspService.capabilities) ? lspService.capabilities : null)
|
|
32
|
+
if (!declared) return [...LSP_READ_ACTIONS]
|
|
33
|
+
const operations = new Set(declared.map((item) => String(item)))
|
|
34
|
+
const actions = LSP_READ_ACTIONS.filter((action) => operations.has(LSP_ACTION_TO_OPERATION[action]))
|
|
35
|
+
return actions
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Resolve a provider descriptor from the live host context (no side effects). */
|
|
39
|
+
export function describeLspProvider({ lspService = null, hooksEnabled = false, forkLocal = false, forkLspInfo = null, supportedActions = null } = {}) {
|
|
40
|
+
const services = {
|
|
41
|
+
[LSP_PROVIDER_MOTHER]: Boolean(lspService && typeof lspService.query === 'function'),
|
|
42
|
+
[LSP_PROVIDER_FORK]: Boolean(forkLocal),
|
|
43
|
+
[LSP_PROVIDER_TEST]: Boolean(hooksEnabled),
|
|
44
|
+
}
|
|
45
|
+
const available = Object.entries(services).filter(([, value]) => value).map(([name]) => name)
|
|
46
|
+
const declared = Array.isArray(supportedActions) ? supportedActions.filter((action) => LSP_READ_ACTIONS.includes(action)) : null
|
|
47
|
+
// Advertise real capabilities only: a missing provider (or a test-only hook) advertises no actions.
|
|
48
|
+
const motherActions = services[LSP_PROVIDER_MOTHER] ? [...(declared ?? LSP_READ_ACTIONS)] : []
|
|
49
|
+
const providers = {
|
|
50
|
+
// 路线 A:母体进程内 provider;委托执行,跨工作区可见性由 workspaceRoot 允许根约束(dsh-lsp-stdio 无沙箱,fail-closed)。
|
|
51
|
+
[LSP_PROVIDER_MOTHER]: { mode: 'delegated', source: 'mother-process', available: services[LSP_PROVIDER_MOTHER], actions: motherActions },
|
|
52
|
+
// 路线 B:加速分身本地 provider;LSP 跑在 fork 自己的 workspace/worktree,不经过契约委托与母体文件面。
|
|
53
|
+
[LSP_PROVIDER_FORK]: { mode: 'local', source: 'fork-worktree', available: services[LSP_PROVIDER_FORK], actions: services[LSP_PROVIDER_FORK] ? [...LSP_READ_ACTIONS] : [], ...(forkLspInfo && typeof forkLspInfo === 'object' ? { detail: forkLspInfo } : {}) },
|
|
54
|
+
}
|
|
55
|
+
if (services[LSP_PROVIDER_TEST]) {
|
|
56
|
+
providers[LSP_PROVIDER_TEST] = { mode: 'test-seam', source: 'e2e-hook', available: true, nonProduction: true, actions: [] }
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
available: available.length > 0,
|
|
60
|
+
default: services[LSP_PROVIDER_MOTHER] ? LSP_PROVIDER_MOTHER : (services[LSP_PROVIDER_TEST] ? LSP_PROVIDER_TEST : (services[LSP_PROVIDER_FORK] ? LSP_PROVIDER_FORK : null)),
|
|
61
|
+
services,
|
|
62
|
+
// 契约口径:测试缝只用于 e2e/内部验证,绝不作为生产能力对外宣称。
|
|
63
|
+
nonProduction: services[LSP_PROVIDER_TEST] ? [LSP_PROVIDER_TEST] : [],
|
|
64
|
+
actions: motherActions,
|
|
65
|
+
providers,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Collect the workspace roots of every fork task from its `storages/workspace.json`.
|
|
71
|
+
* "母体根 + 所有 fork 工作区根(显式登记)" — the task registry is the explicit registration.
|
|
72
|
+
*/
|
|
73
|
+
export function collectForkWorkspaceRoots(taskHomes = [], { readFileSync = fs.readFileSync } = {}) {
|
|
74
|
+
const roots = new Set()
|
|
75
|
+
for (const home of Array.isArray(taskHomes) ? taskHomes : []) {
|
|
76
|
+
const homeDir = String(home ?? '').trim()
|
|
77
|
+
if (!homeDir) continue
|
|
78
|
+
try {
|
|
79
|
+
const doc = JSON.parse(String(readFileSync(path.join(homeDir, 'storages', 'workspace.json'), 'utf8')))
|
|
80
|
+
const ids = Array.isArray(doc?.global?.workspaceIds) ? doc.global.workspaceIds : []
|
|
81
|
+
const tables = doc?.tables?.workspaces ?? {}
|
|
82
|
+
for (const id of ids) {
|
|
83
|
+
const workspacePath = String(tables?.[id]?.path ?? '').trim()
|
|
84
|
+
if (workspacePath) roots.add(path.resolve(workspacePath))
|
|
85
|
+
}
|
|
86
|
+
} catch { /* a fork without a workspace index contributes nothing */ }
|
|
87
|
+
}
|
|
88
|
+
return [...roots]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Merge configured roots with (optionally) every fork workspace root; dedupe, keep order. */
|
|
92
|
+
export function resolveLspAllowedRoots({ configuredRoots = [], forkRoots = [], includeForkWorktrees = true } = {}) {
|
|
93
|
+
const roots = new Set()
|
|
94
|
+
for (const root of Array.isArray(configuredRoots) ? configuredRoots : []) {
|
|
95
|
+
const text = String(root ?? '').trim()
|
|
96
|
+
if (text) roots.add(text)
|
|
97
|
+
}
|
|
98
|
+
if (includeForkWorktrees) {
|
|
99
|
+
for (const root of Array.isArray(forkRoots) ? forkRoots : []) {
|
|
100
|
+
const text = String(root ?? '').trim()
|
|
101
|
+
if (text) roots.add(text)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return [...roots]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Audit record for one LSP delegation attempt (workspace root recorded for the allowlist trail). */
|
|
108
|
+
export function lspAuditRecord({ action = '', provider = LSP_PROVIDER_MOTHER, workspaceRoot = null, outcome = 'error', error = null, latencyMs = 0 } = {}) {
|
|
109
|
+
return {
|
|
110
|
+
capability: 'fang.tool.invoke',
|
|
111
|
+
tool: 'lsp',
|
|
112
|
+
action: String(action ?? ''),
|
|
113
|
+
provider: String(provider ?? ''),
|
|
114
|
+
workspaceRoot: workspaceRoot ? String(workspaceRoot) : null,
|
|
115
|
+
outcome: String(outcome ?? 'error'),
|
|
116
|
+
error: error ?? null,
|
|
117
|
+
latencyMs: Math.max(0, Math.round(Number(latencyMs) || 0)),
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Canonicalise a path for allowlist comparison (best effort; missing paths still normalise). */
|
|
122
|
+
function canonical(pathValue) {
|
|
123
|
+
const resolved = path.resolve(String(pathValue ?? ''))
|
|
124
|
+
try { return fs.realpathSync.native(resolved) } catch { return resolved }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Workspace-root policy: delegated LSP may only read inside an explicitly allowed root, and the
|
|
129
|
+
* source file must live inside that root. Empty allowlist = deny (fail-closed), never "allow all".
|
|
130
|
+
*/
|
|
131
|
+
export function checkWorkspaceRoot({ workspaceRoot = '', file = '', allowedRoots = [] } = {}) {
|
|
132
|
+
if (!String(workspaceRoot ?? '').trim()) {
|
|
133
|
+
return { ok: false, code: DELEGATE_ERROR.INVALID, reason: 'workspace-root-missing', message: 'lsp delegation requires workspaceRoot (explicitly allowed root)' }
|
|
134
|
+
}
|
|
135
|
+
if (!Array.isArray(allowedRoots) || allowedRoots.length === 0) {
|
|
136
|
+
return { ok: false, code: DELEGATE_ERROR.INVALID, reason: 'allowlist-empty', message: 'lsp delegation has no allowed workspace roots; configure contract.delegate.lsp.allowedRoots' }
|
|
137
|
+
}
|
|
138
|
+
const root = canonical(workspaceRoot)
|
|
139
|
+
const inside = allowedRoots.some((allowed) => {
|
|
140
|
+
const prefix = canonical(allowed)
|
|
141
|
+
return root === prefix || root.startsWith(prefix.endsWith(path.sep) ? prefix : `${prefix}${path.sep}`)
|
|
142
|
+
})
|
|
143
|
+
if (!inside) return { ok: false, code: DELEGATE_ERROR.INVALID, reason: 'root-not-allowed', message: `workspaceRoot is not in contract.delegate.lsp.allowedRoots: ${root}` }
|
|
144
|
+
const source = canonical(path.isAbsolute(file) ? file : path.join(root, file))
|
|
145
|
+
if (!(source === root || source.startsWith(root.endsWith(path.sep) ? root : `${root}${path.sep}`))) {
|
|
146
|
+
return { ok: false, code: DELEGATE_ERROR.INVALID, reason: 'file-outside-root', message: `lsp file escapes workspaceRoot: ${source}` }
|
|
147
|
+
}
|
|
148
|
+
return { ok: true, workspaceRoot: root, file: source }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const CODE_MAP = {
|
|
152
|
+
LSP_UNAVAILABLE: DELEGATE_ERROR.UNAVAILABLE,
|
|
153
|
+
LSP_INVALID_PROVIDER: DELEGATE_ERROR.INVALID,
|
|
154
|
+
LSP_CONFLICT: DELEGATE_ERROR.INVALID,
|
|
155
|
+
LSP_FILE_OUTSIDE_WORKSPACE: DELEGATE_ERROR.INVALID,
|
|
156
|
+
LSP_MALFORMED_RESPONSE: DELEGATE_ERROR.UNAVAILABLE,
|
|
157
|
+
LSP_SERVER_ERROR: DELEGATE_ERROR.UNAVAILABLE,
|
|
158
|
+
LSP_SPAWN_FAILED: DELEGATE_ERROR.UNAVAILABLE,
|
|
159
|
+
LSP_SERVER_EXITED: DELEGATE_ERROR.UNAVAILABLE,
|
|
160
|
+
LSP_PROTOCOL_ERROR: DELEGATE_ERROR.UNAVAILABLE,
|
|
161
|
+
LSP_MESSAGE_TOO_LARGE: DELEGATE_ERROR.INVALID,
|
|
162
|
+
LSP_DISPOSED: DELEGATE_ERROR.UNAVAILABLE,
|
|
163
|
+
LSP_UNSUPPORTED_OPERATION: DELEGATE_ERROR.UNSUPPORTED,
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Map an LSP seam failure to a delegation error code + readable detail. */
|
|
167
|
+
export function mapLspError(error) {
|
|
168
|
+
const name = String(error?.code ?? error?.name ?? '')
|
|
169
|
+
const code = CODE_MAP[name] ?? DELEGATE_ERROR.UNAVAILABLE
|
|
170
|
+
const message = `lsp provider error: ${name || String(error?.message ?? 'unknown')}${error?.message ? ` — ${String(error.message).slice(0, 300)}` : ''}`
|
|
171
|
+
return { code, message, detail: { lspCode: name || null, serverMessage: String(error?.message ?? '').slice(0, 500) || null } }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Normalise the seam's closed-union result into the contract payload (JSON-safe). */
|
|
175
|
+
/** 结果裁剪默认值(沿用 tool 的 maxLocations / maxResultChars 思路)。 */
|
|
176
|
+
export const LSP_DEFAULT_LIMITS = Object.freeze({ maxLocations: 200, maxResultChars: 20000 })
|
|
177
|
+
|
|
178
|
+
/** file:// URI → 本地路径(契约结果里的 path 字段)。 */
|
|
179
|
+
export function pathFromLspUri(uri) {
|
|
180
|
+
const text = String(uri ?? '')
|
|
181
|
+
if (!text) return ''
|
|
182
|
+
if (text.startsWith('file://')) {
|
|
183
|
+
try { return fileURLToPath(text) } catch { return decodeURIComponent(text.replace(/^file:\/\//, '')) }
|
|
184
|
+
}
|
|
185
|
+
return text
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 结果归一化(契约口径):
|
|
190
|
+
* - locations → [{ path, line, character }],line/character 转 1-based 展示;
|
|
191
|
+
* - hover → { contents };
|
|
192
|
+
* - 超限裁剪:maxLocations / maxResultChars,并标记 truncated(不静默截断)。
|
|
193
|
+
*/
|
|
194
|
+
export function normalizeLspResult(result, { action, operation, provider = LSP_PROVIDER_MOTHER, limits = {} } = {}) {
|
|
195
|
+
const base = { provider, action: action ?? null, operation: operation ?? null }
|
|
196
|
+
const maxLocations = Number.isInteger(limits?.maxLocations) && limits.maxLocations > 0 ? limits.maxLocations : LSP_DEFAULT_LIMITS.maxLocations
|
|
197
|
+
const maxResultChars = Number.isInteger(limits?.maxResultChars) && limits.maxResultChars > 0 ? limits.maxResultChars : LSP_DEFAULT_LIMITS.maxResultChars
|
|
198
|
+
if (!result || typeof result !== 'object') return { ...base, kind: 'unknown', value: null }
|
|
199
|
+
if (result.kind === 'locations') {
|
|
200
|
+
const raw = Array.isArray(result.locations) ? result.locations : []
|
|
201
|
+
const kept = raw.slice(0, maxLocations)
|
|
202
|
+
return {
|
|
203
|
+
...base,
|
|
204
|
+
kind: 'locations',
|
|
205
|
+
resolvedWorkspaceUri: String(result.resolvedWorkspaceUri ?? ''),
|
|
206
|
+
totalLocations: raw.length,
|
|
207
|
+
truncated: raw.length > kept.length,
|
|
208
|
+
locations: kept.map((location) => ({
|
|
209
|
+
path: pathFromLspUri(location?.uri),
|
|
210
|
+
line: Number(location?.range?.start?.line ?? 0) + 1,
|
|
211
|
+
character: Number(location?.range?.start?.character ?? 0) + 1,
|
|
212
|
+
})),
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (result.kind === 'hover') {
|
|
216
|
+
const full = String(result.hover?.contents ?? '')
|
|
217
|
+
return {
|
|
218
|
+
...base,
|
|
219
|
+
kind: 'hover',
|
|
220
|
+
contents: full.length > maxResultChars ? full.slice(0, maxResultChars) : full,
|
|
221
|
+
truncated: full.length > maxResultChars,
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return { ...base, kind: String(result.kind ?? 'unknown'), value: null }
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Run one contract LSP action through a live `ctx.lsp` seam.
|
|
229
|
+
* @returns {Promise<{ok:true, result:object} | {ok:false, code:string, message:string, detail?:object}>}
|
|
230
|
+
*/
|
|
231
|
+
export async function queryMotherLsp({ lspService, invoke, workspaceRoot, limits, signal } = {}) {
|
|
232
|
+
if (!lspService || typeof lspService.query !== 'function') {
|
|
233
|
+
return { ok: false, code: DELEGATE_ERROR.UNAVAILABLE, message: 'lsp provider unavailable on mother (ctx.lsp seam not installed)', detail: { provider: LSP_PROVIDER_MOTHER } }
|
|
234
|
+
}
|
|
235
|
+
const operation = LSP_ACTION_TO_OPERATION[String(invoke?.action ?? '')]
|
|
236
|
+
if (!operation) return { ok: false, code: DELEGATE_ERROR.UNSUPPORTED, message: `lsp action not supported by official seam: ${invoke?.action ?? '(empty)'}` }
|
|
237
|
+
const request = {
|
|
238
|
+
operation,
|
|
239
|
+
filePath: String(invoke.file ?? ''),
|
|
240
|
+
// 契约参数为 0-based 非负整数(官方 seam 原生坐标),直接透传。
|
|
241
|
+
position: { line: Number(invoke.line), character: Number(invoke.character) },
|
|
242
|
+
workspaceRoot: String(workspaceRoot ?? ''),
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
const value = await lspService.query(request, signal)
|
|
246
|
+
return { ok: true, result: normalizeLspResult(value, { action: invoke.action, operation, provider: LSP_PROVIDER_MOTHER, limits }) }
|
|
247
|
+
} catch (error) {
|
|
248
|
+
return { ok: false, ...mapLspError(error) }
|
|
249
|
+
}
|
|
250
|
+
}
|