dsh-desktop-enhance 0.10.0 → 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 CHANGED
@@ -87,9 +87,9 @@ Web 版(浏览器里打开的那种)**不提供插件查找的默认快捷
87
87
 
88
88
  ### 压缩后恢复近期原文
89
89
 
90
- 在摘要旁补一份近期原话备忘录:从宿主保留尾部之前往前取最近 10 个有效轮,人类对话与工作回报合计。预算上限为 32,768 估算 tokens;上下文占用弹窗可按会话调整轮数和预算,轮数设为 0 后停止未来恢复。超预算先丢最老整轮;只有最新单轮也放不下时,才对助手答复、工作回报做明确标记的头尾摘录,人类输入与审批答案不截断。图片仅恢复名称和附件定位,不重发像素。弹窗可查看上次实际恢复的总轮数、部分轮与原文。
90
+ 压缩后在下一次请求准入时追加独立的近期对话备忘录,位于本步新输入之后、恢复的 Skill 之前:从宿主保留尾部之前往前取最近 10 个有效轮,只保留人类对话与助手最终回复,并将历史回复中的 `dsh-ui` 组件提取为干净的纯文本/Markdown。预算上限为 32,768 估算 tokens;上下文占用弹窗可按会话调整轮数和预算,轮数设为 0 后停止未来恢复。超预算先丢最老整轮;只有最新单轮也放不下时,才对助手答复做明确标记的头尾摘录,人类输入与审批答案不截断。图片仅恢复名称和附件定位,不重发像素。弹窗可查看上次实际恢复的总轮数、部分轮与原文。
91
91
 
