@morlay/session-rdb 0.0.18 → 0.0.19

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.
@@ -4,7 +4,7 @@ import { Session, SessionEvent, SessionHeader, SessionId, SessionLogOffset, Sess
4
4
  import { KvUnit } from "@deepseek-ai/dsh-storage";
5
5
  import { Context, Service } from "@deepseek-ai/cordis";
6
6
  import { SessionId as SessionId$1 } from "@deepseek-ai/dsh-session/types";
7
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/json-schema.d.cts
7
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/json-schema.d.cts
8
8
  type _JSONSchema = boolean | JSONSchema;
9
9
  type SchemaType = "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
10
10
  type JSONSchema = {
@@ -73,7 +73,7 @@ type JSONSchema = {
73
73
  };
74
74
  type BaseSchema = JSONSchema;
75
75
  //#endregion
76
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/standard-schema.d.cts
76
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/standard-schema.d.cts
77
77
  /** The Standard interface. */
78
78
  interface StandardTypedV1<Input = unknown, Output = Input> {
79
79
  /** The Standard properties. */
@@ -192,7 +192,7 @@ declare namespace StandardJSONSchemaV1 {
192
192
  }
193
193
  interface StandardSchemaWithJSONProps<Input = unknown, Output = Input> extends StandardSchemaV1.Props<Input, Output>, StandardJSONSchemaV1.Props<Input, Output> {}
194
194
  //#endregion
195
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/registries.d.cts
195
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/registries.d.cts
196
196
  declare const $output: unique symbol;
197
197
  type $output = typeof $output;
198
198
  declare const $input: unique symbol;
@@ -219,7 +219,7 @@ interface JSONSchemaMeta {
219
219
  }
220
220
  interface GlobalMeta extends JSONSchemaMeta {}
221
221
  //#endregion
222
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/to-json-schema.d.cts
222
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/to-json-schema.d.cts
223
223
  type Processor<T extends $ZodType = $ZodType> = (schema: T, ctx: ToJSONSchemaContext, json: BaseSchema, params: ProcessParams) => void;
224
224
  /**
225
225
  * Called for each schema that has no JSON Schema equivalent. Return a JSON Schema to use in its
@@ -341,14 +341,13 @@ interface ZodStandardJSONSchemaPayload<T> extends BaseSchema {
341
341
  "~standard": ZodStandardSchemaWithJSON$1<T>;
342
342
  }
343
343
  //#endregion
344
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/util.d.cts
344
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/util.d.cts
345
345
  type JWTAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | (string & {});
346
346
  type MimeTypes = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/javascript" | "application/pdf" | "application/zip" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/octet-stream" | "application/graphql" | "text/html" | "text/plain" | "text/css" | "text/javascript" | "text/csv" | "image/png" | "image/jpeg" | "image/gif" | "image/svg+xml" | "image/webp" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "video/mp4" | "video/webm" | "video/ogg" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf" | "multipart/form-data" | (string & {});
347
347
  type IsAny<T> = 0 extends 1 & T ? true : false;
348
348
  type Omit$1<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
349
349
  type MakePartial<T, K extends keyof T> = Omit$1<T, K> & InexactPartial<Pick<T, K>>;
350
350
  type NoUndefined<T> = T extends undefined ? never : T;
351
- type Widen<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends bigint ? bigint : T;
352
351
  type LoosePartial<T extends object> = InexactPartial<T> & {
353
352
  [k: string]: unknown;
354
353
  };
@@ -385,14 +384,14 @@ declare abstract class Class {
385
384
  /** A trait's prototype members: a partial view of its own interface, with `this` typed as the instance. */
386
385
  type ProtoOf<T> = { [K in keyof T]?: (T[K] extends ((...args: infer A) => infer R) ? (...args: A) => R : T[K]) | undefined; } & ThisType<T>;
387
386
  //#endregion
388
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/versions.d.cts
387
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/versions.d.cts
389
388
  declare const version: {
390
389
  readonly major: 4;
391
390
  readonly minor: 6;
392
391
  readonly patch: number;
393
392
  };
394
393
  //#endregion
395
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/schemas.d.cts
394
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/schemas.d.cts
396
395
  interface ParseContext<T extends $ZodIssueBase = never> {
397
396
  /** Customize error messages. */
398
397
  readonly error?: $ZodErrorMap<T>;
@@ -420,7 +419,7 @@ interface ParsePayload<T = unknown> {
420
419
  }
421
420
  type CheckFn<T> = (input: ParsePayload<T>) => MaybeAsync<void>;
422
421
  interface $ZodTypeDef {
423
- type: "string" | "number" | "int" | "boolean" | "bigint" | "symbol" | "null" | "undefined" | "void" | "never" | "any" | "unknown" | "date" | "object" | "record" | "file" | "array" | "tuple" | "union" | "intersection" | "map" | "set" | "enum" | "literal" | "nullable" | "optional" | "nonoptional" | "success" | "transform" | "default" | "prefault" | "catch" | "nan" | "pipe" | "readonly" | "template_literal" | "promise" | "lazy" | "function" | "custom" | "properties";
422
+ type: "string" | "number" | "int" | "boolean" | "bigint" | "symbol" | "null" | "undefined" | "void" | "never" | "any" | "unknown" | "date" | "object" | "record" | "file" | "array" | "tuple" | "union" | "intersection" | "map" | "set" | "enum" | "literal" | "nullable" | "optional" | "nonoptional" | "success" | "transform" | "default" | "prefault" | "catch" | "nan" | "pipe" | "readonly" | "template_literal" | "promise" | "lazy" | "function" | "custom";
424
423
  error?: $ZodErrorMap<never> | undefined;
425
424
  checks?: $ZodCheck<never>[];
426
425
  }
@@ -1198,7 +1197,7 @@ interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
1198
1197
  /** The default value. May be a getter. */
1199
1198
  defaultValue: input<T>;
1200
1199
  }
1201
- interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<NoUndefined<output<T>>, input<T> | undefined> {
1200
+ interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<output<T>, input<T> | undefined> {
1202
1201
  def: $ZodPrefaultDef<T>;
1203
1202
  optin: "defaulted";
1204
1203
  optout?: "optional" | undefined;
@@ -1411,24 +1410,9 @@ interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
1411
1410
  _zod: $ZodCustomInternals<O, I>;
1412
1411
  }
1413
1412
  declare const $ZodCustom: $constructor<$ZodCustom>;
1414
- interface $ZodPropertiesDef<Shape extends $ZodShape = $ZodShape> extends $ZodTypeDef, $ZodCheckDef {
1415
- type: "properties";
1416
- check: "properties";
1417
- shape: Shape;
1418
- }
1419
- interface $ZodPropertiesInternals<Shape extends $ZodShape = $ZodShape> extends $ZodTypeInternals<$InferObjectInput<Shape, {}>, $InferObjectInput<Shape, {}>>, $ZodCheckInternals<{ -readonly [k in keyof Shape]: Widen<input<Shape[k]>>; }> {
1420
- def: $ZodPropertiesDef<Shape>;
1421
- isst: $ZodIssueInvalidType;
1422
- issc: $ZodIssue;
1423
- }
1424
- interface $ZodProperties<Shape extends $ZodShape = $ZodShape> extends $ZodType {
1425
- _zod: $ZodPropertiesInternals<Shape>;
1426
- [Symbol.iterator](): Iterator<this>;
1427
- }
1428
- declare const $ZodProperties: $constructor<$ZodProperties>;
1429
- type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodFunction | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodProperties | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
1413
+ type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodFunction | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
1430
1414
  //#endregion
1431
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/checks.d.cts
1415
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/checks.d.cts
1432
1416
  interface $ZodCheckDef {
1433
1417
  check: string;
1434
1418
  error?: $ZodErrorMap<never> | undefined;
@@ -1610,7 +1594,7 @@ interface $ZodCheckEndsWith extends $ZodCheckInternals<string> {
1610
1594
  }
1611
1595
  declare const $ZodCheckEndsWith: $constructor<$ZodCheckEndsWith>;
1612
1596
  //#endregion
1613
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/errors.d.cts
1597
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/errors.d.cts
1614
1598
  interface $ZodIssueBase {
1615
1599
  readonly code?: string;
1616
1600
  readonly input?: unknown;
@@ -1739,7 +1723,7 @@ type $ZodFormattedError<T, U = string> = {
1739
1723
  _errors: U[];
1740
1724
  } & Flatten<_ZodFormattedError<T, U>>;
1741
1725
  //#endregion
1742
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/core.d.cts
1726
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/core.d.cts
1743
1727
  type ZodTrait = {
1744
1728
  _zod: {
1745
1729
  def: any;
@@ -1785,7 +1769,7 @@ type output<T> = T extends {
1785
1769
  };
1786
1770
  } ? T["_zod"]["output"] : unknown;
1787
1771
  //#endregion
1788
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/core/api.d.cts
1772
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/core/api.d.cts
1789
1773
  type Params<T extends $ZodType | $ZodCheck, IssueTypes extends $ZodIssueBase, OmitKeys extends keyof T["_zod"]["def"] = never> = Flatten<Partial<EmptyToNever<Omit<T["_zod"]["def"], OmitKeys> & ([IssueTypes] extends [never] ? {} : {
1790
1774
  error?: string | $ZodErrorMap<IssueTypes> | undefined;
1791
1775
  /** @deprecated This parameter is deprecated. Use `error` instead. */
@@ -1857,7 +1841,7 @@ interface $ZodSuperRefineParams {
1857
1841
  when?: ((payload: ParsePayload) => boolean) | undefined;
1858
1842
  }
1859
1843
  //#endregion
1860
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/classic/errors.d.cts
1844
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/classic/errors.d.cts
1861
1845
  /** An Error-like class used to store Zod validation issues. */
1862
1846
  interface ZodError<T = unknown> extends $ZodError<T> {
1863
1847
  /** @deprecated Use the `z.treeifyError(err)` function instead. */
@@ -1875,7 +1859,7 @@ interface ZodError<T = unknown> extends $ZodError<T> {
1875
1859
  }
1876
1860
  declare const ZodError: $constructor<ZodError>;
1877
1861
  //#endregion
1878
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/classic/parse.d.cts
1862
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/classic/parse.d.cts
1879
1863
  type ZodSafeParseResult<T> = ZodSafeParseSuccess<T> | ZodSafeParseError<T>;
1880
1864
  type ZodSafeParseSuccess<T> = {
1881
1865
  success: true;
@@ -1888,7 +1872,7 @@ type ZodSafeParseError<T> = {
1888
1872
  error: ZodError<T>;
1889
1873
  };
1890
1874
  //#endregion
1891
- //#region ../../node_modules/.pnpm/zod@4.6.1/node_modules/zod/v4/classic/schemas.d.cts
1875
+ //#region ../../../node_modules/.pnpm/zod@4.6.4/node_modules/zod/v4/classic/schemas.d.cts
1892
1876
  type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<input<T>, output<T>>;
1893
1877
  interface ZodType<out Output = unknown, out Input = unknown, out Internals extends $ZodTypeInternals<Output, Input> = $ZodTypeInternals<Output, Input>> extends $ZodType<Output, Input, Internals> {
1894
1878
  def: Internals["def"];
@@ -2220,7 +2204,7 @@ interface ZodReadonly<T extends SomeType = $ZodType> extends _ZodType<$ZodReadon
2220
2204
  }
2221
2205
  declare const ZodReadonly: $constructor<ZodReadonly>;
2222
2206
  //#endregion
2223
- //#region ../../vendor/deepseek-harness/packages/session/session-projection/lib/types/types.d.ts
2207
+ //#region ../../../vendor/deepseek-harness/packages/session/session-projection/lib/types/types.d.ts
2224
2208
  /**
2225
2209
  * Pure-type outlet of the session-projection Service Definition: the one projection type
2226
2210
  * table, importable from client aggregates without dragging the host-side
@@ -2244,7 +2228,7 @@ interface SessionProjectionMap {}
2244
2228
  */
2245
2229
  interface SessionProjectionStateMap {}
2246
2230
  //#endregion
2247
- //#region ../../vendor/deepseek-harness/packages/session/session-projection/lib/types/index.d.ts
2231
+ //#region ../../../vendor/deepseek-harness/packages/session/session-projection/lib/types/index.d.ts
2248
2232
  declare module '@deepseek-ai/cordis' {
2249
2233
  interface Context {
2250
2234
  sessionProjections: SessionProjectionRegistry;
@@ -2512,7 +2496,7 @@ declare class SessionProjectionRegistry extends Service {
2512
2496
  private viewCell;
2513
2497
  }
2514
2498
  //#endregion
2515
- //#region ../../vendor/deepseek-harness/packages/storage/storage-domain/lib/types/spec.d.ts
2499
+ //#region ../../../vendor/deepseek-harness/packages/storage/storage-domain/lib/types/spec.d.ts
2516
2500
  /** Global singleton declaration: schema plus the value used before the first write. */
2517
2501
  interface DomainGlobalSpec<G> {
2518
2502
  /** Validates the stored global at the durable boundary. */
@@ -2575,7 +2559,7 @@ type TableKeyOf<S extends DomainSpec, N extends keyof S['tables']> = S['tables']
2575
2559
  /** Value type of one declared table. */
2576
2560
  type TableValueOf<S extends DomainSpec, N extends keyof S['tables']> = S['tables'][N] extends DomainTableSpec<string, infer V> ? V : never;
2577
2561
  //#endregion
2578
- //#region ../../vendor/deepseek-harness/packages/storage/storage-domain/lib/types/domain.d.ts
2562
+ //#region ../../../vendor/deepseek-harness/packages/storage/storage-domain/lib/types/domain.d.ts
2579
2563
  /** Handle on a domain's global singleton. */
2580
2564
  interface DomainGlobal<G> {
2581
2565
  /**
@@ -2729,7 +2713,7 @@ declare class DomainImpl {
2729
2713
  private assertReadable;
2730
2714
  }
2731
2715
  //#endregion
2732
- //#region ../../vendor/deepseek-harness/packages/storage/storage-domain/lib/types/events.d.ts
2716
+ //#region ../../../vendor/deepseek-harness/packages/storage/storage-domain/lib/types/events.d.ts
2733
2717
  /**
2734
2718
  * Change-event vocabulary of the domain data form. Every durable write emits
2735
2719
  * one event after the backend resolves durability, carrying the new snapshot
@@ -2774,7 +2758,7 @@ declare module '@deepseek-ai/cordis' {
2774
2758
  }
2775
2759
  }
2776
2760
  //#endregion
2777
- //#region ../../vendor/deepseek-harness/packages/storage/storage-domain/lib/types/index.d.ts
2761
+ //#region ../../../vendor/deepseek-harness/packages/storage/storage-domain/lib/types/index.d.ts
2778
2762
  declare module '@deepseek-ai/dsh-storage' {
2779
2763
  interface StorageForms {
2780
2764
  domain: DomainFacility;
@@ -2852,7 +2836,7 @@ declare class DomainFacility {
2852
2836
  closeAll(): Promise<void>;
2853
2837
  }
2854
2838
  //#endregion
2855
- //#region ../../vendor/deepseek-harness/packages/session/session-projection-cache/lib/types/spec.d.ts
2839
+ //#region ../../../vendor/deepseek-harness/packages/session/session-projection-cache/lib/types/spec.d.ts
2856
2840
  /**
2857
2841
  * The stored-log identity a record is bound to: the immutable header fields
2858
2842
  * that distinguish one session lifecycle from another under the same id. A
@@ -2879,7 +2863,7 @@ declare const checkpointIdentity: ZodObject<{
2879
2863
  /** The identity fields a record is bound to, inferred from {@link checkpointIdentity}. */
2880
2864
  type CheckpointIdentity = output<typeof checkpointIdentity>;
2881
2865
  //#endregion
2882
- //#region ../../vendor/deepseek-harness/packages/session/session-projection-cache/lib/types/index.d.ts
2866
+ //#region ../../../vendor/deepseek-harness/packages/session/session-projection-cache/lib/types/index.d.ts
2883
2867
  declare module '@deepseek-ai/cordis' {
2884
2868
  interface Context {
2885
2869
  sessionProjectionCache: SessionProjectionCache;
@@ -3014,7 +2998,7 @@ declare class SessionProjectionCache extends Service {
3014
2998
  private requireTable;
3015
2999
  }
3016
3000
  //#endregion
3017
- //#region ../../vendor/deepseek-harness/packages/util/brand/lib/types/index.d.ts
3001
+ //#region ../../../vendor/deepseek-harness/packages/util/brand/lib/types/index.d.ts
3018
3002
  /**
3019
3003
  * Duplicate-install-safe nominal primitive helpers.
3020
3004
  *
@@ -3034,7 +3018,7 @@ type Branded<B extends string> = string & {
3034
3018
  readonly [BRAND]: B;
3035
3019
  };
3036
3020
  //#endregion
3037
- //#region ../../vendor/deepseek-harness/packages/workspace/workspace/lib/types/types.d.ts
3021
+ //#region ../../../vendor/deepseek-harness/packages/workspace/workspace/lib/types/types.d.ts
3038
3022
  /**
3039
3023
  * Identifies one workspace record. A generated uuid, never the path: path
3040
3024
  * normalization rewrites paths, and a reference anchor must stay stable.
@@ -3127,7 +3111,7 @@ interface Workspace {
3127
3111
  status(): Promise<'ok' | 'missing-dir'>;
3128
3112
  }
3129
3113
  //#endregion
3130
- //#region ../../vendor/deepseek-harness/packages/workspace/workspace/lib/types/spec.d.ts
3114
+ //#region ../../../vendor/deepseek-harness/packages/workspace/workspace/lib/types/spec.d.ts
3131
3115
  /**
3132
3116
  * Durable shape of one workspace record. `path` is the `fs.realpath` canon
3133
3117
  * stamped at create; `sessionIds` is the ordered ownership account (array
@@ -3166,7 +3150,7 @@ declare const workspaceDomainState: ZodObject<{
3166
3150
  /** Durable registry state inferred from {@link workspaceDomainState}. */
3167
3151
  type WorkspaceDomainState = output<typeof workspaceDomainState>;
3168
3152
  //#endregion
3169
- //#region ../../vendor/deepseek-harness/packages/workspace/workspace/lib/types/index.d.ts
3153
+ //#region ../../../vendor/deepseek-harness/packages/workspace/workspace/lib/types/index.d.ts
3170
3154
  /** Identifies one workspace record (see `src/types.ts` for the brand rationale). */
3171
3155
  type WorkspaceId = WorkspaceId$1;
3172
3156
  /**
@@ -3359,8 +3343,13 @@ interface StorageRepository {
3359
3343
  * @param rows - 每个投影 key 一行。
3360
3344
  */
3361
3345
  putProjcache(sessionId: string, rows: ProjectionCheckpoint): Promise<void>;
3362
- /** 删除一个会话的 checkpoint(缺失为 no-op)。 */
3363
- deleteProjcache(sessionId: string): Promise<void>;
3346
+ /**
3347
+ * 清理陈旧 checkpoint 行:水位为负却已有事件的会话(旧版写入路径的产物,
3348
+ * 会把有对话的会话误判为空白)。缓存是派生数据,删除只让该会话回到
3349
+ * 「未知即可见」并等待下一次强制点重写。
3350
+ * @returns 删除的行数。
3351
+ */
3352
+ pruneStaleProjcache(): Promise<number>;
3364
3353
  }
3365
3354
  //#endregion
3366
3355
  //#region src/backend.d.ts
@@ -1,7 +1,7 @@
1
1
  import { g as titleOfEventData, m as sessionInsertRow, p as sessionConflictRow } from "./log-DO69NQnn.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
- import { SessionId, SessionLogOffset, SessionSeq } from "@deepseek-ai/dsh-session";
4
- import { and, desc, eq, gte, isNotNull, notInArray, sql } from "drizzle-orm";
3
+ import { SESSION_FORMAT_VERSION, SessionId, SessionLogOffset, SessionSeq } from "@deepseek-ai/dsh-session";
4
+ import { and, desc, eq, gte, inArray, isNotNull, lt, notInArray, sql } from "drizzle-orm";
5
5
  import { check, index, integer, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
6
6
  import { bigint, check as check$1, index as index$1, integer as integer$1, pgSchema, pgTable, serial, text as text$1, unique as unique$1 } from "drizzle-orm/pg-core";
7
7
  import { readdirSync, statSync } from "node:fs";
@@ -407,7 +407,7 @@ const workspaceSessions = {
407
407
  * workspace 域 global 单例(上游 `workspaceDomainState`):`initialized` 是
408
408
  * 引导标记,`pendingMutation` 拆成操作与目标两列(create / delete 的可恢复
409
409
  * 两写标记)。显示顺序(`workspaceIds`)在 `t_workspaces.f_position`,
410
- * 归档集在 `t_session_archives`。
410
+ * 归档集由 `t_sessions.f_archived_at` 承载(归档不触碰归属槽位)。
411
411
  */
412
412
  const workspaceState = {
413
413
  name: "t_workspace_state",
@@ -842,7 +842,24 @@ function createStorageRepository(host) {
842
842
  const archived = state.archivedSessionIds;
843
843
  await runQuery(archived.length === 0 ? db.update(tSessions).set({ fArchivedAt: null }).where(isNotNull(tSessions.fArchivedAt)) : db.update(tSessions).set({ fArchivedAt: null }).where(and(isNotNull(tSessions.fArchivedAt), notInArray(tSessions.fSessionId, archived))));
844
844
  const stamp = Date.now();
845
- for (const sessionId of archived) await runQuery(db.update(tSessions).set({ fArchivedAt: sql`COALESCE(${tSessions.fArchivedAt}, ${stamp})` }).where(eq(tSessions.fSessionId, sessionId)));
845
+ for (const sessionId of archived) await runQuery(db.insert(tSessions).values({
846
+ fSessionId: sessionId,
847
+ fHeadEventId: "",
848
+ fHeadSequence: -1,
849
+ fVersion: SESSION_FORMAT_VERSION,
850
+ fCreatedAt: stamp,
851
+ fCwd: null,
852
+ fParentSession: null,
853
+ fSeedLength: null,
854
+ fOrigin: null,
855
+ fDelegationDepth: null,
856
+ fIncarnation: randomUUID(),
857
+ fRevision: 0,
858
+ fArchivedAt: stamp
859
+ }).onConflictDoUpdate({
860
+ target: tSessions.fSessionId,
861
+ set: { fArchivedAt: sql`COALESCE(${tSessions.fArchivedAt}, ${stamp})` }
862
+ }));
846
863
  });
847
864
  },
848
865
  async loadProjcache() {
@@ -881,8 +898,12 @@ function createStorageRepository(host) {
881
898
  if (values.length > 0) await runQuery(db.insert(tProjcacheRows).values(values));
882
899
  });
883
900
  },
884
- async deleteProjcache(sessionId) {
885
- await runQuery((await dbx()).delete(tProjcacheRows).where(eq(tProjcacheRows.fSessionId, sessionId)));
901
+ async pruneStaleProjcache() {
902
+ const db = await dbx();
903
+ const stale = await allRows(db.select({ fSessionId: tProjcacheRows.fSessionId }).from(tProjcacheRows).where(and(lt(tProjcacheRows.fSeq, 0), inArray(tProjcacheRows.fSessionId, db.select({ fSessionId: tSessions.fSessionId }).from(tSessions).where(gte(tSessions.fHeadSequence, 0))))));
904
+ if (stale.length === 0) return 0;
905
+ await runQuery(db.delete(tProjcacheRows).where(inArray(tProjcacheRows.fSessionId, stale.map((row) => row.fSessionId))));
906
+ return stale.length;
886
907
  },
887
908
  ...host.dbSync === void 0 ? {} : {
888
909
  readProjcacheSync: (sessionId) => {
@@ -1,4 +1,4 @@
1
- import { C as EventRow, S as BackendTx, T as StorageRepository, _ as tWorkspaceSessions, a as JournalMode, b as WriteGuard, c as eventDimensions, d as tPersistenceState, f as tSchemaMeta, g as tStorageUnits, h as tSessions, i as EventRole, l as eventKind, m as tSessionProjcacheRows, n as EVENT_ENCODING, o as SCHEMA_VERSION, p as tSessionEvents, r as EventKind, s as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, t as DEFAULT_BUSY_TIMEOUT_MS, u as tEvents, v as tWorkspaceState, w as SessionRow, x as Backend, y as tWorkspaces } from "./schema-Bo6Hy5gW.mjs";
1
+ import { C as EventRow, S as BackendTx, T as StorageRepository, _ as tWorkspaceSessions, a as JournalMode, b as WriteGuard, c as eventDimensions, d as tPersistenceState, f as tSchemaMeta, g as tStorageUnits, h as tSessions, i as EventRole, l as eventKind, m as tSessionProjcacheRows, n as EVENT_ENCODING, o as SCHEMA_VERSION, p as tSessionEvents, r as EventKind, s as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, t as DEFAULT_BUSY_TIMEOUT_MS, u as tEvents, v as tWorkspaceState, w as SessionRow, x as Backend, y as tWorkspaces } from "./schema-DPcuEh_a.mjs";
2
2
  import { SessionId } from "@deepseek-ai/dsh-session";
3
3
  import { DatabaseSync } from "node:sqlite";
4
4
  //#region src/sqlite.d.ts
package/dist/storage.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { S as WriteGuard, _ as tWorkspaceSessions, a as EVENT_ENCODING, c as eventDimensions, d as tPersistenceState, f as tSchemaMeta, g as tStorageUnits, h as tSessions, i as DEFAULT_BUSY_TIMEOUT_MS, l as eventKind, m as tSessionProjcacheRows, n as openDatabase, o as SCHEMA_VERSION, p as tSessionEvents, s as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, t as SqliteBackend, u as tEvents, v as tWorkspaceState, y as tWorkspaces } from "./sqlite-BIPdMNQb.mjs";
1
+ import { S as WriteGuard, _ as tWorkspaceSessions, a as EVENT_ENCODING, c as eventDimensions, d as tPersistenceState, f as tSchemaMeta, g as tStorageUnits, h as tSessions, i as DEFAULT_BUSY_TIMEOUT_MS, l as eventKind, m as tSessionProjcacheRows, n as openDatabase, o as SCHEMA_VERSION, p as tSessionEvents, s as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, t as SqliteBackend, u as tEvents, v as tWorkspaceState, y as tWorkspaces } from "./sqlite-DYExtbLo.mjs";
2
2
  export { DEFAULT_BUSY_TIMEOUT_MS, EVENT_ENCODING, SCHEMA_VERSION, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, SqliteBackend, WriteGuard, eventDimensions, eventKind, openDatabase, tEvents, tPersistenceState, tSchemaMeta, tSessionEvents, tSessionProjcacheRows, tSessions, tStorageUnits, tWorkspaceSessions, tWorkspaceState, tWorkspaces };
package/dist/testing.mjs CHANGED
@@ -19,7 +19,7 @@ var EmptySettings = class extends SettingsProvider {
19
19
  }
20
20
  };
21
21
  //#endregion
22
- //#region ../../node_modules/.pnpm/tinyrainbow@3.1.1/node_modules/tinyrainbow/dist/index.js
22
+ //#region ../../../node_modules/.pnpm/tinyrainbow@3.1.1/node_modules/tinyrainbow/dist/index.js
23
23
  var b = {
24
24
  reset: [0, 0],
25
25
  bold: [
@@ -102,7 +102,7 @@ function C({ force: e } = {}) {
102
102
  }
103
103
  var y = C();
104
104
  //#endregion
105
- //#region ../../node_modules/.pnpm/@vitest+pretty-format@4.1.11/node_modules/@vitest/pretty-format/dist/index.js
105
+ //#region ../../../node_modules/.pnpm/@vitest+pretty-format@4.1.11/node_modules/@vitest/pretty-format/dist/index.js
106
106
  function _mergeNamespaces(n, m) {
107
107
  m.forEach(function(e) {
108
108
  e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
@@ -985,7 +985,7 @@ const plugins = {
985
985
  Error: ErrorPlugin
986
986
  };
987
987
  //#endregion
988
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/display.js
988
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/display.js
989
989
  const ansiColors$1 = {
990
990
  bold: ["1", "22"],
991
991
  dim: ["2", "22"],
@@ -1541,7 +1541,7 @@ function objDisplay$1(obj, options = {}) {
1541
1541
  return str;
1542
1542
  }
1543
1543
  //#endregion
1544
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/helpers.js
1544
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/helpers.js
1545
1545
  /**
1546
1546
  * Get original stacktrace without source map support the most performant way.
1547
1547
  * - Create only 1 stack frame.
@@ -3030,7 +3030,7 @@ function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
3030
3030
  return diffs.reduce((reduced, diff) => reduced + (diff[0] === 0 ? diff[1] : diff[0] === op ? hasCommonDiff ? y.inverse(diff[1]) : diff[1] : ""), "");
3031
3031
  }
3032
3032
  //#endregion
3033
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/serialize.js
3033
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/serialize.js
3034
3034
  const IS_RECORD_SYMBOL$1 = "@@__IMMUTABLE_RECORD__@@";
3035
3035
  const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
3036
3036
  function isImmutable(v) {
@@ -3104,7 +3104,7 @@ function normalizeErrorMessage(message) {
3104
3104
  return message.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/getByTestId('__vitest_\d+__')/g, "page");
3105
3105
  }
3106
3106
  //#endregion
3107
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/error.js
3107
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/error.js
3108
3108
  function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
3109
3109
  if (!_err || typeof _err !== "object") return { message: String(_err) };
3110
3110
  const err = _err;
@@ -3134,7 +3134,7 @@ function prettifyValue(value, options) {
3134
3134
  return value;
3135
3135
  }
3136
3136
  //#endregion
3137
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/timers.js
3137
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/timers.js
3138
3138
  const SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS");
3139
3139
  function getSafeTimers() {
3140
3140
  const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
@@ -3168,7 +3168,7 @@ function delay(timeout, scheduler = setTimeout) {
3168
3168
  return new Promise((resolve) => scheduler(resolve, timeout));
3169
3169
  }
3170
3170
  //#endregion
3171
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
3171
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
3172
3172
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
3173
3173
  function normalizeWindowsPath(input = "") {
3174
3174
  if (!input) return input;
@@ -3247,7 +3247,7 @@ const isAbsolute = function(p) {
3247
3247
  return _IS_ABSOLUTE_RE.test(p);
3248
3248
  };
3249
3249
  //#endregion
3250
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/source-map.js
3250
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/source-map.js
3251
3251
  var comma = ",".charCodeAt(0);
3252
3252
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
3253
3253
  var intToChar = /* @__PURE__ */ new Uint8Array(64);
@@ -3615,7 +3615,7 @@ function getOriginalPosition(map, needle) {
3615
3615
  return result;
3616
3616
  }
3617
3617
  //#endregion
3618
- //#region ../../node_modules/.pnpm/@vitest+runner@4.1.11/node_modules/@vitest/runner/dist/chunk-artifact.js
3618
+ //#region ../../../node_modules/.pnpm/@vitest+runner@4.1.11/node_modules/@vitest/runner/dist/chunk-artifact.js
3619
3619
  var PendingError = class extends Error {
3620
3620
  code = "VITEST_PENDING";
3621
3621
  taskId;
@@ -5116,7 +5116,7 @@ function manageArtifactAttachment(attachment) {
5116
5116
  if (attachment.body != null) attachment.bodyEncoding ??= "base64";
5117
5117
  }
5118
5118
  //#endregion
5119
- //#region ../../node_modules/.pnpm/vitest@4.1.11_@opentelemetry+api@1.9.1_@types+node@26.5.1_happy-dom@20.14.3_vite@8.2.2__e05875f349154650201ff2ddb1226938/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js
5119
+ //#region ../../../node_modules/.pnpm/vitest@4.1.11_@opentelemetry+api@1.9.1_@types+node@26.5.1_happy-dom@20.14.5_vite@8.3.0__92c0f6eceeda0310e820829bd463d84c/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js
5120
5120
  const NAME_WORKER_STATE = "__vitest_worker__";
5121
5121
  function getWorkerState() {
5122
5122
  const workerState = globalThis[NAME_WORKER_STATE];
@@ -5156,7 +5156,7 @@ async function waitForImportsToResolve() {
5156
5156
  await waitForImportsToResolve();
5157
5157
  }
5158
5158
  //#endregion
5159
- //#region ../../node_modules/.pnpm/@vitest+spy@4.1.11/node_modules/@vitest/spy/dist/index.js
5159
+ //#region ../../../node_modules/.pnpm/@vitest+spy@4.1.11/node_modules/@vitest/spy/dist/index.js
5160
5160
  function isMockFunction(fn) {
5161
5161
  return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
5162
5162
  }
@@ -5539,7 +5539,7 @@ function throwConstructorError(shorthand) {
5539
5539
  throw new TypeError(`Cannot use \`${shorthand}\` when called with \`new\`. Use \`mockImplementation\` with a \`class\` keyword instead. See https://vitest.dev/api/mock#class-support for more information.`);
5540
5540
  }
5541
5541
  //#endregion
5542
- //#region ../../node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js
5542
+ //#region ../../../node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js
5543
5543
  var __defProp = Object.defineProperty;
5544
5544
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
5545
5545
  enumerable: true,
@@ -8519,7 +8519,7 @@ function use(fn) {
8519
8519
  }
8520
8520
  __name(use, "use");
8521
8521
  //#endregion
8522
- //#region ../../node_modules/.pnpm/@vitest+expect@4.1.11/node_modules/@vitest/expect/dist/index.js
8522
+ //#region ../../../node_modules/.pnpm/@vitest+expect@4.1.11/node_modules/@vitest/expect/dist/index.js
8523
8523
  const ChaiStyleAssertions = (chai, utils) => {
8524
8524
  function defProperty(name, delegateTo) {
8525
8525
  utils.addProperty(chai.Assertion.prototype, name, function() {
@@ -9995,7 +9995,7 @@ const JestExtend = (chai, utils) => {
9995
9995
  });
9996
9996
  };
9997
9997
  //#endregion
9998
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/offset.js
9998
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/offset.js
9999
9999
  const lineSplitRE = /\r?\n/;
10000
10000
  function positionToOffset(source, lineNumber, columnNumber) {
10001
10001
  const lines = source.split(lineSplitRE);
@@ -10019,10 +10019,10 @@ function offsetToLineNumber(source, offset) {
10019
10019
  return line + 1;
10020
10020
  }
10021
10021
  //#endregion
10022
- //#region ../../node_modules/.pnpm/vitest@4.1.11_@opentelemetry+api@1.9.1_@types+node@26.5.1_happy-dom@20.14.3_vite@8.2.2__e05875f349154650201ff2ddb1226938/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
10022
+ //#region ../../../node_modules/.pnpm/vitest@4.1.11_@opentelemetry+api@1.9.1_@types+node@26.5.1_happy-dom@20.14.5_vite@8.3.0__92c0f6eceeda0310e820829bd463d84c/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
10023
10023
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
10024
10024
  //#endregion
10025
- //#region ../../node_modules/.pnpm/vitest@4.1.11_@opentelemetry+api@1.9.1_@types+node@26.5.1_happy-dom@20.14.3_vite@8.2.2__e05875f349154650201ff2ddb1226938/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js
10025
+ //#region ../../../node_modules/.pnpm/vitest@4.1.11_@opentelemetry+api@1.9.1_@types+node@26.5.1_happy-dom@20.14.5_vite@8.3.0__92c0f6eceeda0310e820829bd463d84c/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js
10026
10026
  const RealDate = Date;
10027
10027
  let now = null;
10028
10028
  var MockDate = class MockDate extends RealDate {
@@ -10070,7 +10070,7 @@ function resetDate() {
10070
10070
  }
10071
10071
  const { get } = Reflect;
10072
10072
  //#endregion
10073
- //#region ../../node_modules/.pnpm/@vitest+snapshot@4.1.11/node_modules/@vitest/snapshot/dist/index.js
10073
+ //#region ../../../node_modules/.pnpm/@vitest+snapshot@4.1.11/node_modules/@vitest/snapshot/dist/index.js
10074
10074
  function getDefaultExportFromCjs(x) {
10075
10075
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
10076
10076
  }
@@ -10276,7 +10276,7 @@ function memo(fn) {
10276
10276
  };
10277
10277
  }
10278
10278
  async function saveInlineSnapshots(environment, snapshots) {
10279
- const MagicString = (await import("./magic-string.es-BWtG0AyA.mjs")).default;
10279
+ const MagicString = (await import("./magic-string.es-BgJoa-3K.mjs")).default;
10280
10280
  const files = new Set(snapshots.map((i) => i.file));
10281
10281
  await Promise.all(Array.from(files).map(async (file) => {
10282
10282
  const snaps = snapshots.filter((i) => i.file === file);
@@ -10987,7 +10987,7 @@ function raceWith(promise, other) {
10987
10987
  }))]);
10988
10988
  }
10989
10989
  //#endregion
10990
- //#region ../../node_modules/.pnpm/vitest@4.1.11_@opentelemetry+api@1.9.1_@types+node@26.5.1_happy-dom@20.14.3_vite@8.2.2__e05875f349154650201ff2ddb1226938/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js
10990
+ //#region ../../../node_modules/.pnpm/vitest@4.1.11_@opentelemetry+api@1.9.1_@types+node@26.5.1_happy-dom@20.14.5_vite@8.3.0__92c0f6eceeda0310e820829bd463d84c/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js
10991
10991
  var fakeTimersSrc = {};
10992
10992
  var global$1;
10993
10993
  var hasRequiredGlobal;