@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.
- package/LICENSE +21 -0
- package/README.md +184 -2
- package/README.zh.md +185 -0
- package/cordis.patch.yml +4 -0
- package/icon.svg +1 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client.js +7684 -0
- package/lib/connection-errors.d.ts +66 -0
- package/lib/connection-errors.js +21 -0
- package/lib/domain.d.ts +451 -0
- package/lib/domain.js +20 -0
- package/lib/host/ai-answer.d.ts +7 -0
- package/lib/host/ai-answer.js +132 -0
- package/lib/host/ai-budget.d.ts +43 -0
- package/lib/host/ai-budget.js +78 -0
- package/lib/host/ai-connection-tools.d.ts +8 -0
- package/lib/host/ai-connection-tools.js +49 -0
- package/lib/host/ai-hash-filter.d.ts +13 -0
- package/lib/host/ai-hash-filter.js +97 -0
- package/lib/host/ai-hash-pages.d.ts +15 -0
- package/lib/host/ai-hash-pages.js +42 -0
- package/lib/host/ai-key-pages.d.ts +14 -0
- package/lib/host/ai-key-pages.js +27 -0
- package/lib/host/ai-locate-tool.d.ts +6 -0
- package/lib/host/ai-locate-tool.js +234 -0
- package/lib/host/ai-match-tools.d.ts +7 -0
- package/lib/host/ai-match-tools.js +112 -0
- package/lib/host/ai-page-coordinator.d.ts +21 -0
- package/lib/host/ai-page-coordinator.js +81 -0
- package/lib/host/ai-page-store.d.ts +40 -0
- package/lib/host/ai-page-store.js +104 -0
- package/lib/host/ai-profile-tools.d.ts +7 -0
- package/lib/host/ai-profile-tools.js +44 -0
- package/lib/host/ai-query-scope.d.ts +42 -0
- package/lib/host/ai-query-scope.js +104 -0
- package/lib/host/ai-reader.d.ts +219 -0
- package/lib/host/ai-reader.js +1221 -0
- package/lib/host/ai-report-samples.d.ts +26 -0
- package/lib/host/ai-report-samples.js +77 -0
- package/lib/host/ai-report-tools.d.ts +11 -0
- package/lib/host/ai-report-tools.js +70 -0
- package/lib/host/ai-set-pages.d.ts +15 -0
- package/lib/host/ai-set-pages.js +40 -0
- package/lib/host/ai-stream-pages.d.ts +15 -0
- package/lib/host/ai-stream-pages.js +42 -0
- package/lib/host/ai-tools.d.ts +4 -0
- package/lib/host/ai-tools.js +106 -0
- package/lib/host/ai-ui-tools.d.ts +10 -0
- package/lib/host/ai-ui-tools.js +72 -0
- package/lib/host/ai-value.d.ts +12 -0
- package/lib/host/ai-value.js +15 -0
- package/lib/host/ai-write-tools.d.ts +5 -0
- package/lib/host/ai-write-tools.js +101 -0
- package/lib/host/ai-writer.d.ts +25 -0
- package/lib/host/ai-writer.js +77 -0
- package/lib/host/ai-zset-pages.d.ts +15 -0
- package/lib/host/ai-zset-pages.js +40 -0
- package/lib/host/byte-identity.d.ts +3 -0
- package/lib/host/byte-identity.js +12 -0
- package/lib/host/client-list.d.ts +13 -0
- package/lib/host/client-list.js +35 -0
- package/lib/host/connection-service.d.ts +71 -0
- package/lib/host/connection-service.js +468 -0
- package/lib/host/database-reader.d.ts +10 -0
- package/lib/host/database-reader.js +62 -0
- package/lib/host/hash-reader.d.ts +12 -0
- package/lib/host/hash-reader.js +91 -0
- package/lib/host/key-reader.d.ts +20 -0
- package/lib/host/key-reader.js +65 -0
- package/lib/host/list-reader.d.ts +8 -0
- package/lib/host/list-reader.js +61 -0
- package/lib/host/match-preset-store.d.ts +36 -0
- package/lib/host/match-preset-store.js +201 -0
- package/lib/host/profile-snapshots.d.ts +32 -0
- package/lib/host/profile-snapshots.js +187 -0
- package/lib/host/profile-store.d.ts +15 -0
- package/lib/host/profile-store.js +120 -0
- package/lib/host/read-context.d.ts +23 -0
- package/lib/host/read-context.js +41 -0
- package/lib/host/redis-transport.d.ts +34 -0
- package/lib/host/redis-transport.js +262 -0
- package/lib/host/redis-write-transaction.d.ts +28 -0
- package/lib/host/redis-write-transaction.js +180 -0
- package/lib/host/resp.d.ts +38 -0
- package/lib/host/resp.js +174 -0
- package/lib/host/scan-cursors.d.ts +25 -0
- package/lib/host/scan-cursors.js +59 -0
- package/lib/host/selected-reader.d.ts +22 -0
- package/lib/host/selected-reader.js +84 -0
- package/lib/host/set-reader.d.ts +12 -0
- package/lib/host/set-reader.js +85 -0
- package/lib/host/stream-groups.d.ts +17 -0
- package/lib/host/stream-groups.js +42 -0
- package/lib/host/stream-reader.d.ts +12 -0
- package/lib/host/stream-reader.js +105 -0
- package/lib/host/string-reader.d.ts +9 -0
- package/lib/host/string-reader.js +81 -0
- package/lib/host/ui-action-channel.d.ts +4 -0
- package/lib/host/ui-action-channel.js +182 -0
- package/lib/host/ui-action-coordinator.d.ts +28 -0
- package/lib/host/ui-action-coordinator.js +188 -0
- package/lib/host/value-prefix.d.ts +5 -0
- package/lib/host/value-prefix.js +11 -0
- package/lib/host/write-bytes.d.ts +3 -0
- package/lib/host/write-bytes.js +9 -0
- package/lib/host/write-history.d.ts +18 -0
- package/lib/host/write-history.js +79 -0
- package/lib/host/write-proposals.d.ts +46 -0
- package/lib/host/write-proposals.js +132 -0
- package/lib/host/zset-reader.d.ts +12 -0
- package/lib/host/zset-reader.js +103 -0
- package/lib/host/zset-values.d.ts +6 -0
- package/lib/host/zset-values.js +26 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +5 -0
- package/lib/redis-answer.d.ts +32 -0
- package/lib/redis-answer.js +215 -0
- package/lib/redis-databases.d.ts +3 -0
- package/lib/redis-databases.js +21 -0
- package/lib/redis-read-tools.d.ts +2 -0
- package/lib/redis-read-tools.js +7 -0
- package/lib/redis-result.d.ts +4 -0
- package/lib/redis-result.js +18 -0
- package/lib/redis-score.d.ts +2 -0
- package/lib/redis-score.js +6 -0
- package/lib/remote-service.d.ts +69 -0
- package/lib/remote-service.js +187 -0
- package/lib/runtime.d.ts +3 -0
- package/lib/runtime.js +29 -0
- package/lib/stream-id.d.ts +7 -0
- package/lib/stream-id.js +19 -0
- package/lib/typert.host.d.ts +13 -0
- package/lib/typert.host.js +7 -0
- package/lib/typert.remote-client.d.ts +98 -0
- package/lib/typert.remote-client.js +3 -0
- package/lib/typert.shared.d.ts +62 -0
- package/lib/typert.shared.js +735 -0
- package/lib/ui-action-selection.d.ts +3 -0
- package/lib/ui-action-selection.js +12 -0
- package/licenses/THIRD_PARTY_NOTICES.txt +9 -0
- package/licenses/deepseek-harness-MIT.txt +21 -0
- package/licenses/dsh-database-MIT.txt +21 -0
- package/licenses/dsh-git-graph-MIT.txt +21 -0
- package/licenses/lucide-react-LICENSE.txt +43 -0
- package/licenses/phosphor-icons-MIT.txt +21 -0
- package/package.json +132 -3
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
2
|
+
import { MAX_AI_RESULT_BYTES, MAX_AI_SESSION_CALLS } from "./ai-budget.js";
|
|
3
|
+
import { evidenceTools } from "../redis-read-tools.js";
|
|
4
|
+
import { describeRedisResult, summarizeRedisFilters } from "../redis-answer.js";
|
|
5
|
+
import { parseResultRecord, resultFits } from "../redis-result.js";
|
|
6
|
+
const uiReceiptTools = new Set(['redis_viewer_show', 'redis_viewer_refresh', 'redis_viewer_format', 'redis_viewer_locate_key', 'redis_viewer_locate_hash_field', 'redis_viewer_locate_list_index', 'redis_viewer_locate_set_member', 'redis_viewer_locate_zset_member', 'redis_viewer_locate_stream_field']);
|
|
7
|
+
/** Consume committed session events, never model-supplied copies of Redis data.
|
|
8
|
+
* This bounded, turn-local index holds no cursor or query state. The final answer
|
|
9
|
+
* is persisted by DSH like any other tool result, so replay needs no live cache.
|
|
10
|
+
*/
|
|
11
|
+
export function registerRedisAnswerTool(ctx, reader) {
|
|
12
|
+
const sessions = new Map();
|
|
13
|
+
const readable = new Set([...evidenceTools, ...uiReceiptTools]);
|
|
14
|
+
const currentConnection = (sessionId) => reader.connectionSnapshot(sessionId);
|
|
15
|
+
const observe = (sessionId, event) => {
|
|
16
|
+
if (event.type === 'turn/start') {
|
|
17
|
+
sessions.set(sessionId, { turn: event.data.turn, calls: new Map(), omittedCalls: 0 });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (event.type === 'turn/end') {
|
|
21
|
+
sessions.delete(sessionId);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const current = sessions.get(sessionId);
|
|
25
|
+
if (current === undefined)
|
|
26
|
+
return;
|
|
27
|
+
// Newly admitted input must not inherit an earlier answer's observations.
|
|
28
|
+
if (event.type === 'user/message' && event.data.source.kind === 'user') {
|
|
29
|
+
current.calls.clear();
|
|
30
|
+
current.omittedCalls = 0;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (event.type === 'tool/call' && event.data.turn === current.turn && readable.has(event.data.name)) {
|
|
34
|
+
if (current.calls.size >= MAX_AI_SESSION_CALLS) {
|
|
35
|
+
current.calls.delete(current.calls.keys().next().value ?? '');
|
|
36
|
+
current.omittedCalls++;
|
|
37
|
+
}
|
|
38
|
+
// Keep only the continuation identity needed for summaries, not arbitrary
|
|
39
|
+
// model arguments. Malformed inputs never become an iteration start.
|
|
40
|
+
let inputCursor;
|
|
41
|
+
if (event.data.name === 'redis_viewer_filter_hash')
|
|
42
|
+
try {
|
|
43
|
+
const args = JSON.parse(event.data.arguments);
|
|
44
|
+
if (typeof args === 'object' && args !== null && !Array.isArray(args))
|
|
45
|
+
inputCursor = !('cursor' in args) ? null : typeof args.cursor === 'string' ? args.cursor : undefined;
|
|
46
|
+
}
|
|
47
|
+
catch { /* The tool owns argument validation. */ }
|
|
48
|
+
current.calls.set(event.data.callId, { tool: event.data.name, connection: currentConnection(sessionId), inputCursor });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (event.type !== 'tool/result' || event.data.turn !== current.turn)
|
|
52
|
+
return;
|
|
53
|
+
const message = event.data.message, entry = current.calls.get(message.toolCallId);
|
|
54
|
+
if (entry === undefined)
|
|
55
|
+
return;
|
|
56
|
+
// Rejections/cancellation are evidence too. They refer to the connection at
|
|
57
|
+
// dispatch and must not be mistaken for a successful Redis observation.
|
|
58
|
+
const failed = (reason) => { entry.result = { readOnly: true, connection: entry.connection, state: 'failed', errorMessage: reason }; };
|
|
59
|
+
failed('读取未取得可用的结构化结果,请查看对应调用记录。');
|
|
60
|
+
if (message.content.length !== 1 || message.content[0]?.type !== 'text')
|
|
61
|
+
return;
|
|
62
|
+
const text = message.content[0].text;
|
|
63
|
+
if (message.isError) {
|
|
64
|
+
if (resultFits(text, MAX_AI_RESULT_BYTES))
|
|
65
|
+
failed(text);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const value = parseResultRecord(text, MAX_AI_RESULT_BYTES);
|
|
69
|
+
if (value === null)
|
|
70
|
+
return;
|
|
71
|
+
if (value.readOnly === true)
|
|
72
|
+
entry.result = value;
|
|
73
|
+
// Keep the exact UI receipt and dispatch connection for summarization.
|
|
74
|
+
else if (uiReceiptTools.has(entry.tool) && typeof value.outcome === 'string' && typeof value.message === 'string') {
|
|
75
|
+
entry.result = { readOnly: true, connection: entry.connection, kind: 'ui-receipt', receipt: value };
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
ctx.on('session/event', (session, event) => observe(session.id, event));
|
|
79
|
+
ctx.on('session/disposed', session => { sessions.delete(session.id); });
|
|
80
|
+
ctx.effect(() => () => sessions.clear(), 'redis answer evidence');
|
|
81
|
+
ctx.tools.register(defineTool({
|
|
82
|
+
name: 'redis_viewer_answer',
|
|
83
|
+
description: '完成必要的 Redis 查找、读取、分页及界面操作后,无参数调用一次本工具。Host 引用本轮当前连接和 DB 的已完成记录及界面回执,显示中文事实、原值与范围说明。本工具不会结束回合:返回后必须继续用简短自然语言回答用户的具体问题,依据本轮证据区分已知事实、推测和无法判断之处;不要只展示卡片而遗漏解释,不为写解释重复查询。仅打开、定位、刷新或切换显示格式也可以展示实际回执,不必额外读取值。不要传调用 ID、Key 或自由文本。只有名称线索时先 status → keys,按真实候选读取,候选不唯一且用户未要求全部时先请用户澄清;明确 Key/字段直接 value,只问类型或 TTL 用 key_metadata。保留原查询范围,不用旧选择或历史值代替当前结果。',
|
|
84
|
+
parameters: {},
|
|
85
|
+
output: { schema: { type: 'json' }, render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }] },
|
|
86
|
+
async execute(args, exec) {
|
|
87
|
+
exec.signal.throwIfAborted();
|
|
88
|
+
if (exec.agent === undefined)
|
|
89
|
+
throw new Error('Redis 工具调用缺少有效的 DSH 对话身份。');
|
|
90
|
+
if (Object.keys(args).length !== 0)
|
|
91
|
+
throw new Error('完成回答不接受参数;本轮读取记录由 Host 自动引用。');
|
|
92
|
+
const sessionId = exec.agent.session.id, current = sessions.get(sessionId);
|
|
93
|
+
const target = currentConnection(sessionId);
|
|
94
|
+
if ([...(current?.calls.values() ?? [])].some(record => record.result === undefined))
|
|
95
|
+
throw new Error('本轮还有读取未结束,请等待结果后再回答。');
|
|
96
|
+
const records = [...(current?.calls ?? [])].filter(([, record]) => {
|
|
97
|
+
const connection = record.result?.connection;
|
|
98
|
+
return typeof connection === 'object' && connection !== null && 'id' in connection && 'generation' in connection && 'db' in connection && connection.id === target.id && connection.generation === target.generation && connection.db === target.db;
|
|
99
|
+
});
|
|
100
|
+
if (records.length === 0)
|
|
101
|
+
throw new Error('本轮当前连接和 DB 尚无已完成的读取,请先查询再回答。');
|
|
102
|
+
const hasData = records.some(([, record]) => record.tool !== 'redis_viewer_status' && record.tool !== 'redis_viewer_select_db');
|
|
103
|
+
const answers = records.filter(([, record]) => !hasData || (record.tool !== 'redis_viewer_status' && record.tool !== 'redis_viewer_select_db')).map(([callId, record]) => ({ callId, tool: record.tool, ...describeRedisResult(record.tool, record.result ?? {}) }));
|
|
104
|
+
const summaries = summarizeRedisFilters(records.filter(([, record]) => record.tool === 'redis_viewer_filter_hash').map(([callId, record]) => ({ callId, inputCursor: record.inputCursor, result: record.result ?? {} })));
|
|
105
|
+
for (const answer of answers) {
|
|
106
|
+
const summary = summaries.get(answer.callId);
|
|
107
|
+
if (summary !== undefined) {
|
|
108
|
+
answer.paragraphs.push(...summary.paragraphs);
|
|
109
|
+
answer.values.push(...summary.values);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const omittedCalls = current?.omittedCalls ?? 0;
|
|
113
|
+
if (omittedCalls > 0)
|
|
114
|
+
answers[0]?.paragraphs.unshift(`本轮较早的 ${omittedCalls} 次调用已超出摘要保留上限;这里仅汇总最近记录,不是完整查询汇总,早期结果请查看原调用。`);
|
|
115
|
+
const result = { readOnly: true, state: 'answered', omittedCalls, answers };
|
|
116
|
+
if (Buffer.byteLength(JSON.stringify(result)) > MAX_AI_RESULT_BYTES) {
|
|
117
|
+
// Do not truncate a JSON value or silently discard an earlier page.
|
|
118
|
+
// The original call cards already own every value; keep all summaries.
|
|
119
|
+
for (const answer of answers) {
|
|
120
|
+
answer.values = [];
|
|
121
|
+
answer.paragraphs.push('本轮原值较大,答案只汇总状态与范围;原值请展开对应读取卡片查看。');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (Buffer.byteLength(JSON.stringify(result)) > MAX_AI_RESULT_BYTES)
|
|
125
|
+
throw new Error('本轮摘要超过答案预算,请查看对应读取卡片。');
|
|
126
|
+
exec.signal.throwIfAborted();
|
|
127
|
+
// Evidence is not an answer to every user question. Leave the native
|
|
128
|
+
// assistant step open so it can explain these facts and their limits.
|
|
129
|
+
return result;
|
|
130
|
+
},
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AiBudgetStatus } from '../domain.js';
|
|
2
|
+
/** Independent limits for one DSH session, shared by all AI result producers. */
|
|
3
|
+
export declare const MAX_AI_RESULT_BYTES: number;
|
|
4
|
+
export declare const MAX_AI_SESSION_CALLS = 32;
|
|
5
|
+
export declare const MAX_AI_SESSION_BYTES: number;
|
|
6
|
+
/** Opaque identity: only the exact object returned by begin can be finished. */
|
|
7
|
+
export interface AiBudgetLease {
|
|
8
|
+
readonly sessionId: string;
|
|
9
|
+
}
|
|
10
|
+
export type AiBudgetStart = {
|
|
11
|
+
readonly ok: true;
|
|
12
|
+
readonly lease: AiBudgetLease;
|
|
13
|
+
readonly status: AiBudgetStatus;
|
|
14
|
+
} | {
|
|
15
|
+
readonly ok: false;
|
|
16
|
+
readonly reason: 'exhausted' | 'busy';
|
|
17
|
+
readonly status: AiBudgetStatus;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Reserves a full result before dispatch, so overlapping calls cannot exceed
|
|
21
|
+
* the session budget. The caller must finish every admitted call, including
|
|
22
|
+
* failures and cancellation, with the number of bytes actually returned.
|
|
23
|
+
*/
|
|
24
|
+
export declare class RedisAiBudget {
|
|
25
|
+
private readonly sessions;
|
|
26
|
+
private readonly maxCalls;
|
|
27
|
+
private readonly maxBytes;
|
|
28
|
+
private readonly maxResultBytes;
|
|
29
|
+
constructor(limits?: {
|
|
30
|
+
readonly maxCalls?: number;
|
|
31
|
+
readonly maxBytes?: number;
|
|
32
|
+
readonly maxResultBytes?: number;
|
|
33
|
+
});
|
|
34
|
+
private snapshot;
|
|
35
|
+
status(sessionId: string): AiBudgetStatus;
|
|
36
|
+
begin(sessionId: string): AiBudgetStart;
|
|
37
|
+
/** Returns false for a stale, already finished, or disposed lease. */
|
|
38
|
+
finish(lease: AiBudgetLease, returnedBytes: number, commit?: () => void): boolean;
|
|
39
|
+
/** Called only by a trusted user action; pending work cannot cross a reset. */
|
|
40
|
+
resume(sessionId: string): boolean;
|
|
41
|
+
disposeSession(sessionId: string): void;
|
|
42
|
+
dispose(): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Independent limits for one DSH session, shared by all AI result producers. */
|
|
2
|
+
export const MAX_AI_RESULT_BYTES = 64 * 1024;
|
|
3
|
+
export const MAX_AI_SESSION_CALLS = 32;
|
|
4
|
+
export const MAX_AI_SESSION_BYTES = 1024 * 1024;
|
|
5
|
+
/**
|
|
6
|
+
* Reserves a full result before dispatch, so overlapping calls cannot exceed
|
|
7
|
+
* the session budget. The caller must finish every admitted call, including
|
|
8
|
+
* failures and cancellation, with the number of bytes actually returned.
|
|
9
|
+
*/
|
|
10
|
+
export class RedisAiBudget {
|
|
11
|
+
sessions = new Map();
|
|
12
|
+
maxCalls;
|
|
13
|
+
maxBytes;
|
|
14
|
+
maxResultBytes;
|
|
15
|
+
constructor(limits = {}) {
|
|
16
|
+
this.maxCalls = limits.maxCalls ?? MAX_AI_SESSION_CALLS;
|
|
17
|
+
this.maxBytes = limits.maxBytes ?? MAX_AI_SESSION_BYTES;
|
|
18
|
+
this.maxResultBytes = limits.maxResultBytes ?? MAX_AI_RESULT_BYTES;
|
|
19
|
+
if (![this.maxCalls, this.maxBytes, this.maxResultBytes].every(value => Number.isSafeInteger(value) && value > 0) || this.maxResultBytes > this.maxBytes) {
|
|
20
|
+
throw new RangeError('Invalid AI budget limits');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
snapshot(state) {
|
|
24
|
+
const callsUsed = state?.callsUsed ?? 0, bytesUsed = state?.bytesUsed ?? 0;
|
|
25
|
+
return {
|
|
26
|
+
callsUsed, maxCalls: this.maxCalls, bytesUsed, maxBytes: this.maxBytes,
|
|
27
|
+
inFlight: state?.leases.size ?? 0,
|
|
28
|
+
// A partial remaining allowance cannot safely reserve a complete result.
|
|
29
|
+
stopped: callsUsed >= this.maxCalls || bytesUsed + this.maxResultBytes > this.maxBytes,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
status(sessionId) { return this.snapshot(this.sessions.get(sessionId)); }
|
|
33
|
+
begin(sessionId) {
|
|
34
|
+
if (sessionId.length === 0)
|
|
35
|
+
throw new Error('Missing AI session identity');
|
|
36
|
+
let state = this.sessions.get(sessionId);
|
|
37
|
+
if (state === undefined) {
|
|
38
|
+
state = { callsUsed: 0, bytesUsed: 0, leases: new Set() };
|
|
39
|
+
this.sessions.set(sessionId, state);
|
|
40
|
+
}
|
|
41
|
+
const status = this.snapshot(state);
|
|
42
|
+
if (status.stopped)
|
|
43
|
+
return { ok: false, reason: 'exhausted', status };
|
|
44
|
+
if (state.bytesUsed + (state.leases.size + 1) * this.maxResultBytes > this.maxBytes)
|
|
45
|
+
return { ok: false, reason: 'busy', status };
|
|
46
|
+
const lease = Object.freeze({ sessionId });
|
|
47
|
+
state.callsUsed++;
|
|
48
|
+
state.leases.add(lease);
|
|
49
|
+
return { ok: true, lease, status: this.snapshot(state) };
|
|
50
|
+
}
|
|
51
|
+
/** Returns false for a stale, already finished, or disposed lease. */
|
|
52
|
+
finish(lease, returnedBytes, commit) {
|
|
53
|
+
const state = this.sessions.get(lease.sessionId);
|
|
54
|
+
if (state === undefined || !state.leases.has(lease))
|
|
55
|
+
return false;
|
|
56
|
+
if (!Number.isSafeInteger(returnedBytes) || returnedBytes < 0 || returnedBytes > this.maxResultBytes) {
|
|
57
|
+
state.leases.delete(lease);
|
|
58
|
+
throw new RangeError('Invalid AI result byte count');
|
|
59
|
+
}
|
|
60
|
+
// Commit and accounting run synchronously as one transition. A rejected
|
|
61
|
+
// commit leaves the lease for the caller's zero-byte failure cleanup.
|
|
62
|
+
commit?.();
|
|
63
|
+
state.leases.delete(lease);
|
|
64
|
+
state.bytesUsed += returnedBytes;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/** Called only by a trusted user action; pending work cannot cross a reset. */
|
|
68
|
+
resume(sessionId) {
|
|
69
|
+
const state = this.sessions.get(sessionId);
|
|
70
|
+
if (state === undefined || state.leases.size !== 0 || !this.snapshot(state).stopped)
|
|
71
|
+
return false;
|
|
72
|
+
state.callsUsed = 0;
|
|
73
|
+
state.bytesUsed = 0;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
disposeSession(sessionId) { this.sessions.delete(sessionId); }
|
|
77
|
+
dispose() { this.sessions.clear(); }
|
|
78
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
|
+
import type { ConnectionTarget, ConnectionView, SavedConnection } from '../domain.js';
|
|
4
|
+
import type { RedisAiReader } from './ai-reader.js';
|
|
5
|
+
import type { CandidateConnectionResult } from './connection-service.js';
|
|
6
|
+
import type { RedisProfileSnapshots } from './profile-snapshots.js';
|
|
7
|
+
/** A model can refer only to a recently listed, unchanged local connection profile. */
|
|
8
|
+
export declare function registerRedisConnectionTools(ctx: Context, reader: RedisAiReader, snapshots: RedisProfileSnapshots, connect: (agent: Agent, profile: SavedConnection, signal: AbortSignal, isCurrent: () => boolean) => Promise<CandidateConnectionResult>, disconnect: (agent: Agent, target: ConnectionTarget, signal: AbortSignal) => Promise<ConnectionView>): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
2
|
+
import { connectionTargetSchema } from "../typert.shared.js";
|
|
3
|
+
/** A model can refer only to a recently listed, unchanged local connection profile. */
|
|
4
|
+
export function registerRedisConnectionTools(ctx, reader, snapshots, connect, disconnect) {
|
|
5
|
+
ctx.tools.register(defineTool({
|
|
6
|
+
name: 'redis_viewer_connect_profile',
|
|
7
|
+
description: '仅在用户明确要求连接或切换到某个已保存 Redis 资料,且名称已唯一确定时使用。先调用 redis_viewer_profiles,传入同一会话最近列出的 id 和 snapshotToken;资料变化、令牌过期或会话不匹配会拒绝。不会接收地址、密码或凭据;若需要密码,请用户在 Redis 本地连接表单填写。失败保留旧连接;成功从 DB 0 开始。取消或回执丢失后连接结果可能未知,先查看状态,不盲目重试。',
|
|
8
|
+
parameters: { id: { type: 'string', required: true }, snapshotToken: { type: 'string', required: true } },
|
|
9
|
+
output: { schema: { type: 'json' }, render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }] }, timeoutMs: 15000,
|
|
10
|
+
async execute(args, exec) {
|
|
11
|
+
exec.signal.throwIfAborted();
|
|
12
|
+
const agent = exec.agent;
|
|
13
|
+
if (agent === undefined)
|
|
14
|
+
throw new Error('Redis 工具调用缺少有效的 DSH 对话身份。');
|
|
15
|
+
if (Object.keys(args).some(key => key !== 'id' && key !== 'snapshotToken'))
|
|
16
|
+
throw new Error('Redis 工具包含不支持的参数。');
|
|
17
|
+
if (args.id.length === 0 || args.id.length > 128 || !/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/u.test(args.snapshotToken))
|
|
18
|
+
throw new Error('连接资料或令牌无效,请重新列出。');
|
|
19
|
+
return reader.withBudget(agent.session.id, exec.signal, async () => {
|
|
20
|
+
const profile = snapshots.resolve(agent.session.id, args.id, args.snapshotToken);
|
|
21
|
+
if (profile === undefined)
|
|
22
|
+
throw new Error('连接资料令牌已失效或不属于当前对话,请重新列出。');
|
|
23
|
+
const isCurrent = () => JSON.stringify(snapshots.resolve(agent.session.id, args.id, args.snapshotToken)) === JSON.stringify(profile);
|
|
24
|
+
const result = await connect(agent, profile, exec.signal, isCurrent);
|
|
25
|
+
const view = result.state === 'failed' ? null : result.view;
|
|
26
|
+
return { state: result.state, error: result.state === 'failed' ? result.error : view?.error ?? null, previousRelease: result.state === 'failed' ? null : result.previousRelease, connection: view === null ? null : { id: view.id, generation: view.generation, db: view.db, state: view.state }, message: result.state === 'failed' && result.error === 'auth' ? '需要认证,请在 Redis 本地连接表单输入凭据。' : result.state === 'failed' && result.error === 'stale' ? '连接资料或当前目标已变化,请查看状态并重新选择。' : result.state === 'changed' ? '连接交换后状态已变化,请查看当前状态。' : null, sampledAt: new Date().toISOString() };
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
ctx.tools.register(defineTool({
|
|
31
|
+
name: 'redis_viewer_disconnect',
|
|
32
|
+
description: '仅在用户明确要求断开当前对话的 Redis 连接时调用。先调用 redis_viewer_status,并传入该结果的 connection.id 与 connection.generation;连接已变化时拒绝,不影响其他会话。取消或回执丢失后结果可能未知,先查询当前状态。',
|
|
33
|
+
parameters: { id: { type: 'string', required: true }, generation: { type: 'integer', required: true } },
|
|
34
|
+
output: { schema: { type: 'json' }, render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }] }, timeoutMs: 15000,
|
|
35
|
+
async execute(args, exec) {
|
|
36
|
+
exec.signal.throwIfAborted();
|
|
37
|
+
const agent = exec.agent;
|
|
38
|
+
if (agent === undefined)
|
|
39
|
+
throw new Error('Redis 工具调用缺少有效的 DSH 对话身份。');
|
|
40
|
+
if (Object.keys(args).some(key => key !== 'id' && key !== 'generation'))
|
|
41
|
+
throw new Error('Redis 工具包含不支持的参数。');
|
|
42
|
+
const target = connectionTargetSchema.parse(args);
|
|
43
|
+
return reader.withBudget(agent.session.id, exec.signal, async () => {
|
|
44
|
+
const view = await disconnect(agent, target, exec.signal);
|
|
45
|
+
return { state: view.error === 'stale' ? 'stale' : view.state === 'disconnected' ? 'disconnected' : 'failed', connection: { id: view.id, generation: view.generation, db: view.db, state: view.state }, error: view.error, sampledAt: new Date().toISOString() };
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DatabaseTarget } from '../domain.js';
|
|
2
|
+
import { type PreparedAiPage } from './ai-page-store.js';
|
|
3
|
+
import type { RedisConnections } from './connection-service.js';
|
|
4
|
+
/** Independent scan state keeps filters from consuming the normal AI or UI cursor. */
|
|
5
|
+
export declare class RedisAiHashFilter {
|
|
6
|
+
private readonly connections;
|
|
7
|
+
private readonly keys;
|
|
8
|
+
private readonly pages;
|
|
9
|
+
constructor(connections: RedisConnections);
|
|
10
|
+
prepare(sessionId: string, target: DatabaseTarget, pattern: string, fieldBase64: string, expectedBase64: string, cursor: string | null, signal: AbortSignal): Promise<PreparedAiPage>;
|
|
11
|
+
disposeSession(sessionId: string): void;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { scanKeysResultSchema } from "../typert.shared.js";
|
|
3
|
+
import { connectionErrorMessages } from "../connection-errors.js";
|
|
4
|
+
import { MAX_AI_RESULT_BYTES } from "./ai-budget.js";
|
|
5
|
+
import { AiPageStore } from "./ai-page-store.js";
|
|
6
|
+
import { KEY_SCAN_SCOPE, RedisKeys } from "./key-reader.js";
|
|
7
|
+
import { RedisSelectedReader } from "./selected-reader.js";
|
|
8
|
+
/** The per-call limit applies to actual candidate reads, not Redis SCAN's COUNT hint. */
|
|
9
|
+
const MAX_CANDIDATES_PER_CALL = 10;
|
|
10
|
+
const RESULT_RESERVE = ' '.repeat(4096);
|
|
11
|
+
/** Independent scan state keeps filters from consuming the normal AI or UI cursor. */
|
|
12
|
+
export class RedisAiHashFilter {
|
|
13
|
+
connections;
|
|
14
|
+
keys;
|
|
15
|
+
pages = new AiPageStore('f:');
|
|
16
|
+
constructor(connections) {
|
|
17
|
+
this.connections = connections;
|
|
18
|
+
this.keys = new RedisKeys(connections);
|
|
19
|
+
}
|
|
20
|
+
async prepare(sessionId, target, pattern, fieldBase64, expectedBase64, cursor, signal) {
|
|
21
|
+
// Both texts were validated losslessly at the reader boundary. Keep the full
|
|
22
|
+
// predicate in every recorded page, including empty and failed results.
|
|
23
|
+
const condition = { field: Buffer.from(fieldBase64, 'base64').toString('utf8'), equals: Buffer.from(expectedBase64, 'base64').toString('utf8') };
|
|
24
|
+
const page = await this.pages.prepare({
|
|
25
|
+
sessionId, binding: JSON.stringify([target.id, target.generation, target.db, pattern, fieldBase64, expectedBase64]), selection: null, cursor, signal,
|
|
26
|
+
fetch: next => this.keys.scan(sessionId, { target, pattern, cursor: next }, signal),
|
|
27
|
+
rows: result => result.keys,
|
|
28
|
+
// Measure the actual condition too: JSON escaping can expand control text.
|
|
29
|
+
// The reserve covers counts and connection metadata, not the predicate.
|
|
30
|
+
output: (result, keys, next) => ({ ...result, condition, keys, cursor: next, reserve: RESULT_RESERVE }),
|
|
31
|
+
validate: error => this.connections.assertReadResult(sessionId, target, error),
|
|
32
|
+
discard: () => this.keys.disposeSession(sessionId),
|
|
33
|
+
maxRows: MAX_CANDIDATES_PER_CALL,
|
|
34
|
+
oversize: '单个 Key 身份超过筛选结果预算,请缩小范围。',
|
|
35
|
+
});
|
|
36
|
+
try {
|
|
37
|
+
const raw = page.result;
|
|
38
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
|
|
39
|
+
throw new Error('筛选页格式无效。');
|
|
40
|
+
// The AI continuation has an f: prefix; only the underlying Redis scan
|
|
41
|
+
// cursor uses the shared UUID-only RPC schema.
|
|
42
|
+
const cursor = raw.cursor === null ? null : z.string().regex(/^f:[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/u).parse(raw.cursor);
|
|
43
|
+
const data = scanKeysResultSchema.parse({ state: raw.state, error: raw.error, keys: raw.keys, cursor: null, sampledAt: raw.sampledAt });
|
|
44
|
+
if (data.state === 'failed' && cursor !== null)
|
|
45
|
+
throw new Error('筛选失败结果包含无效游标。');
|
|
46
|
+
const expected = Buffer.from(expectedBase64, 'base64'), matches = [];
|
|
47
|
+
const counts = { checked: 0, matched: 0, different: 0, missingField: 0, missingKey: 0, notHash: 0, typeChanged: 0, failed: 0 };
|
|
48
|
+
const errors = new Set();
|
|
49
|
+
const readStartedAt = new Date().toISOString();
|
|
50
|
+
if (data.state === 'page')
|
|
51
|
+
for (const key of data.keys) {
|
|
52
|
+
signal.throwIfAborted();
|
|
53
|
+
const sample = await new RedisSelectedReader(this.connections).read(sessionId, target, key.base64, { kind: 'hash', fieldBase64 }, signal, undefined, 'unsupported');
|
|
54
|
+
signal.throwIfAborted();
|
|
55
|
+
this.connections.assertReadResult(sessionId, target, sample.error);
|
|
56
|
+
counts.checked++;
|
|
57
|
+
if (sample.state === 'value' && sample.cell !== null) {
|
|
58
|
+
// The expected value is bounded and only exact complete bytes can match.
|
|
59
|
+
if (sample.cell.fullByteLength === expected.length && Buffer.from(sample.cell.base64, 'base64').equals(expected)) {
|
|
60
|
+
counts.matched++;
|
|
61
|
+
matches.push(key);
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
counts.different++;
|
|
65
|
+
}
|
|
66
|
+
else if (sample.state === 'selection-missing')
|
|
67
|
+
counts.missingField++;
|
|
68
|
+
else if (sample.state === 'missing')
|
|
69
|
+
counts.missingKey++;
|
|
70
|
+
else if (sample.state === 'unsupported')
|
|
71
|
+
counts.notHash++;
|
|
72
|
+
else if (sample.state === 'changed')
|
|
73
|
+
counts.typeChanged++;
|
|
74
|
+
else {
|
|
75
|
+
counts.failed++;
|
|
76
|
+
if (sample.error !== null)
|
|
77
|
+
errors.add(sample.error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
signal.throwIfAborted();
|
|
81
|
+
this.connections.assertReadResult(sessionId, target, data.error);
|
|
82
|
+
const result = z.json().parse({ readOnly: true, connection: this.connections.status(sessionId), pattern, condition, scanScope: KEY_SCAN_SCOPE, state: data.state, error: data.error,
|
|
83
|
+
errorMessage: data.error === null ? null : connectionErrorMessages[data.error].zh, matches, counts, errors: [...errors], cursor,
|
|
84
|
+
scanComplete: data.state === 'page' && cursor === null, sampledAt: data.sampledAt, readStartedAt, readFinishedAt: new Date().toISOString(),
|
|
85
|
+
coverage: '本批候选;跨批可能重复,SCAN 与逐项读取不是同一时刻的快照。' });
|
|
86
|
+
if (Buffer.byteLength(JSON.stringify(result)) > MAX_AI_RESULT_BYTES)
|
|
87
|
+
throw new Error('筛选结果超过单次预算,请缩小范围。');
|
|
88
|
+
return { ...page, result };
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
page.rollback();
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
disposeSession(sessionId) { this.pages.disposeSession(sessionId); this.keys.disposeSession(sessionId); }
|
|
96
|
+
dispose() { this.pages.dispose(); this.keys.dispose(); }
|
|
97
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DatabaseTarget } from '../domain.js';
|
|
2
|
+
import type { RedisConnections } from './connection-service.js';
|
|
3
|
+
import type { RedisHashes } from './hash-reader.js';
|
|
4
|
+
import { type PreparedAiPage } from './ai-page-store.js';
|
|
5
|
+
export declare const isAiHashCursor: (cursor: string | null) => boolean;
|
|
6
|
+
/** Hash values preserve their own continuation and whole-field identity. */
|
|
7
|
+
export declare class RedisAiHashPages {
|
|
8
|
+
private readonly connections;
|
|
9
|
+
private readonly hashes;
|
|
10
|
+
private readonly pages;
|
|
11
|
+
constructor(connections: RedisConnections, hashes: RedisHashes);
|
|
12
|
+
disposeSession(sessionId: string): void;
|
|
13
|
+
dispose(): void;
|
|
14
|
+
prepare(sessionId: string, target: DatabaseTarget, keyBase64: string, pattern: string, cursor: string | null, selected: object | null, assertSelection: () => void, signal: AbortSignal): Promise<PreparedAiPage>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { connectionErrorMessages, keyStateMessages } from "../connection-errors.js";
|
|
2
|
+
import { byteIdentity } from "./byte-identity.js";
|
|
3
|
+
import { aiValue } from "./ai-value.js";
|
|
4
|
+
import { AiPageStore } from "./ai-page-store.js";
|
|
5
|
+
export const isAiHashCursor = (cursor) => cursor?.startsWith('h:') === true;
|
|
6
|
+
/** Hash values preserve their own continuation and whole-field identity. */
|
|
7
|
+
export class RedisAiHashPages {
|
|
8
|
+
connections;
|
|
9
|
+
hashes;
|
|
10
|
+
pages = new AiPageStore('h:');
|
|
11
|
+
constructor(connections, hashes) {
|
|
12
|
+
this.connections = connections;
|
|
13
|
+
this.hashes = hashes;
|
|
14
|
+
}
|
|
15
|
+
disposeSession(sessionId) { this.pages.disposeSession(sessionId); this.hashes.disposeSession(sessionId); }
|
|
16
|
+
dispose() { this.pages.dispose(); this.hashes.dispose(); }
|
|
17
|
+
prepare(sessionId, target, keyBase64, pattern, cursor, selected, assertSelection, signal) {
|
|
18
|
+
signal.throwIfAborted();
|
|
19
|
+
this.connections.assertTarget(sessionId, target);
|
|
20
|
+
assertSelection();
|
|
21
|
+
const identity = byteIdentity(Buffer.from(keyBase64, 'base64'));
|
|
22
|
+
return this.pages.prepare({
|
|
23
|
+
sessionId, binding: JSON.stringify([target.id, target.generation, target.db, keyBase64, pattern, selected !== null]), selection: selected, cursor, signal,
|
|
24
|
+
fetch: async (next) => {
|
|
25
|
+
const read = await this.hashes.scan(sessionId, { target, keyBase64, pattern, cursor: next }, signal);
|
|
26
|
+
// Discovery saw Hash; a different type in the reader means it changed.
|
|
27
|
+
return read.state === 'unsupported' && read.metadata?.type !== 'hash' ? { ...read, state: 'changed', metadata: null } : read;
|
|
28
|
+
},
|
|
29
|
+
rows: page => page.entries,
|
|
30
|
+
output: (page, rows, next, first) => {
|
|
31
|
+
const entries = rows.map(entry => ({ field: entry.field, value: aiValue(entry.value) }));
|
|
32
|
+
const errorMessage = page.error !== null ? connectionErrorMessages[page.error].zh : page.state === 'missing' || page.state === 'changed' ? keyStateMessages[page.state].zh : null;
|
|
33
|
+
return { readOnly: true, connection: this.connections.status(sessionId), source: selected === null ? 'explicit' : 'selection', key: identity, errorMessage,
|
|
34
|
+
value: { ...page, entries, cursor: next, scanComplete: page.state === 'page' && next === null,
|
|
35
|
+
complete: page.state === 'page' && first && pattern === '*' && next === null && String(entries.length) === page.metadata?.length && entries.every(entry => entry.value.complete) } };
|
|
36
|
+
},
|
|
37
|
+
validate: error => { assertSelection(); this.connections.assertReadResult(sessionId, target, error); },
|
|
38
|
+
discard: () => this.hashes.disposeSession(sessionId),
|
|
39
|
+
oversize: '单个 Hash 字段或其必要元信息超过 AI 单次结果上限,无法完整返回;请缩小匹配范围。',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DatabaseTarget } from '../domain.js';
|
|
2
|
+
import type { RedisConnections } from './connection-service.js';
|
|
3
|
+
import { type RedisKeys } from './key-reader.js';
|
|
4
|
+
import { type PreparedAiPage } from './ai-page-store.js';
|
|
5
|
+
/** Key results keep their own store and the existing opaque UUID format. */
|
|
6
|
+
export declare class RedisAiKeyPages {
|
|
7
|
+
private readonly connections;
|
|
8
|
+
private readonly keys;
|
|
9
|
+
private readonly pages;
|
|
10
|
+
constructor(connections: RedisConnections, keys: RedisKeys);
|
|
11
|
+
disposeSession(sessionId: string): void;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
prepare(sessionId: string, target: DatabaseTarget, pattern: string, cursor: string | null, signal: AbortSignal): Promise<PreparedAiPage>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { connectionErrorMessages } from "../connection-errors.js";
|
|
2
|
+
import { KEY_SCAN_SCOPE } from "./key-reader.js";
|
|
3
|
+
import { AiPageStore } from "./ai-page-store.js";
|
|
4
|
+
/** Key results keep their own store and the existing opaque UUID format. */
|
|
5
|
+
export class RedisAiKeyPages {
|
|
6
|
+
connections;
|
|
7
|
+
keys;
|
|
8
|
+
pages = new AiPageStore('');
|
|
9
|
+
constructor(connections, keys) {
|
|
10
|
+
this.connections = connections;
|
|
11
|
+
this.keys = keys;
|
|
12
|
+
}
|
|
13
|
+
disposeSession(sessionId) { this.pages.disposeSession(sessionId); this.keys.disposeSession(sessionId); }
|
|
14
|
+
dispose() { this.pages.dispose(); this.keys.dispose(); }
|
|
15
|
+
prepare(sessionId, target, pattern, cursor, signal) {
|
|
16
|
+
return this.pages.prepare({
|
|
17
|
+
sessionId, binding: JSON.stringify([target.id, target.generation, target.db, pattern]), selection: null, cursor, signal,
|
|
18
|
+
fetch: next => this.keys.scan(sessionId, { target, pattern, cursor: next }, signal),
|
|
19
|
+
rows: page => page.keys,
|
|
20
|
+
output: (page, keys, next) => ({ readOnly: true, connection: this.connections.status(sessionId), pattern, scanScope: KEY_SCAN_SCOPE, ...page, keys, returnedCount: keys.length, cursor: next,
|
|
21
|
+
errorMessage: page.error === null ? null : connectionErrorMessages[page.error].zh, scanComplete: page.state === 'page' && next === null }),
|
|
22
|
+
validate: error => this.connections.assertReadResult(sessionId, target, error),
|
|
23
|
+
discard: () => this.keys.disposeSession(sessionId),
|
|
24
|
+
oversize: '单个 Key 或其必要元信息超过 AI 单次结果上限,无法完整返回;请缩小匹配范围。',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { type UiAction } from '../domain.js';
|
|
3
|
+
import type { RedisAiReader } from './ai-reader.js';
|
|
4
|
+
import type { UiActionCoordinator } from './ui-action-coordinator.js';
|
|
5
|
+
/** Locate only an explicitly supplied key in the current trusted session. */
|
|
6
|
+
export declare function registerRedisLocateTool(ctx: Context, reader: RedisAiReader, actions: UiActionCoordinator<UiAction>): void;
|