-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtypes.ts
More file actions
272 lines (245 loc) · 6.06 KB
/
types.ts
File metadata and controls
272 lines (245 loc) · 6.06 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
export type DirEntry = {
name: string;
path: string;
type: "file" | "directory";
};
export type ExistingProjectData = {
orgSlug: string;
projectSlug: string;
projectId: string;
dsn: string;
url: string;
platform?: string;
};
export type WizardOptions = {
directory: string;
yes: boolean;
dryRun: boolean;
features?: string[];
team?: string;
org?: string;
project?: string;
/** Pre-selected app name for monorepo runs. When set, skips the interactive
* app-selection prompt and uses this value directly. Required when `--yes`
* is passed against a monorepo with more than one detected app. */
app?: string;
/**
* Force the non-Ink fallback (`LoggingUI`). Mapped from
* `--no-tui`. Acts as an escape hatch when the Ink TUI
* misbehaves; in an interactive run this effectively disables
* prompts (any prompt path will throw a `LoggingUIPromptError`),
* so users hitting this flag should also pass `--yes` or set
* every choice via flags.
*/
forceLegacyUi?: boolean;
};
export type ResolvedInitContext = {
directory: string;
yes: boolean;
dryRun: boolean;
features?: string[];
org: string;
/**
* Resolved team slug for init operations.
* Omitted when init defers empty-org auto-creation until project creation.
*/
team?: string;
project?: string;
/** Pre-selected app name for monorepo runs. Passed through from `--app`. */
app?: string;
authToken?: string;
existingProject?: ExistingProjectData;
};
export type InteractiveContext = Pick<
ResolvedInitContext,
"yes" | "dryRun" | "app"
>;
// Tool suspend payloads
export type ToolPayload =
| ListDirPayload
| ReadFilesPayload
| FileExistsBatchPayload
| RunCommandsPayload
| ApplyPatchsetPayload
| GrepPayload
| GlobPayload
| CreateSentryProjectPayload
| EnsureSentryProjectPayload
| DetectSentryPayload;
export type ToolOperation = ToolPayload["operation"];
export type ListDirPayload = {
type: "tool";
operation: "list-dir";
cwd: string;
params: {
path: string;
recursive?: boolean;
maxDepth?: number;
maxEntries?: number;
};
};
export type ReadFilesPayload = {
type: "tool";
operation: "read-files";
cwd: string;
params: {
paths: string[];
maxBytes?: number;
};
};
export type FileExistsBatchPayload = {
type: "tool";
operation: "file-exists-batch";
cwd: string;
params: {
paths: string[];
};
};
export type RunCommandsPayload = {
type: "tool";
operation: "run-commands";
cwd: string;
params: {
commands: string[];
timeoutMs?: number;
};
};
export type GrepSearch = {
pattern: string;
path?: string;
include?: string;
/**
* Case-insensitive match. Default: false (case-sensitive, matching
* `rg`'s default). A leading `(?i)` inline flag in `pattern` has
* the same effect — callers can use either.
*
* No current Mastra server invocation sets this field; reserving
* it here means the server can start sending it without a CLI
* update. The underlying scan engine natively supports it.
*/
caseInsensitive?: boolean;
/**
* Multiline mode: when true (default), `^` and `$` match at line
* boundaries within the file — grep/rg semantics. When false, they
* anchor to the buffer start/end — strict JS `RegExp` semantics.
* Rarely needs to be set.
*/
multiline?: boolean;
};
export type GrepPayload = {
type: "tool";
operation: "grep";
cwd: string;
params: {
searches: GrepSearch[];
maxResultsPerSearch?: number;
};
};
export type GlobPayload = {
type: "tool";
operation: "glob";
cwd: string;
params: {
patterns: string[];
path?: string;
maxResults?: number;
};
};
export type PatchEdit = {
oldString: string;
newString: string;
};
export type ApplyPatchsetPatch =
| { path: string; action: "create"; patch: string }
| { path: string; action: "modify"; edits: PatchEdit[] }
| { path: string; action: "delete"; patch?: string };
export type ApplyPatchsetPayload = {
type: "tool";
operation: "apply-patchset";
cwd: string;
params: {
patches: ApplyPatchsetPatch[];
};
};
export type CreateSentryProjectPayload = {
type: "tool";
operation: "create-sentry-project";
/** Human-readable spinner hint from the server (≤ 120 chars, sensitive values redacted). */
detail?: string;
cwd: string;
params: {
name: string;
platform: string;
};
};
export type EnsureSentryProjectPayload = {
type: "tool";
operation: "ensure-sentry-project";
/** Human-readable spinner hint from the server (≤ 120 chars, sensitive values redacted). */
detail?: string;
cwd: string;
params: {
name: string;
platform: string;
};
};
export type DetectSentryPayload = {
type: "tool";
operation: "detect-sentry";
detail?: string;
cwd: string;
params: Record<string, never>;
};
export type ToolResult = {
ok: boolean;
error?: string;
message?: string;
data?: unknown;
};
// Wizard output
export type WizardOutput = {
platform?: string;
projectDir?: string;
features?: string[];
commands?: string[];
changedFiles?: Array<{ action: string; path: string }>;
warnings?: string[];
exitCode?: number;
docsUrl?: string;
sentryProjectUrl?: string;
message?: string;
featureBlurbs?: Array<{ feature: string; blurb: string }>;
};
// Interactive payloads
export type InteractivePayload =
| SelectPayload
| MultiSelectPayload
| ConfirmPayload;
export type SelectPayload = {
type: "interactive";
kind: "select";
prompt: string;
options?: string[];
apps?: Array<{ name: string; path: string; framework?: string }>;
};
export type MultiSelectPayload = {
type: "interactive";
kind: "multi-select";
prompt: string;
availableFeatures?: string[];
options?: string[];
};
export type ConfirmPayload = {
type: "interactive";
kind: "confirm";
prompt: string;
};
export type SuspendPayload = ToolPayload | InteractivePayload;
export type WorkflowRunResult = {
status: "suspended" | "success" | "failed";
suspended?: string[][];
steps?: Record<string, { suspendPayload?: unknown }>;
suspendPayload?: unknown;
result?: WizardOutput;
error?: string;
};