@the-librarian/cli 1.0.0-rc.21

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 (155) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +94 -0
  3. package/dist/bin.d.ts +3 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +15 -0
  6. package/dist/bin.js.map +1 -0
  7. package/dist/commands/install.d.ts +28 -0
  8. package/dist/commands/install.d.ts.map +1 -0
  9. package/dist/commands/install.js +204 -0
  10. package/dist/commands/install.js.map +1 -0
  11. package/dist/commands/shared.d.ts +16 -0
  12. package/dist/commands/shared.d.ts.map +1 -0
  13. package/dist/commands/shared.js +30 -0
  14. package/dist/commands/shared.js.map +1 -0
  15. package/dist/commands/uninstall.d.ts +18 -0
  16. package/dist/commands/uninstall.d.ts.map +1 -0
  17. package/dist/commands/uninstall.js +67 -0
  18. package/dist/commands/uninstall.js.map +1 -0
  19. package/dist/commands/update.d.ts +21 -0
  20. package/dist/commands/update.d.ts.map +1 -0
  21. package/dist/commands/update.js +75 -0
  22. package/dist/commands/update.js.map +1 -0
  23. package/dist/config.d.ts +40 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +65 -0
  26. package/dist/config.js.map +1 -0
  27. package/dist/doctor.d.ts +23 -0
  28. package/dist/doctor.d.ts.map +1 -0
  29. package/dist/doctor.js +81 -0
  30. package/dist/doctor.js.map +1 -0
  31. package/dist/env.d.ts +39 -0
  32. package/dist/env.d.ts.map +1 -0
  33. package/dist/env.js +208 -0
  34. package/dist/env.js.map +1 -0
  35. package/dist/exec.d.ts +37 -0
  36. package/dist/exec.d.ts.map +1 -0
  37. package/dist/exec.js +81 -0
  38. package/dist/exec.js.map +1 -0
  39. package/dist/harnesses/claude.d.ts +3 -0
  40. package/dist/harnesses/claude.d.ts.map +1 -0
  41. package/dist/harnesses/claude.js +88 -0
  42. package/dist/harnesses/claude.js.map +1 -0
  43. package/dist/harnesses/cli.d.ts +4 -0
  44. package/dist/harnesses/cli.d.ts.map +1 -0
  45. package/dist/harnesses/cli.js +16 -0
  46. package/dist/harnesses/cli.js.map +1 -0
  47. package/dist/harnesses/codex.d.ts +3 -0
  48. package/dist/harnesses/codex.d.ts.map +1 -0
  49. package/dist/harnesses/codex.js +183 -0
  50. package/dist/harnesses/codex.js.map +1 -0
  51. package/dist/harnesses/hermes.d.ts +16 -0
  52. package/dist/harnesses/hermes.d.ts.map +1 -0
  53. package/dist/harnesses/hermes.js +158 -0
  54. package/dist/harnesses/hermes.js.map +1 -0
  55. package/dist/harnesses/index.d.ts +12 -0
  56. package/dist/harnesses/index.d.ts.map +1 -0
  57. package/dist/harnesses/index.js +29 -0
  58. package/dist/harnesses/index.js.map +1 -0
  59. package/dist/harnesses/opencode.d.ts +3 -0
  60. package/dist/harnesses/opencode.d.ts.map +1 -0
  61. package/dist/harnesses/opencode.js +141 -0
  62. package/dist/harnesses/opencode.js.map +1 -0
  63. package/dist/harnesses/pi.d.ts +3 -0
  64. package/dist/harnesses/pi.d.ts.map +1 -0
  65. package/dist/harnesses/pi.js +72 -0
  66. package/dist/harnesses/pi.js.map +1 -0
  67. package/dist/harnesses/types.d.ts +48 -0
  68. package/dist/harnesses/types.d.ts.map +1 -0
  69. package/dist/harnesses/types.js +22 -0
  70. package/dist/harnesses/types.js.map +1 -0
  71. package/dist/index.d.ts +11 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +15 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/machine.d.ts +10 -0
  76. package/dist/machine.d.ts.map +1 -0
  77. package/dist/machine.js +39 -0
  78. package/dist/machine.js.map +1 -0
  79. package/dist/parse-args.d.ts +12 -0
  80. package/dist/parse-args.d.ts.map +1 -0
  81. package/dist/parse-args.js +54 -0
  82. package/dist/parse-args.js.map +1 -0
  83. package/dist/paths.d.ts +32 -0
  84. package/dist/paths.d.ts.map +1 -0
  85. package/dist/paths.js +75 -0
  86. package/dist/paths.js.map +1 -0
  87. package/dist/prompt.d.ts +53 -0
  88. package/dist/prompt.d.ts.map +1 -0
  89. package/dist/prompt.js +165 -0
  90. package/dist/prompt.js.map +1 -0
  91. package/dist/runtime.d.ts +45 -0
  92. package/dist/runtime.d.ts.map +1 -0
  93. package/dist/runtime.js +370 -0
  94. package/dist/runtime.js.map +1 -0
  95. package/dist/semver.d.ts +13 -0
  96. package/dist/semver.d.ts.map +1 -0
  97. package/dist/semver.js +98 -0
  98. package/dist/semver.js.map +1 -0
  99. package/dist/server/admin.d.ts +31 -0
  100. package/dist/server/admin.d.ts.map +1 -0
  101. package/dist/server/admin.js +110 -0
  102. package/dist/server/admin.js.map +1 -0
  103. package/dist/server/boot.d.ts +51 -0
  104. package/dist/server/boot.d.ts.map +1 -0
  105. package/dist/server/boot.js +233 -0
  106. package/dist/server/boot.js.map +1 -0
  107. package/dist/server/deploy-state.d.ts +33 -0
  108. package/dist/server/deploy-state.d.ts.map +1 -0
  109. package/dist/server/deploy-state.js +79 -0
  110. package/dist/server/deploy-state.js.map +1 -0
  111. package/dist/server/docker.d.ts +37 -0
  112. package/dist/server/docker.d.ts.map +1 -0
  113. package/dist/server/docker.js +138 -0
  114. package/dist/server/docker.js.map +1 -0
  115. package/dist/server/down.d.ts +19 -0
  116. package/dist/server/down.d.ts.map +1 -0
  117. package/dist/server/down.js +62 -0
  118. package/dist/server/down.js.map +1 -0
  119. package/dist/server/index.d.ts +8 -0
  120. package/dist/server/index.d.ts.map +1 -0
  121. package/dist/server/index.js +48 -0
  122. package/dist/server/index.js.map +1 -0
  123. package/dist/server/logs.d.ts +50 -0
  124. package/dist/server/logs.d.ts.map +1 -0
  125. package/dist/server/logs.js +162 -0
  126. package/dist/server/logs.js.map +1 -0
  127. package/dist/server/preflight.d.ts +24 -0
  128. package/dist/server/preflight.d.ts.map +1 -0
  129. package/dist/server/preflight.js +58 -0
  130. package/dist/server/preflight.js.map +1 -0
  131. package/dist/server/redact.d.ts +2 -0
  132. package/dist/server/redact.d.ts.map +1 -0
  133. package/dist/server/redact.js +26 -0
  134. package/dist/server/redact.js.map +1 -0
  135. package/dist/server/status.d.ts +20 -0
  136. package/dist/server/status.d.ts.map +1 -0
  137. package/dist/server/status.js +103 -0
  138. package/dist/server/status.js.map +1 -0
  139. package/dist/server/up.d.ts +211 -0
  140. package/dist/server/up.d.ts.map +1 -0
  141. package/dist/server/up.js +625 -0
  142. package/dist/server/up.js.map +1 -0
  143. package/dist/server/update.d.ts +35 -0
  144. package/dist/server/update.d.ts.map +1 -0
  145. package/dist/server/update.js +308 -0
  146. package/dist/server/update.js.map +1 -0
  147. package/dist/status.d.ts +18 -0
  148. package/dist/status.d.ts.map +1 -0
  149. package/dist/status.js +113 -0
  150. package/dist/status.js.map +1 -0
  151. package/dist/version.d.ts +2 -0
  152. package/dist/version.d.ts.map +1 -0
  153. package/dist/version.js +20 -0
  154. package/dist/version.js.map +1 -0
  155. package/package.json +36 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # `@the-librarian/cli` — the `librarian` installer
