@takboo/dsh-session-bin 0.0.0-stage → 0.1.0

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -2
  3. package/cordis.patch.yml +4 -0
  4. package/dist/client-model.js +1673 -0
  5. package/dist/client.js +17043 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/host/archive.d.ts +766 -0
  8. package/dist/host/lease.d.ts +4 -0
  9. package/dist/host/module.d.ts +705 -0
  10. package/dist/host/native-jsonl-files.d.ts +198 -0
  11. package/dist/host/native-retirement-admission.d.ts +33 -0
  12. package/dist/host/native-retirement-metadata.d.ts +109 -0
  13. package/dist/host/native-retirement-owner.d.ts +305 -0
  14. package/dist/host/native-retirement-persistence.d.ts +24 -0
  15. package/dist/host/native-retirement-sdk.d.ts +80 -0
  16. package/dist/host/native.d.ts +12 -0
  17. package/dist/host/platform-files.d.ts +19 -0
  18. package/dist/host/remote.d.ts +32 -0
  19. package/dist/host/retirement-owner-store.d.ts +124 -0
  20. package/dist/host/retirement-owner.d.ts +124 -0
  21. package/dist/host/retirement-store.d.ts +311 -0
  22. package/dist/host/retirement.d.ts +76 -0
  23. package/dist/host/store.d.ts +215 -0
  24. package/dist/index.d.ts +912 -0
  25. package/dist/index.js +4921 -0
  26. package/dist/index.js.map +7 -0
  27. package/dist/operations/archive.d.ts +82 -0
  28. package/dist/operations/index.d.ts +2 -0
  29. package/dist/operations/retirement-owner.d.ts +129 -0
  30. package/dist/operations/retirement.d.ts +821 -0
  31. package/dist/operations/schema.d.ts +115 -0
  32. package/dist/operations.js +130 -0
  33. package/dist/operations.js.map +7 -0
  34. package/dist/remote/contracts.d.ts +891 -0
  35. package/dist/remote.js +442 -0
  36. package/dist/remote.js.map +7 -0
  37. package/dist/types/client/components.d.ts +17 -0
  38. package/dist/types/client/index.d.ts +10 -0
  39. package/dist/types/client/locales.d.ts +116 -0
  40. package/dist/types/client/model.d.ts +137 -0
  41. package/dist/types/client/purge-batch.d.ts +45 -0
  42. package/dist/types/client/retirement-digest.d.ts +3 -0
  43. package/dist/types/operations/archive.d.ts +82 -0
  44. package/dist/types/operations/retirement.d.ts +821 -0
  45. package/dist/types/operations/schema.d.ts +115 -0
  46. package/dist/types/remote/contracts.d.ts +891 -0
  47. package/docs/client-interface.md +79 -0
  48. package/docs/host-lifecycle.md +158 -0
  49. package/locale/en.json +6 -0
  50. package/locale/zh.json +6 -0
  51. package/package.json +163 -4
