dsh-manage-session 0.5.7 → 2.0.4

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.
Files changed (67) hide show
  1. package/CHANGELOG.ja.md +33 -229
  2. package/CHANGELOG.ko.md +33 -229
  3. package/CHANGELOG.md +33 -363
  4. package/INSTALL.ja.md +164 -164
  5. package/INSTALL.ko.md +164 -164
  6. package/INSTALL.md +164 -164
  7. package/INSTALL.zh.md +164 -164
  8. package/LICENSE +21 -21
  9. package/README.en.md +41 -46
  10. package/README.ja.md +33 -57
  11. package/README.ko.md +32 -55
  12. package/README.md +64 -64
  13. package/cordis.patch.yml +19 -16
  14. package/dsh.plugin.json +4 -4
  15. package/lib/client.js +661 -3082
  16. package/lib/index.d.ts +79 -970
  17. package/lib/index.js +249 -2669
  18. package/locale/de.json +2 -2
  19. package/locale/en.json +2 -2
  20. package/locale/es.json +2 -2
  21. package/locale/fr.json +2 -2
  22. package/locale/it.json +2 -2
  23. package/locale/ja.json +2 -2
  24. package/locale/ko.json +2 -2
  25. package/locale/ru.json +2 -2
  26. package/locale/zh.json +2 -2
  27. package/package.json +15 -25
  28. package/screenshots.json +3 -3
  29. package/src/client/bridge-scope.ts +202 -213
  30. package/src/client/card.tsx +154 -154
  31. package/src/client/health-panel.tsx +49 -49
  32. package/src/client/host-api.ts +72 -6
  33. package/src/client/index.ts +594 -503
  34. package/src/client/locales.ts +893 -893
  35. package/src/client/manage-locales.ts +178 -0
  36. package/src/client/{search/manage.tsx → manage.tsx} +430 -404
  37. package/src/client/panel.tsx +131 -129
  38. package/src/client/session-menu-legacy.ts +2 -3
  39. package/src/client/session-menu.tsx +5 -5
  40. package/src/config.ts +43 -99
  41. package/src/host/health/attribution.ts +118 -118
  42. package/src/host/health/lossless.ts +128 -128
  43. package/src/host/health/repair.ts +2 -2
  44. package/src/host/health/source-kind.ts +350 -350
  45. package/src/host/history/archive-source.ts +250 -250
  46. package/src/host/history/archive.ts +249 -249
  47. package/src/host/history/favorites.ts +71 -71
  48. package/src/host/history/purge.ts +370 -370
  49. package/src/host/history/tombstones.ts +3 -3
  50. package/src/host/registry/archive-registry.ts +317 -317
  51. package/src/host/settings-bridge.ts +222 -264
  52. package/src/index.ts +66 -694
  53. package/src/client/search/card.tsx +0 -563
  54. package/src/client/search/host-api.ts +0 -213
  55. package/src/client/search/locales.ts +0 -861
  56. package/src/client/search/locate.ts +0 -330
  57. package/src/client/search/panel.tsx +0 -940
  58. package/src/client/search/platform.ts +0 -136
  59. package/src/host/index/archive-source.ts +0 -90
  60. package/src/host/index/drs-source.ts +0 -211
  61. package/src/host/index/engine.ts +0 -699
  62. package/src/host/index/extract.ts +0 -272
  63. package/src/host/index/peers.ts +0 -62
  64. package/src/host/index/rebuild.ts +0 -432
  65. package/src/host/index/schema.ts +0 -136
  66. package/src/host/index/snapshot.ts +0 -135
  67. package/src/host/index/sync.ts +0 -413
package/lib/index.d.ts CHANGED
@@ -1,10 +1,7 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
- //#region node_modules/.pnpm/cosmokit@1.8.1/node_modules/cosmokit/lib/index.d.ts
3
2
  type Dict<T = any, K extends string | symbol = string> = { [key in K]: T; };
4
3
  type Promisify<T> = Promise<T extends Promise<infer S> ? S : T>;
5
4
  type Awaitable<T> = [T] extends [Promise<unknown>] ? T : T | Promise<T>;
6
- //#endregion
7
- //#region node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
8
5
  /** The Standard Typed interface. This is a base type extended by other specs. */
