teleton 0.7.2 → 0.7.4

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 (31) hide show
  1. package/README.md +31 -12
  2. package/dist/{chunk-ND2X5FWB.js → chunk-5PLZ3KSO.js} +16 -3
  3. package/dist/{chunk-NERLQY2H.js → chunk-BGC2IUM5.js} +73 -15
  4. package/dist/{chunk-FNV5FF35.js → chunk-EK7M5K26.js} +29 -13
  5. package/dist/chunk-JQDLW7IE.js +107 -0
  6. package/dist/{chunk-VSMUAU5X.js → chunk-LAQOUFOJ.js} +2419 -2132
  7. package/dist/chunk-QOQWUUA4.js +158 -0
  8. package/dist/{chunk-LRCPA7SC.js → chunk-RMLQS3X6.js} +15 -3
  9. package/dist/{chunk-UDD7FYOU.js → chunk-WIKM24GZ.js} +1 -18
  10. package/dist/{chunk-RBU6JXD3.js → chunk-XDYDA2KV.js} +1 -1
  11. package/dist/{chunk-JHKWHGBM.js → chunk-YFG2QHLA.js} +380 -47
  12. package/dist/cli/index.js +216 -272
  13. package/dist/{client-3VWE7NC4.js → client-RTNALK7W.js} +3 -2
  14. package/dist/{get-my-gifts-RI7FAXAL.js → get-my-gifts-TPVUGUWT.js} +1 -1
  15. package/dist/index.js +9 -10
  16. package/dist/{memory-5SS3Q5EA.js → memory-JQZ6MTRU.js} +2 -2
  17. package/dist/{migrate-M7SJMDOL.js → migrate-GS5ACQDA.js} +2 -2
  18. package/dist/{server-NPSODUMA.js → server-TCJOBV3D.js} +292 -11
  19. package/dist/{setup-server-C7ZTPHD5.js → setup-server-YHYJLAMA.js} +77 -112
  20. package/dist/{tool-index-MIVK3D7H.js → tool-index-6HBRVXVG.js} +1 -1
  21. package/dist/web/assets/index-B6M9knfJ.css +1 -0
  22. package/dist/web/assets/index-DAGeQfVZ.js +72 -0
  23. package/dist/web/assets/{index.es-D81xLR29.js → index.es-CqZHj0tz.js} +1 -1
  24. package/dist/web/index.html +2 -2
  25. package/package.json +2 -2
  26. package/dist/chunk-EHEV7FJ7.js +0 -157
  27. package/dist/chunk-QUAPFI2N.js +0 -42
  28. package/dist/endpoint-FLYNEZ2F.js +0 -7
  29. package/dist/format-transactions-FD74HI5N.js +0 -9
  30. package/dist/web/assets/index-BqwoDycr.js +0 -72
  31. package/dist/web/assets/index-CRDIf07k.css +0 -1
package/dist/cli/index.js CHANGED
@@ -1,9 +1,11 @@
1
+ import {
2
+ getModelsForProvider
3
+ } from "../chunk-QOQWUUA4.js";
1
4
  import {
2
5
  TelegramUserClient,
3
6
  main
4
- } from "../chunk-VSMUAU5X.js";
5
- import "../chunk-UDD7FYOU.js";
6
- import "../chunk-EHEV7FJ7.js";
7
+ } from "../chunk-LAQOUFOJ.js";
8
+ import "../chunk-WIKM24GZ.js";
7
9
  import "../chunk-U7FQYCBQ.js";
8
10
  import {
9
11
  CONFIGURABLE_KEYS,
@@ -14,7 +16,7 @@ import {
14
16
  readRawConfig,
15
17
  setNestedValue,
16
18
  writeRawConfig
17
- } from "../chunk-JHKWHGBM.js";
19
+ } from "../chunk-YFG2QHLA.js";
18
20
  import {
19
21
  ConfigSchema,
20
22
  DealsConfigSchema,
@@ -25,22 +27,25 @@ import {
25
27
  loadWallet,
26
28
  saveWallet,
27
29
  walletExists
28
- } from "../chunk-NERLQY2H.js";
29
- import "../chunk-QUAPFI2N.js";
30
+ } from "../chunk-BGC2IUM5.js";
30
31
  import "../chunk-TSKJCWQQ.js";
