This repository was archived by the owner on May 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathtool-params.ts
More file actions
118 lines (105 loc) · 3.32 KB
/
Copy pathtool-params.ts
File metadata and controls
118 lines (105 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* Tool parameter type definitions for native protocol
*/
/**
* Read mode for the read_file tool.
* - "slice": Simple offset/limit reading (default)
* - "indentation": Semantic block extraction based on code structure
*/
export type ReadFileMode = "slice" | "indentation"
/**
* Indentation-mode configuration for the read_file tool.
*/
export interface IndentationParams {
/** 1-based line number to anchor indentation extraction (defaults to offset) */
anchor_line?: number
/** Maximum indentation levels to include above anchor (0 = unlimited) */
max_levels?: number
/** Include sibling blocks at the same indentation level */
include_siblings?: boolean
/** Include file header (imports, comments at top) */
include_header?: boolean
/** Hard cap on lines returned for indentation mode */
max_lines?: number
}
/**
* Parameters for the read_file tool (new format).
*
* NOTE: This is the canonical, single-file-per-call shape.
*/
export interface ReadFileParams {
/** Path to the file, relative to workspace */
path: string
/** Reading mode: "slice" (default) or "indentation" */
mode?: ReadFileMode
/** 1-based line number to start reading from (slice mode, default: 1) */
offset?: number
/** Maximum number of lines to read (default: 2000) */
limit?: number
/** Indentation-mode configuration (only used when mode === "indentation") */
indentation?: IndentationParams
}
// ─── Legacy Format Types (Backward Compatibility) ─────────────────────────────
/**
* Line range specification for legacy read_file format.
* Represents a contiguous range of lines [start, end] (1-based, inclusive).
*/
export interface LineRange {
start: number
end: number
}
/**
* File entry for legacy read_file format.
* Supports reading multiple disjoint line ranges from a single file.
*/
export interface FileEntry {
/** Path to the file, relative to workspace */
path: string
/** Optional list of line ranges to read (if omitted, reads entire file) */
lineRanges?: LineRange[]
}
/**
* Legacy parameters for the read_file tool (pre-refactor format).
* Supports reading multiple files in a single call with optional line ranges.
*
* @deprecated Use ReadFileParams instead. This format is maintained for
* backward compatibility with existing chat histories.
*/
export interface LegacyReadFileParams {
/** Array of file entries to read */
files: FileEntry[]
/** Discriminant flag for type narrowing */
_legacyFormat: true
}
/**
* Union type for read_file tool parameters.
* Supports both new single-file format and legacy multi-file format.
*/
export type ReadFileToolParams = ReadFileParams | LegacyReadFileParams
/**
* Type guard to check if params are in legacy format.
*/
export function isLegacyReadFileParams(params: ReadFileToolParams): params is LegacyReadFileParams {
return "_legacyFormat" in params && params._legacyFormat === true
}
export interface Coordinate {
x: number
y: number
}
export interface Size {
width: number
height: number
}
export interface BrowserActionParams {
action: "launch" | "click" | "hover" | "type" | "scroll_down" | "scroll_up" | "resize" | "close" | "screenshot"
url?: string
coordinate?: Coordinate
size?: Size
text?: string
path?: string
}
export interface GenerateImageParams {
prompt: string
path: string
image?: string
}