@getmateo/protocol 0.0.0-stage → 0.17.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.
Files changed (171) hide show
  1. package/LICENSE +211 -0
  2. package/README.md +11 -2
  3. package/dist/addresses.d.ts +6 -0
  4. package/dist/addresses.js +2 -0
  5. package/dist/agent-attention-notification.d.ts +57 -0
  6. package/dist/agent-attention-notification.js +177 -0
  7. package/dist/agent-deep-link.d.ts +8 -0
  8. package/dist/agent-deep-link.js +49 -0
  9. package/dist/agent-labels.d.ts +14 -0
  10. package/dist/agent-labels.js +38 -0
  11. package/dist/agent-lifecycle.d.ts +3 -0
  12. package/dist/agent-lifecycle.js +8 -0
  13. package/dist/agent-message.d.ts +20 -0
  14. package/dist/agent-message.js +12 -0
  15. package/dist/agent-profile.d.ts +31 -0
  16. package/dist/agent-profile.js +32 -0
  17. package/dist/agent-runtime-config.d.ts +4 -0
  18. package/dist/agent-runtime-config.js +5 -0
  19. package/dist/agent-shells.d.ts +25 -0
  20. package/dist/agent-shells.js +17 -0
  21. package/dist/agent-state-bucket.d.ts +15 -0
  22. package/dist/agent-state-bucket.js +41 -0
  23. package/dist/agent-title-limits.d.ts +2 -0
  24. package/dist/agent-title-limits.js +2 -0
  25. package/dist/agent-types.d.ts +484 -0
  26. package/dist/agent-types.js +33 -0
  27. package/dist/binary-frames/demux.d.ts +15 -0
  28. package/dist/binary-frames/demux.js +28 -0
  29. package/dist/binary-frames/file-transfer.d.ts +51 -0
  30. package/dist/binary-frames/file-transfer.js +108 -0
  31. package/dist/binary-frames/host-route.d.ts +13 -0
  32. package/dist/binary-frames/host-route.js +39 -0
  33. package/dist/binary-frames/index.d.ts +5 -0
  34. package/dist/binary-frames/index.js +5 -0
  35. package/dist/binary-frames/terminal.d.ts +35 -0
  36. package/dist/binary-frames/terminal.js +100 -0
  37. package/dist/branch-slug.d.ts +14 -0
  38. package/dist/branch-slug.js +49 -0
  39. package/dist/browser-automation/capabilities.d.ts +7 -0
  40. package/dist/browser-automation/capabilities.js +31 -0
  41. package/dist/browser-automation/rpc-schemas.d.ts +1113 -0
  42. package/dist/browser-automation/rpc-schemas.js +463 -0
  43. package/dist/build-metadata.d.ts +17 -0
  44. package/dist/build-metadata.js +61 -0
  45. package/dist/chat/rpc-schemas.d.ts +158 -0
  46. package/dist/chat/rpc-schemas.js +104 -0
  47. package/dist/chat/types.d.ts +30 -0
  48. package/dist/chat/types.js +23 -0
  49. package/dist/check-traits.d.ts +11 -0
  50. package/dist/check-traits.js +10 -0
  51. package/dist/chunked-transport.d.ts +42 -0
  52. package/dist/chunked-transport.js +277 -0
  53. package/dist/client-capabilities.d.ts +24 -0
  54. package/dist/client-capabilities.js +52 -0
  55. package/dist/connection-offer.d.ts +36 -0
  56. package/dist/connection-offer.js +53 -0
  57. package/dist/daemon-auth.d.ts +548 -0
  58. package/dist/daemon-auth.js +152 -0
  59. package/dist/daemon-endpoints.d.ts +54 -0
  60. package/dist/daemon-endpoints.js +243 -0
  61. package/dist/error-utils.d.ts +11 -0
  62. package/dist/error-utils.js +27 -0
  63. package/dist/fleet.d.ts +381 -0
  64. package/dist/fleet.js +134 -0
  65. package/dist/forge-manifest.d.ts +66 -0
  66. package/dist/forge-manifest.js +92 -0
  67. package/dist/generated/validation/ws-outbound-schema-metadata.d.ts +14023 -0
  68. package/dist/generated/validation/ws-outbound-schema-metadata.js +258 -0
  69. package/dist/generated/validation/ws-outbound.aot.d.ts +512 -0
  70. package/dist/generated/validation/ws-outbound.aot.js +105425 -0
  71. package/dist/git-remote.d.ts +33 -0
  72. package/dist/git-remote.js +94 -0
  73. package/dist/gitea-status.d.ts +10 -0
  74. package/dist/gitea-status.js +23 -0
  75. package/dist/gitlab-pipeline.d.ts +10 -0
  76. package/dist/gitlab-pipeline.js +17 -0
  77. package/dist/global-terminal.d.ts +3 -0
  78. package/dist/global-terminal.js +8 -0
  79. package/dist/host-connection-schema.d.ts +11 -0
  80. package/dist/host-connection-schema.js +9 -0
  81. package/dist/host-target.d.ts +20 -0
  82. package/dist/host-target.js +137 -0
  83. package/dist/hosts.d.ts +133 -0
  84. package/dist/hosts.js +82 -0
  85. package/dist/literal-union.d.ts +2 -0
  86. package/dist/literal-union.js +2 -0
  87. package/dist/loop/rpc-schemas.d.ts +636 -0
  88. package/dist/loop/rpc-schemas.js +164 -0
  89. package/dist/mateo-config-schema.d.ts +138 -0
  90. package/dist/mateo-config-schema.js +98 -0
  91. package/dist/mateo-tool-call-detail.d.ts +2 -0
  92. package/dist/mateo-tool-call-detail.js +3 -0
  93. package/dist/mateo-tool-presentation/agent-message.d.ts +10 -0
  94. package/dist/mateo-tool-presentation/agent-message.js +23 -0
  95. package/dist/mateo-tool-presentation/catalog.d.ts +320 -0
  96. package/dist/mateo-tool-presentation/catalog.js +318 -0
  97. package/dist/mateo-tool-presentation/detail-sections.d.ts +15 -0
  98. package/dist/mateo-tool-presentation/detail-sections.js +161 -0
  99. package/dist/mateo-tool-presentation/index.d.ts +22 -0
  100. package/dist/mateo-tool-presentation/index.js +62 -0
  101. package/dist/mateo-tool-presentation/summary-text.d.ts +7 -0
  102. package/dist/mateo-tool-presentation/summary-text.js +22 -0
  103. package/dist/messages.d.ts +69382 -0
  104. package/dist/messages.js +6717 -0
  105. package/dist/path-utils.d.ts +2 -0
  106. package/dist/path-utils.js +16 -0
  107. package/dist/plugin-config.d.ts +18 -0
  108. package/dist/plugin-config.js +13 -0
  109. package/dist/plugin-overview.d.ts +12 -0
  110. package/dist/plugin-overview.js +50 -0
  111. package/dist/plugin-registry.d.ts +153 -0
  112. package/dist/plugin-registry.js +83 -0
  113. package/dist/plugin-requirements.d.ts +11 -0
  114. package/dist/plugin-requirements.js +26 -0
  115. package/dist/plugin-source-reference.d.ts +11 -0
  116. package/dist/plugin-source-reference.js +68 -0
  117. package/dist/provider-config.d.ts +141 -0
  118. package/dist/provider-config.js +113 -0
  119. package/dist/provider-icon-names.d.ts +5 -0
  120. package/dist/provider-icon-names.js +54 -0
  121. package/dist/provider-manifest.d.ts +30 -0
  122. package/dist/provider-manifest.js +247 -0
  123. package/dist/provider-snapshot-codec.d.ts +18 -0
  124. package/dist/provider-snapshot-codec.js +71 -0
  125. package/dist/schedule/cadence.d.ts +6 -0
  126. package/dist/schedule/cadence.js +28 -0
  127. package/dist/schedule/cron-expression.d.ts +14 -0
  128. package/dist/schedule/cron-expression.js +107 -0
  129. package/dist/schedule/rpc-schemas.d.ts +570 -0
  130. package/dist/schedule/rpc-schemas.js +158 -0
  131. package/dist/schedule/types.d.ts +201 -0
  132. package/dist/schedule/types.js +68 -0
  133. package/dist/search/text-match.d.ts +78 -0
  134. package/dist/search/text-match.js +330 -0
  135. package/dist/service-defaults.d.ts +3 -0
  136. package/dist/service-defaults.js +5 -0
  137. package/dist/ssh-transport.d.ts +11 -0
  138. package/dist/ssh-transport.js +72 -0
  139. package/dist/terminal-activity.d.ts +21 -0
  140. package/dist/terminal-activity.js +25 -0
  141. package/dist/terminal-input-mode.d.ts +30 -0
  142. package/dist/terminal-input-mode.js +180 -0
  143. package/dist/terminal-key-input.d.ts +13 -0
  144. package/dist/terminal-key-input.js +210 -0
  145. package/dist/terminal-profile.d.ts +10 -0
  146. package/dist/terminal-profile.js +11 -0
  147. package/dist/terminal-profiles.d.ts +41 -0
  148. package/dist/terminal-profiles.js +276 -0
  149. package/dist/terminal-snapshot.d.ts +4 -0
  150. package/dist/terminal-snapshot.js +220 -0
  151. package/dist/terminal-stream-protocol.d.ts +2 -0
  152. package/dist/terminal-stream-protocol.js +2 -0
  153. package/dist/terminal-subscription-key.d.ts +2 -0
  154. package/dist/terminal-subscription-key.js +9 -0
  155. package/dist/timeline-identity.d.ts +3 -0
  156. package/dist/timeline-identity.js +8 -0
  157. package/dist/tool-call-display.d.ts +13 -0
  158. package/dist/tool-call-display.js +144 -0
  159. package/dist/tool-name-normalization.d.ts +9 -0
  160. package/dist/tool-name-normalization.js +82 -0
  161. package/dist/user-agent.d.ts +26 -0
  162. package/dist/user-agent.js +101 -0
  163. package/dist/validation/ws-outbound-envelope.d.ts +13261 -0
  164. package/dist/validation/ws-outbound-envelope.js +17 -0
  165. package/dist/validation/ws-outbound.d.ts +12 -0
  166. package/dist/validation/ws-outbound.js +38 -0
  167. package/dist/websocket-message-limit.d.ts +5 -0
  168. package/dist/websocket-message-limit.js +5 -0
  169. package/dist/workspace-labels.d.ts +9 -0
  170. package/dist/workspace-labels.js +19 -0
  171. package/package.json +43 -4
