@deepseek-ai/dsh-session-persistence 0.0.1-rc.1

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.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Bounded per-session write batching for the shared persistence coordinator.
3
+ * @module @deepseek-ai/dsh-session-persistence/write-behind
4
+ */
5
+ import type { SessionEvent } from '@deepseek-ai/dsh-session';
6
+ /** Dependencies and scheduling policy for one live session's write controller. */
7
+ export interface SessionWriteBehindOptions {
8
+ /** Maximum intentional batching wait after an idle queue receives work. */
9
+ readonly maxDelayMs: number;
10
+ /** Persist one stable ordered prefix; resolves only after backend durability. */
11
+ readonly write: (events: readonly SessionEvent[]) => Promise<void>;
12
+ /** Observe a detached background write failure without rejecting the producer. */
13
+ readonly reportBackgroundFailure: (error: unknown) => void;
14
+ }
15
+ /**
16
+ * Owns one live session's pending events, fixed batching deadline, active write,
17
+ * failure retention, and explicit quiescence barrier.
18
+ */
19
+ export declare class SessionWriteBehind {
20
+ private readonly options;
21
+ private pending;
22
+ private timer;
23
+ private active;
24
+ private barrier;
25
+ private deadlineExpired;
26
+ private automaticPaused;
27
+ /**
28
+ * @param options - fixed scheduling policy and durable batch sink.
29
+ */
30
+ constructor(options: SessionWriteBehindOptions);
31
+ /** Whether this controller owns queued events or an active durable write. */
32
+ get hasWork(): boolean;
33
+ /**
34
+ * Copy one event into the persistence-owned queue and start a fixed deadline
35
+ * when the automatic path is idle.
36
+ * @param event - frozen live event to retain independently of its producer.
37
+ */
38
+ enqueue(event: SessionEvent): void;
39
+ /**
40
+ * Cancel the batching wait and durably drain through a quiescent point.
41
+ * Concurrent callers join the same barrier.
42
+ * @returns a promise that rejects if the barrier's durable retry fails.
43
+ */
44
+ flush(): Promise<void>;
45
+ /** Cancel the current automatic deadline without draining retained work. */
46
+ cancelAutomaticWait(): void;
47
+ /** Start the one fixed window for the current pending prefix. */
48
+ private armTimer;
49
+ /** Cancel any pending automatic deadline. */
50
+ private cancelTimer;
51
+ /** Start a background write now, or remember that an active write used the budget. */
52
+ private onDeadline;
53
+ /** Start one detached write whose failure is reported and retained. */
54
+ private startBackground;
55
+ /** Continue immediately after an over-budget active write, otherwise keep its timer. */
56
+ private continueAutomatic;
57
+ /** Await overlapping work, drain to quiescence, and settle the shared barrier. */
58
+ private drainBarrier;
59
+ /** Start one stable pending prefix, retaining it in order if durability fails. */
60
+ private startWrite;
61
+ }
62
+ //# sourceMappingURL=write-behind.d.ts.map
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@deepseek-ai/dsh-session-persistence",
3
+ "description": "Abstract durable session persistence seam (ctx.sessionPersistence) for the DeepSeek Harness",
4
+ "version": "0.0.1-rc.1",
5
+ "publishConfig": {
6
+ "access": "restricted"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
11
+ "directory": "packages/session/session-persistence"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./src/*": "./src/*",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "lib/index.js",
30
+ "lib/invariant.js",
31
+ "lib/types/**/*.d.ts"
32
+ ],
33
+ "license": "BSD-3-Clause",
34
+ "peerDependencies": {
35
+ "@deepseek-ai/dsh-brand": "^0.0.1-rc.1",
36
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.1",
37
+ "@deepseek-ai/dsh-session": "^0.0.1-rc.1",
38
+ "@deepseek-ai/dsh-timeout": "^0.0.1-rc.1",
39
+ "@deepseek-ai/cordis": "^4.0.1-rc.1"
40
+ },
41
+ "devDependencies": {
42
+ "@deepseek-ai/dsh-brand": "^0.0.1-rc.1",
43
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.1",
44
+ "@deepseek-ai/dsh-scope": "^0.0.1-rc.1",
45
+ "@deepseek-ai/dsh-session": "^0.0.1-rc.1",
46
+ "@deepseek-ai/dsh-timeout": "^0.0.1-rc.1",
47
+ "@deepseek-ai/cordis": "^4.0.1-rc.1"
48
+ }
49
+ }