@hcu-lab.me/mcp-device 1.0.9 → 1.0.10
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 +1 -1
- package/dist/device/device.d.ts +1 -0
- package/dist/device/device.js +13 -4
- package/dist/device/gateway-tool-adapter.d.ts +2 -3
- package/dist/device/gateway-tool-adapter.js +121 -97
- package/dist/handlers/filesystem-handlers.js +53 -37
- package/dist/handlers/search-handlers.d.ts +1 -0
- package/dist/handlers/search-handlers.js +51 -1
- package/dist/mcp-device.d.ts +1 -1
- package/dist/mcp-device.js +1 -1
- package/dist/search-manager.d.ts +6 -0
- package/dist/search-manager.js +123 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +2 -2
- package/dist/terminal-manager.d.ts +9 -0
- package/dist/terminal-manager.js +127 -42
- package/dist/tool-dispatcher.d.ts +11 -0
- package/dist/tool-dispatcher.js +224 -0
- package/dist/tools/edit.js +72 -1
- package/dist/tools/filesystem.d.ts +1 -1
- package/dist/tools/filesystem.js +2 -2
- package/dist/tools/improved-process-tools.js +87 -108
- package/dist/tools/schemas.d.ts +94 -2
- package/dist/tools/schemas.js +20 -6
- package/dist/types.d.ts +7 -0
- package/dist/utils/output-budget.d.ts +6 -0
- package/dist/utils/output-budget.js +15 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/tools/schemas.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare const ListProcessesArgsSchema: z.ZodObject<{}, "strip", z.ZodType
|
|
|
23
23
|
export declare const StartProcessArgsSchema: z.ZodObject<{
|
|
24
24
|
command: z.ZodString;
|
|
25
25
|
timeout_ms: z.ZodNumber;
|
|
26
|
+
yield_ms: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
26
28
|
working_directory: z.ZodOptional<z.ZodString>;
|
|
27
29
|
shell: z.ZodOptional<z.ZodString>;
|
|
28
30
|
verbose_timing: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -31,6 +33,8 @@ export declare const StartProcessArgsSchema: z.ZodObject<{
|
|
|
31
33
|
command: string;
|
|
32
34
|
timeout_ms: number;
|
|
33
35
|
origin?: "ui" | "llm" | undefined;
|
|
36
|
+
yield_ms?: number | undefined;
|
|
37
|
+
background?: boolean | undefined;
|
|
34
38
|
working_directory?: string | undefined;
|
|
35
39
|
shell?: string | undefined;
|
|
36
40
|
verbose_timing?: boolean | undefined;
|
|
@@ -38,6 +42,8 @@ export declare const StartProcessArgsSchema: z.ZodObject<{
|
|
|
38
42
|
command: string;
|
|
39
43
|
timeout_ms: number;
|
|
40
44
|
origin?: "ui" | "llm" | undefined;
|
|
45
|
+
yield_ms?: number | undefined;
|
|
46
|
+
background?: boolean | undefined;
|
|
41
47
|
working_directory?: string | undefined;
|
|
42
48
|
shell?: string | undefined;
|
|
43
49
|
verbose_timing?: boolean | undefined;
|
|
@@ -106,10 +112,19 @@ export declare const ReadFileArgsSchema: z.ZodObject<{
|
|
|
106
112
|
}>;
|
|
107
113
|
export declare const ReadMultipleFilesArgsSchema: z.ZodObject<{
|
|
108
114
|
paths: z.ZodArray<z.ZodString, "many">;
|
|
115
|
+
offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
116
|
+
length: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
117
|
+
maxBytes: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
109
118
|
}, "strip", z.ZodTypeAny, {
|
|
119
|
+
length: number;
|
|
120
|
+
offset: number;
|
|
110
121
|
paths: string[];
|
|
122
|
+
maxBytes: number;
|
|
111
123
|
}, {
|
|
112
124
|
paths: string[];
|
|
125
|
+
length?: number | undefined;
|
|
126
|
+
offset?: number | undefined;
|
|
127
|
+
maxBytes?: number | undefined;
|
|
113
128
|
}>;
|
|
114
129
|
export declare const WriteFileArgsSchema: z.ZodObject<{
|
|
115
130
|
path: z.ZodString;
|
|
@@ -287,19 +302,37 @@ export declare const EditBlockArgsSchema: z.ZodEffects<z.ZodObject<{
|
|
|
287
302
|
old_string: z.ZodOptional<z.ZodString>;
|
|
288
303
|
new_string: z.ZodOptional<z.ZodString>;
|
|
289
304
|
expected_replacements: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
305
|
+
edits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
306
|
+
old_string: z.ZodString;
|
|
307
|
+
new_string: z.ZodString;
|
|
308
|
+
expected_replacements: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
309
|
+
}, "strip", z.ZodTypeAny, {
|
|
310
|
+
old_string: string;
|
|
311
|
+
new_string: string;
|
|
312
|
+
expected_replacements: number;
|
|
313
|
+
}, {
|
|
314
|
+
old_string: string;
|
|
315
|
+
new_string: string;
|
|
316
|
+
expected_replacements?: number | undefined;
|
|
317
|
+
}>, "many">>;
|
|
290
318
|
range: z.ZodOptional<z.ZodString>;
|
|
291
319
|
content: z.ZodOptional<z.ZodAny>;
|
|
292
320
|
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
293
321
|
origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
|
|
294
322
|
}, "strip", z.ZodTypeAny, {
|
|
295
|
-
file_path: string;
|
|
296
323
|
expected_replacements: number;
|
|
324
|
+
file_path: string;
|
|
297
325
|
origin?: "ui" | "llm" | undefined;
|
|
298
326
|
options?: Record<string, any> | undefined;
|
|
299
327
|
range?: string | undefined;
|
|
300
328
|
content?: any;
|
|
301
329
|
old_string?: string | undefined;
|
|
302
330
|
new_string?: string | undefined;
|
|
331
|
+
edits?: {
|
|
332
|
+
old_string: string;
|
|
333
|
+
new_string: string;
|
|
334
|
+
expected_replacements: number;
|
|
335
|
+
}[] | undefined;
|
|
303
336
|
}, {
|
|
304
337
|
file_path: string;
|
|
305
338
|
origin?: "ui" | "llm" | undefined;
|
|
@@ -309,15 +342,25 @@ export declare const EditBlockArgsSchema: z.ZodEffects<z.ZodObject<{
|
|
|
309
342
|
old_string?: string | undefined;
|
|
310
343
|
new_string?: string | undefined;
|
|
311
344
|
expected_replacements?: number | undefined;
|
|
345
|
+
edits?: {
|
|
346
|
+
old_string: string;
|
|
347
|
+
new_string: string;
|
|
348
|
+
expected_replacements?: number | undefined;
|
|
349
|
+
}[] | undefined;
|
|
312
350
|
}>, {
|
|
313
|
-
file_path: string;
|
|
314
351
|
expected_replacements: number;
|
|
352
|
+
file_path: string;
|
|
315
353
|
origin?: "ui" | "llm" | undefined;
|
|
316
354
|
options?: Record<string, any> | undefined;
|
|
317
355
|
range?: string | undefined;
|
|
318
356
|
content?: any;
|
|
319
357
|
old_string?: string | undefined;
|
|
320
358
|
new_string?: string | undefined;
|
|
359
|
+
edits?: {
|
|
360
|
+
old_string: string;
|
|
361
|
+
new_string: string;
|
|
362
|
+
expected_replacements: number;
|
|
363
|
+
}[] | undefined;
|
|
321
364
|
}, {
|
|
322
365
|
file_path: string;
|
|
323
366
|
origin?: "ui" | "llm" | undefined;
|
|
@@ -327,6 +370,11 @@ export declare const EditBlockArgsSchema: z.ZodEffects<z.ZodObject<{
|
|
|
327
370
|
old_string?: string | undefined;
|
|
328
371
|
new_string?: string | undefined;
|
|
329
372
|
expected_replacements?: number | undefined;
|
|
373
|
+
edits?: {
|
|
374
|
+
old_string: string;
|
|
375
|
+
new_string: string;
|
|
376
|
+
expected_replacements?: number | undefined;
|
|
377
|
+
}[] | undefined;
|
|
330
378
|
}>;
|
|
331
379
|
export declare const InteractWithProcessArgsSchema: z.ZodObject<{
|
|
332
380
|
pid: z.ZodNumber;
|
|
@@ -388,6 +436,50 @@ export declare const StartSearchArgsSchema: z.ZodObject<{
|
|
|
388
436
|
earlyTermination?: boolean | undefined;
|
|
389
437
|
literalSearch?: boolean | undefined;
|
|
390
438
|
}>;
|
|
439
|
+
export declare const SearchOnceArgsSchema: z.ZodObject<{
|
|
440
|
+
path: z.ZodString;
|
|
441
|
+
pattern: z.ZodString;
|
|
442
|
+
searchType: z.ZodDefault<z.ZodEnum<["files", "content"]>>;
|
|
443
|
+
filePattern: z.ZodOptional<z.ZodString>;
|
|
444
|
+
ignoreCase: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
445
|
+
maxResults: z.ZodOptional<z.ZodNumber>;
|
|
446
|
+
includeHidden: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
447
|
+
contextLines: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
448
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
449
|
+
earlyTermination: z.ZodOptional<z.ZodBoolean>;
|
|
450
|
+
literalSearch: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
451
|
+
origin: z.ZodOptional<z.ZodEnum<["ui", "llm"]>>;
|
|
452
|
+
} & {
|
|
453
|
+
maxBytes: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
454
|
+
}, "strip", z.ZodTypeAny, {
|
|
455
|
+
path: string;
|
|
456
|
+
maxBytes: number;
|
|
457
|
+
pattern: string;
|
|
458
|
+
searchType: "content" | "files";
|
|
459
|
+
ignoreCase: boolean;
|
|
460
|
+
includeHidden: boolean;
|
|
461
|
+
contextLines: number;
|
|
462
|
+
literalSearch: boolean;
|
|
463
|
+
origin?: "ui" | "llm" | undefined;
|
|
464
|
+
timeout_ms?: number | undefined;
|
|
465
|
+
filePattern?: string | undefined;
|
|
466
|
+
maxResults?: number | undefined;
|
|
467
|
+
earlyTermination?: boolean | undefined;
|
|
468
|
+
}, {
|
|
469
|
+
path: string;
|
|
470
|
+
pattern: string;
|
|
471
|
+
origin?: "ui" | "llm" | undefined;
|
|
472
|
+
timeout_ms?: number | undefined;
|
|
473
|
+
maxBytes?: number | undefined;
|
|
474
|
+
searchType?: "content" | "files" | undefined;
|
|
475
|
+
filePattern?: string | undefined;
|
|
476
|
+
ignoreCase?: boolean | undefined;
|
|
477
|
+
maxResults?: number | undefined;
|
|
478
|
+
includeHidden?: boolean | undefined;
|
|
479
|
+
contextLines?: number | undefined;
|
|
480
|
+
earlyTermination?: boolean | undefined;
|
|
481
|
+
literalSearch?: boolean | undefined;
|
|
482
|
+
}>;
|
|
391
483
|
export declare const GetMoreSearchResultsArgsSchema: z.ZodObject<{
|
|
392
484
|
sessionId: z.ZodString;
|
|
393
485
|
offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
package/dist/tools/schemas.js
CHANGED
|
@@ -23,6 +23,8 @@ export const ListProcessesArgsSchema = z.object({});
|
|
|
23
23
|
export const StartProcessArgsSchema = z.object({
|
|
24
24
|
command: z.string(),
|
|
25
25
|
timeout_ms: z.number(),
|
|
26
|
+
yield_ms: z.number().positive().optional(),
|
|
27
|
+
background: z.boolean().optional(),
|
|
26
28
|
working_directory: z.string().optional(),
|
|
27
29
|
shell: z.string().optional(),
|
|
28
30
|
verbose_timing: z.boolean().optional(),
|
|
@@ -60,6 +62,9 @@ export const ReadFileArgsSchema = z.object({
|
|
|
60
62
|
});
|
|
61
63
|
export const ReadMultipleFilesArgsSchema = z.object({
|
|
62
64
|
paths: z.array(z.string()),
|
|
65
|
+
offset: z.number().optional().default(0),
|
|
66
|
+
length: z.number().optional().default(1000),
|
|
67
|
+
maxBytes: z.number().int().positive().optional().default(256 * 1024),
|
|
63
68
|
});
|
|
64
69
|
export const WriteFileArgsSchema = z.object({
|
|
65
70
|
path: z.string(),
|
|
@@ -119,17 +124,21 @@ export const MoveFileArgsSchema = z.object({
|
|
|
119
124
|
export const GetFileInfoArgsSchema = z.object({
|
|
120
125
|
path: z.string(),
|
|
121
126
|
});
|
|
122
|
-
// Edit
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
// Edit tool schema. Legacy text replacement and structured range rewrites remain.
|
|
128
|
+
// The additive edits[] mode is exact-only and batches multiple text replacements
|
|
129
|
+
// into one validated read/write cycle.
|
|
130
|
+
const ExactEditSchema = z.object({
|
|
131
|
+
old_string: z.string().min(1),
|
|
132
|
+
new_string: z.string(),
|
|
133
|
+
expected_replacements: z.number().int().positive().optional().default(1),
|
|
134
|
+
});
|
|
127
135
|
export const EditBlockArgsSchema = z.object({
|
|
128
136
|
file_path: z.string(),
|
|
129
137
|
// Text file string replacement
|
|
130
138
|
old_string: z.string().optional(),
|
|
131
139
|
new_string: z.string().optional(),
|
|
132
140
|
expected_replacements: z.number().optional().default(1),
|
|
141
|
+
edits: z.array(ExactEditSchema).min(1).optional(),
|
|
133
142
|
// Structured file range rewrite (Excel, etc.)
|
|
134
143
|
range: z.string().optional(),
|
|
135
144
|
content: z.any().optional(),
|
|
@@ -141,8 +150,9 @@ export const EditBlockArgsSchema = z.object({
|
|
|
141
150
|
// Helper to check if value is actually provided (not undefined, not empty string)
|
|
142
151
|
const hasValue = (v) => v !== undefined && v !== '';
|
|
143
152
|
return (hasValue(data.old_string) && data.new_string !== undefined) ||
|
|
153
|
+
(data.edits !== undefined && data.edits.length > 0) ||
|
|
144
154
|
(hasValue(data.range) && hasValue(data.content));
|
|
145
|
-
}, { message: "Must provide either (old_string + new_string) or (range + content)" });
|
|
155
|
+
}, { message: "Must provide either (old_string + new_string), edits, or (range + content)" });
|
|
146
156
|
// Send input to process schema
|
|
147
157
|
export const InteractWithProcessArgsSchema = z.object({
|
|
148
158
|
pid: z.number(),
|
|
@@ -170,6 +180,9 @@ export const StartSearchArgsSchema = z.object({
|
|
|
170
180
|
// excluded from tool-call telemetry (see isUiOriginCall in server.ts).
|
|
171
181
|
origin: z.enum(['ui', 'llm']).optional(),
|
|
172
182
|
});
|
|
183
|
+
export const SearchOnceArgsSchema = StartSearchArgsSchema.extend({
|
|
184
|
+
maxBytes: z.number().int().positive().optional().default(256 * 1024),
|
|
185
|
+
});
|
|
173
186
|
export const GetMoreSearchResultsArgsSchema = z.object({
|
|
174
187
|
sessionId: z.string(),
|
|
175
188
|
offset: z.number().optional().default(0), // Same as file reading
|
|
@@ -213,6 +226,7 @@ export const toolArgSchemas = {
|
|
|
213
226
|
list_directory: ListDirectoryArgsSchema,
|
|
214
227
|
move_file: MoveFileArgsSchema,
|
|
215
228
|
start_search: StartSearchArgsSchema,
|
|
229
|
+
search_once: SearchOnceArgsSchema,
|
|
216
230
|
get_more_search_results: GetMoreSearchResultsArgsSchema,
|
|
217
231
|
stop_search: StopSearchArgsSchema,
|
|
218
232
|
list_searches: ListSearchesArgsSchema,
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export interface TerminalSession {
|
|
|
16
16
|
process: ChildProcess;
|
|
17
17
|
outputLines: string[];
|
|
18
18
|
lastReadIndex: number;
|
|
19
|
+
lastReadOffset: number;
|
|
20
|
+
outputVersion: number;
|
|
21
|
+
outputWaiters: Set<() => void>;
|
|
19
22
|
isBlocked: boolean;
|
|
20
23
|
startTime: Date;
|
|
21
24
|
bufferedChars: number;
|
|
@@ -26,6 +29,10 @@ export interface CommandExecutionResult {
|
|
|
26
29
|
pid: number;
|
|
27
30
|
output: string;
|
|
28
31
|
isBlocked: boolean;
|
|
32
|
+
deliveredCursor?: {
|
|
33
|
+
lineIndex: number;
|
|
34
|
+
lineOffset: number;
|
|
35
|
+
};
|
|
29
36
|
timingInfo?: TimingInfo;
|
|
30
37
|
}
|
|
31
38
|
export interface TimingInfo {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
2
|
+
export function takeUtf8Budget(text, maxBytes) {
|
|
3
|
+
const totalBytes = Buffer.byteLength(text, 'utf8');
|
|
4
|
+
if (totalBytes <= maxBytes) {
|
|
5
|
+
return { text, bytes: totalBytes, truncated: false };
|
|
6
|
+
}
|
|
7
|
+
const decoder = new StringDecoder('utf8');
|
|
8
|
+
const chunk = Buffer.from(text, 'utf8').subarray(0, Math.max(0, maxBytes));
|
|
9
|
+
const bounded = decoder.write(chunk);
|
|
10
|
+
return {
|
|
11
|
+
text: bounded,
|
|
12
|
+
bytes: Buffer.byteLength(bounded, 'utf8'),
|
|
13
|
+
truncated: true,
|
|
14
|
+
};
|
|
15
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.0.
|
|
1
|
+
export declare const VERSION = "1.0.10";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.0.
|
|
1
|
+
export const VERSION = '1.0.10';
|