@@ -0,0 +1,80 @@
1
+ /** Locked public npm implementation files actually inspected and tested. */
2
+ export declare const nativeRetirementSdkSources: {
3
+ readonly cordis: {
4
+ readonly version: "4.0.4";
5
+ readonly files: {
6
+ readonly 'lib/index.js': "6a9394c0877ff45218818c6e815edd038f8057e1a1deb390a8d43ec81c57691e";
7
+ };
8
+ };
9
+ readonly 'dsh-session': {
10
+ readonly version: "0.2.0-rc.2";
11
+ readonly files: {
12
+ readonly 'lib/index.js': "87ea85e2fb5318bf1f826db9a1c88c1b26d3ea328027a7f32b211880c4d62b9d";
13
+ readonly 'lib/types/index.js': "71b3a3578b85704f026b590462e7d5e8bceb6dededd4e8782a83696138ec7da7";
14
+ };
15
+ };
16
+ readonly 'dsh-session-persistence': {
17
+ readonly version: "0.2.0-rc.2";
18
+ readonly files: {
19
+ readonly 'lib/index.js': "cc0b6d3a224133af611b428d5a49020e300f86c3b4ba28037aeb219029bde3eb";
20
+ };
21
+ };
22
+ readonly 'dsh-session-persistence-jsonl': {
23
+ readonly version: "0.2.0-rc.2";
24
+ readonly files: {
25
+ readonly 'lib/index.js': "0845707017acc2b4a8a75eab2244fa3fd88587b8094ab32014321dce7ca1e31b";
26
+ };
27
+ };
28
+ readonly 'dsh-session-format-catalog': {
29
+ readonly version: "0.2.0-rc.2";
30
+ readonly files: {
31
+ readonly 'lib/index.js': "836bbb772ab505c299f1a4a246164c50c7c08b67ab0d17f1251d7ea2cd8c1818";
32
+ readonly 'lib/types/index.js': "c7d797760bf2b9bc654751f2f8cb0b8a6b98998c8d9c1e41323c71a4d5f316f2";
33
+ };
34
+ };
35
+ readonly 'dsh-storage-domain': {
36
+ readonly version: "0.2.0-rc.2";
37
+ readonly files: {
38
+ readonly 'lib/index.js': "e536ba09b7ccc0f10bb54818dfe44454374e5cbf7aeba140b216ba1ca2e87517";
39
+ };
40
+ };
41
+ readonly 'dsh-storage-json': {
42
+ readonly version: "0.2.0-rc.2";
43
+ readonly files: {
44
+ readonly 'lib/index.js': "0a6b75d5569db3379edd93e863570170e1f4121b6c9fabd856f5b476cffe8df4";
45
+ };
46
+ };
47
+ readonly 'dsh-workspace': {
48
+ readonly version: "0.2.0-rc.2";
49
+ readonly files: {
50
+ readonly 'lib/index.js': "a33af459cfc7af29dd17412443a63655fd5037dd348b0dec20a413ce60c6c8bc";
51
+ readonly 'lib/types/index.js': "dbc8cc80e2b33c6bce07c73bd4e43be08af02051077ea9e032c2db2b9a154104";
52
+ };
53
+ };
54
+ readonly 'dsh-session-query': {
55
+ readonly version: "0.2.0-rc.2";
56
+ readonly files: {
57
+ readonly 'lib/index.js': "dd8056fad008063c7e85169d4306720abe8efa6b32eac98f1b3053c6f89894aa";
58
+ };
59
+ };
60
+ readonly 'dsh-session-query-sqlite': {
61
+ readonly version: "0.2.0-rc.2";
62
+ readonly files: {
63
+ readonly 'lib/index.js': "dbecf83320e10d93d735b3d01384ab817a0b90102ccecb0a22c013c71dfe70a0";
64
+ };
65
+ };
66
+ readonly 'dsh-session-projection-cache': {
67
+ readonly version: "0.2.0-rc.2";
68
+ readonly files: {
69
+ readonly 'lib/index.js': "797282e86a23ece3a6a6246765277ec00360813bc0bac0450caff8c56278db0b";
70
+ };
71
+ };
72
+ readonly 'dsh-api-session-controller': {
73
+ readonly version: "0.2.0-rc.2";
74
+ readonly files: {
75
+ readonly 'lib/index.js': "fb0f7b96130f595db20809eeb77a195b05f4a039f931d1e67692f1f74a4dd269";
76
+ readonly 'lib/types/index.js': "764de9dca8a029a3c874f8fe15b864de59b222666853319f0e5f16fe29909e9f";
77
+ };
78
+ };
79
+ };
80
+ export declare function nativeRetirementSdkFingerprint(): Promise<string | null>;
@@ -0,0 +1,12 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { NativeBinPort, NativeSessionState } from './module.js';
3
+ /** All native actions stay on public SDK methods; cold inspection claims no writer. */
4
+ export declare class DshBinPort implements NativeBinPort {
5
+ private readonly ctx;
6
+ constructor(ctx: Context);
7
+ archivedSessionIds(): readonly string[];
8
+ inspect(rawId: string): Promise<NativeSessionState>;
9
+ activity(rawId: string): Promise<string[]>;
10
+ archive(rawId: string): Promise<void>;
11
+ unarchive(rawId: string): Promise<void>;
12
+ }
@@ -0,0 +1,19 @@
1
+ import type { FileHandle } from 'node:fs/promises';
2
+ export type NativePlatform = 'darwin' | 'linux' | 'win32';
3
+ export declare function nativePlatformCandidate(platform?: NodeJS.Platform, arch?: NodeJS.Architecture): boolean;
4
+ /** Actual erasure evidence is promoted separately from an implemented Adapter. */
5
+ export declare function nativePlatformVerified(platform?: NodeJS.Platform, arch?: NodeJS.Architecture, node?: string, uv?: string): boolean;
6
+ /** Session namespace matches the audited JSONL writer; plugin ownership is independent. */
7
+ export declare function windowsSemaphoreName(path: string, purpose: 'session' | 'plugin'): string;
8
+ /** Same-volume rename whose metadata acknowledgement is written through. */
9
+ export declare function renameWindowsWriteThrough(source: string, destination: string): Promise<void>;
10
+ /** No lock file, expiry, or stale-PID deletion; the last kernel handle owns its lifetime. */
11
+ export declare function acquireWindowsSemaphore(path: string, purpose: 'session' | 'plugin'): Promise<() => Promise<void>>;
12
+ /** POSIX namespace durability. Windows callers must use their audited owner protocol. */
13
+ export declare function syncDirectory(path: string): Promise<void>;
14
+ export declare class RegularFileRefusal extends Error {
15
+ readonly code: 'platform/unsafe-file' | 'platform/file-changed' | 'platform/identity-unavailable';
16
+ constructor(code: 'platform/unsafe-file' | 'platform/file-changed' | 'platform/identity-unavailable', message: string);
17
+ }
18
+ /** Refuse symlinks and compare the opened identity even when O_NOFOLLOW is unavailable. */
19
+ export declare function openRegularFile(path: string, access: 'read' | 'write'): Promise<FileHandle>;
@@ -0,0 +1,32 @@
1
+ import { Context } from '@deepseek-ai/cordis';
2
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
3
+ import type { RemoteStream } from '@deepseek-ai/dsh-typert-protocol';
4
+ import type { BinSnapshot } from '../remote/contracts.js';
5
+ import type { ArchiveOperation, ArchivePlan as BinPlan, ArchiveResult as BinResult, ArchivePrepareRequest as PrepareRequest } from '../operations/archive.js';
6
+ import type { BinOperation } from '../operations/schema.js';
7
+ import type { PreparePurgeRequest, PurgePlan, PurgeResult, PurgeOperation } from '../operations/retirement.js';
8
+ /** Public strict Typert adapter; all native mutation stays in the existing Module. */
9
+ export declare class SessionBinRemote extends TypertRemoteService {
10
+ static inject: string[];
11
+ private readonly lifetime;
12
+ private readonly streams;
13
+ private closed;
14
+ constructor(ctx: Context);
15
+ prepare(request: PrepareRequest, signal: AbortSignal): Promise<BinPlan>;
16
+ execute(plan: BinPlan, signal: AbortSignal): Promise<BinResult>;
17
+ list(signal: AbortSignal): Promise<{
18
+ schemaVersion: 2;
19
+ sessionId: string;
20
+ entryId: string;
21
+ }[]>;
22
+ getOperation(operationId: string, signal: AbortSignal): Promise<ArchiveOperation | BinOperation | null>;
23
+ preparePurge(request: PreparePurgeRequest, signal: AbortSignal): Promise<PurgePlan>;
24
+ executePurge(input: PurgePlan, signal: AbortSignal): Promise<PurgeResult>;
25
+ getPurgeOperation(operationId: string, signal: AbortSignal): Promise<PurgeOperation | null>;
26
+ purgeOperations(signal: AbortSignal): Promise<PurgeOperation[]>;
27
+ follow(signal: AbortSignal): RemoteStream<BinSnapshot>;
28
+ private snapshots;
29
+ private call;
30
+ }
31
+ /** The parent Host calls this only after its SessionBin Module has initialized. */
32
+ export declare function installSessionBinRemote(ctx: Context): Promise<() => Promise<void>>;
@@ -0,0 +1,124 @@
1
+ import type { Domain } from '@deepseek-ai/dsh-storage-domain';
2
+ import type { RetirementCapabilities } from '../operations/retirement.js';
3
+ import type { RetirementOwnerRecord } from '../operations/retirement-owner.js';
4
+ export declare const retirementOwnerDomainSpec: {
5
+ readonly name: "session_bin_retirement_owner";
6
+ readonly version: 1;
7
+ readonly layout: "single";
8
+ readonly global: {
9
+ readonly schema: import("zod").ZodObject<{
10
+ schemaVersion: import("zod").ZodLiteral<1>;
11
+ capabilities: import("zod").ZodNullable<import("zod").ZodObject<{
12
+ protocolVersion: import("zod").ZodLiteral<1>;
13
+ ownerId: import("zod").ZodString;
14
+ hostVersion: import("zod").ZodString;
15
+ providerId: import("zod").ZodString;
16
+ storeId: import("zod").ZodString;
17
+ participants: import("zod").ZodArray<import("zod").ZodObject<{
18
+ id: import("zod").ZodString;
19
+ version: import("zod").ZodString;
20
+ }, import("zod/v4/core").$strict>>;
21
+ }, import("zod/v4/core").$strict>>;
22
+ }, import("zod/v4/core").$strict>;
23
+ readonly initial: {
24
+ readonly schemaVersion: 1;
25
+ readonly capabilities: null;
26
+ };
27
+ };
28
+ readonly tables: {
29
+ readonly operations: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, {
30
+ schemaVersion: 1;
31
+ state: {
32
+ schemaVersion: 1;
33
+ request: {
34
+ operationId: string;
35
+ expected: {
36
+ storeId: string;
37
+ sessionId: string;
38
+ lifecycleId: string;
39
+ };
40
+ bin: {
41
+ entryId: string;
42
+ entryVersion: 1;
43
+ } | {
44
+ kind: "native-archive";
45
+ entryId: string;
46
+ entryVersion: 2;
47
+ };
48
+ manifestDigest: string;
49
+ };
50
+ manifest: {
51
+ schemaVersion: 1;
52
+ lifecycle: {
53
+ storeId: string;
54
+ sessionId: string;
55
+ lifecycleId: string;
56
+ };
57
+ capabilities: {
58
+ protocolVersion: 1;
59
+ ownerId: string;
60
+ hostVersion: string;
61
+ providerId: string;
62
+ storeId: string;
63
+ participants: {
64
+ id: string;
65
+ version: string;
66
+ }[];
67
+ };
68
+ resources: {
69
+ ownerId: string;
70
+ resourceId: string;
71
+ revision: string;
72
+ kind: "transcript" | "workspace" | "index" | "cache" | "attachment" | "spill" | "coordination";
73
+ disposition: "erase" | "release-reference" | "retain-shared" | "retain-coordination";
74
+ retention: {
75
+ reason: "shared-reference" | "coordination-identity";
76
+ retainedBy: {
77
+ storeId: string;
78
+ sessionId: string;
79
+ lifecycleId: string;
80
+ }[];
81
+ } | null;
82
+ }[];
83
+ };
84
+ authorizationId: string | null;
85
+ phase: "rejected" | "conflict" | "done" | "fenced" | "quiesced" | "erasing" | "converging";
86
+ reason: string | null;
87
+ resources: {
88
+ ownerId: string;
89
+ resourceId: string;
90
+ status: "erased" | "reference-released" | "retained" | "failed";
91
+ reason: string | null;
92
+ }[];
93
+ };
94
+ participants: {
95
+ id: string;
96
+ version: string;
97
+ fenced: boolean;
98
+ quiesced: boolean;
99
+ converged: boolean;
100
+ }[];
101
+ lifecycleQuiesced: boolean;
102
+ lifecycleFinalized: boolean;
103
+ blockedReason: string | null;
104
+ }>;
105
+ };
106
+ };
107
+ export interface RetirementOwnerStore {
108
+ bindCapabilities(capabilities: RetirementCapabilities): Promise<void>;
109
+ operation(operationId: string): RetirementOwnerRecord | undefined;
110
+ operations(): RetirementOwnerRecord[];
111
+ putOperation(record: RetirementOwnerRecord): Promise<void>;
112
+ close(): Promise<void>;
113
+ }
114
+ export declare function sameRetirementCapabilities(a: RetirementCapabilities, b: RetirementCapabilities): boolean;
115
+ /** The caller must hold the composition's lifetime lease before opening this domain. */
116
+ export declare class DomainRetirementOwnerStore implements RetirementOwnerStore {
117
+ private readonly domain;
118
+ constructor(domain: Domain<typeof retirementOwnerDomainSpec>);
119
+ bindCapabilities(input: RetirementCapabilities): Promise<void>;
120
+ operation(operationId: string): RetirementOwnerRecord | undefined;
121
+ operations(): RetirementOwnerRecord[];
122
+ putOperation(input: RetirementOwnerRecord): Promise<void>;
123
+ close(): Promise<void>;
124
+ }
@@ -0,0 +1,124 @@
1
+ import { z } from 'zod';
2
+ import { retirementResourceReceiptSchema, retirementResourceSchema } from '../operations/retirement.js';
3
+ import type { LifecycleKey, RetirementAuthorization, RetirementCapabilities, RetirementManifest, RetirementRequest, RetirementState } from '../operations/retirement.js';
4
+ import type { RetirementOwnerRecord } from '../operations/retirement-owner.js';
5
+ import type { SessionRetirementOwnerV1 } from './retirement.js';
6
+ import type { RetirementOwnerStore } from './retirement-owner-store.js';
7
+ export type RetirementResource = z.infer<typeof retirementResourceSchema>;
8
+ export type RetirementResourceReceipt = z.infer<typeof retirementResourceReceiptSchema>;
9
+ export interface RetirementOwnerGuards {
10
+ /** Synchronous checks apply to retained handles and late writes as well as new opens. */
11
+ assertCanUse(lifecycle: LifecycleKey): void;
12
+ assertCanCreate(sessionId: string): void;
13
+ }
14
+ export interface RetirementLifecycleScope {
15
+ readonly lifecycle: LifecycleKey;
16
+ current(): Promise<LifecycleKey | null>;
17
+ activity(): Promise<string[]>;
18
+ /** false acknowledges a known pending barrier; throws mean unknown outcome. */
19
+ quiesce(request: RetirementRequest): Promise<boolean>;
20
+ finalize(request: RetirementRequest): Promise<boolean>;
21
+ release(): Promise<void>;
22
+ }
23
+ export interface RetirementLifecyclePort {
24
+ inspect(sessionId: string): Promise<LifecycleKey | null>;
25
+ /** Teardown disables these routes/retained references, rather than making them unguarded. */
26
+ bindGuards(guards: RetirementOwnerGuards): Promise<() => Promise<void>>;
27
+ /** A saved record grants maintenance access to exactly its retired lifecycle.
28
+ * Recovery must work after transcript removal/finalization without create/resume.
29
+ * Every acquire must restore current runtime exclusion/reservations for all
30
+ * participants; persisted quiescence acknowledgements are not live leases. */
31
+ acquire(expected: LifecycleKey, maintenance: RetirementOwnerRecord | null): Promise<RetirementLifecycleScope>;
32
+ }
33
+ export interface RetirementResourceParticipant {
34
+ readonly identity: {
35
+ id: string;
36
+ version: string;
37
+ };
38
+ bindGuards(guards: RetirementOwnerGuards): Promise<() => Promise<void>>;
39
+ manifest(expected: LifecycleKey): Promise<RetirementResource[]>;
40
+ fence(request: RetirementRequest): Promise<boolean>;
41
+ quiesce(request: RetirementRequest): Promise<boolean>;
42
+ /** Exact operation/resource/revision actions and all barriers are idempotent. */
43
+ applyResource(request: RetirementRequest, resource: RetirementResource): Promise<RetirementResourceReceipt>;
44
+ converge(request: RetirementRequest): Promise<boolean>;
45
+ }
46
+ export interface RetirementOwnerCheckpoint {
47
+ request: RetirementRequest;
48
+ manifest: RetirementManifest;
49
+ record: RetirementOwnerRecord | null;
50
+ resource: RetirementResource | null;
51
+ }
52
+ export interface RetirementOwnerCoordinatorOptions {
53
+ capabilities: RetirementCapabilities;
54
+ store: RetirementOwnerStore;
55
+ lifecycle: RetirementLifecyclePort;
56
+ participants: readonly RetirementResourceParticipant[];
57
+ /** A bounded worker may pause only after a durable acknowledgement; the fence remains. */
58
+ canAdvance?: (record: RetirementOwnerRecord) => boolean;
59
+ checkpoint?: (name: string, context: RetirementOwnerCheckpoint) => Promise<void> | void;
60
+ }
61
+ export declare class RetirementOwnerError extends Error {
62
+ readonly code: string;
63
+ constructor(code: string, message: string, options?: ErrorOptions);
64
+ }
65
+ /** Provider-neutral owner machinery. Ports must own the actual resources and
66
+ * admission paths; this class supplies no native deletion or private-file adapter. */
67
+ export declare class RetirementOwnerCoordinator implements SessionRetirementOwnerV1 {
68
+ private readonly options;
69
+ private readonly descriptor;
70
+ private readonly participants;
71
+ private tail;
72
+ private failure;
73
+ private ready;
74
+ private readonly frames;
75
+ private readonly activeFrames;
76
+ private readonly observations;
77
+ private closing;
78
+ private initializing;
79
+ private closePromise;
80
+ private readonly disposers;
81
+ private readonly expectedErrors;
82
+ readonly guards: RetirementOwnerGuards;
83
+ constructor(options: RetirementOwnerCoordinatorOptions);
84
+ initialize(): Promise<void>;
85
+ ownsCurrentMaintenanceFrame(): boolean;
86
+ isRefusal(error: unknown): boolean;
87
+ capabilities(): Promise<RetirementCapabilities>;
88
+ inspect(sessionId: string): Promise<LifecycleKey | null>;
89
+ prepare(input: LifecycleKey): Promise<RetirementManifest>;
90
+ getOperation(operationId: string): Promise<RetirementState | null>;
91
+ getRecord(operationId: string): RetirementOwnerRecord | undefined;
92
+ retire(input: RetirementRequest, authorize: () => Promise<RetirementAuthorization>, frozenInput?: RetirementManifest): Promise<RetirementState>;
93
+ recover(operationId: string): Promise<RetirementState>;
94
+ close(): Promise<void>;
95
+ private advance;
96
+ private emptyRecord;
97
+ private refusal;
98
+ private pending;
99
+ private manifest;
100
+ private validateFrozen;
101
+ private current;
102
+ private withScope;
103
+ private context;
104
+ private contextFor;
105
+ private checkpoint;
106
+ private canAdvance;
107
+ private barrier;
108
+ private save;
109
+ private records;
110
+ private validateJournal;
111
+ private verifyParticipants;
112
+ private capabilitiesSnapshot;
113
+ private known;
114
+ private unavailable;
115
+ private assertMaintenanceUse;
116
+ private assertUnfenced;
117
+ private rememberFailure;
118
+ private requireControlReady;
119
+ private requireReady;
120
+ private read;
121
+ private assertHealthy;
122
+ private call;
123
+ private enqueue;
124
+ }