92
- 原文提取不额外调用模型,不把历史命令当成新的授权;预算维护仍可能调用原生摘要。Fork 沿用现有规则,不复制会话设置覆盖。Host 变更需重启 App,范围与限制见[近期原文恢复](docs/features/recent-conversation.md)。
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
@@ -82,29 +82,20 @@ interface RecoveryTextBlock {
82
82
  interface RecentConversationEntry {
83
83
  readonly seq: number;
84
84
  readonly turn: number;
85
- readonly time: number;
86
- readonly role: 'user' | 'assistant' | 'human-answer' | 'agent-report';
87
- readonly source: Record<string, unknown>;
85
+ readonly role: 'user' | 'assistant' | 'human-answer';
88
86
  readonly status: string;
89
87
  readonly text: string;
90
- readonly originalLength: number;
91
88
  readonly ranges: readonly (readonly [number, number])[];
92
89
  }
93
- interface RecentConversationRecord {
94
- readonly schemaVersion: 1;
95
- readonly sessionId: string;
96
- readonly throughSeq: number;
97
- readonly entries: readonly RecentConversationEntry[];
98
- readonly omitted: readonly {
99
- readonly seq: number;
100
- readonly turn: number;
101
- readonly reason: string;
102
- }[];
103
- readonly estimatedTokens: number;
90
+ interface RecentConversationSummary {
104
91
  readonly turns: {
105
92
  readonly complete: readonly number[];
106
93
  readonly partial: readonly number[];
107
94
  };
95
+ readonly estimatedTokens: number;
96
+ }
97
+ interface RecentConversationRecord extends RecentConversationSummary {
98
+ readonly entries: readonly RecentConversationEntry[];
108
99
  }
109
100
  type RecentConversationPlan = {
110
101
  readonly status: 'prepared';
@@ -120,196 +111,67 @@ interface Input {
120
111
  readonly events: readonly RecentConversationEvent[];
121
112
  readonly surfaceNodes: readonly number[];
122
113
  readonly compactedSeqs: readonly number[];
123
- readonly sessionId: string;
124
114
  readonly policy: RecentConversationPolicy;
125
115
  readonly budgetTokens: number;
126
116
  }
127
117
  declare function recoveryTextCost(value: string | readonly RecoveryTextBlock[]): number;
128
- declare function readRecentConversationRecord(value: unknown): RecentConversationRecord | null;
118
+ declare function readRecentConversationSummary(value: unknown): RecentConversationSummary | null;
129
119
  declare function planRecentConversation(input: Input): RecentConversationPlan;
130
- //#endregion
131
- //#region src/shared/suggest.d.ts
132
- declare function buildPrompt(template?: string): string;
133
- //#endregion
134
- //#region src/shared/diagnostics.d.ts
135
- type DiagnosticArea = 'suggest' | 'session' | 'remote';
136
- type DiagnosticPhase = 'started' | 'queued' | 'completed' | 'skipped' | 'cancelled' | 'failed' | 'fallback';
137
- type DiagnosticFields = Readonly<Record<string, string | number | boolean | readonly string[] | null | undefined>>;
138
- interface DiagnosticContext {
139
- readonly operationId?: string;
140
- readonly parentOperationId?: string;
141
- readonly sessionId?: string;
142
- readonly turn?: number;
143
- readonly step?: number;
144
- }
145
- interface DiagnosticInput extends DiagnosticContext {
146
- readonly area: DiagnosticArea;
147
- readonly event: string;
148
- readonly phase: DiagnosticPhase;
149
- readonly durationMs?: number;
150
- readonly fields?: DiagnosticFields;
151
- }
152
- interface DiagnosticRecord extends DiagnosticInput {
153
- readonly schemaVersion: 1;
154
- readonly id: string;
155
- readonly time: number;
156
- readonly runId: string;
157
- readonly source: 'host' | 'client';
158
- readonly level: 'info' | 'warn' | 'error';
159
- 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;
160
125
  }
161
- interface DiagnosticOperation {
126
+ type RecoveryState = RecoveryIdentity & ({
127
+ readonly state: 'restored';
128
+ } | {
129
+ readonly state: 'skipped';
130
+ readonly reason: 'empty' | 'budget';
131
+ });
132
+ interface RecoveryMessage {
162
133
  readonly id: string;
163
- record(phase: DiagnosticPhase, fields?: DiagnosticFields): void;
164
- end(phase: Exclude<DiagnosticPhase, 'started' | 'queued' | 'fallback'>, fields?: DiagnosticFields): void;
165
- }
166
- interface DiagnosticHealth {
167
- readonly state: 'starting' | 'ready' | 'failed' | 'closed';
168
- readonly pending: number;
169
- readonly persisted: number;
170
- readonly dropped: number;
171
- readonly rejected: number;
172
- readonly expired: number;
173
- readonly errorCode: string | null;
174
- readonly oldestTime: number | null;
175
- readonly latestTime: number | null;
176
- readonly retainedBytes: number;
177
- readonly retentionDays: number;
178
- readonly maxBytes: number;
179
- }
180
- interface DiagnosticQuery {
181
- readonly area?: DiagnosticArea;
182
- readonly sessionId?: string;
183
- readonly operationId?: string;
184
- readonly level?: 'info' | 'warn' | 'error';
185
- readonly from?: number;
186
- readonly to?: number;
187
- readonly cursor?: string;
188
- readonly limit?: number;
189
- }
190
- interface DiagnosticPage {
191
- readonly records: readonly DiagnosticRecord[];
192
- readonly nextCursor: string | null;
193
- readonly health: DiagnosticHealth;
194
- }
195
- //#endregion
196
- //#region src/suggest/host.d.ts
197
- interface HostContext$2 {
198
- get(name: string): unknown;
199
- inject(services: readonly string[], callback: (ctx: HostContext$2) => void): unknown;
200
- effect(factory: () => void | (() => void), label: string): unknown;
201
- readonly logger?: {
202
- warn(message: string): void;
134
+ readonly role: 'user';
135
+ readonly source: {
136
+ readonly kind: typeof RECENT_CONVERSATION_SOURCE;
137
+ readonly recovery: RecoveryState;
203
138
  };
139
+ readonly content: readonly RecoveryTextBlock[];
204
140
  }
205
- interface HostSession {
206
- deriveMessages(): readonly HostMessage$1[];
207
- requestHeader(): {
208
- readonly config?: HostRoute;
209
- } | undefined;
210
- }
211
- interface HostRoute {
212
- readonly provider?: string;
213
- readonly model?: string;
214
- }
215
- interface HostMessage$1 {
216
- readonly role?: string;
217
- readonly content?: readonly {
218
- readonly type?: string;
219
- readonly text?: string;
220
- }[];
221
- readonly source?: {
222
- readonly kind?: unknown;
223
- readonly entries?: unknown;
224
- };
225
- }
226
- interface HostGenerateOptions {
227
- readonly provider: string;
228
- readonly model: string;
229
- readonly messages: readonly HostMessage$1[];
230
- readonly system?: string;
231
- readonly maxTokens?: number;
232
- readonly sessionId?: string;
233
- readonly signal?: AbortSignal;
234
- readonly reasoningEffort?: string;
235
- }
236
- interface HostLlm {
237
- stream(options: HostGenerateOptions): AsyncIterable<HostChunk>;
238
- listProviders?(): readonly {
239
- readonly id?: unknown;
240
- readonly name?: unknown;
241
- }[];
242
- listModels?(provider: string): Promise<readonly unknown[]>;
243
- resolveModelInfo?(provider: string, model: string): Promise<unknown>;
244
- }
245
- interface HostChunk {
246
- readonly type?: string;
247
- readonly text?: string;
248
- readonly index?: number;
249
- readonly reason?: {
250
- readonly kind?: string;
251
- };
252
- }
253
- declare function collectText(chunks: AsyncIterable<HostChunk>, onFinish?: (kind: 'stop' | 'max-tokens') => void): Promise<string>;
254
- declare function routeOf(session: HostSession): {
255
- provider: string;
256
- model: string;
257
- } | null;
258
- declare function buildMessages(history: readonly HostMessage$1[], instruction: string): HostMessage$1[];
259
- declare function knownNamesOf(messages: readonly HostMessage$1[]): ReadonlySet<string> | null;
260
- declare function handleSuggest(ctx: HostContext$2, request: Request, timeoutMs?: number): Promise<Response>;
261
- declare function quietEffortFor(llm: HostLlm, route: {
262
- readonly provider: string;
263
- readonly model: string;
264
- }, operation?: DiagnosticOperation): Promise<string>;
265
- declare function listModels(ctx: HostContext$2): Promise<{
266
- providers: readonly {
267
- id: string;
268
- name: string;
269
- models: readonly {
270
- id: string;
271
- name: string;
272
- }[];
273
- }[];
274
- }>;
275
- declare function listEfforts(ctx: HostContext$2, provider: string, model: string): Promise<{
276
- efforts: readonly {
277
- id: string;
278
- name: string;
279
- }[];
280
- defaultEffort: string | null;
281
- }>;
282
- declare function registerSuggestRoute(ctx: HostContext$2): () => void;
141
+ declare function isRecentConversationMessage(value: unknown): boolean;
283
142
  //#endregion
284
143
  //#region src/recent-conversation/host.d.ts
285
- interface RecoveryHost extends HostContext$2 {
286
- on?(event: string, listener: (...args: never[]) => unknown, options?: {
287
- readonly prepend?: boolean;
288
- }): () => void;
144
+ interface RecoverySession {
145
+ readonly surface: {
146
+ readonly nodes: readonly number[];
147
+ };
148
+ snapshotEvents(): readonly RecentConversationEvent[];
289
149
  }
290
- interface RecentConversationOptions {
291
- readonly config: () => unknown;
150
+ interface RecoveryAgent {
151
+ readonly id: string;
152
+ readonly session: RecoverySession;
153
+ }
154
+ interface RecoveryContext {
155
+ get(name: string): unknown;
156
+ readonly config?: unknown;
292
157
  }
293
158
  declare function readRecentConversationPolicy(config: unknown, state: Pick<SessionState, 'read'> | undefined, sessionId: string): RecentConversationPolicy;
294
- declare function withoutRecentConversationRecovery<T>(session: object, work: () => Promise<T>): Promise<T>;
295
- declare function recentConversationTokenAdjustment(messages: readonly {
296
- readonly source?: {
297
- readonly kind?: string;
298
- };
299
- readonly content?: readonly {
300
- readonly type?: string;
301
- readonly text?: string;
302
- }[];
303
- }[]): 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
+ }
304
166
  declare function recentConversationSnapshot(session: {
305
- snapshotEvents?(): readonly {
306
- readonly type: string;
307
- readonly data?: unknown;
308
- }[];
167
+ readonly surface?: {
168
+ readonly nodes?: readonly number[];
169
+ };
170
+ snapshotEvents?(): readonly SnapshotEvent[];
309
171
  } | undefined, policy: RecentConversationPolicy, customized: boolean): {
310
172
  customized: boolean;
311
173
  last: {
312
- state: "restored" | "skipped" | "failed";
174
+ state: "restored" | "skipped" | "failed" | "pending";
313
175
  reason?: string;
314
176
  restoredTurns: number;
315
177
  partialTurns: number;
@@ -319,16 +181,15 @@ declare function recentConversationSnapshot(session: {
319
181
  turns: number;
320
182
  maxTokens: number;
321
183
  };
322
- declare function installRecentConversationRecovery(ctx: RecoveryHost, options: RecentConversationOptions): () => void;
323
184
  //#endregion
324
185
  //#region src/session-state/host.d.ts
325
186
  declare function handleSessionStateRequest(state: SessionState, request: Request, retry?: () => Promise<void>, lifetime?: AbortSignal): Promise<Response>;
326
- interface HostContext$1 {
187
+ interface HostContext$2 {
327
188
  get(name: string): unknown;
328
189
  readonly reflect: {
329
190
  provide(name: string, value: unknown): () => void;
330
191
  };
331
- inject(deps: readonly string[], callback: (ctx: HostContext$1) => void): {
192
+ inject(deps: readonly string[], callback: (ctx: HostContext$2) => void): {
332
193
  dispose(): Promise<unknown>;
333
194
  };
334
195
  effect(factory: () => unknown, label?: string): unknown;
@@ -336,7 +197,7 @@ interface HostContext$1 {
336
197
  warn(message: string): void;
337
198
  };
338
199
  }
339
- declare function installSessionState(ctx: HostContext$1): () => Promise<void>;
200
+ declare function installSessionState(ctx: HostContext$2): () => Promise<void>;
340
201
  //#endregion
341
202
  //#region src/session-state/store.d.ts
342
203
  declare const sessionStateDomainSpec: {
@@ -395,6 +256,68 @@ declare function createSessionState(options: SessionStateOptions): {
395
256
  close: () => Promise<void>;
396
257
  };
397
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
398
321
  //#region src/diagnostics/store.d.ts
399
322
  declare const segmentSchema: z.ZodObject<{
400
323
  rows: z.ZodArray<z.ZodObject<{
@@ -490,6 +413,97 @@ declare function handleDiagnosticRequest(store: DiagnosticStore, request: Reques
490
413
  declare function handleDiagnosticReport(store: DiagnosticStore, request: Request): Promise<Response>;
491
414
  declare function installDiagnostics(ctx: DiagnosticHostContext, config: unknown): () => Promise<void>;
492
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
493
507
  //#region src/shared/session-info.d.ts
494
508
  interface RawSystemSection {
495
509
  readonly name: string;
@@ -498,12 +512,12 @@ interface RawSystemSection {
498
512
  }
499
513
  //#endregion
500
514
  //#region src/session-info/host.d.ts
501
- declare function collectSystemPromptMetadata(ctx: HostContext$2, scope?: unknown, onPartial?: (error?: unknown) => void): {
515
+ declare function collectSystemPromptMetadata(ctx: HostContext$1, scope?: unknown, onPartial?: (error?: unknown) => void): {
502
516
  readonly systemSections: readonly RawSystemSection[];
503
517
  readonly pluginOwners: Readonly<Record<string, string>>;
504
518
  };
505
- declare function handleSessionInfo(ctx: HostContext$2, request: Request): Promise<Response>;
506
- declare function registerSessionInfoRoute(ctx: HostContext$2): () => void;
519
+ declare function handleSessionInfo(ctx: HostContext$1, request: Request): Promise<Response>;
520
+ declare function registerSessionInfoRoute(ctx: HostContext$1): () => void;
507
521
  //#endregion
508
522
  //#region src/shared/tools-manager.d.ts
509
523
  type ToolScope = 'builtin' | 'plugin';
@@ -529,18 +543,18 @@ interface HostPromptAssembly {
529
543
  }[];
530
544
  readonly [key: string]: unknown;
531
545
  }
532
- interface ToolsHostContext extends HostContext$2 {
546
+ interface ToolsHostContext extends HostContext$1 {
533
547
  on?(event: string, listener: (assembly: HostPromptAssembly, context: unknown, next: () => Promise<HostPromptAssembly>) => Promise<HostPromptAssembly>): () => void;
534
548
  }
535
- declare function resolveSessionIdFromScope(candidate: unknown, ctx?: HostContext$2): string | undefined;
549
+ declare function resolveSessionIdFromScope(candidate: unknown, ctx?: HostContext$1): string | undefined;
536
550
  declare function readToolsConfig(config: unknown, sessionId?: string, state?: Pick<SessionState, 'read'>): ToolsPolicyState;
537
551
  declare function resolveFiberModuleName(fiber: unknown): string | undefined;
538
552
  declare function resolveCallerPackageFromStack(stack?: string): string | undefined;
539
- declare function scanCordisFiberToolOwners(ctx: HostContext$2, targetOwners?: Map<string, string>): Map<string, string>;
540
- declare function collectAllToolSchemas(ctx: HostContext$2, sessionId?: string): Promise<readonly ToolSummary[]>;
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[]>;
541
555
  declare function installToolsPolicy(ctx: ToolsHostContext, readState: (sessionId?: string) => ToolsPolicyState): () => void;
542
- declare function handleToolsCatalog(ctx: HostContext$2, request?: Request): Promise<Response>;
543
- declare function registerToolsRoute(ctx: HostContext$2): () => void;
556
+ declare function handleToolsCatalog(ctx: HostContext$1, request?: Request): Promise<Response>;
557
+ declare function registerToolsRoute(ctx: HostContext$1): () => void;
544
558
  //#endregion
545
559
  //#region src/remote/update.d.ts
546
560
  type UpdatePhase = 'idle' | 'checking' | 'available' | 'downloading' | 'verifying' | 'ready' | 'installing' | 'error';
@@ -632,10 +646,10 @@ interface SkillsPolicyState {
632
646
  readonly disabled: ReadonlySet<string>;
633
647
  }
634
648
  declare function readSkillsConfig(config: unknown, sessionId?: string, state?: Pick<SessionState, 'read'>): SkillsPolicyState;
635
- declare function collectSkillCatalog(ctx: HostContext$2, sessionId?: string): Promise<readonly SkillCatalogItem[]>;
649
+ declare function collectSkillCatalog(ctx: HostContext$1, sessionId?: string): Promise<readonly SkillCatalogItem[]>;
636
650
  declare function installSkillsPolicy(ctx: ToolsHostContext, readState: (sessionId?: string) => SkillsPolicyState): () => void;
637
- declare function handleSkillsCatalog(ctx: HostContext$2, request?: Request): Promise<Response>;
638
- declare function registerSkillsRoute(ctx: HostContext$2): () => void;
651
+ declare function handleSkillsCatalog(ctx: HostContext$1, request?: Request): Promise<Response>;
652
+ declare function registerSkillsRoute(ctx: HostContext$1): () => void;
639
653
  //#endregion
640
654
  //#region src/shared/context-policy.d.ts
641
655
  type SessionCap = number | null;
@@ -704,8 +718,9 @@ interface HostMessage {
704
718
  interface HostSessionEvent {
705
719
  readonly type: string;
706
720
  readonly seq: number;
707
- readonly data?: {
721
+ readonly data?: HostMessage & {
708
722
  readonly message?: HostMessage;
723
+ readonly turn?: number;
709
724
  };
710
725
  readonly sourceEventSeqs?: readonly number[];
711
726
  readonly surfaceOp?: string | {
@@ -732,12 +747,12 @@ interface HostSessionLike {
732
747
  }
733
748
  declare function readCap(state: Pick<SessionState, 'read'>, sessionId: string): SessionCap;
734
749
  declare function readContextManagerEnabled(config: unknown): boolean;
735
- declare function resolveTargetAgent(ctx: HostContext$2, sessionId: string): Promise<HostAgentLike | undefined>;
750
+ declare function resolveTargetAgent(ctx: HostContext$1, sessionId: string): Promise<HostAgentLike | undefined>;
736
751
  interface ContextControlOptions {
737
752
  readonly config: () => unknown;
738
753
  readonly state?: Pick<SessionState, 'read' | 'change'>;
739
754
  }
740
- declare function createContextControl(ctx: HostContext$2, options: ContextControlOptions): {
755
+ declare function createContextControl(ctx: HostContext$1, options: ContextControlOptions): {
741
756
  setRecentConversation: (sessionId: string, value: {
742
757
  readonly turns?: number | null;
743
758
  readonly maxTokens?: number | null;
@@ -750,8 +765,8 @@ declare function createContextControl(ctx: HostContext$2, options: ContextContro
750
765
  setCap: (sessionId: string, cap: SessionCap) => Promise<ContextSnapshot>;
751
766
  };
752
767
  declare function handleContextRequest(control: ContextControl, request?: Request): Promise<Response>;
753
- declare function registerContextRoute(ctx: HostContext$2, control: ContextControl): () => void;
754
- interface ContextHookHost extends HostContext$2 {
768
+ declare function registerContextRoute(ctx: HostContext$1, control: ContextControl): () => void;
769
+ interface ContextHookHost extends HostContext$1 {
755
770
  on?(event: string, listener: (...args: never[]) => unknown, options?: {
756
771
  readonly prepend?: boolean;
757
772
  }): () => void;
@@ -798,7 +813,7 @@ interface HostSessionEventLike {
798
813
  };
799
814
  readonly sourceEventSeqs?: readonly number[];
800
815
  }
801
- interface RecoveryHookHost extends HostContext$2 {
816
+ interface RecoveryHookHost extends HostContext$1 {
802
817
  on?(event: string, listener: (...args: never[]) => unknown, options?: {
803
818
  readonly prepend?: boolean;
804
819
  }): () => void;
@@ -812,7 +827,13 @@ interface SkillRecoveryOptions {
812
827
  readonly available?: (name: string, sessionId: string) => boolean;
813
828
  }
814
829
  declare function readSkillRecoveryEnabled(config: unknown): boolean;
815
- declare function installSkillRecovery(ctx: RecoveryHookHost, options: SkillRecoveryOptions): () => void;
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;
816
837
  //#endregion
817
838
  //#region src/shared/skill-retention.d.ts
818
839
  interface SkillRetentionCandidate {
@@ -903,13 +924,14 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
903
924
  }>>, "plain">;
904
925
  export declare function apply(ctx: ToolsHostContext, config?: unknown): void;
905
926
  export declare const __test: {
906
- installRecentConversationRecovery: typeof installRecentConversationRecovery;
927
+ installRecovery: typeof installRecovery;
928
+ prepareRecentConversation: typeof prepareRecentConversation;
929
+ isRecentConversationMessage: typeof isRecentConversationMessage;
907
930
  readRecentConversationPolicy: typeof readRecentConversationPolicy;
908
931
  recentConversationSnapshot: typeof recentConversationSnapshot;
909
932
  recentConversationTokenAdjustment: typeof recentConversationTokenAdjustment;
910
- withoutRecentConversationRecovery: typeof withoutRecentConversationRecovery;
911
933
  planRecentConversation: typeof planRecentConversation;
912
- readRecentConversationRecord: typeof readRecentConversationRecord;
934
+ readRecentConversationSummary: typeof readRecentConversationSummary;
913
935
  recoveryTextCost: typeof recoveryTextCost;
914
936
  imageTokensForModel: typeof imageTokensForModel;
915
937
  installImagePricing: typeof installImagePricing;
@@ -1018,7 +1040,6 @@ export declare const __test: {
1018
1040
  resolvePolicy: typeof resolvePolicy;
1019
1041
  decideRecovery: typeof decideRecovery;
1020
1042
  renderSkillContentForRecovery: typeof renderSkillContentForRecovery;
1021
- installSkillRecovery: typeof installSkillRecovery;
1022
1043
  projectRecoveryState: typeof projectRecoveryState;
1023
1044
  readSkillRecoveryEnabled: typeof readSkillRecoveryEnabled;
1024
1045
  SKILL_RETENTION_TIMEOUT_MS: number;