@vibesdotdev/terminal-client 0.0.0-stage → 1.0.0-rc.2

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 (195) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +102 -2
  3. package/dist/ansi/index.d.ts +11 -0
  4. package/dist/ansi/index.d.ts.map +1 -0
  5. package/dist/ansi/index.js +11 -0
  6. package/dist/ansi/index.js.map +1 -0
  7. package/dist/ansi/keymap.d.ts +77 -0
  8. package/dist/ansi/keymap.d.ts.map +1 -0
  9. package/dist/ansi/keymap.js +257 -0
  10. package/dist/ansi/keymap.js.map +1 -0
  11. package/dist/api-client-plugin.d.ts +4 -0
  12. package/dist/api-client-plugin.d.ts.map +1 -0
  13. package/dist/api-client-plugin.js +16 -0
  14. package/dist/api-client-plugin.js.map +1 -0
  15. package/dist/client/http-session.d.ts +44 -0
  16. package/dist/client/http-session.d.ts.map +1 -0
  17. package/dist/client/http-session.js +457 -0
  18. package/dist/client/http-session.js.map +1 -0
  19. package/dist/client/index.d.ts +8 -0
  20. package/dist/client/index.d.ts.map +1 -0
  21. package/dist/client/index.js +8 -0
  22. package/dist/client/index.js.map +1 -0
  23. package/dist/client.d.ts +56 -0
  24. package/dist/client.d.ts.map +1 -0
  25. package/dist/client.js +169 -0
  26. package/dist/client.js.map +1 -0
  27. package/dist/index.d.ts +14 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +14 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/pty-bridge/index.d.ts +15 -0
  32. package/dist/pty-bridge/index.d.ts.map +1 -0
  33. package/dist/pty-bridge/index.js +15 -0
  34. package/dist/pty-bridge/index.js.map +1 -0
  35. package/dist/pty-bridge/protocol.d.ts +6 -0
  36. package/dist/pty-bridge/protocol.d.ts.map +1 -0
  37. package/dist/pty-bridge/protocol.js +6 -0
  38. package/dist/pty-bridge/protocol.js.map +1 -0
  39. package/dist/pty-bridge/server.d.ts +7 -0
  40. package/dist/pty-bridge/server.d.ts.map +1 -0
  41. package/dist/pty-bridge/server.js +9 -0
  42. package/dist/pty-bridge/server.js.map +1 -0
  43. package/dist/remote-session.d.ts +51 -0
  44. package/dist/remote-session.d.ts.map +1 -0
  45. package/dist/remote-session.js +326 -0
  46. package/dist/remote-session.js.map +1 -0
  47. package/dist/schemas/http.d.ts +61 -0
  48. package/dist/schemas/http.d.ts.map +1 -0
  49. package/dist/schemas/http.js +45 -0
  50. package/dist/schemas/http.js.map +1 -0
  51. package/dist/schemas/remote.d.ts +25 -0
  52. package/dist/schemas/remote.d.ts.map +1 -0
  53. package/dist/schemas/remote.js +23 -0
  54. package/dist/schemas/remote.js.map +1 -0
  55. package/dist/schemas/session.d.ts +26 -0
  56. package/dist/schemas/session.d.ts.map +1 -0
  57. package/dist/schemas/session.js +17 -0
  58. package/dist/schemas/session.js.map +1 -0
  59. package/dist/schemas/store.d.ts +29 -0
  60. package/dist/schemas/store.d.ts.map +1 -0
  61. package/dist/schemas/store.js +22 -0
  62. package/dist/schemas/store.js.map +1 -0
  63. package/dist/schemas/terminal.d.ts +296 -0
  64. package/dist/schemas/terminal.d.ts.map +1 -0
  65. package/dist/schemas/terminal.js +243 -0
  66. package/dist/schemas/terminal.js.map +1 -0
  67. package/dist/server/index.d.ts +9 -0
  68. package/dist/server/index.d.ts.map +1 -0
  69. package/dist/server/index.js +9 -0
  70. package/dist/server/index.js.map +1 -0
  71. package/dist/server/session-store.d.ts +176 -0
  72. package/dist/server/session-store.d.ts.map +1 -0
  73. package/dist/server/session-store.js +462 -0
  74. package/dist/server/session-store.js.map +1 -0
  75. package/dist/server/sse-stream.d.ts +32 -0
  76. package/dist/server/sse-stream.d.ts.map +1 -0
  77. package/dist/server/sse-stream.js +87 -0
  78. package/dist/server/sse-stream.js.map +1 -0
  79. package/dist/svelte/HostPicker.svelte +256 -0
  80. package/dist/svelte/HostPicker.svelte.d.ts +30 -0
  81. package/dist/svelte/HostPicker.svelte.d.ts.map +1 -0
  82. package/dist/svelte/README.md +52 -0
  83. package/dist/svelte/ReconnectBanner.svelte +88 -0
  84. package/dist/svelte/ReconnectBanner.svelte.d.ts +16 -0
  85. package/dist/svelte/ReconnectBanner.svelte.d.ts.map +1 -0
  86. package/dist/svelte/SessionTabs.svelte +192 -0
  87. package/dist/svelte/SessionTabs.svelte.d.ts +17 -0
  88. package/dist/svelte/SessionTabs.svelte.d.ts.map +1 -0
  89. package/dist/svelte/Terminal.svelte +567 -0
  90. package/dist/svelte/Terminal.svelte.d.ts +25 -0
  91. package/dist/svelte/Terminal.svelte.d.ts.map +1 -0
  92. package/dist/svelte/TerminalMobileToolbar.svelte +56 -0
  93. package/dist/svelte/TerminalMobileToolbar.svelte.d.ts +14 -0
  94. package/dist/svelte/TerminalMobileToolbar.svelte.d.ts.map +1 -0
  95. package/dist/svelte/TerminalWorkspace.svelte +562 -0
  96. package/dist/svelte/TerminalWorkspace.svelte.d.ts +25 -0
  97. package/dist/svelte/TerminalWorkspace.svelte.d.ts.map +1 -0
  98. package/dist/svelte/ambient.d.ts +9 -0
  99. package/dist/svelte/docs/terminal-svelte.docs.descriptor.d.ts +4 -0
  100. package/dist/svelte/docs/terminal-svelte.docs.descriptor.d.ts.map +1 -0
  101. package/dist/svelte/docs/terminal-svelte.docs.descriptor.js +74 -0
  102. package/dist/svelte/index.d.ts +27 -0
  103. package/dist/svelte/index.d.ts.map +1 -0
  104. package/dist/svelte/index.js +26 -0
  105. package/dist/svelte/styles.css +8 -0
  106. package/dist/svelte/terminal-session-authority.d.ts +17 -0
  107. package/dist/svelte/terminal-session-authority.d.ts.map +1 -0
  108. package/dist/svelte/terminal-session-authority.js +25 -0
  109. package/dist/svelte/terminal-svelte.plugin.d.ts +19 -0
  110. package/dist/svelte/terminal-svelte.plugin.d.ts.map +1 -0
  111. package/dist/svelte/terminal-svelte.plugin.js +42 -0
  112. package/dist/svelte/terminal-theme.d.ts +11 -0
  113. package/dist/svelte/terminal-theme.d.ts.map +1 -0
  114. package/dist/svelte/terminal-theme.js +116 -0
  115. package/dist/svelte/tool-widgets/TerminalToolCard.svelte +65 -0
  116. package/dist/svelte/tool-widgets/TerminalToolCard.svelte.d.ts +5 -0
  117. package/dist/svelte/tool-widgets/TerminalToolCard.svelte.d.ts.map +1 -0
  118. package/dist/svelte/tool-widgets/terminal-tool-card.d.ts +25 -0
  119. package/dist/svelte/tool-widgets/terminal-tool-card.d.ts.map +1 -0
  120. package/dist/svelte/tool-widgets/terminal-tool-card.js +116 -0
  121. package/dist/svelte/types.d.ts +160 -0
  122. package/dist/svelte/types.d.ts.map +1 -0
  123. package/dist/svelte/types.js +51 -0
  124. package/dist/svelte/workspace.d.ts +3 -0
  125. package/dist/svelte/workspace.d.ts.map +1 -0
  126. package/dist/svelte/workspace.js +2 -0
  127. package/dist/terminal-client.plugin.d.ts +3 -0
  128. package/dist/terminal-client.plugin.d.ts.map +1 -0
  129. package/dist/terminal-client.plugin.js +3 -0
  130. package/dist/terminal-client.plugin.js.map +1 -0
  131. package/dist/terminal-runtime.d.ts +30 -0
  132. package/dist/terminal-runtime.d.ts.map +1 -0
  133. package/dist/terminal-runtime.js +673 -0
  134. package/dist/terminal-runtime.js.map +1 -0
  135. package/dist/terminal.consumer.plugin.d.ts +14 -0
  136. package/dist/terminal.consumer.plugin.d.ts.map +1 -0
  137. package/dist/terminal.consumer.plugin.js +31 -0
  138. package/dist/terminal.consumer.plugin.js.map +1 -0
  139. package/dist/tools/terminal.impl.consumer.d.ts +11 -0
  140. package/dist/tools/terminal.impl.consumer.d.ts.map +1 -0
  141. package/dist/tools/terminal.impl.consumer.js +20 -0
  142. package/dist/tools/terminal.impl.consumer.js.map +1 -0
  143. package/dist/tools/terminal.schemas.d.ts +3 -0
  144. package/dist/tools/terminal.schemas.d.ts.map +1 -0
  145. package/dist/tools/terminal.schemas.js +3 -0
  146. package/dist/tools/terminal.schemas.js.map +1 -0
  147. package/dist/tools/terminal.unified.descriptor.d.ts +218 -0
  148. package/dist/tools/terminal.unified.descriptor.d.ts.map +1 -0
  149. package/dist/tools/terminal.unified.descriptor.js +36 -0
  150. package/dist/tools/terminal.unified.descriptor.js.map +1 -0
  151. package/dist/tui/index.d.ts +9 -0
  152. package/dist/tui/index.d.ts.map +1 -0
  153. package/dist/tui/index.js +8 -0
  154. package/dist/tui/index.js.map +1 -0
  155. package/dist/tui/terminal-open.descriptor.d.ts +9 -0
  156. package/dist/tui/terminal-open.descriptor.d.ts.map +1 -0
  157. package/dist/tui/terminal-open.descriptor.js +18 -0
  158. package/dist/tui/terminal-open.descriptor.js.map +1 -0
  159. package/dist/tui/terminal-open.impl.consumer.d.ts +9 -0
  160. package/dist/tui/terminal-open.impl.consumer.d.ts.map +1 -0
  161. package/dist/tui/terminal-open.impl.consumer.js +13 -0
  162. package/dist/tui/terminal-open.impl.consumer.js.map +1 -0
  163. package/dist/tui/terminal-registry.descriptor.d.ts +11 -0
  164. package/dist/tui/terminal-registry.descriptor.d.ts.map +1 -0
  165. package/dist/tui/terminal-registry.descriptor.js +17 -0
  166. package/dist/tui/terminal-registry.descriptor.js.map +1 -0
  167. package/dist/tui/terminal-registry.impl.consumer.d.ts +71 -0
  168. package/dist/tui/terminal-registry.impl.consumer.d.ts.map +1 -0
  169. package/dist/tui/terminal-registry.impl.consumer.js +190 -0
  170. package/dist/tui/terminal-registry.impl.consumer.js.map +1 -0
  171. package/dist/tui/terminal-tui.plugin.d.ts +10 -0
  172. package/dist/tui/terminal-tui.plugin.d.ts.map +1 -0
  173. package/dist/tui/terminal-tui.plugin.js +32 -0
  174. package/dist/tui/terminal-tui.plugin.js.map +1 -0
  175. package/dist/tui/terminal.descriptor.d.ts +10 -0
  176. package/dist/tui/terminal.descriptor.d.ts.map +1 -0
  177. package/dist/tui/terminal.descriptor.js +25 -0
  178. package/dist/tui/terminal.descriptor.js.map +1 -0
  179. package/dist/tui/terminal.impl.consumer.d.ts +14 -0
  180. package/dist/tui/terminal.impl.consumer.d.ts.map +1 -0
  181. package/dist/tui/terminal.impl.consumer.js +189 -0
  182. package/dist/tui/terminal.impl.consumer.js.map +1 -0
  183. package/dist/tui/terminal.state-key.d.ts +30 -0
  184. package/dist/tui/terminal.state-key.d.ts.map +1 -0
  185. package/dist/tui/terminal.state-key.js +9 -0
  186. package/dist/tui/terminal.state-key.js.map +1 -0
  187. package/dist/tui/terminal.state.d.ts +152 -0
  188. package/dist/tui/terminal.state.d.ts.map +1 -0
  189. package/dist/tui/terminal.state.js +149 -0
  190. package/dist/tui/terminal.state.js.map +1 -0
  191. package/dist/workspace.d.ts +155 -0
  192. package/dist/workspace.d.ts.map +1 -0
  193. package/dist/workspace.js +292 -0
  194. package/dist/workspace.js.map +1 -0
  195. package/package.json +228 -4