2
+
3
+ A small cross-harness CLI that installs, updates, and tracks
4
+ [The Librarian](https://github.com/JimJafar/the-librarian)'s integrations across
5
+ all your harnesses and machines. Think of it as the package manager for your
6
+ Librarian setup: one tool you keep, driving each harness's **native** install
7
+ path rather than hand-editing five config formats.
8
+
9
+ Harnesses it manages: **Claude Code, Codex, OpenCode, Hermes, Pi.**
10
+
11
+ ## Install
12
+
13
+ Install the CLI globally, then run the interactive setup:
14
+
15
+ ```sh
16
+ npm i -g @the-librarian/cli
17
+ librarian install
18
+ ```
19
+
20
+ That's it — any harness you'd install into already has Node, so there's no
21
+ bootstrap script. `librarian install` with no args opens the interactive
22
+ multi-select and prompts once for your MCP URL + token; pass harness ids to
23
+ target specific ones. Re-run it any time to add a harness.
24
+
25
+ ## Commands
26
+
27
+ ```
28
+ librarian install [harness…] Install into one or more harnesses
29
+ (no args → interactive multi-select; prompts
30
+ for MCP URL + token once)
31
+ librarian uninstall [harness…] Remove The Librarian from each harness
32
+ librarian update [harness…] Update the integration to the current version
33
+ librarian status Live table: harness · installed · version
34
+ librarian doctor Token set? server reachable? which harness CLIs?
35
+ librarian config Show or set MCP URL, token, server URL
36
+ librarian self-update Update the CLI itself (coming in a later release)
37
+ librarian report Push this machine's state to the server
38
+ (coming in a later release)
39
+ ```
40
+
41
+ Useful flags: `--mcp-url <url>`, `--token <token>` (never printed),
42
+ `--shell <bash|zsh|fish>` to override shell detection, `-h/--help`,
43
+ `-v/--version`. Harness ids: `claude`, `codex`, `opencode`, `hermes`, `pi`. A
44
+ harness whose CLI isn't installed is reported `not-detected` and skipped — not
45
+ an error.
46
+
47
+ ## What it writes to your environment
48
+
49
+ The CLI keeps everything under `~/.librarian/`:
50
+
51
+ - **`~/.librarian/env`** — a POSIX env file (`chmod 600`, owner-only) holding
52
+ your two secrets:
53
+
54
+ ```sh
55
+ export LIBRARIAN_MCP_URL="…"
56
+ export LIBRARIAN_AGENT_TOKEN="…"
57
+ ```
58
+
59
+ - **`~/.librarian/machine-id`** — a UUID generated on first run, so the same
60
+ setup on different machines stays distinct in the dashboard.
61
+
62
+ It adds **one** idempotent managed block to your shell rc (`~/.bashrc` /
63
+ `~/.zshrc`) that sources the env file:
64
+
65
+ ```sh
66
+ # >>> librarian >>>
67
+ [ -f "$HOME/.librarian/env" ] && . "$HOME/.librarian/env"
68
+ # <<< librarian <<<
69
+ ```
70
+
71
+ Fish can't source a POSIX file, so it instead gets a native
72
+ `~/.config/fish/conf.d/librarian.fish` with `set -gx`. Re-running any command
73
+ replaces the block — it never duplicates. `librarian config` rewrites
74
+ `~/.librarian/env`.
75
+
76
+ ## Security
77
+
78
+ Your agent token is a credential. The CLI treats it like one:
79
+
80
+ - It's written **only** to `~/.librarian/env`, which is `chmod 600`
81
+ (owner read/write only) — never to a committed or world-readable file.
82
+ - It is **never printed** (not in `status`, `doctor`, `config`, or logs) and
83
+ never put in a URL — bearer tokens travel in headers, to the configured
84
+ server, over the configured URL, and nowhere else.
85
+
86
+ If you ever need to rotate it, re-run `librarian config --token <new>` (or edit
87
+ `~/.librarian/env` directly).
88
+
89
+ > **Avoid `--token <value>` on a shared or audited machine.** A value passed on
90
+ > the command line is visible to anyone who can run `ps` while the command runs,
91
+ > and it lands in your shell history. Prefer entering the token at the
92
+ > interactive prompt — `librarian install` reads it with the echo **muted**, so
93
+ > it never appears on screen, in `ps`, or in history — or edit the `chmod 600`
94
+ > `~/.librarian/env` file directly.
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ // `librarian` CLI bin entrypoint.
3
+ //
4
+ // Runs the typed runtime over the caller's argv, prints the captured
5
+ // stdout/stderr, and translates the structured result into a process exit
6
+ // code. The runtime is pure over `{ home }`, so tests drive it directly
7
+ // without spawning this process.
8
+ import { runCli } from "./runtime.js";
9
+ const result = await runCli(process.argv.slice(2));
10
+ if (result.stdout)
11
+ console.log(result.stdout);
12
+ if (result.stderr)
13
+ console.error(result.stderr);
14
+ process.exitCode = result.exitCode || 0;
15
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,kCAAkC;AAClC,EAAE;AACF,qEAAqE;AACrE,0EAA0E;AAC1E,wEAAwE;AACxE,iCAAiC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,IAAI,MAAM,CAAC,MAAM;IAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC9C,IAAI,MAAM,CAAC,MAAM;IAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAChD,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Shell } from "../env.js";
2
+ import type { Prompter } from "../prompt.js";
3
+ export interface InstallDeps {
4
+ home?: string | undefined;
5
+ shell?: Shell | undefined;
6
+ prompter: Prompter;
7
+ /**
8
+ * The process environment to read existing `LIBRARIAN_*` vars from (BUG 2).
9
+ * Injectable so tests never read the real `process.env`. Defaults to
10
+ * `process.env`. The token value is never logged.
11
+ */
12
+ env?: NodeJS.ProcessEnv | undefined;
13
+ }
14
+ export interface InstallOutcome {
15
+ installed: string[];
16
+ skipped: {
17
+ id: string;
18
+ reason: string;
19
+ }[];
20
+ failed: {
21
+ id: string;
22
+ reason: string;
23
+ }[];
24
+ output: string;
25
+ }
26
+ /** Run the install orchestration over the (possibly empty) named harnesses. */
27
+ export declare function runInstall(named: string[], deps: InstallDeps): Promise<InstallOutcome>;
28
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAIvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,+EAA+E;AAC/E,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CA2D5F"}
@@ -0,0 +1,204 @@
1
+ // `librarian install [harness…]` orchestration.
2
+ //
3
+ // Flow:
4
+ // 1. Resolve config. If the MCP URL or token is unset, prompt for them
5
+ // (token is a SECRET prompt — never echoed) and persist via `setConfig`,
6
+ // which also (re)applies the managed shell block for the user's shell.
7
+ // 2. Choose harnesses: explicit args win; otherwise an interactive
8
+ // multi-select over the harnesses whose native CLI is on PATH (file-based
9
+ // harnesses always offered). Non-interactive falls back to all available.
10
+ // 3. For each chosen harness, run its native `install(cfg)`:
11
+ // - a "CLI not found" error → SKIP with a note (not a failure);
12
+ // - any OTHER error → attempt `uninstall()` to avoid a half-applied
13
+ // state (spec §9), record it failed, and continue.
14
+ // 4. Print a summary (installed / skipped / failed) + a restart hint.
15
+ import { deriveServerUrl, readConfig, setConfig } from "../config.js";
16
+ import { which } from "../exec.js";
17
+ import { HARNESS_CLI } from "../harnesses/cli.js";
18
+ import { allHarnesses, isHarnessId } from "../harnesses/index.js";
19
+ import { messageOf, toHarnessConfig } from "./shared.js";
20
+ /** Run the install orchestration over the (possibly empty) named harnesses. */
21
+ export async function runInstall(named, deps) {
22
+ const lines = [];
23
+ // 1) Resolve config in-memory, prompting for any missing secret/URL. We do
24
+ // NOT persist `~/.librarian/env` or rewrite the shell rc block yet — that
25
+ // is deferred until at least one harness install succeeds (S1), so a total
26
+ // failure leaves no global side effect. The harness installs consume the
27
+ // in-memory cfg, never the env file, so deferring is safe.
28
+ const { cfg, changed } = await resolveConfig(deps);
29
+ // 2) Choose harnesses.
30
+ const chosen = await chooseHarnesses(named, deps, lines);
31
+ if (chosen.length === 0) {
32
+ lines.push("No harnesses selected — nothing to do.");
33
+ return { installed: [], skipped: [], failed: [], output: lines.join("\n") };
34
+ }
35
+ // 3) Install each, with per-harness skip / rollback.
36
+ const harnessCfg = toHarnessConfig(cfg);
37
+ const installed = [];
38
+ const skipped = [];
39
+ const failed = [];
40
+ for (const harness of chosen) {
41
+ try {
42
+ await harness.install(harnessCfg);
43
+ installed.push(harness.id);
44
+ }
45
+ catch (error) {
46
+ const reason = messageOf(error);
47
+ if (isCliNotFound(reason)) {
48
+ skipped.push({ id: harness.id, reason });
49
+ continue;
50
+ }
51
+ // Mid-install failure → roll back so we don't leave a half-applied
52
+ // state (spec §9). Best-effort: a failed rollback is noted, not fatal.
53
+ let rollbackNote = "";
54
+ try {
55
+ await harness.uninstall();
56
+ rollbackNote = " (rolled back)";
57
+ }
58
+ catch (rollbackError) {
59
+ rollbackNote = ` (rollback also failed: ${messageOf(rollbackError)})`;
60
+ }
61
+ failed.push({ id: harness.id, reason: `${reason}${rollbackNote}` });
62
+ }
63
+ }
64
+ // 4) Now that at least one harness may have succeeded, persist the config
65
+ // (writes `~/.librarian/env` + the managed shell block). Deferred from
66
+ // step 1 so a run where EVERY harness failed leaves no global side effect
67
+ // (S1). Only persist when the values actually changed — keeps re-runs
68
+ // idempotent and quiet.
69
+ if (installed.length > 0 && changed) {
70
+ setConfig({ mcpUrl: cfg.mcpUrl, token: cfg.token }, { home: deps.home, shell: deps.shell });
71
+ lines.unshift("Saved config to ~/.librarian/env and updated the shell block.", "");
72
+ }
73
+ // 5) Summary + restart hint.
74
+ renderSummary(lines, { installed, skipped, failed });
75
+ return { installed, skipped, failed, output: lines.join("\n") };
76
+ }
77
+ /**
78
+ * Resolve the config to install with, prompting for whatever is missing.
79
+ * Returns the in-memory config and whether it differs from what's persisted
80
+ * (so the caller can defer the actual `setConfig` write until a harness
81
+ * install has succeeded — S1). Does NOT touch the filesystem.
82
+ *
83
+ * Source precedence (BUG 2 — reuse existing `LIBRARIAN_*`):
84
+ * 1. `~/.librarian/env` already has BOTH values → use them, no prompts.
85
+ * 2. Otherwise, consult `process.env` (injected as `deps.env`):
86
+ * - BOTH `LIBRARIAN_MCP_URL` + `LIBRARIAN_AGENT_TOKEN` present → offer
87
+ * to reuse them (URL shown in full, token redacted to
88
+ * `LIBRARIAN_AGENT_TOKEN=set` — the value is NEVER displayed). Accept
89
+ * → use them; decline → prompt for fresh values.
90
+ * - Only ONE present → prefill it as that prompt's default so the user
91
+ * can accept with enter; prompt for the other.
92
+ * - Neither → prompt for both (unchanged behaviour).
93
+ * The token value is never logged.
94
+ */
95
+ async function resolveConfig(deps) {
96
+ const existing = readConfig(deps.home);
97
+ const env = deps.env ?? process.env;
98
+ const envUrl = (env.LIBRARIAN_MCP_URL ?? "").trim();
99
+ const envToken = (env.LIBRARIAN_AGENT_TOKEN ?? "").trim();
100
+ let mcpUrl = existing?.mcpUrl ?? "";
101
+ let token = existing?.token ?? "";
102
+ // When both env vars are present we offer to reuse them as a pair; if the
103
+ // user DECLINES we prompt for fresh values WITHOUT prefilling the rejected
104
+ // env defaults. A single env var, by contrast, prefills its prompt's default.
105
+ let declinedEnvPair = false;
106
+ // (2) Only consult the environment when the persisted config is incomplete.
107
+ if ((!mcpUrl || !token) && envUrl && envToken) {
108
+ // Both present → offer to reuse them, showing the URL but redacting the
109
+ // token (only that it's set, never its value).
110
+ const question = [
111
+ "Found these in your environment:",
112
+ ` LIBRARIAN_MCP_URL=${envUrl}`,
113
+ " LIBRARIAN_AGENT_TOKEN=set",
114
+ "Use the LIBRARIAN_MCP_URL and LIBRARIAN_AGENT_TOKEN from your environment? [Y/n]",
115
+ ].join("\n");
116
+ const answer = await deps.prompter.promptText(question, { default: "y" });
117
+ if (isYes(answer)) {
118
+ if (!mcpUrl)
119
+ mcpUrl = envUrl;
120
+ if (!token)
121
+ token = envToken;
122
+ }
123
+ else {
124
+ declinedEnvPair = true;
125
+ }
126
+ }
127
+ // Prompt for anything still missing. When exactly one env var is present (and
128
+ // we didn't just decline the both-present pair), prefill it as the prompt's
129
+ // default so the user can accept it with a bare enter.
130
+ if (!mcpUrl) {
131
+ const opts = envUrl && !declinedEnvPair ? { default: envUrl } : undefined;
132
+ mcpUrl = await deps.prompter.promptText("MCP URL", opts);
133
+ }
134
+ if (!token) {
135
+ // A secret prompt never echoes a default, but a present env token can still
136
+ // back an empty reply — so pass it as the default invisibly.
137
+ const opts = envToken && !declinedEnvPair ? { default: envToken, secret: true } : { secret: true };
138
+ token = await deps.prompter.promptText("Agent token", opts);
139
+ }
140
+ const changed = mcpUrl !== existing?.mcpUrl || token !== existing?.token;
141
+ const cfg = { mcpUrl, token, serverUrl: deriveServerUrl(mcpUrl) };
142
+ return { cfg, changed };
143
+ }
144
+ /** A yes/no answer parser — empty (bare enter) counts as yes given a "y" default. */
145
+ function isYes(answer) {
146
+ const a = answer.trim().toLowerCase();
147
+ return a === "" || a === "y" || a === "yes";
148
+ }
149
+ /**
150
+ * Resolve the harness set to install into:
151
+ * - explicit args (validated) win;
152
+ * - otherwise interactive multi-select over harnesses whose CLI is present
153
+ * (file-based harnesses always offered).
154
+ */
155
+ async function chooseHarnesses(named, deps, lines) {
156
+ if (named.length > 0) {
157
+ const valid = [];
158
+ for (const id of named) {
159
+ if (isHarnessId(id)) {
160
+ valid.push(allHarnesses.find((h) => h.id === id));
161
+ }
162
+ else {
163
+ lines.push(`Skipping unknown harness: ${id}`);
164
+ }
165
+ }
166
+ return valid;
167
+ }
168
+ // Default set: harnesses whose CLI is on PATH, plus file-based ones.
169
+ const available = [];
170
+ for (const harness of allHarnesses) {
171
+ const cli = HARNESS_CLI[harness.id];
172
+ if (cli === null || (await which(cli)))
173
+ available.push(harness);
174
+ }
175
+ if (available.length === 0) {
176
+ lines.push("No harness CLIs detected on PATH.");
177
+ return [];
178
+ }
179
+ const selectedIds = await deps.prompter.selectHarnesses(available.map((h) => ({ id: h.id, label: h.displayName })));
180
+ return available.filter((h) => selectedIds.includes(h.id));
181
+ }
182
+ function renderSummary(lines, outcome) {
183
+ lines.push("", "Install summary:");
184
+ if (outcome.installed.length > 0) {
185
+ lines.push(` Installed: ${outcome.installed.join(", ")}`);
186
+ }
187
+ for (const s of outcome.skipped) {
188
+ lines.push(` Skipped ${s.id}: ${s.reason}`);
189
+ }
190
+ for (const f of outcome.failed) {
191
+ lines.push(` Failed ${f.id}: ${f.reason}`);
192
+ }
193
+ if (outcome.installed.length === 0 &&
194
+ outcome.failed.length === 0 &&
195
+ outcome.skipped.length === 0) {
196
+ lines.push(" (nothing installed)");
197
+ }
198
+ lines.push("", "Restart your shell or run `source ~/.librarian/env` to load the new environment.");
199
+ }
200
+ /** True iff the error message is a harness "CLI not found on PATH" signal. */
201
+ function isCliNotFound(message) {
202
+ return /not found on path/i.test(message) || /cli not found/i.test(message);
203
+ }
204
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,QAAQ;AACR,yEAAyE;AACzE,8EAA8E;AAC9E,4EAA4E;AAC5E,qEAAqE;AACrE,+EAA+E;AAC/E,+EAA+E;AAC/E,+DAA+D;AAC/D,uEAAuE;AACvE,2EAA2E;AAC3E,4DAA4D;AAC5D,wEAAwE;AAExE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAwB,MAAM,cAAc,CAAC;AAE5F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,WAAW,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C;AAED,SAAS,aAAa,CACpB,KAAe,EACf,OAIC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;IACnC,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,gBAAgB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC;IACD,IACE,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAC3B,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAC5B,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACtC,CAAC;IACD,KAAK,CAAC,IAAI,CACR,EAAE,EACF,kFAAkF,CACnF,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { LibrarianConfig } from "../config.js";
2
+ import { type HarnessModule } from "../harnesses/index.js";
3
+ import type { HarnessConfig } from "../harnesses/types.js";
4
+ /** Adapt the persisted config into the shape harness modules consume. */
5
+ export declare function toHarnessConfig(cfg: LibrarianConfig): HarnessConfig;
6
+ /**
7
+ * Resolve named harness ids to modules, collecting any unknown ids. An empty
8
+ * `named` list returns every harness (the "all" default for uninstall/update).
9
+ */
10
+ export declare function resolveNamed(named: string[]): {
11
+ harnesses: HarnessModule[];
12
+ unknown: string[];
13
+ };
14
+ /** Pull a clean message string off an unknown thrown value. */
15
+ export declare function messageOf(error: unknown): string;
16
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,GAAG,EAAE,eAAe,GAAG,aAAa,CAEnE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;IAC7C,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAYA;AAED,+DAA+D;AAC/D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD"}
@@ -0,0 +1,30 @@
1
+ // Shared helpers for the harness-touching commands.
2
+ import { allHarnesses, isHarnessId } from "../harnesses/index.js";
3
+ /** Adapt the persisted config into the shape harness modules consume. */
4
+ export function toHarnessConfig(cfg) {
5
+ return { mcpUrl: cfg.mcpUrl, token: cfg.token, serverUrl: cfg.serverUrl };
6
+ }
7
+ /**
8
+ * Resolve named harness ids to modules, collecting any unknown ids. An empty
9
+ * `named` list returns every harness (the "all" default for uninstall/update).
10
+ */
11
+ export function resolveNamed(named) {
12
+ if (named.length === 0)
13
+ return { harnesses: [...allHarnesses], unknown: [] };
14
+ const harnesses = [];
15
+ const unknown = [];
16
+ for (const id of named) {
17
+ if (isHarnessId(id)) {
18
+ harnesses.push(allHarnesses.find((h) => h.id === id));
19
+ }
20
+ else {
21
+ unknown.push(id);
22
+ }
23
+ }
24
+ return { harnesses, unknown };
25
+ }
26
+ /** Pull a clean message string off an unknown thrown value. */
27
+ export function messageOf(error) {
28
+ return error instanceof Error ? error.message : String(error);
29
+ }
30
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAGpD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAsB,MAAM,uBAAuB,CAAC;AAGtF,yEAAyE;AACzE,MAAM,UAAU,eAAe,CAAC,GAAoB;IAClD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAe;IAI1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,CAAC,GAAG,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,SAAS,GAAoB,EAAE,CAAC;IACtC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;YACpB,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAkB,CAAC,CAAC;QACzE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type Shell } from "../env.js";
2
+ import type { Prompter } from "../prompt.js";
3
+ export interface UninstallDeps {
4
+ home?: string | undefined;
5
+ shell?: Shell | undefined;
6
+ prompter: Prompter;
7
+ }
8
+ export interface UninstallOutcome {
9
+ removed: string[];
10
+ failed: {
11
+ id: string;
12
+ reason: string;
13
+ }[];
14
+ envRemoved: boolean;
15
+ output: string;
16
+ }
17
+ export declare function runUninstall(named: string[], deps: UninstallDeps): Promise<UninstallOutcome>;
18
+ //# sourceMappingURL=uninstall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../src/commands/uninstall.ts"],"names":[],"mappings":"AASA,OAAO,EAAiC,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAGtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzC,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,gBAAgB,CAAC,CA6C3B"}