9
6
  interface StandardTypedV1<Input = unknown, Output = Input> {
10
7
  /** The Standard properties. */
@@ -80,8 +77,25 @@ declare namespace StandardSchemaV1 {
80
77
  /** Infers the output type of a Standard. */
81
78
  type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
82
79
  }
83
- //#endregion
84
- //#region node_modules/.pnpm/cordis@4.0.0-rc.10/node_modules/cordis/lib/utils.d.ts
80
+ declare abstract class Service<out T = never> {
81
+ protected ctx: Context;
82
+ static readonly init: unique symbol;
83
+ static readonly check: unique symbol;
84
+ static readonly invoke: unique symbol;
85
+ static readonly metadata: unique symbol;
86
+ static readonly extend: unique symbol;
87
+ static readonly tracker: unique symbol;
88
+ static readonly mergeIntercept: unique symbol;
89
+ static readonly resolveIntercept: unique symbol;
90
+ [symbols.metadata]: T;
91
+ name: string;
92
+ constructor(ctx: Context, name: string);
93
+ protected [symbols.filter](ctx: Context): boolean;
94
+ protected [symbols.extend](props?: any): any;
95
+ [symbols.mergeIntercept](...values: T[]): T;
96
+ [symbols.resolveIntercept](): T;
97
+ static [Symbol.hasInstance](instance: any): boolean;
98
+ }
85
99
  declare class DisposableList<T extends WeakKey> {
86
100
  private sn;
87
101
  private map;
@@ -97,29 +111,29 @@ declare const symbols: {
97
111
  caller: symbol;
98
112
  receiver: symbol;
99
113
  original: symbol;
100
- metadata: symbol;
114
+ decorator: symbol;
101
115
  initHooks: symbol;
102
116
  checkProto: symbol;
117
+ root: typeof Context.root;
103
118
  effect: typeof Context.effect;
104
119
  filter: typeof Context.filter;
105
120
  isolate: typeof Context.isolate;
106
121
  intercept: typeof Context.intercept;
107
122
  init: typeof Service.init;
108
123
  check: typeof Service.check;
109
- config: typeof Service.config;
110
124
  invoke: typeof Service.invoke;
125
+ metadata: typeof Service.metadata;
111
126
  extend: typeof Service.extend;
112
127
  tracker: typeof Service.tracker;
113
- resolveConfig: typeof Service.resolveConfig;
128
+ mergeIntercept: typeof Service.mergeIntercept;
129
+ resolveIntercept: typeof Service.resolveIntercept;
114
130
  };
115
- //#endregion
116
- //#region node_modules/.pnpm/cordis@4.0.0-rc.10/node_modules/cordis/lib/registry.d.ts
117
131
  type Inject<M = Dict> = (keyof M)[] | { [K in keyof M]?: M[K]; };
118
132
  type InjectKey = keyof { [K in keyof Context & string as Context[K] extends {
119
- [symbols.config]: any;
133
+ [symbols.metadata]: any;
120
134
  } ? K : never]: any; };
121
135
  declare function Inject<K extends InjectKey>(name: K, config?: Context[K] extends {
122
- [symbols.config]: infer T;
136
+ [symbols.metadata]: infer T;
123
137
  } ? T : never): (value: any, decorator: ClassDecoratorContext<any> | ClassMethodDecoratorContext<any>) => void;
124
138
  declare namespace Inject {
125
139
  function resolve(inject: Inject | null | undefined, result?: Dict): Dict;
@@ -158,7 +172,7 @@ type GetPluginParameters<P> = P extends ((ctx: Context, ...args: infer R) => any
158
172
  apply(ctx: Context, ...args: infer R): any;
159
173
  } ? R : never;
160
174
  type GetPluginConfig<P> = P extends Plugin.Transform<infer S, any> ? S : GetPluginParameters<P>[0];
161
- declare module './context' {
175
+ declare module './context.ts' {
162
176
  interface Context {
163
177
  inject(deps: Inject, callback: Plugin.Function<void>): Fiber & PromiseLike<Fiber>;
164
178
  plugin<P extends Plugin>(plugin: P, ...args: Spread<GetPluginConfig<P>>): Fiber & PromiseLike<Fiber>;
@@ -182,9 +196,7 @@ declare class RegistryService {
182
196
  inject(inject: Inject, callback: Plugin.Function<void>): Fiber & PromiseLike<Fiber>;
183
197
  plugin(plugin: Plugin, config?: any, getOuterStack?: () => string[]): Fiber & PromiseLike<Fiber>;
184
198
  }
185
- //#endregion
186
- //#region node_modules/.pnpm/cordis@4.0.0-rc.10/node_modules/cordis/lib/reflect.d.ts
187
- declare module './context' {
199
+ declare module './context.ts' {
188
200
  interface Context {
189
201
  get<K extends string & keyof this>(name: K, strict?: boolean): undefined | this[K];
190
202
  get(name: string, strict?: boolean): any;
@@ -209,30 +221,33 @@ declare namespace Property {
209
221
  }
210
222
  }
211
223
  interface Impl {
224
+ uid: number;
212
225
  name: string;
213
- fiber: Fiber;
226
+ ctx: Context;
227
+ dependents: Set<Fiber>;
228
+ release?: () => void;
214
229
  value?: any;
215
230
  check?: () => boolean;
231
+ isolate: symbol;
216
232
  }
217
233
  declare class ReflectService {
218
234
  ctx: Context;
219
235
  static handler: ProxyHandler<Context>;
220
236
  store: Dict<Impl, symbol>;
221
237
  props: Dict<Property>;
238
+ private _implCounter;
222
239
  constructor(ctx: Context);
223
240
  get(name: string, strict?: boolean): any;
224
241
  _getImpl(name: string, strict?: boolean): Impl | undefined;
225
242
  set(name: string, value: any, error?: Error): boolean;
226
243
  provide(name: string, value?: any, check?: () => boolean): Disposable<Promise<void>>;
227
- notify(names: string[], filter?: (ctx: Context, name: string) => boolean): Fiber[];
244
+ notify(names: string[], filter?: (ctx: Context, name: string) => boolean): void;
228
245
  accessor(name: string, options: Omit<Property.Accessor, 'type'>): Disposable<Promise<void>>;
229
246
  mixin(source: any, mixins: string[] | Dict<string>): Disposable<Promise<void>>;
230
247
  trace<T>(value: T): T;
231
248
  bind<T extends Function>(callback: T): T;
232
249
  }
233
- //#endregion
234
- //#region node_modules/.pnpm/cordis@4.0.0-rc.10/node_modules/cordis/lib/fiber.d.ts
235
- declare module './context' {
250
+ declare module './context.ts' {
236
251
  interface Context extends Pick<Fiber, 'effect'> {
237
252
  fiber: Fiber;
238
253
  }
@@ -258,24 +273,28 @@ declare const enum FiberState {
258
273
  }
259
274
  declare class Fiber {
260
275
  parent: Context;
276
+ config: any;
261
277
  inject: Dict<any>;
262
278
  runtime: Plugin.Runtime | null;
263
279
  uid: number | null;
264
280
  readonly ctx: Context;
265
- config: any;
266
281
  state: FiberState;
267
282
  readonly dispose: () => Promise<void>;
268
- store: Dict<Impl> | undefined;
283
+ committed: Readonly<Dict<Impl>> | undefined;
284
+ readonly provisions: Set<Impl>;
269
285
  inertia: Promise<void> | undefined;
270
286
  readonly _hooks: Dict<DisposableList<Function>>;
271
287
  readonly _disposables: DisposableList<Disposable<any>>;
272
288
  protected context: Context;
273
289
  private _error;
290
+ private _revision;
274
291
  private _runner;
275
292
  private _store;
293
+ private _release;
276
294
  constructor(parent: Context, config: any, inject: Dict<any>, runtime: Plugin.Runtime | null, getOuterStack: () => string[]);
277
295
  get name(): string;
278
296
  assertActive(): void;
297
+ private _resolve;
279
298
  private _execute;
280
299
  effect(execute: () => SyncEffect, label?: string): Disposable<Promise<void>>;
281
300
  effect(execute: () => Effect, label?: string): AsyncDisposable<Promise<void>>;
@@ -291,24 +310,22 @@ declare class Fiber {
291
310
  restart(): Promise<void>;
292
311
  update(config: any, noSave?: boolean): Awaitable<void>;
293
312
  }
294
- //#endregion
295
- //#region node_modules/.pnpm/cordis@4.0.0-rc.10/node_modules/cordis/lib/events.d.ts
296
313
  type Parameters<F> = F extends ((...args: infer P) => any) ? P : never;
297
- type ReturnType$1<F> = F extends ((...args: any) => infer R) ? R : never;
314
+ type ReturnType<F> = F extends ((...args: any) => infer R) ? R : never;
298
315
  type ThisType<F> = F extends ((this: infer T, ...args: any) => any) ? T : never;
299
316
  type DispatchMode = 'emit' | 'parallel' | 'serial' | 'bail' | 'waterfall';
300
- declare module './context' {
317
+ declare module './context.ts' {
301
318
  interface Context {
302
319
  parallel<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): Promise<void>;
303
320
  parallel<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): Promise<void>;
304
321
  emit<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): void;
305
322
  emit<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): void;
306
- serial<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): Promisify<ReturnType$1<Events[K]>>;
307
- serial<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): Promisify<ReturnType$1<Events[K]>>;
308
- bail<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
309
- bail<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
310
- waterfall<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
311
- waterfall<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): ReturnType$1<Events[K]>;
323
+ serial<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): Promisify<ReturnType<Events[K]>>;
324
+ serial<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): Promisify<ReturnType<Events[K]>>;
325
+ bail<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): ReturnType<Events[K]>;
326
+ bail<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): ReturnType<Events[K]>;
327
+ waterfall<K extends keyof Events>(name: K, ...args: Parameters<Events[K]>): ReturnType<Events[K]>;
328
+ waterfall<K extends keyof Events>(thisArg: NoInfer<ThisType<Events[K]>>, name: K, ...args: Parameters<Events[K]>): ReturnType<Events[K]>;
312
329
  on<K extends keyof Events>(name: K, listener: Events[K], options?: boolean | EventOptions): () => boolean;
313
330
  once<K extends keyof Events>(name: K, listener: Events[K], options?: boolean | EventOptions): () => boolean;
314
331
  }
@@ -343,19 +360,14 @@ interface Events {
343
360
  'internal/plugin'(fiber: Fiber): void;
344
361
  'internal/status'(fiber: Fiber, oldValue: FiberState): void;
345
362
  'internal/service'(this: Context, name: string, value: any): void;
346
- 'internal/update'(this: Fiber, config: any, noSave: boolean, next: () => Awaitable<void>): Awaitable<void>;
363
+ 'internal/update'(this: Fiber, resolvedConfig: any, next: () => Awaitable<void>): Awaitable<void>;
364
+ 'internal/commit'(fiber: Fiber, originalConfig: any): void;
365
+ 'internal/config'(fiber: Fiber, next: () => any): any;
347
366
  'internal/get'(ctx: Context, name: string, error: Error, next: () => any): any;
348
367
  'internal/set'(ctx: Context, name: string, value: any, error: Error, next: () => boolean): boolean;
349
368
  'internal/listener'(this: Context, name: string, listener: any, prepend: boolean): void;
350
369
  'internal/dispatch'(mode: DispatchMode, name: string | symbol, args: any[], thisArg: any): void;
351
370
  }
352
- //#endregion
353
- //#region node_modules/.pnpm/cordis@4.0.0-rc.10/node_modules/cordis/lib/logger.d.ts
354
- declare module './context' {
355
- interface Intercept {
356
- logger: LoggerService.Intercept;
357
- }
358
- }
359
371
  type LoggerType = 'error' | 'info' | 'warn' | 'debug';
360
372
  type LoggerMethod = (format: any, ...param: any[]) => void;
361
373
  type Formatter = (value: any, exporter: Exporter, message: Message) => any;
@@ -400,6 +412,7 @@ interface LoggerService extends Record<LoggerType, LoggerMethod> {
400
412
  (name?: string): Logger;
401
413
  }
402
414
  declare class LoggerService {
415
+ [symbols.metadata]: LoggerService.Intercept;
403
416
  bufferSize: number;
404
417
  buffer: Message[];
405
418
  ctx: Context;
@@ -408,16 +421,12 @@ declare class LoggerService {
408
421
  exporters: Map<number, Exporter>;
409
422
  constructor(ctx: Context);
410
423
  exporter(exporter: Exporter): Disposable<Promise<void>>;
411
- private _resolveConfig;
412
424
  [symbols.invoke](name?: string): Logger;
413
425
  }
414
- //#endregion
415
- //#region node_modules/.pnpm/cordis@4.0.0-rc.10/node_modules/cordis/lib/context.d.ts
416
426
  interface Context {
427
+ [symbols.root]: this;
417
428
  [symbols.isolate]: Dict<symbol>;
418
429
  [symbols.intercept]: Dict;
419
- /** @experimental */
420
- root: this;
421
430
  baseUrl?: string | undefined;
422
431
  events: EventsService;
423
432
  logger: LoggerService;
@@ -425,6 +434,7 @@ interface Context {
425
434
  registry: RegistryService;
426
435
  }
427
436
  declare class Context {
437
+ static readonly root: unique symbol;
428
438
  static readonly effect: unique symbol;
429
439
  static readonly filter: unique symbol;
430
440
  static readonly isolate: unique symbol;
@@ -434,101 +444,41 @@ declare class Context {
434
444
  extend(meta?: {}): this;
435
445
  isolate(name: string, label?: symbol): this;
436
446
  intercept<K extends InjectKey>(name: K, config: Context[K] extends {
437
- [symbols.config]: infer T;
447
+ [symbols.metadata]: infer T;
438
448
  } ? T : never): this;
439
449
  intercept(name: string, config: any): this;
440
450
  }
441
- //#endregion
442
- //#region node_modules/.pnpm/cordis@4.0.0-rc.10/node_modules/cordis/lib/service.d.ts
443
- declare abstract class Service<out T = never> {
444
- protected ctx: Context;
445
- static readonly init: unique symbol;
446
- static readonly check: unique symbol;
447
- static readonly config: unique symbol;
448
- static readonly invoke: unique symbol;
449
- static readonly extend: unique symbol;
450
- static readonly tracker: unique symbol;
451
- static readonly resolveConfig: unique symbol;
452
- [symbols.config]: T;
453
- name: string;
454
- constructor(ctx: Context, name: string);
455
- protected [symbols.filter](ctx: Context): boolean;
456
- protected [symbols.extend](props?: any): any;
457
- [symbols.resolveConfig](base?: T, head?: T): T;
458
- static [Symbol.hasInstance](instance: any): boolean;
459
- }
460
- //#endregion
461
- //#region src/config.d.ts
462
451
  /**
463
- * dsh-manage-session 的共享配置面(合并包:管家子域 + 搜索索引子域)。
452
+ * dsh-manage-session 的共享配置面(会话管理器:归档 + 体检)。
464
453
  *
465
454
  * 与 host 半身(schemastery schema 在 src/index.ts)以及浏览器半身共用同一形状,
466
455
  * 使一处 admitted 的值在另一处也 admitted。
467
456
  *
468
- * 两个设置命名空间**并存且互不迁移**:
469
- * - `session-steward` —— 管家子域(enabled/historyFiles/healthCheck/search 等共享键);
470
- * - `switch-search` —— 搜索子域的历史命名空间,存储键承诺保持稳定(见
471
- * dsh-search-index README「存储键保持稳定,不做迁移」);0.1.7 起两者实际
472
- * 都落在同一 composition entry(configForms),旧宿主才按命名空间分流。
457
+ * 设置命名空间只有一个:`manage-session`(enabled/historyFiles/healthCheck/directDelete)。
458
+ * 搜索/索引子域已拆回 dsh-search-index,本包不再持有 `search` 开关、索引目录、
459
+ * 语料源(DRS)等字段——DRS 依赖也随搜索一起迁回那边。
473
460
  */
474
- /** 会话管家运行时配置(设置命名空间 + 组合入口)。 */
461
+ /** 会话管理运行时配置(设置命名空间 + 组合入口)。 */
475
462
  interface StewardConfig {
476
- /** 插件总开关(合并包唯一 master:关闭后不注册任何子域路由)。 */
463
+ /** 插件总开关(关闭后不注册任何子域路由)。 */
477
464
  enabled: boolean;
478
- /** 会话历史文件(归档浏览与清理)。关闭后不注册 history 路由、不渲染「养老院」页签。 */
465
+ /** 会话历史文件(归档浏览与清理)。关闭后不注册 history 路由。 */
479
466
  historyFiles?: boolean;
480
467
  /** 会话健康检查(体检 → 处方 → 出院)。关闭后不注册 health 路由、不渲染「体检」页签。 */
481
468
  healthCheck?: boolean;
482
- /** 搜索索引子域(`index-*` 路由与侧栏搜索入口)。关闭后索引子域整体停摆。 */
483
- search?: boolean;
484
469
  /**
485
- * 直接删除入口(2026-10-20 用户定标):开启后搜索面板结果行出现行内
486
- * 「删除」按钮(两步确认,走管理端同款 session-history-purge 链路)。
487
- * **缺省关**——破坏性入口不默认铺开;管理端批量删除不受本开关限制。
470
+ * 直接删除入口(2026-10-20 用户定标):开启后侧栏会话菜单出现「删除」行
471
+ * (两步确认,走管理端同款 session-history-purge 链路)。
472
+ * **缺省关**——破坏性入口不默认铺开;管理端批量删除不受本开关限制。
488
473
  */
489
474
  directDelete?: boolean;
490
475
  }
491
476
  /** 缺省值。 */
492
477
  declare const DEFAULT_CONFIG: Required<StewardConfig>;
493
478
  /** host 半身注册的设置命名空间(与 src/index.ts 保持一致)。 */
494
- declare const STEWARD_SETTINGS_NAMESPACE = "session-steward";
495
- /** host 路由前缀(管家子域;与搜索子域的 /switch-search/api 互不干扰)。 */
496
- declare const STEWARD_API_PREFIX = "/session-steward/api";
497
- /** 搜索子域路由前缀(历史值,浏览器旧 bundle 与快照文件名依赖它,保持不变)。 */
498
- declare const SWITCH_API_PREFIX = "/switch-search/api";
499
- /** 搜索面板打开时的默认模式。 */
500
- type SwitchSearchDefaultMode = 'title' | 'content';
501
- /** 搜索子域可调配置(独立于 StewardConfig 的历史形状,字段名保持稳定)。 */
502
- interface SwitchSearchConfig {
503
- /**
504
- * 搜索卡上的「启用」开关。合并包里它与管家 `enabled` 是**同一个**组合入口
505
- * 字段(0.1.7 configForms 单 scope);保留在此处是为了 legacy settingsScope
506
- * 回退路径(旧 switch-search 命名空间的存储形状)与设置卡类型不变。
507
- */
508
- enabled?: boolean;
509
- /** 面板默认模式。 */
510
- defaultMode: SwitchSearchDefaultMode;
511
- /** 独立索引是否后台自动同步(水位轮询)。 */
512
- autoSync?: boolean;
513
- /** 增量同步间隔(ms)。 */
514
- syncIntervalMs?: number;
515
- /** 整理索引后保留的归档份数。 */
516
- archiveKeep?: number;
517
- /** 独立索引文件的可选绝对目录。 */
518
- indexDir?: string;
519
- /**
520
- * 语料源(T7.1):`'native'`=sessionQuery 服务 + 转录文件兜底(缺省);
521
- * `'drs'`=dsh-reference-session-collector 投影库(docs 直插;DRS 不可达时整轮
522
- * 回退 native 链路,水位语义切换的首轮会全量重灌一次)。
523
- */
524
- corpusSource?: 'native' | 'drs';
525
- /** DRS 投影库 API 基址;空=自动(首个 trustedHosts 条目,再退 http://127.0.0.1:8080)。 */
526
- drsBaseUrl?: string;
527
- }
528
- /** 搜索子域缺省值。 */
529
- declare const SWITCH_DEFAULT_CONFIG: Required<SwitchSearchConfig>;
530
- //#endregion
531
- //#region src/host/history/archive-source.d.ts
479
+ declare const STEWARD_SETTINGS_NAMESPACE = "manage-session";
480
+ /** host 路由前缀(管理 + 体检,方法名一律 `session-*`)。 */
481
+ declare const STEWARD_API_PREFIX = "/manage-session/api";
532
482
  /** 一次归档读取的结果:ids 以及服务它的来源。 */
533
483
  interface StewardArchiveRead {
534
484
  ids: readonly string[];
@@ -611,8 +561,6 @@ declare function archiveArchiveFile(ids: readonly string[], log?: (msg: string)
611
561
  total: number;
612
562
  file?: string;
613
563
  };
614
- //#endregion
615
- //#region src/host/settings-bridge.d.ts
616
564
  /** 桥对 handleMethod 暴露的面。 */
617
565
  interface LegacySettingsBridge {
618
566
  /** 读一个命名空间文档(无文档/非对象 → undefined)。 */
@@ -625,8 +573,6 @@ interface BridgeState {
625
573
  bridge: LegacySettingsBridge | undefined;
626
574
  revision: number;
627
575
  }
628
- //#endregion
629
- //#region src/host/health/decode.d.ts
630
576
  /** 一次读取的统计与问题清单。 */
631
577
  interface SessionLogRead {
632
578
  events: DecodedEvent[];
@@ -693,8 +639,6 @@ interface OfficialDecoders {
693
639
  declare function decodeSessionLogBytes(file: string, bytes: Buffer, decoders?: OfficialDecoders): SessionLogRead;
694
640
  /** 从文件读取并解码。 */
695
641
  declare function decodeSessionLogFile(file: string, decoders?: OfficialDecoders): SessionLogRead;
696
- //#endregion
697
- //#region src/host/health/generation.d.ts
698
642
  /** 日志的物理编码(对齐宿主的 `JsonlCompression`)。 */
699
643
  type LogCompression = 'zstd' | 'none';
700
644
  /** 处置优先级:`high` = 该会话的当前代是从暂存(TMP)发布出来的。 */
@@ -783,8 +727,6 @@ declare function latestArtifactMtime(facts: SessionGenerations): number | undefi
783
727
  * @returns 处置优先级。
784
728
  */
785
729
  declare function sessionPriority(facts: SessionGenerations): SessionPriority;
786
- //#endregion
787
- //#region src/host/health/gates.d.ts
788
730
  /**
789
731
  * gate 严重级。
790
732
  *
@@ -906,8 +848,6 @@ declare function gateLosslessJson(projectionState: Record<string, unknown> | und
906
848
  declare function gateColdRead(facts: TailFacts): GateResult;
907
849
  /** 聚合全部 gate 结果为一份报告。 */
908
850
  declare function buildSessionReport(context: GateContext): SessionHealthReport;
909
- //#endregion
910
- //#region src/host/health/cache.d.ts
911
851
  /** 一份已成型的缓存。 */
912
852
  interface HealthCacheEntry {
913
853
  /** 非 ok 的会话报告(与 `onlyProblems: true` 的扫描结果同构)。 */
@@ -948,692 +888,6 @@ declare class HealthCache {
948
888
  /** 丢弃缓存与未完成的累积。 */
949
889
  clear(): void;
950
890
  }
951
- //#endregion
952
- //#region src/host/index/schema.d.ts
953
- /**
954
- * Which SQLite driver served the handle (better-sqlite3 when the optional
955
- * dependency installed, node:sqlite otherwise). Surfaced in logs and
956
- * index-status so rebuild speed can be compared across drivers.
957
- */
958
- type SwitchSqliteDriver = 'better-sqlite3' | 'node:sqlite';
959
- //#endregion
960
- //#region src/host/index/extract.d.ts
961
- /**
962
- * First-party semantic text extraction for the independent switch-search index.
963
- *
964
- * Semantics mirror the official session-query `extractSessionEventText` and the
965
- * core-session surface fold, mirrored structurally: the plugin must not
966
- * value-import official packages, so the event data is inspected as plain
967
- * records. Structural boundaries, embedded raw streams, request envelopes, and
968
- * unknown declaration-merged events contribute no text.
969
- */
970
- /** One raw session event the plugin reads through sessionQuery.readSession. */
971
- interface SwitchRawEvent {
972
- seq: number;
973
- type: string;
974
- time?: number;
975
- ignorable?: boolean;
976
- surfaceOp?: unknown;
977
- data: unknown;
978
- }
979
- /**
980
- * 从会话事件流里抽出**最后一帧标题**(`session/title` log-only 事件)。
981
- *
982
- * 这是标题的基础层:入索引时随事件白拿,不依赖 readTitleSnapshots(后者
983
- * 对归档 id 可能整批失败——beta.4 标题全军覆没的根因)。数据形状按历史
984
- * 演变兼容三种:`{ title: string }`、`{ title: { title } }`、`{ title: { val } }`。
985
- */
986
- declare function extractTitleFromEvents(events: readonly SwitchRawEvent[]): string;
987
- //#endregion
988
- //#region src/host/index/engine.d.ts
989
- /** One indexed session header row. */
990
- interface SwitchIndexedSession {
991
- sessionId: string;
992
- version: number;
993
- title: string;
994
- cwd: string;
995
- updatedAt: number;
996
- indexedAt: number;
997
- archived: boolean;
998
- }
999
- /** One session-grouped search hit. */
1000
- interface SwitchSearchHit {
1001
- sessionId: string;
1002
- title: string;
1003
- seq: number;
1004
- type: string;
1005
- /** Timestamp of the strongest matching document. Per-hit, not per-session. */
1006
- time: number;
1007
- /**
1008
- * Session-level last-activity timestamp. Distinct from `time`: a session
1009
- * may hold an old best match yet have moved one minute ago. This is the
1010
- * field recency ordering and any client-side re-sort must key on.
1011
- */
1012
- updatedAt: number;
1013
- snippet: string;
1014
- }
1015
- /**
1016
- * Result ordering for one search.
1017
- * - `relevance` (default) — weighted BM25, the historical behaviour.
1018
- * - `time` — session recency first, relevance as the tie-break.
1019
- */
1020
- type SwitchSearchSort = 'relevance' | 'time';
1021
- /** Coarse type-filter buckets mapped onto raw session event types. */
1022
- type SwitchIndexContentType = 'all' | 'user' | 'reply' | 'tool';
1023
- /** Constructor options for one engine instance. */
1024
- interface SwitchIndexEngineOptions {
1025
- /** Absolute path of the index file this engine owns. */
1026
- path: string;
1027
- }
1028
- /** One open index handle. All mutating calls are synchronous; callers pace
1029
- * them off the HTTP hot path (background sync / rebuild tasks). */
1030
- declare class SwitchIndexEngine {
1031
- private readonly options;
1032
- private db;
1033
- private driver;
1034
- private inBatch;
1035
- constructor(options: SwitchIndexEngineOptions);
1036
- /** Which SQLite driver is serving this handle. */
1037
- get driverLabel(): SwitchSqliteDriver;
1038
- /**
1039
- * Run one write inside the current batched transaction, or its own
1040
- * IMMEDIATE transaction when not batching (nested calls join the batch).
1041
- */
1042
- withWriteTx<T>(fn: () => T): T;
1043
- /**
1044
- * Run one function as a single batched transaction (one fsync checkpoint):
1045
- * upserts inside it join via withWriteTx instead of opening their own.
1046
- */
1047
- runBatched<T>(fn: () => T): T;
1048
- /** Whether the handle is open. */
1049
- get isOpen(): boolean;
1050
- /** Open (creating or migrating) the index file. Idempotent. */
1051
- open(): Promise<void>;
1052
- /** Close the handle. Idempotent. */
1053
- close(): void;
1054
- /** Remove one session's FTS entries for external-content bookkeeping. */
1055
- private deleteSessionFts;
1056
- /** Insert or replace one session's documents and header row. */
1057
- upsertSession(input: {
1058
- sessionId: string;
1059
- version: number;
1060
- title?: string;
1061
- cwd?: string;
1062
- updatedAt?: number;
1063
- events: readonly SwitchRawEvent[];
1064
- /**
1065
- * 归档标记。缺省时**保留行上现有值**(归档态翻转由 setArchived 单独负责,
1066
- * 全量重灌不改变归档状态);显式传入时以传入值为准(重建/导入路径)。
1067
- */
1068
- archived?: boolean;
1069
- }): number;
1070
- /**
1071
- * 该会话是否已有正文(issue #1:hollow 行判据)。
1072
- * LIMIT 1 探测命中 docs_session 索引,每轮 poll 对每个未变更会话的开销可忽略。
1073
- */
1074
- hasSessionDocs(sessionId: string): boolean;
1075
- /**
1076
- * 「有表头无正文」的会话 id(升序)—— hollow 体检面。补录后仍 hollow 的行
1077
- * 包含无可索引文本的真空会话(合法终态,见 sync 的 confirmedEmpty 缓存)。
1078
- */
1079
- listHollowSessions(): string[];
1080
- /**
1081
- * `PRAGMA integrity_check` 首行:'ok' 或损坏报告串。swap 后完整性闸门用。
1082
- */
1083
- integrityCheck(): string;
1084
- /**
1085
- * Write an archived session's header row without any document content.
1086
- *
1087
- * @deprecated 旧"归档即软删"语义的遗物,合并包 R1 已改为归档保留 docs;仅剩
1088
- * 旧快照兼容路径可落 header 行。新代码一律 upsertSession + setArchived。
1089
- */
1090
- upsertArchivedHeader(input: {
1091
- sessionId: string;
1092
- version: number;
1093
- title?: string;
1094
- cwd?: string;
1095
- updatedAt?: number;
1096
- }): void;
1097
- /**
1098
- * Apply the official archive set: flip the archived flag both ways.
1099
- *
1100
- * 合表复用语义(R1):归档**保留全部 docs 与 FTS**——正文在归档态不可变
1101
- * (归档门只拒新回合),翻转只是检索域成员资格的变化;恢复也不再需要重灌
1102
- * (旧实现的 version = -1 强制重读随"归档即删 docs"一并废除)。
1103
- */
1104
- setArchived(archivedIds: ReadonlySet<string>): void;
1105
- /**
1106
- * Flip one session's archived flag (steward write-side linkage). No-op when
1107
- * the row does not exist — flag state on an unindexed session is meaningless.
1108
- */
1109
- setArchivedOne(sessionId: string, archived: boolean): void;
1110
- /** One session's stored documents, ascending seq (snapshot export face). */
1111
- exportSessionDocs(sessionId: string): {
1112
- seq: number;
1113
- type: string;
1114
- surface: string;
1115
- time: number;
1116
- text: string;
1117
- }[];
1118
- /**
1119
- * Insert or replace one session from already-extracted documents
1120
- * (snapshot import face; no re-extraction, what was exported is restored;
1121
- * segmentation is recomputed for the current index format).
1122
- */
1123
- importSessionDocs(input: {
1124
- sessionId: string;
1125
- version: number;
1126
- title?: string;
1127
- /** 归档标记随快照往返;旧快照缺省为活跃。 */
1128
- archived?: boolean;
1129
- docs: readonly {
1130
- seq: number;
1131
- type: string;
1132
- surface: string;
1133
- time: number;
1134
- text: string;
1135
- }[];
1136
- }): void;
1137
- /**
1138
- * Insert or replace one session from corpus-source documents (T7.1 DRS
1139
- * 语料源):docs 已由语料源抽好(surface 字符串),切分仍由本引擎重算。
1140
- * 与 importSessionDocs 的三点差异,均为检索排序/水印所需:cwd 与
1141
- * updated_at 直写(日期过滤/时间排序键);标题空串保留旧行(upsertSession
1142
- * 同款 CASE——DRS 对老会话可能给不出标题,不能抹掉既有精修);归档旗标
1143
- * 冲突时不动(翻转仍归 setArchived)。
1144
- * @returns 落库 docs 数(0 = 该会话无可索引文本,合法终态)。
1145
- */
1146
- upsertSessionDocs(input: {
1147
- sessionId: string;
1148
- version: number;
1149
- title?: string;
1150
- cwd?: string;
1151
- updatedAt?: number;
1152
- archived?: boolean;
1153
- docs: readonly {
1154
- seq: number;
1155
- type: string;
1156
- surface: string;
1157
- time: number;
1158
- text: string;
1159
- }[];
1160
- }): number;
1161
- /**
1162
- * 会话头直写(DRS 直连时代的同步轮专用,T7.3):只维护 sessions 元数据
1163
- * (水位/标题/目录/末时间/归档),**不碰 docs/docs_fts**——内容检索
1164
- * 已直连 dsh-reference-session-collector(op=search&group=session),本地正文索引
1165
- * 退役,存量 docs 行自然老化不再新增。空标题保留旧行(同 upsertSessionDocs)。
1166
- */
1167
- upsertSessionHead(input: {
1168
- sessionId: string;
1169
- version: number;
1170
- title?: string;
1171
- cwd?: string;
1172
- updatedAt?: number;
1173
- archived?: boolean;
1174
- }): void;
1175
- /** Remove one session and its documents entirely. */
1176
- removeSession(sessionId: string): void;
1177
- /** Update only a session's header row (title backfill), keeping documents. */
1178
- updateSessionHeader(input: {
1179
- sessionId: string;
1180
- title?: string;
1181
- cwd?: string;
1182
- updatedAt?: number;
1183
- }): void;
1184
- /** One indexed session row, or undefined. */
1185
- getSession(sessionId: string): SwitchIndexedSession | undefined;
1186
- /** All indexed sessions (active AND archived), newest first — the title
1187
- * corpus and the manage console both read this; the `archived` flag rides
1188
- * each row so clients filter locally. */
1189
- listIndexedSessions(): SwitchIndexedSession[];
1190
- /** Archived (soft-deleted) sessions, newest first — the archive viewer face. */
1191
- listArchived(): SwitchIndexedSession[];
1192
- /** Number of indexed sessions (active + archived — the whole corpus). */
1193
- countSessions(): number;
1194
- /** Number of archived (soft-deleted) sessions. */
1195
- countArchived(): number;
1196
- /**
1197
- * Run one session-grouped full-text search.
1198
- *
1199
- * One statement: the FTS match is bounded by rank in a subquery (its rowid
1200
- * aligns with docs.doc_id), then the type/surface filters join in — no
1201
- * second round-trip, no large IN parameter lists.
1202
- * @param request - query text, coarse type filter, page size, ordering.
1203
- * @returns hits ordered by `sortBy` (relevance by default).
1204
- */
1205
- search(request: {
1206
- query: string;
1207
- types?: readonly SwitchIndexContentType[];
1208
- limit?: number;
1209
- sortBy?: SwitchSearchSort;
1210
- /**
1211
- * 检索域:`'active'` 仅活跃、`'archived'` 仅归档、`'all'`(缺省)两者。
1212
- * 归档正文入索引后的筛选 chip 即此参数。
1213
- */
1214
- archived?: 'active' | 'archived' | 'all';
1215
- /** 更新时间下界(epoch ms,含)。 */
1216
- from?: number;
1217
- /** 更新时间上界(epoch ms,排他)。 */
1218
- to?: number;
1219
- }): SwitchSearchHit[];
1220
- private requireDb;
1221
- }
1222
- //#endregion
1223
- //#region src/host/index/sync.d.ts
1224
- /** The sessionQuery faces the sync reads (structural mirrors). */
1225
- interface SwitchSyncSessionQuery {
1226
- listSessions(): Promise<readonly {
1227
- header: {
1228
- id: string;
1229
- version: number;
1230
- createdAt?: number;
1231
- cwd?: string;
1232
- };
1233
- }[]>;
1234
- readSession(sessionId: string): Promise<{
1235
- session: {
1236
- id: string;
1237
- version: number;
1238
- createdAt?: number;
1239
- cwd?: string;
1240
- };
1241
- events: readonly SwitchRawEvent[];
1242
- }>;
1243
- readTitleSnapshots?(sessionIds: readonly string[]): Promise<readonly {
1244
- status: 'fulfilled' | 'rejected';
1245
- value?: {
1246
- session: {
1247
- id: string;
1248
- };
1249
- title?: {
1250
- title: string;
1251
- };
1252
- };
1253
- }[]>;
1254
- }
1255
- /** Live sync progress reported to the status endpoint. */
1256
- interface SwitchSyncState {
1257
- /** What the syncer is doing right now. */
1258
- state: 'idle' | 'syncing' | 'error';
1259
- /** Epoch ms of the last completed pass. */
1260
- lastSyncAt: number;
1261
- /** Sessions currently in the index. */
1262
- indexed: number;
1263
- /** Sessions seen in the corpus at the last pass. */
1264
- total: number;
1265
- /** Sessions re-read in the last pass. */
1266
- updated: number;
1267
- /** Per-session failures from the last pass. */
1268
- failures: {
1269
- sessionId: string;
1270
- error: string;
1271
- }[];
1272
- /** 补录后仍「有表头无正文」的行数(hollow 体检面,含合法真空会话)。 */
1273
- hollow: number;
1274
- /** Last pass error (whole-pass abort), if any. */
1275
- error?: string;
1276
- }
1277
- /**
1278
- * The official archive-set face (workspaceRegistry mirror): read-only.
1279
- * Resolved lazily per pass — the registry may mount after this plugin.
1280
- */
1281
- interface SwitchArchiveSource {
1282
- readonly archivedSessionIds: readonly string[];
1283
- }
1284
- /** DRS 语料头(依赖倒置端口;真身 = drs-source.ts 的 DrsCorpusSource)。 */
1285
- interface SwitchDrsCorpusHead {
1286
- sessionId: string;
1287
- /** 水位代理 = DRS sessions.artifact_mtime_ms(日志重写必 bump)。 */
1288
- version: number;
1289
- title: string;
1290
- cwd: string;
1291
- updatedAt: number;
1292
- archived: boolean;
1293
- }
1294
- /** DRS 检索臂文档(surface 已折算引擎字符串域;切分由引擎重算)。 */
1295
- interface SwitchDrsCorpusDoc {
1296
- seq: number;
1297
- type: string;
1298
- surface: string;
1299
- time: number;
1300
- text: string;
1301
- }
1302
- /**
1303
- * DRS 语料源端口(T7.1):corpusSource='drs' 时语料改从
1304
- * dsh-reference-session-collector 投影库取,docs 直插引擎;不可达时整轮回退原生
1305
- * sessionQuery + 文件兜底链路。单测注入普通对象。
1306
- */
1307
- interface SwitchDrsCorpusSource {
1308
- listSessions(): Promise<readonly SwitchDrsCorpusHead[]>;
1309
- readSession(sessionId: string): Promise<{
1310
- head: SwitchDrsCorpusHead;
1311
- docs: readonly SwitchDrsCorpusDoc[];
1312
- } | undefined>;
1313
- }
1314
- /**
1315
- * One watermark syncer bound to one open engine. `poll()` is re-entrant-safe:
1316
- * overlapping calls collapse into the running pass.
1317
- */
1318
- declare class SwitchWatermarkSync {
1319
- private readonly engine;
1320
- private readonly sessionQuery;
1321
- private readonly readArchiveSource?;
1322
- private readonly log?;
1323
- private readonly readSessionFromFile?;
1324
- /**
1325
- * 第三标题源(可选):官方投影缓存里的 title 行。事件流没有 session/title
1326
- * 的老会话,快照服务又整片不可用时,这是最后兜底。
1327
- */
1328
- private readonly readProjectionTitle?;
1329
- /**
1330
- * DRS 语料源(可选,T7.1):提供时每轮先走 DRS 轮(docs 直插);DRS 整轮
1331
- * 失败(网络/路由/包络)自动回退原生 sessionQuery + 文件兜底。
1332
- */
1333
- private readonly drsSource?;
1334
- private running;
1335
- /**
1336
- * 本进程已确认「重读过且产出仍为 0 docs」的会话(键 id@version)。
1337
- * 无可索引文本是合法终态——没有这份缓存,hollow 补录判据会把真空会话
1338
- * 每轮完整重读一次(热循环)。宿主重启后缓存归零,最多各重读一次。
1339
- */
1340
- private readonly confirmedEmpty;
1341
- private static emptyKey;
1342
- private readonly state;
1343
- /**
1344
- * @param readSessionFromFile - 可选的**文件级兜底读取器**(管家 health 侧的
1345
- * 多帧 zstd 读取器):sessionQuery.readSession 对某些会话(典型:归档会话,
1346
- * 或服务面退化)失败时改读转录文件。返回 undefined 表示文件也不可用。
1347
- */
1348
- constructor(engine: SwitchIndexEngine, sessionQuery: SwitchSyncSessionQuery, readArchiveSource?: (() => SwitchArchiveSource | undefined) | undefined, log?: ((msg: string) => void) | undefined, readSessionFromFile?: ((sessionId: string) => Promise<{
1349
- session: {
1350
- id: string;
1351
- version: number;
1352
- createdAt?: number;
1353
- cwd?: string;
1354
- };
1355
- events: readonly SwitchRawEvent[];
1356
- } | undefined>) | undefined,
1357
- /**
1358
- * 第三标题源(可选):官方投影缓存里的 title 行。事件流没有 session/title
1359
- * 的老会话,快照服务又整片不可用时,这是最后兜底。
1360
- */
1361
- readProjectionTitle?: ((sessionId: string) => string) | undefined,
1362
- /**
1363
- * DRS 语料源(可选,T7.1):提供时每轮先走 DRS 轮(docs 直插);DRS 整轮
1364
- * 失败(网络/路由/包络)自动回退原生 sessionQuery + 文件兜底。
1365
- */
1366
- drsSource?: SwitchDrsCorpusSource | undefined);
1367
- /**
1368
- * 读取一个会话的日志:服务面优先,失败落文件兜底。两条路都失败时抛最后
1369
- * 一个错误,由调用方按会话隔离记失败。
1370
- */
1371
- private readSessionLog;
1372
- /** Current progress snapshot (cloned). */
1373
- snapshot(): SwitchSyncState;
1374
- /**
1375
- * Fold titles for an explicit id set without running a full pass.
1376
- *
1377
- * Used by the `session/title` event listener so a rename lands immediately
1378
- * rather than at the next poll. It deliberately leaves watermarks alone: a
1379
- * title-only refresh can never make the index claim content it has not read,
1380
- * and the next poll still re-ingests the session off its bumped version.
1381
- * Safe for unknown ids — the header write is a no-op when no row exists.
1382
- * @param sessionIds - sessions whose titles should be re-folded.
1383
- */
1384
- refreshTitles(sessionIds: readonly string[]): Promise<void>;
1385
- /**
1386
- * Run one incremental pass (or await the running one).
1387
- * @returns the state after the pass completes.
1388
- */
1389
- poll(): Promise<SwitchSyncState>;
1390
- private runPass;
1391
- /**
1392
- * DRS 语料轮(T7.1):语料头从 DRS `op=sessions` 分页拉取,水位
1393
- * diff(version=artifact_mtime_ms)后按会话 `op=session&fields=search`
1394
- * 取检索臂 docs 直插引擎(upsertSessionDocs)。归档集合改用 DRS 行的
1395
- * archived 旗标(DRS sync 本就只读跟随 workspace.json,同源);标题直接
1396
- * 采 DRS 行(投影侧同一 extractTitleFromEvents 视界),不再走快照精修。
1397
- * 每会话失败隔离语义与原生轮一致;无可索引文本仍进 confirmedEmpty 缓存。
1398
- */
1399
- private runDrsPass;
1400
- /**
1401
- * Fold latest titles for changed sessions into the index header rows.
1402
- *
1403
- * beta.4 教训:整批一次调用,任何一个坏 id(典型:归档 id)让整个 promise
1404
- * reject,catch 一吞就是**全部**标题丢失。改为分块 + 块失败时逐 id 重试 ——
1405
- * 单点坏 id 最多损失它自己的精修标题(入索引时的 extractTitleFromEvents
1406
- * 基础层仍然在)。
1407
- */
1408
- private backfillTitles;
1409
- }
1410
- //#endregion
1411
- //#region src/host/index/archive-source.d.ts
1412
- /** One resolved archive read: ids plus which source served them. */
1413
- interface SwitchArchiveRead {
1414
- ids: readonly string[];
1415
- source: 'registry' | 'storage-file' | 'none';
1416
- }
1417
- /** The workspaceRegistry mirror face (getter only). */
1418
- interface SwitchRegistryFace {
1419
- readonly archivedSessionIds: readonly string[];
1420
- }
1421
- /** Diagnostics describing how the archive set is being resolved. */
1422
- interface SwitchArchiveDiagnostics {
1423
- source: 'registry' | 'storage-file' | 'none';
1424
- ids: number;
1425
- error?: string;
1426
- }
1427
- /** Build the lazy source face the syncer expects, with diagnostics capture. */
1428
- declare function createArchiveSource(getRegistry: () => SwitchRegistryFace | undefined): {
1429
- read: () => SwitchArchiveRead;
1430
- diagnostics: () => SwitchArchiveDiagnostics;
1431
- };
1432
- //#endregion
1433
- //#region src/host/index/drs-source.d.ts
1434
- /** 一个 DRS 会话头(watermark 代理 + 检索排序字段)。 */
1435
- interface DrsCorpusHead {
1436
- sessionId: string;
1437
- version: number;
1438
- title: string;
1439
- cwd: string;
1440
- updatedAt: number;
1441
- archived: boolean;
1442
- }
1443
- /** 一个 DRS 检索臂文档(surface 已折算成引擎列的字符串域)。 */
1444
- interface DrsCorpusDoc {
1445
- seq: number;
1446
- type: string;
1447
- surface: 'current' | 'shadowed';
1448
- time: number;
1449
- text: string;
1450
- }
1451
- /** 一个 DRS 会话的完整语料(头 + docs)。 */
1452
- interface DrsCorpusSession {
1453
- head: DrsCorpusHead;
1454
- docs: DrsCorpusDoc[];
1455
- }
1456
- interface DrsCorpusSourceOptions {
1457
- /** DRS API 基址(http://host[:port];解析序见 resolveDrsBaseUrl)。 */
1458
- baseUrl: string;
1459
- /** 注入面(单测);缺省全局 fetch。 */
1460
- fetchImpl?: typeof fetch;
1461
- /** 显式 Host 头(trustedHosts 首条回显;缺省不覆盖)。 */
1462
- hostHeader?: string;
1463
- log?: (message: string) => void;
1464
- }
1465
- declare class DrsCorpusSource {
1466
- private readonly options;
1467
- private readonly fetchImpl;
1468
- constructor(options: DrsCorpusSourceOptions);
1469
- /** 一个 GET 的 JSON 包络(ok!==true 或非 2xx 一律抛,由调用方回退 native)。 */
1470
- private getJson;
1471
- private static headOf;
1472
- /** 全量语料头(内部翻页;rows 空或凑满 total 即止)。 */
1473
- listSessions(): Promise<DrsCorpusHead[]>;
1474
- /** 一个会话的检索臂 docs;DRS 无此会话(session:null)返回 undefined。 */
1475
- readSession(sessionId: string): Promise<DrsCorpusSession | undefined>;
1476
- /**
1477
- * 分组内容搜索直连臂(op=search&group=session,DRS surface.searchGrouped 同构):
1478
- * 会话分组/加权/过滤/锚定节选全部在 DRS 侧完成,本方法只搬 wire →
1479
- * 引擎命中形状(SwitchSearchHit 字段同名)。失败(网络/非 2xx/包络)直抛,
1480
- * 调用侧按硬依赖语义显式报错——**不回退本地索引**。
1481
- */
1482
- searchGrouped(request: {
1483
- query: string;
1484
- /** 原事件 type 列表(调用方展开粗类);空=DRS 缺省 user+assistant。 */
1485
- kinds?: readonly string[];
1486
- archived?: 'active' | 'archived' | 'all';
1487
- from?: number;
1488
- to?: number;
1489
- sortBy?: 'relevance' | 'time';
1490
- limit?: number;
1491
- /** 命中展开(wire `expand=1`):同会话多命中各自成行;缺省聚合。 */
1492
- expand?: boolean;
1493
- /** 同源 Host 覆盖(转发调用方请求头;优先于装配 baseUrl)。 */
1494
- atHost?: string;
1495
- }): Promise<{
1496
- sessionId: string;
1497
- title: string;
1498
- seq: number;
1499
- type: string;
1500
- time: number;
1501
- updatedAt: number;
1502
- snippet: string;
1503
- }[]>;
1504
- /** 可性探针(op=status):硬依赖预检/降级提示用;失败返回 false。 */
1505
- probe(atHost?: string): Promise<boolean>;
1506
- }
1507
- //#endregion
1508
- //#region src/host/index/rebuild.d.ts
1509
- /** The corpus reader a rebuild needs (same faces as the syncer). */
1510
- interface SwitchRebuildSessionQuery {
1511
- listSessions(): Promise<readonly {
1512
- header: {
1513
- id: string;
1514
- version: number;
1515
- createdAt?: number;
1516
- cwd?: string;
1517
- };
1518
- }[]>;
1519
- readSession(sessionId: string): Promise<{
1520
- session: {
1521
- id: string;
1522
- version: number;
1523
- createdAt?: number;
1524
- cwd?: string;
1525
- };
1526
- events: readonly SwitchRawEvent[];
1527
- }>;
1528
- }
1529
- /** Live rebuild progress reported to the status endpoint. */
1530
- interface SwitchRebuildState {
1531
- state: 'idle' | 'building' | 'swapping' | 'error';
1532
- /** Sessions written into the shadow index so far. */
1533
- done: number;
1534
- /** Sessions seen in the corpus when the build started. */
1535
- total: number;
1536
- /** Epoch ms when the build started. */
1537
- startedAt: number;
1538
- /** Epoch ms when the last build finished. */
1539
- finishedAt: number;
1540
- /** Per-session failures during the last build. */
1541
- failures: {
1542
- sessionId: string;
1543
- error: string;
1544
- }[];
1545
- error?: string;
1546
- }
1547
- /** Filesystem layout of one index directory. */
1548
- interface SwitchIndexLayout {
1549
- /** Directory holding every index file. */
1550
- dir: string;
1551
- /** Active index file name. */
1552
- active: string;
1553
- /** Shadow file name used while building. */
1554
- building: string;
1555
- /** Archive file name prefix. */
1556
- archivePrefix: string;
1557
- }
1558
- /** Default layout names. */
1559
- declare const DEFAULT_INDEX_LAYOUT: SwitchIndexLayout;
1560
- /**
1561
- * Inspect the index directory for half-built leftovers from an abnormally
1562
- * terminated rebuild and recover:
1563
- * - shadow present + active present: the build never finished — the shadow
1564
- * is garbage (the active index kept serving) and is discarded.
1565
- * - shadow present + active missing: the crash hit the rename window — the
1566
- * newest archive is restored as the active index, the shadow discarded.
1567
- * Runs at host activation, before the engine opens (opening would create a
1568
- * fresh empty active file and mask the swap-window case).
1569
- */
1570
- declare function recoverIndex(layout: SwitchIndexLayout, log?: (msg: string) => void): Promise<string[]>;
1571
- /**
1572
- * Build a fresh index into the shadow file, then swap it in atomically.
1573
- *
1574
- * During the build the caller's active engine stays open and queryable; only
1575
- * the final swap briefly reopens the handle.
1576
- * @param activeEngine - the currently-serving engine (its file is replaced).
1577
- * @param layout - filesystem layout of the index directory.
1578
- * @param sessionQuery - corpus reader for the full rebuild.
1579
- * @param keepArchives - how many archive files to retain (oldest pruned).
1580
- * @param onProgress - optional progress callback after each session.
1581
- * @returns the rebuild state snapshot after completion.
1582
- */
1583
- /** Optional observability callbacks for rebuildIndex. */
1584
- interface SwitchRebuildHooks {
1585
- /** Progress log line sink (cordis logger bridge). */
1586
- log?: (msg: string) => void;
1587
- /** State-mutation sink: called after every change so index-status sees
1588
- * live progress (the "0/?" bug was state cloned only at completion). */
1589
- onState?: (state: SwitchRebuildState) => void;
1590
- /**
1591
- * 文件级兜底读取器(与同步器同语义):readSession 对归档/服务面退化会话
1592
- * 失败时改读转录文件;返回 undefined 表示文件也不可用(记失败)。
1593
- */
1594
- readSessionFromFile?: (sessionId: string) => Promise<{
1595
- session: {
1596
- id: string;
1597
- version: number;
1598
- createdAt?: number;
1599
- cwd?: string;
1600
- };
1601
- events: readonly SwitchRawEvent[];
1602
- } | undefined>;
1603
- }
1604
- /**
1605
- * The swap window: synchronous renames only; queries fail only inside it.
1606
- *
1607
- * issue #1 评论的损坏根因:只搬主文件时,旧库残留的 -wal/-shm 会被同名顶替
1608
- * 的新库当自己的 WAL 重放,页号错配 → malformed。因此 sidecar 必须随主文件
1609
- * 一并迁 archive(干净 close 本会 checkpoint 自删,这里是异常关闭的兜底)。
1610
- * swap 后跑 integrity_check:非 ok 则把损坏库改名 .corrupt、从刚落的 archive
1611
- * 回滚重开,并抛错让调用方置 error(把「索引损坏」降级为「回到上次快照」)。
1612
- * 导出供测试直接驱动 swap 窗口(多连接场景在 Windows 上 rename 必 EBUSY,
1613
- * 无法经 rebuildIndex 全链路确定性复现)。
1614
- */
1615
- declare function swapShadowIntoActive(activeEngine: SwitchIndexEngine, layout: SwitchIndexLayout, log?: (msg: string) => void): Promise<void>;
1616
- declare function rebuildIndex(activeEngine: SwitchIndexEngine, layout: SwitchIndexLayout, sessionQuery: SwitchRebuildSessionQuery, keepArchives: number, onProgress?: (done: number, total: number) => void, archiveSource?: () => SwitchArchiveSource | undefined, hooks?: SwitchRebuildHooks): Promise<SwitchRebuildState>;
1617
- /** One doc-level record the snapshot importer feeds in. */
1618
- interface SwitchImportRecord {
1619
- sessionId: string;
1620
- version: number;
1621
- title?: string;
1622
- /** 归档标记(旧快照缺省活跃)。 */
1623
- archived?: boolean;
1624
- docs: readonly {
1625
- seq: number;
1626
- type: string;
1627
- surface: string;
1628
- time: number;
1629
- text: string;
1630
- }[];
1631
- }
1632
- /** Import doc-level records into the shadow file and swap it in (same swap path).
1633
- * @param log - 可选日志汇(空 docs 记录告警,issue #1 写入侧可观测)。 */
1634
- declare function importIntoIndex(activeEngine: SwitchIndexEngine, layout: SwitchIndexLayout, records: readonly SwitchImportRecord[], keepArchives: number, log?: (msg: string) => void): Promise<SwitchRebuildState>;
1635
- //#endregion
1636
- //#region src/host/history/archive.d.ts
1637
891
  /** 一行历史文件条目(尽力而为的元数据 + 磁盘占用)。 */
1638
892
  interface StewardHistoryRow {
1639
893
  sessionId: string;
@@ -1720,8 +974,6 @@ interface StewardHistoryArchiveResult {
1720
974
  * @param searchPaths - 可选候选路径覆盖(测试注入用)。
1721
975
  */
1722
976
  declare function archiveHistory(payload: unknown, log?: (msg: string) => void, searchPaths?: readonly string[]): StewardHistoryArchiveResult;
1723
- //#endregion
1724
- //#region src/host/history/purge.d.ts
1725
977
  /** 一个归档会话在磁盘上的实体与占用。 */
1726
978
  interface StewardSessionUsage {
1727
979
  sessionId: string;
@@ -1823,8 +1075,6 @@ interface StewardPurgeOptions {
1823
1075
  * @returns 清理条数、释放字节数与逐条失败。
1824
1076
  */
1825
1077
  declare function purgeHistory(payload: unknown, log?: (msg: string) => void, options?: StewardPurgeOptions): StewardHistoryPurgeResult;
1826
- //#endregion
1827
- //#region src/host/health/source-kind.d.ts
1828
1078
  /** v4 线起点的宿主版本(会话格式 v4 引入 producer-owned source kind)。 */
1829
1079
  declare const V4_HOST_MIN = "0.1.7-rc.1";
1830
1080
  /** 一份日志里的旧署名事实。 */
@@ -1905,8 +1155,6 @@ declare function migrateLegacySource(source: unknown): Record<string, unknown> |
1905
1155
  declare function migrateSessionSourceKind(sessionId: string, logPath: string, log: SessionLogRead, dshHome?: string, now?: () => number): SourceKindMigrationOutcome;
1906
1156
  /** 备份文件的后缀约定(purge/清理工具可据此识别并一并处置)。 */
1907
1157
  declare const SOURCE_MIGRATE_BACKUP_SUFFIX = ".pre-sourcemigrate-";
1908
- //#endregion
1909
- //#region src/host/health/lossless.d.ts
1910
1158
  /**
1911
1159
  * 无损 JSON 判定 —— 本次事故的核心 gate 判据。
1912
1160
  *
@@ -1935,8 +1183,6 @@ declare function isLossless(value: unknown): boolean;
1935
1183
  * @returns 首个违规点位或 undefined。
1936
1184
  */
1937
1185
  declare function firstLosslessViolation(value: unknown, limit?: number): LosslessViolation | undefined;
1938
- //#endregion
1939
- //#region src/host/health/attribution.d.ts
1940
1186
  /** 一条归属记录。 */
1941
1187
  interface ProjectionOwner {
1942
1188
  key: string;
@@ -1955,8 +1201,6 @@ interface ProjectionOwner {
1955
1201
  declare function buildProjectionOwnerIndex(nodeModulesRoot: string): ProjectionOwner[];
1956
1202
  /** 索引查询器。 */
1957
1203
  declare function createAttributor(index: readonly ProjectionOwner[]): (projection: string) => GateAttribution | undefined;
1958
- //#endregion
1959
- //#region src/host/health/repair.d.ts
1960
1204
  /** 可逆处置的结果。 */
1961
1205
  interface RepairOutcome {
1962
1206
  ok: boolean;
@@ -2022,8 +1266,6 @@ declare function assessRepair(input: {
2022
1266
  after: SessionHealthReport;
2023
1267
  repair: RepairOutcome;
2024
1268
  }): RepairAssessment;
2025
- //#endregion
2026
- //#region src/host/health/scan.d.ts
2027
1269
  /** 一个已发现的会话。 */
2028
1270
  interface DiscoveredSession {
2029
1271
  sessionId: string;
@@ -2108,56 +1350,6 @@ declare function scanSessions(options: {
2108
1350
  projectionStateFor?: (sessionId: string) => Record<string, unknown> | undefined;
2109
1351
  now?: () => number;
2110
1352
  }): HealthScanResult;
2111
- //#endregion
2112
- //#region src/host/index/snapshot.d.ts
2113
- /**
2114
- * Export the whole index (active AND archived) as a JSON Lines string.
2115
- * 归档行带 archived 标记一起导出——快照是完整备份,不是活跃子集。
2116
- * @param engine - the open active engine.
2117
- * @returns the complete snapshot text (header line first).
2118
- */
2119
- declare function exportSnapshot(engine: SwitchIndexEngine): string;
2120
- /** One parsed snapshot: importable records plus skipped-line count. */
2121
- interface SwitchParsedSnapshot {
2122
- records: SwitchImportRecord[];
2123
- skipped: number;
2124
- }
2125
- /**
2126
- * Parse a snapshot's JSON Lines text into importable records.
2127
- * The header line and any malformed line are skipped, not fatal.
2128
- * @param text - raw snapshot text.
2129
- * @returns importable records and how many lines were skipped.
2130
- */
2131
- declare function parseSnapshot(text: string): SwitchParsedSnapshot;
2132
- //#endregion
2133
- //#region src/host/index/peers.d.ts
2134
- /** Resolution outcome for a peer plugin package. */
2135
- type PeerPresence = 'installed' | 'missing' | 'unknown';
2136
- /**
2137
- * Probe whether a package resolves from this plugin's own module graph.
2138
- *
2139
- * The bundle lives at `<profile>/node_modules/dsh-search-index/lib/index.mjs`,
2140
- * so resolution runs against `<profile>/node_modules` — exactly where a
2141
- * profile dependency lands, and therefore the same place the host would load
2142
- * the peer from.
2143
- *
2144
- * @param name - the package name to resolve.
2145
- * @param base - resolution base; defaults to this module's own URL, i.e. the
2146
- * plugin's install directory. Injectable so the classification can be tested
2147
- * against a fixture that fails in a way this checkout cannot produce.
2148
- * @returns `installed` when it resolves; `missing` only for a genuine
2149
- * module-not-found; `unknown` for every other failure, because an
2150
- * unanswerable probe is not evidence of absence.
2151
- */
2152
- declare function probePeer(name: string, base?: string): PeerPresence;
2153
- /**
2154
- * Probe whether {@link STEWARD_PACKAGE} is installed alongside this plugin.
2155
- *
2156
- * @returns the resolution state, never a throw.
2157
- */
2158
- declare function detectSteward(): PeerPresence;
2159
- //#endregion
2160
- //#region src/index.d.ts
2161
1353
  /** 本插件声明的宿主服务(与 toggle 相同的注入面)。0.2.1-a.2 起 webRuntime 更名 webStartup,读取面走双名回退链。 */
2162
1354
  declare const inject: string[];
2163
1355
  /** 运行时配置 schema(与 src/config.ts 的形状保持一致)。0.1.7+:volatile 字段即设置表单。 */
@@ -2165,28 +1357,12 @@ declare const Config: z<Schemastery.ObjectS<NoInfer<{
2165
1357
  enabled: z<boolean, boolean, "defined">;
2166
1358
  historyFiles: z<boolean, boolean, "defined">;
2167
1359
  healthCheck: z<boolean, boolean, "defined">;
2168
- search: z<boolean, boolean, "defined">;
2169
1360
  directDelete: z<boolean, boolean, "defined">;
2170
- defaultMode: z<"title" | "content", "title" | "content", "defined">;
2171
- autoSync: z<boolean, boolean, "defined">;
2172
- syncIntervalMs: z<number, number, "defined">;
2173
- archiveKeep: z<number, number, "defined">;
2174
- indexDir: z<string, string, "defined">;
2175
- corpusSource: z<"native" | "drs", "native" | "drs", "defined">;
2176
- drsBaseUrl: z<string, string, "defined">;
2177
1361
  }>>, Schemastery.ObjectT<NoInfer<{
2178
1362
  enabled: z<boolean, boolean, "defined">;
2179
1363
  historyFiles: z<boolean, boolean, "defined">;
2180
1364
  healthCheck: z<boolean, boolean, "defined">;
2181
- search: z<boolean, boolean, "defined">;
2182
1365
  directDelete: z<boolean, boolean, "defined">;
2183
- defaultMode: z<"title" | "content", "title" | "content", "defined">;
2184
- autoSync: z<boolean, boolean, "defined">;
2185
- syncIntervalMs: z<number, number, "defined">;
2186
- archiveKeep: z<number, number, "defined">;
2187
- indexDir: z<string, string, "defined">;
2188
- corpusSource: z<"native" | "drs", "native" | "drs", "defined">;
2189
- drsBaseUrl: z<string, string, "defined">;
2190
1366
  }>>, "plain">;
2191
1367
  /** 运行时依赖。 */
2192
1368
  interface StewardRuntime {
@@ -2200,6 +1376,10 @@ interface StewardRuntime {
2200
1376
  field?: string;
2201
1377
  } | undefined;
2202
1378
  log: (message: string) => void;
1379
+ /**
1380
+ * 管理台语料来源(宿主 `sessionQuery`;可选:缺席时 `session-catalog` 显式报错)。
1381
+ */
1382
+ sessionQuery?: SwitchSessionQuery;
2203
1383
  /**
2204
1384
  * 体检结果缓存(进程内,随 fiber 存活)。
2205
1385
  *
@@ -2212,23 +1392,6 @@ interface StewardRuntime {
2212
1392
  * 租约。缺省(单测/modern 宿主)= describe 回空投影、mutate 显式拒绝。
2213
1393
  */
2214
1394
  settingsBridge?: BridgeState;
2215
- /**
2216
- * 搜索索引联动钩子(可选):管家写侧操作成功后同步翻索引的归档标记 /
2217
- * 删除索引行,消灭"搜索还挂着 30s 前的幽灵"的窗口。缺省(单测/降级)为无联动。
2218
- */
2219
- index?: {
2220
- /** 批量归档成功 → 翻 archived=true。 */
2221
- onArchive: (sessionIds: readonly string[]) => void;
2222
- /** 取消归档成功 → 翻 archived=false。 */
2223
- onUnarchive: (sessionIds: readonly string[]) => void;
2224
- /** 清理成功(物理删除)→ 索引行整个移除。 */
2225
- onPurged: (sessionIds: readonly string[]) => void;
2226
- };
2227
- /**
2228
- * 退场墓碑台账目录(可选):purge 成功后追加 retired-tombstones.jsonl。
2229
- * 缺省 = ~/.dsh-switch-search(单测注入临时目录隔离真实家目录)。
2230
- */
2231
- tombstoneDir?: () => string;
2232
1395
  }
2233
1396
  /**
2234
1397
  * 支持的路由方法(按子域分组;用于对外声明与测试断言)。
@@ -2238,11 +1401,9 @@ interface StewardRuntime {
2238
1401
  */
2239
1402
  declare const HISTORY_METHODS: readonly ["session-history-list", "session-history-archive", "session-history-prune", "session-history-purge", "session-history-favorites-list", "session-history-favorite-set"];
2240
1403
  declare const HEALTH_METHODS: readonly ["session-health-status", "session-health-scan", "session-health-session", "session-health-repair", "session-health-source-migrate"];
2241
- /** 搜索索引子域方法(`/switch-search/api`;index-export/import 走原始体,其余 JSON)。 */
2242
- declare const INDEX_METHODS: readonly ["list-sessions", "content-search", "search-status", "index-status", "index-rebuild", "index-export", "index-import"];
2243
1404
  /** 依据开关判定某方法是否启用。 */
2244
1405
  declare function methodEnabled(method: string, config: Required<StewardConfig>): boolean;
2245
- /** ------------------------------------------------------------------ 搜索子域 handlers */
1406
+ /** ------------------------------------------------------------------ 会话语料结构镜像 */
2246
1407
  /**
2247
1408
  * One session header shape the query service returns (structural subset).
2248
1409
  */
@@ -2273,72 +1434,20 @@ interface SwitchTitleObservationResult {
2273
1434
  };
2274
1435
  reason?: unknown;
2275
1436
  }
2276
- /** The session-query service face: corpus reads, title folding, FTS5 search. */
1437
+ /** The session-query service face used by the manage console catalog. */
2277
1438
  interface SwitchSessionQuery {
2278
1439
  listSessions(signal?: AbortSignal): Promise<readonly SwitchSessionRecord[]>;
2279
1440
  readSession?(sessionId: string): Promise<{
2280
1441
  session: SwitchSessionHeader;
2281
- events: readonly SwitchRawEvent[];
1442
+ events: readonly unknown[];
2282
1443
  }>;
2283
1444
  readTitleSnapshots(sessionIds: readonly string[], signal?: AbortSignal): Promise<readonly SwitchTitleObservationResult[]>;
2284
- searchSessions?(request: {
2285
- query: string;
2286
- eventFilters?: readonly unknown[];
2287
- limit?: number;
2288
- }, exec?: {
2289
- signal?: AbortSignal;
2290
- }): Promise<{
2291
- items: readonly unknown[];
2292
- nextCursor?: string;
2293
- }>;
2294
- }
2295
- /** ------------------------------------------------------------------ index service */
2296
- /** The per-activation index service state, carried in the apply closure. */
2297
- interface SwitchIndexServiceState {
2298
- engine: SwitchIndexEngine;
2299
- sync: SwitchWatermarkSync;
2300
- layout: SwitchIndexLayout;
2301
- rebuild: SwitchRebuildState;
2302
- /** Official archive-set reader (registry first, storage-hub file fallback). */
2303
- archiveReader: ReturnType<typeof createArchiveSource>;
2304
- }
2305
- /**
2306
- * Everything the search handlers need, captured from the apply closure: the
2307
- * optional live sessionQuery, the index service state, and the latest config.
2308
- * Handlers never touch the cordis context — arbitrary property writes on a
2309
- * Context are rejected ("cannot set property ... without provide").
2310
- */
2311
- interface SearchRuntime {
2312
- sessionQuery: SwitchSessionQuery | undefined;
2313
- index: SwitchIndexServiceState;
2314
- /** DRS 直连客户端(T7.3 硬依赖:内容分组检索臂唯一来源 + 可性探针)。 */
2315
- drsSource: DrsCorpusSource;
2316
- config: () => Required<StewardConfig> & SwitchSearchConfig;
2317
- /** Lazy official archive-set source (registry first, file fallback). */
2318
- registry: () => {
2319
- archivedSessionIds: readonly string[];
2320
- };
2321
- /** Cordis logger bridge ([session-steward] prefixed). */
2322
- log: (msg: string) => void;
2323
- /** 文件级兜底读取器(重建钩子透传;见 SwitchWatermarkSync 注释)。 */
2324
- readSessionFromFile: (sessionId: string) => Promise<{
2325
- session: {
2326
- id: string;
2327
- version: number;
2328
- createdAt?: number;
2329
- cwd?: string;
2330
- };
2331
- events: readonly SwitchRawEvent[];
2332
- } | undefined>;
2333
1445
  }
2334
- /** JSON 面的搜索子域方法分发(index-export/import 走原始体,在路由层特判)。 */
2335
- declare function handleIndexMethod(method: string, payload: unknown, srt: SearchRuntime, requestHost?: string): Promise<unknown>;
2336
1446
  declare function handleMethod(method: string, payload: unknown, runtime: StewardRuntime): Promise<unknown>;
2337
1447
  /**
2338
1448
  * 插件主体:装配运行时、挂载两条 fenced 路由与索引生命周期。
2339
1449
  * @param ctx - host 插件上下文(webServer / webStartup(旧名 webRuntime)/ 可选 sessionQuery、workspaceRegistry)。
2340
1450
  * @param config - 组合条目(0.1.7:`.volatile()` 字段为 live ref)。
2341
1451
  */
2342
- declare function apply(ctx: Context, config?: Partial<StewardConfig & SwitchSearchConfig>): void;
2343
- //#endregion
2344
- export { Config, DEFAULT_CONFIG, DEFAULT_INDEX_LAYOUT, type DiscoveredSession, type GenerationArtifact, HEALTH_METHODS, HISTORY_METHODS, HealthCache, type HealthCacheEntry, INDEX_METHODS, type LogArtifact, type LogCompression, type RepairAssessment, type RepairVerdict, SOURCE_MIGRATE_BACKUP_SUFFIX, STEWARD_API_PREFIX, STEWARD_SETTINGS_NAMESPACE, SWITCH_API_PREFIX, SWITCH_DEFAULT_CONFIG, SearchRuntime, type SessionGenerations, type SessionPriority, type StewardConfig, StewardRuntime, type SwitchArchiveDiagnostics, SwitchIndexEngine, SwitchIndexServiceState, type SwitchSearchConfig, SwitchWatermarkSync, V4_HOST_MIN, apply, archiveArchiveFile, archiveHistory, assessRepair, backupFilesIn, buildProjectionOwnerIndex, buildSessionReport, classifyGenerationFilename, countCorpus, createArchiveSource, createAttributor, decodeSessionLogBytes, decodeSessionLogFile, detectSteward, dirSize, discoverSessions, editWorkspaceDocument, exportSnapshot, extractTitleFromEvents, findSession, findSessionLog, firstLosslessViolation, gateColdRead, gateGeneration, gateLogIntegrity, gateLosslessJson, gateProjectionCache, gateSourceKind, generationLogFilename, handleIndexMethod, handleMethod, importIntoIndex, indexSessionDirs, inject, isLossless, isMigrationStagingFilename, isSafeChild, isSourceMigrateBackupName, latestArtifactMtime, listHistory, locateSessionUsage, methodEnabled, migrateLegacySource, migrateSessionSourceKind, parseGenerationLogFilename, parseSnapshot, prescribe, probePeer, projCacheRootFor, pruneArchiveFile, pruneHistory, purgeHistory, quarantineProjectionCache, readArchiveSet, readProjectionCache, readSessionGenerations, readSourceKindFacts, readTailFacts, rebuildIndex, recoverIndex, scanSessions, scanZstdFrames, sessionPriority, sessionsRootFor, swapShadowIntoActive };
1452
+ declare function apply(ctx: Context, config?: Partial<StewardConfig>): void;
1453
+ export { Config, DEFAULT_CONFIG, type DiscoveredSession, type GenerationArtifact, HEALTH_METHODS, HISTORY_METHODS, HealthCache, type HealthCacheEntry, type LogArtifact, type LogCompression, type RepairAssessment, type RepairVerdict, SOURCE_MIGRATE_BACKUP_SUFFIX, STEWARD_API_PREFIX, STEWARD_SETTINGS_NAMESPACE, type SessionGenerations, type SessionPriority, type StewardConfig, StewardRuntime, V4_HOST_MIN, apply, archiveArchiveFile, archiveHistory, assessRepair, backupFilesIn, buildProjectionOwnerIndex, buildSessionReport, classifyGenerationFilename, countCorpus, createAttributor, decodeSessionLogBytes, decodeSessionLogFile, dirSize, discoverSessions, editWorkspaceDocument, findSession, findSessionLog, firstLosslessViolation, gateColdRead, gateGeneration, gateLogIntegrity, gateLosslessJson, gateProjectionCache, gateSourceKind, generationLogFilename, handleMethod, indexSessionDirs, inject, isLossless, isMigrationStagingFilename, isSafeChild, isSourceMigrateBackupName, latestArtifactMtime, listHistory, locateSessionUsage, methodEnabled, migrateLegacySource, migrateSessionSourceKind, parseGenerationLogFilename, prescribe, projCacheRootFor, pruneArchiveFile, pruneHistory, purgeHistory, quarantineProjectionCache, readArchiveSet, readProjectionCache, readSessionGenerations, readSourceKindFacts, readTailFacts, scanSessions, scanZstdFrames, sessionPriority, sessionsRootFor };