@openspecui/core 3.3.0 → 3.4.1
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/dist/hosted-app.d.mts +1 -1
- package/dist/hosted-app.mjs +1 -1
- package/dist/index.d.mts +126 -621
- package/dist/index.mjs +5 -4
- package/dist/opsx-display-path.d.mts +1 -1
- package/dist/opsx-display-path.mjs +1 -1
- package/dist/terminal-invocation-8OLmCJfv.mjs +1216 -0
- package/dist/terminal-invocation-ajsrCPhf.d.mts +1777 -0
- package/dist/terminal-invocation.d.mts +2 -0
- package/dist/terminal-invocation.mjs +3 -0
- package/dist/terminal-theme.d.mts +1 -1
- package/dist/terminal-theme.mjs +1 -1
- package/package.json +7 -3
- /package/dist/{hosted-app-BTvoFBMY.d.mts → hosted-app-Be-ourtC.d.mts} +0 -0
- /package/dist/{hosted-app-DAtQMMt1.mjs → hosted-app-CC8DBuyE.mjs} +0 -0
- /package/dist/{opsx-display-path-DDr9O-4r.mjs → opsx-display-path-DNqQo2uK.mjs} +0 -0
- /package/dist/{opsx-display-path-Bs-P2sK2.d.mts → opsx-display-path-ElGeez1E.d.mts} +0 -0
- /package/dist/{terminal-theme-BxBl5NsA.d.mts → terminal-theme-C_2UGXPr.d.mts} +0 -0
- /package/dist/{terminal-theme-B-mkZOey.mjs → terminal-theme-Cyyo2Zln.mjs} +0 -0
|
@@ -0,0 +1,1216 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/terminal-invocation.ts
|
|
4
|
+
const TERMINAL_SHELL_QUOTE_STYLE_VALUES = [
|
|
5
|
+
"posix",
|
|
6
|
+
"cmd",
|
|
7
|
+
"powershell"
|
|
8
|
+
];
|
|
9
|
+
const TERMINAL_COMMAND_FIELD_TYPE_VALUES = [
|
|
10
|
+
"text",
|
|
11
|
+
"textarea",
|
|
12
|
+
"boolean",
|
|
13
|
+
"select"
|
|
14
|
+
];
|
|
15
|
+
const TerminalShellQuoteStyleSchema = z.enum(TERMINAL_SHELL_QUOTE_STYLE_VALUES);
|
|
16
|
+
const TerminalShellProfileSchema = z.object({
|
|
17
|
+
id: z.string().min(1),
|
|
18
|
+
label: z.string().min(1),
|
|
19
|
+
command: z.string().min(1),
|
|
20
|
+
args: z.array(z.string()).default([]),
|
|
21
|
+
source: z.enum(["builtin", "custom"]).default("custom"),
|
|
22
|
+
quoteStyle: TerminalShellQuoteStyleSchema.default("posix")
|
|
23
|
+
});
|
|
24
|
+
const TerminalCommandFieldSchema = z.object({
|
|
25
|
+
id: z.string().min(1),
|
|
26
|
+
label: z.string().min(1),
|
|
27
|
+
type: z.enum(TERMINAL_COMMAND_FIELD_TYPE_VALUES),
|
|
28
|
+
description: z.string().optional(),
|
|
29
|
+
placeholder: z.string().optional(),
|
|
30
|
+
defaultValue: z.union([z.string(), z.boolean()]).optional(),
|
|
31
|
+
options: z.array(z.string()).default([]),
|
|
32
|
+
required: z.boolean().default(false),
|
|
33
|
+
advanced: z.boolean().default(false)
|
|
34
|
+
});
|
|
35
|
+
function defineTerminalCommandField(field) {
|
|
36
|
+
return {
|
|
37
|
+
...field,
|
|
38
|
+
options: field.options ?? [],
|
|
39
|
+
required: field.required ?? false,
|
|
40
|
+
advanced: field.advanced ?? false
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function defineTerminalSpawnCommand(command) {
|
|
44
|
+
return {
|
|
45
|
+
...command,
|
|
46
|
+
parameters: fieldsToTerminalCommandParameters(command.fields),
|
|
47
|
+
source: command.source ?? "builtin"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const TerminalCommandArgumentSchema = z.discriminatedUnion("kind", [
|
|
51
|
+
z.object({
|
|
52
|
+
kind: z.literal("literal"),
|
|
53
|
+
value: z.string()
|
|
54
|
+
}),
|
|
55
|
+
z.object({
|
|
56
|
+
kind: z.literal("field"),
|
|
57
|
+
fieldId: z.string().min(1),
|
|
58
|
+
prefix: z.string().default(""),
|
|
59
|
+
omitWhenEmpty: z.boolean().default(true)
|
|
60
|
+
}),
|
|
61
|
+
z.object({
|
|
62
|
+
kind: z.literal("booleanFlag"),
|
|
63
|
+
fieldId: z.string().min(1),
|
|
64
|
+
flag: z.string().min(1)
|
|
65
|
+
})
|
|
66
|
+
]);
|
|
67
|
+
const TerminalCommandJsonSchemaPropertySchema = z.object({
|
|
68
|
+
type: z.enum(["string", "boolean"]).default("string"),
|
|
69
|
+
title: z.string().optional(),
|
|
70
|
+
description: z.string().optional(),
|
|
71
|
+
default: z.union([z.string(), z.boolean()]).optional(),
|
|
72
|
+
enum: z.array(z.string()).optional()
|
|
73
|
+
});
|
|
74
|
+
const TerminalCommandJsonSchemaSchema = z.object({
|
|
75
|
+
type: z.literal("object"),
|
|
76
|
+
properties: z.record(TerminalCommandJsonSchemaPropertySchema).default({}),
|
|
77
|
+
required: z.array(z.string()).default([])
|
|
78
|
+
});
|
|
79
|
+
const TerminalCommandParametersSchema = z.object({
|
|
80
|
+
schema: TerminalCommandJsonSchemaSchema,
|
|
81
|
+
uiSchema: z.record(z.unknown()).default({})
|
|
82
|
+
});
|
|
83
|
+
const TerminalCommandBuilderPartSchema = z.discriminatedUnion("kind", [
|
|
84
|
+
z.object({
|
|
85
|
+
kind: z.literal("literal"),
|
|
86
|
+
value: z.string()
|
|
87
|
+
}),
|
|
88
|
+
z.object({
|
|
89
|
+
kind: z.literal("field"),
|
|
90
|
+
fieldId: z.string().min(1),
|
|
91
|
+
prefix: z.string().default(""),
|
|
92
|
+
omitWhenEmpty: z.boolean().default(true)
|
|
93
|
+
}),
|
|
94
|
+
z.object({
|
|
95
|
+
kind: z.literal("booleanFlag"),
|
|
96
|
+
fieldId: z.string().min(1),
|
|
97
|
+
flag: z.string().min(1)
|
|
98
|
+
})
|
|
99
|
+
]);
|
|
100
|
+
const TerminalCommandBuilderSchema = z.discriminatedUnion("kind", [z.object({
|
|
101
|
+
kind: z.literal("argv"),
|
|
102
|
+
parts: z.array(TerminalCommandBuilderPartSchema).default([])
|
|
103
|
+
}), z.object({
|
|
104
|
+
kind: z.literal("shellLine"),
|
|
105
|
+
template: z.string().default("")
|
|
106
|
+
})]);
|
|
107
|
+
const TerminalSpawnCommandSchema = z.object({
|
|
108
|
+
id: z.string().min(1),
|
|
109
|
+
label: z.string().min(1),
|
|
110
|
+
description: z.string().optional(),
|
|
111
|
+
command: z.string().min(1),
|
|
112
|
+
args: z.array(TerminalCommandArgumentSchema).default([]),
|
|
113
|
+
fields: z.array(TerminalCommandFieldSchema).default([]),
|
|
114
|
+
parameters: TerminalCommandParametersSchema.optional(),
|
|
115
|
+
builder: TerminalCommandBuilderSchema.optional(),
|
|
116
|
+
shellProfileId: z.string().optional(),
|
|
117
|
+
source: z.enum(["builtin", "custom"]).default("custom")
|
|
118
|
+
});
|
|
119
|
+
const TerminalInvocationSettingsSchema = z.object({
|
|
120
|
+
defaultShellProfileId: z.string().optional(),
|
|
121
|
+
customShellProfiles: z.array(TerminalShellProfileSchema).default([]),
|
|
122
|
+
customSpawnCommands: z.array(TerminalSpawnCommandSchema).default([])
|
|
123
|
+
});
|
|
124
|
+
function uniqueById(items) {
|
|
125
|
+
const seen = /* @__PURE__ */ new Set();
|
|
126
|
+
const result = [];
|
|
127
|
+
for (const item of items) {
|
|
128
|
+
if (seen.has(item.id)) continue;
|
|
129
|
+
seen.add(item.id);
|
|
130
|
+
result.push(item);
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
function normalizeShellPath(input) {
|
|
135
|
+
return input?.trim() || "";
|
|
136
|
+
}
|
|
137
|
+
function getAmbientTerminalShellEnv() {
|
|
138
|
+
if (typeof process === "undefined") return {};
|
|
139
|
+
return {
|
|
140
|
+
SHELL: process.env.SHELL,
|
|
141
|
+
ComSpec: process.env.ComSpec
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function resolveTerminalShellDefaults(options) {
|
|
145
|
+
const env = options.env ?? getAmbientTerminalShellEnv();
|
|
146
|
+
if (options.platform === "windows") {
|
|
147
|
+
const builtinShellProfiles$1 = [
|
|
148
|
+
{
|
|
149
|
+
id: "builtin:cmd",
|
|
150
|
+
label: "Command Prompt",
|
|
151
|
+
command: normalizeShellPath(env.ComSpec) || "cmd.exe",
|
|
152
|
+
args: [],
|
|
153
|
+
source: "builtin",
|
|
154
|
+
quoteStyle: "cmd"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: "builtin:powershell",
|
|
158
|
+
label: "PowerShell",
|
|
159
|
+
command: "powershell.exe",
|
|
160
|
+
args: [],
|
|
161
|
+
source: "builtin",
|
|
162
|
+
quoteStyle: "powershell"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: "builtin:wsl-bash",
|
|
166
|
+
label: "WSL Bash",
|
|
167
|
+
command: "wsl.exe",
|
|
168
|
+
args: ["bash"],
|
|
169
|
+
source: "builtin",
|
|
170
|
+
quoteStyle: "posix"
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
return {
|
|
174
|
+
platform: options.platform,
|
|
175
|
+
effectiveDefaultShell: builtinShellProfiles$1[0],
|
|
176
|
+
builtinShellProfiles: builtinShellProfiles$1
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const envShell = normalizeShellPath(env.SHELL);
|
|
180
|
+
const fallbackShell = {
|
|
181
|
+
id: "builtin:sh",
|
|
182
|
+
label: "/bin/sh",
|
|
183
|
+
command: "/bin/sh",
|
|
184
|
+
args: [],
|
|
185
|
+
source: "builtin",
|
|
186
|
+
quoteStyle: "posix"
|
|
187
|
+
};
|
|
188
|
+
const builtinShellProfiles = uniqueById([fallbackShell, ...envShell && envShell !== fallbackShell.command ? [{
|
|
189
|
+
id: "builtin:env-shell",
|
|
190
|
+
label: `SHELL (${envShell})`,
|
|
191
|
+
command: envShell,
|
|
192
|
+
args: [],
|
|
193
|
+
source: "builtin",
|
|
194
|
+
quoteStyle: "posix"
|
|
195
|
+
}] : []]);
|
|
196
|
+
return {
|
|
197
|
+
platform: options.platform,
|
|
198
|
+
effectiveDefaultShell: builtinShellProfiles.find((profile) => profile.id === "builtin:env-shell") ?? fallbackShell,
|
|
199
|
+
builtinShellProfiles
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const CLAUDE_COMMAND_FIELDS = [
|
|
203
|
+
defineTerminalCommandField({
|
|
204
|
+
id: "prompt",
|
|
205
|
+
label: "Prompt",
|
|
206
|
+
type: "textarea",
|
|
207
|
+
description: "Initial prompt to send to Claude.",
|
|
208
|
+
defaultValue: "",
|
|
209
|
+
required: false
|
|
210
|
+
}),
|
|
211
|
+
defineTerminalCommandField({
|
|
212
|
+
id: "model",
|
|
213
|
+
label: "Model",
|
|
214
|
+
type: "text",
|
|
215
|
+
description: "Claude model alias or full model name.",
|
|
216
|
+
defaultValue: "",
|
|
217
|
+
required: false
|
|
218
|
+
}),
|
|
219
|
+
defineTerminalCommandField({
|
|
220
|
+
id: "permissionMode",
|
|
221
|
+
label: "Permission mode",
|
|
222
|
+
type: "select",
|
|
223
|
+
description: "Permission mode for this session.",
|
|
224
|
+
defaultValue: "",
|
|
225
|
+
options: [
|
|
226
|
+
"",
|
|
227
|
+
"default",
|
|
228
|
+
"acceptEdits",
|
|
229
|
+
"auto",
|
|
230
|
+
"dontAsk",
|
|
231
|
+
"plan",
|
|
232
|
+
"bypassPermissions"
|
|
233
|
+
],
|
|
234
|
+
required: false
|
|
235
|
+
}),
|
|
236
|
+
defineTerminalCommandField({
|
|
237
|
+
id: "effort",
|
|
238
|
+
label: "Effort",
|
|
239
|
+
type: "select",
|
|
240
|
+
description: "Reasoning effort for the current session.",
|
|
241
|
+
defaultValue: "",
|
|
242
|
+
options: [
|
|
243
|
+
"",
|
|
244
|
+
"low",
|
|
245
|
+
"medium",
|
|
246
|
+
"high",
|
|
247
|
+
"xhigh",
|
|
248
|
+
"max"
|
|
249
|
+
],
|
|
250
|
+
required: false
|
|
251
|
+
}),
|
|
252
|
+
defineTerminalCommandField({
|
|
253
|
+
id: "continueLatest",
|
|
254
|
+
label: "Continue latest",
|
|
255
|
+
type: "boolean",
|
|
256
|
+
description: "Continue the most recent conversation in the current directory.",
|
|
257
|
+
defaultValue: false,
|
|
258
|
+
required: false,
|
|
259
|
+
advanced: true
|
|
260
|
+
}),
|
|
261
|
+
defineTerminalCommandField({
|
|
262
|
+
id: "resumeSession",
|
|
263
|
+
label: "Resume session",
|
|
264
|
+
type: "text",
|
|
265
|
+
description: "Resume a conversation by session ID or picker search term.",
|
|
266
|
+
defaultValue: "",
|
|
267
|
+
required: false,
|
|
268
|
+
advanced: true
|
|
269
|
+
}),
|
|
270
|
+
defineTerminalCommandField({
|
|
271
|
+
id: "name",
|
|
272
|
+
label: "Session name",
|
|
273
|
+
type: "text",
|
|
274
|
+
description: "Display name for the Claude session.",
|
|
275
|
+
defaultValue: "",
|
|
276
|
+
required: false,
|
|
277
|
+
advanced: true
|
|
278
|
+
}),
|
|
279
|
+
defineTerminalCommandField({
|
|
280
|
+
id: "addDir",
|
|
281
|
+
label: "Additional dirs",
|
|
282
|
+
type: "text",
|
|
283
|
+
description: "Additional directories to allow tool access to.",
|
|
284
|
+
defaultValue: "",
|
|
285
|
+
required: false,
|
|
286
|
+
advanced: true
|
|
287
|
+
}),
|
|
288
|
+
defineTerminalCommandField({
|
|
289
|
+
id: "appendSystemPrompt",
|
|
290
|
+
label: "Append system prompt",
|
|
291
|
+
type: "textarea",
|
|
292
|
+
description: "Text appended to the default system prompt.",
|
|
293
|
+
defaultValue: "",
|
|
294
|
+
required: false,
|
|
295
|
+
advanced: true
|
|
296
|
+
}),
|
|
297
|
+
defineTerminalCommandField({
|
|
298
|
+
id: "allowedTools",
|
|
299
|
+
label: "Allowed tools",
|
|
300
|
+
type: "text",
|
|
301
|
+
description: "Comma or space-separated tool allowlist.",
|
|
302
|
+
defaultValue: "",
|
|
303
|
+
required: false,
|
|
304
|
+
advanced: true
|
|
305
|
+
}),
|
|
306
|
+
defineTerminalCommandField({
|
|
307
|
+
id: "disallowedTools",
|
|
308
|
+
label: "Disallowed tools",
|
|
309
|
+
type: "text",
|
|
310
|
+
description: "Comma or space-separated tool denylist.",
|
|
311
|
+
defaultValue: "",
|
|
312
|
+
required: false,
|
|
313
|
+
advanced: true
|
|
314
|
+
}),
|
|
315
|
+
defineTerminalCommandField({
|
|
316
|
+
id: "print",
|
|
317
|
+
label: "Print and exit",
|
|
318
|
+
type: "boolean",
|
|
319
|
+
description: "Run in non-interactive print mode.",
|
|
320
|
+
defaultValue: false,
|
|
321
|
+
required: false,
|
|
322
|
+
advanced: true
|
|
323
|
+
}),
|
|
324
|
+
defineTerminalCommandField({
|
|
325
|
+
id: "outputFormat",
|
|
326
|
+
label: "Output format",
|
|
327
|
+
type: "select",
|
|
328
|
+
description: "Output format for print mode.",
|
|
329
|
+
defaultValue: "",
|
|
330
|
+
options: [
|
|
331
|
+
"",
|
|
332
|
+
"text",
|
|
333
|
+
"json",
|
|
334
|
+
"stream-json"
|
|
335
|
+
],
|
|
336
|
+
required: false,
|
|
337
|
+
advanced: true
|
|
338
|
+
}),
|
|
339
|
+
defineTerminalCommandField({
|
|
340
|
+
id: "dangerouslySkipPermissions",
|
|
341
|
+
label: "Skip permissions",
|
|
342
|
+
type: "boolean",
|
|
343
|
+
description: "Bypass all permission checks. Use only in externally sandboxed workspaces.",
|
|
344
|
+
defaultValue: false,
|
|
345
|
+
required: false,
|
|
346
|
+
advanced: true
|
|
347
|
+
}),
|
|
348
|
+
defineTerminalCommandField({
|
|
349
|
+
id: "allowDangerouslySkipPermissions",
|
|
350
|
+
label: "Allow skip permissions",
|
|
351
|
+
type: "boolean",
|
|
352
|
+
description: "Expose the skip-permissions option without enabling it by default.",
|
|
353
|
+
defaultValue: false,
|
|
354
|
+
required: false,
|
|
355
|
+
advanced: true
|
|
356
|
+
}),
|
|
357
|
+
defineTerminalCommandField({
|
|
358
|
+
id: "bare",
|
|
359
|
+
label: "Bare mode",
|
|
360
|
+
type: "boolean",
|
|
361
|
+
description: "Minimal mode that skips hooks, plugin sync, memory, and auto-discovery.",
|
|
362
|
+
defaultValue: false,
|
|
363
|
+
required: false,
|
|
364
|
+
advanced: true
|
|
365
|
+
}),
|
|
366
|
+
defineTerminalCommandField({
|
|
367
|
+
id: "verbose",
|
|
368
|
+
label: "Verbose",
|
|
369
|
+
type: "boolean",
|
|
370
|
+
description: "Override verbose mode setting from config.",
|
|
371
|
+
defaultValue: false,
|
|
372
|
+
required: false,
|
|
373
|
+
advanced: true
|
|
374
|
+
})
|
|
375
|
+
];
|
|
376
|
+
const CODEX_COMMAND_FIELDS = [
|
|
377
|
+
defineTerminalCommandField({
|
|
378
|
+
id: "prompt",
|
|
379
|
+
label: "Prompt",
|
|
380
|
+
type: "textarea",
|
|
381
|
+
description: "Initial prompt to send to Codex.",
|
|
382
|
+
defaultValue: "",
|
|
383
|
+
required: false
|
|
384
|
+
}),
|
|
385
|
+
defineTerminalCommandField({
|
|
386
|
+
id: "model",
|
|
387
|
+
label: "Model",
|
|
388
|
+
type: "text",
|
|
389
|
+
description: "Model the agent should use.",
|
|
390
|
+
defaultValue: "",
|
|
391
|
+
required: false
|
|
392
|
+
}),
|
|
393
|
+
defineTerminalCommandField({
|
|
394
|
+
id: "profile",
|
|
395
|
+
label: "Profile",
|
|
396
|
+
type: "text",
|
|
397
|
+
description: "Configuration profile from config.toml.",
|
|
398
|
+
defaultValue: "",
|
|
399
|
+
required: false
|
|
400
|
+
}),
|
|
401
|
+
defineTerminalCommandField({
|
|
402
|
+
id: "sandbox",
|
|
403
|
+
label: "Sandbox",
|
|
404
|
+
type: "select",
|
|
405
|
+
description: "Sandbox policy for model-generated commands.",
|
|
406
|
+
defaultValue: "",
|
|
407
|
+
options: [
|
|
408
|
+
"",
|
|
409
|
+
"read-only",
|
|
410
|
+
"workspace-write",
|
|
411
|
+
"danger-full-access"
|
|
412
|
+
],
|
|
413
|
+
required: false
|
|
414
|
+
}),
|
|
415
|
+
defineTerminalCommandField({
|
|
416
|
+
id: "approvalPolicy",
|
|
417
|
+
label: "Approval policy",
|
|
418
|
+
type: "select",
|
|
419
|
+
description: "When Codex should ask for human approval.",
|
|
420
|
+
defaultValue: "",
|
|
421
|
+
options: [
|
|
422
|
+
"",
|
|
423
|
+
"untrusted",
|
|
424
|
+
"on-request",
|
|
425
|
+
"never"
|
|
426
|
+
],
|
|
427
|
+
required: false
|
|
428
|
+
}),
|
|
429
|
+
defineTerminalCommandField({
|
|
430
|
+
id: "search",
|
|
431
|
+
label: "Web search",
|
|
432
|
+
type: "boolean",
|
|
433
|
+
description: "Enable live web search for the session.",
|
|
434
|
+
defaultValue: false,
|
|
435
|
+
required: false
|
|
436
|
+
}),
|
|
437
|
+
defineTerminalCommandField({
|
|
438
|
+
id: "cd",
|
|
439
|
+
label: "Working root",
|
|
440
|
+
type: "text",
|
|
441
|
+
description: "Directory Codex should use as its working root.",
|
|
442
|
+
defaultValue: "",
|
|
443
|
+
required: false,
|
|
444
|
+
advanced: true
|
|
445
|
+
}),
|
|
446
|
+
defineTerminalCommandField({
|
|
447
|
+
id: "addDir",
|
|
448
|
+
label: "Additional dir",
|
|
449
|
+
type: "text",
|
|
450
|
+
description: "Additional writable directory alongside the primary workspace.",
|
|
451
|
+
defaultValue: "",
|
|
452
|
+
required: false,
|
|
453
|
+
advanced: true
|
|
454
|
+
}),
|
|
455
|
+
defineTerminalCommandField({
|
|
456
|
+
id: "config",
|
|
457
|
+
label: "Config override",
|
|
458
|
+
type: "text",
|
|
459
|
+
description: "Configuration override in key=value form.",
|
|
460
|
+
defaultValue: "",
|
|
461
|
+
required: false,
|
|
462
|
+
advanced: true
|
|
463
|
+
}),
|
|
464
|
+
defineTerminalCommandField({
|
|
465
|
+
id: "enableFeature",
|
|
466
|
+
label: "Enable feature",
|
|
467
|
+
type: "text",
|
|
468
|
+
description: "Feature flag to enable.",
|
|
469
|
+
defaultValue: "",
|
|
470
|
+
required: false,
|
|
471
|
+
advanced: true
|
|
472
|
+
}),
|
|
473
|
+
defineTerminalCommandField({
|
|
474
|
+
id: "disableFeature",
|
|
475
|
+
label: "Disable feature",
|
|
476
|
+
type: "text",
|
|
477
|
+
description: "Feature flag to disable.",
|
|
478
|
+
defaultValue: "",
|
|
479
|
+
required: false,
|
|
480
|
+
advanced: true
|
|
481
|
+
}),
|
|
482
|
+
defineTerminalCommandField({
|
|
483
|
+
id: "image",
|
|
484
|
+
label: "Image file",
|
|
485
|
+
type: "text",
|
|
486
|
+
description: "Image file to attach to the initial prompt.",
|
|
487
|
+
defaultValue: "",
|
|
488
|
+
required: false,
|
|
489
|
+
advanced: true
|
|
490
|
+
}),
|
|
491
|
+
defineTerminalCommandField({
|
|
492
|
+
id: "oss",
|
|
493
|
+
label: "OSS provider",
|
|
494
|
+
type: "boolean",
|
|
495
|
+
description: "Use an open-source provider.",
|
|
496
|
+
defaultValue: false,
|
|
497
|
+
required: false,
|
|
498
|
+
advanced: true
|
|
499
|
+
}),
|
|
500
|
+
defineTerminalCommandField({
|
|
501
|
+
id: "localProvider",
|
|
502
|
+
label: "Local provider",
|
|
503
|
+
type: "select",
|
|
504
|
+
description: "Local provider to use with OSS mode.",
|
|
505
|
+
defaultValue: "",
|
|
506
|
+
options: [
|
|
507
|
+
"",
|
|
508
|
+
"lmstudio",
|
|
509
|
+
"ollama"
|
|
510
|
+
],
|
|
511
|
+
required: false,
|
|
512
|
+
advanced: true
|
|
513
|
+
}),
|
|
514
|
+
defineTerminalCommandField({
|
|
515
|
+
id: "noAltScreen",
|
|
516
|
+
label: "No alt screen",
|
|
517
|
+
type: "boolean",
|
|
518
|
+
description: "Disable alternate screen mode.",
|
|
519
|
+
defaultValue: false,
|
|
520
|
+
required: false,
|
|
521
|
+
advanced: true
|
|
522
|
+
}),
|
|
523
|
+
defineTerminalCommandField({
|
|
524
|
+
id: "dangerouslyBypassApprovalsAndSandbox",
|
|
525
|
+
label: "Bypass approvals and sandbox",
|
|
526
|
+
type: "boolean",
|
|
527
|
+
description: "Skip all confirmation prompts and execute without sandboxing.",
|
|
528
|
+
defaultValue: false,
|
|
529
|
+
required: false,
|
|
530
|
+
advanced: true
|
|
531
|
+
})
|
|
532
|
+
];
|
|
533
|
+
const GEMINI_COMMAND_FIELDS = [
|
|
534
|
+
defineTerminalCommandField({
|
|
535
|
+
id: "prompt",
|
|
536
|
+
label: "Prompt",
|
|
537
|
+
type: "textarea",
|
|
538
|
+
description: "Initial prompt to send to Gemini.",
|
|
539
|
+
defaultValue: "",
|
|
540
|
+
required: false
|
|
541
|
+
}),
|
|
542
|
+
defineTerminalCommandField({
|
|
543
|
+
id: "model",
|
|
544
|
+
label: "Model",
|
|
545
|
+
type: "text",
|
|
546
|
+
description: "Model Gemini CLI should use.",
|
|
547
|
+
defaultValue: "",
|
|
548
|
+
required: false
|
|
549
|
+
}),
|
|
550
|
+
defineTerminalCommandField({
|
|
551
|
+
id: "approvalMode",
|
|
552
|
+
label: "Approval mode",
|
|
553
|
+
type: "select",
|
|
554
|
+
description: "Approval mode for tool execution.",
|
|
555
|
+
defaultValue: "",
|
|
556
|
+
options: [
|
|
557
|
+
"",
|
|
558
|
+
"default",
|
|
559
|
+
"auto_edit",
|
|
560
|
+
"yolo",
|
|
561
|
+
"plan"
|
|
562
|
+
],
|
|
563
|
+
required: false
|
|
564
|
+
}),
|
|
565
|
+
defineTerminalCommandField({
|
|
566
|
+
id: "sandbox",
|
|
567
|
+
label: "Sandbox",
|
|
568
|
+
type: "boolean",
|
|
569
|
+
description: "Run Gemini in sandbox mode.",
|
|
570
|
+
defaultValue: false,
|
|
571
|
+
required: false
|
|
572
|
+
}),
|
|
573
|
+
defineTerminalCommandField({
|
|
574
|
+
id: "debug",
|
|
575
|
+
label: "Debug",
|
|
576
|
+
type: "boolean",
|
|
577
|
+
description: "Run in debug mode.",
|
|
578
|
+
defaultValue: false,
|
|
579
|
+
required: false,
|
|
580
|
+
advanced: true
|
|
581
|
+
}),
|
|
582
|
+
defineTerminalCommandField({
|
|
583
|
+
id: "worktree",
|
|
584
|
+
label: "Worktree",
|
|
585
|
+
type: "text",
|
|
586
|
+
description: "Start Gemini in a named new git worktree.",
|
|
587
|
+
defaultValue: "",
|
|
588
|
+
required: false,
|
|
589
|
+
advanced: true
|
|
590
|
+
}),
|
|
591
|
+
defineTerminalCommandField({
|
|
592
|
+
id: "yolo",
|
|
593
|
+
label: "YOLO mode",
|
|
594
|
+
type: "boolean",
|
|
595
|
+
description: "Automatically accept all actions.",
|
|
596
|
+
defaultValue: false,
|
|
597
|
+
required: false,
|
|
598
|
+
advanced: true
|
|
599
|
+
}),
|
|
600
|
+
defineTerminalCommandField({
|
|
601
|
+
id: "policy",
|
|
602
|
+
label: "Policy",
|
|
603
|
+
type: "text",
|
|
604
|
+
description: "Additional policy files or directories.",
|
|
605
|
+
defaultValue: "",
|
|
606
|
+
required: false,
|
|
607
|
+
advanced: true
|
|
608
|
+
}),
|
|
609
|
+
defineTerminalCommandField({
|
|
610
|
+
id: "adminPolicy",
|
|
611
|
+
label: "Admin policy",
|
|
612
|
+
type: "text",
|
|
613
|
+
description: "Additional admin policy files or directories.",
|
|
614
|
+
defaultValue: "",
|
|
615
|
+
required: false,
|
|
616
|
+
advanced: true
|
|
617
|
+
}),
|
|
618
|
+
defineTerminalCommandField({
|
|
619
|
+
id: "extensions",
|
|
620
|
+
label: "Extensions",
|
|
621
|
+
type: "text",
|
|
622
|
+
description: "Extensions to use.",
|
|
623
|
+
defaultValue: "",
|
|
624
|
+
required: false,
|
|
625
|
+
advanced: true
|
|
626
|
+
}),
|
|
627
|
+
defineTerminalCommandField({
|
|
628
|
+
id: "includeDirectories",
|
|
629
|
+
label: "Include directories",
|
|
630
|
+
type: "text",
|
|
631
|
+
description: "Additional directories to include in the workspace.",
|
|
632
|
+
defaultValue: "",
|
|
633
|
+
required: false,
|
|
634
|
+
advanced: true
|
|
635
|
+
}),
|
|
636
|
+
defineTerminalCommandField({
|
|
637
|
+
id: "allowedMcpServerNames",
|
|
638
|
+
label: "Allowed MCP servers",
|
|
639
|
+
type: "text",
|
|
640
|
+
description: "Allowed MCP server names.",
|
|
641
|
+
defaultValue: "",
|
|
642
|
+
required: false,
|
|
643
|
+
advanced: true
|
|
644
|
+
}),
|
|
645
|
+
defineTerminalCommandField({
|
|
646
|
+
id: "outputFormat",
|
|
647
|
+
label: "Output format",
|
|
648
|
+
type: "select",
|
|
649
|
+
description: "Gemini CLI output format.",
|
|
650
|
+
defaultValue: "",
|
|
651
|
+
options: [
|
|
652
|
+
"",
|
|
653
|
+
"text",
|
|
654
|
+
"json",
|
|
655
|
+
"stream-json"
|
|
656
|
+
],
|
|
657
|
+
required: false,
|
|
658
|
+
advanced: true
|
|
659
|
+
}),
|
|
660
|
+
defineTerminalCommandField({
|
|
661
|
+
id: "screenReader",
|
|
662
|
+
label: "Screen reader",
|
|
663
|
+
type: "boolean",
|
|
664
|
+
description: "Enable screen reader mode.",
|
|
665
|
+
defaultValue: false,
|
|
666
|
+
required: false,
|
|
667
|
+
advanced: true
|
|
668
|
+
}),
|
|
669
|
+
defineTerminalCommandField({
|
|
670
|
+
id: "rawOutput",
|
|
671
|
+
label: "Raw output",
|
|
672
|
+
type: "boolean",
|
|
673
|
+
description: "Disable output sanitization.",
|
|
674
|
+
defaultValue: false,
|
|
675
|
+
required: false,
|
|
676
|
+
advanced: true
|
|
677
|
+
}),
|
|
678
|
+
defineTerminalCommandField({
|
|
679
|
+
id: "acceptRawOutputRisk",
|
|
680
|
+
label: "Accept raw output risk",
|
|
681
|
+
type: "boolean",
|
|
682
|
+
description: "Suppress the raw-output security warning.",
|
|
683
|
+
defaultValue: false,
|
|
684
|
+
required: false,
|
|
685
|
+
advanced: true
|
|
686
|
+
})
|
|
687
|
+
];
|
|
688
|
+
const BUILTIN_TERMINAL_SPAWN_COMMANDS = [
|
|
689
|
+
defineTerminalSpawnCommand({
|
|
690
|
+
id: "builtin:claude",
|
|
691
|
+
label: "Claude",
|
|
692
|
+
description: "Create a terminal and invoke Claude with an optional prompt.",
|
|
693
|
+
command: "claude",
|
|
694
|
+
args: [
|
|
695
|
+
{
|
|
696
|
+
kind: "booleanFlag",
|
|
697
|
+
fieldId: "dangerouslySkipPermissions",
|
|
698
|
+
flag: "--dangerously-skip-permissions"
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
kind: "booleanFlag",
|
|
702
|
+
fieldId: "allowDangerouslySkipPermissions",
|
|
703
|
+
flag: "--allow-dangerously-skip-permissions"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
kind: "field",
|
|
707
|
+
fieldId: "prompt",
|
|
708
|
+
prefix: "",
|
|
709
|
+
omitWhenEmpty: true
|
|
710
|
+
}
|
|
711
|
+
],
|
|
712
|
+
fields: CLAUDE_COMMAND_FIELDS,
|
|
713
|
+
builder: {
|
|
714
|
+
kind: "argv",
|
|
715
|
+
parts: [
|
|
716
|
+
{
|
|
717
|
+
kind: "literal",
|
|
718
|
+
value: "claude"
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
kind: "field",
|
|
722
|
+
fieldId: "model",
|
|
723
|
+
prefix: "--model=",
|
|
724
|
+
omitWhenEmpty: true
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
kind: "field",
|
|
728
|
+
fieldId: "permissionMode",
|
|
729
|
+
prefix: "--permission-mode=",
|
|
730
|
+
omitWhenEmpty: true
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
kind: "field",
|
|
734
|
+
fieldId: "effort",
|
|
735
|
+
prefix: "--effort=",
|
|
736
|
+
omitWhenEmpty: true
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
kind: "booleanFlag",
|
|
740
|
+
fieldId: "continueLatest",
|
|
741
|
+
flag: "--continue"
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
kind: "field",
|
|
745
|
+
fieldId: "resumeSession",
|
|
746
|
+
prefix: "--resume=",
|
|
747
|
+
omitWhenEmpty: true
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
kind: "field",
|
|
751
|
+
fieldId: "name",
|
|
752
|
+
prefix: "--name=",
|
|
753
|
+
omitWhenEmpty: true
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
kind: "field",
|
|
757
|
+
fieldId: "addDir",
|
|
758
|
+
prefix: "--add-dir=",
|
|
759
|
+
omitWhenEmpty: true
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
kind: "field",
|
|
763
|
+
fieldId: "appendSystemPrompt",
|
|
764
|
+
prefix: "--append-system-prompt=",
|
|
765
|
+
omitWhenEmpty: true
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
kind: "field",
|
|
769
|
+
fieldId: "allowedTools",
|
|
770
|
+
prefix: "--allowed-tools=",
|
|
771
|
+
omitWhenEmpty: true
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
kind: "field",
|
|
775
|
+
fieldId: "disallowedTools",
|
|
776
|
+
prefix: "--disallowed-tools=",
|
|
777
|
+
omitWhenEmpty: true
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
kind: "booleanFlag",
|
|
781
|
+
fieldId: "print",
|
|
782
|
+
flag: "--print"
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
kind: "field",
|
|
786
|
+
fieldId: "outputFormat",
|
|
787
|
+
prefix: "--output-format=",
|
|
788
|
+
omitWhenEmpty: true
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
kind: "booleanFlag",
|
|
792
|
+
fieldId: "dangerouslySkipPermissions",
|
|
793
|
+
flag: "--dangerously-skip-permissions"
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
kind: "booleanFlag",
|
|
797
|
+
fieldId: "allowDangerouslySkipPermissions",
|
|
798
|
+
flag: "--allow-dangerously-skip-permissions"
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
kind: "booleanFlag",
|
|
802
|
+
fieldId: "bare",
|
|
803
|
+
flag: "--bare"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
kind: "booleanFlag",
|
|
807
|
+
fieldId: "verbose",
|
|
808
|
+
flag: "--verbose"
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
kind: "field",
|
|
812
|
+
fieldId: "prompt",
|
|
813
|
+
prefix: "",
|
|
814
|
+
omitWhenEmpty: true
|
|
815
|
+
}
|
|
816
|
+
]
|
|
817
|
+
}
|
|
818
|
+
}),
|
|
819
|
+
defineTerminalSpawnCommand({
|
|
820
|
+
id: "builtin:codex",
|
|
821
|
+
label: "Codex",
|
|
822
|
+
description: "Create a terminal and invoke Codex with an optional prompt.",
|
|
823
|
+
command: "codex",
|
|
824
|
+
args: [{
|
|
825
|
+
kind: "booleanFlag",
|
|
826
|
+
fieldId: "dangerouslyBypassApprovalsAndSandbox",
|
|
827
|
+
flag: "--dangerously-bypass-approvals-and-sandbox"
|
|
828
|
+
}, {
|
|
829
|
+
kind: "field",
|
|
830
|
+
fieldId: "prompt",
|
|
831
|
+
prefix: "",
|
|
832
|
+
omitWhenEmpty: true
|
|
833
|
+
}],
|
|
834
|
+
fields: CODEX_COMMAND_FIELDS,
|
|
835
|
+
builder: {
|
|
836
|
+
kind: "argv",
|
|
837
|
+
parts: [
|
|
838
|
+
{
|
|
839
|
+
kind: "literal",
|
|
840
|
+
value: "codex"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
kind: "field",
|
|
844
|
+
fieldId: "model",
|
|
845
|
+
prefix: "--model=",
|
|
846
|
+
omitWhenEmpty: true
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
kind: "field",
|
|
850
|
+
fieldId: "profile",
|
|
851
|
+
prefix: "--profile=",
|
|
852
|
+
omitWhenEmpty: true
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
kind: "field",
|
|
856
|
+
fieldId: "sandbox",
|
|
857
|
+
prefix: "--sandbox=",
|
|
858
|
+
omitWhenEmpty: true
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
kind: "field",
|
|
862
|
+
fieldId: "approvalPolicy",
|
|
863
|
+
prefix: "--ask-for-approval=",
|
|
864
|
+
omitWhenEmpty: true
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
kind: "booleanFlag",
|
|
868
|
+
fieldId: "search",
|
|
869
|
+
flag: "--search"
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
kind: "field",
|
|
873
|
+
fieldId: "cd",
|
|
874
|
+
prefix: "--cd=",
|
|
875
|
+
omitWhenEmpty: true
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
kind: "field",
|
|
879
|
+
fieldId: "addDir",
|
|
880
|
+
prefix: "--add-dir=",
|
|
881
|
+
omitWhenEmpty: true
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
kind: "field",
|
|
885
|
+
fieldId: "config",
|
|
886
|
+
prefix: "--config=",
|
|
887
|
+
omitWhenEmpty: true
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
kind: "field",
|
|
891
|
+
fieldId: "enableFeature",
|
|
892
|
+
prefix: "--enable=",
|
|
893
|
+
omitWhenEmpty: true
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
kind: "field",
|
|
897
|
+
fieldId: "disableFeature",
|
|
898
|
+
prefix: "--disable=",
|
|
899
|
+
omitWhenEmpty: true
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
kind: "field",
|
|
903
|
+
fieldId: "image",
|
|
904
|
+
prefix: "--image=",
|
|
905
|
+
omitWhenEmpty: true
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
kind: "booleanFlag",
|
|
909
|
+
fieldId: "oss",
|
|
910
|
+
flag: "--oss"
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
kind: "field",
|
|
914
|
+
fieldId: "localProvider",
|
|
915
|
+
prefix: "--local-provider=",
|
|
916
|
+
omitWhenEmpty: true
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
kind: "booleanFlag",
|
|
920
|
+
fieldId: "noAltScreen",
|
|
921
|
+
flag: "--no-alt-screen"
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
kind: "booleanFlag",
|
|
925
|
+
fieldId: "dangerouslyBypassApprovalsAndSandbox",
|
|
926
|
+
flag: "--dangerously-bypass-approvals-and-sandbox"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
kind: "field",
|
|
930
|
+
fieldId: "prompt",
|
|
931
|
+
prefix: "",
|
|
932
|
+
omitWhenEmpty: true
|
|
933
|
+
}
|
|
934
|
+
]
|
|
935
|
+
}
|
|
936
|
+
}),
|
|
937
|
+
defineTerminalSpawnCommand({
|
|
938
|
+
id: "builtin:gemini",
|
|
939
|
+
label: "Gemini",
|
|
940
|
+
description: "Create a terminal and invoke Gemini with an optional prompt.",
|
|
941
|
+
command: "gemini",
|
|
942
|
+
args: [{
|
|
943
|
+
kind: "booleanFlag",
|
|
944
|
+
fieldId: "yolo",
|
|
945
|
+
flag: "--yolo"
|
|
946
|
+
}, {
|
|
947
|
+
kind: "field",
|
|
948
|
+
fieldId: "prompt",
|
|
949
|
+
prefix: "",
|
|
950
|
+
omitWhenEmpty: true
|
|
951
|
+
}],
|
|
952
|
+
fields: GEMINI_COMMAND_FIELDS,
|
|
953
|
+
builder: {
|
|
954
|
+
kind: "argv",
|
|
955
|
+
parts: [
|
|
956
|
+
{
|
|
957
|
+
kind: "literal",
|
|
958
|
+
value: "gemini"
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
kind: "booleanFlag",
|
|
962
|
+
fieldId: "debug",
|
|
963
|
+
flag: "--debug"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
kind: "field",
|
|
967
|
+
fieldId: "model",
|
|
968
|
+
prefix: "--model=",
|
|
969
|
+
omitWhenEmpty: true
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
kind: "field",
|
|
973
|
+
fieldId: "approvalMode",
|
|
974
|
+
prefix: "--approval-mode=",
|
|
975
|
+
omitWhenEmpty: true
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
kind: "booleanFlag",
|
|
979
|
+
fieldId: "sandbox",
|
|
980
|
+
flag: "--sandbox"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
kind: "field",
|
|
984
|
+
fieldId: "worktree",
|
|
985
|
+
prefix: "--worktree=",
|
|
986
|
+
omitWhenEmpty: true
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
kind: "booleanFlag",
|
|
990
|
+
fieldId: "yolo",
|
|
991
|
+
flag: "--yolo"
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
kind: "field",
|
|
995
|
+
fieldId: "policy",
|
|
996
|
+
prefix: "--policy=",
|
|
997
|
+
omitWhenEmpty: true
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
kind: "field",
|
|
1001
|
+
fieldId: "adminPolicy",
|
|
1002
|
+
prefix: "--admin-policy=",
|
|
1003
|
+
omitWhenEmpty: true
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
kind: "field",
|
|
1007
|
+
fieldId: "extensions",
|
|
1008
|
+
prefix: "--extensions=",
|
|
1009
|
+
omitWhenEmpty: true
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
kind: "field",
|
|
1013
|
+
fieldId: "includeDirectories",
|
|
1014
|
+
prefix: "--include-directories=",
|
|
1015
|
+
omitWhenEmpty: true
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
kind: "field",
|
|
1019
|
+
fieldId: "allowedMcpServerNames",
|
|
1020
|
+
prefix: "--allowed-mcp-server-names=",
|
|
1021
|
+
omitWhenEmpty: true
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
kind: "field",
|
|
1025
|
+
fieldId: "outputFormat",
|
|
1026
|
+
prefix: "--output-format=",
|
|
1027
|
+
omitWhenEmpty: true
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
kind: "booleanFlag",
|
|
1031
|
+
fieldId: "screenReader",
|
|
1032
|
+
flag: "--screen-reader"
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
kind: "booleanFlag",
|
|
1036
|
+
fieldId: "rawOutput",
|
|
1037
|
+
flag: "--raw-output"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
kind: "booleanFlag",
|
|
1041
|
+
fieldId: "acceptRawOutputRisk",
|
|
1042
|
+
flag: "--accept-raw-output-risk"
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
kind: "field",
|
|
1046
|
+
fieldId: "prompt",
|
|
1047
|
+
prefix: "",
|
|
1048
|
+
omitWhenEmpty: true
|
|
1049
|
+
}
|
|
1050
|
+
]
|
|
1051
|
+
}
|
|
1052
|
+
})
|
|
1053
|
+
];
|
|
1054
|
+
function fieldToJsonSchemaProperty(field) {
|
|
1055
|
+
const base = { title: field.label };
|
|
1056
|
+
const description = field.description ?? field.placeholder;
|
|
1057
|
+
if (description) base.description = description;
|
|
1058
|
+
if (field.type === "boolean") return {
|
|
1059
|
+
...base,
|
|
1060
|
+
type: "boolean",
|
|
1061
|
+
default: typeof field.defaultValue === "boolean" ? field.defaultValue : false
|
|
1062
|
+
};
|
|
1063
|
+
if (field.type === "select") return {
|
|
1064
|
+
...base,
|
|
1065
|
+
type: "string",
|
|
1066
|
+
enum: field.options,
|
|
1067
|
+
default: typeof field.defaultValue === "string" ? field.defaultValue : field.options[0]
|
|
1068
|
+
};
|
|
1069
|
+
return {
|
|
1070
|
+
...base,
|
|
1071
|
+
type: "string",
|
|
1072
|
+
default: typeof field.defaultValue === "string" ? field.defaultValue : ""
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
function fieldsToTerminalCommandParameters(fields) {
|
|
1076
|
+
const properties = {};
|
|
1077
|
+
const uiSchema = {};
|
|
1078
|
+
const required = [];
|
|
1079
|
+
for (const field of fields) {
|
|
1080
|
+
properties[field.id] = fieldToJsonSchemaProperty(field);
|
|
1081
|
+
if (field.required) required.push(field.id);
|
|
1082
|
+
if (field.type === "textarea") uiSchema[field.id] = { "ui:widget": "textarea" };
|
|
1083
|
+
if (field.advanced) {
|
|
1084
|
+
const current = uiSchema[field.id] ?? {};
|
|
1085
|
+
uiSchema[field.id] = {
|
|
1086
|
+
...current,
|
|
1087
|
+
"ui:advanced": true
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
return {
|
|
1092
|
+
schema: {
|
|
1093
|
+
type: "object",
|
|
1094
|
+
properties,
|
|
1095
|
+
required
|
|
1096
|
+
},
|
|
1097
|
+
uiSchema
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
function getTerminalCommandParameters(command) {
|
|
1101
|
+
return command.parameters ?? fieldsToTerminalCommandParameters(command.fields);
|
|
1102
|
+
}
|
|
1103
|
+
function getTerminalCommandDefaultValues(command, presetValues = {}) {
|
|
1104
|
+
const values = {};
|
|
1105
|
+
const parameters = getTerminalCommandParameters(command);
|
|
1106
|
+
for (const [fieldId, property] of Object.entries(parameters.schema.properties)) {
|
|
1107
|
+
const preset = presetValues[fieldId];
|
|
1108
|
+
if (typeof preset === "string" || typeof preset === "boolean") {
|
|
1109
|
+
values[fieldId] = preset;
|
|
1110
|
+
continue;
|
|
1111
|
+
}
|
|
1112
|
+
const defaultValue = getJsonSchemaDefaultValue(property);
|
|
1113
|
+
if (defaultValue !== void 0) {
|
|
1114
|
+
values[fieldId] = defaultValue;
|
|
1115
|
+
continue;
|
|
1116
|
+
}
|
|
1117
|
+
values[fieldId] = getJsonSchemaPropertyType(property) === "boolean" ? false : "";
|
|
1118
|
+
}
|
|
1119
|
+
return values;
|
|
1120
|
+
}
|
|
1121
|
+
function stringifyFieldValue(value) {
|
|
1122
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
1123
|
+
return value ?? "";
|
|
1124
|
+
}
|
|
1125
|
+
function isRecord(value) {
|
|
1126
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1127
|
+
}
|
|
1128
|
+
function getJsonSchemaDefaultValue(property) {
|
|
1129
|
+
if (!isRecord(property)) return void 0;
|
|
1130
|
+
const defaultValue = property.default;
|
|
1131
|
+
if (typeof defaultValue === "string" || typeof defaultValue === "boolean") return defaultValue;
|
|
1132
|
+
}
|
|
1133
|
+
function getJsonSchemaPropertyType(property) {
|
|
1134
|
+
if (!isRecord(property)) return void 0;
|
|
1135
|
+
return typeof property.type === "string" ? property.type : void 0;
|
|
1136
|
+
}
|
|
1137
|
+
function renderTerminalCommandArgs(command, values) {
|
|
1138
|
+
const args = [];
|
|
1139
|
+
for (const arg of command.args) {
|
|
1140
|
+
if (arg.kind === "literal") {
|
|
1141
|
+
args.push(arg.value);
|
|
1142
|
+
continue;
|
|
1143
|
+
}
|
|
1144
|
+
if (arg.kind === "booleanFlag") {
|
|
1145
|
+
if (values[arg.fieldId] === true) args.push(arg.flag);
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
const value = stringifyFieldValue(values[arg.fieldId]).trim();
|
|
1149
|
+
if (!value && arg.omitWhenEmpty) continue;
|
|
1150
|
+
args.push(`${arg.prefix}${value}`);
|
|
1151
|
+
}
|
|
1152
|
+
return args;
|
|
1153
|
+
}
|
|
1154
|
+
function renderTerminalCommandBuilderParts(parts, values) {
|
|
1155
|
+
const argv = [];
|
|
1156
|
+
for (const part of parts) {
|
|
1157
|
+
if (part.kind === "literal") {
|
|
1158
|
+
if (part.value.trim().length > 0) argv.push(part.value);
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
if (part.kind === "booleanFlag") {
|
|
1162
|
+
if (values[part.fieldId] === true) argv.push(part.flag);
|
|
1163
|
+
continue;
|
|
1164
|
+
}
|
|
1165
|
+
const value = stringifyFieldValue(values[part.fieldId]).trim();
|
|
1166
|
+
if (!value && part.omitWhenEmpty) continue;
|
|
1167
|
+
argv.push(`${part.prefix}${value}`);
|
|
1168
|
+
}
|
|
1169
|
+
return argv;
|
|
1170
|
+
}
|
|
1171
|
+
function renderTemplateString(template, values) {
|
|
1172
|
+
return template.replace(/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/g, (_match, fieldId) => stringifyFieldValue(values[fieldId]));
|
|
1173
|
+
}
|
|
1174
|
+
function renderTerminalSpawnCommand(options) {
|
|
1175
|
+
const builder = options.command.builder;
|
|
1176
|
+
if (!builder) return {
|
|
1177
|
+
kind: "argv",
|
|
1178
|
+
argv: [options.command.command, ...renderTerminalCommandArgs(options.command, options.values)]
|
|
1179
|
+
};
|
|
1180
|
+
if (builder.kind === "shellLine") return {
|
|
1181
|
+
kind: "shellLine",
|
|
1182
|
+
commandLine: renderTemplateString(builder.template, options.values).trim()
|
|
1183
|
+
};
|
|
1184
|
+
return {
|
|
1185
|
+
kind: "argv",
|
|
1186
|
+
argv: renderTerminalCommandBuilderParts(builder.parts, options.values)
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
function quotePosix(value) {
|
|
1190
|
+
if (value.length === 0) return "''";
|
|
1191
|
+
if (/^[A-Za-z0-9_./:@%+=,-]+$/.test(value)) return value;
|
|
1192
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
1193
|
+
}
|
|
1194
|
+
function quoteCmd(value) {
|
|
1195
|
+
if (value.length === 0) return "\"\"";
|
|
1196
|
+
if (!/[\s"&|<>^()%!]/.test(value)) return value;
|
|
1197
|
+
return `"${value.replace(/(["^&|<>])/g, "^$1")}"`;
|
|
1198
|
+
}
|
|
1199
|
+
function quotePowerShell(value) {
|
|
1200
|
+
if (value.length === 0) return "''";
|
|
1201
|
+
if (/^[A-Za-z0-9_./:@%+=,-]+$/.test(value)) return value;
|
|
1202
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
1203
|
+
}
|
|
1204
|
+
function quoteTerminalShellArg(value, quoteStyle) {
|
|
1205
|
+
if (quoteStyle === "cmd") return quoteCmd(value);
|
|
1206
|
+
if (quoteStyle === "powershell") return quotePowerShell(value);
|
|
1207
|
+
return quotePosix(value);
|
|
1208
|
+
}
|
|
1209
|
+
function renderTerminalSpawnCommandLine(options) {
|
|
1210
|
+
const result = renderTerminalSpawnCommand(options);
|
|
1211
|
+
if (result.kind === "shellLine") return result.commandLine;
|
|
1212
|
+
return result.argv.map((part) => quoteTerminalShellArg(part, options.quoteStyle)).join(" ");
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
//#endregion
|
|
1216
|
+
export { TerminalInvocationSettingsSchema as a, TerminalSpawnCommandSchema as c, getTerminalCommandParameters as d, quoteTerminalShellArg as f, resolveTerminalShellDefaults as g, renderTerminalSpawnCommandLine as h, TerminalCommandFieldSchema as i, fieldsToTerminalCommandParameters as l, renderTerminalSpawnCommand as m, TERMINAL_COMMAND_FIELD_TYPE_VALUES as n, TerminalShellProfileSchema as o, renderTerminalCommandArgs as p, TERMINAL_SHELL_QUOTE_STYLE_VALUES as r, TerminalShellQuoteStyleSchema as s, BUILTIN_TERMINAL_SPAWN_COMMANDS as t, getTerminalCommandDefaultValues as u };
|