telecoder 0.0.0-stage → 1.3.0

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 (235) hide show
  1. package/.env.example +375 -0
  2. package/CHANGELOG.md +1867 -0
  3. package/LICENSE +22 -0
  4. package/README.md +130 -2
  5. package/dist/audio/transcribe.js +41 -0
  6. package/dist/bin/mcp-server.js +363 -0
  7. package/dist/bin/tool-result.js +22 -0
  8. package/dist/bot/access/group-access.js +147 -0
  9. package/dist/bot/bot.js +573 -0
  10. package/dist/bot/command-catalog.js +263 -0
  11. package/dist/bot/deleted-threads.js +103 -0
  12. package/dist/bot/file-access.js +150 -0
  13. package/dist/bot/handlers/album.handler.js +128 -0
  14. package/dist/bot/handlers/branch.handler.js +1096 -0
  15. package/dist/bot/handlers/command/access.js +407 -0
  16. package/dist/bot/handlers/command/admin.js +803 -0
  17. package/dist/bot/handlers/command/all-view.js +33 -0
  18. package/dist/bot/handlers/command/auto-approve.js +138 -0
  19. package/dist/bot/handlers/command/background.js +37 -0
  20. package/dist/bot/handlers/command/botname.js +76 -0
  21. package/dist/bot/handlers/command/btw.js +175 -0
  22. package/dist/bot/handlers/command/cleanup.js +329 -0
  23. package/dist/bot/handlers/command/model.js +226 -0
  24. package/dist/bot/handlers/command/prefs-scope.js +362 -0
  25. package/dist/bot/handlers/command/project.js +458 -0
  26. package/dist/bot/handlers/command/resume.js +325 -0
  27. package/dist/bot/handlers/command/session.js +299 -0
  28. package/dist/bot/handlers/command/settings.js +657 -0
  29. package/dist/bot/handlers/command/shared.js +207 -0
  30. package/dist/bot/handlers/command/tasks.js +681 -0
  31. package/dist/bot/handlers/command/thread.js +128 -0
  32. package/dist/bot/handlers/command/topic-store.js +74 -0
  33. package/dist/bot/handlers/command/topic.js +27 -0
  34. package/dist/bot/handlers/command/usage.js +382 -0
  35. package/dist/bot/handlers/command-fallback.js +179 -0
  36. package/dist/bot/handlers/command.handler.js +446 -0
  37. package/dist/bot/handlers/loop.handler.js +389 -0
  38. package/dist/bot/handlers/media-fallback.js +126 -0
  39. package/dist/bot/handlers/message/replies.js +56 -0
  40. package/dist/bot/handlers/message/shared.js +95 -0
  41. package/dist/bot/handlers/message/turn-notify.js +135 -0
  42. package/dist/bot/handlers/message/turn-runner.js +56 -0
  43. package/dist/bot/handlers/message.handler.js +114 -0
  44. package/dist/bot/handlers/newbot.handler.js +230 -0
  45. package/dist/bot/handlers/photo.handler.js +286 -0
  46. package/dist/bot/handlers/prompts.handler.js +343 -0
  47. package/dist/bot/handlers/running-note.js +44 -0
  48. package/dist/bot/handlers/session-guard.js +78 -0
  49. package/dist/bot/handlers/suggestion.handler.js +84 -0
  50. package/dist/bot/handlers/tree.handler.js +480 -0
  51. package/dist/bot/handlers/view.js +41 -0
  52. package/dist/bot/handlers/voice.handler.js +147 -0
  53. package/dist/bot/kept-threads.js +51 -0
  54. package/dist/bot/middleware/admin-only.js +49 -0
  55. package/dist/bot/middleware/album-collector.js +69 -0
  56. package/dist/bot/middleware/auth.middleware.js +122 -0
  57. package/dist/bot/middleware/group-mention.middleware.js +145 -0
  58. package/dist/bot/middleware/group-role.middleware.js +75 -0
  59. package/dist/bot/middleware/message-batcher.js +87 -0
  60. package/dist/bot/middleware/queued-messages.js +1082 -0
  61. package/dist/bot/middleware/stale-filter.js +9 -0
  62. package/dist/build-info.json +8 -0
  63. package/dist/claude/ask-user-form.js +517 -0
  64. package/dist/claude/ask-user.js +363 -0
  65. package/dist/claude/auto-approve.js +225 -0
  66. package/dist/claude/auto-topic-haiku.js +143 -0
  67. package/dist/claude/available-commands.js +156 -0
  68. package/dist/claude/background-hint.js +91 -0
  69. package/dist/claude/branch-tree.js +393 -0
  70. package/dist/claude/carry-over.js +25 -0
  71. package/dist/claude/ccr-shim.js +48 -0
  72. package/dist/claude/charter-judge.js +214 -0
  73. package/dist/claude/claude-auth.js +117 -0
  74. package/dist/claude/command-parser.js +206 -0
  75. package/dist/claude/cost-overlay-scraper.js +134 -0
  76. package/dist/claude/effort-level.js +5 -0
  77. package/dist/claude/enabled-plugins.js +52 -0
  78. package/dist/claude/in-flight-tracker.js +82 -0
  79. package/dist/claude/ipc-server.js +192 -0
  80. package/dist/claude/mcp-bridge.js +481 -0
  81. package/dist/claude/memory-guard.js +400 -0
  82. package/dist/claude/message-offsets.js +88 -0
  83. package/dist/claude/modal-relay.js +817 -0
  84. package/dist/claude/model-catalog.js +102 -0
  85. package/dist/claude/monitor-relay.js +712 -0
  86. package/dist/claude/native-commands.js +40 -0
  87. package/dist/claude/pending-branches.js +93 -0
  88. package/dist/claude/pending-suggestions.js +50 -0
  89. package/dist/claude/permission-gate.js +338 -0
  90. package/dist/claude/permission-mode.js +152 -0
  91. package/dist/claude/poll-user.js +51 -0
  92. package/dist/claude/prewarm.js +70 -0
  93. package/dist/claude/project-commands.js +69 -0
  94. package/dist/claude/prompt-hold.js +124 -0
  95. package/dist/claude/prompt-suggestion-scraper.js +89 -0
  96. package/dist/claude/pty-idle-reaper.js +96 -0
  97. package/dist/claude/pty-provider.js +2499 -0
  98. package/dist/claude/pty-spawn-config.js +343 -0
  99. package/dist/claude/pty-stream.js +363 -0
  100. package/dist/claude/pty-watch.js +201 -0
  101. package/dist/claude/request-queue.js +107 -0
  102. package/dist/claude/rewind.js +111 -0
  103. package/dist/claude/scheduled-runner.js +89 -0
  104. package/dist/claude/scheduler.js +241 -0
  105. package/dist/claude/scope-guard.js +279 -0
  106. package/dist/claude/screen-marks.js +83 -0
  107. package/dist/claude/screen-render.js +96 -0
  108. package/dist/claude/secret-request.js +576 -0
  109. package/dist/claude/session-history.js +288 -0
  110. package/dist/claude/session-jsonl.js +1067 -0
  111. package/dist/claude/session-manager.js +216 -0
  112. package/dist/claude/session-move.js +70 -0
  113. package/dist/claude/session-scan.js +270 -0
  114. package/dist/claude/setup-token.js +285 -0
  115. package/dist/claude/shell-mode-gate.js +60 -0
  116. package/dist/claude/side-call-options.js +45 -0
  117. package/dist/claude/side-question.js +252 -0
  118. package/dist/claude/stage-images.js +62 -0
  119. package/dist/claude/subagent-tools.js +12 -0
  120. package/dist/claude/synthetic-ctx.js +51 -0
  121. package/dist/claude/tasks-overlay-scraper.js +217 -0
  122. package/dist/claude/thread-judge-haiku.js +88 -0
  123. package/dist/claude/tip-scraper.js +77 -0
  124. package/dist/claude/tui-modal.js +746 -0
  125. package/dist/claude/tui-state.js +456 -0
  126. package/dist/claude/turn-end.js +105 -0
  127. package/dist/claude/turn-prose.js +64 -0
  128. package/dist/claude/typed-answer.js +104 -0
  129. package/dist/claude/update-banner-relay.js +70 -0
  130. package/dist/cli/commands/doctor.js +338 -0
  131. package/dist/cli/commands/help.js +34 -0
  132. package/dist/cli/commands/init.js +126 -0
  133. package/dist/cli/commands/service.js +710 -0
  134. package/dist/cli/commands/start.js +63 -0
  135. package/dist/cli/commands/version.js +11 -0
  136. package/dist/cli/commands/watch.js +322 -0
  137. package/dist/cli/dispatch.js +84 -0
  138. package/dist/cli/init/env-file.js +99 -0
  139. package/dist/cli/init/flow.js +705 -0
  140. package/dist/cli/init/prompter.js +124 -0
  141. package/dist/cli/init/telegram.js +120 -0
  142. package/dist/cli/service/render.js +212 -0
  143. package/dist/cli.js +18 -0
  144. package/dist/config-report.js +107 -0
  145. package/dist/config.js +525 -0
  146. package/dist/index.js +443 -0
  147. package/dist/launcher.js +960 -0
  148. package/dist/node-version-check.js +27 -0
  149. package/dist/providers/ccr-health.js +119 -0
  150. package/dist/providers/ccr-introspect.js +142 -0
  151. package/dist/providers/ccr-provider.js +59 -0
  152. package/dist/providers/claude-provider.js +10 -0
  153. package/dist/providers/prefs-sync.js +121 -0
  154. package/dist/providers/project-favorites.js +74 -0
  155. package/dist/providers/provider-router.js +128 -0
  156. package/dist/providers/provider-switch.js +91 -0
  157. package/dist/providers/spawn-settings.js +45 -0
  158. package/dist/providers/types.js +8 -0
  159. package/dist/providers/user-preferences.js +322 -0
  160. package/dist/restart-when-idle.js +173 -0
  161. package/dist/startup/auto-continue.js +67 -0
  162. package/dist/startup/auto-resume.js +161 -0
  163. package/dist/startup/notices.js +120 -0
  164. package/dist/startup/shared.js +44 -0
  165. package/dist/startup/verify-token.js +31 -0
  166. package/dist/telegram/access-request.js +153 -0
  167. package/dist/telegram/action-logger.js +522 -0
  168. package/dist/telegram/admin-mention.js +107 -0
  169. package/dist/telegram/background-activity-card.js +502 -0
  170. package/dist/telegram/botname-settings.js +282 -0
  171. package/dist/telegram/button-text.js +26 -0
  172. package/dist/telegram/client-options.js +26 -0
  173. package/dist/telegram/deduplication.js +33 -0
  174. package/dist/telegram/entities.js +295 -0
  175. package/dist/telegram/force-reply-tracker.js +96 -0
  176. package/dist/telegram/lettered-options.js +87 -0
  177. package/dist/telegram/markdown.js +362 -0
  178. package/dist/telegram/message-sender.js +1019 -0
  179. package/dist/telegram/prompt-label.js +148 -0
  180. package/dist/telegram/prompt-suggestion.js +54 -0
  181. package/dist/telegram/send.js +123 -0
  182. package/dist/telegram/streaming-turn.js +103 -0
  183. package/dist/telegram/suggestions-settings.js +30 -0
  184. package/dist/telegram/table-lists.js +56 -0
  185. package/dist/telegram/task-list.js +367 -0
  186. package/dist/telegram/task-tracker.js +128 -0
  187. package/dist/telegram/terminal-renderer.js +667 -0
  188. package/dist/telegram/thread-titles.js +262 -0
  189. package/dist/telegram/threads-setup.js +117 -0
  190. package/dist/utils/admins.js +143 -0
  191. package/dist/utils/agent-timer.js +55 -0
  192. package/dist/utils/atomic-write.js +24 -0
  193. package/dist/utils/bot-icon.js +248 -0
  194. package/dist/utils/bot-token.js +77 -0
  195. package/dist/utils/bounded-map.js +55 -0
  196. package/dist/utils/build-info.js +57 -0
  197. package/dist/utils/caffeinate.js +53 -0
  198. package/dist/utils/claude-env.js +53 -0
  199. package/dist/utils/claude-version.js +48 -0
  200. package/dist/utils/config-home.js +62 -0
  201. package/dist/utils/download.js +137 -0
  202. package/dist/utils/exit-codes.js +59 -0
  203. package/dist/utils/file-type.js +149 -0
  204. package/dist/utils/format.js +78 -0
  205. package/dist/utils/home-project.js +30 -0
  206. package/dist/utils/host-stall.js +51 -0
  207. package/dist/utils/id-list.js +44 -0
  208. package/dist/utils/idle-restart.js +92 -0
  209. package/dist/utils/install-mode.js +63 -0
  210. package/dist/utils/instance-config.js +148 -0
  211. package/dist/utils/instances.js +95 -0
  212. package/dist/utils/json-store.js +140 -0
  213. package/dist/utils/keyed-settings.js +62 -0
  214. package/dist/utils/legacy-env.js +35 -0
  215. package/dist/utils/memory-pressure.js +60 -0
  216. package/dist/utils/npm-version.js +134 -0
  217. package/dist/utils/prefs-relay.js +107 -0
  218. package/dist/utils/proc-children.js +102 -0
  219. package/dist/utils/resolve-bin.js +86 -0
  220. package/dist/utils/resolve-claude-bin.js +52 -0
  221. package/dist/utils/respawn-backoff.js +28 -0
  222. package/dist/utils/sanitize.js +91 -0
  223. package/dist/utils/session-key.js +37 -0
  224. package/dist/utils/stale-launcher.js +109 -0
  225. package/dist/utils/state-dir-migration.js +92 -0
  226. package/dist/utils/systemd.js +126 -0
  227. package/dist/utils/telegram-proxy.js +72 -0
  228. package/dist/utils/uploads-dir.js +27 -0
  229. package/dist/utils/user-roster.js +275 -0
  230. package/dist/utils/verbosity.js +118 -0
  231. package/dist/utils/version-check.js +166 -0
  232. package/dist/utils/workspace-guard.js +44 -0
  233. package/dist/worker-restart.js +141 -0
  234. package/instances.json.example +41 -0
  235. package/package.json +75 -4
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Typed answers to a question: Claude Code's "Type something" row.
3
+ *
4
+ * Claude Code's own question dialog ends on a row where you type an answer of
5
+ * your own instead of picking one. A Telegram keyboard has no text field, so
6
+ * here the answer is an ordinary message: while a question is open, the next
7
+ * text sent in its chat or thread answers it. A reply to a question picks that
8
+ * one, should several be open; anything else answers the one asked last. In a
9
+ * form it answers the question on screen.
10
+ *
11
+ * Before this, a message sent while a question was open waited behind the
12
+ * turn, which was itself waiting on a tap, so nothing happened until the
13
+ * question timed out.
14
+ *
15
+ * {@link captureTypedAnswers} takes the message out of the update stream ahead
16
+ * of the batcher, the queue and sequentialize, for the reason secret-request.ts
17
+ * gives: an answer waiting behind the turn that asked would never arrive.
18
+ * Commands pass, so /cancel, /steer and /later still work.
19
+ *
20
+ * telecoder_ask_user opens a question to typed answers, and so does one of
21
+ * Claude Code's own dialogs when it has a place for words: a text field, or a
22
+ * permission prompt's note (modal-relay.ts). TeleCoder's own questions (the
23
+ * permission gate, the memory guard, a held message) have fixed outcomes and
24
+ * take a tap.
25
+ */
26
+ import { clip } from '../telegram/entities.js';
27
+ import { repliedForceReplyFlow } from '../telegram/force-reply-tracker.js';
28
+ import { getSessionKeyFromCtx } from '../utils/session-key.js';
29
+ /** The line a question ends on, saying it takes a typed answer. */
30
+ export const TYPED_ANSWER_HINT = '✏️ Or reply with your own answer.';
31
+ /** Longest stretch of a typed answer written back into a question's message. */
32
+ const MAX_SHOWN_CHARS = 200;
33
+ /** Open questions, in the order they were asked. */
34
+ const takers = [];
35
+ /**
36
+ * Open a question to typed answers, once its message is posted. Returns the
37
+ * call that closes it again, which is safe to make more than once.
38
+ */
39
+ export function acceptTypedAnswers(taker) {
40
+ takers.push(taker);
41
+ return () => {
42
+ const i = takers.indexOf(taker);
43
+ if (i !== -1)
44
+ takers.splice(i, 1);
45
+ };
46
+ }
47
+ /**
48
+ * Stop taking messages as answers in this session, as /cancel does. The
49
+ * question itself closes once claude has cancelled the tool call, which takes
50
+ * a moment, and the message after /cancel must not land in it meanwhile.
51
+ */
52
+ export function stopTypedAnswers(sessionKey) {
53
+ for (let i = takers.length - 1; i >= 0; i--) {
54
+ if (takers[i].sessionKey === sessionKey)
55
+ takers.splice(i, 1);
56
+ }
57
+ }
58
+ /** Whether this message is an open question. In a group, a reply to one addresses the bot. */
59
+ export function isOpenQuestionMessage(chatId, messageId) {
60
+ return takers.some((t) => t.chatId === chatId && t.messageId === messageId);
61
+ }
62
+ /** The question a message in this session answers: the one it replies to, or else the one asked last. */
63
+ export function pickTaker(sessionKey, replyToId) {
64
+ const open = takers.filter((t) => t.sessionKey === sessionKey);
65
+ return open.find((t) => t.messageId === replyToId) ?? open.at(-1);
66
+ }
67
+ /** A typed answer as a question's message shows it: on one line, and clipped. */
68
+ export function shownTypedAnswer(text) {
69
+ return `✏️ ${clip(text.replace(/\s+/g, ' ').trim(), MAX_SHOWN_CHARS)}`;
70
+ }
71
+ /**
72
+ * Mark the message that answered a question. The question's own message
73
+ * changes too, but an edit is silent and may be scrolled out of view; the
74
+ * sender looks for the answer where they typed it.
75
+ */
76
+ export async function acknowledgeTypedAnswer(ctx) {
77
+ try {
78
+ await ctx.react('👌');
79
+ }
80
+ catch {
81
+ // Cosmetic: a group can turn reactions off, and the question still records the answer.
82
+ }
83
+ }
84
+ /**
85
+ * Hand a text message to the open question it answers, and nothing after this
86
+ * middleware sees it. Registered after the secret capture and ahead of the
87
+ * batcher, the queue and sequentialize. An answer to one of the bot's
88
+ * ForceReply prompts goes on to the flow that asked.
89
+ */
90
+ export const captureTypedAnswers = async (ctx, next) => {
91
+ const message = ctx.message;
92
+ const text = message?.text;
93
+ if (!message || text === undefined || text.startsWith('/') || repliedForceReplyFlow(ctx))
94
+ return next();
95
+ const keyInfo = getSessionKeyFromCtx(ctx);
96
+ const taker = keyInfo ? pickTaker(keyInfo.sessionKey, message.reply_to_message?.message_id) : undefined;
97
+ if (!taker || !(await taker.take(ctx, text)))
98
+ return next();
99
+ };
100
+ /** For tests: forget every open question. */
101
+ export function _resetTypedAnswersForTests() {
102
+ takers.length = 0;
103
+ }
104
+ //# sourceMappingURL=typed-answer.js.map
@@ -0,0 +1,70 @@
1
+ import { parseSessionKey } from '../utils/session-key.js';
2
+ import { sendMarkdown } from '../telegram/send.js';
3
+ /**
4
+ * One-shot relay of Claude Code's startup update banner. Claude prints a
5
+ * notice at the top of its TUI when a newer version is available (or when
6
+ * the auto-updater just installed one): "Update available! Run: claude update"
7
+ * or "Successfully updated to version X. Restart to apply changes." These
8
+ * only show during the first render of the TUI, so we scrape the
9
+ * rendered xterm screen right after _waitForReady and forward whichever
10
+ * banner we find to Telegram.
11
+ *
12
+ * Dedupes per (sessionKey, banner) so respawning the PTY mid-bot-lifetime
13
+ * (e.g. /clear) doesn't re-post the same notice.
14
+ */
15
+ let botRef = null;
16
+ const reported = new Set();
17
+ export function setUpdateBannerRelayBot(bot) {
18
+ botRef = bot;
19
+ }
20
+ export async function relayUpdateBanner(sessionKey, banner) {
21
+ if (!botRef)
22
+ return;
23
+ const dedupeKey = `${sessionKey}::${banner}`;
24
+ if (reported.has(dedupeKey))
25
+ return;
26
+ reported.add(dedupeKey);
27
+ const { chatId, threadId } = parseSessionKey(sessionKey);
28
+ const threadOpts = threadId !== undefined ? { message_thread_id: threadId } : {};
29
+ const text = `🔔 Claude Code: ${banner}`;
30
+ try {
31
+ await sendMarkdown(botRef.api, chatId, text, threadOpts);
32
+ }
33
+ catch (err) {
34
+ console.error('[UpdateBanner] send failed:', err instanceof Error ? err.message : err);
35
+ }
36
+ }
37
+ /**
38
+ * Scan rendered PTY screen text for Claude Code's update banner. The exact
39
+ * phrasings in the v2.1.150 binary are:
40
+ * - "Update available! Run: claude update" (manual update, autoUpdates=false)
41
+ * - "Update available: <details>" (variant used in some flows)
42
+ * - "Successfully updated to version X. Restart to apply changes."
43
+ * (autoUpdates=true post-install)
44
+ *
45
+ * Returns a short user-facing summary string, or null if no banner is on
46
+ * screen. We intentionally collapse multi-line TUI rendering into one line —
47
+ * claude wraps the notice inside box-drawing chrome that the xterm buffer
48
+ * preserves, and rebuilding the layout for Telegram is more brittle than
49
+ * just lifting the essential phrase.
50
+ */
51
+ export function scrapeUpdateBanner(screenText) {
52
+ // "Successfully updated to version X.Y.Z" — the auto-update success path.
53
+ // Capture the version so we can include it in the Telegram notice.
54
+ const updated = screenText.match(/Successfully updated to version\s+(\S+?)\.?\s*(?:Restart to apply[^\n]*)?/i);
55
+ if (updated) {
56
+ const version = updated[1].replace(/[.\s]+$/, '');
57
+ return `updated to v${version} — restart bot to apply`;
58
+ }
59
+ // "Update available! Run: claude update" — the manual-update path.
60
+ if (/Update available!\s*Run:?/i.test(screenText)) {
61
+ return "update available — run `claude update`";
62
+ }
63
+ // "Update available: <X>" — variant, capture trailing detail if short.
64
+ const avail = screenText.match(/Update available:\s*([^\n│]{1,80})/i);
65
+ if (avail) {
66
+ return `update available: ${avail[1].trim()}`;
67
+ }
68
+ return null;
69
+ }
70
+ //# sourceMappingURL=update-banner-relay.js.map
@@ -0,0 +1,338 @@
1
+ /**
2
+ * `telecoder doctor` — check that what TeleCoder needs is in place, without
3
+ * starting it.
4
+ *
5
+ * Reads the .env itself (dotenv.parse, not the bot's config module, which
6
+ * exits on the first invalid value) so it can report every problem at once.
7
+ * Nothing here costs money: the Claude login is checked with
8
+ * `claude auth status`, and the Telegram token only goes over the network
9
+ * with --live (a getMe call, through the proxy the bot would use).
10
+ */
11
+ import { execFile } from 'child_process';
12
+ import * as fs from 'fs';
13
+ import * as os from 'os';
14
+ import * as path from 'path';
15
+ import { parse as parseEnv } from 'dotenv';
16
+ import { getConfigHomeInfo, configFile } from '../../utils/config-home.js';
17
+ import { getInstallMode, getInstalledVersion, PACKAGE_ROOT } from '../../utils/install-mode.js';
18
+ import { legacyEnv } from '../../utils/legacy-env.js';
19
+ import { parseIdList, PLACEHOLDER_USER_ID } from '../../utils/id-list.js';
20
+ import { resolveInstances, InstancesConfigError } from '../../utils/instance-config.js';
21
+ import { resolveBin } from '../../utils/resolve-bin.js';
22
+ import { redactSecrets } from '../../utils/sanitize.js';
23
+ import { unreachableHint } from '../../utils/bot-token.js';
24
+ import { fetchThroughProxy, findProxy } from '../../utils/telegram-proxy.js';
25
+ import { describeFetchError } from '../init/telegram.js';
26
+ import { MIN_NODE_MAJOR } from '../../node-version-check.js';
27
+ import { SERVICE_MANAGER_ENV } from '../../utils/exit-codes.js';
28
+ export { MIN_NODE_MAJOR };
29
+ const ok = (label, ...detail) => ({ status: 'ok', label, detail });
30
+ const warn = (label, ...detail) => ({ status: 'warn', label, detail });
31
+ const fail = (label, ...detail) => ({ status: 'fail', label, detail });
32
+ // ── Pure checks (tested directly) ──────────────────────────────
33
+ export function checkNodeVersion(version = process.versions.node) {
34
+ const major = parseInt(version.split('.')[0], 10);
35
+ return major >= MIN_NODE_MAJOR
36
+ ? ok(`Node.js ${version}`)
37
+ : fail(`Node.js ${version} is too old`, `TeleCoder needs Node.js ${MIN_NODE_MAJOR} or newer.`);
38
+ }
39
+ /** `<bot id>:<secret>`, the shape @BotFather hands out. */
40
+ export function tokenLooksValid(token) {
41
+ return /^\d{5,}:[A-Za-z0-9_-]{30,}$/.test(token.trim());
42
+ }
43
+ export function checkToken(token, where) {
44
+ if (!token)
45
+ return fail('TELEGRAM_BOT_TOKEN is not set', `Add it to ${where} (get one from @BotFather).`);
46
+ if (!tokenLooksValid(token)) {
47
+ return fail('TELEGRAM_BOT_TOKEN does not look like a bot token', 'Expected <bot id>:<secret>, e.g. 123456789:AA… — copy it again from @BotFather.');
48
+ }
49
+ return ok(`Bot token for bot ${token.split(':')[0]}`);
50
+ }
51
+ export function checkAllowedUsers(raw) {
52
+ if (!raw?.trim()) {
53
+ return fail('ALLOWED_USER_IDS is not set', '"telecoder init" finds your numeric Telegram id, or get it from @userinfobot.');
54
+ }
55
+ const parsed = parseIdList('ALLOWED_USER_IDS', raw);
56
+ if (!parsed.ok)
57
+ return fail('ALLOWED_USER_IDS is invalid', parsed.error);
58
+ if (parsed.ids.includes(PLACEHOLDER_USER_ID)) {
59
+ return fail(`ALLOWED_USER_IDS still has the placeholder ${PLACEHOLDER_USER_ID}`, 'Replace it with your own numeric Telegram id (get it from @userinfobot).');
60
+ }
61
+ return ok(`Allowed users: ${parsed.ids.join(', ')}`);
62
+ }
63
+ /** What `claude auth status --json` says about being logged in; null when it can't be read. */
64
+ export function parseAuthStatus(stdout) {
65
+ try {
66
+ const parsed = JSON.parse(stdout);
67
+ if (typeof parsed.loggedIn !== 'boolean')
68
+ return null;
69
+ return { loggedIn: parsed.loggedIn, method: typeof parsed.authMethod === 'string' ? parsed.authMethod : undefined };
70
+ }
71
+ catch {
72
+ return null;
73
+ }
74
+ }
75
+ const SERVICE_LOGIN_NOTE = (envPath) => `This runs under the service, which doesn't see your shell's environment: a login kept in ${CLAUDE_CREDENTIAL_VARS.join(', ')} has to be in ${envPath}.`;
76
+ /**
77
+ * A login that lives only in the shell's environment works from a terminal,
78
+ * but a service starts without that environment. `envOnly` is what
79
+ * envOnlyLogin found; a variable kept in the .env is fine, the bot loads it.
80
+ */
81
+ export function checkLoginSurvivesService(envOnly, fileEnv, envPath) {
82
+ if (!envOnly.length || envOnly.some((key) => fileEnv[key]?.trim()))
83
+ return null;
84
+ const vars = envOnly.join(' / ');
85
+ return warn(`Claude Code's login comes from ${vars} in this shell's environment, not stored credentials`, `When TeleCoder runs as a service (telecoder service install), it starts outside your shell and doesn't have ${vars}, so Claude Code would be logged out.`, `Add ${vars} to ${envPath} (readable by you only), or log in with "claude auth login".`);
86
+ }
87
+ // ── Checks that look at the machine ────────────────────────────
88
+ function exec(cmd, args, timeout = 15_000, env) {
89
+ return new Promise((resolve) => {
90
+ execFile(cmd, args, { timeout, maxBuffer: 1024 * 1024, env }, (error, stdout, stderr) => {
91
+ const code = error ? (typeof error.code === 'number' ? error.code : null) : 0;
92
+ resolve({ code, stdout: String(stdout ?? ''), stderr: String(stderr ?? '') });
93
+ });
94
+ });
95
+ }
96
+ function onPath(name) {
97
+ const resolved = resolveBin(name);
98
+ return path.isAbsolute(resolved);
99
+ }
100
+ /**
101
+ * The variables in the .env that change how claude logs in. The bot loads
102
+ * them into its own environment, so `claude auth status` has to see them too,
103
+ * or a login kept in the .env reads as none.
104
+ */
105
+ const CLAUDE_AUTH_VARS = [
106
+ 'ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN', 'ANTHROPIC_BASE_URL', 'CLAUDE_CODE_OAUTH_TOKEN', 'CLAUDE_CONFIG_DIR',
107
+ 'CLAUDE_CODE_USE_BEDROCK', 'CLAUDE_CODE_USE_VERTEX', 'CLAUDE_CODE_USE_FOUNDRY',
108
+ ];
109
+ export function claudeAuthEnv(value, base = process.env) {
110
+ const env = { ...base };
111
+ for (const key of CLAUDE_AUTH_VARS) {
112
+ const v = value(key);
113
+ if (v)
114
+ env[key] = v;
115
+ }
116
+ return env;
117
+ }
118
+ /** The variables that are a Claude login by themselves, as opposed to stored credentials. */
119
+ export const CLAUDE_CREDENTIAL_VARS = ['CLAUDE_CODE_OAUTH_TOKEN', 'ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN'];
120
+ /** The credential variables set (non-empty) in `env`. */
121
+ export function credentialVarsIn(env) {
122
+ return CLAUDE_CREDENTIAL_VARS.filter((key) => env[key]?.trim());
123
+ }
124
+ /**
125
+ * Whether claude is logged in once the credential variables are taken away:
126
+ * true means stored credentials (~/.claude/.credentials.json, or the macOS
127
+ * keychain), which a service finds too. null when it can't tell (an older CLI
128
+ * without `auth status`), in which case the credentials file is the best sign.
129
+ */
130
+ export async function hasStoredLogin(executable, env = process.env) {
131
+ const bin = path.isAbsolute(executable) || executable.includes('/') ? executable : resolveBin(executable);
132
+ const bare = { ...env };
133
+ for (const key of CLAUDE_CREDENTIAL_VARS)
134
+ delete bare[key];
135
+ const status = parseAuthStatus((await exec(bin, ['auth', 'status', '--json'], 20_000, bare)).stdout);
136
+ if (status)
137
+ return status.loggedIn;
138
+ const configDir = env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
139
+ return fs.existsSync(path.join(configDir, '.credentials.json')) ? true : null;
140
+ }
141
+ /**
142
+ * The credential variables a working login depends on: set in `env`, and
143
+ * claude logged out without them. Empty when the login is stored, or there
144
+ * is none to speak of.
145
+ */
146
+ export async function envOnlyLogin(executable, env = process.env) {
147
+ const vars = credentialVarsIn(env);
148
+ if (!vars.length)
149
+ return [];
150
+ return (await hasStoredLogin(executable, env)) ? [] : vars;
151
+ }
152
+ export async function checkClaude(executable, env = process.env) {
153
+ const bin = path.isAbsolute(executable) || executable.includes('/') ? executable : resolveBin(executable);
154
+ const version = await exec(bin, ['--version'], 15_000, env);
155
+ if (version.code !== 0) {
156
+ return [fail(`Claude Code CLI not found (${executable})`, 'Install it: curl -fsSL https://claude.ai/install.sh | bash — or set CLAUDE_EXECUTABLE_PATH.')];
157
+ }
158
+ const results = [ok(`Claude Code ${version.stdout.trim().split('\n')[0]}`)];
159
+ const auth = await exec(bin, ['auth', 'status', '--json'], 20_000, env);
160
+ const status = parseAuthStatus(auth.stdout);
161
+ if (status?.loggedIn) {
162
+ results.push(ok(`Claude Code is logged in${status.method ? ` (${status.method})` : ''}`));
163
+ }
164
+ else if (status) {
165
+ results.push(fail('Claude Code is not logged in', 'Run "claude" once and log in, or run "claude setup-token" and set CLAUDE_CODE_OAUTH_TOKEN in the .env.'));
166
+ }
167
+ else if (env.ANTHROPIC_API_KEY || env.CLAUDE_CODE_OAUTH_TOKEN
168
+ || fs.existsSync(path.join(os.homedir(), '.claude', '.credentials.json'))) {
169
+ // An older CLI without `auth status`: credentials on disk are the best sign.
170
+ results.push(ok('Claude Code credentials found'));
171
+ }
172
+ else {
173
+ results.push(warn("Couldn't confirm the Claude Code login", 'If the bot can\'t answer, run "claude" once and log in.'));
174
+ }
175
+ return results;
176
+ }
177
+ export async function checkNodePty() {
178
+ try {
179
+ await import('node-pty');
180
+ return [ok('node-pty loads')];
181
+ }
182
+ catch (error) {
183
+ const missing = [
184
+ ['a C compiler', ['cc', 'gcc', 'clang']],
185
+ ['a C++ compiler', ['c++', 'g++', 'clang++']],
186
+ ['make', ['make']],
187
+ ['python3', ['python3']],
188
+ ].filter(([, names]) => !names.some(onPath)).map(([what]) => what);
189
+ const fix = process.platform === 'darwin'
190
+ ? 'Install the Xcode command line tools (xcode-select --install), then reinstall TeleCoder.'
191
+ : 'Install a build toolchain (e.g. apt install build-essential python3), then reinstall TeleCoder.';
192
+ return [fail('node-pty failed to load (Claude Code runs in it, so chats need it)', redactSecrets(error instanceof Error ? error.message.split('\n')[0] : String(error)), ...(missing.length ? [`Missing: ${missing.join(', ')}.`, fix] : ['A build toolchain is present; try reinstalling TeleCoder.']))];
193
+ }
194
+ }
195
+ /**
196
+ * Ask Telegram who the token belongs to (getMe), through `proxyUrl` when the
197
+ * bot with this token would use a proxy. `apiRoot` is for tests.
198
+ */
199
+ export async function checkLive(token, proxyUrl, apiRoot = 'https://api.telegram.org') {
200
+ // The message of a failed request can carry the URL, and the URL the token;
201
+ // a proxy URL can carry a password.
202
+ const scrub = (text) => redactSecrets(text.replaceAll(token, '<token>'));
203
+ const via = proxyUrl ? ` through the proxy ${scrub(proxyUrl)}` : '';
204
+ const unreachable = (reason) => warn(`Couldn't reach Telegram${via}`, scrub(reason), unreachableHint(proxyUrl));
205
+ let status;
206
+ let text;
207
+ try {
208
+ const request = proxyUrl ? fetchThroughProxy(proxyUrl) : fetch;
209
+ const res = await request(`${apiRoot}/bot${token}/getMe`, { signal: AbortSignal.timeout(10_000) });
210
+ status = res.status;
211
+ text = await res.text();
212
+ }
213
+ catch (error) {
214
+ return unreachable(describeFetchError(error));
215
+ }
216
+ let body;
217
+ try {
218
+ body = JSON.parse(text);
219
+ }
220
+ catch {
221
+ // A proxy's own error (a 407, an error page) or a gateway in between.
222
+ return unreachable(`HTTP ${status}, not a Bot API answer`);
223
+ }
224
+ if (body.ok && body.result?.username)
225
+ return ok(`Telegram knows the token: @${body.result.username}${via ? ` (${via.trim()})` : ''}`);
226
+ return fail('Telegram rejected the token', scrub(body.description ?? `HTTP ${status}`));
227
+ }
228
+ // ── The command ────────────────────────────────────────────────
229
+ const ICON = { ok: '✓', warn: '!', fail: '✗' };
230
+ function print(io, result) {
231
+ io.out(`${ICON[result.status]} ${result.label}`);
232
+ for (const line of result.detail ?? [])
233
+ io.out(` ${line}`);
234
+ }
235
+ export async function runChecks(args) {
236
+ const results = [];
237
+ const live = args.includes('--live');
238
+ results.push(checkNodeVersion());
239
+ results.push(ok(`TeleCoder ${getInstalledVersion() ?? '?'} (${getInstallMode()} install at ${PACKAGE_ROOT})`));
240
+ const home = getConfigHomeInfo();
241
+ const why = { override: 'from TELECODER_HOME', 'package-root': 'next to package.json', home: 'default' }[home.source];
242
+ results.push(ok(`Config home: ${home.dir} (${why})`));
243
+ const envPath = legacyEnv('ENV_PATH') || configFile('.env');
244
+ const instancesPath = configFile('instances.json');
245
+ let fileEnv = {};
246
+ if (fs.existsSync(envPath)) {
247
+ try {
248
+ fileEnv = parseEnv(fs.readFileSync(envPath));
249
+ results.push(ok(`Config file: ${envPath}`));
250
+ }
251
+ catch (error) {
252
+ results.push(fail(`Can't read ${envPath}`, error instanceof Error ? error.message : String(error)));
253
+ }
254
+ }
255
+ else if (!fs.existsSync(instancesPath)) {
256
+ results.push(fail(`No config file at ${envPath}`, 'Run "telecoder init" to set one up.'));
257
+ }
258
+ // The environment wins over the file, as it does in the bot.
259
+ const value = (key) => process.env[key] ?? fileEnv[key];
260
+ /** Each token to check with --live, and the proxy its bot would reach Telegram through. */
261
+ const tokens = [];
262
+ if (fs.existsSync(instancesPath)) {
263
+ try {
264
+ const warnings = [];
265
+ const instances = resolveInstances(fs.readFileSync(instancesPath, 'utf-8'), (w) => warnings.push(w));
266
+ results.push(ok(`instances.json: ${instances.length} bot(s) — ${instances.map((i) => i.name).join(', ')}`));
267
+ for (const w of warnings)
268
+ results.push(warn(w));
269
+ for (const inst of instances) {
270
+ const r = checkToken(inst.token, instancesPath);
271
+ if (r.status !== 'ok')
272
+ results.push({ ...r, label: `${inst.name}: ${r.label}` });
273
+ // An instance's overrides are its environment, over the launcher's own.
274
+ else
275
+ tokens.push({ token: inst.token, proxyUrl: findProxy((key) => inst.overrides?.[key] ?? value(key))?.url });
276
+ }
277
+ const users = instances.map((i) => i.overrides?.ALLOWED_USER_IDS ?? value('ALLOWED_USER_IDS'));
278
+ for (const r of new Set(users))
279
+ results.push(checkAllowedUsers(r));
280
+ }
281
+ catch (error) {
282
+ if (!(error instanceof InstancesConfigError))
283
+ throw error;
284
+ results.push(fail(`instances.json: ${error.message}`));
285
+ }
286
+ }
287
+ else {
288
+ const token = value('TELEGRAM_BOT_TOKEN');
289
+ const r = checkToken(token, envPath);
290
+ results.push(r);
291
+ if (r.status === 'ok' && token)
292
+ tokens.push({ token, proxyUrl: findProxy(value)?.url });
293
+ results.push(checkAllowedUsers(value('ALLOWED_USER_IDS')));
294
+ }
295
+ const claudeBin = value('CLAUDE_EXECUTABLE_PATH') || 'claude';
296
+ const claude = await checkClaude(claudeBin, claudeAuthEnv(value));
297
+ results.push(...claude);
298
+ if (claude[1]?.status === 'ok') {
299
+ const loginWarning = checkLoginSurvivesService(await envOnlyLogin(claudeBin, claudeAuthEnv(value)), fileEnv, envPath);
300
+ if (loginWarning)
301
+ results.push(loginWarning);
302
+ }
303
+ else if (claude[1]?.status === 'fail' && process.env[SERVICE_MANAGER_ENV]) {
304
+ claude[1].detail = [...claude[1].detail ?? [], SERVICE_LOGIN_NOTE(envPath)];
305
+ }
306
+ results.push(...await checkNodePty());
307
+ if (live) {
308
+ for (const { token, proxyUrl } of tokens)
309
+ results.push(await checkLive(token, proxyUrl));
310
+ }
311
+ return results;
312
+ }
313
+ export function usage() {
314
+ return [
315
+ 'Usage: telecoder doctor [--live]',
316
+ '',
317
+ 'Checks Node, the claude CLI and its login, node-pty and your config. Writes nothing.',
318
+ ' --live also check each bot token with Telegram (through the proxy, when one is set)',
319
+ ];
320
+ }
321
+ export async function run(args, io) {
322
+ const results = await runChecks(args);
323
+ for (const r of results)
324
+ print(io, r);
325
+ const failed = results.filter((r) => r.status === 'fail').length;
326
+ const warned = results.filter((r) => r.status === 'warn').length;
327
+ io.out('');
328
+ if (failed)
329
+ io.out(`${failed} problem(s) to fix before "telecoder start" will work.`);
330
+ else if (warned)
331
+ io.out(`Ready to start, with ${warned} warning(s).`);
332
+ else
333
+ io.out('All good. Run "telecoder start".');
334
+ if (!args.includes('--live') && !failed)
335
+ io.out('(Add --live to check the token with Telegram.)');
336
+ return failed ? 1 : 0;
337
+ }
338
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1,34 @@
1
+ import { COMMANDS } from '../dispatch.js';
2
+ export function helpText(only) {
3
+ const names = only && Object.hasOwn(COMMANDS, only) ? [only] : Object.keys(COMMANDS);
4
+ const rows = names.map((name) => {
5
+ const spec = COMMANDS[name];
6
+ return { left: [name, spec.usage].filter(Boolean).join(' '), right: spec.summary };
7
+ });
8
+ const width = Math.max(...rows.map((r) => r.left.length));
9
+ return [
10
+ 'TeleCoder: Claude Code from Telegram',
11
+ '',
12
+ 'Usage: telecoder <command> [options]',
13
+ '',
14
+ 'Commands:',
15
+ ...rows.map((r) => ` ${r.left.padEnd(width)} ${r.right}`),
16
+ '',
17
+ 'Config is read from ~/.telecoder/.env (TELECODER_HOME moves it), or from',
18
+ 'next to package.json in a source checkout. Docs: https://telecoder.dev',
19
+ ].join('\n');
20
+ }
21
+ export async function run(args, io, commands = COMMANDS) {
22
+ const only = args[0];
23
+ // About one command: its own usage, with every option, when it has one.
24
+ if (only && Object.hasOwn(commands, only)) {
25
+ const mod = await commands[only].load();
26
+ if (mod.usage) {
27
+ io.out([commands[only].summary, '', ...mod.usage()].join('\n'));
28
+ return 0;
29
+ }
30
+ }
31
+ io.out(helpText(only));
32
+ return 0;
33
+ }
34
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1,126 @@
1
+ /**
2
+ * `telecoder init` — set up a bot interactively, or from flags in a script.
3
+ *
4
+ * The wizard itself is ../init/flow.ts; this module parses the flags and hands
5
+ * it the real terminal, the real Telegram and the real config location (the
6
+ * same .env `telecoder start` and the bot read: TELECODER_ENV_PATH if set,
7
+ * else <config home>/.env).
8
+ */
9
+ import * as os from 'os';
10
+ import { getConfigHomeInfo, configFile } from '../../utils/config-home.js';
11
+ import { isCheckout, detectPackageRunner } from '../../utils/install-mode.js';
12
+ import { legacyEnv } from '../../utils/legacy-env.js';
13
+ import { checkClaude, checkNodePty, checkNodeVersion, envOnlyLogin } from './doctor.js';
14
+ import { runInit } from '../init/flow.js';
15
+ import { planServiceInstall, runServiceInstall } from './service.js';
16
+ import { createTerminalPrompter } from '../init/prompter.js';
17
+ import { createTelegramClient, DEFAULT_API_ROOT } from '../init/telegram.js';
18
+ const USAGE = [
19
+ 'Usage: telecoder init [options]',
20
+ '',
21
+ 'Asks for everything it needs when run in a terminal. For scripts:',
22
+ ' --token-env VAR read the bot token from environment variable VAR',
23
+ ' (never pass the token itself: arguments show up in ps)',
24
+ ' --owner-id ID your numeric Telegram user id',
25
+ ' --workspace DIR the folder your projects are in (default: ~/projects or ~)',
26
+ ' --groq-key-env VAR turn voice transcription on, with the Groq key in VAR',
27
+ ' --icon give the bot the TeleCoder icon as its profile picture,',
28
+ ' replacing one it has (default: only when it has none)',
29
+ ' --no-icon leave the bot\'s picture alone',
30
+ ' --no-test-message don\'t have the bot message you at the end',
31
+ ' --yes ask nothing: take defaults, replace an existing .env',
32
+ ' (backed up first), remove a webhook if one is set',
33
+ '',
34
+ 'Where Telegram is blocked, set TELEGRAM_PROXY_URL (or HTTPS_PROXY) to an HTTP or',
35
+ 'HTTPS proxy first. The wizard goes through it and writes it to the .env.',
36
+ ];
37
+ export function usage() {
38
+ return USAGE;
39
+ }
40
+ export function parseInitArgs(args) {
41
+ const opts = {};
42
+ const valued = {
43
+ '--token-env': (v) => { opts.tokenEnv = v; },
44
+ '--owner-id': (v) => { opts.ownerId = v; },
45
+ '--workspace': (v) => { opts.workspace = v; },
46
+ '--groq-key-env': (v) => { opts.groqKeyEnv = v; },
47
+ };
48
+ for (let i = 0; i < args.length; i++) {
49
+ const [flag, inline] = args[i].includes('=') ? args[i].split(/=(.*)/s, 2) : [args[i], undefined];
50
+ if (flag === '--yes' || flag === '-y')
51
+ opts.yes = true;
52
+ else if (flag === '--icon')
53
+ opts.icon = true;
54
+ else if (flag === '--no-icon')
55
+ opts.icon = false;
56
+ else if (flag === '--no-test-message')
57
+ opts.noTestMessage = true;
58
+ else if (flag === '--token' || flag === '--groq-key') {
59
+ return { ok: false, error: `${flag} isn't accepted: arguments show up in ps. Put it in an environment variable and pass ${flag}-env VAR.` };
60
+ }
61
+ else if (Object.hasOwn(valued, flag)) {
62
+ const value = inline ?? args[++i];
63
+ if (value === undefined || value === '')
64
+ return { ok: false, error: `${flag} needs a value.` };
65
+ const problem = valued[flag](value);
66
+ if (problem)
67
+ return { ok: false, error: problem };
68
+ }
69
+ else {
70
+ return { ok: false, error: `Unknown option: ${args[i]}` };
71
+ }
72
+ }
73
+ return { ok: true, opts };
74
+ }
75
+ export async function run(args, io) {
76
+ const parsed = parseInitArgs(args);
77
+ if (!parsed.ok) {
78
+ io.err(parsed.error);
79
+ for (const line of USAGE)
80
+ io.err(line);
81
+ return 2;
82
+ }
83
+ const claudeBin = process.env.CLAUDE_EXECUTABLE_PATH || 'claude';
84
+ const envPath = legacyEnv('ENV_PATH') || configFile('.env');
85
+ // Test-only: point the wizard at a fake Telegram. See init/telegram.ts.
86
+ const apiRoot = process.env.TELECODER_TELEGRAM_API_ROOT || DEFAULT_API_ROOT;
87
+ const prompter = createTerminalPrompter();
88
+ let serviceRequested = false;
89
+ let code;
90
+ try {
91
+ code = await runInit(parsed.opts, {
92
+ prompter,
93
+ makeClient: (token, proxyUrl) => createTelegramClient(token, { apiRoot, proxyUrl }),
94
+ preflight: async () => {
95
+ const claude = await checkClaude(claudeBin);
96
+ return {
97
+ node: checkNodeVersion(),
98
+ claude,
99
+ envLogin: claude[1]?.status === 'ok' ? await envOnlyLogin(claudeBin) : [],
100
+ nodePty: await checkNodePty(),
101
+ };
102
+ },
103
+ envPath,
104
+ // Tighten only ~/.telecoder itself: a checkout's root or a TELECODER_HOME
105
+ // may be a directory other things live in (a new one is made 0700 anyway).
106
+ ownDir: envPath === configFile('.env') && getConfigHomeInfo().source === 'home',
107
+ env: process.env,
108
+ homedir: os.homedir(),
109
+ claudeBin,
110
+ isCheckout: isCheckout(),
111
+ // Not from npx: its cache can be cleared under the unit, and the installer
112
+ // refuses it anyway.
113
+ requestService: detectPackageRunner() === 'npx' ? undefined : () => { serviceRequested = true; },
114
+ planService: () => planServiceInstall(),
115
+ });
116
+ }
117
+ finally {
118
+ prompter.close();
119
+ }
120
+ if (code === 0 && serviceRequested) {
121
+ io.out('');
122
+ return runServiceInstall({ io });
123
+ }
124
+ return code;
125
+ }
126
+ //# sourceMappingURL=init.js.map