@tarquinen/opencode-dcp 0.3.16 → 0.3.18
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/README.md +16 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -43
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +1 -15
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +22 -95
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/deduplicator.d.ts +0 -34
- package/dist/lib/deduplicator.d.ts.map +1 -1
- package/dist/lib/deduplicator.js +1 -127
- package/dist/lib/deduplicator.js.map +1 -1
- package/dist/lib/display-utils.d.ts +9 -0
- package/dist/lib/display-utils.d.ts.map +1 -0
- package/dist/lib/display-utils.js +71 -0
- package/dist/lib/display-utils.js.map +1 -0
- package/dist/lib/janitor.d.ts +2 -61
- package/dist/lib/janitor.d.ts.map +1 -1
- package/dist/lib/janitor.js +53 -195
- package/dist/lib/janitor.js.map +1 -1
- package/dist/lib/logger.d.ts +0 -24
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +3 -58
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/model-selector.d.ts +0 -31
- package/dist/lib/model-selector.d.ts.map +1 -1
- package/dist/lib/model-selector.js +0 -55
- package/dist/lib/model-selector.js.map +1 -1
- package/dist/lib/prompt.d.ts.map +1 -1
- package/dist/lib/prompt.js +3 -29
- package/dist/lib/prompt.js.map +1 -1
- package/dist/lib/tokenizer.d.ts +0 -23
- package/dist/lib/tokenizer.d.ts.map +1 -1
- package/dist/lib/tokenizer.js +0 -25
- package/dist/lib/tokenizer.js.map +1 -1
- package/dist/lib/version-checker.d.ts +0 -15
- package/dist/lib/version-checker.d.ts.map +1 -1
- package/dist/lib/version-checker.js +1 -19
- package/dist/lib/version-checker.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/deduplicator.js
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
* Deduplicator Module
|
|
3
|
-
*
|
|
4
|
-
* Handles automatic detection and removal of duplicate tool calls based on
|
|
5
|
-
* tool name + parameter signature matching.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Detects duplicate tool calls based on tool name + parameter signature
|
|
9
|
-
* Keeps only the most recent occurrence of each duplicate set
|
|
10
|
-
* Respects protected tools - they are never deduplicated
|
|
11
|
-
*/
|
|
1
|
+
import { extractParameterKey } from "./display-utils";
|
|
12
2
|
export function detectDuplicates(toolMetadata, unprunedToolCallIds, // In chronological order
|
|
13
3
|
protectedTools) {
|
|
14
4
|
const signatureMap = new Map();
|
|
15
|
-
// Filter out protected tools before processing
|
|
16
5
|
const deduplicatableIds = unprunedToolCallIds.filter(id => {
|
|
17
6
|
const metadata = toolMetadata.get(id);
|
|
18
7
|
return !metadata || !protectedTools.includes(metadata.tool);
|
|
19
8
|
});
|
|
20
|
-
// Build map of signature -> [ids in chronological order]
|
|
21
9
|
for (const id of deduplicatableIds) {
|
|
22
10
|
const metadata = toolMetadata.get(id);
|
|
23
11
|
if (!metadata)
|
|
@@ -28,7 +16,6 @@ protectedTools) {
|
|
|
28
16
|
}
|
|
29
17
|
signatureMap.get(signature).push(id);
|
|
30
18
|
}
|
|
31
|
-
// Identify duplicates (keep only last occurrence)
|
|
32
19
|
const duplicateIds = [];
|
|
33
20
|
const deduplicationDetails = new Map();
|
|
34
21
|
for (const [signature, ids] of signatureMap.entries()) {
|
|
@@ -47,24 +34,13 @@ protectedTools) {
|
|
|
47
34
|
}
|
|
48
35
|
return { duplicateIds, deduplicationDetails };
|
|
49
36
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Creates a deterministic signature for a tool call
|
|
52
|
-
* Format: "toolName::JSON(sortedParameters)"
|
|
53
|
-
*/
|
|
54
37
|
function createToolSignature(tool, parameters) {
|
|
55
38
|
if (!parameters)
|
|
56
39
|
return tool;
|
|
57
|
-
// Normalize parameters for consistent comparison
|
|
58
40
|
const normalized = normalizeParameters(parameters);
|
|
59
41
|
const sorted = sortObjectKeys(normalized);
|
|
60
42
|
return `${tool}::${JSON.stringify(sorted)}`;
|
|
61
43
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Normalize parameters to handle edge cases:
|
|
64
|
-
* - Remove undefined/null values
|
|
65
|
-
* - Resolve relative paths to absolute (future enhancement)
|
|
66
|
-
* - Sort arrays if order doesn't matter (future enhancement)
|
|
67
|
-
*/
|
|
68
44
|
function normalizeParameters(params) {
|
|
69
45
|
if (typeof params !== 'object' || params === null)
|
|
70
46
|
return params;
|
|
@@ -78,9 +54,6 @@ function normalizeParameters(params) {
|
|
|
78
54
|
}
|
|
79
55
|
return normalized;
|
|
80
56
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Recursively sort object keys for deterministic comparison
|
|
83
|
-
*/
|
|
84
57
|
function sortObjectKeys(obj) {
|
|
85
58
|
if (typeof obj !== 'object' || obj === null)
|
|
86
59
|
return obj;
|
|
@@ -92,103 +65,4 @@ function sortObjectKeys(obj) {
|
|
|
92
65
|
}
|
|
93
66
|
return sorted;
|
|
94
67
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Extract human-readable parameter key for notifications
|
|
97
|
-
* Supports all ACTIVE OpenCode tools with appropriate parameter extraction
|
|
98
|
-
*
|
|
99
|
-
* ACTIVE Tools (always available):
|
|
100
|
-
* - File: read, write, edit
|
|
101
|
-
* - Search: list, glob, grep
|
|
102
|
-
* - Execution: bash
|
|
103
|
-
* - Agent: task
|
|
104
|
-
* - Web: webfetch
|
|
105
|
-
* - Todo: todowrite, todoread
|
|
106
|
-
*
|
|
107
|
-
* CONDITIONAL Tools (may be disabled):
|
|
108
|
-
* - batch (experimental.batch_tool flag)
|
|
109
|
-
* - websearch, codesearch (OPENCODE_EXPERIMENTAL_EXA flag)
|
|
110
|
-
*
|
|
111
|
-
* INACTIVE Tools (exist but not registered, skip):
|
|
112
|
-
* - multiedit, patch, lsp_diagnostics, lsp_hover
|
|
113
|
-
*/
|
|
114
|
-
export function extractParameterKey(metadata) {
|
|
115
|
-
if (!metadata.parameters)
|
|
116
|
-
return '';
|
|
117
|
-
const { tool, parameters } = metadata;
|
|
118
|
-
// ===== File Operation Tools =====
|
|
119
|
-
if (tool === "read" && parameters.filePath) {
|
|
120
|
-
return parameters.filePath;
|
|
121
|
-
}
|
|
122
|
-
if (tool === "write" && parameters.filePath) {
|
|
123
|
-
return parameters.filePath;
|
|
124
|
-
}
|
|
125
|
-
if (tool === "edit" && parameters.filePath) {
|
|
126
|
-
return parameters.filePath;
|
|
127
|
-
}
|
|
128
|
-
// ===== Directory/Search Tools =====
|
|
129
|
-
if (tool === "list") {
|
|
130
|
-
// path is optional, defaults to current directory
|
|
131
|
-
return parameters.path || '(current directory)';
|
|
132
|
-
}
|
|
133
|
-
if (tool === "glob") {
|
|
134
|
-
// pattern is required for glob
|
|
135
|
-
if (parameters.pattern) {
|
|
136
|
-
const pathInfo = parameters.path ? ` in ${parameters.path}` : "";
|
|
137
|
-
return `"${parameters.pattern}"${pathInfo}`;
|
|
138
|
-
}
|
|
139
|
-
return '(unknown pattern)';
|
|
140
|
-
}
|
|
141
|
-
if (tool === "grep") {
|
|
142
|
-
if (parameters.pattern) {
|
|
143
|
-
const pathInfo = parameters.path ? ` in ${parameters.path}` : "";
|
|
144
|
-
return `"${parameters.pattern}"${pathInfo}`;
|
|
145
|
-
}
|
|
146
|
-
return '(unknown pattern)';
|
|
147
|
-
}
|
|
148
|
-
// ===== Execution Tools =====
|
|
149
|
-
if (tool === "bash") {
|
|
150
|
-
if (parameters.description)
|
|
151
|
-
return parameters.description;
|
|
152
|
-
if (parameters.command) {
|
|
153
|
-
return parameters.command.length > 50
|
|
154
|
-
? parameters.command.substring(0, 50) + "..."
|
|
155
|
-
: parameters.command;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// ===== Web Tools =====
|
|
159
|
-
if (tool === "webfetch" && parameters.url) {
|
|
160
|
-
return parameters.url;
|
|
161
|
-
}
|
|
162
|
-
if (tool === "websearch" && parameters.query) {
|
|
163
|
-
return `"${parameters.query}"`;
|
|
164
|
-
}
|
|
165
|
-
if (tool === "codesearch" && parameters.query) {
|
|
166
|
-
return `"${parameters.query}"`;
|
|
167
|
-
}
|
|
168
|
-
// ===== Todo Tools =====
|
|
169
|
-
// Note: Todo tools are stateful and in protectedTools by default
|
|
170
|
-
if (tool === "todowrite") {
|
|
171
|
-
return `${parameters.todos?.length || 0} todos`;
|
|
172
|
-
}
|
|
173
|
-
if (tool === "todoread") {
|
|
174
|
-
return "read todo list";
|
|
175
|
-
}
|
|
176
|
-
// ===== Agent/Task Tools =====
|
|
177
|
-
// Note: task is in protectedTools by default
|
|
178
|
-
if (tool === "task" && parameters.description) {
|
|
179
|
-
return parameters.description;
|
|
180
|
-
}
|
|
181
|
-
// Note: batch is experimental and needs special handling
|
|
182
|
-
if (tool === "batch") {
|
|
183
|
-
return `${parameters.tool_calls?.length || 0} parallel tools`;
|
|
184
|
-
}
|
|
185
|
-
// ===== Fallback =====
|
|
186
|
-
// For unknown tools, custom tools, or tools without extractable keys
|
|
187
|
-
// Check if parameters is empty or only has empty values
|
|
188
|
-
const paramStr = JSON.stringify(parameters);
|
|
189
|
-
if (paramStr === '{}' || paramStr === '[]' || paramStr === 'null') {
|
|
190
|
-
return ''; // Return empty to trigger (default) fallback in UI
|
|
191
|
-
}
|
|
192
|
-
return paramStr.substring(0, 50);
|
|
193
|
-
}
|
|
194
68
|
//# sourceMappingURL=deduplicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deduplicator.js","sourceRoot":"","sources":["../../lib/deduplicator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"deduplicator.js","sourceRoot":"","sources":["../../lib/deduplicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAarD,MAAM,UAAU,gBAAgB,CAC5B,YAA6D,EAC7D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AED,SAAS,cAAc,CAAC,GAAQ;IAC5B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,CAAA;IACvD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAEtD,MAAM,MAAM,GAAQ,EAAE,CAAA;IACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts a human-readable key from tool metadata for display purposes.
|
|
3
|
+
* Used by both deduplication and AI analysis to show what was pruned.
|
|
4
|
+
*/
|
|
5
|
+
export declare function extractParameterKey(metadata: {
|
|
6
|
+
tool: string;
|
|
7
|
+
parameters?: any;
|
|
8
|
+
}): string;
|
|
9
|
+
//# sourceMappingURL=display-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display-utils.d.ts","sourceRoot":"","sources":["../../lib/display-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,MAAM,CAuExF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts a human-readable key from tool metadata for display purposes.
|
|
3
|
+
* Used by both deduplication and AI analysis to show what was pruned.
|
|
4
|
+
*/
|
|
5
|
+
export function extractParameterKey(metadata) {
|
|
6
|
+
if (!metadata.parameters)
|
|
7
|
+
return '';
|
|
8
|
+
const { tool, parameters } = metadata;
|
|
9
|
+
if (tool === "read" && parameters.filePath) {
|
|
10
|
+
return parameters.filePath;
|
|
11
|
+
}
|
|
12
|
+
if (tool === "write" && parameters.filePath) {
|
|
13
|
+
return parameters.filePath;
|
|
14
|
+
}
|
|
15
|
+
if (tool === "edit" && parameters.filePath) {
|
|
16
|
+
return parameters.filePath;
|
|
17
|
+
}
|
|
18
|
+
if (tool === "list") {
|
|
19
|
+
return parameters.path || '(current directory)';
|
|
20
|
+
}
|
|
21
|
+
if (tool === "glob") {
|
|
22
|
+
if (parameters.pattern) {
|
|
23
|
+
const pathInfo = parameters.path ? ` in ${parameters.path}` : "";
|
|
24
|
+
return `"${parameters.pattern}"${pathInfo}`;
|
|
25
|
+
}
|
|
26
|
+
return '(unknown pattern)';
|
|
27
|
+
}
|
|
28
|
+
if (tool === "grep") {
|
|
29
|
+
if (parameters.pattern) {
|
|
30
|
+
const pathInfo = parameters.path ? ` in ${parameters.path}` : "";
|
|
31
|
+
return `"${parameters.pattern}"${pathInfo}`;
|
|
32
|
+
}
|
|
33
|
+
return '(unknown pattern)';
|
|
34
|
+
}
|
|
35
|
+
if (tool === "bash") {
|
|
36
|
+
if (parameters.description)
|
|
37
|
+
return parameters.description;
|
|
38
|
+
if (parameters.command) {
|
|
39
|
+
return parameters.command.length > 50
|
|
40
|
+
? parameters.command.substring(0, 50) + "..."
|
|
41
|
+
: parameters.command;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (tool === "webfetch" && parameters.url) {
|
|
45
|
+
return parameters.url;
|
|
46
|
+
}
|
|
47
|
+
if (tool === "websearch" && parameters.query) {
|
|
48
|
+
return `"${parameters.query}"`;
|
|
49
|
+
}
|
|
50
|
+
if (tool === "codesearch" && parameters.query) {
|
|
51
|
+
return `"${parameters.query}"`;
|
|
52
|
+
}
|
|
53
|
+
if (tool === "todowrite") {
|
|
54
|
+
return `${parameters.todos?.length || 0} todos`;
|
|
55
|
+
}
|
|
56
|
+
if (tool === "todoread") {
|
|
57
|
+
return "read todo list";
|
|
58
|
+
}
|
|
59
|
+
if (tool === "task" && parameters.description) {
|
|
60
|
+
return parameters.description;
|
|
61
|
+
}
|
|
62
|
+
if (tool === "batch") {
|
|
63
|
+
return `${parameters.tool_calls?.length || 0} parallel tools`;
|
|
64
|
+
}
|
|
65
|
+
const paramStr = JSON.stringify(parameters);
|
|
66
|
+
if (paramStr === '{}' || paramStr === '[]' || paramStr === 'null') {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
return paramStr.substring(0, 50);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=display-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display-utils.js","sourceRoot":"","sources":["../../lib/display-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAA4C;IAC5E,IAAI,CAAC,QAAQ,CAAC,UAAU;QAAE,OAAO,EAAE,CAAA;IAEnC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAA;IAErC,IAAI,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,UAAU,CAAC,QAAQ,CAAA;IAC9B,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC1C,OAAO,UAAU,CAAC,QAAQ,CAAA;IAC9B,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,UAAU,CAAC,QAAQ,CAAA;IAC9B,CAAC;IAED,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAClB,OAAO,UAAU,CAAC,IAAI,IAAI,qBAAqB,CAAA;IACnD,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAClB,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACrB,MA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AAU,CAAC,KAAK,GAAG,CAAA;IAClC,CAAC;IAED,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACvB,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAA;IACnD,CAAC;IACD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACtB,OAAO,gBAAgB,CAAA;IAC3B,CAAC;IAED,IAAI,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAC5C,OAAO,UAAU,CAAC,WAAW,CAAA;IACjC,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACnB,OAAO,GAAG,UAAU,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC,iBAAiB,CAAA;IACjE,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IAC3C,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QAChE,OAAO,EAAE,CAAA;IACb,CAAC;IACD,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC"}
|
package/dist/lib/janitor.d.ts
CHANGED
|
@@ -30,87 +30,28 @@ export declare class Janitor {
|
|
|
30
30
|
private modelCache;
|
|
31
31
|
private configModel?;
|
|
32
32
|
private showModelErrorToasts;
|
|
33
|
+
private strictModelSelection;
|
|
33
34
|
private pruningSummary;
|
|
34
35
|
private workingDirectory?;
|
|
35
36
|
constructor(client: any, prunedIdsState: Map<string, string[]>, statsState: Map<string, SessionStats>, logger: Logger, toolParametersCache: Map<string, any>, protectedTools: string[], modelCache: Map<string, {
|
|
36
37
|
providerID: string;
|
|
37
38
|
modelID: string;
|
|
38
|
-
}>, configModel?: string | undefined,
|
|
39
|
-
showModelErrorToasts?: boolean, // Whether to show toast for model errors
|
|
40
|
-
pruningSummary?: "off" | "minimal" | "detailed", // UI summary display mode
|
|
41
|
-
workingDirectory?: string | undefined);
|
|
42
|
-
/**
|
|
43
|
-
* Sends an ignored message to the session UI (user sees it, AI doesn't)
|
|
44
|
-
*/
|
|
39
|
+
}>, configModel?: string | undefined, showModelErrorToasts?: boolean, strictModelSelection?: boolean, pruningSummary?: "off" | "minimal" | "detailed", workingDirectory?: string | undefined);
|
|
45
40
|
private sendIgnoredMessage;
|
|
46
|
-
/**
|
|
47
|
-
* Convenience method for idle-triggered pruning (sends notification automatically)
|
|
48
|
-
*/
|
|
49
41
|
runOnIdle(sessionID: string, strategies: PruningStrategy[]): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Convenience method for tool-triggered pruning (returns result for tool output)
|
|
52
|
-
*/
|
|
53
42
|
runForTool(sessionID: string, strategies: PruningStrategy[], reason?: string): Promise<PruningResult | null>;
|
|
54
|
-
/**
|
|
55
|
-
* Core pruning method that accepts strategies and options
|
|
56
|
-
*/
|
|
57
43
|
runWithStrategies(sessionID: string, strategies: PruningStrategy[], options: PruningOptions): Promise<PruningResult | null>;
|
|
58
|
-
/**
|
|
59
|
-
* Helper function to shorten paths for display
|
|
60
|
-
*/
|
|
61
44
|
private shortenPath;
|
|
62
|
-
/**
|
|
63
|
-
* Shorten a single path string
|
|
64
|
-
*/
|
|
65
45
|
private shortenSinglePath;
|
|
66
|
-
/**
|
|
67
|
-
* Replace pruned tool outputs with placeholder text to save tokens in janitor context
|
|
68
|
-
* This applies the same replacement logic as the global fetch wrapper, but for the
|
|
69
|
-
* janitor's shadow inference to avoid sending already-pruned content to the LLM
|
|
70
|
-
*/
|
|
71
46
|
private replacePrunedToolOutputs;
|
|
72
|
-
/**
|
|
73
|
-
* Helper function to calculate token savings from tool outputs
|
|
74
|
-
*/
|
|
75
47
|
private calculateTokensSaved;
|
|
76
|
-
/**
|
|
77
|
-
* Build a summary of tools by grouping them
|
|
78
|
-
* Uses shared extractParameterKey logic for consistent parameter extraction
|
|
79
|
-
*
|
|
80
|
-
* Note: prunedIds may be in original case (from LLM) but toolMetadata uses lowercase keys
|
|
81
|
-
*/
|
|
82
48
|
private buildToolsSummary;
|
|
83
|
-
/**
|
|
84
|
-
* Group deduplication details by tool type
|
|
85
|
-
* Shared helper used by notifications and tool output formatting
|
|
86
|
-
*/
|
|
87
49
|
private groupDeduplicationDetails;
|
|
88
|
-
/**
|
|
89
|
-
* Format grouped deduplication results as lines
|
|
90
|
-
* Shared helper for building deduplication summaries
|
|
91
|
-
*/
|
|
92
50
|
private formatDeduplicationLines;
|
|
93
|
-
/**
|
|
94
|
-
* Format tool summary (from buildToolsSummary) as lines
|
|
95
|
-
* Shared helper for building LLM-pruned summaries
|
|
96
|
-
*/
|
|
97
51
|
private formatToolSummaryLines;
|
|
98
|
-
/**
|
|
99
|
-
* Send minimal summary notification (just tokens saved and count)
|
|
100
|
-
*/
|
|
101
52
|
private sendMinimalNotification;
|
|
102
|
-
/**
|
|
103
|
-
* Auto mode notification - shows only deduplication results
|
|
104
|
-
*/
|
|
105
53
|
private sendAutoModeNotification;
|
|
106
|
-
/**
|
|
107
|
-
* Format pruning result for tool output (returned to AI)
|
|
108
|
-
* Uses shared helpers for consistency with UI notifications
|
|
109
|
-
*/
|
|
110
54
|
formatPruningResultForTool(result: PruningResult): string;
|
|
111
|
-
/**
|
|
112
|
-
* Smart mode notification - shows both deduplication and LLM analysis results
|
|
113
|
-
*/
|
|
114
55
|
private sendSmartModeNotification;
|
|
115
56
|
}
|
|
116
57
|
//# sourceMappingURL=janitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"janitor.d.ts","sourceRoot":"","sources":["../../lib/janitor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"janitor.d.ts","sourceRoot":"","sources":["../../lib/janitor.ts"],"names":[],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