@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,116 @@
1
+ import type { LocaleDictOf } from '@deepseek-ai/dsh-client-ui-slots';
2
+ export declare const NS = "dshSessionBin";
3
+ export declare const en: {
4
+ readonly title: "Session Bin";
5
+ readonly count: "{count} conversations";
6
+ readonly countOne: "{count} conversation";
7
+ readonly description: "Manage native archives with search, filters, unarchive, and explicit permanent deletion.";
8
+ readonly unarchive: "Unarchive";
9
+ readonly unarchiveSelected: "Unarchive selected";
10
+ readonly refresh: "Refresh";
11
+ readonly search: "Search archives";
12
+ readonly workspace: "Workspace filter";
13
+ readonly allWorkspaces: "All workspaces";
14
+ readonly ungrouped: "Ungrouped";
15
+ readonly unnamedWorkspace: "Untitled workspace";
16
+ readonly unnamed: "Untitled conversation";
17
+ readonly loading: "Loading archives…";
18
+ readonly empty: "No archived conversations";
19
+ readonly emptyHint: "Use Archive in the conversation menu to collect conversations here.";
20
+ readonly noMatches: "No matching conversations";
21
+ readonly noMatchesHint: "Try another search or workspace.";
22
+ readonly select: "Select {title}";
23
+ readonly selectAll: "Select visible conversations";
24
+ readonly selected: "{count} selected";
25
+ readonly clearSelection: "Clear selection";
26
+ readonly entries: "Archived conversations";
27
+ readonly unarchived: "Conversation unarchived";
28
+ readonly resultSuccess: "Unarchived";
29
+ readonly resultRejected: "Skipped";
30
+ readonly resultConflict: "State changed";
31
+ readonly resultPending: "Awaiting confirmation";
32
+ readonly results: "Latest operation results";
33
+ readonly pending: "{count} operation results need confirmation.";
34
+ readonly pendingOne: "{count} operation result needs confirmation.";
35
+ readonly checkPending: "Check and retry";
36
+ readonly checkResults: "Check results";
37
+ readonly connectionFailed: "Session Bin could not connect. Refresh to try again.";
38
+ readonly pendingResult: "The operation result is not confirmed yet. Check it before trying another action.";
39
+ readonly pendingDeletion: "Permanent deletion needs recovery before this conversation can be unarchived.";
40
+ readonly legacyPending: "An earlier Bin operation is awaiting a receipt. Checking only queries its result; it will not be replayed.";
41
+ readonly active: "This conversation has running work. Try again after it finishes.";
42
+ readonly stateChanged: "The conversation changed. Refresh and choose it again.";
43
+ readonly missing: "This conversation is no longer available.";
44
+ readonly notArchived: "This conversation is no longer archived.";
45
+ readonly operationFailed: "The operation could not finish. Refresh and try again.";
46
+ readonly retry: "Try again";
47
+ readonly permanentDelete: "Permanent delete";
48
+ readonly deleteConversation: "Permanently delete {title}";
49
+ readonly deleteTitle: "Permanently delete “{title}”?";
50
+ readonly deleteDescription: "Delete this one conversation’s logs and its session metadata and indexes. This cannot be undone.";
51
+ readonly deleteScope: "Shared attachments, independent forks, and copies in external tools are kept. Loaded conversations, retained readers, unknown files, and active writers can block deletion.";
52
+ readonly deletionAcknowledge: "I understand that this conversation cannot be restored.";
53
+ readonly cancelDeletion: "Cancel";
54
+ readonly confirmDeletion: "Delete permanently";
55
+ readonly closeDeletion: "Close confirmation";
56
+ readonly discardMissingDeletion: "Discard missing request";
57
+ readonly deletionBlockers: "Reasons deletion is blocked";
58
+ readonly deletionResults: "Permanent deletion results";
59
+ readonly deleted: "Conversation permanently deleted";
60
+ readonly checkDeletion: "Check deletion result";
61
+ readonly continueDeletion: "Continue same deletion";
62
+ readonly prepareDeletionAgain: "Prepare and confirm again";
63
+ readonly deletionPending: "Deletion is unfinished or its result is unknown. Check the saved operation before another action.";
64
+ readonly deletionMissing: "No matching deletion receipt was found. A fresh preparation and confirmation are required; deletion will not be replayed automatically.";
65
+ readonly deletionPartial: "Only part of the deletion is confirmed. The conversation remains protected until the same operation completes.";
66
+ readonly deletionUnsupported: "Permanent deletion is not supported by this Host and storage combination.";
67
+ readonly deletionLive: "This conversation is still loaded. Close its running work and let the Host release it before preparing deletion again.";
68
+ readonly deletionRetained: "A reader, subscription, or pending cache write still holds this conversation. Deletion remains blocked.";
69
+ readonly deletionWriter: "Another writer holds this conversation’s log. Wait for it to close before trying again.";
70
+ readonly deletionSubagent: "This conversation has subagent resources that cannot be deleted through this single-conversation operation.";
71
+ readonly deletionChanged: "The conversation lifecycle or confirmed resource scope changed. Prepare and confirm the target again.";
72
+ readonly deletionProtected: "The Host could not verify this conversation’s files or resources. Deletion remains blocked.";
73
+ readonly purgeCacheCapacity: "Local deletion records awaiting confirmation exceed capacity. Only check existing results; new deletions are temporarily disabled.";
74
+ readonly clearAllArchived: "Clear all archived ({count})";
75
+ readonly permanentlyDeleteSelected: "Permanently delete selected";
76
+ readonly batchSelectionTitle: "Permanently delete {count} selected conversations?";
77
+ readonly batchAllTitle: "Clear all {count} archived conversations?";
78
+ readonly batchPreparingDescription: "Preparing and checking each fixed target. Closing stops targets that have not started preparation.";
79
+ readonly batchConfirmDescription: "Review the fixed targets and resource scope before starting this irreversible batch.";
80
+ readonly batchRunningDescription: "Deletion runs one conversation at a time. Stop prevents unsent conversations; the current operation still finishes and remains protected.";
81
+ readonly closeBatchDeletion: "Close batch deletion";
82
+ readonly confirmBatchDeletion: "Delete executable conversations";
83
+ readonly stopBatchDeletion: "Stop remaining deletions";
84
+ readonly batchSummary: "{total} fixed · {executable} executable · {blocked} blocked";
85
+ readonly batchPreparationProgress: "Checked {prepared} of {total}";
86
+ readonly batchScope: "Executable conversations lose their logs, session metadata, and indexes permanently. Blocked conversations are not sent for deletion.";
87
+ readonly batchResources: "Combined resource scope";
88
+ readonly resourceErase: "Erase";
89
+ readonly resourceReleaseReference: "Release references";
90
+ readonly resourceRetainShared: "Keep shared";
91
+ readonly resourceRetainCoordination: "Keep coordination records";
92
+ readonly batchRetainedCopies: "Shared attachments, independent forks, and copies in external tools remain available.";
93
+ readonly batchItems: "Fixed deletion targets";
94
+ readonly batchAcknowledge: "I understand that executable conversations cannot be restored.";
95
+ readonly batchItemPreparing: "Checking deletion scope";
96
+ readonly batchItemReady: "Ready to delete";
97
+ readonly batchItemRunning: "Deletion in progress";
98
+ readonly batchItemCancelled: "Not sent";
99
+ readonly batchItemBlocked: "Blocked: {reason}";
100
+ readonly batchItemDeleted: "Permanently deleted";
101
+ readonly batchStatus: "Batch deletion status";
102
+ readonly batchPausedTitle: "Batch deletion paused";
103
+ readonly batchPausedDescription: "Review or handle the current operation first, then continue the remaining conversations.";
104
+ readonly batchDoneTitle: "Batch deletion complete";
105
+ readonly batchCancelledTitle: "Batch deletion stopped";
106
+ readonly batchOutcome: "{success} deleted · {unresolved} still needs attention";
107
+ readonly continueBatchDeletion: "Continue remaining";
108
+ readonly dismissBatchDeletion: "Dismiss batch results";
109
+ };
110
+ export type BinLocaleKey = keyof typeof en;
111
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
112
+ interface LocaleNamespaceMap {
113
+ dshSessionBin: BinLocaleKey;
114
+ }
115
+ }
116
+ export declare const zh: LocaleDictOf<typeof NS>;
@@ -0,0 +1,137 @@
1
+ import type { RemoteStream } from '@deepseek-ai/dsh-api-gateway/client';
2
+ import type { BinPlan } from '../operations/schema.js';
3
+ import type { ArchiveEntry, ArchivePlan, ArchiveResult } from '../operations/archive.js';
4
+ import type { PurgePlan } from '../operations/retirement.js';
5
+ import type { SessionBinRemoteApi, BinSnapshot } from '../remote/contracts.js';
6
+ import type { PurgeBatchScope, PurgeBatchState, PurgeClientOutcome } from './purge-batch.js';
7
+ export { retirementManifestDigest } from './retirement-digest.js';
8
+ export type { PurgeBatchItem, PurgeBatchScope, PurgeBatchState, PurgeClientOutcome } from './purge-batch.js';
9
+ export type PendingPlan = ArchivePlan | BinPlan;
10
+ export interface ClientOutcome {
11
+ sessionId: string;
12
+ entryId: string | null;
13
+ status: ArchiveResult['status'] | 'pending';
14
+ reason: string | null;
15
+ }
16
+ export interface BinNotice {
17
+ sequence: number;
18
+ kind: 'unarchived' | 'deleted' | 'failed';
19
+ sessionId: string;
20
+ entryId: string | null;
21
+ reason: string | null;
22
+ }
23
+ export interface PurgeConfirmation {
24
+ plan: PurgePlan;
25
+ title: string;
26
+ acknowledged: boolean;
27
+ }
28
+ export interface BinClientState {
29
+ phase: 'loading' | 'ready' | 'error';
30
+ entries: readonly ArchiveEntry[];
31
+ busy: readonly string[];
32
+ pending: readonly PendingPlan[];
33
+ results: readonly ClientOutcome[];
34
+ error: string | null;
35
+ notice: BinNotice | null;
36
+ purgeConfirmation: PurgeConfirmation | null;
37
+ purgePending: readonly PurgePlan[];
38
+ purgeResults: readonly PurgeClientOutcome[];
39
+ purgeBatch: PurgeBatchState | null;
40
+ purgeBatchOperationIds: readonly string[];
41
+ purgeCacheBlocked: boolean;
42
+ }
43
+ export interface PurgeGrantSnapshot {
44
+ operationId: string;
45
+ authorizationId: string;
46
+ }
47
+ export interface PurgeGrantObservationSnapshot {
48
+ operationId: string;
49
+ }
50
+ export interface PendingCache {
51
+ load(): unknown;
52
+ save(plans: readonly PendingPlan[]): void;
53
+ loadPurge?(): unknown;
54
+ savePurge?(plans: readonly PurgePlan[], batchOperationIds?: readonly string[]): void;
55
+ loadPurgeGrants?(): unknown;
56
+ savePurgeGrants?(grants: readonly PurgeGrantSnapshot[]): void;
57
+ loadPurgeGrantObservations?(): unknown;
58
+ stagePurgeGrantObservation?(operationId: string): void;
59
+ loadPurgeBatchOperations?(): unknown;
60
+ isPurgeCacheBlocked?(): boolean;
61
+ }
62
+ /** One browser page model; native mutations only pass through the Host API. */
63
+ export declare class SessionBinClientModel {
64
+ private readonly api;
65
+ private readonly createStream;
66
+ private readonly cache?;
67
+ private state;
68
+ private snapshot;
69
+ private readonly listeners;
70
+ private readonly lifetime;
71
+ private stream;
72
+ private consumption;
73
+ private epoch;
74
+ private noticeSequence;
75
+ private readonly checking;
76
+ private readonly purgeExecuting;
77
+ private readonly purgeChecking;
78
+ private purgeDiscovering;
79
+ private readonly settledPurgeIds;
80
+ private readonly observedPurgeGrants;
81
+ private readonly uncertainPurgeGrants;
82
+ private readonly unpersistedPurgeGrants;
83
+ private readonly batchPurgeOperationIds;
84
+ private confirmation;
85
+ private purgeBatch;
86
+ private purgeBatchRun;
87
+ private purgePreparationEpoch;
88
+ constructor(api: SessionBinRemoteApi, createStream: () => RemoteStream<BinSnapshot>, cache?: PendingCache | undefined);
89
+ getSnapshot: () => BinClientState;
90
+ subscribe: (listener: () => void) => (() => void);
91
+ private publish;
92
+ private persist;
93
+ private pending;
94
+ refresh(): Promise<void>;
95
+ dispose(): Promise<void>;
96
+ dismissNotice(): void;
97
+ private hasActivePurgeBatch;
98
+ private isPurgeCacheBlocked;
99
+ private rejectPurgeCacheCapacity;
100
+ private publishPurgeBatch;
101
+ private savePurgePending;
102
+ private persistPurgeGrants;
103
+ private stagePurgeGrantObservation;
104
+ private validatePurgeOwnerState;
105
+ private purgeOutcome;
106
+ private publishConfirmation;
107
+ private requestPurgePlan;
108
+ preparePurge(entry: Pick<ArchiveEntry, 'sessionId' | 'entryId'>, title: string): Promise<PurgePlan | null>;
109
+ acknowledgePurge(acknowledged: boolean): void;
110
+ cancelPurge(): void;
111
+ confirmPurge(): Promise<PurgeClientOutcome | undefined>;
112
+ preparePurgeBatch(scope: PurgeBatchScope, titlesBySessionId?: Readonly<Record<string, string>>): Promise<PurgeBatchState | null>;
113
+ acknowledgePurgeBatch(acknowledged: boolean): void;
114
+ runPurgeBatch(): Promise<PurgeBatchState | undefined>;
115
+ stopPurgeBatch(): void;
116
+ dismissPurgeBatch(): void;
117
+ private readPurgeOperation;
118
+ private discoverPurgePending;
119
+ /** Automatic checks and reload only observe; no missing or unfinished deletion is replayed. */
120
+ checkPurgePending(): Promise<void>;
121
+ /** Explicit continuation may only submit a known saved operation's original plan. */
122
+ retryPurge(operationId: string): Promise<PurgeClientOutcome | undefined>;
123
+ /** A confirmed missing operation requires fresh preparation and another explicit confirmation. */
124
+ preparePurgeAgain(operationId: string, title: string): Promise<PurgePlan | null>;
125
+ discardMissingPurge(operationId: string): Promise<boolean>;
126
+ private settlePurge;
127
+ private runPurge;
128
+ unarchive(entry: Pick<ArchiveEntry, 'sessionId' | 'entryId'>): Promise<ClientOutcome>;
129
+ unarchiveMany(entries: readonly ArchiveEntry[]): Promise<ClientOutcome[]>;
130
+ /** Baselines only query receipts. Explicit retry can resend the same missing
131
+ * v2 unarchive identity/plan; v1 bin/restore plans remain query-only forever.
132
+ */
133
+ checkPending(retryMissing?: boolean): Promise<void>;
134
+ private settle;
135
+ private run;
136
+ }
137
+ export declare function browserPendingCache(storage: Storage): PendingCache;
@@ -0,0 +1,45 @@
1
+ import type { PurgePlan, PurgeResult } from '../operations/retirement.js';
2
+ export type PurgeBatchScope = {
3
+ kind: 'selection';
4
+ entryIds: readonly string[];
5
+ } | {
6
+ kind: 'all-archived';
7
+ };
8
+ export interface PurgeClientOutcome {
9
+ operationId: string;
10
+ sessionId: string;
11
+ entryId: string | null;
12
+ status: PurgeResult['status'] | 'pending';
13
+ reason: string | null;
14
+ }
15
+ export interface PurgeBatchTarget {
16
+ sessionId: string;
17
+ entryId: string;
18
+ title: string;
19
+ }
20
+ export interface PurgeBatchItem {
21
+ target: PurgeBatchTarget;
22
+ state: 'preparing' | 'blocked' | 'ready' | 'running' | 'settled' | 'cancelled';
23
+ plan: PurgePlan | null;
24
+ reason: string | null;
25
+ outcome: PurgeClientOutcome | null;
26
+ }
27
+ export interface PurgeBatchResourceCounts {
28
+ erase: number;
29
+ releaseReference: number;
30
+ retainShared: number;
31
+ retainCoordination: number;
32
+ }
33
+ export interface PurgeBatchState {
34
+ batchId: string;
35
+ scope: 'selection' | 'all-archived';
36
+ phase: 'preparing' | 'confirming' | 'running' | 'paused' | 'done' | 'cancelled';
37
+ frozenCount: number;
38
+ acknowledged: boolean;
39
+ stopRequested: boolean;
40
+ items: PurgeBatchItem[];
41
+ resourceCounts: PurgeBatchResourceCounts;
42
+ }
43
+ export declare function emptyPurgeBatchResourceCounts(): PurgeBatchResourceCounts;
44
+ export declare function countPurgeBatchResources(items: readonly PurgeBatchItem[]): PurgeBatchResourceCounts;
45
+ export declare function clonePurgeBatch(batch: PurgeBatchState | null): PurgeBatchState | null;
@@ -0,0 +1,3 @@
1
+ import type { RetirementManifest } from '../operations/retirement.js';
2
+ export declare function canonicalRetirementManifest(input: RetirementManifest): string;
3
+ export declare function retirementManifestDigest(input: RetirementManifest): string;
@@ -0,0 +1,82 @@
1
+ import { z } from 'zod';
2
+ export declare const archiveEntrySchema: z.ZodObject<{
3
+ schemaVersion: z.ZodLiteral<2>;
4
+ sessionId: z.ZodString;
5
+ entryId: z.ZodUUID;
6
+ }, z.core.$strict>;
7
+ export declare const archivePlanSchema: z.ZodObject<{
8
+ schemaVersion: z.ZodLiteral<2>;
9
+ operationId: z.ZodString;
10
+ action: z.ZodLiteral<"unarchive">;
11
+ sessionId: z.ZodString;
12
+ expected: z.ZodObject<{
13
+ archived: z.ZodBoolean;
14
+ entryId: z.ZodNullable<z.ZodUUID>;
15
+ }, z.core.$strict>;
16
+ blockers: z.ZodArray<z.ZodObject<{
17
+ code: z.ZodString;
18
+ activity: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
+ }, z.core.$strict>>;
20
+ }, z.core.$strict>;
21
+ export declare const archiveResultSchema: z.ZodObject<{
22
+ operationId: z.ZodString;
23
+ action: z.ZodLiteral<"unarchive">;
24
+ sessionId: z.ZodString;
25
+ status: z.ZodEnum<{
26
+ success: "success";
27
+ rejected: "rejected";
28
+ conflict: "conflict";
29
+ }>;
30
+ reason: z.ZodNullable<z.ZodString>;
31
+ entryId: z.ZodNullable<z.ZodUUID>;
32
+ }, z.core.$strict>;
33
+ export declare const archiveOperationSchema: z.ZodObject<{
34
+ schemaVersion: z.ZodLiteral<2>;
35
+ plan: z.ZodObject<{
36
+ schemaVersion: z.ZodLiteral<2>;
37
+ operationId: z.ZodString;
38
+ action: z.ZodLiteral<"unarchive">;
39
+ sessionId: z.ZodString;
40
+ expected: z.ZodObject<{
41
+ archived: z.ZodBoolean;
42
+ entryId: z.ZodNullable<z.ZodUUID>;
43
+ }, z.core.$strict>;
44
+ blockers: z.ZodArray<z.ZodObject<{
45
+ code: z.ZodString;
46
+ activity: z.ZodOptional<z.ZodArray<z.ZodString>>;
47
+ }, z.core.$strict>>;
48
+ }, z.core.$strict>;
49
+ createdAt: z.ZodISODateTime;
50
+ phase: z.ZodEnum<{
51
+ intent: "intent";
52
+ applied: "applied";
53
+ done: "done";
54
+ }>;
55
+ entry: z.ZodNullable<z.ZodObject<{
56
+ schemaVersion: z.ZodLiteral<2>;
57
+ sessionId: z.ZodString;
58
+ entryId: z.ZodUUID;
59
+ }, z.core.$strict>>;
60
+ result: z.ZodNullable<z.ZodObject<{
61
+ operationId: z.ZodString;
62
+ action: z.ZodLiteral<"unarchive">;
63
+ sessionId: z.ZodString;
64
+ status: z.ZodEnum<{
65
+ success: "success";
66
+ rejected: "rejected";
67
+ conflict: "conflict";
68
+ }>;
69
+ reason: z.ZodNullable<z.ZodString>;
70
+ entryId: z.ZodNullable<z.ZodUUID>;
71
+ }, z.core.$strict>>;
72
+ }, z.core.$strict>;
73
+ export declare const archivePrepareRequestSchema: z.ZodObject<{
74
+ action: z.ZodLiteral<"unarchive">;
75
+ sessionId: z.ZodString;
76
+ operationId: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strict>;
78
+ export type ArchiveEntry = z.infer<typeof archiveEntrySchema>;
79
+ export type ArchivePlan = z.infer<typeof archivePlanSchema>;
80
+ export type ArchiveResult = z.infer<typeof archiveResultSchema>;
81
+ export type ArchiveOperation = z.infer<typeof archiveOperationSchema>;
82
+ export type ArchivePrepareRequest = z.infer<typeof archivePrepareRequestSchema>;