@whiteplusms/dsh-redis 0.0.0-stage → 0.1.3

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 (146) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +184 -2
  3. package/README.zh.md +185 -0
  4. package/cordis.patch.yml +4 -0
  5. package/icon.svg +1 -0
  6. package/lib/client/index.d.ts +4 -0
  7. package/lib/client.js +7684 -0
  8. package/lib/connection-errors.d.ts +66 -0
  9. package/lib/connection-errors.js +21 -0
  10. package/lib/domain.d.ts +451 -0
  11. package/lib/domain.js +20 -0
  12. package/lib/host/ai-answer.d.ts +7 -0
  13. package/lib/host/ai-answer.js +132 -0
  14. package/lib/host/ai-budget.d.ts +43 -0
  15. package/lib/host/ai-budget.js +78 -0
  16. package/lib/host/ai-connection-tools.d.ts +8 -0
  17. package/lib/host/ai-connection-tools.js +49 -0
  18. package/lib/host/ai-hash-filter.d.ts +13 -0
  19. package/lib/host/ai-hash-filter.js +97 -0
  20. package/lib/host/ai-hash-pages.d.ts +15 -0
  21. package/lib/host/ai-hash-pages.js +42 -0
  22. package/lib/host/ai-key-pages.d.ts +14 -0
  23. package/lib/host/ai-key-pages.js +27 -0
  24. package/lib/host/ai-locate-tool.d.ts +6 -0
  25. package/lib/host/ai-locate-tool.js +234 -0
  26. package/lib/host/ai-match-tools.d.ts +7 -0
  27. package/lib/host/ai-match-tools.js +112 -0
  28. package/lib/host/ai-page-coordinator.d.ts +21 -0
  29. package/lib/host/ai-page-coordinator.js +81 -0
  30. package/lib/host/ai-page-store.d.ts +40 -0
  31. package/lib/host/ai-page-store.js +104 -0
  32. package/lib/host/ai-profile-tools.d.ts +7 -0
  33. package/lib/host/ai-profile-tools.js +44 -0
  34. package/lib/host/ai-query-scope.d.ts +42 -0
  35. package/lib/host/ai-query-scope.js +104 -0
  36. package/lib/host/ai-reader.d.ts +219 -0
  37. package/lib/host/ai-reader.js +1221 -0
  38. package/lib/host/ai-report-samples.d.ts +26 -0
  39. package/lib/host/ai-report-samples.js +77 -0
  40. package/lib/host/ai-report-tools.d.ts +11 -0
  41. package/lib/host/ai-report-tools.js +70 -0
  42. package/lib/host/ai-set-pages.d.ts +15 -0
  43. package/lib/host/ai-set-pages.js +40 -0
  44. package/lib/host/ai-stream-pages.d.ts +15 -0
  45. package/lib/host/ai-stream-pages.js +42 -0
  46. package/lib/host/ai-tools.d.ts +4 -0
  47. package/lib/host/ai-tools.js +106 -0
  48. package/lib/host/ai-ui-tools.d.ts +10 -0
  49. package/lib/host/ai-ui-tools.js +72 -0
  50. package/lib/host/ai-value.d.ts +12 -0
  51. package/lib/host/ai-value.js +15 -0
  52. package/lib/host/ai-write-tools.d.ts +5 -0
  53. package/lib/host/ai-write-tools.js +101 -0
  54. package/lib/host/ai-writer.d.ts +25 -0
  55. package/lib/host/ai-writer.js +77 -0
  56. package/lib/host/ai-zset-pages.d.ts +15 -0
  57. package/lib/host/ai-zset-pages.js +40 -0
  58. package/lib/host/byte-identity.d.ts +3 -0
  59. package/lib/host/byte-identity.js +12 -0
  60. package/lib/host/client-list.d.ts +13 -0
  61. package/lib/host/client-list.js +35 -0
  62. package/lib/host/connection-service.d.ts +71 -0
  63. package/lib/host/connection-service.js +468 -0
  64. package/lib/host/database-reader.d.ts +10 -0
  65. package/lib/host/database-reader.js +62 -0
  66. package/lib/host/hash-reader.d.ts +12 -0
  67. package/lib/host/hash-reader.js +91 -0
  68. package/lib/host/key-reader.d.ts +20 -0
  69. package/lib/host/key-reader.js +65 -0
  70. package/lib/host/list-reader.d.ts +8 -0
  71. package/lib/host/list-reader.js +61 -0
  72. package/lib/host/match-preset-store.d.ts +36 -0
  73. package/lib/host/match-preset-store.js +201 -0
  74. package/lib/host/profile-snapshots.d.ts +32 -0
  75. package/lib/host/profile-snapshots.js +187 -0
  76. package/lib/host/profile-store.d.ts +15 -0
  77. package/lib/host/profile-store.js +120 -0
  78. package/lib/host/read-context.d.ts +23 -0
  79. package/lib/host/read-context.js +41 -0
  80. package/lib/host/redis-transport.d.ts +34 -0
  81. package/lib/host/redis-transport.js +262 -0
  82. package/lib/host/redis-write-transaction.d.ts +28 -0
  83. package/lib/host/redis-write-transaction.js +180 -0
  84. package/lib/host/resp.d.ts +38 -0
  85. package/lib/host/resp.js +174 -0
  86. package/lib/host/scan-cursors.d.ts +25 -0
  87. package/lib/host/scan-cursors.js +59 -0
  88. package/lib/host/selected-reader.d.ts +22 -0
  89. package/lib/host/selected-reader.js +84 -0
  90. package/lib/host/set-reader.d.ts +12 -0
  91. package/lib/host/set-reader.js +85 -0
  92. package/lib/host/stream-groups.d.ts +17 -0
  93. package/lib/host/stream-groups.js +42 -0
  94. package/lib/host/stream-reader.d.ts +12 -0
  95. package/lib/host/stream-reader.js +105 -0
  96. package/lib/host/string-reader.d.ts +9 -0
  97. package/lib/host/string-reader.js +81 -0
  98. package/lib/host/ui-action-channel.d.ts +4 -0
  99. package/lib/host/ui-action-channel.js +182 -0
  100. package/lib/host/ui-action-coordinator.d.ts +28 -0
  101. package/lib/host/ui-action-coordinator.js +188 -0
  102. package/lib/host/value-prefix.d.ts +5 -0
  103. package/lib/host/value-prefix.js +11 -0
  104. package/lib/host/write-bytes.d.ts +3 -0
  105. package/lib/host/write-bytes.js +9 -0
  106. package/lib/host/write-history.d.ts +18 -0
  107. package/lib/host/write-history.js +79 -0
  108. package/lib/host/write-proposals.d.ts +46 -0
  109. package/lib/host/write-proposals.js +132 -0
  110. package/lib/host/zset-reader.d.ts +12 -0
  111. package/lib/host/zset-reader.js +103 -0
  112. package/lib/host/zset-values.d.ts +6 -0
  113. package/lib/host/zset-values.js +26 -0
  114. package/lib/index.d.ts +6 -0
  115. package/lib/index.js +5 -0
  116. package/lib/redis-answer.d.ts +32 -0
  117. package/lib/redis-answer.js +215 -0
  118. package/lib/redis-databases.d.ts +3 -0
  119. package/lib/redis-databases.js +21 -0
  120. package/lib/redis-read-tools.d.ts +2 -0
  121. package/lib/redis-read-tools.js +7 -0
  122. package/lib/redis-result.d.ts +4 -0
  123. package/lib/redis-result.js +18 -0
  124. package/lib/redis-score.d.ts +2 -0
  125. package/lib/redis-score.js +6 -0
  126. package/lib/remote-service.d.ts +69 -0
  127. package/lib/remote-service.js +187 -0
  128. package/lib/runtime.d.ts +3 -0
  129. package/lib/runtime.js +29 -0
  130. package/lib/stream-id.d.ts +7 -0
  131. package/lib/stream-id.js +19 -0
  132. package/lib/typert.host.d.ts +13 -0
  133. package/lib/typert.host.js +7 -0
  134. package/lib/typert.remote-client.d.ts +98 -0
  135. package/lib/typert.remote-client.js +3 -0
  136. package/lib/typert.shared.d.ts +62 -0
  137. package/lib/typert.shared.js +735 -0
  138. package/lib/ui-action-selection.d.ts +3 -0
  139. package/lib/ui-action-selection.js +12 -0
  140. package/licenses/THIRD_PARTY_NOTICES.txt +9 -0
  141. package/licenses/deepseek-harness-MIT.txt +21 -0
  142. package/licenses/dsh-database-MIT.txt +21 -0
  143. package/licenses/dsh-git-graph-MIT.txt +21 -0
  144. package/licenses/lucide-react-LICENSE.txt +43 -0
  145. package/licenses/phosphor-icons-MIT.txt +21 -0
  146. package/package.json +132 -3
