@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
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ /** Loader entry. Browser modules are discovered separately by DSH. */
2
+ export const name = '@whiteplusms/dsh-redis';
3
+ export const inject = ['profileContext', 'tools', 'agents'];
4
+ export { apply } from "./runtime.js";
5
+ export { RedisRemoteService } from "./remote-service.js";
@@ -0,0 +1,32 @@
1
+ export interface RedisAnswerSection {
2
+ readonly callId: string;
3
+ readonly tool: string;
4
+ readonly paragraphs: readonly string[];
5
+ readonly values: readonly {
6
+ readonly label: string;
7
+ readonly text: string;
8
+ }[];
9
+ }
10
+ /** Link only actual continuation pages. Equal conditions alone do not identify
11
+ * one iteration: a restarted query must not be added to its predecessor.
12
+ */
13
+ export declare function summarizeRedisFilters(records: readonly {
14
+ readonly callId: string;
15
+ readonly inputCursor: string | null | undefined;
16
+ readonly result: Record<string, unknown>;
17
+ }[]): Map<string, {
18
+ paragraphs: string[];
19
+ values: {
20
+ label: string;
21
+ text: string;
22
+ }[];
23
+ }>;
24
+ /** Validate persisted display data before rendering; Redis strings stay escaped text. */
25
+ export declare function parseRedisAnswer(raw: string): readonly RedisAnswerSection[] | null;
26
+ export declare function describeRedisResult(tool: string, data: Record<string, unknown>): {
27
+ paragraphs: string[];
28
+ values: {
29
+ label: string;
30
+ text: string;
31
+ }[];
32
+ };
@@ -0,0 +1,215 @@
1
+ /** Chinese answers are projections of one recorded result, not model assertions.
2
+ * Values remain JSON/plain text: never execute content or parse JSON.GET numbers.
3
+ */
4
+ function object(value) {
5
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : {};
6
+ }
7
+ function text(value) { return typeof value === 'string' ? value : null; }
8
+ function identity(value) {
9
+ const data = object(value), label = text(data.label);
10
+ // Display labels can be shortened or hexadecimal previews; preserve the full
11
+ // identity for those cases instead of treating a preview as the actual key.
12
+ return label !== null && !label.endsWith('…') && !label.startsWith('0x') ? label : `Base64 ${JSON.stringify(data.base64 ?? value)}`;
13
+ }
14
+ /** Link only actual continuation pages. Equal conditions alone do not identify
15
+ * one iteration: a restarted query must not be added to its predecessor.
16
+ */
17
+ export function summarizeRedisFilters(records) {
18
+ const names = ['checked', 'matched', 'different', 'missingField', 'missingKey', 'notHash', 'typeChanged', 'failed'];
19
+ const pending = new Map(), groups = [];
20
+ for (const record of records) {
21
+ const data = record.result, counts = object(data.counts), condition = object(data.condition);
22
+ if (record.inputCursor === undefined || data.state !== 'page' || typeof data.pattern !== 'string' || typeof condition.field !== 'string' || typeof condition.equals !== 'string' || !Array.isArray(data.matches) || !names.every(name => Number.isSafeInteger(counts[name]) && Number(counts[name]) >= 0))
23
+ continue;
24
+ const binding = JSON.stringify([data.pattern, condition.field, condition.equals]);
25
+ let group = record.inputCursor === null ? undefined : pending.get(record.inputCursor);
26
+ if (group?.binding !== binding)
27
+ group = undefined;
28
+ if (record.inputCursor !== null)
29
+ pending.delete(record.inputCursor);
30
+ if (group === undefined) {
31
+ group = { binding, first: record.inputCursor === null, pages: 0, counts: { checked: 0, matched: 0, different: 0, missingField: 0, missingKey: 0, notHash: 0, typeChanged: 0, failed: 0 }, matches: new Map(), callId: record.callId, ended: false };
32
+ groups.push(group);
33
+ }
34
+ group.pages++;
35
+ group.callId = record.callId;
36
+ group.ended = data.scanComplete === true && data.cursor === null;
37
+ for (const name of names)
38
+ group.counts[name] += Number(counts[name]);
39
+ for (const match of data.matches) {
40
+ const key = object(match);
41
+ if (typeof key.base64 === 'string')
42
+ group.matches.set(key.base64, match);
43
+ }
44
+ if (typeof data.cursor === 'string')
45
+ pending.set(data.cursor, group);
46
+ }
47
+ return new Map(groups.map(group => [group.callId, {
48
+ paragraphs: [`${group.first && group.ended ? '本次迭代' : '本轮已记录的连续批次'}汇总:${group.pages} 批,累计检查 ${group.counts.checked} 次,匹配 ${group.counts.matched} 次,匹配 Key 去重后 ${group.matches.size} 个;非 Hash ${group.counts.notHash} 次,缺字段 ${group.counts.missingField} 次,读取失败 ${group.counts.failed} 次。`, '累计计数包含跨批重复检查;去重名称仅代表实际返回的匹配,SCAN 不是一致性快照。'],
49
+ values: [{ label: '累计分类计数(检查次数)', text: JSON.stringify(group.counts, null, 2) }, { label: '已返回匹配 Key(去重)', text: JSON.stringify([...group.matches.values()], null, 2) }],
50
+ }]));
51
+ }
52
+ /** Validate persisted display data before rendering; Redis strings stay escaped text. */
53
+ export function parseRedisAnswer(raw) {
54
+ if (raw.length > 65536)
55
+ return null;
56
+ let parsed;
57
+ try {
58
+ parsed = JSON.parse(raw);
59
+ }
60
+ catch {
61
+ return null;
62
+ }
63
+ const data = object(parsed);
64
+ if (data.readOnly !== true || data.state !== 'answered' || !Array.isArray(data.answers) || data.answers.length < 1 || data.answers.length > 32)
65
+ return null;
66
+ const answers = [];
67
+ for (const entry of data.answers) {
68
+ const item = object(entry);
69
+ if (typeof item.callId !== 'string' || typeof item.tool !== 'string' || !Array.isArray(item.paragraphs) || !item.paragraphs.every((value) => typeof value === 'string') || !Array.isArray(item.values))
70
+ return null;
71
+ const values = [];
72
+ for (const rawValue of item.values) {
73
+ const value = object(rawValue);
74
+ if (typeof value.label !== 'string' || typeof value.text !== 'string')
75
+ return null;
76
+ values.push({ label: value.label, text: value.text });
77
+ }
78
+ answers.push({ callId: item.callId, tool: item.tool, paragraphs: item.paragraphs, values });
79
+ }
80
+ return answers;
81
+ }
82
+ export function describeRedisResult(tool, data) {
83
+ if (data.kind === 'ui-receipt') {
84
+ const receipt = object(data.receipt), connection = object(data.connection), endpoint = object(connection.target);
85
+ return {
86
+ paragraphs: [typeof endpoint.host === 'string' ? `操作发起时的连接目标:${JSON.stringify(endpoint.host)}:${String(endpoint.port)};DB ${String(connection.db)}。` : '操作发起时尚未连接 Redis。', text(receipt.message) ?? '界面操作结果见回执。', ...(tool === 'redis_viewer_show' && receipt.outcome === 'applied' ? ['打开已连接面板可能自动加载 DB 与 Key 名称;此回执不证明没有发生名称扫描。'] : []), '此处记录界面动作回执,不把它当作当前 Redis 值、连接状态或故障根因的采样。'],
87
+ values: [{ label: '界面回执', text: JSON.stringify(receipt, null, 2) }],
88
+ };
89
+ }
90
+ const value = object(data.value), metadata = object(data.metadata ?? value.metadata), connection = object(data.connection);
91
+ const state = text(data.state ?? value.state), type = text(data.type ?? value.type ?? metadata.type);
92
+ // Failure envelopes also carry complete=false / scanComplete=false. Those
93
+ // flags do not mean that data was delivered or that continuation is possible.
94
+ const hasResult = state === 'value' || state === 'page' || state === 'partial';
95
+ const paragraphs = [], values = [];
96
+ const add = (label, content) => { if (content !== undefined)
97
+ values.push({ label, text: JSON.stringify(content, null, 2) }); };
98
+ const target = data.key === undefined ? (data.source === 'selection' ? '读取时的侧栏选择' : '本次查询') : `Key ${identity(data.key)}`;
99
+ const time = text(data.sampledAt ?? value.sampledAt);
100
+ const endpoint = object(connection.target);
101
+ paragraphs.push(`${typeof endpoint.host === 'string' ? `${JSON.stringify(endpoint.host)}:${String(endpoint.port)};` : ''}${data.scope === 'server' ? '服务器范围' : `DB ${String(connection.db)}`};${time === null ? '采样时间见各项记录' : `采样时间 ${time}`}。`);
102
+ if (data.source === 'explicit')
103
+ paragraphs.push('按明确指定的目标读取。');
104
+ if (data.source === 'selection')
105
+ paragraphs.push('按读取时确认的侧栏选择读取;之后的选择变化不改变这份记录。');
106
+ const failure = text(data.errorMessage);
107
+ if (data.key !== undefined && !['redis_viewer_value', 'redis_viewer_key_metadata', 'redis_viewer_memory'].includes(tool))
108
+ paragraphs.push(`查询目标:${target}。`);
109
+ if (tool === 'redis_viewer_geo') {
110
+ if (data.member !== undefined)
111
+ paragraphs.push(`成员:${identity(data.member)}。`);
112
+ if (data.other !== undefined && data.other !== null)
113
+ paragraphs.push(`另一成员:${identity(data.other)}。`);
114
+ }
115
+ for (const [key, label] of [['path', 'JSONPath'], ['from', '起始时间(毫秒)'], ['to', '结束时间(毫秒)'], ['offset', '起始位置'], ['count', '请求数量'], ['unit', '单位'], ['section', '概况类别']])
116
+ add(label, data[key]);
117
+ for (const [key, label] of [['offset', '值的起始位置'], ['pattern', '值的名称条件'], ['start', '起始消息 ID'], ['end', '结束消息 ID'], ['direction', '读取方向']])
118
+ add(label, value[key]);
119
+ if (failure !== null)
120
+ paragraphs.push(failure);
121
+ if (state === 'missing')
122
+ paragraphs.push(`${target} 在采样时不存在;这次读取不能判断缺失原因。`);
123
+ else if (state === 'selection-missing')
124
+ paragraphs.push(`${target} 中指定的字段或成员在采样时不存在。`);
125
+ else if (state === 'changed' || state === 'failed' || state === 'unsupported' || state === 'unavailable' || state === 'query-failed')
126
+ paragraphs.push(`${target} 未取得可用结果(${state})。`);
127
+ else if (tool === 'redis_viewer_keys') {
128
+ paragraphs.push(`按名称条件 ${JSON.stringify(data.pattern)} 查找,本批返回 ${Array.isArray(data.keys) ? data.keys.length : 0} 个候选。`);
129
+ add('候选 Key', data.keys);
130
+ }
131
+ else if (tool === 'redis_viewer_filter_hash') {
132
+ const counts = object(data.counts);
133
+ paragraphs.push(`本批检查 ${String(counts.checked)} 个候选,匹配 ${String(counts.matched)} 个;仅代表本批检查结果。`);
134
+ paragraphs.push(`名称条件:${JSON.stringify(data.pattern)}。`);
135
+ add('筛选条件', data.condition);
136
+ add('匹配 Key', data.matches);
137
+ add('检查结果', data.counts);
138
+ add('读取错误', data.errors);
139
+ }
140
+ else if (tool === 'redis_viewer_key_metadata') {
141
+ paragraphs.push(`${target} 的类型为 ${type ?? '未知'}。本次只读取元信息,没有读取值。`);
142
+ }
143
+ else if (tool === 'redis_viewer_value') {
144
+ paragraphs.push(`${target}${type === null ? '' : `(${type})`}的本次读取结果如下。`);
145
+ if (data.field !== undefined)
146
+ paragraphs.push(`指定字段:${identity(data.field)}。`);
147
+ if (data.member !== undefined)
148
+ paragraphs.push(`指定成员:${identity(data.member)}${state === 'value' ? ',采样时存在' : ''}。`);
149
+ if (value.text !== undefined)
150
+ add(value.text === null ? '二进制值(Base64)' : '值', value.text === null ? value.base64 : value.text);
151
+ if (value.cell !== undefined)
152
+ add('选定值', value.cell);
153
+ for (const [key, label] of [['entries', '条目'], ['members', '成员'], ['messages', '消息']])
154
+ add(label, value[key]);
155
+ if (value.score !== null)
156
+ add('分数', value.score);
157
+ add('选择记录', object(data.selected).selection);
158
+ }
159
+ else if (tool === 'redis_viewer_memory') {
160
+ paragraphs.push(`${target} 的 MEMORY USAGE 结果为 ${String(data.bytes)} 字节。SAMPLES ${String(data.requestedSamples)} 是请求参数,实际采样数和误差未知;结果包含 Key、值的分配和管理开销,可能包含内部碎片,不是服务器总内存。`);
161
+ }
162
+ else if (tool === 'redis_viewer_compare_strings') {
163
+ const comparison = { equal: '两次读取的值相同。', different: '两次读取的值不同。', undetermined: '已读前缀相同,但存在截断,无法判定完整值是否相同。', unavailable: '未取得足够的有效数据,无法比较。' };
164
+ paragraphs.push(comparison[String(data.comparison)] ?? '比较结果未知。');
165
+ add('左侧采样', data.left);
166
+ add('右侧采样', data.right);
167
+ }
168
+ else {
169
+ const labels = { fields: '概况字段', entries: '慢日志', clients: '连接明细', groups: '消费组', samples: '时间序列样本', coordinates: '坐标', distance: '距离', bits: '位值', missing: '未返回字段' };
170
+ for (const [key, label] of Object.entries(labels))
171
+ add(label, data[key]);
172
+ if (typeof data.matchesJson === 'string')
173
+ values.push({ label: 'JSONPath 结果(原文)', text: data.matchesJson });
174
+ if (tool === 'redis_viewer_stream_groups')
175
+ paragraphs.push('pending 是已投递但未确认的消息数;lag 是尚未投递的消息数,null 表示未知,不能据此判断积压原因。');
176
+ if (tool === 'redis_viewer_slowlog')
177
+ paragraphs.push('慢日志记录服务器执行耗时,不含网络耗时;空结果不能证明没有慢查询。');
178
+ if (tool === 'redis_viewer_geo')
179
+ paragraphs.push('ZSet 类型本身不能证明数据是 GEO 索引;距离为近似值。');
180
+ if (tool === 'redis_viewer_status' || tool === 'redis_viewer_select_db') {
181
+ add('连接', data.connection);
182
+ add('当前选择', data.currentSelection);
183
+ add('选择同步状态', data.selectionSync);
184
+ }
185
+ }
186
+ const ttl = text(data.ttlMs ?? metadata.ttlMs);
187
+ if (ttl === '-1')
188
+ paragraphs.push('采样时没有设置过期时间;不能据此判断过去是否设置过,或将来是否会过期。');
189
+ else if (ttl !== null && /^\d+$/u.test(ttl))
190
+ paragraphs.push(`采样时剩余过期时间为 ${ttl} 毫秒。`);
191
+ if (hasResult && type === 'zset' && value.mode === 'range') {
192
+ paragraphs.push(value.nextOffset === null ? '本次排名读取已到达末尾;这不是 SCAN 扫描。' : '本次只读取指定排名范围,后续排名可按下一偏移继续读取。');
193
+ }
194
+ else if (hasResult && (data.scanComplete !== undefined || value.scanComplete !== undefined)) {
195
+ const ended = (data.scanComplete ?? value.scanComplete) === true;
196
+ // Stream uses XRANGE/XREVRANGE pagination, not the SCAN command family.
197
+ paragraphs.push(type === 'stream'
198
+ ? ended ? '指定消息范围的分页读取已结束;不代表整个 Stream,跨批读取不是一致性快照。' : '指定消息范围尚未读完,当前结果只包含已返回的消息。'
199
+ : ended ? '本次扫描迭代已结束,但 SCAN 不是一致性快照,跨批可能重复。' : '扫描尚未结束,当前结果不是完整匹配集合。');
200
+ }
201
+ if (hasResult && (data.complete === false || value.complete === false || object(value.cell).complete === false))
202
+ paragraphs.push('本次仅返回部分数据,不能把它当作完整值或完整列表。');
203
+ if (tool === 'redis_viewer_keys' || tool === 'redis_viewer_filter_hash')
204
+ paragraphs.push('MATCH 按 Key 名称匹配;SCAN 仍可能遍历当前 DB 的键空间,COUNT 只是工作量提示。');
205
+ for (const [key, label] of [['cursor', '续读令牌'], ['nextOffset', '下一偏移'], ['nextFrom', '下一时间范围']]) {
206
+ const continuation = data[key] ?? value[key];
207
+ if (continuation !== undefined && continuation !== null)
208
+ add(label, continuation);
209
+ }
210
+ if (hasResult && typeof data.coverage === 'string')
211
+ paragraphs.push(data.coverage);
212
+ if (tool !== 'redis_viewer_status' && tool !== 'redis_viewer_select_db')
213
+ paragraphs.push('以上是本次采样事实;多命令或多批读取不是一致性快照,不能单独证明历史、变化趋势或故障原因。');
214
+ return { paragraphs, values };
215
+ }
@@ -0,0 +1,3 @@
1
+ import { type DatabaseKeyCount } from './domain.js';
2
+ /** INFO keyspace contains counts only. Reject malformed/duplicate database rows. */
3
+ export declare function parseDatabaseKeyspace(text: string): readonly DatabaseKeyCount[];
@@ -0,0 +1,21 @@
1
+ import { MAX_DATABASE_ENTRIES } from "./domain.js";
2
+ /** INFO keyspace contains counts only. Reject malformed/duplicate database rows. */
3
+ export function parseDatabaseKeyspace(text) {
4
+ const rows = [], seen = new Set();
5
+ for (const line of text.split(/\r?\n/u)) {
6
+ if (line === '' || line.startsWith('#'))
7
+ continue;
8
+ const match = /^db(0|[1-9]\d{0,4}):(.+)$/u.exec(line);
9
+ if (match === null)
10
+ throw new TypeError('Invalid keyspace row');
11
+ const db = Number(match[1]), fields = match[2].split(','), counts = fields.filter(field => field.startsWith('keys='));
12
+ const keys = counts[0]?.slice(5);
13
+ if (db > 65535 || seen.has(db) || counts.length !== 1 || keys === undefined || !/^(?:0|[1-9]\d{0,18})$/u.test(keys) || BigInt(keys) > (1n << 63n) - 1n)
14
+ throw new TypeError('Invalid keyspace count');
15
+ if (rows.length >= MAX_DATABASE_ENTRIES)
16
+ throw new RangeError('Keyspace is too large');
17
+ seen.add(db);
18
+ rows.push({ db, keys });
19
+ }
20
+ return rows.sort((a, b) => a.db - b.db);
21
+ }
@@ -0,0 +1,2 @@
1
+ /** Read producers shared by Host answer binding and native result views. */
2
+ export declare const evidenceTools: readonly ["redis_viewer_status", "redis_viewer_keys", "redis_viewer_key_metadata", "redis_viewer_value", "redis_viewer_filter_hash", "redis_viewer_timeseries", "redis_viewer_json_path", "redis_viewer_geo", "redis_viewer_bitmap", "redis_viewer_memory", "redis_viewer_compare_strings", "redis_viewer_slowlog", "redis_viewer_overview", "redis_viewer_clients", "redis_viewer_stream_groups", "redis_viewer_select_db"];
@@ -0,0 +1,7 @@
1
+ /** Read producers shared by Host answer binding and native result views. */
2
+ export const evidenceTools = [
3
+ 'redis_viewer_status', 'redis_viewer_keys', 'redis_viewer_key_metadata', 'redis_viewer_value',
4
+ 'redis_viewer_filter_hash', 'redis_viewer_timeseries', 'redis_viewer_json_path', 'redis_viewer_geo',
5
+ 'redis_viewer_bitmap', 'redis_viewer_memory', 'redis_viewer_compare_strings', 'redis_viewer_slowlog',
6
+ 'redis_viewer_overview', 'redis_viewer_clients', 'redis_viewer_stream_groups', 'redis_viewer_select_db',
7
+ ];
@@ -0,0 +1,4 @@
1
+ export declare function resultFits(text: string, maxBytes: number): boolean;
2
+ export declare function resultRecord(value: unknown): Record<string, unknown> | null;
3
+ /** Treat persisted results as data. Malformed or oversize records cannot become evidence. */
4
+ export declare function parseResultRecord(text: string, maxBytes: number): Record<string, unknown> | null;
@@ -0,0 +1,18 @@
1
+ const utf8 = new TextEncoder();
2
+ export function resultFits(text, maxBytes) {
3
+ return text.length <= maxBytes && utf8.encode(text).byteLength <= maxBytes;
4
+ }
5
+ export function resultRecord(value) {
6
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
7
+ }
8
+ /** Treat persisted results as data. Malformed or oversize records cannot become evidence. */
9
+ export function parseResultRecord(text, maxBytes) {
10
+ if (!resultFits(text, maxBytes))
11
+ return null;
12
+ try {
13
+ return resultRecord(JSON.parse(text));
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ }
@@ -0,0 +1,2 @@
1
+ /** Validate Redis double text without replacing its original spelling/precision. */
2
+ export declare function isRedisScore(value: string): boolean;
@@ -0,0 +1,6 @@
1
+ /** Validate Redis double text without replacing its original spelling/precision. */
2
+ export function isRedisScore(value) {
3
+ if (value.length > 128)
4
+ return false;
5
+ return /^[+-]?inf$/u.test(value) || (/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/u.test(value) && Number.isFinite(Number(value)));
6
+ }
@@ -0,0 +1,69 @@
1
+ import { UiActionCoordinator } from './host/ui-action-coordinator.js';
2
+ import type { UiAction, UiChannelInput, UiChannelMessage } from './domain.js';
3
+ import type { RemoteStream } from '@deepseek-ai/dsh-typert-protocol';
4
+ import { RedisAiReader } from './host/ai-reader.js';
5
+ import { RedisAiWriter } from './host/ai-writer.js';
6
+ import type { AiBudgetResume, AiBudgetStatus, DatabasesReadRequest, DatabasesReadResult } from './domain.js';
7
+ import type { RedisWriteModeRequest, RedisWriteModeStatus } from './domain.js';
8
+ import type { RedisWriteLookupRequest, RedisWriteLookupResult } from './domain.js';
9
+ import type { ZSetReadRequest, ZSetReadResult } from './domain.js';
10
+ import type { StreamReadRequest, StreamReadResult } from './domain.js';
11
+ import type { ScanSetRequest, ScanSetResult } from './domain.js';
12
+ import type { ListReadRequest, ListReadResult } from './domain.js';
13
+ import type { ScanHashRequest, ScanHashResult } from './domain.js';
14
+ import type { ActionPointReadRequest, ActionPointReadResult } from './domain.js';
15
+ import type { StringReadRequest, StringReadResult } from './domain.js';
16
+ import type { DatabaseTarget, ScanKeysRequest, ScanKeysResult } from './domain.js';
17
+ import type { SaveProfileRequest, ProfileId, ProfileCollection, SavedConnection } from './domain.js';
18
+ import type { ConnectionRequest, ConnectionTarget, ConnectionView } from './domain.js';
19
+ import type { Context } from '@deepseek-ai/cordis';
20
+ import type { Agent } from '@deepseek-ai/dsh-agent';
21
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
22
+ import { type EmptyRequest, type RedisHostStatus } from './domain.js';
23
+ /** Typert supplies the trusted Agent; clients cannot select an arbitrary owner. */
24
+ export declare class RedisRemoteService extends TypertRemoteService {
25
+ readonly uiActions: UiActionCoordinator<UiAction>;
26
+ private readonly connections;
27
+ readonly writer: RedisAiWriter;
28
+ readonly ai: RedisAiReader;
29
+ private readonly databases;
30
+ private readonly keys;
31
+ private readonly strings;
32
+ private readonly hashes;
33
+ private readonly lists;
34
+ private readonly sets;
35
+ private readonly zsets;
36
+ private readonly streams;
37
+ private readonly scanReaders;
38
+ private readonly profiles;
39
+ constructor(ctx: Context);
40
+ private disposeScans;
41
+ /** Every target exchange retires writes, selection and all old cursors together. */
42
+ private resetTarget;
43
+ /** The Gateway supplies both the trusted Agent and this stream's uplink. */
44
+ openUiChannel(agent: Agent, _request: EmptyRequest, signal: AbortSignal): RemoteStream<UiChannelMessage, UiChannelInput>;
45
+ connect(agent: Agent, request: ConnectionRequest, signal: AbortSignal): Promise<ConnectionView>;
46
+ disconnect(agent: Agent, request: ConnectionTarget, signal: AbortSignal): Promise<ConnectionView>;
47
+ selectDatabase(agent: Agent, request: DatabaseTarget, signal: AbortSignal): Promise<ConnectionView>;
48
+ scanKeys(agent: Agent, request: ScanKeysRequest, signal: AbortSignal): Promise<ScanKeysResult>;
49
+ readString(agent: Agent, request: StringReadRequest, signal: AbortSignal): Promise<StringReadResult>;
50
+ scanHash(agent: Agent, request: ScanHashRequest, signal: AbortSignal): Promise<ScanHashResult>;
51
+ readActionPoint(agent: Agent, request: ActionPointReadRequest, signal: AbortSignal): Promise<ActionPointReadResult>;
52
+ readList(agent: Agent, request: ListReadRequest, signal: AbortSignal): Promise<ListReadResult>;
53
+ scanSet(agent: Agent, request: ScanSetRequest, signal: AbortSignal): Promise<ScanSetResult>;
54
+ readZSet(agent: Agent, request: ZSetReadRequest, signal: AbortSignal): Promise<ZSetReadResult>;
55
+ readStream(agent: Agent, request: StreamReadRequest, signal: AbortSignal): Promise<StreamReadResult>;
56
+ readDatabases(agent: Agent, request: DatabasesReadRequest, signal: AbortSignal): Promise<DatabasesReadResult>;
57
+ aiBudgetStatus(agent: Agent, _request: EmptyRequest, signal: AbortSignal): Promise<AiBudgetStatus>;
58
+ resumeAiBudget(agent: Agent, _request: EmptyRequest, signal: AbortSignal): Promise<AiBudgetResume>;
59
+ connectionStatus(agent: Agent, _request: EmptyRequest, signal: AbortSignal): Promise<ConnectionView>;
60
+ writeModeStatus(agent: Agent, _request: EmptyRequest, signal: AbortSignal): Promise<RedisWriteModeStatus>;
61
+ setWriteMode(agent: Agent, request: RedisWriteModeRequest, signal: AbortSignal): Promise<RedisWriteModeStatus>;
62
+ writeLookup(agent: Agent, request: RedisWriteLookupRequest, signal: AbortSignal): Promise<RedisWriteLookupResult>;
63
+ listProfiles(_agent: Agent, _request: EmptyRequest, signal: AbortSignal): Promise<ProfileCollection>;
64
+ /** Saved profiles contain no password; authentication failures require the local form. */
65
+ connectSavedProfile(agent: Agent, profile: SavedConnection, signal: AbortSignal, isCurrent: () => boolean): Promise<import("./host/connection-service.js").CandidateConnectionResult>;
66
+ saveProfile(_agent: Agent, request: SaveProfileRequest, signal: AbortSignal): Promise<ProfileCollection>;
67
+ removeProfile(_agent: Agent, request: ProfileId, signal: AbortSignal): Promise<ProfileCollection>;
68
+ status(_agent: Agent, _request: EmptyRequest, signal: AbortSignal): Promise<RedisHostStatus>;
69
+ }
@@ -0,0 +1,187 @@
1
+ import { selectionForAction } from "./ui-action-selection.js";
2
+ import { RedisDatabases } from "./host/database-reader.js";
3
+ import { UiActionCoordinator } from "./host/ui-action-coordinator.js";
4
+ import { openUiActionChannel } from "./host/ui-action-channel.js";
5
+ import { RedisAiReader } from "./host/ai-reader.js";
6
+ import { RedisAiWriter } from "./host/ai-writer.js";
7
+ import { ConnectionFailure, RedisConnections } from "./host/connection-service.js";
8
+ import { RedisProfiles } from "./host/profile-store.js";
9
+ import { RedisKeys } from "./host/key-reader.js";
10
+ import { RedisStrings } from "./host/string-reader.js";
11
+ import { RedisHashes } from "./host/hash-reader.js";
12
+ import { RedisSelectedReader } from "./host/selected-reader.js";
13
+ import { RedisLists } from "./host/list-reader.js";
14
+ import { RedisSets } from "./host/set-reader.js";
15
+ import { RedisZSets } from "./host/zset-reader.js";
16
+ import { RedisStreams } from "./host/stream-reader.js";
17
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
18
+ import { DSH_BASELINE, PROTOCOL_VERSION, MAX_SCAN_JSON_BYTES } from "./domain.js";
19
+ /** Typert supplies the trusted Agent; clients cannot select an arbitrary owner. */
20
+ export class RedisRemoteService extends TypertRemoteService {
21
+ uiActions = new UiActionCoordinator();
22
+ connections = new RedisConnections();
23
+ writer = new RedisAiWriter(this.connections);
24
+ ai = new RedisAiReader(this.connections, sessionId => this.uiActions.invalidateSession(sessionId), async (sessionId, target, expected, signal) => {
25
+ const revision = this.uiActions.selectionRevision(sessionId);
26
+ if (revision === null || (expected !== null && revision !== expected))
27
+ throw new Error('侧栏选择正在变化或界面不可用,请在当前对话打开唯一 Redis 面板并重试。');
28
+ const current = () => this.uiActions.selectionRevision(sessionId) === revision;
29
+ const outcome = await this.uiActions.dispatch(sessionId, { kind: 'confirmSelection' }, target, revision, current, signal, 3000);
30
+ if (outcome !== 'applied' || !current())
31
+ throw new Error('侧栏选择已变化或界面不可用,请重新选择后重试。');
32
+ return revision;
33
+ }, (sessionId, revision) => { const current = this.uiActions.selectionRevision(sessionId); return current !== null && (revision === null || current === revision); }, sessionId => this.resetTarget(sessionId));
34
+ databases = new RedisDatabases(this.connections);
35
+ keys = new RedisKeys(this.connections);
36
+ strings = new RedisStrings(this.connections);
37
+ hashes = new RedisHashes(this.connections);
38
+ lists = new RedisLists(this.connections);
39
+ sets = new RedisSets(this.connections);
40
+ zsets = new RedisZSets(this.connections);
41
+ streams = new RedisStreams(this.connections);
42
+ scanReaders = [this.keys, this.hashes, this.sets, this.zsets, this.streams];
43
+ profiles;
44
+ constructor(ctx) {
45
+ super(ctx, 'redisViewer');
46
+ this.profiles = new RedisProfiles(ctx.profileContext.dir);
47
+ ctx.effect(() => () => { this.writer.dispose(); this.uiActions.dispose(); this.ai.dispose(); for (const reader of this.scanReaders)
48
+ reader.dispose(); this.connections.dispose(); }, 'redis connections');
49
+ ctx.on('session/disposed', session => { this.writer.disable(session.id); this.uiActions.disposeSession(session.id); this.ai.disposeSession(session.id); this.disposeScans(session.id); this.connections.disposeSession(session.id); });
50
+ }
51
+ disposeScans(sessionId) {
52
+ for (const reader of this.scanReaders)
53
+ reader.disposeSession(sessionId);
54
+ }
55
+ /** Every target exchange retires writes, selection and all old cursors together. */
56
+ resetTarget(sessionId) {
57
+ this.writer.disable(sessionId);
58
+ this.ai.clearTarget(sessionId);
59
+ this.disposeScans(sessionId);
60
+ }
61
+ /** The Gateway supplies both the trusted Agent and this stream's uplink. */
62
+ async *openUiChannel(agent, _request, signal) {
63
+ signal.throwIfAborted();
64
+ const invocation = this.ctx.invocation;
65
+ if (invocation === undefined)
66
+ throw new Error('界面动作通道缺少有效调用上下文。');
67
+ yield* openUiActionChannel(this.uiActions, agent.session.id, signal, invocation.uplink(), (request, source) => source === 'action' ? this.ai.commitSelection(agent.session.id, request) : this.ai.setSelection(agent.session.id, request));
68
+ }
69
+ async connect(agent, request, signal) {
70
+ signal.throwIfAborted();
71
+ this.resetTarget(agent.session.id);
72
+ return this.connections.connect(agent.session.id, request, signal);
73
+ }
74
+ async disconnect(agent, request, signal) {
75
+ signal.throwIfAborted();
76
+ const view = this.connections.disconnect(agent.session.id, request);
77
+ if (view.state === 'disconnected')
78
+ this.resetTarget(agent.session.id);
79
+ return view;
80
+ }
81
+ async selectDatabase(agent, request, signal) {
82
+ signal.throwIfAborted();
83
+ const view = await this.connections.selectDatabase(agent.session.id, request, signal, () => this.resetTarget(agent.session.id));
84
+ // An obsolete response must not clear selection state for a newer connection.
85
+ if (!this.connections.isCurrentView(agent.session.id, view))
86
+ return { ...this.connections.status(agent.session.id), error: 'stale' };
87
+ return view;
88
+ }
89
+ async scanKeys(agent, request, signal) {
90
+ return this.keys.scan(agent.session.id, request, signal);
91
+ }
92
+ async readString(agent, request, signal) {
93
+ return this.strings.read(agent.session.id, request, signal);
94
+ }
95
+ async scanHash(agent, request, signal) {
96
+ return this.hashes.scan(agent.session.id, request, signal);
97
+ }
98
+ async readActionPoint(agent, request, signal) {
99
+ const sessionId = agent.session.id, action = this.uiActions.activeRequest(sessionId, request.requestId);
100
+ const failed = (error) => ({ state: 'failed', error, cell: null, score: null, streamMessage: null, sampledAt: new Date().toISOString() });
101
+ const stale = () => failed('stale');
102
+ if (signal.aborted)
103
+ return failed('cancelled');
104
+ if (action === null || action.target === null)
105
+ return stale();
106
+ const selection = selectionForAction(action.action);
107
+ if (selection === null || selection.item === null)
108
+ return stale();
109
+ const { keyBase64, item } = selection;
110
+ if (!this.uiActions.claimPoint(sessionId, action))
111
+ return stale();
112
+ const validate = () => { if (this.uiActions.activeRequest(sessionId, request.requestId) !== action)
113
+ throw new ConnectionFailure('stale'); };
114
+ const reader = new RedisSelectedReader(this.connections);
115
+ const stream = item.kind === 'stream' ? await reader.readStream(sessionId, action.target, keyBase64, item.id, item.fieldIndex, item.fieldBase64, signal, validate) : null;
116
+ const sample = stream === null ? await reader.read(sessionId, action.target, keyBase64, item, signal, validate) : stream.selected;
117
+ if (signal.aborted)
118
+ return failed('cancelled');
119
+ try {
120
+ validate();
121
+ }
122
+ catch {
123
+ return stale();
124
+ }
125
+ const state = sample.state === 'value' || sample.state === 'selection-missing' || sample.state === 'missing' || sample.state === 'failed' ? sample.state : 'changed';
126
+ const result = { state, error: state === 'failed' ? sample.error : null, cell: state === 'value' ? sample.cell : null, score: state === 'value' ? sample.score : null, streamMessage: state === 'value' ? stream?.message ?? null : null, sampledAt: sample.sampledAt };
127
+ if (Buffer.byteLength(JSON.stringify(result)) > MAX_SCAN_JSON_BYTES)
128
+ return failed('oversize');
129
+ if (state === 'value' && !this.uiActions.markPointSucceeded(sessionId, action))
130
+ return stale();
131
+ return result;
132
+ }
133
+ async readList(agent, request, signal) {
134
+ return this.lists.read(agent.session.id, request, signal);
135
+ }
136
+ async scanSet(agent, request, signal) {
137
+ return this.sets.scan(agent.session.id, request, signal);
138
+ }
139
+ async readZSet(agent, request, signal) {
140
+ return this.zsets.read(agent.session.id, request, signal);
141
+ }
142
+ async readStream(agent, request, signal) {
143
+ return this.streams.read(agent.session.id, request, signal);
144
+ }
145
+ async readDatabases(agent, request, signal) { return this.databases.read(agent.session.id, request, signal); }
146
+ async aiBudgetStatus(agent, _request, signal) { signal.throwIfAborted(); return this.ai.budgetStatus(agent.session.id); }
147
+ async resumeAiBudget(agent, _request, signal) { signal.throwIfAborted(); return this.ai.resumeBudget(agent.session.id); }
148
+ async connectionStatus(agent, _request, signal) {
149
+ signal.throwIfAborted();
150
+ return this.connections.status(agent.session.id);
151
+ }
152
+ async writeModeStatus(agent, _request, signal) {
153
+ signal.throwIfAborted();
154
+ const connection = this.connections.status(agent.session.id);
155
+ const enabled = connection.state === 'connected' && connection.id !== null && this.writer.isEnabled(agent.session.id, { id: connection.id, generation: connection.generation, db: connection.db });
156
+ return { connection, enabled };
157
+ }
158
+ async setWriteMode(agent, request, signal) {
159
+ signal.throwIfAborted();
160
+ this.connections.assertTarget(agent.session.id, request.target);
161
+ if (request.enabled)
162
+ this.writer.enable(agent.session.id, request.target);
163
+ else
164
+ this.writer.disable(agent.session.id);
165
+ return this.writeModeStatus(agent, {}, signal);
166
+ }
167
+ async writeLookup(agent, request, signal) {
168
+ signal.throwIfAborted();
169
+ return { record: this.writer.status(agent.session.id, request.id) };
170
+ }
171
+ async listProfiles(_agent, _request, signal) { return this.profiles.list(signal); }
172
+ /** Saved profiles contain no password; authentication failures require the local form. */
173
+ connectSavedProfile(agent, profile, signal, isCurrent) {
174
+ const sessionId = agent.session.id;
175
+ return this.connections.connectProfileCandidate(sessionId, profile, '', signal, this.profiles, () => {
176
+ if (!isCurrent())
177
+ throw new ConnectionFailure('stale');
178
+ this.resetTarget(sessionId);
179
+ });
180
+ }
181
+ async saveProfile(_agent, request, signal) { return this.profiles.save(request, signal); }
182
+ async removeProfile(_agent, request, signal) { return this.profiles.remove(request, signal); }
183
+ async status(_agent, _request, signal) {
184
+ signal.throwIfAborted();
185
+ return { state: 'ready', sidebarReadOnly: true, aiWriteAvailable: true, dshBaseline: DSH_BASELINE, protocolVersion: PROTOCOL_VERSION };
186
+ }
187
+ }
@@ -0,0 +1,3 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ /** Sidebar and model tools share one Host-owned connection per trusted session. */
3
+ export declare function apply(ctx: Context): void;
package/lib/runtime.js ADDED
@@ -0,0 +1,29 @@
1
+ import { RedisRemoteService } from "./remote-service.js";
2
+ import { registerRedisTools } from "./host/ai-tools.js";
3
+ import { registerRedisAnswerTool } from "./host/ai-answer.js";
4
+ import { registerRedisFormatTool, registerRedisRefreshTool, registerRedisUiTools } from "./host/ai-ui-tools.js";
5
+ import { registerRedisProfileTools } from "./host/ai-profile-tools.js";
6
+ import { registerRedisLocateTool } from "./host/ai-locate-tool.js";
7
+ import { RedisProfileSnapshots } from "./host/profile-snapshots.js";
8
+ import { RedisMatchPresets } from "./host/match-preset-store.js";
9
+ import { registerRedisMatchTools } from "./host/ai-match-tools.js";
10
+ import { registerRedisConnectionTools } from "./host/ai-connection-tools.js";
11
+ import { RedisReports, registerRedisReportTools } from "./host/ai-report-tools.js";
12
+ import { registerRedisWriteTools } from "./host/ai-write-tools.js";
13
+ /** Sidebar and model tools share one Host-owned connection per trusted session. */
14
+ export function apply(ctx) {
15
+ const service = new RedisRemoteService(ctx);
16
+ const snapshots = new RedisProfileSnapshots();
17
+ registerRedisTools(ctx, service.ai);
18
+ registerRedisWriteTools(ctx, service.ai, service.writer);
19
+ registerRedisAnswerTool(ctx, service.ai);
20
+ registerRedisProfileTools(ctx, service.ai, snapshots, (agent, signal) => service.listProfiles(agent, {}, signal));
21
+ registerRedisConnectionTools(ctx, service.ai, snapshots, (agent, profile, signal, isCurrent) => service.connectSavedProfile(agent, profile, signal, isCurrent), (agent, target, signal) => service.disconnect(agent, target, signal));
22
+ registerRedisMatchTools(ctx, service.ai, new RedisMatchPresets(ctx.profileContext.dir), service.uiActions);
23
+ registerRedisReportTools(ctx, service.ai, new RedisReports(ctx.profileContext.dir));
24
+ registerRedisLocateTool(ctx, service.ai, service.uiActions);
25
+ registerRedisUiTools(ctx, service.uiActions);
26
+ registerRedisRefreshTool(ctx, service.ai, service.uiActions);
27
+ registerRedisFormatTool(ctx, service.ai, service.uiActions);
28
+ console.info('[dsh-redis] Redis Host registered');
29
+ }
@@ -0,0 +1,7 @@
1
+ export declare const MAX_STREAM_ID: string;
2
+ /** Both unsigned-64-bit components remain decimal text across the RPC boundary. */
3
+ export declare function isStreamId(value: string): boolean;
4
+ /** Inputs have already passed isStreamId; compare pairs, never JS numbers. */
5
+ export declare function compareStreamIds(left: string, right: string): number;
6
+ export declare function isStreamRange(start: string, end: string): boolean;
7
+ export declare function withinStreamRange(id: string, start: string, end: string): boolean;