package/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VIBES DEV LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ # @vibesdotdev/terminal-client
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Terminal sessions for Vibes apps: open a local PTY or a remote PTY on a named
4
+ fleet host, keep it alive across reconnects, drive it from an agent tool, and
5
+ render it in a browser, a desktop window, or a text UI.
6
+
7
+ The package composes `runtime/execution` (which allocates the PTY) and
8
+ `runtime/rpc` (which carries remote sessions). It never allocates a PTY
9
+ itself. Its semantic TerminalClient is registered as runtime/client:terminal.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ bun add @vibesdotdev/terminal-client @vibesdotdev/kernel
15
+ ```
16
+
17
+ The Svelte surface uses optional peers (`svelte`, `@vibesdotdev/kit`,
18
+ `@lucide/svelte`). Install them only if you use
19
+ `@vibesdotdev/terminal-client/svelte`.
20
+
21
+ ## Compose the client
22
+
23
+ Portable hosts compose `@vibesdotdev/terminal-client/api-client-plugin`.
24
+ Consumer hosts retain `@vibesdotdev/terminal-client/plugin` (also available as
25
+ `./consumer-plugin`), which adds the terminal tool and composes that client.
26
+ The portable slice imports no consumer, TUI or host adapter implementations.
27
+
28
+ Resolve `getVibesClient<TerminalClient>('terminal', runtime)` from
29
+ `@vibesdotdev/kernel/client`. The kernel shares that owner within a runtime;
30
+ its disposal terminates tool sessions, process trees and remote PTYs, then releases
31
+ remote connections and counters. Remote PTYs are terminated even if no output
32
+ subscriber ever attached.
33
+ Remote helpers require this composition. Malformed remote references refuse with
34
+ `INVALID_INPUT / terminal-remote-reference-invalid`; explicit local references
35
+ retain `terminal-remote-reference-local`.
36
+
37
+ ## Open a session
38
+
39
+ ```ts
40
+ import { openLocalSession } from '@vibesdotdev/terminal-client';
41
+
42
+ const session = await openLocalSession(runtime, {
43
+ command: 'sh',
44
+ cols: 80,
45
+ rows: 24
46
+ });
47
+ session.onOutput((bytes) => terminal.write(bytes));
48
+ ```
49
+
50
+ Servers that keep sessions across requests use
51
+ `@vibesdotdev/terminal-client/server/session-store` (ownership, backlog,
52
+ detach-vs-kill, idle cleanup) and browsers attach over HTTP with
53
+ `openHttpSession(runtime, options)` from
54
+ `@vibesdotdev/terminal-client/client/http-session`. Agents drive shells
55
+ through the `terminal` tool (`execute`, `spawn`, interactive `session`).
56
+
57
+ ## Entrypoints
58
+
59
+ - `@vibesdotdev/terminal-client` — `openLocalSession`, `openRemoteSession`
60
+ - `@vibesdotdev/terminal-client/api-client-plugin` — portable semantic owner
61
+ - `@vibesdotdev/terminal-client/plugin`, `./consumer-plugin` — consumer tool composition
62
+ - `@vibesdotdev/terminal-client/client` — session composition helpers
63
+ - `@vibesdotdev/terminal-client/workspace` — rune-free workspace lifecycle, place, and receipt contracts
64
+ - `@vibesdotdev/terminal-client/server/session-store` — server store + SSE helpers
65
+ - `@vibesdotdev/terminal-client/client/http-session` — browser HTTP adapter
66
+ - `@vibesdotdev/terminal-client/pty-bridge` — compatibility names for the runtime PTY wire contract
67
+ - `@vibesdotdev/terminal-client/pty-bridge/server` — compatibility delegation to the Bun host
68
+ - `@vibesdotdev/terminal-client/ansi` — key-chord to byte-sequence map
69
+ - `@vibesdotdev/terminal-client/tui` — terminal launcher views and state
70
+ - `@vibesdotdev/terminal-client/tui/plugin` — launcher app, command, registry
71
+ - `@vibesdotdev/terminal-client/svelte` — xterm renderer and workspace
72
+ - `@vibesdotdev/terminal-client/svelte/workspace` — compatibility alias for the universal workspace contract
73
+ - `@vibesdotdev/terminal-client/svelte/plugin` — docs topic and tool card
74
+
75
+ ## Verify
76
+
77
+ From the repository root, run `bun run --cwd repos/platform/framework/terminal-client check`,
78
+ then `test` and `build` with the same prefix. Check includes every TypeScript/TSX
79
+ test and Svelte-adjacent source. Build emits production code only.
80
+ The test script includes the real loopback PTY-to-headless-xterm proof: computed
81
+ shell output must paint into xterm, and the shell must exit cleanly within runtime
82
+ lifecycle deadlines. Session completion waits for remote connection cleanup.
83
+ The proof also observes attached and never-attached PTYs terminate on caller
84
+ disposal while the receiving host remains alive.
85
+
86
+ Session, HTTP, store and tool options are owned by `src/schemas/`; existing helper
87
+ exports remain compatible. `OpenTerminalOptionsSchema` and
88
+ `SessionOpenOptionsSchema` are identical, including the schema exported by the
89
+ server store subpath. HTTP reconnect defaults and store limits are declared in
90
+ those schemas; reconnect callbacks and extra HTTP open-body fields are preserved.
91
+
92
+ ## Documentation
93
+
94
+ - Contract: [SPEC.md](SPEC.md)
95
+ - Svelte surface: [src/svelte/SPEC.md](src/svelte/SPEC.md)
96
+ - PTY bridge: [src/pty-bridge/SPEC.md](src/pty-bridge/SPEC.md)
97
+ - Key map: [src/ansi/SPEC.md](src/ansi/SPEC.md)
98
+ - Package guide: https://docs.vibes.dev/terminal-client
99
+ - Vibes docs: https://docs.vibes.dev
100
+
101
+ ## License
102
+
103
+ Business Source License 1.1 (BUSL-1.1). See [LICENSE](LICENSE) for the terms.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @vibesdotdev/terminal-client/ansi
3
+ *
4
+ * The one genuinely reusable piece mined out of the desktop terminal driver:
5
+ * the key-name → terminal-byte-sequence map. Zero runtime deps. The 857-line
6
+ * ANSI/CSI parser in `desktop` is NOT carried — xterm.js owns parsing.
7
+ *
8
+ * This package registers no runtime kinds; it is pure logic.
9
+ */
10
+ export { chordToSequence, resolveSequence, SPECIAL_KEYS, type KeyChord } from './keymap.ts';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ansi/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACN,eAAe,EACf,eAAe,EACf,YAAY,EACZ,KAAK,QAAQ,EACb,MAAM,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @vibesdotdev/terminal-client/ansi
3
+ *
4
+ * The one genuinely reusable piece mined out of the desktop terminal driver:
5
+ * the key-name → terminal-byte-sequence map. Zero runtime deps. The 857-line
6
+ * ANSI/CSI parser in `desktop` is NOT carried — xterm.js owns parsing.
7
+ *
8
+ * This package registers no runtime kinds; it is pure logic.
9
+ */
10
+ export { chordToSequence, resolveSequence, SPECIAL_KEYS } from "./keymap.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ansi/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACN,eAAe,EACf,eAAe,EACf,YAAY,EAEZ,MAAM,aAAa,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * keymap — the key-name → terminal-byte-sequence map.
3
+ *
4
+ * Extracted and hardened from
5
+ * `desktop/src/runtime/terminal.ts:keyToSequence` (lines 569-642),
6
+ * the one genuinely reusable piece of the desktop terminal driver. The 857-line
7
+ * ANSI/CSI *parser* in that file is deliberately NOT extracted — xterm.js owns
8
+ * parsing in the browser; copying the parser would re-import the exact wheel
9
+ * xterm already turns correctly. Only the byte-sequence map moves here (the
10
+ * thing xterm does NOT hand us for free: byte sequences for non-printing keys).
11
+ *
12
+ * Zero runtime deps. Consumed by `@vibesdotdev/terminal-client/svelte` (browser keydown
13
+ * → bytes) and re-exportable for `@vibesdotdev/test-tui`'s headless input helpers
14
+ * (eventually replacing its `ansi-input.ts` constant duplication).
15
+ */
16
+ /**
17
+ * A key chord, named the way `KeyboardEvent.key` + modifier booleans express it
18
+ * in the browser (e.g. `{ key: 'ArrowUp' }`, `{ key: 'c', ctrl: true }`,
19
+ * `{ key: 'x', alt: true }`). Casing of `key` is normalized internally, so both
20
+ * `'ArrowUp'` and `'up'` resolve.
21
+ */
22
+ export interface KeyChord {
23
+ /** `'a'` | `'Enter'` | `'ArrowUp'` | `'F5'` | `'Home'` | … (KeyboardEvent.key). */
24
+ key: string;
25
+ ctrl?: boolean;
26
+ alt?: boolean;
27
+ shift?: boolean;
28
+ /** Meta/Super key (Cmd on macOS, Win on Windows). */
29
+ meta?: boolean;
30
+ }
31
+ /**
32
+ * The special-key table — arrows, F-keys, home/end/pageup/down/insert/delete,
33
+ * enter/tab/escape/backspace/space. Keys are the lowercased short names the
34
+ * desktop driver used (`up`/`f1`/`home`/…); the resolver also maps the browser's
35
+ * `KeyboardEvent.key` long-names (`ArrowUp`/`F1`/`Home`/…) onto these.
36
+ *
37
+ * Verbatim byte sequences from the desktop `keyToSequence` table.
38
+ */
39
+ export declare const SPECIAL_KEYS: Readonly<Record<string, string>>;
40
+ /**
41
+ * Resolve the *raw* byte sequence for a chord, regardless of whether xterm.js
42
+ * would also handle it. Always returns a string. Use this when you own the input
43
+ * path end-to-end (e.g. test harnesses, the desktop driver). For the browser
44
+ * surface that lets xterm handle most keys, use {@link chordToSequence}.
45
+ *
46
+ * Modifier handling:
47
+ * - Ctrl on a single printable char → its control character (Ctrl-A = 0x01,
48
+ * Ctrl-C = 0x03, Ctrl-D = 0x04, Ctrl-L = 0x0c, Ctrl-Z = 0x1a, …).
49
+ * - Alt → ESC-prefix the resulting sequence.
50
+ * - Shift + special key → xterm/DEC modifier parameter encoding:
51
+ * - CSI arrows/Home/End: ESC [ 1 ; mod <letter>
52
+ * - Tilde-family: ESC [ N ; mod ~
53
+ * - SS3 F1-F4: ESC [ 1 ; mod <letter> (converted from SS3)
54
+ * - Shift on a printable char is consumed by the key's own case.
55
+ */
56
+ export declare function resolveSequence(chord: KeyChord): string;
57
+ /**
58
+ * Map a key chord to the terminal byte sequence for the **browser** surface.
59
+ * Returns `null` for chords xterm.js already encodes natively (so the component
60
+ * lets xterm handle them) — only the gaps come back as a string:
61
+ * - F1–F12 (xterm does not emit these by default),
62
+ * - Modified special keys (shift/ctrl + arrows/Home/End/F-keys/Delete/…),
63
+ * - Alt-<key> meta sequences,
64
+ * - Ctrl-<letter> control chars,
65
+ * - the `space` alias when explicitly modified.
66
+ *
67
+ * Returns `null` (never sends to PTY) for clipboard chords:
68
+ * - Ctrl+V, Cmd+V, Ctrl+Shift+V (paste),
69
+ * - Cmd+C, Ctrl+Shift+C (copy),
70
+ * - Ctrl+Shift+X (cut).
71
+ *
72
+ * IMPORTANT: plain Ctrl+C still returns 0x03 (SIGINT).
73
+ *
74
+ * A plain printable key with no modifier returns `null` (xterm types it itself).
75
+ */
76
+ export declare function chordToSequence(chord: KeyChord): string | null;
77
+ //# sourceMappingURL=keymap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keymap.d.ts","sourceRoot":"","sources":["../../src/ansi/keymap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACxB,mFAAmF;IACnF,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BxD,CAAC;AAwDH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CA0DvD;AAwBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAsC9D"}
@@ -0,0 +1,257 @@
1
+ /**
2
+ * keymap — the key-name → terminal-byte-sequence map.
3
+ *
4
+ * Extracted and hardened from
5
+ * `desktop/src/runtime/terminal.ts:keyToSequence` (lines 569-642),
6
+ * the one genuinely reusable piece of the desktop terminal driver. The 857-line
7
+ * ANSI/CSI *parser* in that file is deliberately NOT extracted — xterm.js owns
8
+ * parsing in the browser; copying the parser would re-import the exact wheel
9
+ * xterm already turns correctly. Only the byte-sequence map moves here (the
10
+ * thing xterm does NOT hand us for free: byte sequences for non-printing keys).
11
+ *
12
+ * Zero runtime deps. Consumed by `@vibesdotdev/terminal-client/svelte` (browser keydown
13
+ * → bytes) and re-exportable for `@vibesdotdev/test-tui`'s headless input helpers
14
+ * (eventually replacing its `ansi-input.ts` constant duplication).
15
+ */
16
+ /**
17
+ * The special-key table — arrows, F-keys, home/end/pageup/down/insert/delete,
18
+ * enter/tab/escape/backspace/space. Keys are the lowercased short names the
19
+ * desktop driver used (`up`/`f1`/`home`/…); the resolver also maps the browser's
20
+ * `KeyboardEvent.key` long-names (`ArrowUp`/`F1`/`Home`/…) onto these.
21
+ *
22
+ * Verbatim byte sequences from the desktop `keyToSequence` table.
23
+ */
24
+ export const SPECIAL_KEYS = Object.freeze({
25
+ return: '\r',
26
+ enter: '\r',
27
+ tab: '\t',
28
+ escape: '\x1b',
29
+ esc: '\x1b',
30
+ backspace: '\x7f',
31
+ delete: '\x1b[3~',
32
+ up: '\x1b[A',
33
+ down: '\x1b[B',
34
+ right: '\x1b[C',
35
+ left: '\x1b[D',
36
+ home: '\x1b[H',
37
+ end: '\x1b[F',
38
+ pageup: '\x1b[5~',
39
+ pagedown: '\x1b[6~',
40
+ insert: '\x1b[2~',
41
+ f1: '\x1bOP',
42
+ f2: '\x1bOQ',
43
+ f3: '\x1bOR',
44
+ f4: '\x1bOS',
45
+ f5: '\x1b[15~',
46
+ f6: '\x1b[17~',
47
+ f7: '\x1b[18~',
48
+ f8: '\x1b[19~',
49
+ f9: '\x1b[20~',
50
+ f10: '\x1b[21~',
51
+ f11: '\x1b[23~',
52
+ f12: '\x1b[24~',
53
+ space: ' '
54
+ });
55
+ /**
56
+ * Browser `KeyboardEvent.key` long-names → the short names used by SPECIAL_KEYS.
57
+ * Lets a raw `KeyboardEvent` flow straight in: `{ key: 'ArrowUp' }`,
58
+ * `{ key: 'PageUp' }`, `{ key: 'F5' }`, `{ key: ' ' }` all resolve.
59
+ */
60
+ const KEY_ALIASES = Object.freeze({
61
+ arrowup: 'up',
62
+ arrowdown: 'down',
63
+ arrowright: 'right',
64
+ arrowleft: 'left',
65
+ pageup: 'pageup',
66
+ pagedown: 'pagedown',
67
+ ' ': 'space',
68
+ spacebar: 'space',
69
+ del: 'delete'
70
+ });
71
+ /** Keys xterm.js already encodes correctly on its own — let them through. */
72
+ const XTERM_NATIVE_KEYS = new Set([
73
+ 'enter',
74
+ 'return',
75
+ 'tab',
76
+ 'backspace',
77
+ 'escape',
78
+ 'esc',
79
+ 'up',
80
+ 'down',
81
+ 'left',
82
+ 'right',
83
+ 'home',
84
+ 'end',
85
+ 'pageup',
86
+ 'pagedown',
87
+ 'insert',
88
+ 'delete'
89
+ ]);
90
+ function normalizeKeyName(key) {
91
+ const lower = key.toLowerCase();
92
+ return KEY_ALIASES[lower] ?? lower;
93
+ }
94
+ /**
95
+ * Compute the xterm/DEC modifier parameter for a chord's modifier keys.
96
+ * Returns undefined when no modifiers are active (avoids injecting ";1" which
97
+ * is technically valid but not emitted by real terminals).
98
+ *
99
+ * mod = 1 + (shift?1:0) + (alt?2:0) + (ctrl?4:0)
100
+ */
101
+ function modParam(chord) {
102
+ const mod = 1 + (chord.shift ? 1 : 0) + (chord.alt ? 2 : 0) + (chord.ctrl ? 4 : 0);
103
+ return mod === 1 ? undefined : mod;
104
+ }
105
+ /**
106
+ * Resolve the *raw* byte sequence for a chord, regardless of whether xterm.js
107
+ * would also handle it. Always returns a string. Use this when you own the input
108
+ * path end-to-end (e.g. test harnesses, the desktop driver). For the browser
109
+ * surface that lets xterm handle most keys, use {@link chordToSequence}.
110
+ *
111
+ * Modifier handling:
112
+ * - Ctrl on a single printable char → its control character (Ctrl-A = 0x01,
113
+ * Ctrl-C = 0x03, Ctrl-D = 0x04, Ctrl-L = 0x0c, Ctrl-Z = 0x1a, …).
114
+ * - Alt → ESC-prefix the resulting sequence.
115
+ * - Shift + special key → xterm/DEC modifier parameter encoding:
116
+ * - CSI arrows/Home/End: ESC [ 1 ; mod <letter>
117
+ * - Tilde-family: ESC [ N ; mod ~
118
+ * - SS3 F1-F4: ESC [ 1 ; mod <letter> (converted from SS3)
119
+ * - Shift on a printable char is consumed by the key's own case.
120
+ */
121
+ export function resolveSequence(chord) {
122
+ const name = normalizeKeyName(chord.key);
123
+ // Special (non-printing) keys map to a fixed escape sequence; printable keys
124
+ // pass through as their own character.
125
+ let sequence = SPECIAL_KEYS[name] ?? chord.key;
126
+ // Modifier parameter encoding for special (escape sequence) keys.
127
+ // Only applies when shift/alt/ctrl are used on a non-printing key, and only
128
+ // when we have a recognizable CSI/SS3 sequence to transform.
129
+ const isSpecial = name in SPECIAL_KEYS;
130
+ if (isSpecial && (chord.shift || chord.ctrl)) {
131
+ const mod = modParam(chord);
132
+ if (mod !== undefined) {
133
+ // SS3 form F1-F4: ESC O P/Q/R/S → CSI 1 ; mod P/Q/R/S
134
+ const ss3Letter = sequence.startsWith('\x1bO') && sequence.length === 3 ? sequence[2] : undefined;
135
+ if (ss3Letter && /^[A-Z]$/.test(ss3Letter)) {
136
+ sequence = `\x1b[1;${mod}${ss3Letter}`;
137
+ }
138
+ // Tilde-family (F5-F12, Insert, Delete, PgUp, PgDn):
139
+ // ESC [ N ~ → ESC [ N ; mod ~
140
+ const tildeDigits = sequence.startsWith('\x1b[') && sequence.endsWith('~')
141
+ ? sequence.slice(2, -1)
142
+ : '';
143
+ if (/^\d+$/.test(tildeDigits)) {
144
+ sequence = `\x1b[${tildeDigits};${mod}~`;
145
+ }
146
+ // CSI letter form (arrows, Home, End): ESC [ <letter>
147
+ // → ESC [ 1 ; mod <letter>
148
+ const csiLetter = sequence.startsWith('\x1b[') && sequence.length === 3 ? sequence[2] : undefined;
149
+ if (csiLetter && /^[A-Za-z]$/.test(csiLetter)) {
150
+ sequence = `\x1b[1;${mod}${csiLetter}`;
151
+ }
152
+ }
153
+ }
154
+ // Ctrl modifier — convert a single printable char to its control character.
155
+ // (Only runs for non-special keys — special keys were handled above.)
156
+ if (chord.ctrl && !isSpecial && sequence.length === 1) {
157
+ const code = sequence.toUpperCase().charCodeAt(0);
158
+ if (code >= 64 && code <= 95) {
159
+ // @ A-Z [ \ ] ^ _ → 0x00–0x1F (Ctrl-@ = NUL, Ctrl-A = 0x01, …).
160
+ sequence = String.fromCharCode(code - 64);
161
+ }
162
+ else {
163
+ const lowerKey = chord.key.toLowerCase();
164
+ if (lowerKey === 'c')
165
+ sequence = '\x03';
166
+ else if (lowerKey === 'd')
167
+ sequence = '\x04';
168
+ else if (lowerKey === 'z')
169
+ sequence = '\x1a';
170
+ else if (lowerKey === 'l')
171
+ sequence = '\x0c';
172
+ }
173
+ }
174
+ // Alt modifier — prepend ESC (meta).
175
+ if (chord.alt) {
176
+ sequence = `\x1b${sequence}`;
177
+ }
178
+ return sequence;
179
+ }
180
+ /**
181
+ * Browser-clipboard chords that must NOT be sent to the PTY. The browser's
182
+ * native copy/paste handling fires *before* the keydown handler; sending a PTY
183
+ * sequence would prefix the pasted content with the quoted-insert byte (0x16)
184
+ * or duplicate a Ctrl-C SIGINT when the user is just copying text.
185
+ *
186
+ * Plain Ctrl-C is NOT in this set — it is still SIGINT (0x03).
187
+ */
188
+ function isClipboardChord(chord) {
189
+ const key = chord.key.toLowerCase();
190
+ // Ctrl+V / Cmd+V / Ctrl+Shift+V — paste
191
+ if (key === 'v' && (chord.ctrl || chord.meta))
192
+ return true;
193
+ // Ctrl+Shift+C / Cmd+C — copy (Cmd+C is the primary macOS copy chord)
194
+ if (key === 'c' && chord.meta)
195
+ return true;
196
+ if (key === 'c' && chord.ctrl && chord.shift)
197
+ return true;
198
+ // Ctrl+Shift+X — cut
199
+ if (key === 'x' && chord.ctrl && chord.shift)
200
+ return true;
201
+ return false;
202
+ }
203
+ /**
204
+ * Map a key chord to the terminal byte sequence for the **browser** surface.
205
+ * Returns `null` for chords xterm.js already encodes natively (so the component
206
+ * lets xterm handle them) — only the gaps come back as a string:
207
+ * - F1–F12 (xterm does not emit these by default),
208
+ * - Modified special keys (shift/ctrl + arrows/Home/End/F-keys/Delete/…),
209
+ * - Alt-<key> meta sequences,
210
+ * - Ctrl-<letter> control chars,
211
+ * - the `space` alias when explicitly modified.
212
+ *
213
+ * Returns `null` (never sends to PTY) for clipboard chords:
214
+ * - Ctrl+V, Cmd+V, Ctrl+Shift+V (paste),
215
+ * - Cmd+C, Ctrl+Shift+C (copy),
216
+ * - Ctrl+Shift+X (cut).
217
+ *
218
+ * IMPORTANT: plain Ctrl+C still returns 0x03 (SIGINT).
219
+ *
220
+ * A plain printable key with no modifier returns `null` (xterm types it itself).
221
+ */
222
+ export function chordToSequence(chord) {
223
+ const name = normalizeKeyName(chord.key);
224
+ // Clipboard chords must never reach the PTY.
225
+ if (isClipboardChord(chord))
226
+ return null;
227
+ // F-keys: xterm does not emit these by default — always supply the sequence.
228
+ // Also handles modified F-keys (shift+F1, ctrl+F5, etc.) via resolveSequence.
229
+ if (/^f([1-9]|1[0-2])$/.test(name)) {
230
+ const seq = resolveSequence(chord);
231
+ return seq.length > 0 ? seq : null;
232
+ }
233
+ // Alt always needs the ESC-prefix that xterm's default handler won't add.
234
+ if (chord.alt) {
235
+ return resolveSequence(chord);
236
+ }
237
+ // Shift or Ctrl on a native special key → modifier-parameter encoding.
238
+ // resolveSequence handles the ESC [ 1 ; mod <letter> / ESC [ N ; mod ~ forms.
239
+ if ((chord.shift || chord.ctrl) && XTERM_NATIVE_KEYS.has(name)) {
240
+ return resolveSequence(chord);
241
+ }
242
+ // Ctrl + a single printable letter → control char xterm may not produce.
243
+ if (chord.ctrl) {
244
+ const seq = resolveSequence(chord);
245
+ // Only override when we actually produced a control char (length 1, < 0x20)
246
+ // or a special-key sequence; otherwise let xterm decide.
247
+ if (seq.length === 1 && seq.charCodeAt(0) < 0x20)
248
+ return seq;
249
+ return null;
250
+ }
251
+ // Unmodified special keys xterm already handles — let it through.
252
+ if (XTERM_NATIVE_KEYS.has(name))
253
+ return null;
254
+ // Everything else (plain printable) — xterm types it; nothing to inject.
255
+ return null;
256
+ }
257
+ //# sourceMappingURL=keymap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keymap.js","sourceRoot":"","sources":["../../src/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kEAAkE;IAClE,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7C,yEAAyE;IACzE,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Portable semantic client slice: no tool, TUI or host adapter loaders. */
2
+ declare const terminalClientPlugin: import("@vibesdotdev/kernel").RuntimePlugin;
3
+ export default terminalClientPlugin;
4
+ //# sourceMappingURL=api-client-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client-plugin.d.ts","sourceRoot":"","sources":["../src/api-client-plugin.ts"],"names":[],"mappings":"AAIA,4EAA4E;AAC5E,QAAA,MAAM,oBAAoB,6CAUxB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { createRuntimePlugin, loader } from '@vibesdotdev/kernel';
2
+ import { runtimeClientKind } from '@vibesdotdev/kernel/client';
3
+ /** Portable semantic client slice: no tool, TUI or host adapter loaders. */
4
+ const terminalClientPlugin = createRuntimePlugin({
5
+ id: 'terminal-client.api',
6
+ kinds: [runtimeClientKind],
7
+ descriptors: [{ kind: 'runtime/client', id: 'terminal', description: 'Terminal session and process custody' }],
8
+ loaders: [loader('terminal', { kind: 'runtime/client' }, () => import("./terminal-runtime.js"))],
9
+ async onDispose(runtime) {
10
+ // tryGetVibesClient intentionally refuses aborted runtimes. Teardown peeks the
11
+ // kernel cache while registration is still live; it never activates a client.
12
+ await runtime.query('runtime/client').withId('terminal').peek?.()?.dispose();
13
+ }
14
+ });
15
+ export default terminalClientPlugin;
16
+ //# sourceMappingURL=api-client-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client-plugin.js","sourceRoot":"","sources":["../src/api-client-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,4EAA4E;AAC5E,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;IAChD,EAAE,EAAE,qBAAqB;IACzB,KAAK,EAAE,CAAC,iBAAiB,CAAC;IAC1B,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;IAC9G,OAAO,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAChG,KAAK,CAAC,SAAS,CAAC,OAAO;QACtB,+EAA+E;QAC/E,8EAA8E;QAC9E,MAAM,OAAO,CAAC,KAAK,CAAwB,gBAAgB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;IACrG,CAAC;CACD,CAAC,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @vibesdotdev/terminal-client/client/http-session — browser ExecutionSession adapter.
3
+ *
4
+ * Implements the L3 `ExecutionSession` interface against the `/api/session/**`
5
+ * bridge endpoints. Works for BOTH remote fleet sessions (hq-web) and local PTY
6
+ * sessions (consumer-hq): both surfaces use the identical wire format.
7
+ *
8
+ * - `onOutput` ← Server-Sent Events from `GET /api/session/{id}/output`
9
+ * - `write`/`resize`/`signal`/`kill` → `POST /api/session/{id}/{verb}`
10
+ * - `exited()` ← resolves when the SSE stream signals exit (or the channel ends)
11
+ *
12
+ * ### Auto-reconnect
13
+ *
14
+ * When the EventSource drops (network blip, server restart), the adapter retries
15
+ * transparently with jittered exponential backoff. Callers get `onReconnecting` /
16
+ * `onReconnected` hooks to show a UI banner. The same server-side backlog ring
17
+ * replays missed output on re-attach. A clean exit from the session (the server
18
+ * sends `event: exit`) is NOT retried — it resolves `exited()` normally.
19
+ *
20
+ * `<Terminal>` doesn't care which transport backs the session — it only ever sees
21
+ * an `ExecutionSession`. The SSE-error → `exited()`-reject path maps to the
22
+ * component's `onDisconnect` banner once retries are exhausted.
23
+ *
24
+ * BROWSER-ONLY. Depends on `fetch` and `EventSource` (both available in browsers
25
+ * and in Bun).
26
+ */
27
+ import { type VibesRuntime } from '@vibesdotdev/kernel';
28
+ import type { ExecutionSession } from '../client.ts';
29
+ export { type ReconnectOptions, type OpenHttpSessionOptions } from '../schemas/http.ts';
30
+ import { type OpenHttpSessionOptions } from '../schemas/http.ts';
31
+ export interface OpenedHttpSession {
32
+ session: ExecutionSession;
33
+ id: string;
34
+ environmentId: string;
35
+ }
36
+ /**
37
+ * Open a terminal session over HTTP and return a browser `ExecutionSession` bound
38
+ * to it. Call from `onMount` (uses `EventSource` / `fetch`).
39
+ *
40
+ * Returns `{ session, id, environmentId }` so callers can inspect metadata if
41
+ * needed; the `session` is ready to pass to `<Terminal session={session} />`.
42
+ */
43
+ export declare function openHttpSession(runtime: VibesRuntime, input: OpenHttpSessionOptions): Promise<OpenedHttpSession>;
44
+ //# sourceMappingURL=http-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-session.d.ts","sourceRoot":"","sources":["../../src/client/http-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAoErD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EACqD,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAcpH,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACpC,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,sBAAsB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAa5B"}