@@ -0,0 +1,66 @@
1
+ /** Key state explanations are shared by the sidebar and model results. */
2
+ export declare const keyStateMessages: {
3
+ readonly missing: {
4
+ readonly zh: "采样时该 Key 不存在。";
5
+ readonly en: "The key did not exist at the time of sampling.";
6
+ };
7
+ readonly changed: {
8
+ readonly zh: "Key 类型或内容已变化,请刷新。";
9
+ readonly en: "The key type or content has changed. Refresh the key.";
10
+ };
11
+ };
12
+ /** Shared explanations for the sidebar and model-facing tool results. */
13
+ export declare const connectionErrorMessages: {
14
+ readonly auth: {
15
+ readonly zh: "认证失败,请检查用户名和密码。";
16
+ readonly en: "Authentication failed. Check the username and password.";
17
+ };
18
+ readonly network: {
19
+ readonly zh: "无法连接 Redis,请检查地址、端口和服务状态。";
20
+ readonly en: "Cannot connect to Redis. Check the host, port and server.";
21
+ };
22
+ readonly timeout: {
23
+ readonly zh: "Redis 操作超时。请先刷新连接状态;连接已断开时手动重连,再缩小范围重试。";
24
+ readonly en: "Redis operation timed out. Refresh connection status first; reconnect manually if disconnected, then narrow the range and retry.";
25
+ };
26
+ readonly cancelled: {
27
+ readonly zh: "已取消等待,Redis 可能仍在处理。请先刷新连接状态,再手动重试。";
28
+ readonly en: "Stopped waiting; Redis may still be processing. Refresh connection status before retrying manually.";
29
+ };
30
+ readonly stale: {
31
+ readonly zh: "连接已变化,请查看当前状态后重试。";
32
+ readonly en: "The connection changed. Check its current state and retry.";
33
+ };
34
+ readonly 'tls-certificate': {
35
+ readonly zh: "TLS 证书验证失败,请检查 CA 和证书有效期。";
36
+ readonly en: "TLS certificate verification failed. Check the CA and certificate validity.";
37
+ };
38
+ readonly 'tls-hostname': {
39
+ readonly zh: "TLS 证书与连接地址不匹配,请检查主机名。";
40
+ readonly en: "TLS certificate does not match the connection address. Check the hostname.";
41
+ };
42
+ readonly permission: {
43
+ readonly zh: "Redis 账号无权执行此操作,请检查权限。";
44
+ readonly en: "The Redis account is not allowed to perform this operation.";
45
+ };
46
+ readonly oversize: {
47
+ readonly zh: "Redis 请求或回复超出安全读取范围,请缩小范围后重试。";
48
+ readonly en: "The Redis request or reply exceeds the safe read limit. Narrow the range and retry.";
49
+ };
50
+ readonly protocol: {
51
+ readonly zh: "无法解析 Redis 回复,请检查地址和服务类型。";
52
+ readonly en: "Cannot parse the Redis reply. Check the endpoint and service type.";
53
+ };
54
+ readonly busy: {
55
+ readonly zh: "读取队列已满。取消后可能仍需等待旧回复结束;请稍候、刷新连接状态后手动重试。";
56
+ readonly en: "Read queue is full. Cancelled reads may still be draining replies. Wait, refresh connection status, then retry manually.";
57
+ };
58
+ readonly database: {
59
+ readonly zh: "DB 编号超出服务器允许范围,请选择有效的 DB。";
60
+ readonly en: "The DB index is outside the server range. Choose a valid DB.";
61
+ };
62
+ readonly 'type-changed': {
63
+ readonly zh: "Key 类型已变化,请刷新。";
64
+ readonly en: "The key type changed. Refresh the key.";
65
+ };
66
+ };
@@ -0,0 +1,21 @@
1
+ /** Key state explanations are shared by the sidebar and model results. */
2
+ export const keyStateMessages = {
3
+ missing: { zh: '采样时该 Key 不存在。', en: 'The key did not exist at the time of sampling.' },
4
+ changed: { zh: 'Key 类型或内容已变化,请刷新。', en: 'The key type or content has changed. Refresh the key.' },
5
+ };
6
+ /** Shared explanations for the sidebar and model-facing tool results. */
7
+ export const connectionErrorMessages = {
8
+ auth: { zh: '认证失败,请检查用户名和密码。', en: 'Authentication failed. Check the username and password.' },
9
+ network: { zh: '无法连接 Redis,请检查地址、端口和服务状态。', en: 'Cannot connect to Redis. Check the host, port and server.' },
10
+ timeout: { zh: 'Redis 操作超时。请先刷新连接状态;连接已断开时手动重连,再缩小范围重试。', en: 'Redis operation timed out. Refresh connection status first; reconnect manually if disconnected, then narrow the range and retry.' },
11
+ cancelled: { zh: '已取消等待,Redis 可能仍在处理。请先刷新连接状态,再手动重试。', en: 'Stopped waiting; Redis may still be processing. Refresh connection status before retrying manually.' },
12
+ stale: { zh: '连接已变化,请查看当前状态后重试。', en: 'The connection changed. Check its current state and retry.' },
13
+ 'tls-certificate': { zh: 'TLS 证书验证失败,请检查 CA 和证书有效期。', en: 'TLS certificate verification failed. Check the CA and certificate validity.' },
14
+ 'tls-hostname': { zh: 'TLS 证书与连接地址不匹配,请检查主机名。', en: 'TLS certificate does not match the connection address. Check the hostname.' },
15
+ permission: { zh: 'Redis 账号无权执行此操作,请检查权限。', en: 'The Redis account is not allowed to perform this operation.' },
16
+ oversize: { zh: 'Redis 请求或回复超出安全读取范围,请缩小范围后重试。', en: 'The Redis request or reply exceeds the safe read limit. Narrow the range and retry.' },
17
+ protocol: { zh: '无法解析 Redis 回复,请检查地址和服务类型。', en: 'Cannot parse the Redis reply. Check the endpoint and service type.' },
18
+ busy: { zh: '读取队列已满。取消后可能仍需等待旧回复结束;请稍候、刷新连接状态后手动重试。', en: 'Read queue is full. Cancelled reads may still be draining replies. Wait, refresh connection status, then retry manually.' },
19
+ database: { zh: 'DB 编号超出服务器允许范围,请选择有效的 DB。', en: 'The DB index is outside the server range. Choose a valid DB.' },
20
+ 'type-changed': { zh: 'Key 类型已变化,请刷新。', en: 'The key type changed. Refresh the key.' },
21
+ };
@@ -0,0 +1,451 @@
1
+ /** Declared SDK baseline, not a runtime version probe. */
2
+ export declare const DSH_BASELINE: "0.2.2-rc.1";
3
+ export declare const PROTOCOL_VERSION: 16;
4
+ export type EmptyRequest = Record<string, never>;
5
+ /** Current conversation's AI result budget, without Redis contents. */
6
+ export interface AiBudgetStatus {
7
+ readonly callsUsed: number;
8
+ readonly maxCalls: number;
9
+ readonly bytesUsed: number;
10
+ readonly maxBytes: number;
11
+ readonly inFlight: number;
12
+ readonly stopped: boolean;
13
+ }
14
+ export interface AiBudgetResume {
15
+ readonly accepted: boolean;
16
+ readonly status: AiBudgetStatus;
17
+ }
18
+ /** Public Host status contains no connection credentials or Redis data. */
19
+ export interface RedisHostStatus {
20
+ readonly state: 'ready';
21
+ readonly sidebarReadOnly: true;
22
+ readonly aiWriteAvailable: true;
23
+ readonly dshBaseline: typeof DSH_BASELINE;
24
+ readonly protocolVersion: typeof PROTOCOL_VERSION;
25
+ }
26
+ /** Credentials are input-only and never appear in a public connection view. */
27
+ export interface ConnectionRequest {
28
+ readonly host: string;
29
+ readonly port: number;
30
+ readonly username: string;
31
+ readonly password: string;
32
+ /** User-supplied label; an absent label means the environment is unknown. */
33
+ readonly environment?: string;
34
+ readonly tls: {
35
+ readonly caPem: string;
36
+ } | null;
37
+ }
38
+ export interface ConnectionTarget {
39
+ readonly id: string;
40
+ readonly generation: number;
41
+ }
42
+ export type ConnectionErrorCode = 'auth' | 'network' | 'timeout' | 'cancelled' | 'stale' | 'tls-certificate' | 'tls-hostname' | 'permission' | 'oversize' | 'protocol' | 'busy' | 'database' | 'type-changed';
43
+ export interface ConnectionView {
44
+ readonly id: string | null;
45
+ readonly generation: number;
46
+ readonly db: number;
47
+ readonly state: 'connecting' | 'connected' | 'disconnected' | 'error';
48
+ readonly error: ConnectionErrorCode | null;
49
+ readonly target: {
50
+ readonly host: string;
51
+ readonly port: number;
52
+ readonly username: string;
53
+ readonly environment?: string;
54
+ readonly tls: boolean;
55
+ } | null;
56
+ }
57
+ /** Saved connection settings contain no password or live socket identity. */
58
+ export type ConnectionSettings = Omit<ConnectionRequest, 'password'>;
59
+ export interface SavedConnection {
60
+ readonly id: string;
61
+ readonly name: string;
62
+ readonly group?: string;
63
+ readonly settings: ConnectionSettings;
64
+ }
65
+ export interface SaveProfileRequest {
66
+ readonly id: string | null;
67
+ readonly name: string;
68
+ readonly group?: string;
69
+ readonly settings: ConnectionSettings;
70
+ }
71
+ export interface ProfileId {
72
+ readonly id: string;
73
+ }
74
+ export interface ProfileCollection {
75
+ readonly profiles: readonly SavedConnection[];
76
+ readonly selectedId: string | null;
77
+ }
78
+ export declare const MAX_PROFILES = 50;
79
+ export declare const MAX_INFO_BYTES: number;
80
+ /** DB and opaque scan cursors are bound to a Host-issued connection generation. */
81
+ export interface DatabaseTarget extends ConnectionTarget {
82
+ readonly db: number;
83
+ }
84
+ /** Write permission is scoped to the current session and exact connection. */
85
+ export interface RedisWriteModeRequest {
86
+ readonly target: DatabaseTarget;
87
+ readonly enabled: boolean;
88
+ }
89
+ export declare const MAX_REDIS_WRITE_BYTES = 4096;
90
+ export interface RedisWriteModeStatus {
91
+ readonly connection: ConnectionView;
92
+ readonly enabled: boolean;
93
+ }
94
+ export interface RedisWriteIdentity {
95
+ readonly type: 'string' | 'hash';
96
+ readonly keyBase64: string;
97
+ readonly fieldBase64: string | null;
98
+ }
99
+ export interface RedisWriteRecord {
100
+ readonly id: string;
101
+ readonly target: DatabaseTarget;
102
+ readonly identity: RedisWriteIdentity;
103
+ readonly state: 'pending' | 'submitting' | 'not-executed' | 'conflict' | 'rejected' | 'written-verified' | 'written-unverified' | 'written-mismatch' | 'unknown';
104
+ readonly startedAt: string;
105
+ readonly updatedAt: string;
106
+ readonly readbackAt: string | null;
107
+ }
108
+ export interface RedisWriteLookupRequest {
109
+ readonly id: string;
110
+ }
111
+ export interface RedisWriteLookupResult {
112
+ readonly record: RedisWriteRecord | null;
113
+ }
114
+ /** Current UI identity only; never cache cell values or credentials here. */
115
+ export type RedisSelectionItem = {
116
+ readonly kind: 'hash';
117
+ readonly fieldBase64: string;
118
+ } | {
119
+ readonly kind: 'list';
120
+ readonly index: string;
121
+ } | {
122
+ readonly kind: 'set';
123
+ readonly memberBase64: string;
124
+ } | {
125
+ readonly kind: 'zset';
126
+ readonly memberBase64: string;
127
+ } | {
128
+ readonly kind: 'stream';
129
+ readonly id: string;
130
+ readonly fieldIndex: number;
131
+ readonly fieldBase64: string;
132
+ };
133
+ export interface RedisSelection {
134
+ readonly keyBase64: string;
135
+ readonly item: RedisSelectionItem | null;
136
+ }
137
+ export interface SetSelectionRequest {
138
+ readonly target: DatabaseTarget;
139
+ readonly selection: RedisSelection | null;
140
+ }
141
+ export interface SelectionAck {
142
+ readonly accepted: boolean;
143
+ }
144
+ /** UI action frames contain identities only, never Redis values or credentials. */
145
+ export type UiActionOutcome = 'applied' | 'unknown' | 'unsupported' | 'failed' | 'stale' | 'cancelled' | 'timeout' | 'disconnected' | 'no_receiver' | 'ambiguous' | 'busy';
146
+ export type UiAction = {
147
+ readonly kind: 'show';
148
+ } | {
149
+ readonly kind: 'confirmSelection';
150
+ } | {
151
+ readonly kind: 'refresh';
152
+ readonly target: DatabaseTarget;
153
+ readonly keyBase64: string;
154
+ } | {
155
+ readonly kind: 'applyMatch';
156
+ readonly target: DatabaseTarget;
157
+ readonly pattern: string;
158
+ } | {
159
+ readonly kind: 'setFormat';
160
+ readonly keyBase64: string;
161
+ readonly format: PreviewFormat;
162
+ } | {
163
+ readonly kind: 'selectKey';
164
+ readonly key: RedisKey;
165
+ } | {
166
+ readonly kind: 'selectHashField';
167
+ readonly keyBase64: string;
168
+ readonly field: RedisKey;
169
+ } | {
170
+ readonly kind: 'selectListIndex';
171
+ readonly keyBase64: string;
172
+ readonly index: string;
173
+ } | {
174
+ readonly kind: 'selectSetMember';
175
+ readonly keyBase64: string;
176
+ readonly member: RedisKey;
177
+ } | {
178
+ readonly kind: 'selectZSetMember';
179
+ readonly keyBase64: string;
180
+ readonly member: RedisKey;
181
+ } | {
182
+ readonly kind: 'selectStreamField';
183
+ readonly keyBase64: string;
184
+ readonly id: string;
185
+ readonly fieldIndex: number;
186
+ readonly fieldBase64: string;
187
+ };
188
+ export interface UiActionRequest<Action> {
189
+ readonly requestId: string;
190
+ readonly action: Action;
191
+ readonly target: DatabaseTarget | null;
192
+ readonly selectionRevision: number;
193
+ readonly expiresAt: number;
194
+ }
195
+ export interface UiActionAck {
196
+ readonly requestId: string;
197
+ readonly target: DatabaseTarget | null;
198
+ readonly selectionRevision: number;
199
+ readonly outcome: 'applied' | 'unsupported' | 'failed' | 'stale' | 'ambiguous';
200
+ }
201
+ export type UiChannelInput = UiActionAck | {
202
+ readonly kind: 'selection';
203
+ readonly revision: number;
204
+ readonly synchronized: boolean;
205
+ } | {
206
+ readonly kind: 'publishSelection';
207
+ readonly requestId: string;
208
+ readonly revision: number;
209
+ readonly request: SetSelectionRequest;
210
+ readonly actionRequestId?: string;
211
+ } | {
212
+ readonly kind: 'commitSelection';
213
+ readonly requestId: string;
214
+ readonly revision: number;
215
+ readonly nextRevision: number;
216
+ };
217
+ export type UiChannelMessage = {
218
+ readonly kind: 'action';
219
+ readonly request: UiActionRequest<UiAction>;
220
+ } | {
221
+ readonly kind: 'cancel';
222
+ readonly requestId: string;
223
+ } | {
224
+ readonly kind: 'selectionResult';
225
+ readonly requestId: string;
226
+ readonly accepted: boolean;
227
+ };
228
+ export interface ScanKeysRequest {
229
+ readonly target: DatabaseTarget;
230
+ readonly pattern: string;
231
+ readonly cursor: string | null;
232
+ }
233
+ export interface RedisKey {
234
+ readonly base64: string;
235
+ readonly byteLength: number;
236
+ readonly label: string;
237
+ }
238
+ export interface ScanKeysResult {
239
+ readonly state: 'page' | 'failed';
240
+ readonly error: ConnectionErrorCode | null;
241
+ readonly keys: readonly RedisKey[];
242
+ readonly cursor: string | null;
243
+ readonly sampledAt: string;
244
+ }
245
+ /** Read-only DB directory. Null means metadata is unavailable, never an empty DB. */
246
+ export interface DatabaseKeyCount {
247
+ readonly db: number;
248
+ readonly keys: string;
249
+ }
250
+ export interface DatabaseCatalog {
251
+ readonly databaseCount: number | null;
252
+ readonly keyspace: readonly DatabaseKeyCount[] | null;
253
+ readonly currentKeys: string | null;
254
+ }
255
+ export interface DatabasesReadRequest {
256
+ readonly target: DatabaseTarget;
257
+ }
258
+ export interface DatabasesReadResult {
259
+ readonly state: 'value' | 'failed';
260
+ readonly error: ConnectionErrorCode | null;
261
+ readonly catalog: DatabaseCatalog | null;
262
+ readonly sampledAt: string;
263
+ }
264
+ export declare const MAX_DATABASE_ENTRIES = 4096;
265
+ export declare const MAX_KEY_BYTES = 65536;
266
+ export declare const MAX_SCAN_KEYS = 4096;
267
+ export declare const MAX_SCAN_JSON_BYTES: number;
268
+ export declare const MAX_CACHED_KEYS = 5000;
269
+ export declare const MAX_CACHED_KEY_BYTES: number;
270
+ /** Integer text preserves Redis's signed-64-bit positions and millisecond TTLs. */
271
+ export interface StringReadRequest {
272
+ readonly target: DatabaseTarget;
273
+ readonly keyBase64: string;
274
+ readonly offset: string;
275
+ readonly count: number;
276
+ }
277
+ export interface KeyMetadata {
278
+ readonly type: string;
279
+ readonly ttlMs: string;
280
+ readonly length: string | null;
281
+ }
282
+ export interface StringReadResult {
283
+ readonly state: 'value' | 'missing' | 'unsupported' | 'changed' | 'failed';
284
+ readonly error: ConnectionErrorCode | null;
285
+ readonly metadata: KeyMetadata | null;
286
+ readonly offset: string;
287
+ readonly base64: string;
288
+ readonly byteLength: number;
289
+ readonly prefix: string;
290
+ readonly suffix: string;
291
+ readonly complete: boolean;
292
+ readonly nextOffset: string | null;
293
+ readonly sampledAt: string;
294
+ }
295
+ export declare const MAX_VALUE_BYTES = 65536;
296
+ /** HSCAN returns whole values; the wire frame is bounded before decoding, while
297
+ * only this prefix is sent to the UI. A prefix is never a full-value identity.
298
+ */
299
+ export interface BytePrefix {
300
+ readonly base64: string;
301
+ readonly byteLength: number;
302
+ readonly fullByteLength: number;
303
+ readonly suffix: string;
304
+ }
305
+ export interface HashEntry {
306
+ readonly field: RedisKey;
307
+ readonly value: BytePrefix;
308
+ }
309
+ export interface ScanHashRequest {
310
+ readonly target: DatabaseTarget;
311
+ readonly keyBase64: string;
312
+ readonly pattern: string;
313
+ readonly cursor: string | null;
314
+ }
315
+ /** A direct Hash field sample is separate from HSCAN and its pagination state. */
316
+ export interface HashFieldReadRequest {
317
+ readonly target: DatabaseTarget;
318
+ readonly keyBase64: string;
319
+ readonly fieldBase64: string;
320
+ }
321
+ export interface ActionPointReadResult {
322
+ readonly state: 'value' | 'selection-missing' | 'missing' | 'changed' | 'failed';
323
+ readonly error: ConnectionErrorCode | null;
324
+ readonly cell: BytePrefix | null;
325
+ readonly score: string | null;
326
+ readonly streamMessage: StreamMessage | null;
327
+ readonly sampledAt: string;
328
+ }
329
+ /** A UI action samples only the exact item held by its Host-owned request. */
330
+ export interface ActionPointReadRequest {
331
+ readonly requestId: string;
332
+ }
333
+ export interface ScanHashResult {
334
+ readonly state: 'page' | 'missing' | 'unsupported' | 'changed' | 'failed';
335
+ readonly error: ConnectionErrorCode | null;
336
+ readonly metadata: KeyMetadata | null;
337
+ readonly entries: readonly HashEntry[];
338
+ readonly cursor: string | null;
339
+ readonly sampledAt: string;
340
+ }
341
+ /** A List row is identified by its original zero-based position, not its value. */
342
+ export interface ListReadRequest {
343
+ readonly target: DatabaseTarget;
344
+ readonly keyBase64: string;
345
+ readonly offset: string;
346
+ readonly count: number;
347
+ }
348
+ export interface ListEntry {
349
+ readonly index: string;
350
+ readonly value: BytePrefix;
351
+ }
352
+ export interface ListReadResult {
353
+ readonly state: 'page' | 'missing' | 'unsupported' | 'changed' | 'failed';
354
+ readonly error: ConnectionErrorCode | null;
355
+ readonly metadata: KeyMetadata | null;
356
+ readonly entries: readonly ListEntry[];
357
+ readonly offset: string;
358
+ readonly nextOffset: string | null;
359
+ readonly sampledAt: string;
360
+ }
361
+ export declare const MAX_LIST_ITEMS = 100;
362
+ /** Members use the same complete raw-byte identity as keys and Hash fields.
363
+ * Oversized identities are refused, never silently replaced by a prefix.
364
+ */
365
+ export interface ScanSetRequest {
366
+ readonly target: DatabaseTarget;
367
+ readonly keyBase64: string;
368
+ readonly pattern: string;
369
+ readonly cursor: string | null;
370
+ }
371
+ /** A direct membership sample never advances the Set scan. */
372
+ export interface SetMemberReadRequest {
373
+ readonly target: DatabaseTarget;
374
+ readonly keyBase64: string;
375
+ readonly memberBase64: string;
376
+ }
377
+ export interface ScanSetResult {
378
+ readonly state: 'page' | 'missing' | 'unsupported' | 'changed' | 'failed';
379
+ readonly error: ConnectionErrorCode | null;
380
+ readonly metadata: KeyMetadata | null;
381
+ readonly members: readonly RedisKey[];
382
+ readonly cursor: string | null;
383
+ readonly sampledAt: string;
384
+ }
385
+ /** Rank intervals are ascending score order; scan pages have no rank or sort. */
386
+ export type ZSetReadRequest = {
387
+ readonly target: DatabaseTarget;
388
+ readonly keyBase64: string;
389
+ readonly mode: 'range';
390
+ readonly offset: string;
391
+ readonly count: number;
392
+ } | {
393
+ readonly target: DatabaseTarget;
394
+ readonly keyBase64: string;
395
+ readonly mode: 'scan';
396
+ readonly pattern: string;
397
+ readonly cursor: string | null;
398
+ };
399
+ export interface ZSetEntry {
400
+ readonly member: RedisKey;
401
+ readonly score: string;
402
+ readonly rank: string | null;
403
+ }
404
+ export interface ZSetReadResult {
405
+ readonly state: 'page' | 'missing' | 'unsupported' | 'changed' | 'failed';
406
+ readonly error: ConnectionErrorCode | null;
407
+ readonly metadata: KeyMetadata | null;
408
+ readonly mode: 'range' | 'scan';
409
+ readonly entries: readonly ZSetEntry[];
410
+ readonly offset: string | null;
411
+ readonly nextOffset: string | null;
412
+ readonly cursor: string | null;
413
+ readonly sampledAt: string;
414
+ }
415
+ /** Fields stay in ordered pairs: repeated names are distinct occurrences. */
416
+ export interface StreamField {
417
+ readonly field: RedisKey;
418
+ readonly value: BytePrefix;
419
+ }
420
+ export interface StreamMessage {
421
+ readonly id: string;
422
+ readonly fields: readonly StreamField[];
423
+ }
424
+ export interface StreamReadRequest {
425
+ readonly target: DatabaseTarget;
426
+ readonly keyBase64: string;
427
+ readonly direction: 'forward' | 'reverse';
428
+ readonly start: string;
429
+ readonly end: string;
430
+ readonly count: number;
431
+ readonly cursor: string | null;
432
+ }
433
+ export interface StreamReadResult {
434
+ readonly state: 'page' | 'missing' | 'unsupported' | 'changed' | 'failed';
435
+ readonly error: ConnectionErrorCode | null;
436
+ readonly metadata: KeyMetadata | null;
437
+ readonly direction: 'forward' | 'reverse';
438
+ readonly start: string;
439
+ readonly end: string;
440
+ readonly messages: readonly StreamMessage[];
441
+ readonly cursor: string | null;
442
+ readonly sampledAt: string;
443
+ }
444
+ export declare const MAX_STREAM_MESSAGES = 100;
445
+ /** UI preferences belong to the trusted Host session, never to a live socket.
446
+ * Only selections survive a sidebar remount; values, credentials and cursors do not.
447
+ */
448
+ export declare const PREVIEW_FORMATS: readonly ["text", "json", "hex", "base64"];
449
+ export type PreviewFormat = typeof PREVIEW_FORMATS[number];
450
+ export declare const PREVIEW_VIEWS: readonly ["string", "hash", "list", "set", "zset", "stream"];
451
+ export type PreviewView = typeof PREVIEW_VIEWS[number];
package/lib/domain.js ADDED
@@ -0,0 +1,20 @@
1
+ /** Declared SDK baseline, not a runtime version probe. */
2
+ export const DSH_BASELINE = '0.2.2-rc.1';
3
+ export const PROTOCOL_VERSION = 16;
4
+ export const MAX_PROFILES = 50;
5
+ export const MAX_INFO_BYTES = 128 * 1024;
6
+ export const MAX_REDIS_WRITE_BYTES = 4096;
7
+ export const MAX_DATABASE_ENTRIES = 4096;
8
+ export const MAX_KEY_BYTES = 65536;
9
+ export const MAX_SCAN_KEYS = 4096;
10
+ export const MAX_SCAN_JSON_BYTES = 1024 * 1024;
11
+ export const MAX_CACHED_KEYS = 5000;
12
+ export const MAX_CACHED_KEY_BYTES = 2 * 1024 * 1024;
13
+ export const MAX_VALUE_BYTES = 65536;
14
+ export const MAX_LIST_ITEMS = 100;
15
+ export const MAX_STREAM_MESSAGES = 100;
16
+ /** UI preferences belong to the trusted Host session, never to a live socket.
17
+ * Only selections survive a sidebar remount; values, credentials and cursors do not.
18
+ */
19
+ export const PREVIEW_FORMATS = ['text', 'json', 'hex', 'base64'];
20
+ export const PREVIEW_VIEWS = ['string', 'hash', 'list', 'set', 'zset', 'stream'];
@@ -0,0 +1,7 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { RedisAiReader } from './ai-reader.js';
3
+ /** Consume committed session events, never model-supplied copies of Redis data.
4
+ * This bounded, turn-local index holds no cursor or query state. The final answer
5
+ * is persisted by DSH like any other tool result, so replay needs no live cache.
6
+ */
7
+ export declare function registerRedisAnswerTool(ctx: Context, reader: RedisAiReader): void;