dsh-desktop-enhance 0.10.1 → 0.10.2
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 +2 -2
- package/lib/client.js +2 -2
- package/lib/index.d.ts +227 -196
- package/lib/index.js +344 -411
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,9 +87,9 @@ Web 版(浏览器里打开的那种)**不提供插件查找的默认快捷
|
|
|
87
87
|
|
|
88
88
|
### 压缩后恢复近期原文
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
压缩后在下一次请求准入时追加独立的近期对话备忘录,位于本步新输入之后、恢复的 Skill 之前:从宿主保留尾部之前往前取最近 10 个有效轮,只保留人类对话与助手最终回复,并将历史回复中的 `dsh-ui` 组件提取为干净的纯文本/Markdown。预算上限为 32,768 估算 tokens;上下文占用弹窗可按会话调整轮数和预算,轮数设为 0 后停止未来恢复。超预算先丢最老整轮;只有最新单轮也放不下时,才对助手答复做明确标记的头尾摘录,人类输入与审批答案不截断。图片仅恢复名称和附件定位,不重发像素。弹窗可查看上次实际恢复的总轮数、部分轮与原文。
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
原文提取不额外调用模型,不把历史命令当成新的授权。预算维护也保留原文,优先整理其他旧历史;完整请求仍放不下时明确停止,不静默删除回顾。预算维护仍可能调用原生摘要。Fork 沿用现有规则,不复制会话设置覆盖。Host 变更需重启 App,范围与限制见[近期原文恢复](docs/features/recent-conversation.md)。
|
|
93
93
|
|
|
94
94
|
### 图片 token 估价
|
|
95
95
|
|
package/lib/client.js
CHANGED
|
@@ -9449,7 +9449,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9449
9449
|
if (raw.last !== null) {
|
|
9450
9450
|
if (typeof raw.last !== "object" || raw.last === void 0) return void 0;
|
|
9451
9451
|
const result = raw.last;
|
|
9452
|
-
if (result.state !== "restored" && result.state !== "skipped" && result.state !== "failed") return void 0;
|
|
9452
|
+
if (result.state !== "restored" && result.state !== "skipped" && result.state !== "failed" && result.state !== "pending") return void 0;
|
|
9453
9453
|
if (result.reason !== void 0 && typeof result.reason !== "string") return void 0;
|
|
9454
9454
|
if (!integerIn(result.restoredTurns, 0, Number.MAX_SAFE_INTEGER) || !integerIn(result.partialTurns, 0, Number.MAX_SAFE_INTEGER) || !integerIn(result.estimatedTokens, 0, Number.MAX_SAFE_INTEGER) || typeof result.details !== "string") return void 0;
|
|
9455
9455
|
last = {
|
|
@@ -9880,7 +9880,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9880
9880
|
result.className = "de-context-note de-context-recent-result";
|
|
9881
9881
|
const status = globalThis.document.createElement("div");
|
|
9882
9882
|
status.className = "de-context-recent-state";
|
|
9883
|
-
status.textContent = recent.last === null ? "暂无上次恢复记录" : recent.last.state === "restored" ? "已恢复" : recent.last.state === "skipped" ? "已跳过" : "恢复失败";
|
|
9883
|
+
status.textContent = recent.last === null ? "暂无上次恢复记录" : recent.last.state === "restored" ? "已恢复" : recent.last.state === "skipped" ? "已跳过" : recent.last.state === "pending" ? "等待下次请求恢复" : "恢复失败";
|
|
9884
9884
|
result.appendChild(status);
|
|
9885
9885
|
if (recent.last !== null) {
|
|
9886
9886
|
if (recent.last.reason) {
|
package/lib/index.d.ts
CHANGED
|
@@ -117,189 +117,61 @@ interface Input {
|
|
|
117
117
|
declare function recoveryTextCost(value: string | readonly RecoveryTextBlock[]): number;
|
|
118
118
|
declare function readRecentConversationSummary(value: unknown): RecentConversationSummary | null;
|
|
119
119
|
declare function planRecentConversation(input: Input): RecentConversationPlan;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
type DiagnosticArea = 'suggest' | 'session' | 'remote';
|
|
126
|
-
type DiagnosticPhase = 'started' | 'queued' | 'completed' | 'skipped' | 'cancelled' | 'failed' | 'fallback';
|
|
127
|
-
type DiagnosticFields = Readonly<Record<string, string | number | boolean | readonly string[] | null | undefined>>;
|
|
128
|
-
interface DiagnosticContext {
|
|
129
|
-
readonly operationId?: string;
|
|
130
|
-
readonly parentOperationId?: string;
|
|
131
|
-
readonly sessionId?: string;
|
|
132
|
-
readonly turn?: number;
|
|
133
|
-
readonly step?: number;
|
|
134
|
-
}
|
|
135
|
-
interface DiagnosticInput extends DiagnosticContext {
|
|
136
|
-
readonly area: DiagnosticArea;
|
|
137
|
-
readonly event: string;
|
|
138
|
-
readonly phase: DiagnosticPhase;
|
|
139
|
-
readonly durationMs?: number;
|
|
140
|
-
readonly fields?: DiagnosticFields;
|
|
141
|
-
}
|
|
142
|
-
interface DiagnosticRecord extends DiagnosticInput {
|
|
143
|
-
readonly schemaVersion: 1;
|
|
144
|
-
readonly id: string;
|
|
145
|
-
readonly time: number;
|
|
146
|
-
readonly runId: string;
|
|
147
|
-
readonly source: 'host' | 'client';
|
|
148
|
-
readonly level: 'info' | 'warn' | 'error';
|
|
149
|
-
readonly operationId: string;
|
|
120
|
+
declare const RECENT_CONVERSATION_SOURCE = "desktop-enhance-recent-conversation";
|
|
121
|
+
interface RecoveryIdentity {
|
|
122
|
+
readonly version: 1;
|
|
123
|
+
readonly compactionId: string;
|
|
124
|
+
readonly summarySeq: number;
|
|
150
125
|
}
|
|
151
|
-
|
|
126
|
+
type RecoveryState = RecoveryIdentity & ({
|
|
127
|
+
readonly state: 'restored';
|
|
128
|
+
} | {
|
|
129
|
+
readonly state: 'skipped';
|
|
130
|
+
readonly reason: 'empty' | 'budget';
|
|
131
|
+
});
|
|
132
|
+
interface RecoveryMessage {
|
|
152
133
|
readonly id: string;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
readonly state: 'starting' | 'ready' | 'failed' | 'closed';
|
|
158
|
-
readonly pending: number;
|
|
159
|
-
readonly persisted: number;
|
|
160
|
-
readonly dropped: number;
|
|
161
|
-
readonly rejected: number;
|
|
162
|
-
readonly expired: number;
|
|
163
|
-
readonly errorCode: string | null;
|
|
164
|
-
readonly oldestTime: number | null;
|
|
165
|
-
readonly latestTime: number | null;
|
|
166
|
-
readonly retainedBytes: number;
|
|
167
|
-
readonly retentionDays: number;
|
|
168
|
-
readonly maxBytes: number;
|
|
169
|
-
}
|
|
170
|
-
interface DiagnosticQuery {
|
|
171
|
-
readonly area?: DiagnosticArea;
|
|
172
|
-
readonly sessionId?: string;
|
|
173
|
-
readonly operationId?: string;
|
|
174
|
-
readonly level?: 'info' | 'warn' | 'error';
|
|
175
|
-
readonly from?: number;
|
|
176
|
-
readonly to?: number;
|
|
177
|
-
readonly cursor?: string;
|
|
178
|
-
readonly limit?: number;
|
|
179
|
-
}
|
|
180
|
-
interface DiagnosticPage {
|
|
181
|
-
readonly records: readonly DiagnosticRecord[];
|
|
182
|
-
readonly nextCursor: string | null;
|
|
183
|
-
readonly health: DiagnosticHealth;
|
|
184
|
-
}
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/suggest/host.d.ts
|
|
187
|
-
interface HostContext$2 {
|
|
188
|
-
get(name: string): unknown;
|
|
189
|
-
inject(services: readonly string[], callback: (ctx: HostContext$2) => void): unknown;
|
|
190
|
-
effect(factory: () => void | (() => void), label: string): unknown;
|
|
191
|
-
readonly logger?: {
|
|
192
|
-
warn(message: string): void;
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
interface HostSession {
|
|
196
|
-
deriveMessages(): readonly HostMessage$1[];
|
|
197
|
-
requestHeader(): {
|
|
198
|
-
readonly config?: HostRoute;
|
|
199
|
-
} | undefined;
|
|
200
|
-
}
|
|
201
|
-
interface HostRoute {
|
|
202
|
-
readonly provider?: string;
|
|
203
|
-
readonly model?: string;
|
|
204
|
-
}
|
|
205
|
-
interface HostMessage$1 {
|
|
206
|
-
readonly role?: string;
|
|
207
|
-
readonly content?: readonly {
|
|
208
|
-
readonly type?: string;
|
|
209
|
-
readonly text?: string;
|
|
210
|
-
}[];
|
|
211
|
-
readonly source?: {
|
|
212
|
-
readonly kind?: unknown;
|
|
213
|
-
readonly entries?: unknown;
|
|
134
|
+
readonly role: 'user';
|
|
135
|
+
readonly source: {
|
|
136
|
+
readonly kind: typeof RECENT_CONVERSATION_SOURCE;
|
|
137
|
+
readonly recovery: RecoveryState;
|
|
214
138
|
};
|
|
139
|
+
readonly content: readonly RecoveryTextBlock[];
|
|
215
140
|
}
|
|
216
|
-
|
|
217
|
-
readonly provider: string;
|
|
218
|
-
readonly model: string;
|
|
219
|
-
readonly messages: readonly HostMessage$1[];
|
|
220
|
-
readonly system?: string;
|
|
221
|
-
readonly maxTokens?: number;
|
|
222
|
-
readonly sessionId?: string;
|
|
223
|
-
readonly signal?: AbortSignal;
|
|
224
|
-
readonly reasoningEffort?: string;
|
|
225
|
-
}
|
|
226
|
-
interface HostLlm {
|
|
227
|
-
stream(options: HostGenerateOptions): AsyncIterable<HostChunk>;
|
|
228
|
-
listProviders?(): readonly {
|
|
229
|
-
readonly id?: unknown;
|
|
230
|
-
readonly name?: unknown;
|
|
231
|
-
}[];
|
|
232
|
-
listModels?(provider: string): Promise<readonly unknown[]>;
|
|
233
|
-
resolveModelInfo?(provider: string, model: string): Promise<unknown>;
|
|
234
|
-
}
|
|
235
|
-
interface HostChunk {
|
|
236
|
-
readonly type?: string;
|
|
237
|
-
readonly text?: string;
|
|
238
|
-
readonly index?: number;
|
|
239
|
-
readonly reason?: {
|
|
240
|
-
readonly kind?: string;
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
declare function collectText(chunks: AsyncIterable<HostChunk>, onFinish?: (kind: 'stop' | 'max-tokens') => void): Promise<string>;
|
|
244
|
-
declare function routeOf(session: HostSession): {
|
|
245
|
-
provider: string;
|
|
246
|
-
model: string;
|
|
247
|
-
} | null;
|
|
248
|
-
declare function buildMessages(history: readonly HostMessage$1[], instruction: string): HostMessage$1[];
|
|
249
|
-
declare function knownNamesOf(messages: readonly HostMessage$1[]): ReadonlySet<string> | null;
|
|
250
|
-
declare function handleSuggest(ctx: HostContext$2, request: Request, timeoutMs?: number): Promise<Response>;
|
|
251
|
-
declare function quietEffortFor(llm: HostLlm, route: {
|
|
252
|
-
readonly provider: string;
|
|
253
|
-
readonly model: string;
|
|
254
|
-
}, operation?: DiagnosticOperation): Promise<string>;
|
|
255
|
-
declare function listModels(ctx: HostContext$2): Promise<{
|
|
256
|
-
providers: readonly {
|
|
257
|
-
id: string;
|
|
258
|
-
name: string;
|
|
259
|
-
models: readonly {
|
|
260
|
-
id: string;
|
|
261
|
-
name: string;
|
|
262
|
-
}[];
|
|
263
|
-
}[];
|
|
264
|
-
}>;
|
|
265
|
-
declare function listEfforts(ctx: HostContext$2, provider: string, model: string): Promise<{
|
|
266
|
-
efforts: readonly {
|
|
267
|
-
id: string;
|
|
268
|
-
name: string;
|
|
269
|
-
}[];
|
|
270
|
-
defaultEffort: string | null;
|
|
271
|
-
}>;
|
|
272
|
-
declare function registerSuggestRoute(ctx: HostContext$2): () => void;
|
|
141
|
+
declare function isRecentConversationMessage(value: unknown): boolean;
|
|
273
142
|
//#endregion
|
|
274
143
|
//#region src/recent-conversation/host.d.ts
|
|
275
|
-
interface
|
|
276
|
-
|
|
277
|
-
readonly
|
|
278
|
-
}
|
|
144
|
+
interface RecoverySession {
|
|
145
|
+
readonly surface: {
|
|
146
|
+
readonly nodes: readonly number[];
|
|
147
|
+
};
|
|
148
|
+
snapshotEvents(): readonly RecentConversationEvent[];
|
|
279
149
|
}
|
|
280
|
-
interface
|
|
281
|
-
readonly
|
|
150
|
+
interface RecoveryAgent {
|
|
151
|
+
readonly id: string;
|
|
152
|
+
readonly session: RecoverySession;
|
|
153
|
+
}
|
|
154
|
+
interface RecoveryContext {
|
|
155
|
+
get(name: string): unknown;
|
|
156
|
+
readonly config?: unknown;
|
|
282
157
|
}
|
|
283
158
|
declare function readRecentConversationPolicy(config: unknown, state: Pick<SessionState, 'read'> | undefined, sessionId: string): RecentConversationPolicy;
|
|
284
|
-
declare function
|
|
285
|
-
declare function
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
readonly
|
|
290
|
-
|
|
291
|
-
readonly text?: string;
|
|
292
|
-
}[];
|
|
293
|
-
}[]): number;
|
|
159
|
+
declare function recentConversationTokenAdjustment(messages: readonly unknown[]): number;
|
|
160
|
+
declare function prepareRecentConversation(ctx: RecoveryContext, agent: RecoveryAgent): readonly RecoveryMessage[];
|
|
161
|
+
interface SnapshotEvent {
|
|
162
|
+
readonly type: string;
|
|
163
|
+
readonly seq?: number;
|
|
164
|
+
readonly data?: unknown;
|
|
165
|
+
}
|
|
294
166
|
declare function recentConversationSnapshot(session: {
|
|
295
|
-
|
|
296
|
-
readonly
|
|
297
|
-
|
|
298
|
-
|
|
167
|
+
readonly surface?: {
|
|
168
|
+
readonly nodes?: readonly number[];
|
|
169
|
+
};
|
|
170
|
+
snapshotEvents?(): readonly SnapshotEvent[];
|
|
299
171
|
} | undefined, policy: RecentConversationPolicy, customized: boolean): {
|
|
300
172
|
customized: boolean;
|
|
301
173
|
last: {
|
|
302
|
-
state: "restored" | "skipped" | "failed";
|
|
174
|
+
state: "restored" | "skipped" | "failed" | "pending";
|
|
303
175
|
reason?: string;
|
|
304
176
|
restoredTurns: number;
|
|
305
177
|
partialTurns: number;
|
|
@@ -309,16 +181,15 @@ declare function recentConversationSnapshot(session: {
|
|
|
309
181
|
turns: number;
|
|
310
182
|
maxTokens: number;
|
|
311
183
|
};
|
|
312
|
-
declare function installRecentConversationRecovery(ctx: RecoveryHost, options: RecentConversationOptions): () => void;
|
|
313
184
|
//#endregion
|
|
314
185
|
//#region src/session-state/host.d.ts
|
|
315
186
|
declare function handleSessionStateRequest(state: SessionState, request: Request, retry?: () => Promise<void>, lifetime?: AbortSignal): Promise<Response>;
|
|
316
|
-
interface HostContext$
|
|
187
|
+
interface HostContext$2 {
|
|
317
188
|
get(name: string): unknown;
|
|
318
189
|
readonly reflect: {
|
|
319
190
|
provide(name: string, value: unknown): () => void;
|
|
320
191
|
};
|
|
321
|
-
inject(deps: readonly string[], callback: (ctx: HostContext$
|
|
192
|
+
inject(deps: readonly string[], callback: (ctx: HostContext$2) => void): {
|
|
322
193
|
dispose(): Promise<unknown>;
|
|
323
194
|
};
|
|
324
195
|
effect(factory: () => unknown, label?: string): unknown;
|
|
@@ -326,7 +197,7 @@ interface HostContext$1 {
|
|
|
326
197
|
warn(message: string): void;
|
|
327
198
|
};
|
|
328
199
|
}
|
|
329
|
-
declare function installSessionState(ctx: HostContext$
|
|
200
|
+
declare function installSessionState(ctx: HostContext$2): () => Promise<void>;
|
|
330
201
|
//#endregion
|
|
331
202
|
//#region src/session-state/store.d.ts
|
|
332
203
|
declare const sessionStateDomainSpec: {
|
|
@@ -385,6 +256,68 @@ declare function createSessionState(options: SessionStateOptions): {
|
|
|
385
256
|
close: () => Promise<void>;
|
|
386
257
|
};
|
|
387
258
|
//#endregion
|
|
259
|
+
//#region src/shared/diagnostics.d.ts
|
|
260
|
+
type DiagnosticArea = 'suggest' | 'session' | 'remote';
|
|
261
|
+
type DiagnosticPhase = 'started' | 'queued' | 'completed' | 'skipped' | 'cancelled' | 'failed' | 'fallback';
|
|
262
|
+
type DiagnosticFields = Readonly<Record<string, string | number | boolean | readonly string[] | null | undefined>>;
|
|
263
|
+
interface DiagnosticContext {
|
|
264
|
+
readonly operationId?: string;
|
|
265
|
+
readonly parentOperationId?: string;
|
|
266
|
+
readonly sessionId?: string;
|
|
267
|
+
readonly turn?: number;
|
|
268
|
+
readonly step?: number;
|
|
269
|
+
}
|
|
270
|
+
interface DiagnosticInput extends DiagnosticContext {
|
|
271
|
+
readonly area: DiagnosticArea;
|
|
272
|
+
readonly event: string;
|
|
273
|
+
readonly phase: DiagnosticPhase;
|
|
274
|
+
readonly durationMs?: number;
|
|
275
|
+
readonly fields?: DiagnosticFields;
|
|
276
|
+
}
|
|
277
|
+
interface DiagnosticRecord extends DiagnosticInput {
|
|
278
|
+
readonly schemaVersion: 1;
|
|
279
|
+
readonly id: string;
|
|
280
|
+
readonly time: number;
|
|
281
|
+
readonly runId: string;
|
|
282
|
+
readonly source: 'host' | 'client';
|
|
283
|
+
readonly level: 'info' | 'warn' | 'error';
|
|
284
|
+
readonly operationId: string;
|
|
285
|
+
}
|
|
286
|
+
interface DiagnosticOperation {
|
|
287
|
+
readonly id: string;
|
|
288
|
+
record(phase: DiagnosticPhase, fields?: DiagnosticFields): void;
|
|
289
|
+
end(phase: Exclude<DiagnosticPhase, 'started' | 'queued' | 'fallback'>, fields?: DiagnosticFields): void;
|
|
290
|
+
}
|
|
291
|
+
interface DiagnosticHealth {
|
|
292
|
+
readonly state: 'starting' | 'ready' | 'failed' | 'closed';
|
|
293
|
+
readonly pending: number;
|
|
294
|
+
readonly persisted: number;
|
|
295
|
+
readonly dropped: number;
|
|
296
|
+
readonly rejected: number;
|
|
297
|
+
readonly expired: number;
|
|
298
|
+
readonly errorCode: string | null;
|
|
299
|
+
readonly oldestTime: number | null;
|
|
300
|
+
readonly latestTime: number | null;
|
|
301
|
+
readonly retainedBytes: number;
|
|
302
|
+
readonly retentionDays: number;
|
|
303
|
+
readonly maxBytes: number;
|
|
304
|
+
}
|
|
305
|
+
interface DiagnosticQuery {
|
|
306
|
+
readonly area?: DiagnosticArea;
|
|
307
|
+
readonly sessionId?: string;
|
|
308
|
+
readonly operationId?: string;
|
|
309
|
+
readonly level?: 'info' | 'warn' | 'error';
|
|
310
|
+
readonly from?: number;
|
|
311
|
+
readonly to?: number;
|
|
312
|
+
readonly cursor?: string;
|
|
313
|
+
readonly limit?: number;
|
|
314
|
+
}
|
|
315
|
+
interface DiagnosticPage {
|
|
316
|
+
readonly records: readonly DiagnosticRecord[];
|
|
317
|
+
readonly nextCursor: string | null;
|
|
318
|
+
readonly health: DiagnosticHealth;
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
388
321
|
//#region src/diagnostics/store.d.ts
|
|
389
322
|
declare const segmentSchema: z.ZodObject<{
|
|
390
323
|
rows: z.ZodArray<z.ZodObject<{
|
|
@@ -480,6 +413,97 @@ declare function handleDiagnosticRequest(store: DiagnosticStore, request: Reques
|
|
|
480
413
|
declare function handleDiagnosticReport(store: DiagnosticStore, request: Request): Promise<Response>;
|
|
481
414
|
declare function installDiagnostics(ctx: DiagnosticHostContext, config: unknown): () => Promise<void>;
|
|
482
415
|
//#endregion
|
|
416
|
+
//#region src/shared/suggest.d.ts
|
|
417
|
+
declare function buildPrompt(template?: string): string;
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/suggest/host.d.ts
|
|
420
|
+
interface HostContext$1 {
|
|
421
|
+
get(name: string): unknown;
|
|
422
|
+
inject(services: readonly string[], callback: (ctx: HostContext$1) => void): unknown;
|
|
423
|
+
effect(factory: () => void | (() => void), label: string): unknown;
|
|
424
|
+
readonly logger?: {
|
|
425
|
+
warn(message: string): void;
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
interface HostSession {
|
|
429
|
+
deriveMessages(): readonly HostMessage$1[];
|
|
430
|
+
requestHeader(): {
|
|
431
|
+
readonly config?: HostRoute;
|
|
432
|
+
} | undefined;
|
|
433
|
+
}
|
|
434
|
+
interface HostRoute {
|
|
435
|
+
readonly provider?: string;
|
|
436
|
+
readonly model?: string;
|
|
437
|
+
}
|
|
438
|
+
interface HostMessage$1 {
|
|
439
|
+
readonly role?: string;
|
|
440
|
+
readonly content?: readonly {
|
|
441
|
+
readonly type?: string;
|
|
442
|
+
readonly text?: string;
|
|
443
|
+
}[];
|
|
444
|
+
readonly source?: {
|
|
445
|
+
readonly kind?: unknown;
|
|
446
|
+
readonly entries?: unknown;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
interface HostGenerateOptions {
|
|
450
|
+
readonly provider: string;
|
|
451
|
+
readonly model: string;
|
|
452
|
+
readonly messages: readonly HostMessage$1[];
|
|
453
|
+
readonly system?: string;
|
|
454
|
+
readonly maxTokens?: number;
|
|
455
|
+
readonly sessionId?: string;
|
|
456
|
+
readonly signal?: AbortSignal;
|
|
457
|
+
readonly reasoningEffort?: string;
|
|
458
|
+
}
|
|
459
|
+
interface HostLlm {
|
|
460
|
+
stream(options: HostGenerateOptions): AsyncIterable<HostChunk>;
|
|
461
|
+
listProviders?(): readonly {
|
|
462
|
+
readonly id?: unknown;
|
|
463
|
+
readonly name?: unknown;
|
|
464
|
+
}[];
|
|
465
|
+
listModels?(provider: string): Promise<readonly unknown[]>;
|
|
466
|
+
resolveModelInfo?(provider: string, model: string): Promise<unknown>;
|
|
467
|
+
}
|
|
468
|
+
interface HostChunk {
|
|
469
|
+
readonly type?: string;
|
|
470
|
+
readonly text?: string;
|
|
471
|
+
readonly index?: number;
|
|
472
|
+
readonly reason?: {
|
|
473
|
+
readonly kind?: string;
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
declare function collectText(chunks: AsyncIterable<HostChunk>, onFinish?: (kind: 'stop' | 'max-tokens') => void): Promise<string>;
|
|
477
|
+
declare function routeOf(session: HostSession): {
|
|
478
|
+
provider: string;
|
|
479
|
+
model: string;
|
|
480
|
+
} | null;
|
|
481
|
+
declare function buildMessages(history: readonly HostMessage$1[], instruction: string): HostMessage$1[];
|
|
482
|
+
declare function knownNamesOf(messages: readonly HostMessage$1[]): ReadonlySet<string> | null;
|
|
483
|
+
declare function handleSuggest(ctx: HostContext$1, request: Request, timeoutMs?: number): Promise<Response>;
|
|
484
|
+
declare function quietEffortFor(llm: HostLlm, route: {
|
|
485
|
+
readonly provider: string;
|
|
486
|
+
readonly model: string;
|
|
487
|
+
}, operation?: DiagnosticOperation): Promise<string>;
|
|
488
|
+
declare function listModels(ctx: HostContext$1): Promise<{
|
|
489
|
+
providers: readonly {
|
|
490
|
+
id: string;
|
|
491
|
+
name: string;
|
|
492
|
+
models: readonly {
|
|
493
|
+
id: string;
|
|
494
|
+
name: string;
|
|
495
|
+
}[];
|
|
496
|
+
}[];
|
|
497
|
+
}>;
|
|
498
|
+
declare function listEfforts(ctx: HostContext$1, provider: string, model: string): Promise<{
|
|
499
|
+
efforts: readonly {
|
|
500
|
+
id: string;
|
|
501
|
+
name: string;
|
|
502
|
+
}[];
|
|
503
|
+
defaultEffort: string | null;
|
|
504
|
+
}>;
|
|
505
|
+
declare function registerSuggestRoute(ctx: HostContext$1): () => void;
|
|
506
|
+
//#endregion
|
|
483
507
|
//#region src/shared/session-info.d.ts
|
|
484
508
|
interface RawSystemSection {
|
|
485
509
|
readonly name: string;
|
|
@@ -488,12 +512,12 @@ interface RawSystemSection {
|
|
|
488
512
|
}
|
|
489
513
|
//#endregion
|
|
490
514
|
//#region src/session-info/host.d.ts
|
|
491
|
-
declare function collectSystemPromptMetadata(ctx: HostContext$
|
|
515
|
+
declare function collectSystemPromptMetadata(ctx: HostContext$1, scope?: unknown, onPartial?: (error?: unknown) => void): {
|
|
492
516
|
readonly systemSections: readonly RawSystemSection[];
|
|
493
517
|
readonly pluginOwners: Readonly<Record<string, string>>;
|
|
494
518
|
};
|
|
495
|
-
declare function handleSessionInfo(ctx: HostContext$
|
|
496
|
-
declare function registerSessionInfoRoute(ctx: HostContext$
|
|
519
|
+
declare function handleSessionInfo(ctx: HostContext$1, request: Request): Promise<Response>;
|
|
520
|
+
declare function registerSessionInfoRoute(ctx: HostContext$1): () => void;
|
|
497
521
|
//#endregion
|
|
498
522
|
//#region src/shared/tools-manager.d.ts
|
|
499
523
|
type ToolScope = 'builtin' | 'plugin';
|
|
@@ -519,18 +543,18 @@ interface HostPromptAssembly {
|
|
|
519
543
|
}[];
|
|
520
544
|
readonly [key: string]: unknown;
|
|
521
545
|
}
|
|
522
|
-
interface ToolsHostContext extends HostContext$
|
|
546
|
+
interface ToolsHostContext extends HostContext$1 {
|
|
523
547
|
on?(event: string, listener: (assembly: HostPromptAssembly, context: unknown, next: () => Promise<HostPromptAssembly>) => Promise<HostPromptAssembly>): () => void;
|
|
524
548
|
}
|
|
525
|
-
declare function resolveSessionIdFromScope(candidate: unknown, ctx?: HostContext$
|
|
549
|
+
declare function resolveSessionIdFromScope(candidate: unknown, ctx?: HostContext$1): string | undefined;
|
|
526
550
|
declare function readToolsConfig(config: unknown, sessionId?: string, state?: Pick<SessionState, 'read'>): ToolsPolicyState;
|
|
527
551
|
declare function resolveFiberModuleName(fiber: unknown): string | undefined;
|
|
528
552
|
declare function resolveCallerPackageFromStack(stack?: string): string | undefined;
|
|
529
|
-
declare function scanCordisFiberToolOwners(ctx: HostContext$
|
|
530
|
-
declare function collectAllToolSchemas(ctx: HostContext$
|
|
553
|
+
declare function scanCordisFiberToolOwners(ctx: HostContext$1, targetOwners?: Map<string, string>): Map<string, string>;
|
|
554
|
+
declare function collectAllToolSchemas(ctx: HostContext$1, sessionId?: string): Promise<readonly ToolSummary[]>;
|
|
531
555
|
declare function installToolsPolicy(ctx: ToolsHostContext, readState: (sessionId?: string) => ToolsPolicyState): () => void;
|
|
532
|
-
declare function handleToolsCatalog(ctx: HostContext$
|
|
533
|
-
declare function registerToolsRoute(ctx: HostContext$
|
|
556
|
+
declare function handleToolsCatalog(ctx: HostContext$1, request?: Request): Promise<Response>;
|
|
557
|
+
declare function registerToolsRoute(ctx: HostContext$1): () => void;
|
|
534
558
|
//#endregion
|
|
535
559
|
//#region src/remote/update.d.ts
|
|
536
560
|
type UpdatePhase = 'idle' | 'checking' | 'available' | 'downloading' | 'verifying' | 'ready' | 'installing' | 'error';
|
|
@@ -622,10 +646,10 @@ interface SkillsPolicyState {
|
|
|
622
646
|
readonly disabled: ReadonlySet<string>;
|
|
623
647
|
}
|
|
624
648
|
declare function readSkillsConfig(config: unknown, sessionId?: string, state?: Pick<SessionState, 'read'>): SkillsPolicyState;
|
|
625
|
-
declare function collectSkillCatalog(ctx: HostContext$
|
|
649
|
+
declare function collectSkillCatalog(ctx: HostContext$1, sessionId?: string): Promise<readonly SkillCatalogItem[]>;
|
|
626
650
|
declare function installSkillsPolicy(ctx: ToolsHostContext, readState: (sessionId?: string) => SkillsPolicyState): () => void;
|
|
627
|
-
declare function handleSkillsCatalog(ctx: HostContext$
|
|
628
|
-
declare function registerSkillsRoute(ctx: HostContext$
|
|
651
|
+
declare function handleSkillsCatalog(ctx: HostContext$1, request?: Request): Promise<Response>;
|
|
652
|
+
declare function registerSkillsRoute(ctx: HostContext$1): () => void;
|
|
629
653
|
//#endregion
|
|
630
654
|
//#region src/shared/context-policy.d.ts
|
|
631
655
|
type SessionCap = number | null;
|
|
@@ -694,8 +718,9 @@ interface HostMessage {
|
|
|
694
718
|
interface HostSessionEvent {
|
|
695
719
|
readonly type: string;
|
|
696
720
|
readonly seq: number;
|
|
697
|
-
readonly data?: {
|
|
721
|
+
readonly data?: HostMessage & {
|
|
698
722
|
readonly message?: HostMessage;
|
|
723
|
+
readonly turn?: number;
|
|
699
724
|
};
|
|
700
725
|
readonly sourceEventSeqs?: readonly number[];
|
|
701
726
|
readonly surfaceOp?: string | {
|
|
@@ -722,12 +747,12 @@ interface HostSessionLike {
|
|
|
722
747
|
}
|
|
723
748
|
declare function readCap(state: Pick<SessionState, 'read'>, sessionId: string): SessionCap;
|
|
724
749
|
declare function readContextManagerEnabled(config: unknown): boolean;
|
|
725
|
-
declare function resolveTargetAgent(ctx: HostContext$
|
|
750
|
+
declare function resolveTargetAgent(ctx: HostContext$1, sessionId: string): Promise<HostAgentLike | undefined>;
|
|
726
751
|
interface ContextControlOptions {
|
|
727
752
|
readonly config: () => unknown;
|
|
728
753
|
readonly state?: Pick<SessionState, 'read' | 'change'>;
|
|
729
754
|
}
|
|
730
|
-
declare function createContextControl(ctx: HostContext$
|
|
755
|
+
declare function createContextControl(ctx: HostContext$1, options: ContextControlOptions): {
|
|
731
756
|
setRecentConversation: (sessionId: string, value: {
|
|
732
757
|
readonly turns?: number | null;
|
|
733
758
|
readonly maxTokens?: number | null;
|
|
@@ -740,8 +765,8 @@ declare function createContextControl(ctx: HostContext$2, options: ContextContro
|
|
|
740
765
|
setCap: (sessionId: string, cap: SessionCap) => Promise<ContextSnapshot>;
|
|
741
766
|
};
|
|
742
767
|
declare function handleContextRequest(control: ContextControl, request?: Request): Promise<Response>;
|
|
743
|
-
declare function registerContextRoute(ctx: HostContext$
|
|
744
|
-
interface ContextHookHost extends HostContext$
|
|
768
|
+
declare function registerContextRoute(ctx: HostContext$1, control: ContextControl): () => void;
|
|
769
|
+
interface ContextHookHost extends HostContext$1 {
|
|
745
770
|
on?(event: string, listener: (...args: never[]) => unknown, options?: {
|
|
746
771
|
readonly prepend?: boolean;
|
|
747
772
|
}): () => void;
|
|
@@ -788,7 +813,7 @@ interface HostSessionEventLike {
|
|
|
788
813
|
};
|
|
789
814
|
readonly sourceEventSeqs?: readonly number[];
|
|
790
815
|
}
|
|
791
|
-
interface RecoveryHookHost extends HostContext$
|
|
816
|
+
interface RecoveryHookHost extends HostContext$1 {
|
|
792
817
|
on?(event: string, listener: (...args: never[]) => unknown, options?: {
|
|
793
818
|
readonly prepend?: boolean;
|
|
794
819
|
}): () => void;
|
|
@@ -802,7 +827,13 @@ interface SkillRecoveryOptions {
|
|
|
802
827
|
readonly available?: (name: string, sessionId: string) => boolean;
|
|
803
828
|
}
|
|
804
829
|
declare function readSkillRecoveryEnabled(config: unknown): boolean;
|
|
805
|
-
|
|
830
|
+
//#endregion
|
|
831
|
+
//#region src/recovery/host.d.ts
|
|
832
|
+
interface RecoveryOptions {
|
|
833
|
+
readonly config: () => unknown;
|
|
834
|
+
readonly skills: SkillRecoveryOptions;
|
|
835
|
+
}
|
|
836
|
+
declare function installRecovery(ctx: RecoveryHookHost, options: RecoveryOptions): () => void;
|
|
806
837
|
//#endregion
|
|
807
838
|
//#region src/shared/skill-retention.d.ts
|
|
808
839
|
interface SkillRetentionCandidate {
|
|
@@ -893,11 +924,12 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
893
924
|
}>>, "plain">;
|
|
894
925
|
export declare function apply(ctx: ToolsHostContext, config?: unknown): void;
|
|
895
926
|
export declare const __test: {
|
|
896
|
-
|
|
927
|
+
installRecovery: typeof installRecovery;
|
|
928
|
+
prepareRecentConversation: typeof prepareRecentConversation;
|
|
929
|
+
isRecentConversationMessage: typeof isRecentConversationMessage;
|
|
897
930
|
readRecentConversationPolicy: typeof readRecentConversationPolicy;
|
|
898
931
|
recentConversationSnapshot: typeof recentConversationSnapshot;
|
|
899
932
|
recentConversationTokenAdjustment: typeof recentConversationTokenAdjustment;
|
|
900
|
-
withoutRecentConversationRecovery: typeof withoutRecentConversationRecovery;
|
|
901
933
|
planRecentConversation: typeof planRecentConversation;
|
|
902
934
|
readRecentConversationSummary: typeof readRecentConversationSummary;
|
|
903
935
|
recoveryTextCost: typeof recoveryTextCost;
|
|
@@ -1008,7 +1040,6 @@ export declare const __test: {
|
|
|
1008
1040
|
resolvePolicy: typeof resolvePolicy;
|
|
1009
1041
|
decideRecovery: typeof decideRecovery;
|
|
1010
1042
|
renderSkillContentForRecovery: typeof renderSkillContentForRecovery;
|
|
1011
|
-
installSkillRecovery: typeof installSkillRecovery;
|
|
1012
1043
|
projectRecoveryState: typeof projectRecoveryState;
|
|
1013
1044
|
readSkillRecoveryEnabled: typeof readSkillRecoveryEnabled;
|
|
1014
1045
|
SKILL_RETENTION_TIMEOUT_MS: number;
|