@dabuliu_wsy/dsh-im 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +204 -3
- package/cordis.patch.yml +4 -0
- package/dist/core/agent-state.d.ts +38 -0
- package/dist/core/agent-state.js +59 -0
- package/dist/core/arbiter-bridge.d.ts +25 -0
- package/dist/core/arbiter-bridge.js +20 -0
- package/dist/core/arbiter.d.ts +29 -0
- package/dist/core/arbiter.js +59 -0
- package/dist/core/avatar-brands.d.ts +23 -0
- package/dist/core/avatar-brands.js +75 -0
- package/dist/core/avatar-presets.d.ts +21 -0
- package/dist/core/avatar-presets.js +38 -0
- package/dist/core/avatar.d.ts +1 -0
- package/dist/core/avatar.js +18 -0
- package/dist/core/blocked.d.ts +12 -0
- package/dist/core/blocked.js +23 -0
- package/dist/core/budget-plan.d.ts +41 -0
- package/dist/core/budget-plan.js +69 -0
- package/dist/core/calibration-samples.d.ts +77 -0
- package/dist/core/calibration-samples.js +168 -0
- package/dist/core/calibrator.d.ts +57 -0
- package/dist/core/calibrator.js +125 -0
- package/dist/core/chapter-tree.d.ts +128 -0
- package/dist/core/chapter-tree.js +400 -0
- package/dist/core/consensus.d.ts +135 -0
- package/dist/core/consensus.js +394 -0
- package/dist/core/context-budget.d.ts +153 -0
- package/dist/core/context-budget.js +183 -0
- package/dist/core/curator.d.ts +28 -0
- package/dist/core/curator.js +190 -0
- package/dist/core/dual-window.d.ts +86 -0
- package/dist/core/dual-window.js +175 -0
- package/dist/core/events.d.ts +110 -0
- package/dist/core/events.js +117 -0
- package/dist/core/facts.d.ts +114 -0
- package/dist/core/facts.js +400 -0
- package/dist/core/fence.d.ts +34 -0
- package/dist/core/fence.js +129 -0
- package/dist/core/floor.d.ts +18 -0
- package/dist/core/floor.js +80 -0
- package/dist/core/ids.d.ts +11 -0
- package/dist/core/ids.js +29 -0
- package/dist/core/im.d.ts +213 -0
- package/dist/core/im.js +1640 -0
- package/dist/core/index.d.ts +34 -0
- package/dist/core/index.js +34 -0
- package/dist/core/log.d.ts +21 -0
- package/dist/core/log.js +63 -0
- package/dist/core/memory-claims.d.ts +67 -0
- package/dist/core/memory-claims.js +164 -0
- package/dist/core/memory-context.d.ts +121 -0
- package/dist/core/memory-context.js +303 -0
- package/dist/core/memory-visibility.d.ts +58 -0
- package/dist/core/memory-visibility.js +36 -0
- package/dist/core/memory.d.ts +12 -0
- package/dist/core/memory.js +73 -0
- package/dist/core/metrics.d.ts +49 -0
- package/dist/core/metrics.js +89 -0
- package/dist/core/multi-hop.d.ts +116 -0
- package/dist/core/multi-hop.js +278 -0
- package/dist/core/persist.d.ts +21 -0
- package/dist/core/persist.js +94 -0
- package/dist/core/proactive.d.ts +54 -0
- package/dist/core/proactive.js +108 -0
- package/dist/core/prompt.d.ts +82 -0
- package/dist/core/prompt.js +164 -0
- package/dist/core/receipt.d.ts +107 -0
- package/dist/core/receipt.js +86 -0
- package/dist/core/retrieval.d.ts +69 -0
- package/dist/core/retrieval.js +260 -0
- package/dist/core/role-state.d.ts +16 -0
- package/dist/core/role-state.js +65 -0
- package/dist/core/runtime.d.ts +137 -0
- package/dist/core/runtime.js +574 -0
- package/dist/core/summary.d.ts +19 -0
- package/dist/core/summary.js +96 -0
- package/dist/core/text.d.ts +10 -0
- package/dist/core/text.js +45 -0
- package/dist/core/time.d.ts +22 -0
- package/dist/core/time.js +84 -0
- package/dist/core/tool-schema.d.ts +12 -0
- package/dist/core/tool-schema.js +92 -0
- package/dist/core/tools.d.ts +137 -0
- package/dist/core/tools.js +348 -0
- package/dist/core/trash.d.ts +110 -0
- package/dist/core/trash.js +56 -0
- package/dist/core/types.d.ts +400 -0
- package/dist/core/types.js +1 -0
- package/dist/core/window.d.ts +6 -0
- package/dist/core/window.js +7 -0
- package/dist/core/workspace-node.d.ts +28 -0
- package/dist/core/workspace-node.js +232 -0
- package/dist/core/workspace.d.ts +9 -0
- package/dist/core/workspace.js +45 -0
- package/dist/host/agent-session.d.ts +296 -0
- package/dist/host/agent-session.js +964 -0
- package/dist/host/attachment-gc.d.ts +37 -0
- package/dist/host/attachment-gc.js +97 -0
- package/dist/host/calibration-samples-store.d.ts +5 -0
- package/dist/host/calibration-samples-store.js +67 -0
- package/dist/host/capabilities.d.ts +45 -0
- package/dist/host/capabilities.js +67 -0
- package/dist/host/derived-store.d.ts +36 -0
- package/dist/host/derived-store.js +199 -0
- package/dist/host/dsh-llm.d.ts +143 -0
- package/dist/host/dsh-llm.js +395 -0
- package/dist/host/event-store.d.ts +47 -0
- package/dist/host/event-store.js +154 -0
- package/dist/host/fs-atomic.d.ts +1 -0
- package/dist/host/fs-atomic.js +26 -0
- package/dist/host/group-files.d.ts +26 -0
- package/dist/host/group-files.js +142 -0
- package/dist/host/im-api.d.ts +408 -0
- package/dist/host/im-api.js +1188 -0
- package/dist/host/index.d.ts +103 -0
- package/dist/host/index.js +509 -0
- package/dist/host/media-type.d.ts +10 -0
- package/dist/host/media-type.js +39 -0
- package/dist/host/memory-index.d.ts +65 -0
- package/dist/host/memory-index.js +181 -0
- package/dist/host/metrics-store.d.ts +7 -0
- package/dist/host/metrics-store.js +104 -0
- package/dist/host/models.d.ts +39 -0
- package/dist/host/models.js +67 -0
- package/dist/host/persona-tools.d.ts +57 -0
- package/dist/host/persona-tools.js +226 -0
- package/dist/host/preflight.d.ts +31 -0
- package/dist/host/preflight.js +29 -0
- package/dist/host/receipt-store.d.ts +26 -0
- package/dist/host/receipt-store.js +68 -0
- package/dist/host/run-check.d.ts +51 -0
- package/dist/host/run-check.js +190 -0
- package/dist/host/state-roots.d.ts +50 -0
- package/dist/host/state-roots.js +163 -0
- package/dist/host/tool-cache.d.ts +25 -0
- package/dist/host/tool-cache.js +90 -0
- package/dist/host/tool-call-budget.d.ts +29 -0
- package/dist/host/tool-call-budget.js +38 -0
- package/dist/host/trash-store.d.ts +32 -0
- package/dist/host/trash-store.js +316 -0
- package/dsh-plugin.json +25 -0
- package/lib/client.inner.cjs +3933 -0
- package/lib/client.js +3941 -0
- package/package.json +86 -6
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { type ToolGroupCatalog } from '../core/tools.ts';
|
|
2
|
+
import { type LlmService } from './dsh-llm.ts';
|
|
3
|
+
import type { MessageAttachment, ModelContentPart, NativeFrame, TurnStepTrace } from '../core/types.ts';
|
|
4
|
+
import { type NativeBridge } from './agent-session.ts';
|
|
5
|
+
import { type HostCapabilityReport } from './capabilities.ts';
|
|
6
|
+
import type { MemoryContextReceipt } from '../core/memory-context.ts';
|
|
7
|
+
import { type BudgetChangedEvent, type ContextBudgetReceipt } from '../core/context-budget.ts';
|
|
8
|
+
import { type GroupFileListing } from './group-files.ts';
|
|
9
|
+
import type { TrashEntryMeta, TrashPayload } from '../core/trash.ts';
|
|
10
|
+
/** DSH 附件存储(ctx.attachments)的最小接口面:我们只用「存文件/存图片」两种。 */
|
|
11
|
+
export interface DshAttachmentStore {
|
|
12
|
+
saveFile?: (input: {
|
|
13
|
+
data: Uint8Array;
|
|
14
|
+
name?: string;
|
|
15
|
+
}) => Promise<{
|
|
16
|
+
attachmentId: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
bytes?: number;
|
|
19
|
+
}>;
|
|
20
|
+
saveImages?: (inputs: {
|
|
21
|
+
data: Uint8Array;
|
|
22
|
+
mediaType: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
}[]) => Promise<{
|
|
25
|
+
attachmentId: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
bytes?: number;
|
|
28
|
+
width?: number;
|
|
29
|
+
height?: number;
|
|
30
|
+
mediaType?: string;
|
|
31
|
+
}[]>;
|
|
32
|
+
}
|
|
33
|
+
export interface ImApiDeps {
|
|
34
|
+
projectRoot: () => string;
|
|
35
|
+
/**
|
|
36
|
+
* 宿主 DSH 的 `ctx.llm`。
|
|
37
|
+
*
|
|
38
|
+
* 插件不直连任何网关:模型目录、调用、默认模型都由 DSH 提供,
|
|
39
|
+
* 网关(如果有)是 DSH 自己配置的 provider,插件不感知。
|
|
40
|
+
*/
|
|
41
|
+
llm: () => LlmService | undefined;
|
|
42
|
+
/** 宿主 DSH 的附件存储 `ctx.attachments`(没挂载时图片只存本地、模型看不到内容)。 */
|
|
43
|
+
attachments?: () => DshAttachmentStore | undefined;
|
|
44
|
+
/** M2.1 原生 session(实验开关;未启用时返回 undefined,插件回退 ctx.llm)。 */
|
|
45
|
+
native?: () => NativeBridge | undefined;
|
|
46
|
+
/** 宿主注册的工作区列表:客户端只能在这些根之间切换,防止任意路径读写。 */
|
|
47
|
+
workspaces?: () => {
|
|
48
|
+
path?: string;
|
|
49
|
+
}[];
|
|
50
|
+
/** 宿主 tools 服务探测(能力契约保证不了时原生整体回退)。 */
|
|
51
|
+
hostTools?: () => {
|
|
52
|
+
register?: unknown;
|
|
53
|
+
guard?: unknown;
|
|
54
|
+
restrict?: unknown;
|
|
55
|
+
schemas?: unknown;
|
|
56
|
+
} | undefined;
|
|
57
|
+
/** 动态工具来源组目录(内置 4 能力 + 宿主来源组,面板刷新即发现新装工具)。 */
|
|
58
|
+
toolGroups?: () => ToolGroupCatalog;
|
|
59
|
+
/** 「用过的数据根」记忆文件(默认 ~/.dsh-im/known-roots.json;测试可注入)。 */
|
|
60
|
+
rootsFile?: () => string | undefined;
|
|
61
|
+
}
|
|
62
|
+
export declare function createImApi(deps: ImApiDeps): {
|
|
63
|
+
getState(projectRoot?: string): Promise<import("../core/types.ts").ImState | null>;
|
|
64
|
+
putState(raw: string, projectRoot?: string): Promise<{
|
|
65
|
+
path: string;
|
|
66
|
+
warnings: string[];
|
|
67
|
+
} | {
|
|
68
|
+
warnings?: undefined;
|
|
69
|
+
path: string;
|
|
70
|
+
}>;
|
|
71
|
+
trashList(projectRoot?: string): Promise<{
|
|
72
|
+
entries: TrashEntryMeta[];
|
|
73
|
+
}>;
|
|
74
|
+
trashAdd(body: {
|
|
75
|
+
projectRoot?: string;
|
|
76
|
+
kind?: string;
|
|
77
|
+
label?: string;
|
|
78
|
+
detail?: string;
|
|
79
|
+
threadIds?: unknown;
|
|
80
|
+
payload?: unknown;
|
|
81
|
+
replaceOnRestore?: boolean;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
entry: TrashEntryMeta;
|
|
84
|
+
}>;
|
|
85
|
+
trashRestore(body: {
|
|
86
|
+
projectRoot?: string;
|
|
87
|
+
id?: unknown;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
meta: TrashEntryMeta;
|
|
90
|
+
payload: TrashPayload;
|
|
91
|
+
}>;
|
|
92
|
+
trashPurge(body: {
|
|
93
|
+
projectRoot?: string;
|
|
94
|
+
id?: unknown;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
purged: number;
|
|
97
|
+
failed: string[];
|
|
98
|
+
}>;
|
|
99
|
+
/** 删除会话/角色、清空记录后释放对应原生会话(被删历史不能继续留在宿主内存)。 */
|
|
100
|
+
nativeForget(body: {
|
|
101
|
+
personaId?: unknown;
|
|
102
|
+
threadId?: unknown;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
disposed: number;
|
|
105
|
+
}>;
|
|
106
|
+
/**
|
|
107
|
+
* 群工作区文件浏览(只读):路径围栏在 `<根>/.dsh-im/groups/<threadId>/` 内,
|
|
108
|
+
* 内部账本(events/facts/metrics/receipts/...)不展示也不允许读。
|
|
109
|
+
*/
|
|
110
|
+
groupFiles(body: {
|
|
111
|
+
threadId?: unknown;
|
|
112
|
+
projectRoot?: string;
|
|
113
|
+
path?: unknown;
|
|
114
|
+
}): Promise<GroupFileListing>;
|
|
115
|
+
/** 读一个群文件(原始字节;面板用 <img>/fetch 展示或下载)。 */
|
|
116
|
+
groupFile(body: {
|
|
117
|
+
threadId?: unknown;
|
|
118
|
+
projectRoot?: string;
|
|
119
|
+
path?: unknown;
|
|
120
|
+
}): Promise<{
|
|
121
|
+
bytes: Buffer;
|
|
122
|
+
mediaType: string;
|
|
123
|
+
name: string;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* 数据根发现(只读):当前根 + DSH 注册工作区 + 以前用过的根,各自有没有数据。
|
|
127
|
+
* 面板加载失败时用它列出「哪个根里还有数据」,而不是静默显示空。
|
|
128
|
+
*/
|
|
129
|
+
stateRoots(): Promise<import("./state-roots.ts").StateRootInfo[]>;
|
|
130
|
+
/** 上传一个附件:字节落到本群 attachments/,图片/文件再登记到 DSH 附件存储(给模型用)。 */
|
|
131
|
+
uploadAttachment(body: {
|
|
132
|
+
threadId?: string;
|
|
133
|
+
projectRoot?: string;
|
|
134
|
+
name?: string;
|
|
135
|
+
mediaType?: string;
|
|
136
|
+
data?: Uint8Array;
|
|
137
|
+
}): Promise<{
|
|
138
|
+
attachment: MessageAttachment;
|
|
139
|
+
url: string;
|
|
140
|
+
modelVisible: boolean;
|
|
141
|
+
}>;
|
|
142
|
+
/** 读本群 attachments/ 下的附件字节(给界面预览/下载)。 */
|
|
143
|
+
attachmentFile(body: {
|
|
144
|
+
threadId?: string;
|
|
145
|
+
file?: string;
|
|
146
|
+
projectRoot?: string;
|
|
147
|
+
}): Promise<{
|
|
148
|
+
bytes: Buffer;
|
|
149
|
+
mediaType: string;
|
|
150
|
+
}>;
|
|
151
|
+
/** 附件垃圾回收:默认 dryRun,只报告孤儿;显式 dryRun=false 才删除。 */
|
|
152
|
+
attachmentGc(body: {
|
|
153
|
+
threadId?: string;
|
|
154
|
+
dryRun?: boolean;
|
|
155
|
+
minAgeMs?: number;
|
|
156
|
+
}): Promise<{
|
|
157
|
+
root: string;
|
|
158
|
+
coveredRoots: string[];
|
|
159
|
+
results: ({
|
|
160
|
+
root: string;
|
|
161
|
+
} & import("./attachment-gc.ts").GcResult)[];
|
|
162
|
+
orphanEntries: {
|
|
163
|
+
root: string;
|
|
164
|
+
path: string;
|
|
165
|
+
}[];
|
|
166
|
+
scanned: number;
|
|
167
|
+
referenced: number;
|
|
168
|
+
orphans: string[];
|
|
169
|
+
freed: number;
|
|
170
|
+
wouldFree: number;
|
|
171
|
+
failed: number;
|
|
172
|
+
statFailed: number;
|
|
173
|
+
errored: number;
|
|
174
|
+
noDir: number;
|
|
175
|
+
dryRun: boolean;
|
|
176
|
+
}>;
|
|
177
|
+
models(): Promise<import("./models.ts").ModelOption[]>;
|
|
178
|
+
preflight(body: {
|
|
179
|
+
threadId?: string;
|
|
180
|
+
projectRoot?: string;
|
|
181
|
+
}): Promise<import("./preflight.ts").PreflightResult>;
|
|
182
|
+
complete(body: {
|
|
183
|
+
model?: string;
|
|
184
|
+
provider?: string;
|
|
185
|
+
system?: string;
|
|
186
|
+
user?: string;
|
|
187
|
+
messages?: {
|
|
188
|
+
role: 'user' | 'assistant' | 'system';
|
|
189
|
+
content: string | ModelContentPart[];
|
|
190
|
+
}[];
|
|
191
|
+
toolAllow?: string[];
|
|
192
|
+
projectRoot?: string;
|
|
193
|
+
threadId?: string;
|
|
194
|
+
/** 回执:这条回复对应的角色、窗口事件序号、摘要覆盖边界、事实版本。 */
|
|
195
|
+
personaId?: string;
|
|
196
|
+
windowSeqs?: number[];
|
|
197
|
+
summaryUntil?: number;
|
|
198
|
+
factsVersion?: string;
|
|
199
|
+
/** 角色状态快照 hash + 检索审计(回执变厚,用于回放/审计)。 */
|
|
200
|
+
stateSnapshotHash?: string;
|
|
201
|
+
retrievalQuery?: {
|
|
202
|
+
topicId: number;
|
|
203
|
+
entities: {
|
|
204
|
+
type: string;
|
|
205
|
+
value: string;
|
|
206
|
+
}[];
|
|
207
|
+
replyChainRoots: number[];
|
|
208
|
+
params: {
|
|
209
|
+
retrievalVersion: string;
|
|
210
|
+
topicSegVersion: string;
|
|
211
|
+
weights: Record<string, number>;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
retrievalHitIds?: number[];
|
|
215
|
+
retrievalSelectedIds?: number[];
|
|
216
|
+
indexVersion?: string;
|
|
217
|
+
/** reply(角色发言)/ extract(异步事实抽取)/ curate(共识整理),指标里区分。 */
|
|
218
|
+
purpose?: 'reply' | 'extract' | 'curate';
|
|
219
|
+
/** A-1 群级预算快照 + 变更事件(客户端组装时算好,回执/指标落盘)。 */
|
|
220
|
+
budget?: ContextBudgetReceipt;
|
|
221
|
+
budgetChanged?: BudgetChangedEvent;
|
|
222
|
+
/** 工具执行预算覆盖(缺省时 host 从 state + 成员模型窗口推导;见 resolveTurnBudget)。 */
|
|
223
|
+
memoryBudgetChars?: number;
|
|
224
|
+
budgetChars?: number;
|
|
225
|
+
budgetTier?: string;
|
|
226
|
+
/** Phase 1 句柄协议回执(含冷区章节目录审计)。 */
|
|
227
|
+
memoryContext?: MemoryContextReceipt;
|
|
228
|
+
}): Promise<{
|
|
229
|
+
text: string;
|
|
230
|
+
trace?: TurnStepTrace[] | undefined;
|
|
231
|
+
}>;
|
|
232
|
+
/**
|
|
233
|
+
* 用 ctx.llm.stream 复刻一次和原生会话相近的请求,把原始异常(含 cause)原样返回。
|
|
234
|
+
* 不经过 agent 循环的 failure 投影。
|
|
235
|
+
*/
|
|
236
|
+
llmProbe(body: {
|
|
237
|
+
model?: string;
|
|
238
|
+
provider?: string;
|
|
239
|
+
system?: string;
|
|
240
|
+
prompt?: string;
|
|
241
|
+
maxTokens?: number;
|
|
242
|
+
reasoningEffort?: string;
|
|
243
|
+
tools?: unknown[];
|
|
244
|
+
/** 循环独有:系统提示更新方式。失败会话里是 in-history。 */
|
|
245
|
+
systemPromptUpdate?: 'in-history' | 'replace';
|
|
246
|
+
}): Promise<{
|
|
247
|
+
ok: boolean;
|
|
248
|
+
failure: {
|
|
249
|
+
message: string;
|
|
250
|
+
};
|
|
251
|
+
text?: undefined;
|
|
252
|
+
ms?: undefined;
|
|
253
|
+
provider?: undefined;
|
|
254
|
+
model?: undefined;
|
|
255
|
+
} | {
|
|
256
|
+
ok: boolean;
|
|
257
|
+
ms: number;
|
|
258
|
+
provider: string;
|
|
259
|
+
model: string;
|
|
260
|
+
text: string;
|
|
261
|
+
failure?: undefined;
|
|
262
|
+
} | {
|
|
263
|
+
text?: undefined;
|
|
264
|
+
ok: boolean;
|
|
265
|
+
ms: number;
|
|
266
|
+
provider: string | undefined;
|
|
267
|
+
model: string | undefined;
|
|
268
|
+
failure: unknown;
|
|
269
|
+
}>;
|
|
270
|
+
/** M2.1 原生 session 是否可用(客户端据此选择 transport;默认关)。 */
|
|
271
|
+
nativeStatus(): {
|
|
272
|
+
enabled: boolean;
|
|
273
|
+
reason?: string;
|
|
274
|
+
checks?: import("./agent-session.ts").NativeChecks;
|
|
275
|
+
capabilities?: {
|
|
276
|
+
read: boolean;
|
|
277
|
+
search: boolean;
|
|
278
|
+
write: boolean;
|
|
279
|
+
check: boolean;
|
|
280
|
+
};
|
|
281
|
+
hostToolGroups?: number;
|
|
282
|
+
};
|
|
283
|
+
/** 诊断:原生会话当前派生消息(排查空回复用;不含敏感 prompt)。 */
|
|
284
|
+
nativeDebug(): {
|
|
285
|
+
enabled: boolean;
|
|
286
|
+
sessions: unknown[];
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Phase 0 宿主能力探测:tokenizer / usage / embeddings 有没有。
|
|
290
|
+
* 只做形状探测 + 已观察到的 usage 字段;不主动发模型调用(那由 /llm-probe 触发)。
|
|
291
|
+
*/
|
|
292
|
+
capabilities(): HostCapabilityReport;
|
|
293
|
+
/** Phase 1b:当前数据根的 chars/token 校准(面板启动读取,用于把 token 预算换算成字符预算)。 */
|
|
294
|
+
/**
|
|
295
|
+
* L1/L2/L3 观测:校准样本报告 + 影子决策 + 各桶「若启用」预算。
|
|
296
|
+
* `charsPerToken`(客户端预算实际用的)**只在显式 shadow→calibrated 后才返回**,
|
|
297
|
+
* 其余情况返回空对象 + 完整 shadow 报告(零行为变更)。
|
|
298
|
+
*/
|
|
299
|
+
tokenCalibration(projectRoot?: string): Promise<{
|
|
300
|
+
mode: string;
|
|
301
|
+
totals: {
|
|
302
|
+
samples: number;
|
|
303
|
+
valid: number;
|
|
304
|
+
invalid: number;
|
|
305
|
+
};
|
|
306
|
+
buckets: {
|
|
307
|
+
bucket: string;
|
|
308
|
+
samples: number;
|
|
309
|
+
valid: number;
|
|
310
|
+
invalidShare: number;
|
|
311
|
+
prior: number;
|
|
312
|
+
median: number | undefined;
|
|
313
|
+
shadowRatio: number | undefined;
|
|
314
|
+
mode: import("../core/calibrator.ts").CalibrationMode;
|
|
315
|
+
wouldClamp: boolean;
|
|
316
|
+
reasons: string[];
|
|
317
|
+
wouldBeWindowChars: number;
|
|
318
|
+
wouldBeTokens: number;
|
|
319
|
+
}[];
|
|
320
|
+
charsPerToken: Record<string, number>;
|
|
321
|
+
}>;
|
|
322
|
+
/**
|
|
323
|
+
* Phase 0 记忆索引预览:构建/增量更新指定群的派生索引,返回统计(默认**不落盘**)。
|
|
324
|
+
* 只读诊断用;`persist:true` 才写 `.dsh-im/groups/<id>/index.json`。
|
|
325
|
+
*/
|
|
326
|
+
memoryIndex(body: {
|
|
327
|
+
threadId?: string;
|
|
328
|
+
projectRoot?: string;
|
|
329
|
+
persist?: boolean;
|
|
330
|
+
}): Promise<{
|
|
331
|
+
rebuilt: boolean;
|
|
332
|
+
reason: string;
|
|
333
|
+
stats: {
|
|
334
|
+
messages: number;
|
|
335
|
+
topics: number;
|
|
336
|
+
active: number;
|
|
337
|
+
superseded: number;
|
|
338
|
+
raw: number;
|
|
339
|
+
untrusted: number;
|
|
340
|
+
imperative: number;
|
|
341
|
+
};
|
|
342
|
+
cursor: import("./memory-index.ts").MemoryIndexCursor;
|
|
343
|
+
sample: import("./memory-index.ts").MemoryIndexEntry[];
|
|
344
|
+
}>;
|
|
345
|
+
/**
|
|
346
|
+
* 动态工具目录:内置 4 能力 + 宿主来源组(浏览器/MCP server/其他)。
|
|
347
|
+
* 面板每次打开/刷新都重新发现,用户新装的工具无需改代码即可出现在角色编辑器里。
|
|
348
|
+
*/
|
|
349
|
+
toolGroups(): {
|
|
350
|
+
capabilities: {
|
|
351
|
+
id: import("../core/tools.ts").CoreCapability;
|
|
352
|
+
label: string;
|
|
353
|
+
tools: string[];
|
|
354
|
+
}[];
|
|
355
|
+
groups: import("../core/tools.ts").DiscoveredToolGroup[];
|
|
356
|
+
native: boolean;
|
|
357
|
+
};
|
|
358
|
+
nativeComplete(body: {
|
|
359
|
+
sessionKey?: string;
|
|
360
|
+
personaId?: string;
|
|
361
|
+
model?: string;
|
|
362
|
+
provider?: string;
|
|
363
|
+
system?: string;
|
|
364
|
+
prompt?: string;
|
|
365
|
+
messages?: {
|
|
366
|
+
role?: string;
|
|
367
|
+
content?: string;
|
|
368
|
+
}[];
|
|
369
|
+
cwd?: string;
|
|
370
|
+
projectRoot?: string;
|
|
371
|
+
threadId?: string;
|
|
372
|
+
windowSeqs?: number[];
|
|
373
|
+
summaryUntil?: number;
|
|
374
|
+
factsVersion?: string;
|
|
375
|
+
frame?: NativeFrame;
|
|
376
|
+
nativeFrame?: NativeFrame;
|
|
377
|
+
toolAllow?: string[];
|
|
378
|
+
personaName?: string;
|
|
379
|
+
setupMode?: 'all' | 'off' | 'sections' | 'restrict' | 'bcdp' | 'mcp';
|
|
380
|
+
sessionIdOverride?: string;
|
|
381
|
+
maxTokens?: number;
|
|
382
|
+
reasoningEffort?: string;
|
|
383
|
+
/** 单轮工具调用上限(缺省读 DSH_IM_MAX_TOOL_CALLS / 12)。 */
|
|
384
|
+
maxToolCalls?: number;
|
|
385
|
+
/** A-1 群级预算快照 + 变更事件(与 ctx.llm 路径同一份回执口径)。 */
|
|
386
|
+
budget?: ContextBudgetReceipt;
|
|
387
|
+
budgetChanged?: BudgetChangedEvent;
|
|
388
|
+
/** Phase 1 句柄协议回执(含冷区章节目录审计;native 与 ctx.llm 同结构)。 */
|
|
389
|
+
memoryContext?: MemoryContextReceipt;
|
|
390
|
+
}): Promise<{
|
|
391
|
+
text: string;
|
|
392
|
+
trace?: TurnStepTrace[] | undefined;
|
|
393
|
+
toolStats?: import("./agent-session.ts").NativeToolStats | undefined;
|
|
394
|
+
}>;
|
|
395
|
+
writeFile(body: {
|
|
396
|
+
threadId?: string;
|
|
397
|
+
relativePath?: string;
|
|
398
|
+
content?: string;
|
|
399
|
+
projectRoot?: string;
|
|
400
|
+
}): Promise<{
|
|
401
|
+
path: string;
|
|
402
|
+
}>;
|
|
403
|
+
workspace(projectRoot?: string): Promise<{
|
|
404
|
+
path: string;
|
|
405
|
+
}>;
|
|
406
|
+
/** 宿主挂载时预热「用过的数据根」缓存,避免首个请求在缓存空的时候被判 400。 */
|
|
407
|
+
loadKnownRoots: () => Promise<void>;
|
|
408
|
+
};
|