@allbluecn/dsh-compat 0.0.0-stage → 0.0.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 +661 -0
- package/README.md +24 -2
- package/package.json +34 -3
- package/src/__tests__/package.test.ts +58 -0
- package/src/assemble/__tests__/assemble.test.ts +656 -0
- package/src/assemble/assemble.ts +383 -0
- package/src/assemble/resolve.ts +59 -0
- package/src/compat/__tests__/context.test.ts +211 -0
- package/src/compat/__tests__/events.test.ts +135 -0
- package/src/compat/__tests__/tool-adapter.test.ts +157 -0
- package/src/compat/__tests__/view-bridge.test.ts +166 -0
- package/src/compat/context.ts +496 -0
- package/src/compat/events.ts +189 -0
- package/src/compat/tool-adapter.ts +115 -0
- package/src/compat/view-bridge.ts +160 -0
- package/src/guard/assert-fetchable-url.ts +239 -0
- package/src/index.ts +52 -0
- package/src/patch/__tests__/patch.test.ts +250 -0
- package/src/patch/eval.ts +343 -0
- package/src/patch/merge.ts +45 -0
- package/src/patch/types.ts +37 -0
- package/src/patch/yaml.ts +75 -0
- package/src/plugin-safety/__tests__/build-approval.test.ts +149 -0
- package/src/plugin-safety/__tests__/install-spec.test.ts +148 -0
- package/src/plugin-safety/build-approval.ts +134 -0
- package/src/plugin-safety/index.ts +31 -0
- package/src/plugin-safety/install-spec.ts +189 -0
- package/src/report.ts +47 -0
- package/src/surface.ts +92 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// DSH npm 插件安装 spec 校验(P3 前置 PRE-4,设计见
|
|
6
|
+
// docs/superpowers/specs/2026-11-11-harness-dsh-plugin-safety-prereq.md §PRE-4)。
|
|
7
|
+
//
|
|
8
|
+
// 镜像 DSH `inspect` 的 spec 三/四形态判定与 problem 枚举(boot/plugin-manager
|
|
9
|
+
// /src/index.ts `parseInstallSpec` + `inspect`),**纯校验不含网络 lookup**——registry
|
|
10
|
+
// 的 `pnpm view` 需 npm install serverFn(GATED,§9.5 ①),本期只做形态/安全校验。
|
|
11
|
+
//
|
|
12
|
+
// 安全不变式(移植自 DSH,不宜削弱):
|
|
13
|
+
// - 拒绝带凭据的 git URL(密码 / HTTP(S) 用户名)——凭据不进 profile settings/pending list
|
|
14
|
+
// - 拒绝 `#` 片段(fragment)——对齐 DSH market URL 校验
|
|
15
|
+
// - 拒绝私网/回环 host(git/tarball 的 http(s) URL 复用 fetch-guard SSRF 守卫,含 IPv6/IPv4-mapped)
|
|
16
|
+
// - 拒绝空 spec / 以 `-` 开头(会被 pnpm 当 flag)
|
|
17
|
+
|
|
18
|
+
import { assertFetchableUrl } from '../guard/assert-fetchable-url'
|
|
19
|
+
|
|
20
|
+
/** 安装 spec 校验结果:accepted(形态 + 归一信息)或 refused(problem 枚举 + 原因)。 */
|
|
21
|
+
export type InstallSpecInspection =
|
|
22
|
+
| { status: 'accepted'; kind: InstallSpecKind; name?: string; host?: string; path?: string }
|
|
23
|
+
| { status: 'refused'; problem: InstallSpecProblem; reason: string }
|
|
24
|
+
|
|
25
|
+
/** 安装 spec 形态(对齐 DSH parseInstallSpec 的 kind)。 */
|
|
26
|
+
export type InstallSpecKind = 'registry' | 'git' | 'tarball' | 'path'
|
|
27
|
+
|
|
28
|
+
/** refusal problem 枚举(对齐 DSH inspect 的 problem)。 */
|
|
29
|
+
export type InstallSpecProblem =
|
|
30
|
+
| 'invalid-spec'
|
|
31
|
+
| 'not-a-package'
|
|
32
|
+
| 'not-a-bundle'
|
|
33
|
+
| 'already-installed'
|
|
34
|
+
| 'network'
|
|
35
|
+
| 'unknown'
|
|
36
|
+
|
|
37
|
+
/** http(s) URL(pnpm --registry 形态)。 */
|
|
38
|
+
const REGISTRY_URL = /^https?:\/\/\S+$/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* git/tarball URL 里是否携带凭据:密码,或 HTTP(S) 上的用户名。带凭据的 spec 一律拒
|
|
42
|
+
* (凭据不进 profile settings/pending list,防泄露)。
|
|
43
|
+
*
|
|
44
|
+
* 覆盖两种形态:
|
|
45
|
+
* - DSH pnpm `allowBuilds` 键:凭据在 `@git+` 前(`...@git+https://host`,少见)
|
|
46
|
+
* - **git/tarball clone URL(本函数主要用途)**:凭据在协议后(`git+https://user:pass@host`
|
|
47
|
+
* 或 `https://user:pass@host/x.tgz`)——直接解析 URL 查 password / HTTP(S) 用户名。
|
|
48
|
+
*/
|
|
49
|
+
function carriesCredential(key: string): boolean {
|
|
50
|
+
// 形态 A(DSH allowBuilds 键):凭据在 `@git+` 前
|
|
51
|
+
const at = key.indexOf('@git+')
|
|
52
|
+
if (at !== -1) {
|
|
53
|
+
const url = URL.parse(key.slice(at + '@git+'.length).replace(/#.*$/s, ''))
|
|
54
|
+
if (url !== null && (url.password !== '' || (url.username !== '' && /^https?:$/.test(url.protocol)))) {
|
|
55
|
+
return true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// 形态 B(clone URL):凭据在 `git+https://` 或 `https://` 后——解析整段 URL
|
|
59
|
+
const gitPrefix = 'git+'
|
|
60
|
+
const raw = key.startsWith(gitPrefix) ? key.slice(gitPrefix.length) : key
|
|
61
|
+
const url = URL.parse(raw.replace(/#.*$/s, ''))
|
|
62
|
+
return url !== null && (url.password !== '' || (url.username !== '' && /^https?:$/.test(url.protocol)))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 提取 git spec 的 host 部分(`git+https://host/path` 或 `git+https://host/path#committish`):
|
|
67
|
+
* host = `git+` 后的 URL。非 git spec(tarball/registry/path)返回 undefined。
|
|
68
|
+
* DSH 的 `#git+https://host` 形态(`#` 后带 `git+`)也兼容。
|
|
69
|
+
*/
|
|
70
|
+
function hostOf(spec: string): string | undefined {
|
|
71
|
+
if (!spec.startsWith('git+')) return undefined
|
|
72
|
+
const hash = spec.indexOf('#')
|
|
73
|
+
const rest = hash === -1 ? spec : spec.slice(hash + 1)
|
|
74
|
+
// `git+https://host/path` 或 `#git+https://host`:剥 `git+` 取 URL
|
|
75
|
+
return rest.startsWith('git+') ? rest.slice('git+'.length) : undefined
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** 是否本地绝对/相对路径(DSH path 形态:指向含 package.json 的目录)。 */
|
|
79
|
+
function isLocalPath(spec: string): boolean {
|
|
80
|
+
return spec.startsWith('/') || spec.startsWith('./') || spec.startsWith('../')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 校验 DSH npm 插件安装 spec(PRE-4 纯校验)。
|
|
85
|
+
*
|
|
86
|
+
* 形态(对齐 DSH parseInstallSpec):
|
|
87
|
+
* - registry:npm 包名(`dsh-plugin-x` / `@scope/pkg`),走 registry lookup
|
|
88
|
+
* - git:git 地址(`git+https://...` / `git+ssh://...`)
|
|
89
|
+
* - tarball:`.tgz` tarball URL 或本地路径
|
|
90
|
+
* - path:本地绝对/相对路径指向含 package.json 的目录
|
|
91
|
+
*
|
|
92
|
+
* 拒绝:空 / `-` 开头(会被包管理器当 flag)/ 带凭据的 git URL / `#` 片段 /
|
|
93
|
+
* http(s) 安装源指向私网(复用 fetch-guard SSRF 守卫,含 IPv6/IPv4-mapped)。
|
|
94
|
+
* **不含** registry 的 `pnpm view` 网络 lookup 与 path/tarball 的 existsSync——那需
|
|
95
|
+
* npm install serverFn(GATED),本期只做形态/安全校验。
|
|
96
|
+
*
|
|
97
|
+
* @param spec 安装 spec(npm 包名 / git 地址 / tarball / 本地路径)
|
|
98
|
+
* @param opts `knownNames` 已装包名集合(命中 → already-installed)
|
|
99
|
+
*/
|
|
100
|
+
export function inspectInstallSpec(
|
|
101
|
+
spec: string,
|
|
102
|
+
opts: { knownNames?: ReadonlySet<string> } = {},
|
|
103
|
+
): InstallSpecInspection {
|
|
104
|
+
const trimmed = spec.trim()
|
|
105
|
+
if (trimmed === '' || trimmed.startsWith('-')) {
|
|
106
|
+
return refused('invalid-spec', '安装 spec 为空或以 - 开头(会被包管理器当 flag)')
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// tarball:.tgz 结尾(URL 或本地路径)
|
|
110
|
+
if (/\.tgz$/.test(trimmed)) {
|
|
111
|
+
if (isLocalPath(trimmed)) {
|
|
112
|
+
// 本地 tarball 的 existsSync 需 serverFn(GATED),本期只认形态
|
|
113
|
+
return { status: 'accepted', kind: 'tarball', path: trimmed }
|
|
114
|
+
}
|
|
115
|
+
// 远程 tarball URL:先拒带凭据的 URL(凭据不进日志/错误),再过 SSRF 守卫
|
|
116
|
+
if (carriesCredential(trimmed)) return refused('invalid-spec', 'tarball URL 携带凭据(密码或 HTTP(S) 用户名)')
|
|
117
|
+
return acceptRemoteUrl(trimmed)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// git:git+<url>
|
|
121
|
+
if (trimmed.startsWith('git+')) {
|
|
122
|
+
if (carriesCredential(trimmed)) return refused('invalid-spec', 'git URL 携带凭据(密码或 HTTP(S) 用户名)')
|
|
123
|
+
// 安全判定不依赖 hostOf(它服务 host 字段提取,对 committish 形态返回 undefined 会绕过私网检查)。
|
|
124
|
+
// 剥 `git+` + committish fragment 后解析整段 URL:http(s) 走 assertFetchableUrl(与 tarball 同款,
|
|
125
|
+
// 含 IPv6 ULA/链路本地/IPv4-mapped/整数混淆/.local/.internal);ssh 等非 http(s) 协议不经 HTTP
|
|
126
|
+
// fetch,无此 SSRF 面,跳过(不误拒合法 git+ssh)。
|
|
127
|
+
const raw = trimmed.slice('git+'.length).replace(/#.*$/s, '')
|
|
128
|
+
const parsed = URL.parse(raw)
|
|
129
|
+
if (parsed && /^https?:$/.test(parsed.protocol)) {
|
|
130
|
+
try {
|
|
131
|
+
assertFetchableUrl(raw)
|
|
132
|
+
} catch (err) {
|
|
133
|
+
const reason = err instanceof Error ? err.message : String(err)
|
|
134
|
+
return refused('invalid-spec', `git URL 被拒(SSRF 守卫): ${reason}`)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const host = hostOf(trimmed)
|
|
138
|
+
return { status: 'accepted', kind: 'git', ...(host ? { host } : {}) }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// path:本地绝对/相对路径
|
|
142
|
+
if (isLocalPath(trimmed)) {
|
|
143
|
+
// existsSync / package.json 读取需 serverFn(GATED),本期只认形态
|
|
144
|
+
return { status: 'accepted', kind: 'path', path: trimmed }
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// registry:npm 包名(其余)
|
|
148
|
+
if (carriesCredential(trimmed)) return refused('invalid-spec', 'spec 携带凭据')
|
|
149
|
+
if (trimmed.includes('#')) return refused('invalid-spec', 'spec 含 # 片段')
|
|
150
|
+
if (isPrivateHost(trimmed)) return refused('invalid-spec', 'spec 指向私网/回环 host')
|
|
151
|
+
if (opts.knownNames?.has(trimmed)) {
|
|
152
|
+
return refused('already-installed', `${trimmed} 已安装`)
|
|
153
|
+
}
|
|
154
|
+
return { status: 'accepted', kind: 'registry', name: trimmed }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** tarball http(s) URL 的 SSRF 校验(复用 fetch-guard,含 IPv6/IPv4-mapped)。 */
|
|
158
|
+
function acceptRemoteUrl(url: string): InstallSpecInspection {
|
|
159
|
+
try {
|
|
160
|
+
assertFetchableUrl(url)
|
|
161
|
+
} catch (err) {
|
|
162
|
+
const reason = err instanceof Error ? err.message : String(err)
|
|
163
|
+
return refused('invalid-spec', `tarball URL 被拒(SSRF 守卫): ${reason}`)
|
|
164
|
+
}
|
|
165
|
+
return { status: 'accepted', kind: 'tarball', ...(hostOf(url) ? { host: hostOf(url) } : {}) }
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function refused(problem: InstallSpecProblem, reason: string): InstallSpecInspection {
|
|
169
|
+
return { status: 'refused', problem, reason }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 私网/回环 host 判定(registry 名不含 URL 时对 host 部分的快速兜底;git/tarball 的
|
|
174
|
+
* http(s) URL 走 assertFetchableUrl 的完整 SSRF 守卫,含 IPv6/IPv4-mapped)。
|
|
175
|
+
*/
|
|
176
|
+
function isPrivateHost(host: string): boolean {
|
|
177
|
+
const h = host.toLowerCase().replace(/^\[|\]$/g, '')
|
|
178
|
+
return (
|
|
179
|
+
h === 'localhost' ||
|
|
180
|
+
h.endsWith('.localhost') ||
|
|
181
|
+
h === '0.0.0.0' ||
|
|
182
|
+
/^127\./.test(h) ||
|
|
183
|
+
/^10\./.test(h) ||
|
|
184
|
+
/^192\.168\./.test(h) ||
|
|
185
|
+
/^172\.(1[6-9]|2\d|3[01])\./.test(h) ||
|
|
186
|
+
/^169\.254\./.test(h) ||
|
|
187
|
+
h === '::1'
|
|
188
|
+
)
|
|
189
|
+
}
|
package/src/report.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// AssemblyReport 契约(规格 §4.1.5 / 计划 F1-5)。
|
|
6
|
+
//
|
|
7
|
+
// assembleProfile 的诊断产出:一次组装把每条 patch 行归入下列互斥桶之一
|
|
8
|
+
// (disabled → unresolved → deactivated → failed → activated),外加跨插件的
|
|
9
|
+
// 工具名冲突清单与版本化兼容面标识。纯数据,零依赖。
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 一次 assembleProfile 的诊断报告。
|
|
13
|
+
*
|
|
14
|
+
* 每条 merged patch 行恰好落入一个状态桶(disabled 优先,其次 unresolved /
|
|
15
|
+
* deactivated / failed,最后 activated);`toolConflicts` 是跨插件的去重记录。
|
|
16
|
+
*/
|
|
17
|
+
export interface AssemblyReport {
|
|
18
|
+
/** 成功激活并产出贡献的插件。 */
|
|
19
|
+
activated: Array<{ id: string; name: string }>
|
|
20
|
+
/**
|
|
21
|
+
* 未激活(inject 含 provided-services 表外键)。`missing` = 缺失的服务键。
|
|
22
|
+
* `name` 可缺省 = resolver 未命中(此时无从得知模块名)。
|
|
23
|
+
*/
|
|
24
|
+
deactivated: Array<{
|
|
25
|
+
id: string
|
|
26
|
+
name?: string
|
|
27
|
+
missing: ReadonlyArray<string>
|
|
28
|
+
}>
|
|
29
|
+
/** apply 抛错(failed 插件贡献为空,见 F1-4 I-1;不拖垮其余插件)。 */
|
|
30
|
+
failed: Array<{ id: string; name: string; error: string }>
|
|
31
|
+
/** evalDisabled 判定为停用(boolean false 或 !!js 表达式 truthy)。 */
|
|
32
|
+
disabled: Array<{ id: string }>
|
|
33
|
+
/**
|
|
34
|
+
* 无法解析的行:无 `name`(未指定解析名)或 resolver 未命中。
|
|
35
|
+
* 可选字段——空数组时 assemble 不写出(保持 report 精简)。
|
|
36
|
+
*/
|
|
37
|
+
unresolved?: Array<{ id: string; name?: string }>
|
|
38
|
+
/**
|
|
39
|
+
* 工具名冲突去重记录(规格 §4.1.3 硬前置防御)。官方对 PluginContributions.tools
|
|
40
|
+
* 同名是 throw + 全部插件逆序回滚 + session open 失败,故 assemble 预去重:
|
|
41
|
+
* 撞名时应用侧让位——先出现者(高优先层)保留,后到同名工具丢弃。
|
|
42
|
+
* `owner` = 被让位(丢弃工具)的插件名,`yieldedTo` = 保留工具的插件名。
|
|
43
|
+
*/
|
|
44
|
+
toolConflicts: Array<{ name: string; owner: string; yieldedTo: string }>
|
|
45
|
+
/** = DSH_COMPAT_SURFACE.version,版本化兼容面标识。 */
|
|
46
|
+
surfaceVersion: string
|
|
47
|
+
}
|
package/src/surface.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// DSH 版本化兼容面(规格 §4.1.1 / 计划 F1-5)。
|
|
6
|
+
//
|
|
7
|
+
// `DSH_COMPAT_SURFACE` 声明本包向 DSH 插件暴露的 L0 兼容面:provided-services
|
|
8
|
+
// 的键集 + 关键行为。conformance(F1-6)可断言组装产物未越此边界。
|
|
9
|
+
|
|
10
|
+
/** L0 兼容面版本。 */
|
|
11
|
+
export const DSH_COMPAT_SURFACE_VERSION = '0.1.0' as const
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* L0 provided-services 键集:翻译层 `CordisContext` 暴露给 DSH 插件的面
|
|
15
|
+
* (inject 判定表可出现的键)。`inject` 含表外键 ⇒ 插件不激活(硬前置②)。
|
|
16
|
+
*/
|
|
17
|
+
export const L0_PROVIDED_SERVICE_KEYS: ReadonlyArray<string> = [
|
|
18
|
+
'config',
|
|
19
|
+
'tools',
|
|
20
|
+
'systemPrompt',
|
|
21
|
+
'commands',
|
|
22
|
+
'effect',
|
|
23
|
+
'events',
|
|
24
|
+
'logger',
|
|
25
|
+
'resources',
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* DSH 版本化兼容面:版本 + L0 provided-services 键集 + 关键行为描述。
|
|
30
|
+
*/
|
|
31
|
+
export const DSH_COMPAT_SURFACE = {
|
|
32
|
+
version: DSH_COMPAT_SURFACE_VERSION,
|
|
33
|
+
keys: L0_PROVIDED_SERVICE_KEYS,
|
|
34
|
+
behaviors: [
|
|
35
|
+
'patch 多层逐 key 覆盖(id 定向,未提及 key 保留前层)',
|
|
36
|
+
'inject 含 provided-services 表外键 → 插件不激活(不调 apply)',
|
|
37
|
+
'apply 100% try-catch → failed 插件贡献为空,单插件失败不拖垮其余',
|
|
38
|
+
'工具名预去重:撞名时应用侧让位(先出现者保留),不触发官方 throw + 逆序回滚',
|
|
39
|
+
'effect → 官方 resources.acquire(逆序清理)',
|
|
40
|
+
'已知事件 → 官方 middleware contribution;未知事件 → 包内互通总线',
|
|
41
|
+
'session lifetime(默认):资源随 session open→close 存活',
|
|
42
|
+
'通道 A 渲染桥:presentResult 视图挂 result.__dshView',
|
|
43
|
+
],
|
|
44
|
+
} as const
|
|
45
|
+
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// L0 边界
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
//
|
|
50
|
+
// **L0 兼容面不含 agent / subagent 贡献**——裸 JSON Schema 的宽容只覆盖**工具**
|
|
51
|
+
// (`parameters` 直传官方 `inputSchema`,见 tool-adapter.ts);agent / subagent
|
|
52
|
+
// 的 `inputSchema` 必须是 Standard Schema(core 对裸 JSON Schema 直接报错)。
|
|
53
|
+
// DSH cordis 路径只产出 tools / prompts / commands / middleware(CordisContributions
|
|
54
|
+
// 收集面),永不产出 agents / subagents。conformance(F1-6)用
|
|
55
|
+
// {@link assertL0Surface} 断言组装产物未越此边界。
|
|
56
|
+
|
|
57
|
+
/** assertL0Surface 接受的最小插件面(真实 HarnessPlugin 或纯 contributions 均可)。 */
|
|
58
|
+
export interface L0SurfaceCandidate {
|
|
59
|
+
name?: string
|
|
60
|
+
contributions?: {
|
|
61
|
+
agents?: ReadonlyArray<unknown>
|
|
62
|
+
subagents?: ReadonlyArray<unknown>
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 断言一组插件未越 L0 边界:不含 agent / subagent 贡献。
|
|
68
|
+
*
|
|
69
|
+
* DSH cordis 翻译层永不产出 agent 贡献;若出现(未来误接内置 `@allblue/*`
|
|
70
|
+
* agent 工厂),说明越界到 L0 之外(agent 的 inputSchema 需 Standard Schema,
|
|
71
|
+
* 非本兼容面承诺),抛错。
|
|
72
|
+
*
|
|
73
|
+
* @param plugins 组装产物(HarnessPlugin[] 或其 contributions 投影)
|
|
74
|
+
* @throws Error 任一插件含 agents / subagents 贡献
|
|
75
|
+
*/
|
|
76
|
+
export function assertL0Surface(
|
|
77
|
+
plugins: ReadonlyArray<L0SurfaceCandidate>,
|
|
78
|
+
): void {
|
|
79
|
+
for (const plugin of plugins) {
|
|
80
|
+
const name = plugin.name ?? '<unnamed>'
|
|
81
|
+
if (plugin.contributions?.agents?.length) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`L0 边界越界:插件 ${name} 贡献了 agents(L0 兼容面不含 agent 贡献)`,
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
if (plugin.contributions?.subagents?.length) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`L0 边界越界:插件 ${name} 贡献了 subagents(L0 兼容面不含 subagent 贡献)`,
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|