@@ -0,0 +1,13 @@
1
+ import type { TerminalInputModeState } from "./terminal-input-mode.js";
2
+ export interface TerminalKeyInput {
3
+ key: string;
4
+ ctrl?: boolean;
5
+ alt?: boolean;
6
+ shift?: boolean;
7
+ meta?: boolean;
8
+ }
9
+ export interface TerminalKeyInputEncodingOptions {
10
+ inputMode?: TerminalInputModeState;
11
+ }
12
+ export declare function encodeTerminalKeyInput(input: TerminalKeyInput, options?: TerminalKeyInputEncodingOptions): string;
13
+ //# sourceMappingURL=terminal-key-input.d.ts.map
@@ -0,0 +1,210 @@
1
+ const WIN32_LEFT_ALT_PRESSED = 0x0002;
2
+ const WIN32_LEFT_CTRL_PRESSED = 0x0008;
3
+ const WIN32_SHIFT_PRESSED = 0x0010;
4
+ function modifierParam(input) {
5
+ let value = 1;
6
+ if (input.shift)
7
+ value += 1;
8
+ if (input.alt)
9
+ value += 2;
10
+ if (input.ctrl)
11
+ value += 4;
12
+ if (input.meta)
13
+ value += 8;
14
+ return value;
15
+ }
16
+ function win32ControlKeyState(input) {
17
+ let value = 0;
18
+ if (input.shift)
19
+ value += WIN32_SHIFT_PRESSED;
20
+ if (input.ctrl)
21
+ value += WIN32_LEFT_CTRL_PRESSED;
22
+ if (input.alt)
23
+ value += WIN32_LEFT_ALT_PRESSED;
24
+ return value;
25
+ }
26
+ function shouldUseWin32InputMode(input, options) {
27
+ if (!options.inputMode?.win32InputMode) {
28
+ return false;
29
+ }
30
+ return Boolean(input.shift || input.ctrl || input.alt);
31
+ }
32
+ function shouldUseKittyKeyboardMode(input, options) {
33
+ if ((options.inputMode?.kittyKeyboardFlags ?? 0) <= 0) {
34
+ return false;
35
+ }
36
+ return Boolean(input.shift || input.ctrl || input.alt || input.meta);
37
+ }
38
+ function encodeWin32EnterKeyInput(input) {
39
+ const controlKeyState = win32ControlKeyState(input);
40
+ // ConPTY Win32 input mode: CSI Vk;Sc;Uc;Kd;Cs;Rc _
41
+ return `\x1b[13;28;13;1;${controlKeyState};1_`;
42
+ }
43
+ function applyAltLikePrefix(sequence, input) {
44
+ return input.alt ? `\x1b${sequence}` : sequence;
45
+ }
46
+ function ctrlSymbolCode(char) {
47
+ switch (char) {
48
+ case " ":
49
+ case "@":
50
+ case "2":
51
+ return "\x00";
52
+ case "[":
53
+ case "3":
54
+ return "\x1b";
55
+ case "\\":
56
+ case "4":
57
+ return "\x1c";
58
+ case "]":
59
+ case "5":
60
+ return "\x1d";
61
+ case "^":
62
+ case "6":
63
+ return "\x1e";
64
+ case "_":
65
+ case "/":
66
+ case "7":
67
+ return "\x1f";
68
+ case "8":
69
+ case "?":
70
+ return "\x7f";
71
+ default:
72
+ return null;
73
+ }
74
+ }
75
+ function encodeCtrlChar(char, input) {
76
+ const upper = char.toUpperCase();
77
+ if (upper.length === 1 && upper >= "A" && upper <= "Z") {
78
+ return applyAltLikePrefix(String.fromCharCode(upper.charCodeAt(0) - 64), input);
79
+ }
80
+ const symbol = ctrlSymbolCode(char);
81
+ if (symbol !== null) {
82
+ return applyAltLikePrefix(symbol, input);
83
+ }
84
+ if (char.length === 1) {
85
+ const code = char.charCodeAt(0) & 0x1f;
86
+ return applyAltLikePrefix(String.fromCharCode(code), input);
87
+ }
88
+ return applyAltLikePrefix(char, input);
89
+ }
90
+ function encodePrintableKey(input) {
91
+ const raw = input.key;
92
+ const char = input.shift ? raw.toUpperCase() : raw;
93
+ if (input.ctrl) {
94
+ return encodeCtrlChar(char, input);
95
+ }
96
+ return applyAltLikePrefix(char, input);
97
+ }
98
+ function csiWithModifier(finalByte, input) {
99
+ const mod = modifierParam(input);
100
+ return mod === 1 ? `\x1b[${finalByte}` : `\x1b[1;${mod}${finalByte}`;
101
+ }
102
+ function ss3WithModifier(finalByte, input) {
103
+ return modifierParam(input) === 1 ? `\x1bO${finalByte}` : csiWithModifier(finalByte, input);
104
+ }
105
+ function csiTilde(base, input) {
106
+ const mod = modifierParam(input);
107
+ return mod === 1 ? `\x1b[${base}~` : `\x1b[${base};${mod}~`;
108
+ }
109
+ function encodeFunctionKey(key, input) {
110
+ switch (key) {
111
+ case "F1":
112
+ return modifierParam(input) === 1 ? "\x1bOP" : csiWithModifier("P", input);
113
+ case "F2":
114
+ return modifierParam(input) === 1 ? "\x1bOQ" : csiWithModifier("Q", input);
115
+ case "F3":
116
+ return modifierParam(input) === 1 ? "\x1bOR" : csiWithModifier("R", input);
117
+ case "F4":
118
+ return modifierParam(input) === 1 ? "\x1bOS" : csiWithModifier("S", input);
119
+ case "F5":
120
+ return csiTilde(15, input);
121
+ case "F6":
122
+ return csiTilde(17, input);
123
+ case "F7":
124
+ return csiTilde(18, input);
125
+ case "F8":
126
+ return csiTilde(19, input);
127
+ case "F9":
128
+ return csiTilde(20, input);
129
+ case "F10":
130
+ return csiTilde(21, input);
131
+ case "F11":
132
+ return csiTilde(23, input);
133
+ case "F12":
134
+ return csiTilde(24, input);
135
+ default:
136
+ return null;
137
+ }
138
+ }
139
+ function encodeArrowKey(finalByte, input, options) {
140
+ if (options.inputMode?.applicationCursorKeys) {
141
+ return ss3WithModifier(finalByte, input);
142
+ }
143
+ return csiWithModifier(finalByte, input);
144
+ }
145
+ function encodeNavigationKey(key, input, options) {
146
+ switch (key) {
147
+ case "ArrowUp":
148
+ return encodeArrowKey("A", input, options);
149
+ case "ArrowDown":
150
+ return encodeArrowKey("B", input, options);
151
+ case "ArrowRight":
152
+ return encodeArrowKey("C", input, options);
153
+ case "ArrowLeft":
154
+ return encodeArrowKey("D", input, options);
155
+ case "Home":
156
+ return csiWithModifier("H", input);
157
+ case "End":
158
+ return csiWithModifier("F", input);
159
+ case "Insert":
160
+ return csiTilde(2, input);
161
+ case "Delete":
162
+ return csiTilde(3, input);
163
+ case "PageUp":
164
+ return csiTilde(5, input);
165
+ case "PageDown":
166
+ return csiTilde(6, input);
167
+ default:
168
+ return null;
169
+ }
170
+ }
171
+ export function encodeTerminalKeyInput(input, options = {}) {
172
+ const key = input.key;
173
+ if (!key) {
174
+ return "";
175
+ }
176
+ if (key.length === 1) {
177
+ return encodePrintableKey(input);
178
+ }
179
+ switch (key) {
180
+ case "Enter": {
181
+ const mod = modifierParam(input);
182
+ if (mod > 1 && shouldUseWin32InputMode(input, options)) {
183
+ return encodeWin32EnterKeyInput(input);
184
+ }
185
+ if (mod > 1 && shouldUseKittyKeyboardMode(input, options)) {
186
+ return `\x1b[13;${mod}u`;
187
+ }
188
+ return "\r";
189
+ }
190
+ case "Tab":
191
+ if (input.shift && !input.ctrl && !input.alt && !input.meta) {
192
+ return "\x1b[Z";
193
+ }
194
+ return applyAltLikePrefix("\t", input);
195
+ case "Backspace":
196
+ return applyAltLikePrefix("\x7f", input);
197
+ case "Escape":
198
+ return "\x1b";
199
+ default:
200
+ break;
201
+ }
202
+ const nav = encodeNavigationKey(key, input, options);
203
+ if (nav !== null)
204
+ return nav;
205
+ const fn = encodeFunctionKey(key, input);
206
+ if (fn !== null)
207
+ return fn;
208
+ return "";
209
+ }
210
+ //# sourceMappingURL=terminal-key-input.js.map
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ export declare const TerminalProfileSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ name: z.ZodString;
5
+ command: z.ZodString;
6
+ args: z.ZodOptional<z.ZodArray<z.ZodString>>;
7
+ icon: z.ZodOptional<z.ZodString>;
8
+ }, z.core.$loose>;
9
+ export type TerminalProfile = z.infer<typeof TerminalProfileSchema>;
10
+ //# sourceMappingURL=terminal-profile.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ export const TerminalProfileSchema = z
3
+ .object({
4
+ id: z.string(),
5
+ name: z.string(),
6
+ command: z.string(),
7
+ args: z.array(z.string()).optional(),
8
+ icon: z.string().optional(),
9
+ })
10
+ .passthrough();
11
+ //# sourceMappingURL=terminal-profile.js.map
@@ -0,0 +1,41 @@
1
+ import type { TerminalProfile } from "./messages.js";
2
+ /**
3
+ * Marks where a typed prompt goes inside a profile's `command` or `args`. A
4
+ * profile carrying it accepts a prompt; one without it launches as-is.
5
+ *
6
+ * Substitution happens client-side before `create_terminal_request` is sent, so
7
+ * this is profile-format vocabulary rather than anything on the wire. It lives
8
+ * here because this module owns what a `TerminalProfile` means.
9
+ */
10
+ export declare const PROMPT_SENTINEL = "{{{prompt}}}";
11
+ export declare const DEFAULT_TERMINAL_PROFILES: readonly TerminalProfile[];
12
+ export interface SubstitutableCommand {
13
+ command: string;
14
+ args?: string[];
15
+ }
16
+ export interface ResolvedCommand {
17
+ command: string;
18
+ args: string[];
19
+ }
20
+ /** True when the sentinel appears anywhere in `command` or an `args` entry. */
21
+ export declare function profileTakesPrompt(profile: SubstitutableCommand): boolean;
22
+ /** Replaces every sentinel occurrence with `prompt`, dropping prompt-only args when there is none. */
23
+ export declare function substitutePrompt(profile: SubstitutableCommand, prompt: string): ResolvedCommand;
24
+ /** Human-readable preview of the resolved command, for read-only display. */
25
+ export declare function formatResolvedCommand(resolved: ResolvedCommand): string;
26
+ export interface TerminalProfileLaunch {
27
+ name: string;
28
+ command: string;
29
+ args: string[];
30
+ }
31
+ /**
32
+ * What to spawn for a profile. Every launcher goes through here, so no caller
33
+ * can forward a raw `profile.args` still carrying the sentinel: launchers with
34
+ * nowhere to type (pinned targets, the workspace terminal menu) pass an empty
35
+ * prompt and get the bare command back.
36
+ */
37
+ export declare function resolveTerminalProfileLaunch(profile: TerminalProfile, prompt: string): TerminalProfileLaunch;
38
+ export declare function guessTerminalProfileIcon(command: string): string | undefined;
39
+ export declare function getTerminalProfileIcon(profile: TerminalProfile): string | undefined;
40
+ export declare function resolveTerminalProfiles(terminalProfiles: TerminalProfile[] | undefined): readonly TerminalProfile[];
41
+ //# sourceMappingURL=terminal-profiles.d.ts.map
@@ -0,0 +1,276 @@
1
+ import { KNOWN_PROVIDER_ICON_NAMES } from "./provider-icon-names.js";
2
+ /**
3
+ * Marks where a typed prompt goes inside a profile's `command` or `args`. A
4
+ * profile carrying it accepts a prompt; one without it launches as-is.
5
+ *
6
+ * Substitution happens client-side before `create_terminal_request` is sent, so
7
+ * this is profile-format vocabulary rather than anything on the wire. It lives
8
+ * here because this module owns what a `TerminalProfile` means.
9
+ */
10
+ export const PROMPT_SENTINEL = "{{{prompt}}}";
11
+ // Prompt forms are taken from each CLI's own `--help`. claude, codex, and pi
12
+ // take the prompt as a trailing positional. opencode's positional is the
13
+ // project directory, so its prompt goes through `--prompt`, written in the
14
+ // `--flag=value` form to keep it one argv entry that can be dropped whole when
15
+ // no prompt is typed.
16
+ export const DEFAULT_TERMINAL_PROFILES = [
17
+ { id: "claude", name: "Claude Code", command: "claude", args: [PROMPT_SENTINEL], icon: "claude" },
18
+ { id: "codex", name: "Codex", command: "codex", args: [PROMPT_SENTINEL], icon: "codex" },
19
+ {
20
+ id: "opencode",
21
+ name: "OpenCode",
22
+ command: "opencode",
23
+ args: [`--prompt=${PROMPT_SENTINEL}`],
24
+ icon: "opencode",
25
+ },
26
+ { id: "pi", name: "Pi", command: "pi", args: [PROMPT_SENTINEL], icon: "pi" },
27
+ ];
28
+ function containsSentinel(value) {
29
+ return value.includes(PROMPT_SENTINEL);
30
+ }
31
+ /** True when the sentinel appears anywhere in `command` or an `args` entry. */
32
+ export function profileTakesPrompt(profile) {
33
+ return containsSentinel(profile.command) || (profile.args ?? []).some(containsSentinel);
34
+ }
35
+ function replaceSentinel(value, prompt) {
36
+ return value.split(PROMPT_SENTINEL).join(prompt);
37
+ }
38
+ /**
39
+ * An arg that exists only to carry a prompt: the sentinel alone
40
+ * (`{{{prompt}}}`), or as the whole value of an option assignment
41
+ * (`--prompt={{{prompt}}}`). Both are dropped when there is no prompt, because
42
+ * an empty positional and a valueless `--prompt=` are not the same as omitting
43
+ * them. A sentinel embedded in larger text (`echo {{{prompt}}}`) is not
44
+ * prompt-only and still substitutes to empty.
45
+ *
46
+ * This is why an option and its value belong in one entry. Split across two,
47
+ * the option would survive with nothing to carry.
48
+ */
49
+ function isPromptOnlyArg(arg) {
50
+ if (arg === PROMPT_SENTINEL) {
51
+ return true;
52
+ }
53
+ const separator = arg.indexOf("=");
54
+ return separator > 0 && arg.slice(separator + 1) === PROMPT_SENTINEL;
55
+ }
56
+ /** Replaces every sentinel occurrence with `prompt`, dropping prompt-only args when there is none. */
57
+ export function substitutePrompt(profile, prompt) {
58
+ return {
59
+ command: replaceSentinel(profile.command, prompt),
60
+ args: (profile.args ?? []).flatMap((arg) => prompt === "" && isPromptOnlyArg(arg) ? [] : [replaceSentinel(arg, prompt)]),
61
+ };
62
+ }
63
+ /** Human-readable preview of the resolved command, for read-only display. */
64
+ export function formatResolvedCommand(resolved) {
65
+ return [resolved.command, ...resolved.args].join(" ");
66
+ }
67
+ /**
68
+ * What to spawn for a profile. Every launcher goes through here, so no caller
69
+ * can forward a raw `profile.args` still carrying the sentinel: launchers with
70
+ * nowhere to type (pinned targets, the workspace terminal menu) pass an empty
71
+ * prompt and get the bare command back.
72
+ */
73
+ export function resolveTerminalProfileLaunch(profile, prompt) {
74
+ return { name: profile.name, ...substitutePrompt(profile, prompt) };
75
+ }
76
+ // CLIs whose binary is not named after their icon. Matching stays exact, so a
77
+ // command only gets an icon when its whole base name is listed.
78
+ const COMMAND_ICON_ALIASES = [["cursor-agent", "cursor"]];
79
+ const WELL_KNOWN_COMMAND_ICONS = new Map([
80
+ ...KNOWN_PROVIDER_ICON_NAMES.map((name) => [name, name]),
81
+ ...COMMAND_ICON_ALIASES,
82
+ ]);
83
+ function getCommandBaseName(command) {
84
+ const lastSlash = command.lastIndexOf("/");
85
+ const lastBackslash = command.lastIndexOf("\\");
86
+ const start = Math.max(lastSlash, lastBackslash) + 1;
87
+ const base = command.slice(start).toLowerCase();
88
+ const dotIndex = base.indexOf(".");
89
+ return dotIndex > 0 ? base.slice(0, dotIndex) : base;
90
+ }
91
+ export function guessTerminalProfileIcon(command) {
92
+ return WELL_KNOWN_COMMAND_ICONS.get(getCommandBaseName(command));
93
+ }
94
+ export function getTerminalProfileIcon(profile) {
95
+ return profile.icon ?? guessTerminalProfileIcon(profile.command);
96
+ }
97
+ // Base command name to the sentinel-bearing args that command wants, derived
98
+ // from the shipped defaults rather than written out again, so adding a default
99
+ // profile later cannot silently miss the adoption below or get the wrong form.
100
+ const PROMPT_ARGS_BY_COMMAND = new Map(DEFAULT_TERMINAL_PROFILES.map((profile) => [
101
+ getCommandBaseName(profile.command),
102
+ (profile.args ?? []).filter(containsSentinel),
103
+ ]));
104
+ // Adoption applies only to the interactive, prompt-taking form of each CLI.
105
+ // These are the global options whose values would otherwise look positional
106
+ // while walking argv. Unknown options stay conservative: a following bare arg
107
+ // blocks adoption rather than risking a second prompt or changing a subcommand.
108
+ const GLOBAL_OPTIONS_WITH_VALUES_BY_COMMAND = new Map([
109
+ [
110
+ "claude",
111
+ new Set([
112
+ "--add-dir",
113
+ "--agent",
114
+ "--agents",
115
+ "--allowed-tools",
116
+ "--allowedTools",
117
+ "--append-system-prompt",
118
+ "--betas",
119
+ "--debug-file",
120
+ "--disallowed-tools",
121
+ "--disallowedTools",
122
+ "--effort",
123
+ "--fallback-model",
124
+ "--file",
125
+ "--input-format",
126
+ "--json-schema",
127
+ "--max-budget-usd",
128
+ "--mcp-config",
129
+ "--model",
130
+ "--name",
131
+ "--output-format",
132
+ "--permission-mode",
133
+ "--plugin-dir",
134
+ "--plugin-url",
135
+ "--remote-control-session-name-prefix",
136
+ "--settings",
137
+ "--system-prompt",
138
+ "--system-prompt-file",
139
+ "--tools",
140
+ "-n",
141
+ ]),
142
+ ],
143
+ [
144
+ "codex",
145
+ new Set([
146
+ "--add-dir",
147
+ "--ask-for-approval",
148
+ "--cd",
149
+ "--config",
150
+ "--disable",
151
+ "--enable",
152
+ "--image",
153
+ "--local-provider",
154
+ "--model",
155
+ "--profile",
156
+ "--remote",
157
+ "--remote-auth-token-env",
158
+ "--sandbox",
159
+ "-C",
160
+ "-a",
161
+ "-c",
162
+ "-i",
163
+ "-m",
164
+ "-p",
165
+ "-s",
166
+ ]),
167
+ ],
168
+ [
169
+ "opencode",
170
+ new Set([
171
+ "--agent",
172
+ "--cors",
173
+ "--hostname",
174
+ "--log-level",
175
+ "--mdns-domain",
176
+ "--model",
177
+ "--port",
178
+ "--prompt",
179
+ "--replay-limit",
180
+ "--session",
181
+ "-m",
182
+ "-s",
183
+ ]),
184
+ ],
185
+ [
186
+ "pi",
187
+ new Set([
188
+ "--api-key",
189
+ "--append-system-prompt",
190
+ "--exclude-tools",
191
+ "--export",
192
+ "--extension",
193
+ "--fork",
194
+ "--mode",
195
+ "--model",
196
+ "--models",
197
+ "--name",
198
+ "--prompt-template",
199
+ "--provider",
200
+ "--session",
201
+ "--session-dir",
202
+ "--session-id",
203
+ "--skill",
204
+ "--system-prompt",
205
+ "--theme",
206
+ "--thinking",
207
+ "--tools",
208
+ "-e",
209
+ "-n",
210
+ "-t",
211
+ "-xt",
212
+ ]),
213
+ ],
214
+ ]);
215
+ // Profiles predating the sentinel got materialized into user config the first
216
+ // time anyone touched the profile list (host-page.tsx patches the whole list on
217
+ // any add, edit, or reorder). Those users would otherwise be stuck with
218
+ // launch-only versions of the agents we ship, while a fresh install gets prompt
219
+ // support, so a profile still pointing at one of those agents adopts the
220
+ // trailing sentinel on read.
221
+ //
222
+ // Keyed on the command's base name, not the profile id: profiles created
223
+ // through the settings UI get generated ids (`profile_<timestamp>_<random>`),
224
+ // so a real user's Codex profile is never id `codex`. The base name also
225
+ // normalizes `/usr/local/bin/codex` and `codex.cmd` onto the same agent.
226
+ //
227
+ // User args are preserved: `codex --yolo` becomes `codex --yolo {{{prompt}}}`.
228
+ // The appended form comes from the shipped default for that command, so
229
+ // opencode gets `--prompt=` rather than a trailing positional, which it would
230
+ // read as a project directory. A profile that already carries the sentinel
231
+ // anywhere is left alone, and so is one pointing at any other command. Nothing
232
+ // is written back, so this stays a read-time adoption with no version stamp and
233
+ // no daemon-start hook.
234
+ // Any positional means this is not the bare interactive form we can safely
235
+ // adopt. It may be a subcommand (`codex --profile work login`) or an existing
236
+ // prompt/project argument. Option assignments carry their value inline; known
237
+ // split options consume the next argv entry before positional detection.
238
+ function hasPositionalArg(command, args) {
239
+ const optionsWithValues = GLOBAL_OPTIONS_WITH_VALUES_BY_COMMAND.get(command) ?? new Set();
240
+ let expectsOptionValue = false;
241
+ for (const arg of args) {
242
+ if (expectsOptionValue) {
243
+ expectsOptionValue = false;
244
+ continue;
245
+ }
246
+ if (arg === "--") {
247
+ return true;
248
+ }
249
+ if (!arg.startsWith("-")) {
250
+ return true;
251
+ }
252
+ const separator = arg.indexOf("=");
253
+ const option = separator === -1 ? arg : arg.slice(0, separator);
254
+ expectsOptionValue = separator === -1 && optionsWithValues.has(option);
255
+ }
256
+ return false;
257
+ }
258
+ function adoptPromptSentinel(profile) {
259
+ const command = getCommandBaseName(profile.command);
260
+ const promptArgs = PROMPT_ARGS_BY_COMMAND.get(command);
261
+ if (!promptArgs || promptArgs.length === 0) {
262
+ return profile;
263
+ }
264
+ const args = profile.args ?? [];
265
+ if (profileTakesPrompt(profile) || hasPositionalArg(command, args)) {
266
+ return profile;
267
+ }
268
+ return { ...profile, args: [...args, ...promptArgs] };
269
+ }
270
+ export function resolveTerminalProfiles(terminalProfiles) {
271
+ if (terminalProfiles === undefined) {
272
+ return DEFAULT_TERMINAL_PROFILES;
273
+ }
274
+ return terminalProfiles.map(adoptPromptSentinel);
275
+ }
276
+ //# sourceMappingURL=terminal-profiles.js.map
@@ -0,0 +1,4 @@
1
+ import type { TerminalState } from "./messages.js";
2
+ export declare function renderTerminalMouseModesToAnsi(modes: TerminalState["mouseModes"]): string;
3
+ export declare function renderTerminalSnapshotToAnsi(state: TerminalState): string;
4
+ //# sourceMappingURL=terminal-snapshot.d.ts.map