31
32
  import {
32
33
  getErrorMessage
33
34
  } from "../chunk-XBE4JB7C.js";
34
- import "../chunk-ND2X5FWB.js";
35
+ import "../chunk-5PLZ3KSO.js";
36
+ import {
37
+ getClaudeCodeApiKey,
38
+ isClaudeCodeTokenValid
39
+ } from "../chunk-JQDLW7IE.js";
35
40
  import {
36
41
  getProviderMetadata,
37
42
  getSupportedProviders,
38
43
  validateApiKeyFormat
39
- } from "../chunk-LRCPA7SC.js";
44
+ } from "../chunk-RMLQS3X6.js";
40
45
  import "../chunk-OCLG5GKI.js";
41
- import "../chunk-RBU6JXD3.js";
46
+ import "../chunk-XDYDA2KV.js";
42
47
  import "../chunk-UCN6TI25.js";
43
- import "../chunk-FNV5FF35.js";
48
+ import "../chunk-EK7M5K26.js";
44
49
  import "../chunk-XBKSS6DM.js";
45
50
  import {
46
51
  TELEGRAM_MAX_MESSAGE_LENGTH
@@ -358,12 +363,12 @@ import { join } from "path";
358
363
  import YAML from "yaml";
359
364
  import ora2 from "ora";
360
365
  var STEPS = [
361
- { label: "Agent", desc: "Name & mode" },
362
- { label: "Provider", desc: "LLM & API key" },
363
- { label: "Telegram", desc: "Credentials" },
364
- { label: "Config", desc: "Model & policies" },
365
- { label: "Modules", desc: "Optional features" },
366
+ { label: "Agent", desc: "Name" },
367
+ { label: "Provider", desc: "LLM, key & model" },
368
+ { label: "Config", desc: "Policies" },
369
+ { label: "Modules", desc: "Optional API keys" },
366
370
  { label: "Wallet", desc: "TON blockchain" },
371
+ { label: "Telegram", desc: "Credentials" },
367
372
  { label: "Connect", desc: "Telegram auth" }
368
373
  ];
369
374
  function redraw(currentStep) {
@@ -375,109 +380,9 @@ function redraw(currentStep) {
375
380
  function sleep(ms) {
376
381
  return new Promise((r) => setTimeout(r, ms));
377
382
  }
378
- var MODEL_OPTIONS = {
379
- anthropic: [
380
- {
381
- value: "claude-opus-4-5-20251101",
382
- name: "Claude Opus 4.5",
383
- description: "Most capable, $5/M"
384
- },
385
- { value: "claude-sonnet-4-0", name: "Claude Sonnet 4", description: "Balanced, $3/M" },
386
- {
387
- value: "claude-haiku-4-5-20251001",
388
- name: "Claude Haiku 4.5",
389
- description: "Fast & cheap, $1/M"
390
- },
391
- {
392
- value: "claude-3-5-haiku-20241022",
393
- name: "Claude 3.5 Haiku",
394
- description: "Cheapest, $0.80/M"
395
- }
396
- ],
397
- openai: [
398
- { value: "gpt-5", name: "GPT-5", description: "Most capable, 400K ctx, $1.25/M" },
399
- { value: "gpt-4o", name: "GPT-4o", description: "Balanced, 128K ctx, $2.50/M" },
400
- { value: "gpt-4.1", name: "GPT-4.1", description: "1M ctx, $2/M" },
401
- { value: "gpt-4.1-mini", name: "GPT-4.1 Mini", description: "1M ctx, cheap, $0.40/M" },
402
- { value: "o3", name: "o3", description: "Reasoning, 200K ctx, $2/M" }
403
- ],
404
- google: [
405
- { value: "gemini-2.5-flash", name: "Gemini 2.5 Flash", description: "Fast, 1M ctx, $0.30/M" },
406
- {
407
- value: "gemini-2.5-pro",
408
- name: "Gemini 2.5 Pro",
409
- description: "Most capable, 1M ctx, $1.25/M"
410
- },
411
- { value: "gemini-2.0-flash", name: "Gemini 2.0 Flash", description: "Cheap, 1M ctx, $0.10/M" }
412
- ],
413
- xai: [
414
- { value: "grok-4-fast", name: "Grok 4 Fast", description: "Vision, 2M ctx, $0.20/M" },
415
- { value: "grok-4", name: "Grok 4", description: "Reasoning, 256K ctx, $3/M" },
416
- { value: "grok-3", name: "Grok 3", description: "Stable, 131K ctx, $3/M" }
417
- ],
418
- groq: [
419
- {
420
- value: "meta-llama/llama-4-maverick-17b-128e-instruct",
421
- name: "Llama 4 Maverick",
422
- description: "Vision, 131K ctx, $0.20/M"
423
- },
424
- { value: "qwen/qwen3-32b", name: "Qwen3 32B", description: "Reasoning, 131K ctx, $0.29/M" },
425
- {
426
- value: "deepseek-r1-distill-llama-70b",
427
- name: "DeepSeek R1 70B",
428
- description: "Reasoning, 131K ctx, $0.75/M"
429
- },
430
- {
431
- value: "llama-3.3-70b-versatile",
432
- name: "Llama 3.3 70B",
433
- description: "General purpose, 131K ctx, $0.59/M"
434
- }
435
- ],
436
- openrouter: [
437
- { value: "anthropic/claude-opus-4.5", name: "Claude Opus 4.5", description: "200K ctx, $5/M" },
438
- { value: "openai/gpt-5", name: "GPT-5", description: "400K ctx, $1.25/M" },
439
- { value: "google/gemini-2.5-flash", name: "Gemini 2.5 Flash", description: "1M ctx, $0.30/M" },
440
- {
441
- value: "deepseek/deepseek-r1",
442
- name: "DeepSeek R1",
443
- description: "Reasoning, 64K ctx, $0.70/M"
444
- },
445
- { value: "x-ai/grok-4", name: "Grok 4", description: "256K ctx, $3/M" }
446
- ],
447
- moonshot: [
448
- { value: "kimi-k2.5", name: "Kimi K2.5", description: "Free, 256K ctx, multimodal" },
449
- {
450
- value: "kimi-k2-thinking",
451
- name: "Kimi K2 Thinking",
452
- description: "Free, 256K ctx, reasoning"
453
- }
454
- ],
455
- mistral: [
456
- {
457
- value: "devstral-small-2507",
458
- name: "Devstral Small",
459
- description: "Coding, 128K ctx, $0.10/M"
460
- },
461
- {
462
- value: "devstral-medium-latest",
463
- name: "Devstral Medium",
464
- description: "Coding, 262K ctx, $0.40/M"
465
- },
466
- {
467
- value: "mistral-large-latest",
468
- name: "Mistral Large",
469
- description: "General, 128K ctx, $2/M"
470
- },
471
- {
472
- value: "magistral-small",
473
- name: "Magistral Small",
474
- description: "Reasoning, 128K ctx, $0.50/M"
475
- }
476
- ]
477
- };
478
383
  async function onboardCommand(options = {}) {
479
384
  if (options.ui) {
480
- const { SetupServer } = await import("../setup-server-C7ZTPHD5.js");
385
+ const { SetupServer } = await import("../setup-server-YHYJLAMA.js");
481
386
  const port = parseInt(options.uiPort || "7777") || 7777;
482
387
  const url = `http://localhost:${port}/setup`;
483
388
  const blue2 = "\x1B[34m";
@@ -532,9 +437,7 @@ ${blue2} \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25
532
437
  }
533
438
  }
534
439
  async function runInteractiveOnboarding(options, prompter) {
535
- let selectedFlow = "quick";
536
440
  let selectedProvider = "anthropic";
537
- const dealsEnabled = true;
538
441
  let selectedModel = "";
539
442
  let apiKey = "";
540
443
  let apiId = 0;
@@ -550,8 +453,6 @@ async function runInteractiveOnboarding(options, prompter) {
550
453
  let requireMention = true;
551
454
  let maxAgenticIterations = "5";
552
455
  let cocoonInstance = 1e4;
553
- let buyMaxFloorPercent = 100;
554
- let sellMinFloorPercent = 105;
555
456
  console.clear();
556
457
  console.log();
557
458
  console.log(wizardFrame(0, STEPS));
@@ -578,7 +479,8 @@ async function runInteractiveOnboarding(options, prompter) {
578
479
  spinner.start(DIM("Creating workspace..."));
579
480
  const workspace = await ensureWorkspace({
580
481
  workspaceDir: options.workspace,
581
- ensureTemplates: true
482
+ ensureTemplates: true,
483
+ silent: true
582
484
  });
583
485
  const isNew = isNewWorkspace(workspace);
584
486
  spinner.succeed(DIM(`Workspace: ${workspace.root}`));
@@ -606,20 +508,7 @@ async function runInteractiveOnboarding(options, prompter) {
606
508
  const updated = identity.replace("[Your name - pick one or ask your human]", agentName.trim());
607
509
  writeFileSync(workspace.identityPath, updated, "utf-8");
608
510
  }
609
- selectedFlow = await select({
610
- message: "Installation mode",
611
- default: "quick",
612
- theme: inquirerTheme,
613
- choices: [
614
- {
615
- value: "quick",
616
- name: "\u26A1 QuickStart",
617
- description: "Minimal configuration (recommended)"
618
- },
619
- { value: "advanced", name: "\u2699 Advanced", description: "Detailed configuration" }
620
- ]
621
- });
622
- STEPS[0].value = `${agentName} (${selectedFlow})`;
511
+ STEPS[0].value = agentName;
623
512
  redraw(1);
624
513
  const providers = getSupportedProviders();
625
514
  selectedProvider = await select({
@@ -686,6 +575,56 @@ Teleton will connect to ${localBaseUrl}`,
686
575
  TON
687
576
  );
688
577
  STEPS[1].value = `${providerMeta.displayName} ${DIM(localBaseUrl)}`;
578
+ } else if (selectedProvider === "claude-code") {
579
+ let detected = false;
580
+ try {
581
+ const key = getClaudeCodeApiKey();
582
+ const valid = isClaudeCodeTokenValid();
583
+ apiKey = "";
584
+ detected = true;
585
+ const masked = key.length > 16 ? key.slice(0, 12) + "..." + key.slice(-4) : "***";
586
+ noteBox(
587
+ `Credentials auto-detected from Claude Code
588
+ Key: ${masked}
589
+ Status: ${valid ? GREEN("valid \u2713") : "expired (will refresh on use)"}
590
+ Token will auto-refresh when it expires.`,
591
+ "Claude Code",
592
+ TON
593
+ );
594
+ await confirm({
595
+ message: "Continue with auto-detected credentials?",
596
+ default: true,
597
+ theme: inquirerTheme
598
+ });
599
+ } catch (err) {
600
+ if (err instanceof CancelledError) throw err;
601
+ prompter.warn(
602
+ "Claude Code credentials not found. Make sure Claude Code is installed and authenticated (claude login)."
603
+ );
604
+ const useFallback = await confirm({
605
+ message: "Enter an API key manually instead?",
606
+ default: true,
607
+ theme: inquirerTheme
608
+ });
609
+ if (useFallback) {
610
+ apiKey = await password({
611
+ message: `Anthropic API Key (fallback)`,
612
+ theme: inquirerTheme,
613
+ validate: (value = "") => {
614
+ if (!value || value.trim().length === 0) return "API key is required";
615
+ return true;
616
+ }
617
+ });
618
+ } else {
619
+ throw new CancelledError();
620
+ }
621
+ }
622
+ if (detected) {
623
+ STEPS[1].value = `${providerMeta.displayName} ${DIM("auto-detected \u2713")}`;
624
+ } else {
625
+ const maskedKey = apiKey.length > 10 ? apiKey.slice(0, 6) + "..." + apiKey.slice(-4) : "***";
626
+ STEPS[1].value = `${providerMeta.displayName} ${DIM(maskedKey)}`;
627
+ }
689
628
  } else {
690
629
  const envApiKey = process.env.TELETON_API_KEY;
691
630
  if (options.apiKey) {
@@ -719,62 +658,9 @@ Get it at: ${providerMeta.consoleUrl}`,
719
658
  const maskedKey = apiKey.length > 10 ? apiKey.slice(0, 6) + "..." + apiKey.slice(-4) : "***";
720
659
  STEPS[1].value = `${providerMeta.displayName} ${DIM(maskedKey)}`;
721
660
  }
722
- redraw(2);
723
- noteBox(
724
- "You need Telegram credentials from https://my.telegram.org/apps\nCreate an application and note the API ID and API Hash",
725
- "Telegram",
726
- TON
727
- );
728
- const envApiId = process.env.TELETON_TG_API_ID;
729
- const envApiHash = process.env.TELETON_TG_API_HASH;
730
- const envPhone = process.env.TELETON_TG_PHONE;
731
- const apiIdStr = options.apiId ? options.apiId.toString() : await input({
732
- message: envApiId ? "API ID (from env)" : "API ID (from my.telegram.org)",
733
- default: envApiId,
734
- theme: inquirerTheme,
735
- validate: (value) => {
736
- if (!value || isNaN(parseInt(value))) return "Invalid API ID (must be a number)";
737
- return true;
738
- }
739
- });
740
- apiId = parseInt(apiIdStr);
741
- apiHash = options.apiHash ? options.apiHash : await input({
742
- message: envApiHash ? "API Hash (from env)" : "API Hash (from my.telegram.org)",
743
- default: envApiHash,
744
- theme: inquirerTheme,
745
- validate: (value) => {
746
- if (!value || value.length < 10) return "Invalid API Hash";
747
- return true;
748
- }
749
- });
750
- phone = options.phone ? options.phone : await input({
751
- message: envPhone ? "Phone number (from env)" : "Phone number (international format)",
752
- default: envPhone,
753
- theme: inquirerTheme,
754
- validate: (value) => {
755
- if (!value || !value.startsWith("+")) return "Must start with +";
756
- return true;
757
- }
758
- });
759
- noteBox(
760
- "To get your Telegram User ID:\n1. Open @userinfobot on Telegram\n2. Send /start\n3. Note the ID displayed",
761
- "User ID",
762
- TON
763
- );
764
- const userIdStr = options.userId ? options.userId.toString() : await input({
765
- message: "Your Telegram User ID (for admin rights)",
766
- theme: inquirerTheme,
767
- validate: (value) => {
768
- if (!value || isNaN(parseInt(value))) return "Invalid User ID";
769
- return true;
770
- }
771
- });
772
- userId = parseInt(userIdStr);
773
- STEPS[2].value = `${phone} (ID: ${userId})`;
774
- redraw(3);
775
661
  selectedModel = providerMeta.defaultModel;
776
- if (selectedFlow === "advanced" && selectedProvider !== "cocoon" && selectedProvider !== "local") {
777
- const providerModels = MODEL_OPTIONS[selectedProvider] || [];
662
+ if (selectedProvider !== "cocoon" && selectedProvider !== "local") {
663
+ const providerModels = getModelsForProvider(selectedProvider);
778
664
  const modelChoices = [
779
665
  ...providerModels,
780
666
  { value: "__custom__", name: "Custom", description: "Enter a model ID manually" }
@@ -795,78 +681,70 @@ Get it at: ${providerMeta.consoleUrl}`,
795
681
  } else {
796
682
  selectedModel = modelChoice;
797
683
  }
798
- dmPolicy = await select({
799
- message: "DM policy (private messages)",
800
- default: "open",
801
- theme: inquirerTheme,
802
- choices: [
803
- { value: "open", name: "Open", description: "Reply to everyone" },
804
- { value: "allowlist", name: "Allowlist", description: "Only specific users" },
805
- { value: "disabled", name: "Disabled", description: "No DM replies" }
806
- ]
807
- });
808
- groupPolicy = await select({
809
- message: "Group policy",
810
- default: "open",
811
- theme: inquirerTheme,
812
- choices: [
813
- { value: "open", name: "Open", description: "Reply in all groups" },
814
- { value: "allowlist", name: "Allowlist", description: "Only specific groups" },
815
- { value: "disabled", name: "Disabled", description: "No group replies" }
816
- ]
817
- });
818
- requireMention = await confirm({
819
- message: "Require @mention in groups?",
820
- default: true,
821
- theme: inquirerTheme
822
- });
823
- maxAgenticIterations = await input({
824
- message: "Max agentic iterations (tool call loops per message)",
825
- default: "5",
826
- theme: inquirerTheme,
827
- validate: (v) => {
828
- const n = parseInt(v, 10);
829
- return !isNaN(n) && n >= 1 && n <= 50 ? true : "Must be 1\u201350";
830
- }
831
- });
832
684
  const modelLabel = providerModels.find((m) => m.value === selectedModel)?.name ?? selectedModel;
833
- STEPS[3].value = `${modelLabel}, ${dmPolicy}/${groupPolicy}`;
834
- } else {
835
- STEPS[3].value = `${selectedModel} (defaults)`;
685
+ STEPS[1].value = `${STEPS[1].value ?? providerMeta.displayName}, ${modelLabel}`;
836
686
  }
837
- redraw(4);
838
- const extras = [];
839
- if (dealsEnabled) {
840
- const customizeStrategy = await confirm({
841
- message: `Customize trading thresholds? ${DIM("(default: buy \u2264 floor, sell \u2265 floor +5%)")}`,
842
- default: false,
843
- theme: inquirerTheme
844
- });
845
- if (customizeStrategy) {
846
- const buyInput = await input({
847
- message: "Max buy price (% of floor price)",
848
- default: "100",
849
- theme: inquirerTheme,
850
- validate: (v) => {
851
- const n = parseInt(v, 10);
852
- return !isNaN(n) && n >= 50 && n <= 150 ? true : "Must be 50\u2013150";
853
- }
854
- });
855
- buyMaxFloorPercent = parseInt(buyInput, 10);
856
- const sellInput = await input({
857
- message: "Min sell price (% of floor price)",
858
- default: "105",
859
- theme: inquirerTheme,
860
- validate: (v) => {
861
- const n = parseInt(v, 10);
862
- return !isNaN(n) && n >= 100 && n <= 200 ? true : "Must be 100\u2013200";
863
- }
864
- });
865
- sellMinFloorPercent = parseInt(sellInput, 10);
687
+ redraw(2);
688
+ noteBox(
689
+ "To get your Telegram User ID:\n1. Open @userinfobot on Telegram\n2. Send /start\n3. Note the ID displayed",
690
+ "User ID",
691
+ TON
692
+ );
693
+ const userIdStr = options.userId ? options.userId.toString() : await input({
694
+ message: "Your Telegram User ID (for admin rights)",
695
+ theme: inquirerTheme,
696
+ validate: (value) => {
697
+ if (!value || isNaN(parseInt(value))) return "Invalid User ID";
698
+ return true;
866
699
  }
700
+ });
701
+ userId = parseInt(userIdStr);
702
+ dmPolicy = await select({
703
+ message: "DM policy (private messages)",
704
+ default: "open",
705
+ theme: inquirerTheme,
706
+ choices: [
707
+ { value: "open", name: "Open", description: "Reply to everyone" },
708
+ { value: "allowlist", name: "Allowlist", description: "Only specific users" },
709
+ { value: "disabled", name: "Disabled", description: "No DM replies" }
710
+ ]
711
+ });
712
+ groupPolicy = await select({
713
+ message: "Group policy",
714
+ default: "open",
715
+ theme: inquirerTheme,
716
+ choices: [
717
+ { value: "open", name: "Open", description: "Reply in all groups" },
718
+ { value: "allowlist", name: "Allowlist", description: "Only specific groups" },
719
+ { value: "disabled", name: "Disabled", description: "No group replies" }
720
+ ]
721
+ });
722
+ requireMention = await confirm({
723
+ message: "Require @mention in groups?",
724
+ default: true,
725
+ theme: inquirerTheme
726
+ });
727
+ maxAgenticIterations = await input({
728
+ message: "Max agentic iterations (tool call loops per message)",
729
+ default: "5",
730
+ theme: inquirerTheme,
731
+ validate: (v) => {
732
+ const n = parseInt(v, 10);
733
+ return !isNaN(n) && n >= 1 && n <= 50 ? true : "Must be 1\u201350";
734
+ }
735
+ });
736
+ STEPS[2].value = `${dmPolicy}/${groupPolicy}`;
737
+ redraw(3);
738
+ const extras = [];
739
+ const setupBot = await confirm({
740
+ message: `Add a Telegram bot token? ${DIM("(recommended \u2014 enables deals & inline buttons)")}`,
741
+ default: true,
742
+ theme: inquirerTheme
743
+ });
744
+ if (setupBot) {
867
745
  noteBox(
868
746
  "Create a bot with @BotFather on Telegram:\n1. Send /newbot and follow the instructions\n2. Copy the bot token\n3. Enable inline mode: /setinline on the bot",
869
- "Deals Bot",
747
+ "Bot Token",
870
748
  TON
871
749
  );
872
750
  const tokenInput = await password({
@@ -887,6 +765,7 @@ Get it at: ${providerMeta.consoleUrl}`,
887
765
  botToken = tokenInput;
888
766
  botUsername = data.result.username;
889
767
  spinner.succeed(DIM(`Bot verified: @${botUsername}`));
768
+ extras.push("Bot");
890
769
  }
891
770
  } catch {
892
771
  spinner.warn(DIM("Could not validate bot token (network error) \u2014 saving anyway"));
@@ -900,8 +779,8 @@ Get it at: ${providerMeta.consoleUrl}`,
900
779
  }
901
780
  });
902
781
  botUsername = usernameInput;
782
+ extras.push("Bot");
903
783
  }
904
- extras.push("Deals");
905
784
  }
906
785
  const setupTonapi = await confirm({
907
786
  message: `Add a TonAPI key? ${DIM("(optional, recommended for 10x rate limits)")}`,
@@ -947,8 +826,8 @@ Get it at: ${providerMeta.consoleUrl}`,
947
826
  tavilyApiKey = keyInput;
948
827
  extras.push("Tavily");
949
828
  }
950
- STEPS[4].value = extras.length ? extras.join(", ") : "defaults";
951
- redraw(5);
829
+ STEPS[3].value = extras.length ? extras.join(", ") : "defaults";
830
+ redraw(4);
952
831
  let wallet;
953
832
  const existingWallet = walletExists() ? loadWallet() : null;
954
833
  if (existingWallet) {
@@ -989,10 +868,38 @@ Get it at: ${providerMeta.consoleUrl}`,
989
868
  spinner.succeed(DIM("New TON wallet generated"));
990
869
  }
991
870
  } else {
992
- spinner.start(DIM("Generating TON wallet..."));
993
- wallet = await generateWallet();
994
- saveWallet(wallet);
995
- spinner.succeed(DIM("TON wallet generated"));
871
+ const walletAction = await select({
872
+ message: "TON Wallet",
873
+ default: "generate",
874
+ theme: inquirerTheme,
875
+ choices: [
876
+ {
877
+ value: "generate",
878
+ name: "Generate new wallet",
879
+ description: "Create a fresh TON wallet"
880
+ },
881
+ { value: "import", name: "Import from mnemonic", description: "Restore from 24-word seed" }
882
+ ]
883
+ });
884
+ if (walletAction === "import") {
885
+ const mnemonicInput = await input({
886
+ message: "Enter your 24-word mnemonic (space-separated)",
887
+ theme: inquirerTheme,
888
+ validate: (value = "") => {
889
+ const words = value.trim().split(/\s+/);
890
+ return words.length === 24 ? true : `Expected 24 words, got ${words.length}`;
891
+ }
892
+ });
893
+ spinner.start(DIM("Importing wallet..."));
894
+ wallet = await importWallet(mnemonicInput.trim().split(/\s+/));
895
+ saveWallet(wallet);
896
+ spinner.succeed(DIM(`Wallet imported: ${wallet.address}`));
897
+ } else {
898
+ spinner.start(DIM("Generating TON wallet..."));
899
+ wallet = await generateWallet();
900
+ saveWallet(wallet);
901
+ spinner.succeed(DIM("TON wallet generated"));
902
+ }
996
903
  }
997
904
  if (!existingWallet || wallet !== existingWallet) {
998
905
  const W = FRAME_WIDTH;
@@ -1029,8 +936,51 @@ Get it at: ${providerMeta.consoleUrl}`,
1029
936
  console.log(RED(" \u2502") + " ".repeat(W) + RED("\u2502"));
1030
937
  console.log(RED(` \u2514${"\u2500".repeat(W)}\u2518`));
1031
938
  console.log();
939
+ await confirm({
940
+ message: "I have written down my seed phrase",
941
+ default: true,
942
+ theme: inquirerTheme
943
+ });
1032
944
  }
1033
- STEPS[5].value = `${wallet.address.slice(0, 8)}...${wallet.address.slice(-4)}`;
945
+ STEPS[4].value = `${wallet.address.slice(0, 8)}...${wallet.address.slice(-4)}`;
946
+ redraw(5);
947
+ noteBox(
948
+ 'To get your API credentials:\n\n 1. Go to https://my.telegram.org/apps\n 2. Log in with your phone number\n 3. Click "API development tools"\n 4. Create an application (any name/short name works)\n 5. Copy the API ID (number) and API Hash (hex string)\n\n\u26A0 Do NOT use a VPN \u2014 Telegram will block the login page.',
949
+ "Telegram",
950
+ TON
951
+ );
952
+ const envApiId = process.env.TELETON_TG_API_ID;
953
+ const envApiHash = process.env.TELETON_TG_API_HASH;
954
+ const envPhone = process.env.TELETON_TG_PHONE;
955
+ const apiIdStr = options.apiId ? options.apiId.toString() : await input({
956
+ message: envApiId ? "API ID (from env)" : "API ID (from my.telegram.org)",
957
+ default: envApiId,
958
+ theme: inquirerTheme,
959
+ validate: (value) => {
960
+ if (!value || isNaN(parseInt(value))) return "Invalid API ID (must be a number)";
961
+ return true;
962
+ }
963
+ });
964
+ apiId = parseInt(apiIdStr);
965
+ apiHash = options.apiHash ? options.apiHash : await input({
966
+ message: envApiHash ? "API Hash (from env)" : "API Hash (from my.telegram.org)",
967
+ default: envApiHash,
968
+ theme: inquirerTheme,
969
+ validate: (value) => {
970
+ if (!value || value.length < 10) return "Invalid API Hash";
971
+ return true;
972
+ }
973
+ });
974
+ phone = options.phone ? options.phone : await input({
975
+ message: envPhone ? "Phone number (from env)" : "Phone number (international format)",
976
+ default: envPhone,
977
+ theme: inquirerTheme,
978
+ validate: (value) => {
979
+ if (!value || !value.startsWith("+")) return "Must start with +";
980
+ return true;
981
+ }
982
+ });
983
+ STEPS[5].value = phone;
1034
984
  redraw(6);
1035
985
  const config = {
1036
986
  meta: {
@@ -1078,16 +1028,11 @@ Get it at: ${providerMeta.consoleUrl}`,
1078
1028
  },
1079
1029
  storage: {
1080
1030
  sessions_file: `${workspace.root}/sessions.json`,
1081
- pairing_file: `${workspace.root}/pairing.json`,
1082
1031
  memory_file: `${workspace.root}/memory.json`,
1083
1032
  history_limit: 100
1084
1033
  },
1085
1034
  embedding: { provider: "local" },
1086
- deals: DealsConfigSchema.parse({
1087
- enabled: dealsEnabled,
1088
- buy_max_floor_percent: buyMaxFloorPercent,
1089
- sell_min_floor_percent: sellMinFloorPercent
1090
- }),
1035
+ deals: DealsConfigSchema.parse({ enabled: !!botToken }),
1091
1036
  webui: {
1092
1037
  enabled: false,
1093
1038
  port: 7777,
@@ -1239,7 +1184,6 @@ async function runNonInteractiveOnboarding(options, prompter) {
1239
1184
  },
1240
1185
  storage: {
1241
1186
  sessions_file: `${workspace.root}/sessions.json`,
1242
- pairing_file: `${workspace.root}/pairing.json`,
1243
1187
  memory_file: `${workspace.root}/memory.json`,
1244
1188
  history_limit: 100
1245
1189
  },
@@ -8,8 +8,9 @@ import {
8
8
  loadContextFromTranscript,
9
9
  registerCocoonModels,
10
10
  registerLocalModels
11
- } from "./chunk-ND2X5FWB.js";
12
- import "./chunk-LRCPA7SC.js";
11
+ } from "./chunk-5PLZ3KSO.js";
12
+ import "./chunk-JQDLW7IE.js";
13
+ import "./chunk-RMLQS3X6.js";
13
14
  import "./chunk-OCLG5GKI.js";
14
15
  import "./chunk-VAUJSSD3.js";
15
16
  import "./chunk-4DU3C27M.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  telegramGetMyGiftsExecutor,
3
3
  telegramGetMyGiftsTool
4
- } from "./chunk-UDD7FYOU.js";
4
+ } from "./chunk-WIKM24GZ.js";
5
5
  import "./chunk-XBE4JB7C.js";
6
6
  import "./chunk-RCMD3U65.js";
7
7
  import "./chunk-QGM4M3NI.js";