@x-otto/tools 0.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/dist/index.d.ts +1329 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +152 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1329 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ChildProcess, SpawnOptionsWithoutStdio } from "node:child_process";
|
|
3
|
+
import { CallAgent, CancelBackground, GetBackgroundOutput, GetTask, ListTasks, TaskDispatch, UpdateTask, WriteTodos } from "@x-otto/orchestration-contracts";
|
|
4
|
+
import * as _$_x_otto_interchange0 from "@x-otto/interchange";
|
|
5
|
+
import { AgentTool, GrillAnswer, GrillQuestion, ProcessTracker } from "@x-otto/interchange";
|
|
6
|
+
import { SandboxConfig, ToolPreset } from "@x-otto/setting";
|
|
7
|
+
|
|
8
|
+
//#region src/hitl/grill-me.d.ts
|
|
9
|
+
type SessionGrill = (sessionId: string, question: Omit<GrillQuestion, 'id'>) => Promise<GrillAnswer>;
|
|
10
|
+
declare const GrillMeArgsSchema: z.ZodObject<{
|
|
11
|
+
header: z.ZodString;
|
|
12
|
+
question: z.ZodString;
|
|
13
|
+
background: z.ZodString;
|
|
14
|
+
recommendation: z.ZodString;
|
|
15
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
16
|
+
label: z.ZodString;
|
|
17
|
+
rationale: z.ZodString;
|
|
18
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>>>;
|
|
21
|
+
allowFreeform: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
22
|
+
multiSelect: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
23
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
type GrillMeArgs = z.infer<typeof GrillMeArgsSchema>;
|
|
26
|
+
declare function createGrillMe(_projectRoot: string, grill?: SessionGrill): AgentTool<GrillMeArgs>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/binary/binary-executor.d.ts
|
|
29
|
+
interface BinaryToolExecutionOptions extends SpawnOptionsWithoutStdio {
|
|
30
|
+
/**
|
|
31
|
+
* stdout 累计字节上限(M6-06,防无界缓冲/OOM)。超过即停止收集 + 终止子进程,
|
|
32
|
+
* 结果标记 `truncated`。缺省不限(向后兼容)。
|
|
33
|
+
*/
|
|
34
|
+
maxBuffer?: number;
|
|
35
|
+
}
|
|
36
|
+
interface BinaryToolExecutionResult {
|
|
37
|
+
stdout: string;
|
|
38
|
+
stderr: string;
|
|
39
|
+
exitCode: number | null;
|
|
40
|
+
/** stdout 触达 maxBuffer 被截断(M6-06)。 */
|
|
41
|
+
truncated?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface BinaryTool {
|
|
44
|
+
name: string;
|
|
45
|
+
version: string;
|
|
46
|
+
execute(args: string[], options?: BinaryToolExecutionOptions): Promise<BinaryToolExecutionResult>;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/binary/binary-executor-registry.d.ts
|
|
50
|
+
declare class BinaryToolExecutorRegistry {
|
|
51
|
+
private binaries;
|
|
52
|
+
has(tool: string): boolean;
|
|
53
|
+
get(tool: string): BinaryTool | undefined;
|
|
54
|
+
register(tool: BinaryTool): void;
|
|
55
|
+
unregister(tool: string): void;
|
|
56
|
+
ensureAll(): Promise<void>;
|
|
57
|
+
ensure(tool: string): Promise<BinaryTool>;
|
|
58
|
+
dispose(): void;
|
|
59
|
+
}
|
|
60
|
+
declare const createBinaryToolExecutorRegistry: (projectRoot: string, processTracker?: ProcessTracker) => BinaryToolExecutorRegistry;
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/orchestration/delegate-job.d.ts
|
|
63
|
+
/** 起一个隔离作业的回调(app 注入:→ agentJobs.start({origin:'main'}))。同步返回作业 id。 */
|
|
64
|
+
type StartJob = (input: {
|
|
65
|
+
prompt: string;
|
|
66
|
+
title: string;
|
|
67
|
+
sessionId: string;
|
|
68
|
+
}) => {
|
|
69
|
+
jobId: string;
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/memory/memory-archive.d.ts
|
|
73
|
+
/**
|
|
74
|
+
* memory-archive.ts — RFC-340 M2:会话归档召回工具。
|
|
75
|
+
*
|
|
76
|
+
* 背景:压缩(compaction)把旧历史折叠成摘要后,原始消息仍完整保留在会话树里
|
|
77
|
+
* (RFC-159 红线保证 `session_entries` 永不删行),`MemoryManager` 也早已实现了
|
|
78
|
+
* 按 compaction 边界重建归档全文的能力(`readArchiveFromEntries`)——但这套能力
|
|
79
|
+
* **从未暴露给模型**(终局复审 R3 实证:零工具、零生产调用方)。
|
|
80
|
+
*
|
|
81
|
+
* 后果是 RFC-340 M1 的低保真标注只完成了半环:标注告诉模型"有 N% 历史没进摘要",
|
|
82
|
+
* 模型却没有任何手段找回,标注沦为焦虑提示而非可行动信息。本文件补上下半环。
|
|
83
|
+
*/
|
|
84
|
+
/** 归档条目的工具层视图——不依赖 `@x-otto/memory` 的 `ArchiveEntry`(保持 tools 包分层纯净)。 */
|
|
85
|
+
interface ArchiveEntryView {
|
|
86
|
+
path: string;
|
|
87
|
+
timestamp: number;
|
|
88
|
+
messageCount: number;
|
|
89
|
+
summary: string;
|
|
90
|
+
}
|
|
91
|
+
type ReadArchive = (archivePath: string) => Promise<string>;
|
|
92
|
+
type ListArchives = (sessionId: string) => Promise<ArchiveEntryView[]>;
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/scheduling/create.d.ts
|
|
95
|
+
declare const CronCreateArgs: z.ZodObject<{
|
|
96
|
+
cron: z.ZodString;
|
|
97
|
+
prompt: z.ZodString;
|
|
98
|
+
recurring: z.ZodBoolean;
|
|
99
|
+
name: z.ZodOptional<z.ZodString>;
|
|
100
|
+
maxDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
type CronCreateArgs = z.infer<typeof CronCreateArgs>;
|
|
103
|
+
interface CronCreateResult {
|
|
104
|
+
taskId: string;
|
|
105
|
+
nextFireAt: number;
|
|
106
|
+
name: string;
|
|
107
|
+
}
|
|
108
|
+
type ScheduleCreateCallback = (input: CronCreateArgs) => CronCreateResult;
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/scheduling/list.d.ts
|
|
111
|
+
interface CronTask {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
cronExpression: string;
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
recurring: boolean;
|
|
117
|
+
nextFireAt: number;
|
|
118
|
+
lastFiredAt?: number;
|
|
119
|
+
}
|
|
120
|
+
type ScheduleListCallback = () => CronTask[];
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/scheduling/delete.d.ts
|
|
123
|
+
type ScheduleDeleteCallback = (taskId: string) => boolean;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/scheduling/run.d.ts
|
|
126
|
+
type ScheduleRunCallback = (taskId: string) => void;
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/scheduling/cancel.d.ts
|
|
129
|
+
interface ScheduleCancelResult {
|
|
130
|
+
ok: boolean;
|
|
131
|
+
reason?: string;
|
|
132
|
+
}
|
|
133
|
+
type ScheduleCancelCallback = (taskId: string) => ScheduleCancelResult;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/orchestration/capability-gap.d.ts
|
|
136
|
+
/**
|
|
137
|
+
* capability_gap —— RFC-287 M4:自迭代回路的**认知入口**。
|
|
138
|
+
*
|
|
139
|
+
* 让模型在"我做不到这件事"时,能主动查生态里有没有现成能力、没有则拿到造一个的蓝图,
|
|
140
|
+
* 而不是简单地回一句"我不支持"。这是 otto 作为开放 Agent 容器的关键一环:能力面不再
|
|
141
|
+
* 只能由人类预先装好,模型可以参与发现与补齐。
|
|
142
|
+
*
|
|
143
|
+
* ## 无副作用契约(R1 零豁免的结构性保证,不是保守取舍)
|
|
144
|
+
*
|
|
145
|
+
* 本工具**只返回文本引导,绝不执行安装**。理由是安全而非谨慎:
|
|
146
|
+
* - 工具无任何写盘/装载副作用 → 结构上不存在"模型自己把插件装上了"的路径;
|
|
147
|
+
* - 用户执行 `otto extension install` 时走的是既有 `runPluginInstall` —— 高危能力确认
|
|
148
|
+
* 弹窗 → `trustPlugin`/`grantPluginCapabilities`,与人类第三方插件**完全同一条路径**;
|
|
149
|
+
* - **不新增任何 scope/来源标记**来区分"模型生成的插件"。RFC-229 §10 的事故(借
|
|
150
|
+
* `builtin` scope 绕过信任门)已经证明:任何为自动化开的旁路,最终都会变成提权通道。
|
|
151
|
+
*
|
|
152
|
+
* 因此"模型能造插件"与"模型能给自己装插件"是两件事——本里程碑只做前者。
|
|
153
|
+
*/
|
|
154
|
+
declare const CapabilityGapArgsSchema: z.ZodObject<{
|
|
155
|
+
need: z.ZodString;
|
|
156
|
+
searchTerms: z.ZodArray<z.ZodString>;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
type CapabilityGapArgs = z.infer<typeof CapabilityGapArgsSchema>;
|
|
159
|
+
/** registry 命中项(宿主侧检索后回传的最小投影)。 */
|
|
160
|
+
interface CapabilityGapHit {
|
|
161
|
+
id: string;
|
|
162
|
+
description: string;
|
|
163
|
+
/** 能力预披露(registry 声明值,非执法源——真实执法在安装时的 manifest 信任门)。 */
|
|
164
|
+
capabilities?: string[];
|
|
165
|
+
sourceName: string;
|
|
166
|
+
/** registry 缓存已过期(结果可能不是最新)。 */
|
|
167
|
+
stale?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 宿主注入的生态检索能力。返回 `undefined` 表示 registry 不可达(网络/配置问题)——
|
|
171
|
+
* 与"检索到 0 条"是不同语义,前者要如实告知模型"没查成"而非"生态里没有"。
|
|
172
|
+
*/
|
|
173
|
+
type SearchEcosystem = (searchTerms: string[]) => Promise<{
|
|
174
|
+
hits: CapabilityGapHit[];
|
|
175
|
+
warnings: string[];
|
|
176
|
+
} | undefined>;
|
|
177
|
+
/**
|
|
178
|
+
* 会话级去重键:searchTerms 归一化(小写 + 去重 + 排序 + 连接)。
|
|
179
|
+
*
|
|
180
|
+
* 用 searchTerms 而非 `need` 做键——`need` 是自由文本,同一缺口每轮措辞都可能不同,
|
|
181
|
+
* 用它去重等于不去重;searchTerms 是模型给出的检索意图,重复上报时高度稳定。
|
|
182
|
+
*/
|
|
183
|
+
declare function capabilityGapDedupKey(searchTerms: string[]): string;
|
|
184
|
+
declare function createCapabilityGap(searchEcosystem?: SearchEcosystem): AgentTool<CapabilityGapArgs>;
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/shell/execution-backend.d.ts
|
|
187
|
+
interface ExecutionBackendOptions {
|
|
188
|
+
cwd?: string;
|
|
189
|
+
env?: Record<string, string>;
|
|
190
|
+
/** 毫秒。超时后后端应自行终止命令并在结果里标 `timedOut: true`。 */
|
|
191
|
+
timeout: number;
|
|
192
|
+
/** 触发时后端应尽快终止命令(不保证立即,语义与本地 SIGTERM→SIGKILL 分级一致)。 */
|
|
193
|
+
signal?: AbortSignal;
|
|
194
|
+
}
|
|
195
|
+
interface ExecutionResult {
|
|
196
|
+
/** stdout+stderr 按到达顺序交错合并的全量字节流(与现有 `SpawnExecuteResult.chunks` 语义一致)。 */
|
|
197
|
+
chunks: Buffer;
|
|
198
|
+
stdout: Buffer;
|
|
199
|
+
stderr: Buffer;
|
|
200
|
+
exitCode: number;
|
|
201
|
+
timedOut: boolean;
|
|
202
|
+
}
|
|
203
|
+
type ExecutionProgressCallback = (chunk: Buffer, source: StreamSource) => void;
|
|
204
|
+
interface ExecutionBackend {
|
|
205
|
+
/** 后端标识名(日志/调试/配置文件选择用)。 */
|
|
206
|
+
readonly name: string;
|
|
207
|
+
/**
|
|
208
|
+
* 执行一条命令,返回聚合后的 stdout/stderr/exitCode。
|
|
209
|
+
* 超时应 reject(与现有 `process.spawn()` 行为一致:`Process timed out after ${timeout}ms`);
|
|
210
|
+
* 非超时失败(如 spawn 本身失败)应 reject 底层错误;正常退出(含非零 exitCode)应 resolve。
|
|
211
|
+
*/
|
|
212
|
+
execute(command: string, args: string[], options: ExecutionBackendOptions, onProgress?: ExecutionProgressCallback): Promise<ExecutionResult>;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 晚绑定 provider(M16a `SandboxProvider` 同款范式,见 `bash.ts` 对 `sandbox` 的解析方式)。
|
|
216
|
+
* 无参数——是否用某个执行后端通常是会话/全局级配置,不存在"按命令名选后端"的真实场景
|
|
217
|
+
* (对比 `SandboxProvider` 接受 `{command}` 上下文用于命令级 bypass 决策,见 RFC-297 D1a
|
|
218
|
+
* 自查补充说明)。未来若出现命令级选择后端的真实需求,再按需给 provider 加参数。
|
|
219
|
+
*/
|
|
220
|
+
type ExecutionBackendProvider = () => ExecutionBackend;
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/shell/process.d.ts
|
|
223
|
+
type StreamSource = 'stdout' | 'stderr';
|
|
224
|
+
type ProgressCallback = (chunk: Buffer, source: StreamSource) => void;
|
|
225
|
+
interface SpawnExecuteOptions {
|
|
226
|
+
timeout: number;
|
|
227
|
+
cwd?: string;
|
|
228
|
+
signal?: AbortSignal;
|
|
229
|
+
env?: Record<string, string>;
|
|
230
|
+
onProgress?: ProgressCallback;
|
|
231
|
+
/** OS 级沙箱策略。未注入时直接 spawn(保持兼容行为)。 */
|
|
232
|
+
sandbox?: SandboxStrategy;
|
|
233
|
+
/**
|
|
234
|
+
* 项目根目录(沙箱可写域锚点)。
|
|
235
|
+
* 与 cwd 是不同概念:cwd 是命令工作目录(bash targetDir,可为项目子目录),
|
|
236
|
+
* projectRoot 是沙箱允许写入的根。未传时回退 cwd(兼容直接调 spawn 的用法)。
|
|
237
|
+
*/
|
|
238
|
+
projectRoot?: string;
|
|
239
|
+
/**
|
|
240
|
+
* RFC-297:可插拔命令执行后端。未提供时回退 `LocalExecutionBackend`(即本函数迁移前的
|
|
241
|
+
* 原生 `node:child_process.spawn` 行为,零回归)。可传实例或晚绑定 provider。
|
|
242
|
+
*/
|
|
243
|
+
backend?: ExecutionBackend | ExecutionBackendProvider;
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/shell/sandbox/types.d.ts
|
|
247
|
+
/**
|
|
248
|
+
* OS 级沙箱策略接口(M16a)。
|
|
249
|
+
*
|
|
250
|
+
* 在 spawn() 层注入,包装 child_process.spawn 的参数以在隔离环境中执行命令。
|
|
251
|
+
* 与 coding/session/sandbox.ts 的 SandboxRunner(L2 重执行隔离)是不同关注点:
|
|
252
|
+
* 本接口用于**首次执行即隔离**,非重放沙箱。
|
|
253
|
+
*/
|
|
254
|
+
interface SandboxStrategy {
|
|
255
|
+
/** 策略标识名(用于日志/调试/配置文件选择)。 */
|
|
256
|
+
readonly name: string;
|
|
257
|
+
/**
|
|
258
|
+
* 包装 spawn 参数,返回经沙箱包装后的 command / args / options。
|
|
259
|
+
* spawn() 使用返回的参数执行,对上游调用方完全透明。
|
|
260
|
+
*/
|
|
261
|
+
wrap(input: SandboxWrapInput): SandboxWrapResult;
|
|
262
|
+
/**
|
|
263
|
+
* 释放沙箱持有的临时资源(临时文件等)。
|
|
264
|
+
* 应在不再需要该策略实例时调用。
|
|
265
|
+
*/
|
|
266
|
+
dispose(): Promise<void>;
|
|
267
|
+
}
|
|
268
|
+
interface SandboxWrapInput {
|
|
269
|
+
/** 要执行的命令(如 'sh') */
|
|
270
|
+
command: string;
|
|
271
|
+
/** 命令参数(如 ['-c', 'echo hello']) */
|
|
272
|
+
args: string[];
|
|
273
|
+
/** spawn 选项(cwd / timeout / signal / env / onProgress) */
|
|
274
|
+
options: SpawnExecuteOptions;
|
|
275
|
+
/** 项目根目录(用于路径约束;沙箱通常将可写范围限定在此目录内) */
|
|
276
|
+
projectRoot: string;
|
|
277
|
+
}
|
|
278
|
+
interface SandboxWrapResult {
|
|
279
|
+
/** 经沙箱包装后的命令 */
|
|
280
|
+
command: string;
|
|
281
|
+
/** 经沙箱包装后的参数 */
|
|
282
|
+
args: string[];
|
|
283
|
+
/** 经沙箱包装后的选项(可修改 cwd / env 等) */
|
|
284
|
+
options: SpawnExecuteOptions;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* 沙箱策略晚绑定提供者(M16a settings 接线)。
|
|
288
|
+
*
|
|
289
|
+
* createBash 在工具创建期注入,但策略本身可在运行期变化
|
|
290
|
+
* (settings.sandbox 在 app.start() 才 load,且支持热更新)。
|
|
291
|
+
* 每次命令执行时调用,返回当前生效策略;undefined = 无沙箱。
|
|
292
|
+
* M4 1b-2:可选 ctx 让提供者按当前操作裁决——被批准 bypass 的命令返回 undefined(该次不套沙箱)。
|
|
293
|
+
*/
|
|
294
|
+
type SandboxProvider = (ctx?: {
|
|
295
|
+
command?: string;
|
|
296
|
+
}) => SandboxStrategy | undefined;
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/shell/background-types.d.ts
|
|
299
|
+
/**
|
|
300
|
+
* 后台进程注册表的结构化 port。
|
|
301
|
+
*
|
|
302
|
+
* tools 与 runtime 互不依赖(都依赖 agent),故此处定义工具侧所需的最小接口,
|
|
303
|
+
* runtime 的 `ProcessRegistry`(含 `globalProcessRegistry` 单例)结构化满足它,
|
|
304
|
+
* 由组合根(coding)注入。避免 tools→runtime 循环依赖。
|
|
305
|
+
*/
|
|
306
|
+
type BackgroundProcessStatus = 'running' | 'killing' | 'exited' | 'killed';
|
|
307
|
+
/** RFC-223:委托后台进程的服务协议分类——从运行时输出识别,best-effort。 */
|
|
308
|
+
type ServiceProtocol = 'http' | 'ws' | 'tcp';
|
|
309
|
+
/** RFC-223:从后台进程运行时输出识别到的服务信息(url 优先,退化到纯端口)。 */
|
|
310
|
+
interface DetectedService {
|
|
311
|
+
url?: string;
|
|
312
|
+
port?: number;
|
|
313
|
+
protocol: ServiceProtocol;
|
|
314
|
+
}
|
|
315
|
+
interface BackgroundProcessInfo {
|
|
316
|
+
id: string;
|
|
317
|
+
sessionId: string;
|
|
318
|
+
pid: number;
|
|
319
|
+
command: string;
|
|
320
|
+
status: BackgroundProcessStatus;
|
|
321
|
+
exitCode?: number;
|
|
322
|
+
logPath?: string;
|
|
323
|
+
port?: number;
|
|
324
|
+
url?: string;
|
|
325
|
+
startedAt: number;
|
|
326
|
+
/** RFC-223:运行时输出识别到的服务信息(比 port/url 更精确时覆盖,见 D2 去重规则)。 */
|
|
327
|
+
detectedService?: DetectedService;
|
|
328
|
+
}
|
|
329
|
+
interface BackgroundProcessRegisterInput {
|
|
330
|
+
id: string;
|
|
331
|
+
sessionId: string;
|
|
332
|
+
/** 子进程句柄:注册表据此监听自然退出 + 推导 pgid。 */
|
|
333
|
+
child: ChildProcess;
|
|
334
|
+
command: string;
|
|
335
|
+
cwd: string;
|
|
336
|
+
logPath?: string;
|
|
337
|
+
port?: number;
|
|
338
|
+
url?: string;
|
|
339
|
+
}
|
|
340
|
+
interface BackgroundProcessPort {
|
|
341
|
+
register(input: BackgroundProcessRegisterInput): BackgroundProcessInfo;
|
|
342
|
+
get(id: string): BackgroundProcessInfo | undefined;
|
|
343
|
+
getForSession(sessionId: string, id: string): BackgroundProcessInfo | undefined;
|
|
344
|
+
listForSession(sessionId: string): BackgroundProcessInfo[];
|
|
345
|
+
/** 优雅停止:SIGTERM→grace→SIGKILL。 */
|
|
346
|
+
kill(id: string): Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* RFC-223:运行时输出识别到新的服务信息时调用(D2 去重规则由实现方——`ProcessRegistry`
|
|
349
|
+
* ——内部处理:"最近一条更优先":新 URL 覆盖旧 URL/无 URL;新 port-only 不覆盖已有 URL)。
|
|
350
|
+
* 进程已不在册(已退出/被驱逐)时静默忽略,不抛错。
|
|
351
|
+
*/
|
|
352
|
+
updateDetectedService(id: string, service: DetectedService): void;
|
|
353
|
+
}
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/orchestration/capture-file-state.d.ts
|
|
356
|
+
declare const CaptureFileStateArgsSchema: z.ZodObject<{
|
|
357
|
+
plan_status: z.ZodOptional<z.ZodString>;
|
|
358
|
+
recent_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
359
|
+
findings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
360
|
+
}, z.core.$strip>;
|
|
361
|
+
type CaptureFileStateArgs = z.infer<typeof CaptureFileStateArgsSchema>;
|
|
362
|
+
type CaptureFileState = (args: {
|
|
363
|
+
planStatus?: string;
|
|
364
|
+
recentFiles?: string[];
|
|
365
|
+
findings?: string[];
|
|
366
|
+
}) => Promise<{
|
|
367
|
+
success: boolean;
|
|
368
|
+
summary: string;
|
|
369
|
+
timestamp: number;
|
|
370
|
+
}>;
|
|
371
|
+
declare function createCaptureFileState(captureFileState?: CaptureFileState): AgentTool<CaptureFileStateArgs>;
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/orchestration/learn.d.ts
|
|
374
|
+
declare const LearnArgsSchema: z.ZodObject<{
|
|
375
|
+
tags: z.ZodArray<z.ZodString>;
|
|
376
|
+
trigger: z.ZodString;
|
|
377
|
+
insight: z.ZodString;
|
|
378
|
+
scope: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
379
|
+
workspace: "workspace";
|
|
380
|
+
local: "local";
|
|
381
|
+
}>>>;
|
|
382
|
+
}, z.core.$strip>;
|
|
383
|
+
type LearnArgs = z.infer<typeof LearnArgsSchema>;
|
|
384
|
+
type LearnCallback = (args: {
|
|
385
|
+
tags: string[];
|
|
386
|
+
trigger: string;
|
|
387
|
+
insight: string;
|
|
388
|
+
sessionId: string;
|
|
389
|
+
scope?: 'workspace' | 'local';
|
|
390
|
+
}) => Promise<{
|
|
391
|
+
success: boolean;
|
|
392
|
+
lessonId?: string; /** RFC-036 R4:命中近似既有经验、复用而非新增(去重)。 */
|
|
393
|
+
deduped?: boolean;
|
|
394
|
+
error?: string;
|
|
395
|
+
}>;
|
|
396
|
+
declare function createLearn(sessionId: string, learn?: LearnCallback): AgentTool<LearnArgs>;
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/orchestration/list-models.d.ts
|
|
399
|
+
interface ModelCatalogEntry {
|
|
400
|
+
id: string;
|
|
401
|
+
provider: string;
|
|
402
|
+
/** 能力优势标签(planning/knowledge/coding/reasoning/vision/speed/long-context)。 */
|
|
403
|
+
strengths: string[];
|
|
404
|
+
/** 是否经实时拉取确认「当前账号可用」(会话配置内)。 */
|
|
405
|
+
available: boolean;
|
|
406
|
+
/**
|
|
407
|
+
* 是否通过 usability gate(已认证 + 非 429 风险)——subagent 选型应只从 usable!==false 中选。
|
|
408
|
+
* 缺省(undefined)视为可用(host 未提供 gate 信息时向后兼容)。
|
|
409
|
+
*/
|
|
410
|
+
usable?: boolean;
|
|
411
|
+
/** usable===false 时的原因(unauthenticated / oauth-429-risk),供 LLM 理解为何不可选。 */
|
|
412
|
+
unusableReason?: string;
|
|
413
|
+
}
|
|
414
|
+
/** host 注入:按 sessionId 返回该会话的模型目录(含会话级可用集合 + 可用性)。可同步或异步。 */
|
|
415
|
+
type ModelCatalogQuery = (sessionId?: string) => ModelCatalogEntry[] | Promise<ModelCatalogEntry[]>;
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/session/session-manager.d.ts
|
|
418
|
+
declare const SessionManagerArgsSchema: z.ZodObject<{
|
|
419
|
+
action: z.ZodEnum<{
|
|
420
|
+
list: "list";
|
|
421
|
+
create: "create";
|
|
422
|
+
remove: "remove";
|
|
423
|
+
compact: "compact";
|
|
424
|
+
}>;
|
|
425
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
426
|
+
title: z.ZodOptional<z.ZodString>;
|
|
427
|
+
}, z.core.$strip>;
|
|
428
|
+
type SessionManagerArgs = z.infer<typeof SessionManagerArgsSchema>;
|
|
429
|
+
interface SessionManagerTool {
|
|
430
|
+
list: () => Promise<Array<{
|
|
431
|
+
id: string;
|
|
432
|
+
title: string;
|
|
433
|
+
messageCount: number;
|
|
434
|
+
}>>;
|
|
435
|
+
create: (title?: string) => Promise<{
|
|
436
|
+
id: string;
|
|
437
|
+
}>;
|
|
438
|
+
remove: (id: string) => Promise<boolean>;
|
|
439
|
+
compact: (id: string) => Promise<boolean>;
|
|
440
|
+
}
|
|
441
|
+
interface SessionManagerToolOptions {
|
|
442
|
+
sessionManager?: SessionManagerTool;
|
|
443
|
+
}
|
|
444
|
+
declare function createSessionManagerTool(options: SessionManagerToolOptions): AgentTool<SessionManagerArgs>;
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/skill/skill.d.ts
|
|
447
|
+
type LoadSkill = (path: string) => Promise<{
|
|
448
|
+
success: boolean;
|
|
449
|
+
name?: string;
|
|
450
|
+
error?: string;
|
|
451
|
+
}>;
|
|
452
|
+
type ExecuteSkill = (name: string) => Promise<{
|
|
453
|
+
success: boolean;
|
|
454
|
+
content?: string;
|
|
455
|
+
error?: string;
|
|
456
|
+
}>;
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/memory/memory-record.d.ts
|
|
459
|
+
type RecordMemory = (entry: {
|
|
460
|
+
name: string;
|
|
461
|
+
description: string;
|
|
462
|
+
content: string;
|
|
463
|
+
scope?: 'workspace' | 'local' | 'project-shared';
|
|
464
|
+
}) => Promise<void>;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/memory/memory-read.d.ts
|
|
467
|
+
type ReadMemory = (name: string) => Promise<string | null>;
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/orchestration/delegation-runners.d.ts
|
|
470
|
+
/**
|
|
471
|
+
* 委派 runner 回调契约(M90-02):宿主注入给 `task_delegate` 的 fork/team 执行体。
|
|
472
|
+
* 原分别定义在 fork-call.ts / team-run.ts;那两个独立工具已被 task_delegate 的
|
|
473
|
+
* mode=fork/team 吸收(§10 C5),类型抽到此中性处供工具面与 register-builtin 共用。
|
|
474
|
+
*/
|
|
475
|
+
/** mode=fork:在全新隔离会话里跑 prompt-only 子任务(不继承父上下文,§10 C15)。 */
|
|
476
|
+
type ForkRunner = (prompt: string, depth?: number, signal?: AbortSignal) => Promise<{
|
|
477
|
+
ok: boolean;
|
|
478
|
+
value?: string;
|
|
479
|
+
error?: string;
|
|
480
|
+
}>;
|
|
481
|
+
/** mode=team:跑声明式多 agent team(topology 由 swarm 决,.otto/teams/*.md)。 */
|
|
482
|
+
type RunTeam = (team: string, input: string, signal?: AbortSignal, depth?: number) => Promise<{
|
|
483
|
+
success: boolean;
|
|
484
|
+
output?: string;
|
|
485
|
+
pattern?: string;
|
|
486
|
+
error?: string;
|
|
487
|
+
}>;
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/register-builtin.d.ts
|
|
490
|
+
interface OrchestrationCapability {
|
|
491
|
+
dispatchTask: TaskDispatch;
|
|
492
|
+
getTask?: GetTask;
|
|
493
|
+
listTasks?: ListTasks;
|
|
494
|
+
updateTask?: UpdateTask;
|
|
495
|
+
getBackgroundOutput?: GetBackgroundOutput;
|
|
496
|
+
cancelBackground?: CancelBackground;
|
|
497
|
+
writeTodos?: WriteTodos;
|
|
498
|
+
/** 起一个隔离可变作业(origin:'main')。缺省 → delegate_job 回 missingCapability。 */
|
|
499
|
+
startJob?: StartJob;
|
|
500
|
+
}
|
|
501
|
+
interface AgentsCapability {
|
|
502
|
+
callAgent: CallAgent;
|
|
503
|
+
}
|
|
504
|
+
interface ForkCapability {
|
|
505
|
+
fork: ForkRunner;
|
|
506
|
+
}
|
|
507
|
+
interface SkillsCapability {
|
|
508
|
+
loadSkill: LoadSkill;
|
|
509
|
+
executeSkill: ExecuteSkill;
|
|
510
|
+
}
|
|
511
|
+
interface MemoryCapability {
|
|
512
|
+
recordMemory: RecordMemory;
|
|
513
|
+
readMemory: ReadMemory;
|
|
514
|
+
/**
|
|
515
|
+
* RFC-340 M2:会话归档召回(压缩折叠掉的历史全文)。
|
|
516
|
+
*
|
|
517
|
+
* **可选**——归档重建依赖 `MemoryManager` 的 `loadSessionEntries` 注入,V 形态/
|
|
518
|
+
* 无持久化会话拿不到。缺省时归档工具整组**不注册**(`tool-nodes` 的 `when` 门),
|
|
519
|
+
* 模型看不到它,而不是注册一个恒失败的工具(对齐 `capabilityGap` 既有纪律)。
|
|
520
|
+
*/
|
|
521
|
+
archive?: {
|
|
522
|
+
read: ReadArchive;
|
|
523
|
+
list: ListArchives;
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
interface TeamCapability {
|
|
527
|
+
runTeam: RunTeam;
|
|
528
|
+
}
|
|
529
|
+
interface SessionCapability {
|
|
530
|
+
manager: SessionManagerTool;
|
|
531
|
+
}
|
|
532
|
+
interface FeaturesCapability {
|
|
533
|
+
captureFileState?: CaptureFileState;
|
|
534
|
+
learn?: LearnCallback;
|
|
535
|
+
sessionId?: string;
|
|
536
|
+
/** LSP 工具 opt-in(语言服务器需本机安装;缺省不注册)。 */
|
|
537
|
+
enableLsp?: boolean;
|
|
538
|
+
/**
|
|
539
|
+
* bash OS 级沙箱策略(缺省 = 无沙箱,保持兼容)。
|
|
540
|
+
* provider 形态支持晚绑定:settings.sandbox 在 app.start() 才 load 且可热更新。
|
|
541
|
+
*/
|
|
542
|
+
sandbox?: SandboxStrategy | SandboxProvider;
|
|
543
|
+
/** HITL grill 能力(按 sessionId 路由到会话闸)。缺省 → grill_me 兜底 fail-soft。 */
|
|
544
|
+
grill?: SessionGrill;
|
|
545
|
+
/** 列出当前会话可用模型 + 能力优势(供 list_models 工具 → subagent 选型)。 */
|
|
546
|
+
listModels?: ModelCatalogQuery;
|
|
547
|
+
/**
|
|
548
|
+
* 后台进程注册表 port。注入 → bash 支持 run_in_background +
|
|
549
|
+
* 注册 bash_output/kill_shell;缺省 → run_in_background 优雅降级为前台。
|
|
550
|
+
*/
|
|
551
|
+
processRegistry?: BackgroundProcessPort;
|
|
552
|
+
}
|
|
553
|
+
interface RegisterBuiltinOptions {
|
|
554
|
+
orchestration: OrchestrationCapability;
|
|
555
|
+
agents: AgentsCapability;
|
|
556
|
+
fork?: ForkCapability;
|
|
557
|
+
skills?: SkillsCapability;
|
|
558
|
+
memory?: MemoryCapability;
|
|
559
|
+
team?: TeamCapability;
|
|
560
|
+
session?: SessionCapability;
|
|
561
|
+
features?: FeaturesCapability;
|
|
562
|
+
/** task_delegate 描述所需的 declared agent profile 列表 */
|
|
563
|
+
agentProfiles?: Array<{
|
|
564
|
+
name: string;
|
|
565
|
+
description: string;
|
|
566
|
+
preferredModelTier?: string;
|
|
567
|
+
}>;
|
|
568
|
+
/** Schedule callbacks (schedule_create/list/delete/run/cancel tools). */
|
|
569
|
+
schedule?: {
|
|
570
|
+
readonly create: ScheduleCreateCallback;
|
|
571
|
+
readonly list: ScheduleListCallback;
|
|
572
|
+
readonly delete: ScheduleDeleteCallback;
|
|
573
|
+
readonly run: ScheduleRunCallback;
|
|
574
|
+
readonly cancel: ScheduleCancelCallback;
|
|
575
|
+
};
|
|
576
|
+
/** RFC-287 M4:自迭代回路的生态检索能力(缺省 → capability_gap 工具不注册)。 */
|
|
577
|
+
capabilityGap?: {
|
|
578
|
+
readonly search: SearchEcosystem;
|
|
579
|
+
};
|
|
580
|
+
/** RFC-095:进程追踪器(组合根注入,替代 globalProcessRuntime)。 */
|
|
581
|
+
processTracker?: _$_x_otto_interchange0.ProcessTracker;
|
|
582
|
+
}
|
|
583
|
+
declare function registerBuiltinTools(registry: ToolRegistry, projectRoot: string, options: RegisterBuiltinOptions): void;
|
|
584
|
+
//#endregion
|
|
585
|
+
//#region src/types.d.ts
|
|
586
|
+
interface ToolMetadata {
|
|
587
|
+
preset: ToolPreset;
|
|
588
|
+
category?: string;
|
|
589
|
+
builtin: boolean;
|
|
590
|
+
snippet?: string;
|
|
591
|
+
guideline?: string;
|
|
592
|
+
/**
|
|
593
|
+
* 注册来源标签(RFC-105 D4/R2):插件工具打 `pluginId`,供 `unregisterBySource` 批量清理。
|
|
594
|
+
* 内置工具/MCP 工具不设置(MCP 走既有 `mcp__` 前缀 unregister 约定,不用此字段)。
|
|
595
|
+
*/
|
|
596
|
+
source?: string;
|
|
597
|
+
}
|
|
598
|
+
interface RegisteredTool<Args = unknown> extends AgentTool<Args> {
|
|
599
|
+
metadata: ToolMetadata;
|
|
600
|
+
}
|
|
601
|
+
interface ToolRegistrationOptions {
|
|
602
|
+
preset?: ToolPreset;
|
|
603
|
+
category?: string;
|
|
604
|
+
builtin?: boolean;
|
|
605
|
+
snippet?: string;
|
|
606
|
+
guideline?: string;
|
|
607
|
+
/** description 函数求值所需的 projectRoot,注册时传。 */
|
|
608
|
+
projectRoot?: string;
|
|
609
|
+
/** 注册来源(RFC-105 D4):插件装载器传 `pluginId`。 */
|
|
610
|
+
source?: string;
|
|
611
|
+
}
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region src/tool-registry.d.ts
|
|
614
|
+
declare class ToolRegistry {
|
|
615
|
+
private readonly tools;
|
|
616
|
+
private binaryToolExecutors;
|
|
617
|
+
private readonly disposers;
|
|
618
|
+
/**
|
|
619
|
+
* RFC-303 D4:工具面变更通知(register/unregister/unregisterBySource 后调用)。
|
|
620
|
+
* 由宿主(App)注入,桥接为 monitor 事件 `tool.registered`/`tool.unregistered`。
|
|
621
|
+
* 可选——不注入则工具增减不对外广播(不影响注册/注销本身)。
|
|
622
|
+
*/
|
|
623
|
+
onMutation?: (delta: {
|
|
624
|
+
added?: string[];
|
|
625
|
+
removed?: string[];
|
|
626
|
+
source?: string;
|
|
627
|
+
}) => void;
|
|
628
|
+
get size(): number;
|
|
629
|
+
setBinaryToolExecutors(registry: BinaryToolExecutorRegistry): void;
|
|
630
|
+
getBinaryToolExecutors(): BinaryToolExecutorRegistry;
|
|
631
|
+
/** 注册随 registry dispose(app stop)一并释放的清理函数(如 browser session)。best-effort。 */
|
|
632
|
+
registerDisposer(disposer: () => void | Promise<void>): void;
|
|
633
|
+
register(tool: unknown, options?: ToolRegistrationOptions): void;
|
|
634
|
+
register(tools: unknown[], options?: ToolRegistrationOptions): void;
|
|
635
|
+
unregister(name: string): boolean;
|
|
636
|
+
unregister(name: string[]): boolean;
|
|
637
|
+
/**
|
|
638
|
+
* 注销某来源注册的全部工具(RFC-105 D4/R2:插件卸载/reload 批量清理)。
|
|
639
|
+
* 只清理 `metadata.source === source` 的条目——不影响内置工具(source 未设置)或
|
|
640
|
+
* 其他来源。返回注销数量。
|
|
641
|
+
*/
|
|
642
|
+
unregisterBySource(source: string): number;
|
|
643
|
+
get(name: string): RegisteredTool | undefined;
|
|
644
|
+
has(name: string): boolean;
|
|
645
|
+
getAll(): RegisteredTool[];
|
|
646
|
+
getAvailable(preset?: ToolPreset): RegisteredTool[];
|
|
647
|
+
/** M33-02:按 preset 投影并三分流——direct 进模型列表 / deferred 进 tool_search / hidden 仅 dispatch。 */
|
|
648
|
+
project(preset?: ToolPreset): {
|
|
649
|
+
direct: RegisteredTool[];
|
|
650
|
+
deferred: RegisteredTool[];
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* Tool Reference 段的默认总预算(tokens)。同 `@x-otto/memory` 的预算门同一治理动机——
|
|
654
|
+
* MCP/插件工具经 `register()` 的 `guideline`/`snippet` 选项可贡献任意长度文本,
|
|
655
|
+
* 且无 per-tool 上限;已安装插件数量增长时这段会无界累积(同 skill catalog 此前的
|
|
656
|
+
* 问题)。本仓 full preset 实测 ~1.7k tokens,取 3 倍留余量,同时挡住"装了一堆长
|
|
657
|
+
* guideline 插件"的极端场景。
|
|
658
|
+
*/
|
|
659
|
+
private static readonly TOOL_GUIDANCE_BUDGET_TOKENS;
|
|
660
|
+
private static estimatedTokens;
|
|
661
|
+
/**
|
|
662
|
+
* RFC-303 D6:exposure 泄漏修复——此前用 `getAvailable(preset)` 遍历全集,deferred
|
|
663
|
+
* (MCP 工具默认态)与 hidden 工具的完整 description 会被渐进披露契约以外的方式
|
|
664
|
+
* 泄漏进 system prompt(M33 的核心设计是"deferred 工具只能经 tool_search 按需发现",
|
|
665
|
+
* 但指引段一直在无条件展开它们的正文)。改用 `project(preset)` 统一投影:direct 集合
|
|
666
|
+
* 走原有分组渲染,deferred 集合只输出一行聚合提示(不展开 description,省 token 且不
|
|
667
|
+
* 破坏渐进披露),hidden 集合完全不出现(tool_search 也搜不到,仅供内部派发)。
|
|
668
|
+
*/
|
|
669
|
+
buildToolGuidance(preset?: ToolPreset): string;
|
|
670
|
+
clear(): void;
|
|
671
|
+
dispose(): void;
|
|
672
|
+
}
|
|
673
|
+
declare const createToolRegistry: (workspaceDir: string, options: RegisterBuiltinOptions) => ToolRegistry;
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region src/tool-nodes.d.ts
|
|
676
|
+
/**
|
|
677
|
+
* 工具装配上下文。**least-privilege**——只暴露工具装配真需的能力子集,
|
|
678
|
+
* 不再挂整包 `RegisterBuiltinOptions`(宿主编排全套)。每个能力按需注入命名字段,工具工厂无法
|
|
679
|
+
* 越权触达无关宿主编排细节(规则 10:能力层不泄漏宿主知识)。
|
|
680
|
+
*/
|
|
681
|
+
interface ToolNodeContext {
|
|
682
|
+
readonly projectRoot: string;
|
|
683
|
+
readonly registry: ToolRegistry;
|
|
684
|
+
readonly orchestration: OrchestrationCapability;
|
|
685
|
+
readonly agents: AgentsCapability;
|
|
686
|
+
readonly features: FeaturesCapability;
|
|
687
|
+
/** 统一降级:skills 缺组时已解析的占位实现(文案单源在 register-builtin)。 */
|
|
688
|
+
readonly loadSkill: LoadSkill;
|
|
689
|
+
readonly executeSkill: ExecuteSkill;
|
|
690
|
+
/** 委派 fork runner(task_delegate fork mode)。缺省 → 该路径优雅降级。 */
|
|
691
|
+
readonly fork?: ForkCapability;
|
|
692
|
+
/** 多代理 team runner(task_delegate team mode)。 */
|
|
693
|
+
readonly team?: TeamCapability;
|
|
694
|
+
/** 跨会话 memory 读写(memory_record/memory_read)。 */
|
|
695
|
+
readonly memory?: MemoryCapability;
|
|
696
|
+
/** 会话管理工具(session_manager)。缺省 → 整组跳过。 */
|
|
697
|
+
readonly session?: SessionCapability;
|
|
698
|
+
/** task_delegate 描述所需的 declared agent profile 列表。 */
|
|
699
|
+
readonly agentProfiles?: Array<{
|
|
700
|
+
name: string;
|
|
701
|
+
description: string;
|
|
702
|
+
preferredModelTier?: string;
|
|
703
|
+
}>;
|
|
704
|
+
/**
|
|
705
|
+
* RFC-287 M4:自迭代回路的生态检索能力。缺省 → `capability_gap` 工具不注册
|
|
706
|
+
* (`when` 门),模型看不到该工具。
|
|
707
|
+
*/
|
|
708
|
+
readonly capabilityGap?: {
|
|
709
|
+
readonly search: SearchEcosystem;
|
|
710
|
+
};
|
|
711
|
+
readonly schedule?: {
|
|
712
|
+
readonly create: ScheduleCreateCallback;
|
|
713
|
+
readonly list: ScheduleListCallback;
|
|
714
|
+
readonly delete: ScheduleDeleteCallback;
|
|
715
|
+
readonly run: ScheduleRunCallback;
|
|
716
|
+
readonly cancel: ScheduleCancelCallback;
|
|
717
|
+
};
|
|
718
|
+
/** RFC-095:进程追踪器(组合根注入)。 */
|
|
719
|
+
readonly processTracker?: ProcessTracker;
|
|
720
|
+
}
|
|
721
|
+
interface ToolNode {
|
|
722
|
+
/**
|
|
723
|
+
* 本节点产出的 canonical 工具名(**必填**)。register-builtin 无条件断言
|
|
724
|
+
* `create` 实产名集合 === names——漏声明或 create 漂移在注册时 fail-fast,不再静默绕过。
|
|
725
|
+
*/
|
|
726
|
+
readonly names: readonly string[];
|
|
727
|
+
readonly preset: ToolPreset;
|
|
728
|
+
readonly category: string;
|
|
729
|
+
/** 行为指南(注入 system prompt;同 category 同串在 buildToolGuidance 渲染时去重)。 */
|
|
730
|
+
readonly guidance?: string;
|
|
731
|
+
/** opt-in / 能力闸:缺省恒注册;返回 false → 整组跳过。 */
|
|
732
|
+
readonly when?: (ctx: ToolNodeContext) => boolean;
|
|
733
|
+
/** 工具构造(单一来源);返回该节点产出的一组工具。 */
|
|
734
|
+
readonly create: (ctx: ToolNodeContext) => AgentTool[];
|
|
735
|
+
}
|
|
736
|
+
declare const TOOL_NODES: readonly ToolNode[];
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/fs/read.d.ts
|
|
739
|
+
declare const ReadArgsSchema: z.ZodObject<{
|
|
740
|
+
path: z.ZodString;
|
|
741
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
742
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
743
|
+
}, z.core.$strip>;
|
|
744
|
+
type ReadArgs = z.infer<typeof ReadArgsSchema>;
|
|
745
|
+
declare function createRead(projectRoot: string): AgentTool<ReadArgs>;
|
|
746
|
+
//#endregion
|
|
747
|
+
//#region src/fs/write.d.ts
|
|
748
|
+
declare const WriteArgsSchema: z.ZodObject<{
|
|
749
|
+
path: z.ZodString;
|
|
750
|
+
content: z.ZodString;
|
|
751
|
+
createDirectories: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
752
|
+
}, z.core.$strip>;
|
|
753
|
+
type WriteArgs = z.infer<typeof WriteArgsSchema>;
|
|
754
|
+
declare function createWrite(projectRoot: string): AgentTool<WriteArgs>;
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region src/fs/edit.d.ts
|
|
757
|
+
declare const EditArgsSchema: z.ZodObject<{
|
|
758
|
+
path: z.ZodString;
|
|
759
|
+
oldContent: z.ZodString;
|
|
760
|
+
newContent: z.ZodString;
|
|
761
|
+
}, z.core.$strip>;
|
|
762
|
+
type EditArgs = z.infer<typeof EditArgsSchema>;
|
|
763
|
+
declare function createEdit(projectRoot: string): AgentTool<EditArgs>;
|
|
764
|
+
//#endregion
|
|
765
|
+
//#region src/orchestration/write-todos.d.ts
|
|
766
|
+
declare const WriteTodosArgsSchema: z.ZodObject<{
|
|
767
|
+
title: z.ZodOptional<z.ZodString>;
|
|
768
|
+
action: z.ZodEnum<{
|
|
769
|
+
set: "set";
|
|
770
|
+
update: "update";
|
|
771
|
+
}>;
|
|
772
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
773
|
+
id: z.ZodString;
|
|
774
|
+
title: z.ZodString;
|
|
775
|
+
status: z.ZodEnum<{
|
|
776
|
+
pending: "pending";
|
|
777
|
+
failed: "failed";
|
|
778
|
+
in_progress: "in_progress";
|
|
779
|
+
done: "done";
|
|
780
|
+
skipped: "skipped";
|
|
781
|
+
}>;
|
|
782
|
+
}, z.core.$strip>>;
|
|
783
|
+
}, z.core.$strip>;
|
|
784
|
+
type WriteTodosArgs = z.infer<typeof WriteTodosArgsSchema>;
|
|
785
|
+
declare function createWriteTodos(writeTodos?: WriteTodos): AgentTool<WriteTodosArgs>;
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region src/orchestration/agent-call-description.d.ts
|
|
788
|
+
/**
|
|
789
|
+
* agent-call-description.ts —— declared agent profiles 的描述段构建器(RFC-302 共享模块)。
|
|
790
|
+
*
|
|
791
|
+
* RFC-302(委派单一入口):原 `buildAgentCallDescription` 把「探询句 + agents 段」揉在
|
|
792
|
+
* 一个函数里,只服务 agent_call。合并后 agents 段由 task_delegate / agent_call 共用,
|
|
793
|
+
* 探询句由各调用方自己的静态主体提供——本函数只产「agents 段」:空 profiles → '',
|
|
794
|
+
* 非空 → 'Available agents:' 列表 + fuzzy match 提示(不带探询句,调用方拼接)。
|
|
795
|
+
* M3 结案时 agent_call 工厂删除,本共享模块保留。
|
|
796
|
+
*/
|
|
797
|
+
interface AgentSummary {
|
|
798
|
+
name: string;
|
|
799
|
+
description: string;
|
|
800
|
+
slot?: string;
|
|
801
|
+
readOnly?: boolean;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* 生成 declared agents 描述段(含 Available agents 列表 + fuzzy match 提示)。
|
|
805
|
+
* 空 profiles → ''(调用方描述回退为自己的静态主体)。拼接约定:`静态主体 + (段 ? '\n' + 段 : '')`,
|
|
806
|
+
* 与旧 buildAgentCallDescription 非空分支输出字节一致(探询句\nAvailable agents:…)。
|
|
807
|
+
*/
|
|
808
|
+
declare function buildDelegationAgentListDescription(profiles: AgentSummary[]): string;
|
|
809
|
+
//#endregion
|
|
810
|
+
//#region src/orchestration/task-inspect.d.ts
|
|
811
|
+
declare const TaskInspectArgsSchema: z.ZodObject<{
|
|
812
|
+
action: z.ZodEnum<{
|
|
813
|
+
output: "output";
|
|
814
|
+
get: "get";
|
|
815
|
+
list: "list";
|
|
816
|
+
}>;
|
|
817
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
818
|
+
statusFilter: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
819
|
+
all: "all";
|
|
820
|
+
pending: "pending";
|
|
821
|
+
running: "running";
|
|
822
|
+
completed: "completed";
|
|
823
|
+
failed: "failed";
|
|
824
|
+
cancelled: "cancelled";
|
|
825
|
+
}>>>;
|
|
826
|
+
}, z.core.$strip>;
|
|
827
|
+
type TaskInspectArgs = z.infer<typeof TaskInspectArgsSchema>;
|
|
828
|
+
interface TaskInspectOptions {
|
|
829
|
+
get?: GetTask;
|
|
830
|
+
list?: ListTasks;
|
|
831
|
+
output?: GetBackgroundOutput;
|
|
832
|
+
}
|
|
833
|
+
declare function createTaskInspect(_projectRoot: string, options: TaskInspectOptions): AgentTool<TaskInspectArgs>;
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region src/orchestration/task-control.d.ts
|
|
836
|
+
declare const TaskControlArgsSchema: z.ZodObject<{
|
|
837
|
+
action: z.ZodEnum<{
|
|
838
|
+
cancel: "cancel";
|
|
839
|
+
retry: "retry";
|
|
840
|
+
}>;
|
|
841
|
+
taskId: z.ZodString;
|
|
842
|
+
}, z.core.$strip>;
|
|
843
|
+
type TaskControlArgs = z.infer<typeof TaskControlArgsSchema>;
|
|
844
|
+
interface TaskControlOptions {
|
|
845
|
+
update?: UpdateTask;
|
|
846
|
+
cancelBackground?: CancelBackground;
|
|
847
|
+
}
|
|
848
|
+
declare function createTaskControl(_projectRoot: string, options: TaskControlOptions): AgentTool<TaskControlArgs>;
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region src/orchestration/tool-search.d.ts
|
|
851
|
+
declare const ToolSearchArgsSchema: z.ZodObject<{
|
|
852
|
+
query: z.ZodString;
|
|
853
|
+
}, z.core.$strip>;
|
|
854
|
+
type ToolSearchArgs = z.infer<typeof ToolSearchArgsSchema>;
|
|
855
|
+
declare function createToolSearch(/** 返回当前 deferred 工具池(由 registry.project() 提供)。 */
|
|
856
|
+
|
|
857
|
+
getDeferredTools: () => RegisteredTool[]): AgentTool<ToolSearchArgs>;
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/orchestration/constants.d.ts
|
|
860
|
+
/**
|
|
861
|
+
* 直接派生子代理的工具名(**子代理生成器 denylist**)——`allowSubagents=false` 时由
|
|
862
|
+
* session-config-resolver 据此剔除,防锁定 agent 递归起子代理。
|
|
863
|
+
*
|
|
864
|
+
* RFC-074 D9:这是 orchestration `category` 的**有意子集**(category 还含 write_todos/list_models/
|
|
865
|
+
* task_inspect 等管理类,非生成器,不应被剔),故不从 category 派生。新增"会起子代理"的工具时
|
|
866
|
+
* 必须在此登记;`tool-nodes.test` 的漂移守卫断言本集合 ⊆ 真实工具名(堵 team_run/fork_call 类幻影)。
|
|
867
|
+
*/
|
|
868
|
+
declare const ORCHESTRATION_TOOL_NAMES: Set<string>;
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/web/fetch.d.ts
|
|
871
|
+
declare const WebFetchArgsSchema: z.ZodObject<{
|
|
872
|
+
url: z.ZodString;
|
|
873
|
+
format: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
874
|
+
text: "text";
|
|
875
|
+
markdown: "markdown";
|
|
876
|
+
raw: "raw";
|
|
877
|
+
}>>>;
|
|
878
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
879
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
880
|
+
}, z.core.$strip>;
|
|
881
|
+
type WebFetchArgs = z.infer<typeof WebFetchArgsSchema>;
|
|
882
|
+
declare function createWebFetch(_projectRoot: string): AgentTool<WebFetchArgs>;
|
|
883
|
+
//#endregion
|
|
884
|
+
//#region src/web/search.d.ts
|
|
885
|
+
interface SearchResult {
|
|
886
|
+
title: string;
|
|
887
|
+
url: string;
|
|
888
|
+
snippet: string;
|
|
889
|
+
}
|
|
890
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
891
|
+
interface WebSearchProvider {
|
|
892
|
+
readonly id: string;
|
|
893
|
+
/** 结构化/官方 API=true;HTML 抓取(易随页面改版失效)=false → 输出标注不可靠。 */
|
|
894
|
+
readonly reliable: boolean;
|
|
895
|
+
search(query: string, limit: number, signal?: AbortSignal): Promise<SearchResult[]>;
|
|
896
|
+
}
|
|
897
|
+
declare const WebSearchArgsSchema: z.ZodObject<{
|
|
898
|
+
query: z.ZodString;
|
|
899
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
900
|
+
}, z.core.$strip>;
|
|
901
|
+
type WebSearchArgs = z.infer<typeof WebSearchArgsSchema>;
|
|
902
|
+
interface WebSearchOptions {
|
|
903
|
+
/** 直接注入 provider(测试/自定义后端)。优先于 env 推断。 */
|
|
904
|
+
provider?: WebSearchProvider;
|
|
905
|
+
/** Brave API key(覆盖 env)。 */
|
|
906
|
+
apiKey?: string;
|
|
907
|
+
fetchImpl?: FetchLike;
|
|
908
|
+
}
|
|
909
|
+
declare function createWebSearch(_projectRoot: string, options?: WebSearchOptions): AgentTool<WebSearchArgs>;
|
|
910
|
+
//#endregion
|
|
911
|
+
//#region src/lsp/types.d.ts
|
|
912
|
+
interface LSPServerConfig {
|
|
913
|
+
id: string;
|
|
914
|
+
command: string[];
|
|
915
|
+
extensions: string[];
|
|
916
|
+
disabled?: boolean;
|
|
917
|
+
env?: Record<string, string>;
|
|
918
|
+
initialization?: Record<string, unknown>;
|
|
919
|
+
}
|
|
920
|
+
interface Position {
|
|
921
|
+
line: number;
|
|
922
|
+
character: number;
|
|
923
|
+
}
|
|
924
|
+
interface Range {
|
|
925
|
+
start: Position;
|
|
926
|
+
end: Position;
|
|
927
|
+
}
|
|
928
|
+
interface Location {
|
|
929
|
+
uri: string;
|
|
930
|
+
range: Range;
|
|
931
|
+
}
|
|
932
|
+
interface LocationLink {
|
|
933
|
+
targetUri: string;
|
|
934
|
+
targetRange: Range;
|
|
935
|
+
targetSelectionRange: Range;
|
|
936
|
+
originSelectionRange?: Range;
|
|
937
|
+
}
|
|
938
|
+
interface SymbolInfo {
|
|
939
|
+
name: string;
|
|
940
|
+
kind: number;
|
|
941
|
+
location: Location;
|
|
942
|
+
containerName?: string;
|
|
943
|
+
}
|
|
944
|
+
interface DocumentSymbol {
|
|
945
|
+
name: string;
|
|
946
|
+
kind: number;
|
|
947
|
+
range: Range;
|
|
948
|
+
selectionRange: Range;
|
|
949
|
+
children?: DocumentSymbol[];
|
|
950
|
+
}
|
|
951
|
+
interface Diagnostic {
|
|
952
|
+
range: Range;
|
|
953
|
+
severity?: number;
|
|
954
|
+
code?: string | number;
|
|
955
|
+
source?: string;
|
|
956
|
+
message: string;
|
|
957
|
+
}
|
|
958
|
+
interface TextDocumentIdentifier {
|
|
959
|
+
uri: string;
|
|
960
|
+
}
|
|
961
|
+
interface VersionedTextDocumentIdentifier extends TextDocumentIdentifier {
|
|
962
|
+
version: number | null;
|
|
963
|
+
}
|
|
964
|
+
interface TextEdit {
|
|
965
|
+
range: Range;
|
|
966
|
+
newText: string;
|
|
967
|
+
}
|
|
968
|
+
interface TextDocumentEdit {
|
|
969
|
+
textDocument: VersionedTextDocumentIdentifier;
|
|
970
|
+
edits: TextEdit[];
|
|
971
|
+
}
|
|
972
|
+
interface CreateFile {
|
|
973
|
+
kind: 'create';
|
|
974
|
+
uri: string;
|
|
975
|
+
options?: {
|
|
976
|
+
overwrite?: boolean;
|
|
977
|
+
ignoreIfExists?: boolean;
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
interface RenameFile {
|
|
981
|
+
kind: 'rename';
|
|
982
|
+
oldUri: string;
|
|
983
|
+
newUri: string;
|
|
984
|
+
options?: {
|
|
985
|
+
overwrite?: boolean;
|
|
986
|
+
ignoreIfExists?: boolean;
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
interface DeleteFile {
|
|
990
|
+
kind: 'delete';
|
|
991
|
+
uri: string;
|
|
992
|
+
options?: {
|
|
993
|
+
recursive?: boolean;
|
|
994
|
+
ignoreIfNotExists?: boolean;
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
interface WorkspaceEdit {
|
|
998
|
+
changes?: {
|
|
999
|
+
[uri: string]: TextEdit[];
|
|
1000
|
+
};
|
|
1001
|
+
documentChanges?: (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[];
|
|
1002
|
+
}
|
|
1003
|
+
interface PrepareRenameResult {
|
|
1004
|
+
range: Range;
|
|
1005
|
+
placeholder?: string;
|
|
1006
|
+
}
|
|
1007
|
+
interface ServerLookupInfo {
|
|
1008
|
+
id: string;
|
|
1009
|
+
command: string[];
|
|
1010
|
+
extensions: string[];
|
|
1011
|
+
}
|
|
1012
|
+
type ServerLookupResult = {
|
|
1013
|
+
status: 'found';
|
|
1014
|
+
server: ResolvedServer;
|
|
1015
|
+
} | {
|
|
1016
|
+
status: 'not_configured';
|
|
1017
|
+
extension: string;
|
|
1018
|
+
availableServers: string[];
|
|
1019
|
+
} | {
|
|
1020
|
+
status: 'not_installed';
|
|
1021
|
+
server: ServerLookupInfo;
|
|
1022
|
+
installHint: string;
|
|
1023
|
+
};
|
|
1024
|
+
interface ResolvedServer {
|
|
1025
|
+
id: string;
|
|
1026
|
+
command: string[];
|
|
1027
|
+
extensions: string[];
|
|
1028
|
+
priority: number;
|
|
1029
|
+
env?: Record<string, string>;
|
|
1030
|
+
initialization?: Record<string, unknown>;
|
|
1031
|
+
/**
|
|
1032
|
+
* workspace/configuration 应答按 section 注入的配置(M6-09,去硬编码)。
|
|
1033
|
+
* 例:`{ json: { validate: { enable: true } } }`。未提供则 json 段回退默认、其余空对象。
|
|
1034
|
+
*/
|
|
1035
|
+
settings?: Record<string, unknown>;
|
|
1036
|
+
}
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region src/lsp/lsp-server-manager.d.ts
|
|
1039
|
+
declare class LSPServerManager {
|
|
1040
|
+
private static instance;
|
|
1041
|
+
private clients;
|
|
1042
|
+
private cleanupInterval;
|
|
1043
|
+
private readonly IDLE_TIMEOUT;
|
|
1044
|
+
private readonly INIT_TIMEOUT;
|
|
1045
|
+
/** RFC-095:进程追踪器(组合根注入)。 */
|
|
1046
|
+
private processTracker?;
|
|
1047
|
+
private constructor();
|
|
1048
|
+
static getInstance(): LSPServerManager;
|
|
1049
|
+
/** RFC-095:设置进程追踪器(组合根装配时调用)。 */
|
|
1050
|
+
setProcessTracker(tracker: ProcessTracker): void;
|
|
1051
|
+
private getKey;
|
|
1052
|
+
private startCleanupTimer;
|
|
1053
|
+
private cleanupIdleClients;
|
|
1054
|
+
getClient(root: string, server: ResolvedServer): Promise<LSPClient>;
|
|
1055
|
+
warmupClient(root: string, server: ResolvedServer): void;
|
|
1056
|
+
releaseClient(root: string, serverId: string): void;
|
|
1057
|
+
isServerInitializing(root: string, serverId: string): boolean;
|
|
1058
|
+
stopAll(): Promise<void>;
|
|
1059
|
+
}
|
|
1060
|
+
declare const lspManager: LSPServerManager;
|
|
1061
|
+
//#endregion
|
|
1062
|
+
//#region src/lsp/lsp-client.d.ts
|
|
1063
|
+
declare class LSPClient {
|
|
1064
|
+
private readonly root;
|
|
1065
|
+
private readonly server;
|
|
1066
|
+
private readonly processTracker?;
|
|
1067
|
+
private process;
|
|
1068
|
+
private nextId;
|
|
1069
|
+
private pending;
|
|
1070
|
+
private buffer;
|
|
1071
|
+
private contentLength;
|
|
1072
|
+
private processExited;
|
|
1073
|
+
private stderrBuffer;
|
|
1074
|
+
private diagnosticsStore;
|
|
1075
|
+
private readonly diagnosticsWaiter;
|
|
1076
|
+
private openedFiles;
|
|
1077
|
+
private documentVersions;
|
|
1078
|
+
private lastSyncedText;
|
|
1079
|
+
private readonly REQUEST_TIMEOUT;
|
|
1080
|
+
constructor(root: string, server: ResolvedServer, processTracker?: ProcessTracker | undefined);
|
|
1081
|
+
start(): Promise<void>;
|
|
1082
|
+
initialize(): Promise<void>;
|
|
1083
|
+
private rejectAllPending;
|
|
1084
|
+
stop(): Promise<void>;
|
|
1085
|
+
isAlive(): boolean;
|
|
1086
|
+
private processBuffer;
|
|
1087
|
+
private onMessage;
|
|
1088
|
+
private sendRequest;
|
|
1089
|
+
private sendNotification;
|
|
1090
|
+
private respond;
|
|
1091
|
+
openFile(filePath: string): Promise<void>;
|
|
1092
|
+
definition(filePath: string, line: number, character: number): Promise<unknown>;
|
|
1093
|
+
references(filePath: string, line: number, character: number, includeDeclaration?: boolean): Promise<unknown>;
|
|
1094
|
+
documentSymbols(filePath: string): Promise<unknown>;
|
|
1095
|
+
workspaceSymbols(query: string): Promise<unknown>;
|
|
1096
|
+
diagnostics(filePath: string): Promise<{
|
|
1097
|
+
items: Diagnostic[];
|
|
1098
|
+
}>;
|
|
1099
|
+
prepareRename(filePath: string, line: number, character: number): Promise<unknown>;
|
|
1100
|
+
rename(filePath: string, line: number, character: number, newName: string): Promise<unknown>;
|
|
1101
|
+
}
|
|
1102
|
+
//#endregion
|
|
1103
|
+
//#region src/lsp/lsp-wrapper.d.ts
|
|
1104
|
+
declare function findWorkspaceRoot(filePath: string): string;
|
|
1105
|
+
declare function withLspClient<T>(filePath: string, fn: (client: LSPClient) => Promise<T>): Promise<T>;
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/lsp/definition.d.ts
|
|
1108
|
+
declare const DefinitionArgsSchema: z.ZodObject<{
|
|
1109
|
+
filePath: z.ZodString;
|
|
1110
|
+
line: z.ZodNumber;
|
|
1111
|
+
character: z.ZodNumber;
|
|
1112
|
+
}, z.core.$strip>;
|
|
1113
|
+
type DefinitionArgs = z.infer<typeof DefinitionArgsSchema>;
|
|
1114
|
+
declare function createLspDefinition(_projectRoot: string): AgentTool<DefinitionArgs>;
|
|
1115
|
+
//#endregion
|
|
1116
|
+
//#region src/lsp/references.d.ts
|
|
1117
|
+
declare const ReferencesArgsSchema: z.ZodObject<{
|
|
1118
|
+
filePath: z.ZodString;
|
|
1119
|
+
line: z.ZodNumber;
|
|
1120
|
+
character: z.ZodNumber;
|
|
1121
|
+
includeDeclaration: z.ZodOptional<z.ZodBoolean>;
|
|
1122
|
+
}, z.core.$strip>;
|
|
1123
|
+
type ReferencesArgs = z.infer<typeof ReferencesArgsSchema>;
|
|
1124
|
+
declare function createLspReferences(_projectRoot: string): AgentTool<ReferencesArgs>;
|
|
1125
|
+
//#endregion
|
|
1126
|
+
//#region src/lsp/symbols.d.ts
|
|
1127
|
+
declare const SymbolsArgsSchema: z.ZodObject<{
|
|
1128
|
+
filePath: z.ZodString;
|
|
1129
|
+
scope: z.ZodDefault<z.ZodEnum<{
|
|
1130
|
+
workspace: "workspace";
|
|
1131
|
+
document: "document";
|
|
1132
|
+
}>>;
|
|
1133
|
+
query: z.ZodOptional<z.ZodString>;
|
|
1134
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
1135
|
+
}, z.core.$strip>;
|
|
1136
|
+
type SymbolsArgs = z.infer<typeof SymbolsArgsSchema>;
|
|
1137
|
+
declare function createLspSymbols(_projectRoot: string): AgentTool<SymbolsArgs>;
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region src/lsp/diagnostics.d.ts
|
|
1140
|
+
declare const DiagnosticsArgsSchema: z.ZodObject<{
|
|
1141
|
+
filePath: z.ZodString;
|
|
1142
|
+
severity: z.ZodOptional<z.ZodEnum<{
|
|
1143
|
+
error: "error";
|
|
1144
|
+
all: "all";
|
|
1145
|
+
warning: "warning";
|
|
1146
|
+
information: "information";
|
|
1147
|
+
hint: "hint";
|
|
1148
|
+
}>>;
|
|
1149
|
+
}, z.core.$strip>;
|
|
1150
|
+
type DiagnosticsArgs = z.infer<typeof DiagnosticsArgsSchema>;
|
|
1151
|
+
declare function createLspDiagnostics(_projectRoot: string): AgentTool<DiagnosticsArgs>;
|
|
1152
|
+
//#endregion
|
|
1153
|
+
//#region src/lsp/rename.d.ts
|
|
1154
|
+
declare const PrepareRenameArgsSchema: z.ZodObject<{
|
|
1155
|
+
filePath: z.ZodString;
|
|
1156
|
+
line: z.ZodNumber;
|
|
1157
|
+
character: z.ZodNumber;
|
|
1158
|
+
}, z.core.$strip>;
|
|
1159
|
+
type PrepareRenameArgs = z.infer<typeof PrepareRenameArgsSchema>;
|
|
1160
|
+
declare function createLspPrepareRename(_projectRoot: string): AgentTool<PrepareRenameArgs>;
|
|
1161
|
+
declare const RenameArgsSchema: z.ZodObject<{
|
|
1162
|
+
filePath: z.ZodString;
|
|
1163
|
+
line: z.ZodNumber;
|
|
1164
|
+
character: z.ZodNumber;
|
|
1165
|
+
newName: z.ZodString;
|
|
1166
|
+
}, z.core.$strip>;
|
|
1167
|
+
type RenameArgs = z.infer<typeof RenameArgsSchema>;
|
|
1168
|
+
declare function createLspRename(_projectRoot: string): AgentTool<RenameArgs>;
|
|
1169
|
+
//#endregion
|
|
1170
|
+
//#region src/shell/sandbox/noop.d.ts
|
|
1171
|
+
declare function createNoopSandbox(): SandboxStrategy;
|
|
1172
|
+
//#endregion
|
|
1173
|
+
//#region src/shell/sandbox/macos-seatbelt.d.ts
|
|
1174
|
+
/**
|
|
1175
|
+
* macOS Seatbelt 沙箱选项。
|
|
1176
|
+
*/
|
|
1177
|
+
interface MacOsSeatbeltOptions {
|
|
1178
|
+
/**
|
|
1179
|
+
* 网络访问策略。默认 'allow'。
|
|
1180
|
+
* 'deny' 时禁止沙箱内进程发起网络连接。
|
|
1181
|
+
*/
|
|
1182
|
+
network?: 'allow' | 'deny';
|
|
1183
|
+
/**
|
|
1184
|
+
* 额外可写路径(绝对路径)。
|
|
1185
|
+
* 项目根目录和临时目录已默认允许;额外路径按需添加。
|
|
1186
|
+
*/
|
|
1187
|
+
writablePaths?: string[];
|
|
1188
|
+
/**
|
|
1189
|
+
* 凭证读隔离(opt-in,endgame review 余 backlog #1 的真正落点):拒绝读取这些子树。
|
|
1190
|
+
* seatbelt 默认 `(allow file-read* /)` 整盘可读 → 凭证目录(~/.ssh 等)默认可被读出外泄;
|
|
1191
|
+
* 此项在 profile 末尾追加 `(deny file-read* (subpath ...))`(SBPL 末匹配胜,deny 盖过前面的
|
|
1192
|
+
* allow,包括可写根内的子树)。仅拦读、不拦写(写由 file-guard/protected-paths 另管)。
|
|
1193
|
+
* 注意:deny 后沙箱内 git-over-ssh / aws-cli / gpg 会因读不到密钥而失败——故为 opt-in。
|
|
1194
|
+
*/
|
|
1195
|
+
denyReadPaths?: string[];
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* macOS Seatbelt(sandbox-exec)沙箱策略。
|
|
1199
|
+
*
|
|
1200
|
+
* 用 `/usr/bin/sandbox-exec -f <profile>` 包装
|
|
1201
|
+
* 命令执行。动态生成 .sb 文件,执行后清理。
|
|
1202
|
+
*
|
|
1203
|
+
* 约束:
|
|
1204
|
+
* - 文件系统:只读访问系统路径,可写仅限 projectRoot + /tmp + 指定额外路径
|
|
1205
|
+
* - 网络:按 options.network 控制
|
|
1206
|
+
* - 进程:允许 fork(bash 命令常需 fork 子进程)
|
|
1207
|
+
*
|
|
1208
|
+
* 注意:仅在 macOS 平台可用(sandbox-exec 是 macOS 特有工具)。
|
|
1209
|
+
*/
|
|
1210
|
+
declare class MacOsSeatbeltSandbox implements SandboxStrategy {
|
|
1211
|
+
readonly name = "macos-seatbelt";
|
|
1212
|
+
private readonly options;
|
|
1213
|
+
private readonly profilePathByContent;
|
|
1214
|
+
constructor(options?: MacOsSeatbeltOptions);
|
|
1215
|
+
wrap(input: SandboxWrapInput): SandboxWrapResult;
|
|
1216
|
+
dispose(): Promise<void>;
|
|
1217
|
+
/** 生成 Seatbelt profile 文本 */
|
|
1218
|
+
private buildProfile;
|
|
1219
|
+
/**
|
|
1220
|
+
* 同步确保 profile 临时文件存在(spawn 调用点同步执行,需要文件立即可读)。
|
|
1221
|
+
* 同内容复用缓存路径;文件被外部清理(如系统 tmp 清扫)时重写。
|
|
1222
|
+
*/
|
|
1223
|
+
private ensureProfileSync;
|
|
1224
|
+
}
|
|
1225
|
+
declare function createMacOsSeatbeltSandbox(options?: MacOsSeatbeltOptions): MacOsSeatbeltSandbox;
|
|
1226
|
+
//#endregion
|
|
1227
|
+
//#region src/shell/sandbox/bubblewrap.d.ts
|
|
1228
|
+
/**
|
|
1229
|
+
* Linux Bubblewrap 沙箱选项。
|
|
1230
|
+
*/
|
|
1231
|
+
interface BubblewrapOptions {
|
|
1232
|
+
/**
|
|
1233
|
+
* 网络访问策略。默认 'allow'。
|
|
1234
|
+
* 'deny' 时不创建网络命名空间(去 --share-net),进程无网络访问。
|
|
1235
|
+
*/
|
|
1236
|
+
network?: 'allow' | 'deny';
|
|
1237
|
+
/**
|
|
1238
|
+
* 额外可写路径(绝对路径)。
|
|
1239
|
+
* 项目根目录通过 --bind 已可写;系统路径(/usr /lib /bin /etc)通过 --ro-bind 只读挂载。
|
|
1240
|
+
* 临时目录(/tmp)由 bwrap 自动创建 tmpfs 隔离。
|
|
1241
|
+
*/
|
|
1242
|
+
writablePaths?: string[];
|
|
1243
|
+
/**
|
|
1244
|
+
* 凭证读隔离(opt-in):拒绝读取这些子树。
|
|
1245
|
+
* bwrap 是 allowlist-bind 模型——未绑定的路径在沙箱内**根本不可见**,故 `~/.ssh` 在项目目录
|
|
1246
|
+
* 外时本就读不到(ENOENT),无需处理。此项只覆盖边角:凭证目录**落在已绑定区内**(如项目根
|
|
1247
|
+
* 恰为 $HOME → `--bind $HOME` 把 ~/.ssh 也暴露了)时,用 `--tmpfs <dir>` 以空 tmpfs 遮蔽。
|
|
1248
|
+
*/
|
|
1249
|
+
denyReadPaths?: string[];
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Linux Bubblewrap (bwrap) 沙箱策略。
|
|
1253
|
+
*
|
|
1254
|
+
* 使用 bwrap 子进程包装(用户态,无需内核模块或 root 权限)。
|
|
1255
|
+
* bwrap 比 Firejail 更轻量,是 Flatpak/snap 使用的底层沙箱技术。
|
|
1256
|
+
*
|
|
1257
|
+
* 约束:
|
|
1258
|
+
* - 文件系统:系统路径只读绑定(--ro-bind),项目目录可写(--bind),/tmp 隔离(--tmpfs)
|
|
1259
|
+
* - 网络:按 options.network 控制(--share-net 显式保留 / --unshare-net 隔离)
|
|
1260
|
+
* - 进程/命名空间:--unshare-all 全命名空间隔离 + --cap-drop ALL 去特权
|
|
1261
|
+
*
|
|
1262
|
+
* 威胁模型(M16a-R1,与 seatbelt 对称):写保护 + 网络开关,**不承诺** env/文件读隔离
|
|
1263
|
+
* (seatbelt 同样允许 file-read* /)。env 透传宿主:--clearenv 会丢 PATH/HOME,
|
|
1264
|
+
* node/git 等真实命令直接不可用,且读隔离在 file-read* 全放行下本就不成立。
|
|
1265
|
+
*
|
|
1266
|
+
* 前置要求:系统中需安装 bwrap(`which bwrap`,常见于 flatpak 或 bubblewrap 包)。
|
|
1267
|
+
* 未安装时 spawn 会收到 ENOENT 错误(子进程 spawn 失败,由调用方的错误传递链处理)。
|
|
1268
|
+
*/
|
|
1269
|
+
declare class BubblewrapSandbox implements SandboxStrategy {
|
|
1270
|
+
readonly name = "bubblewrap";
|
|
1271
|
+
private readonly options;
|
|
1272
|
+
constructor(options?: BubblewrapOptions);
|
|
1273
|
+
wrap(input: SandboxWrapInput): SandboxWrapResult;
|
|
1274
|
+
dispose(): Promise<void>;
|
|
1275
|
+
}
|
|
1276
|
+
declare function createBubblewrapSandbox(options?: BubblewrapOptions): BubblewrapSandbox;
|
|
1277
|
+
//#endregion
|
|
1278
|
+
//#region src/shell/sandbox/platform.d.ts
|
|
1279
|
+
/**
|
|
1280
|
+
* 平台沙箱选项(联合 macOS Seatbelt 与 Linux Bubblewrap 的可配字段)。
|
|
1281
|
+
*/
|
|
1282
|
+
interface PlatformSandboxOptions {
|
|
1283
|
+
/** 网络访问策略。默认 'allow'。 */
|
|
1284
|
+
network?: 'allow' | 'deny';
|
|
1285
|
+
/**
|
|
1286
|
+
* 额外可写路径(绝对路径)。
|
|
1287
|
+
* 项目根目录和 /tmp 已默认允许,无需在此列出。
|
|
1288
|
+
*/
|
|
1289
|
+
writablePaths?: string[];
|
|
1290
|
+
/**
|
|
1291
|
+
* 凭证读隔离(opt-in):拒绝读取这些子树(绝对路径)。
|
|
1292
|
+
* 标准凭证集见 {@link credentialDenyReadPaths}。seatbelt 末尾追加 deny;bwrap 仅遮蔽落在绑定区内者。
|
|
1293
|
+
*/
|
|
1294
|
+
denyReadPaths?: string[];
|
|
1295
|
+
/**
|
|
1296
|
+
* 强制指定平台策略名,跳过 process.platform 自动检测。
|
|
1297
|
+
* 用于测试或强制使用特定后端。
|
|
1298
|
+
*/
|
|
1299
|
+
force?: 'seatbelt' | 'bubblewrap' | 'noop';
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* 标准凭证读隔离路径集(opt-in `protectCredentials` 展开为此):
|
|
1303
|
+
* `~/.ssh`、`~/.aws`、`~/.gnupg` + otto auth store 目录(默认 `~/.config/otto`,
|
|
1304
|
+
* 经 OTTO_AUTH_PATH 覆盖时取其所在目录)。
|
|
1305
|
+
*/
|
|
1306
|
+
declare function credentialDenyReadPaths(): string[];
|
|
1307
|
+
/**
|
|
1308
|
+
* 按平台自动选择沙箱策略:
|
|
1309
|
+
* - darwin → macOS Seatbelt (sandbox-exec)
|
|
1310
|
+
* - linux → Bubblewrap (bwrap)
|
|
1311
|
+
* - 其他 → Noop(Windows 等回退)
|
|
1312
|
+
*
|
|
1313
|
+
* 每个平台使用最优 OS 级沙箱技术,无需调用方判断平台。
|
|
1314
|
+
*/
|
|
1315
|
+
declare function createPlatformSandbox(options?: PlatformSandboxOptions): SandboxStrategy;
|
|
1316
|
+
/**
|
|
1317
|
+
* M4 Phase 2 preflight:当前平台的 OS 沙箱是否**实际可用**。
|
|
1318
|
+
* - darwin:`sandbox-exec` 是 macOS 内置 → true。
|
|
1319
|
+
* - linux:需安装 `bwrap`(bubblewrap)→ 探测 PATH/常见路径;缺失 → false。
|
|
1320
|
+
* - 其它平台:无沙箱 → false。
|
|
1321
|
+
*
|
|
1322
|
+
* 默认开(Phase 2)必须先过此关:缺 bwrap 的 Linux 主机若强行套 bwrap,spawn ENOENT
|
|
1323
|
+
* 会让**每条命令失败**(fail-closed 但用户体验=全挂)。preflight 让默认开在不可用时
|
|
1324
|
+
* 优雅降级为「无沙箱 + 一次告警」,而非破坏。
|
|
1325
|
+
*/
|
|
1326
|
+
declare function isPlatformSandboxAvailable(): boolean;
|
|
1327
|
+
//#endregion
|
|
1328
|
+
export { type BackgroundProcessInfo, type BackgroundProcessPort, type BackgroundProcessRegisterInput, type BackgroundProcessStatus, BinaryToolExecutorRegistry, type BubblewrapOptions, type CapabilityGapHit, type CaptureFileState, type DocumentSymbol, type ExecuteSkill, type ForkRunner, LSPClient, type LSPServerConfig, type LearnCallback, type LoadSkill, type Location, type LocationLink, type MacOsSeatbeltOptions, ORCHESTRATION_TOOL_NAMES, type PlatformSandboxOptions, type PrepareRenameResult, type ReadMemory, type RecordMemory, type RegisterBuiltinOptions, type RegisteredTool, type ResolvedServer, type RunTeam, type SandboxConfig, type SandboxProvider, type SandboxStrategy, type SandboxWrapInput, type SandboxWrapResult, type SearchEcosystem, type ServerLookupResult, type SessionGrill, type SessionManagerTool, type SymbolInfo, TOOL_NODES, type ToolMetadata, type ToolNode, type ToolNodeContext, type ToolRegistrationOptions, ToolRegistry, type WorkspaceEdit, buildDelegationAgentListDescription, capabilityGapDedupKey, createBinaryToolExecutorRegistry, createBubblewrapSandbox, createCapabilityGap, createCaptureFileState, createEdit, createGrillMe, createLearn, createLspDefinition, createLspDiagnostics, createLspPrepareRename, createLspReferences, createLspRename, createLspSymbols, createMacOsSeatbeltSandbox, createNoopSandbox, createPlatformSandbox, createRead, createSessionManagerTool, createTaskControl, createTaskInspect, createToolRegistry, createToolSearch, createWebFetch, createWebSearch, createWrite, createWriteTodos, credentialDenyReadPaths, findWorkspaceRoot, isPlatformSandboxAvailable, lspManager, registerBuiltinTools, withLspClient };
|
|
1329
|
+
//# sourceMappingURL=index.d.ts.map
|