heartcode 0.1.27 → 0.1.32
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.
- package/CHANGELOG.md +123 -0
- package/README.md +84 -30
- package/SKILL.md +37 -11
- package/bin/heartcode.js +252 -56
- package/package.json +1 -1
- package/prompts/agent.md +131 -22
- package/src/agent.js +498 -77
- package/src/background.js +105 -0
- package/src/client.js +14 -3
- package/src/config.js +1 -1
- package/src/guided.js +7 -2
- package/src/headless.js +10 -4
- package/src/memory.js +6 -2
- package/src/research.js +142 -0
- package/src/sessions.js +4 -1
- package/src/settings.html +331 -76
- package/src/settings.js +73 -0
- package/src/telegram.js +81 -0
- package/src/tools.js +163 -53
- package/src/ui.js +235 -34
- package/src/web.js +150 -40
package/src/settings.html
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
--accent: #16824c; --accent-soft: #e8f5ee; --on-accent: #ffffff;
|
|
17
17
|
--brand: var(--accent); --brand-soft: var(--accent-soft); --on-brand: var(--on-accent);
|
|
18
18
|
--ok: #1d8a4b; --ok-soft: #e7f5ec; --err: #d1242f; --err-soft: #fdecee;
|
|
19
|
+
--warn: #a16207; /* in progress, or needs a look: not green (works) and not red (broken) */
|
|
19
20
|
--ring: 0 0 0 3px rgba(22, 130, 76, .18);
|
|
20
21
|
--shadow: 0 1px 2px rgba(20, 22, 30, .04), 0 8px 24px rgba(20, 22, 30, .06);
|
|
21
22
|
--shadow-pop: 0 24px 64px rgba(20, 22, 30, .18), 0 2px 6px rgba(20, 22, 30, .06);
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
--line: #23252c; --line-strong: #2f323a; --hover: #1c1e24; --input: #101115;
|
|
32
33
|
--accent: #5ccf8a; --accent-soft: rgba(92, 207, 138, .13); --on-accent: #07140d;
|
|
33
34
|
--ok: #62cf8b; --ok-soft: rgba(98, 207, 139, .12); --err: #ff7a7a; --err-soft: rgba(255, 122, 122, .12);
|
|
35
|
+
--warn: #e3b341;
|
|
34
36
|
--ring: 0 0 0 3px rgba(92, 207, 138, .25);
|
|
35
37
|
--shadow: 0 1px 2px rgba(0, 0, 0, .3);
|
|
36
38
|
--shadow-pop: 0 28px 72px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .03);
|
|
@@ -42,6 +44,7 @@
|
|
|
42
44
|
--line: #23252c; --line-strong: #2f323a; --hover: #1c1e24; --input: #101115;
|
|
43
45
|
--accent: #5ccf8a; --accent-soft: rgba(92, 207, 138, .13); --on-accent: #07140d;
|
|
44
46
|
--ok: #62cf8b; --ok-soft: rgba(98, 207, 139, .12); --err: #ff7a7a; --err-soft: rgba(255, 122, 122, .12);
|
|
47
|
+
--warn: #e3b341;
|
|
45
48
|
--ring: 0 0 0 3px rgba(92, 207, 138, .25);
|
|
46
49
|
--shadow: 0 1px 2px rgba(0, 0, 0, .3);
|
|
47
50
|
--shadow-pop: 0 28px 72px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .03);
|
|
@@ -69,15 +72,24 @@
|
|
|
69
72
|
nav a.on::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
|
|
70
73
|
nav a .ic { width: 18px; text-align: center; opacity: .7; font-size: 13px; }
|
|
71
74
|
nav a.on .ic { color: var(--accent); opacity: 1; }
|
|
75
|
+
.nav-group { height: 1px; margin: 10px 12px; background: var(--line); }
|
|
76
|
+
.nav-group:first-child { display: none; }
|
|
77
|
+
.subtabs { display: flex; gap: 4px; margin: -4px 0 18px; border-bottom: 1px solid var(--line); }
|
|
78
|
+
.subtabs a { position: relative; padding: 8px 12px 10px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 13.5px; transition: color .15s; }
|
|
79
|
+
.subtabs a:hover { color: var(--text); }
|
|
80
|
+
.subtabs a.on { color: var(--text); font-weight: 600; }
|
|
81
|
+
.subtabs a.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
|
|
82
|
+
.subtabs a .count { margin-left: 6px; font-size: 11.5px; color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
72
83
|
nav a .count { margin-left: auto; font-size: 11.5px; color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
73
84
|
.using:empty { visibility: hidden; } /* until your settings are in */
|
|
74
85
|
.using { margin: auto 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; background: var(--panel); }
|
|
75
86
|
.using .k { color: var(--faint); display: block; }
|
|
76
87
|
.using b { display: block; font-family: var(--mono); font-size: 12.5px; font-weight: 600; word-break: break-all; margin: 3px 0 2px; color: var(--text); }
|
|
77
88
|
.using a { font-weight: 600; }
|
|
78
|
-
|
|
79
|
-
.theme-
|
|
80
|
-
.
|
|
89
|
+
/* light or dark: one button at the top right of the page */
|
|
90
|
+
.theme-btn { position: absolute; top: 18px; right: 22px; z-index: 5; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
|
|
91
|
+
.theme-btn:hover { color: var(--text); }
|
|
92
|
+
.theme-btn svg { width: 18px; height: 18px; }
|
|
81
93
|
main { padding: 36px 44px 72px; width: 100%; max-width: 1640px; min-width: 0; }
|
|
82
94
|
.page { display: none; }
|
|
83
95
|
.page.on { display: block; animation: page-in .22s ease-out; }
|
|
@@ -316,7 +328,7 @@
|
|
|
316
328
|
.olist .test .spin { flex: none; }
|
|
317
329
|
.olist .test button { flex: none; }
|
|
318
330
|
.olist .test.ok { color: var(--ok); }
|
|
319
|
-
.olist .test.warn { color: var(--
|
|
331
|
+
.olist .test.warn { color: var(--warn); }
|
|
320
332
|
dialog { width: 70vw; max-width: none; max-height: calc(100vh - 32px); overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); padding: 26px 28px 24px; box-shadow: var(--shadow-pop); }
|
|
321
333
|
dialog[open] { animation: pop-in .18s cubic-bezier(.2, .8, .3, 1); }
|
|
322
334
|
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
|
|
@@ -330,7 +342,7 @@
|
|
|
330
342
|
#pr-list li.dragging { opacity: .4; }
|
|
331
343
|
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
|
|
332
344
|
.olist .test.failed { color: var(--err); }
|
|
333
|
-
.olist .test.testing, .olist .test.waiting { color: var(--
|
|
345
|
+
.olist .test.testing, .olist .test.waiting { color: var(--warn); }
|
|
334
346
|
.olist .test button { padding: 0 7px; font-size: 11px; }
|
|
335
347
|
.spin { width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
|
|
336
348
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
@@ -404,7 +416,7 @@
|
|
|
404
416
|
.mtable .yes { color: var(--ok); }
|
|
405
417
|
.mtable .no { color: var(--faint); }
|
|
406
418
|
.mtable .src { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
|
|
407
|
-
.mtable .src.warn { color: var(--
|
|
419
|
+
.mtable .src.warn { color: var(--warn); }
|
|
408
420
|
.mtable button { padding: 2px 8px; font-size: 11.5px; border-color: transparent; background: transparent; color: var(--muted); }
|
|
409
421
|
.mtable li:hover button, .mtable li.picked button { border-color: var(--line-strong); background: var(--panel); color: var(--text); }
|
|
410
422
|
.mtable li:hover button.danger { color: var(--err); }
|
|
@@ -412,7 +424,10 @@
|
|
|
412
424
|
.mtable .try .msg { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
413
425
|
.mtable .try.ok { color: var(--ok); }
|
|
414
426
|
.mtable .try.bad { color: var(--err); }
|
|
415
|
-
.mtable .try.going { color: var(--
|
|
427
|
+
.mtable .try.going { color: var(--warn); }
|
|
428
|
+
.mtable .try.going .msg { animation: pulse 1.4s ease-in-out infinite; }
|
|
429
|
+
@keyframes pulse { 50% { opacity: .45; } }
|
|
430
|
+
@media (prefers-reduced-motion: reduce) { .mtable .try.going .msg { animation: none; } }
|
|
416
431
|
.mt-empty { padding: 28px 18px; color: var(--muted); }
|
|
417
432
|
.olist .grip { cursor: grab; color: var(--faint); padding: 0 2px; user-select: none; }
|
|
418
433
|
.olist .n { font-weight: 800; color: var(--brand); min-width: 24px; }
|
|
@@ -443,9 +458,42 @@
|
|
|
443
458
|
|
|
444
459
|
/* choices as cards (permissions, colors) */
|
|
445
460
|
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
|
|
461
|
+
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
462
|
+
.choices.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
463
|
+
/* General: cards in pairs on rows that line up (related ones side by side: permissions | colors,
|
|
464
|
+
behavior | model, voice | tools), the full width; one column when there isn't room for two */
|
|
465
|
+
.settings-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
|
|
466
|
+
@media (max-width: 1280px) { .settings-col { grid-template-columns: minmax(0, 1fr); } }
|
|
467
|
+
.settings-col .card h2 { margin-bottom: 4px; }
|
|
468
|
+
.settings-col #g-toggles { margin-top: 8px; }
|
|
469
|
+
.setting { display: flex; align-items: center; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
|
|
470
|
+
.setting:last-child { border-bottom: 0; padding-bottom: 2px; }
|
|
471
|
+
.setting .t { flex: 1; min-width: 0; cursor: default; }
|
|
472
|
+
.setting .t b { display: block; font-weight: 600; }
|
|
473
|
+
.setting .t span { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.45; text-wrap: pretty; }
|
|
474
|
+
.setting select, .setting input { flex: none; width: 240px; }
|
|
475
|
+
.settings-col .card.wide { grid-column: 1 / -1; }
|
|
476
|
+
.ws-url { display: flex; gap: 8px; margin-top: 10px; }
|
|
477
|
+
.ws-url input { flex: 1; min-width: 0; }
|
|
478
|
+
.ws-addr { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
|
|
479
|
+
.ws-addr code { font: 12.5px/1.4 var(--mono, ui-monospace, Menlo, monospace); color: var(--text); background: var(--panel-2, color-mix(in srgb, var(--muted) 12%, transparent)); padding: 3px 8px; border-radius: 6px; word-break: break-all; }
|
|
480
|
+
.ws-row.mine { align-items: flex-start; }
|
|
481
|
+
.ws-row.mine .n, .ws-row.mine .mv, .ws-row.mine > .sw { margin-top: 2px; }
|
|
482
|
+
.ws-list { margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
|
|
483
|
+
.ws-row { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
|
|
484
|
+
.ws-row:last-child { border-bottom: 0; }
|
|
485
|
+
.ws-row .n { width: 22px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
|
|
486
|
+
.ws-row .t { flex: 1; min-width: 0; }
|
|
487
|
+
.ws-row .t b { font-weight: 600; }
|
|
488
|
+
.ws-row .t span { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
|
|
489
|
+
.ws-row.off .t > b, .ws-row.off .t > span, .ws-row.off .n { opacity: .5; } /* not the address box in it */
|
|
490
|
+
.ws-row .mv { display: flex; gap: 4px; }
|
|
491
|
+
.ws-row .mv button { width: 30px; padding: 4px 0; }
|
|
492
|
+
@media (max-width: 640px) { .ws-url { flex-wrap: wrap; } .ws-url input { flex-basis: 100%; } }
|
|
446
493
|
.choice { position: relative; border: 1px solid var(--line-strong); border-radius: 12px; padding: 13px 15px; cursor: pointer; background: var(--panel); transition: border-color .15s, box-shadow .15s, background .15s; }
|
|
447
494
|
.choice:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
|
|
448
|
-
.choice.on { border-color: var(--accent); background: var(--accent-soft)
|
|
495
|
+
.choice.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, var(--panel)); }
|
|
496
|
+
.choice:has(input:focus-visible) { box-shadow: var(--ring); }
|
|
449
497
|
.choice b { display: block; }
|
|
450
498
|
.choice span { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
|
|
451
499
|
.choice input { position: absolute; opacity: 0; }
|
|
@@ -493,17 +541,20 @@
|
|
|
493
541
|
.md { grid-template-columns: 280px minmax(0, 1fr); }
|
|
494
542
|
}
|
|
495
543
|
@media (max-width: 860px) {
|
|
496
|
-
.app { grid-template-columns: minmax(0, 1fr); }
|
|
544
|
+
.app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; } /* the bar on top keeps its height; the page gets the rest */
|
|
497
545
|
aside { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px 8px; }
|
|
498
546
|
.brand { padding: 0 0 8px; }
|
|
499
547
|
nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
|
|
500
548
|
nav a { flex: none; margin: 0; }
|
|
501
549
|
nav a.on::before { display: none; } /* a strip of tabs: the highlighted one is enough */
|
|
502
|
-
nav a .count, .using { display: none; }
|
|
503
|
-
.theme-
|
|
550
|
+
nav a .count, .using, .nav-group { display: none; }
|
|
551
|
+
.theme-btn { top: 10px; right: 12px; }
|
|
504
552
|
main { padding: 20px 16px 60px; }
|
|
505
553
|
.steps { grid-template-columns: 1fr; }
|
|
506
|
-
.choices { grid-template-columns: 1fr; }
|
|
554
|
+
.choices, .choices.three { grid-template-columns: 1fr; }
|
|
555
|
+
.choices.four { grid-template-columns: 1fr 1fr; }
|
|
556
|
+
.setting { flex-direction: column; align-items: stretch; gap: 10px; }
|
|
557
|
+
.setting select, .setting input { width: 100%; }
|
|
507
558
|
.grid, .cols { grid-template-columns: 1fr; }
|
|
508
559
|
.md { grid-template-columns: 1fr; }
|
|
509
560
|
.md .list { position: static; max-height: 300px; }
|
|
@@ -552,6 +603,10 @@
|
|
|
552
603
|
.imp-row { display: flex; align-items: baseline; gap: 10px; padding: 7px 8px; border-radius: var(--radius-s); cursor: pointer; }
|
|
553
604
|
.imp-row:hover { background: var(--hover); }
|
|
554
605
|
.imp-row input { margin: 0; flex: none; align-self: center; }
|
|
606
|
+
.tg-steps { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 14px; line-height: 1.55; }
|
|
607
|
+
.tg-steps li::marker { color: var(--muted); }
|
|
608
|
+
.tg-conn { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
|
|
609
|
+
.opt.tg-off { opacity: .5; }
|
|
555
610
|
.imp-row .imp-label { font-weight: 500; font-family: var(--mono); font-size: 12.5px; flex: none; }
|
|
556
611
|
.imp-row .imp-desc { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
557
612
|
</style>
|
|
@@ -561,20 +616,19 @@
|
|
|
561
616
|
<aside>
|
|
562
617
|
<div class="brand"><span>♥</span> HeartCode <small>settings</small></div>
|
|
563
618
|
<nav id="nav">
|
|
564
|
-
<
|
|
565
|
-
<a href="#models" data-page="models"><span class="ic">☰</span>
|
|
566
|
-
<
|
|
567
|
-
<a href="#
|
|
568
|
-
<a href="#
|
|
569
|
-
<
|
|
570
|
-
<a href="#mcp" data-page="mcp"><span class="ic">⧉</span> MCP servers <span class="count" id="n-mcp"></span></a>
|
|
619
|
+
<div class="nav-group" role="separator"></div>
|
|
620
|
+
<a href="#models" data-page="models" data-tabs="models providers"><span class="ic">☰</span> Models <span class="count" id="n-mine"></span></a>
|
|
621
|
+
<div class="nav-group" role="separator"></div>
|
|
622
|
+
<a href="#general" data-page="general" data-tabs="general statusbar"><span class="ic">⚙</span> General</a>
|
|
623
|
+
<a href="#notify" data-page="notify"><span class="ic">✉</span> Notifications</a>
|
|
624
|
+
<div class="nav-group" role="separator"></div>
|
|
571
625
|
<a href="#skills" data-page="skills"><span class="ic">✦</span> Skills <span class="count" id="n-skills"></span></a>
|
|
572
|
-
<a href="#
|
|
626
|
+
<a href="#mcp" data-page="mcp"><span class="ic">⧉</span> MCP servers <span class="count" id="n-mcp"></span></a>
|
|
627
|
+
<a href="#prompts" data-page="prompts"><span class="ic">✎</span> System prompt</a>
|
|
628
|
+
<div class="nav-group" role="separator"></div>
|
|
629
|
+
<a href="#logging" data-page="logging" data-tabs="logging files"><span class="ic">▤</span> Advanced <span class="count" id="n-failed"></span></a>
|
|
573
630
|
</nav>
|
|
574
631
|
<div class="using" id="using"></div>
|
|
575
|
-
<div class="seg theme-pick" id="theme-pick" role="radiogroup" aria-label="Light or dark">
|
|
576
|
-
<label><input type="radio" name="theme-pick" value="system">System</label><label><input type="radio" name="theme-pick" value="light">Light</label><label><input type="radio" name="theme-pick" value="dark">Dark</label>
|
|
577
|
-
</div>
|
|
578
632
|
</aside>
|
|
579
633
|
|
|
580
634
|
<main>
|
|
@@ -582,7 +636,7 @@
|
|
|
582
636
|
<!-- Providers & models -->
|
|
583
637
|
<section class="page" id="page-providers">
|
|
584
638
|
<div class="head">
|
|
585
|
-
<div><h1>Providers
|
|
639
|
+
<div><h1>Providers</h1><p class="lead">Click a model to add it to your list, or tick several. HeartCode tries your list in order: #1 first, the next when one fails.</p></div>
|
|
586
640
|
<div class="head-actions"><button id="p-mine" type="button"></button><button class="primary" id="p-open">+ Add a provider</button></div>
|
|
587
641
|
</div>
|
|
588
642
|
<div class="steps" id="steps"></div>
|
|
@@ -609,9 +663,30 @@
|
|
|
609
663
|
<div class="card mt-card" id="mt"></div>
|
|
610
664
|
</section>
|
|
611
665
|
|
|
666
|
+
<!-- Notifications -->
|
|
667
|
+
<section class="page" id="page-notify">
|
|
668
|
+
<div class="head"><div><h1>Notifications</h1><p class="lead">A message on your phone when HeartCode finishes a task, fails, or needs you, so you can step away while it works.</p></div></div>
|
|
669
|
+
<div class="cols">
|
|
670
|
+
<div class="stack">
|
|
671
|
+
<div class="card">
|
|
672
|
+
<h2>Telegram</h2>
|
|
673
|
+
<p class="sub">Through a bot of your own: only you get its messages.</p>
|
|
674
|
+
<div id="tg-setup"></div>
|
|
675
|
+
</div>
|
|
676
|
+
</div>
|
|
677
|
+
<div class="stack">
|
|
678
|
+
<div class="card">
|
|
679
|
+
<h2>When to send one</h2>
|
|
680
|
+
<p class="sub">Each on its own. A running HeartCode follows changes right away.</p>
|
|
681
|
+
<div id="tg-events"></div>
|
|
682
|
+
</div>
|
|
683
|
+
</div>
|
|
684
|
+
</div>
|
|
685
|
+
</section>
|
|
686
|
+
|
|
612
687
|
<!-- Logging -->
|
|
613
688
|
<section class="page" id="page-logging">
|
|
614
|
-
<div class="head"><div><h1>
|
|
689
|
+
<div class="head"><div><h1>Logs</h1><p class="lead">What HeartCode writes down, for finding out what went wrong. Off unless you switch it on.</p></div><div class="disk" id="l-disk"></div></div>
|
|
615
690
|
<div class="card">
|
|
616
691
|
<div class="log-opts">
|
|
617
692
|
<div>
|
|
@@ -655,48 +730,61 @@
|
|
|
655
730
|
</div>
|
|
656
731
|
</section>
|
|
657
732
|
|
|
658
|
-
<!-- General -->
|
|
733
|
+
<!-- General: one column, a card per topic, every setting saved as it changes -->
|
|
659
734
|
<section class="page" id="page-general">
|
|
660
|
-
<div class="head"><div><h1>General</h1><p class="lead">How HeartCode works for you.
|
|
661
|
-
<div class="
|
|
662
|
-
<div class="
|
|
663
|
-
<
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
<
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
735
|
+
<div class="head"><div><h1>General</h1><p class="lead">How HeartCode works for you. Every change saves on its own, and a running HeartCode picks it up right away.</p></div></div>
|
|
736
|
+
<div class="settings-col">
|
|
737
|
+
<div class="card">
|
|
738
|
+
<h2>Permissions</h2>
|
|
739
|
+
<p class="sub">What HeartCode may do without asking you first. <span class="mono">Shift+Tab</span> in HeartCode switches between these too.</p>
|
|
740
|
+
<div class="choices three" id="g-perm"></div>
|
|
741
|
+
</div>
|
|
742
|
+
<div class="card">
|
|
743
|
+
<h2>Terminal colors</h2>
|
|
744
|
+
<p class="sub">Your own colors on top of one: theme.json in <a href="#files">Advanced → Files</a>.</p>
|
|
745
|
+
<div class="choices four" id="g-theme"></div>
|
|
746
|
+
</div>
|
|
747
|
+
<div class="card">
|
|
748
|
+
<h2>Behavior</h2>
|
|
749
|
+
<div id="g-toggles"></div>
|
|
750
|
+
</div>
|
|
751
|
+
<div class="card">
|
|
752
|
+
<h2>Model</h2>
|
|
753
|
+
<div class="setting">
|
|
754
|
+
<label class="t" for="g-effort"><b>Thinking effort</b><span>How hard a thinking model thinks before it answers.</span></label>
|
|
755
|
+
<select id="g-effort"></select>
|
|
672
756
|
</div>
|
|
673
|
-
<div class="
|
|
674
|
-
<
|
|
675
|
-
<
|
|
676
|
-
<div class="grow"><label class="f" for="g-effort">How hard a thinking model thinks</label><select id="g-effort"></select></div>
|
|
677
|
-
<div class="grow"><label class="f" for="g-context">Context window (tokens)</label><input type="number" id="g-context" min="1" placeholder="as the model says"></div>
|
|
678
|
-
</div>
|
|
679
|
-
<div class="hint">Leave the context window empty unless HeartCode gets it wrong for your model.</div>
|
|
757
|
+
<div class="setting">
|
|
758
|
+
<label class="t" for="g-context"><b>Context window</b><span>How many tokens the model can hold. Leave it on auto unless HeartCode gets it wrong.</span></label>
|
|
759
|
+
<input type="number" id="g-context" min="1" placeholder="Auto">
|
|
680
760
|
</div>
|
|
681
761
|
</div>
|
|
682
|
-
<div class="
|
|
683
|
-
<
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
<
|
|
762
|
+
<div class="card">
|
|
763
|
+
<h2>Voice input</h2>
|
|
764
|
+
<p class="sub">Press Space in an empty input box (or type /voice), talk, and Enter. Your words land in the box.</p>
|
|
765
|
+
<div class="setting">
|
|
766
|
+
<label class="t" for="v-src"><b>Transcribe with</b><span id="v-src-about"></span></label>
|
|
767
|
+
<select id="v-src"></select>
|
|
687
768
|
</div>
|
|
688
|
-
<div class="
|
|
689
|
-
<
|
|
690
|
-
<
|
|
691
|
-
<textarea id="v-text" spellcheck="false" rows="3" placeholder="(whisper-cli on this machine)"></textarea>
|
|
692
|
-
<div class="actions"><button class="primary" id="v-save">Save voice</button></div>
|
|
769
|
+
<div class="setting">
|
|
770
|
+
<label class="t" for="v-model"><b>Model</b><span id="v-model-about"></span></label>
|
|
771
|
+
<input type="text" id="v-model" spellcheck="false" autocomplete="off">
|
|
693
772
|
</div>
|
|
694
|
-
<div class="
|
|
695
|
-
<
|
|
696
|
-
<
|
|
697
|
-
<div id="g-caps"></div>
|
|
773
|
+
<div class="setting">
|
|
774
|
+
<label class="t" for="v-lang"><b>Language</b><span id="v-lang-about"></span></label>
|
|
775
|
+
<input type="text" id="v-lang" spellcheck="false" autocomplete="off">
|
|
698
776
|
</div>
|
|
699
777
|
</div>
|
|
778
|
+
<div class="card">
|
|
779
|
+
<h2>External tools</h2>
|
|
780
|
+
<p class="sub">Some features need a tool on your machine. Ready ones are ticked; the rest say what to install.</p>
|
|
781
|
+
<div id="g-caps"></div>
|
|
782
|
+
</div>
|
|
783
|
+
<div class="card wide">
|
|
784
|
+
<h2>Web search</h2>
|
|
785
|
+
<p class="sub">The engines HeartCode searches with, in this order: it asks the first one, and the next only when that one hasn't found enough, fails, or takes over 3 seconds. None needs a key.</p>
|
|
786
|
+
<div class="ws-list" id="ws-order"></div>
|
|
787
|
+
</div>
|
|
700
788
|
</div>
|
|
701
789
|
</section>
|
|
702
790
|
|
|
@@ -765,7 +853,7 @@
|
|
|
765
853
|
|
|
766
854
|
<!-- Advanced files -->
|
|
767
855
|
<section class="page" id="page-files">
|
|
768
|
-
<div class="head"><div><h1>
|
|
856
|
+
<div class="head"><div><h1>Settings files</h1><p class="lead">The rest of HeartCode's settings, as the files they're kept in (<span class="mono" id="f-home"></span>). A JSON file that doesn't parse isn't saved; save one empty to delete it.</p></div></div>
|
|
769
857
|
<div class="md">
|
|
770
858
|
<div class="list"><div class="items" id="f-items"></div></div>
|
|
771
859
|
<div class="detail" id="f-detail"></div>
|
|
@@ -852,22 +940,32 @@
|
|
|
852
940
|
<div class="actions"><button id="pr-cancel" type="button">Cancel</button><button class="primary" id="pr-save" type="button">Save</button></div>
|
|
853
941
|
</form>
|
|
854
942
|
</dialog>
|
|
943
|
+
<button type="button" class="theme-btn" id="theme-btn"></button>
|
|
855
944
|
<div id="toast" role="status"></div>
|
|
856
945
|
<div id="tip" role="tooltip"></div>
|
|
857
946
|
<script>
|
|
858
947
|
const token = new URLSearchParams(location.search).get('t')
|
|
859
|
-
// Light
|
|
948
|
+
// Light or dark: the button at the top right switches; as the system is set until it's pressed. Kept in
|
|
949
|
+
// this browser (the one thing the page keeps itself).
|
|
860
950
|
{
|
|
861
|
-
const
|
|
862
|
-
const
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
951
|
+
const btn = document.getElementById('theme-btn')
|
|
952
|
+
const system = matchMedia('(prefers-color-scheme: dark)')
|
|
953
|
+
const now = () => document.documentElement.dataset.theme || (system.matches ? 'dark' : 'light')
|
|
954
|
+
const SUN = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="12" cy="12" r="4.2"/><path d="M12 2.5v2.2M12 19.3v2.2M4.6 4.6l1.6 1.6M17.8 17.8l1.6 1.6M2.5 12h2.2M19.3 12h2.2M4.6 19.4l1.6-1.6M17.8 6.2l1.6-1.6"/></svg>'
|
|
955
|
+
const MOON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"><path d="M20.5 14.2A8.5 8.5 0 0 1 9.8 3.5a8.5 8.5 0 1 0 10.7 10.7Z"/></svg>'
|
|
956
|
+
const show = () => {
|
|
957
|
+
const dark = now() === 'dark'
|
|
958
|
+
btn.innerHTML = dark ? SUN : MOON
|
|
959
|
+
btn.title = dark ? 'Light theme' : 'Dark theme'
|
|
960
|
+
btn.setAttribute('aria-label', btn.title)
|
|
961
|
+
}
|
|
962
|
+
btn.addEventListener('click', () => {
|
|
963
|
+
const v = now() === 'dark' ? 'light' : 'dark'
|
|
964
|
+
document.documentElement.dataset.theme = v
|
|
965
|
+
try { localStorage.setItem('heart-theme', v) } catch {}
|
|
869
966
|
show()
|
|
870
967
|
})
|
|
968
|
+
system.addEventListener('change', show)
|
|
871
969
|
show()
|
|
872
970
|
}
|
|
873
971
|
const $ = (id) => document.getElementById(id)
|
|
@@ -953,6 +1051,9 @@ const DOING = {
|
|
|
953
1051
|
'/api/provider/on': 'Switching the provider',
|
|
954
1052
|
'/api/order': 'Saving your models',
|
|
955
1053
|
'/api/mcp/login': 'Signing in — your browser will open',
|
|
1054
|
+
'/api/telegram/connect': 'Checking the token with Telegram',
|
|
1055
|
+
'/api/telegram/test': 'Sending a test message',
|
|
1056
|
+
'/api/search/test': 'Trying a search on your SearXNG',
|
|
956
1057
|
'/api/models-dev': null, // its own strip
|
|
957
1058
|
}
|
|
958
1059
|
let acting = 0
|
|
@@ -1010,12 +1111,13 @@ addEventListener('scroll', drawVirtual, { capture: true, passive: true }) // the
|
|
|
1010
1111
|
addEventListener('resize', drawVirtual)
|
|
1011
1112
|
|
|
1012
1113
|
// pages: one at a time, from the address (#providers…)
|
|
1013
|
-
const PAGES = ['providers', 'models', 'general', 'statusbar', 'logging', 'prompts', 'mcp', 'skills', 'files']
|
|
1114
|
+
const PAGES = ['providers', 'models', 'general', 'statusbar', 'notify', 'logging', 'prompts', 'mcp', 'skills', 'files']
|
|
1014
1115
|
const page = () => (PAGES.includes(location.hash.slice(1)) ? location.hash.slice(1) : 'providers')
|
|
1015
1116
|
function showPage() {
|
|
1016
1117
|
for (const p of PAGES) $('page-' + p).classList.toggle('on', p === page())
|
|
1017
1118
|
$('page-' + page()).querySelector('.head').after(document.querySelector('.job-slot[data-where="page"]')) // what's loading: under this page's title
|
|
1018
|
-
for (const a of document.querySelectorAll('nav a')) a.classList.toggle('on', a.dataset.
|
|
1119
|
+
for (const a of document.querySelectorAll('nav a')) a.classList.toggle('on', (a.dataset.tabs?.split(' ') ?? [a.dataset.page]).includes(page()))
|
|
1120
|
+
for (const a of document.querySelectorAll('.subtabs a')) a.classList.toggle('on', a.dataset.tab === page())
|
|
1019
1121
|
if (S) drawUsing(S)
|
|
1020
1122
|
if (page() === 'logging') drawDisk()
|
|
1021
1123
|
scrollTo(0, 0)
|
|
@@ -1024,6 +1126,16 @@ function showPage() {
|
|
|
1024
1126
|
document.querySelector('nav a.on')?.scrollIntoView({ inline: 'center', block: 'nearest' }) // on a phone the pages scroll sideways
|
|
1025
1127
|
}
|
|
1026
1128
|
addEventListener('hashchange', showPage)
|
|
1129
|
+
// A sidebar item with several pages (data-tabs): a tab bar on top of each of them. Each page keeps
|
|
1130
|
+
// its own address (#providers, #statusbar, #files…), so links to one still open it.
|
|
1131
|
+
const TAB_NAMES = { models: 'Your list', providers: 'Providers', general: 'Settings', statusbar: 'Status bar', logging: 'Logs', files: 'Files' }
|
|
1132
|
+
const TAB_COUNTS = { providers: 'n-providers' } // a count shown on the tab, not the sidebar item
|
|
1133
|
+
for (const a of document.querySelectorAll('nav a[data-tabs]')) {
|
|
1134
|
+
const tabs = a.dataset.tabs.split(' ')
|
|
1135
|
+
for (const p of tabs) {
|
|
1136
|
+
$('page-' + p).prepend(h('div', { className: 'subtabs', role: 'tablist' }, tabs.map((t) => h('a', { href: '#' + t, role: 'tab', 'data-tab': t }, TAB_NAMES[t], TAB_COUNTS[t] ? h('span', { className: 'count', 'data-count': TAB_COUNTS[t] }) : null))))
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1027
1139
|
|
|
1028
1140
|
// A list on the left, the chosen one on the right (prompts, skills, files). Unsaved text in the
|
|
1029
1141
|
// editor is kept per item while you look at others, marked with a dot in the list.
|
|
@@ -1461,7 +1573,7 @@ function drawProviders(s) {
|
|
|
1461
1573
|
catalogShape = shape
|
|
1462
1574
|
markCatalog()
|
|
1463
1575
|
$('m-search').placeholder = `Search ${Object.values(MODELS).reduce((n, m) => n + (m.list?.length ?? 0), 0) || 'all'} models…`
|
|
1464
|
-
|
|
1576
|
+
for (const el of document.querySelectorAll('[data-count="n-providers"]')) el.textContent = s.providers.length || ''
|
|
1465
1577
|
}
|
|
1466
1578
|
// Your models: pick one up (anywhere on it with a mouse, by its ⋮⋮ on a touch screen) and the
|
|
1467
1579
|
// others move aside as it goes; let go and it's saved, already in its place (no jump when the
|
|
@@ -2051,7 +2163,8 @@ function drawGeneral(s) {
|
|
|
2051
2163
|
put($('g-toggles'), Object.entries(s.choices.toggles).map(([k, d]) => h('label', { className: 'opt' },
|
|
2052
2164
|
h('div', { className: 't' }, h('b', { textContent: TOGGLE_INFO[k] ?? k }), h('span', { textContent: d[0].toUpperCase() + d.slice(1) })),
|
|
2053
2165
|
sw({ checked: s.settings[k], onchange: (e) => act('/api/setting', { name: k, value: e.target.checked }, `${TOGGLE_INFO[k] ?? k}: ${e.target.checked ? 'on' : 'off'}`) }))))
|
|
2054
|
-
|
|
2166
|
+
drawVoice(s)
|
|
2167
|
+
drawSearch(s)
|
|
2055
2168
|
put($('g-caps'), ...(s.capabilities || []).map((c) =>
|
|
2056
2169
|
h('div', { className: 'cap' + (c.ok ? '' : ' cap-off') },
|
|
2057
2170
|
h('div', { className: 'cap-h' }, h('span', { className: 'cap-mark', textContent: c.ok ? '✓' : '✗' }), h('b', { textContent: c.name }), h('span', { className: c.ok ? 'tag ok' : 'tag need', textContent: c.ok ? 'ready' : 'needs setup' })),
|
|
@@ -2060,7 +2173,146 @@ function drawGeneral(s) {
|
|
|
2060
2173
|
}
|
|
2061
2174
|
$('g-effort').onchange = (e) => act('/api/setting', { name: 'effort', value: e.target.value }, 'effort saved')
|
|
2062
2175
|
$('g-context').onchange = (e) => act('/api/setting', { name: 'context', value: e.target.value.trim() ? Number(e.target.value) : null }, 'context window saved')
|
|
2063
|
-
|
|
2176
|
+
// Voice: this machine (whisper-cli and a ggml model) or a provider's transcription API, a model and a
|
|
2177
|
+
// language: kept as config's "voice" ({ provider, model, language }; nothing set: this machine).
|
|
2178
|
+
function voiceNow() {
|
|
2179
|
+
try {
|
|
2180
|
+
return S?.voice ? JSON.parse(S.voice) : {}
|
|
2181
|
+
} catch {
|
|
2182
|
+
return {}
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
function drawVoice(s) {
|
|
2186
|
+
const v = voiceNow()
|
|
2187
|
+
const names = (s.providers ?? []).map((p) => p.name)
|
|
2188
|
+
put($('v-src'), h('option', { value: '', textContent: 'This machine (whisper-cli)' }), names.map((n) => h('option', { value: n, textContent: `${n} (its transcription API)` })))
|
|
2189
|
+
$('v-src').value = v.provider && names.includes(v.provider) ? v.provider : ''
|
|
2190
|
+
const remote = Boolean($('v-src').value)
|
|
2191
|
+
$('v-src-about').textContent = remote ? 'Sent to that provider to turn into text: fast, needs its key.' : 'Runs on your computer: private, free, slower. Needs whisper-cli and a model.'
|
|
2192
|
+
$('v-model-about').textContent = remote ? 'Its speech-to-text model, like whisper-large-v3 (Groq) or whisper-1 (OpenAI).' : 'A whisper model file (ggml-….bin). Empty: the best one in ~/.whisper-models.'
|
|
2193
|
+
$('v-lang-about').textContent = remote ? 'What you speak, like en or bn. Empty: worked out from what you say.' : 'What you speak, like en or bn; auto works it out. Empty: English.'
|
|
2194
|
+
$('v-model').placeholder = remote ? 'whisper-large-v3' : 'auto'
|
|
2195
|
+
$('v-lang').placeholder = remote ? 'auto' : 'en'
|
|
2196
|
+
for (const [id, k] of [['v-model', 'model'], ['v-lang', 'language']]) if (document.activeElement !== $(id)) $(id).value = v[k] ?? ''
|
|
2197
|
+
}
|
|
2198
|
+
function saveVoice(what) {
|
|
2199
|
+
const v = { provider: $('v-src').value || undefined, model: $('v-model').value.trim() || undefined, language: $('v-lang').value.trim() || undefined }
|
|
2200
|
+
const set = Object.fromEntries(Object.entries(v).filter(([, x]) => x !== undefined))
|
|
2201
|
+
act('/api/voice', { text: Object.keys(set).length ? JSON.stringify(set) : '' }, what)
|
|
2202
|
+
}
|
|
2203
|
+
$('v-src').onchange = (e) => {
|
|
2204
|
+
$('v-model').value = '' // a local model's path means nothing to a provider, and the other way round
|
|
2205
|
+
saveVoice(`voice: ${e.target.value || 'this machine'}`)
|
|
2206
|
+
}
|
|
2207
|
+
$('v-model').onchange = () => saveVoice('voice model saved')
|
|
2208
|
+
$('v-lang').onchange = () => saveVoice('voice language saved')
|
|
2209
|
+
|
|
2210
|
+
// Web search: the engines in the order they're asked (↑↓), each switchable. Your own SearXNG's address
|
|
2211
|
+
// is typed in its own row: a box with Test and Add while there's none (or Change was pressed), else the
|
|
2212
|
+
// address with Change, Test and Remove.
|
|
2213
|
+
const ENGINE_INFO = {
|
|
2214
|
+
searxng: 'Your own instance: private, and no other site\'s limits. Its JSON API is used when it has it on.',
|
|
2215
|
+
searx: 'Many engines at once, through public instances from searx.space. Broad; some instances are busy.',
|
|
2216
|
+
duckduckgo: 'Broad results from its HTML page. Blocked on some networks.',
|
|
2217
|
+
mwmbl: 'An open, non-profit index of its own. Fast; smaller than the big engines.',
|
|
2218
|
+
stackoverflow: 'Questions and answers: for errors and how-to. Up to 3 results.',
|
|
2219
|
+
npm: 'Packages: for libraries and tools. Up to 3 results.',
|
|
2220
|
+
github: 'Repositories: for projects and examples. Up to 3 results.',
|
|
2221
|
+
}
|
|
2222
|
+
const wsInput = h('input', { type: 'text', placeholder: 'http://192.168.1.10:8888 or https://search.example.com', spellcheck: false, autocomplete: 'off', 'aria-label': 'Your SearXNG address' })
|
|
2223
|
+
let wsEditing = false
|
|
2224
|
+
const wsCancel = () => ((wsEditing = false), wsInput.blur(), drawSearch(S))
|
|
2225
|
+
const wsSave = async (url) => {
|
|
2226
|
+
const r = await act('/api/search', { searxng: url }, url.trim() ? 'your SearXNG saved: it is asked first' : 'your SearXNG removed')
|
|
2227
|
+
if (r) (wsEditing = false), wsInput.blur(), S && drawSearch(S)
|
|
2228
|
+
}
|
|
2229
|
+
const wsTest = async (url) => {
|
|
2230
|
+
const r = await act('/api/search/test', { searxng: url })
|
|
2231
|
+
if (r) toast(`it works: ${r.results} results for a test search`)
|
|
2232
|
+
}
|
|
2233
|
+
wsInput.onkeydown = (e) => {
|
|
2234
|
+
if (e.key === 'Enter') wsSave(wsInput.value) // a block: an on… handler returning false would cancel every other key (typing, pasting)
|
|
2235
|
+
if (e.key === 'Escape' && S?.search?.searxng) wsCancel()
|
|
2236
|
+
}
|
|
2237
|
+
function drawSearch(s) {
|
|
2238
|
+
if (document.activeElement === wsInput) return // typing there: left alone (a redraw would take the box away)
|
|
2239
|
+
const w = s.search ?? { order: [], off: [], names: {} }
|
|
2240
|
+
const save = (order, off, what) => act('/api/search', { order, off }, what)
|
|
2241
|
+
const btn = (text, onclick, cls = 'small') => h('button', { className: cls, type: 'button', textContent: text, onclick })
|
|
2242
|
+
put($('ws-order'), ...w.order.map((n, i) => {
|
|
2243
|
+
const mine = n === 'searxng'
|
|
2244
|
+
const none = mine && !w.searxng
|
|
2245
|
+
const on = !w.off.includes(n) && !none
|
|
2246
|
+
const move = (d) => {
|
|
2247
|
+
const o = [...w.order]
|
|
2248
|
+
;[o[i], o[i + d]] = [o[i + d], o[i]]
|
|
2249
|
+
save(o, w.off, `${w.names[n]}: moved ${d < 0 ? 'up' : 'down'}`)
|
|
2250
|
+
}
|
|
2251
|
+
let extra = null
|
|
2252
|
+
if (mine && (none || wsEditing)) {
|
|
2253
|
+
if (!wsEditing) wsInput.value = ''
|
|
2254
|
+
extra = h('div', { className: 'ws-url' }, wsInput, btn('Test', () => wsTest(wsInput.value), ''), btn(none ? 'Add' : 'Save', () => wsSave(wsInput.value), 'primary'), none ? null : btn('Cancel', wsCancel, ''))
|
|
2255
|
+
} else if (mine) {
|
|
2256
|
+
extra = h('div', { className: 'ws-addr' }, h('code', { textContent: w.searxng }),
|
|
2257
|
+
btn('Change', () => ((wsEditing = true), (wsInput.value = w.searxng), drawSearch(S), wsInput.focus())),
|
|
2258
|
+
btn('Test', () => wsTest(w.searxng)),
|
|
2259
|
+
btn('Remove', () => wsSave('')))
|
|
2260
|
+
}
|
|
2261
|
+
return h('div', { className: 'ws-row' + (on ? '' : ' off') + (mine ? ' mine' : '') },
|
|
2262
|
+
h('span', { className: 'n', textContent: on ? `${w.order.filter((x, j) => j <= i && !w.off.includes(x) && !(x === 'searxng' && !w.searxng)).length}` : '–' }),
|
|
2263
|
+
h('div', { className: 't' }, h('b', { textContent: w.names[n] ?? n }), h('span', { textContent: ENGINE_INFO[n] ?? '' }), extra),
|
|
2264
|
+
h('div', { className: 'mv' },
|
|
2265
|
+
btn('↑', () => move(-1)),
|
|
2266
|
+
btn('↓', () => move(1))),
|
|
2267
|
+
sw({ checked: on, disabled: none, 'aria-label': `Use ${w.names[n]}`, onchange: (e) => save(w.order, e.target.checked ? w.off.filter((x) => x !== n) : [...w.off, n], `${w.names[n]}: ${e.target.checked ? 'on' : 'off'}`) }))
|
|
2268
|
+
}))
|
|
2269
|
+
// ↑ on the first and ↓ on the last can't move
|
|
2270
|
+
const rows = [...$('ws-order').children]
|
|
2271
|
+
rows[0]?.querySelector('.mv button').setAttribute('disabled', '')
|
|
2272
|
+
rows.at(-1)?.querySelectorAll('.mv button')[1]?.setAttribute('disabled', '')
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
// --- Notifications: Telegram set up in three steps (a bot from @BotFather, its token, Start in the
|
|
2276
|
+
// bot), then on/off, a test, and which events send one ---
|
|
2277
|
+
function drawNotify(s) {
|
|
2278
|
+
const t = s.telegram ?? { events: {}, names: {} }
|
|
2279
|
+
const tokenRow = (label) => h('div', { className: 'row', style: 'align-items:flex-end;gap:10px' },
|
|
2280
|
+
h('div', { className: 'grow' }, h('label', { className: 'f', for: 'tg-token', textContent: label }),
|
|
2281
|
+
h('input', { type: 'password', id: 'tg-token', autocomplete: 'off', spellcheck: false, placeholder: t.hint ? `saved: ${t.hint}` : '123456789:AAH…' })),
|
|
2282
|
+
h('button', { className: 'primary', type: 'button', textContent: 'Connect', onclick: tgConnect }))
|
|
2283
|
+
const typed = $('tg-token')?.value ?? '' // a redraw keeps what's being typed
|
|
2284
|
+
const focused = document.activeElement === $('tg-token')
|
|
2285
|
+
if (!t.connected) {
|
|
2286
|
+
put($('tg-setup'), h('ol', { className: 'tg-steps' },
|
|
2287
|
+
h('li', {}, 'In Telegram, open ', h('a', { href: 'https://t.me/BotFather', target: '_blank', rel: 'noopener', textContent: '@BotFather' }), ', send ', h('span', { className: 'mono', textContent: '/newbot' }), ', pick a name, and copy the token it gives you.'),
|
|
2288
|
+
h('li', {}, tokenRow('Paste the token here')),
|
|
2289
|
+
h('li', { className: t.bot ? '' : 'muted' }, t.bot ? ['Open ', h('a', { href: `https://t.me/${t.bot}`, target: '_blank', rel: 'noopener', textContent: `@${t.bot}` }), ' and press ', h('b', { textContent: 'Start' }), ' (or send it any message), then ', h('button', { className: 'small', type: 'button', textContent: 'Find my chat', onclick: () => tgConnect(true) })] : 'Then press Start in your bot, so HeartCode knows where to send.')))
|
|
2290
|
+
$('tg-token').value = typed
|
|
2291
|
+
if (focused) $('tg-token').focus()
|
|
2292
|
+
} else {
|
|
2293
|
+
put($('tg-setup'),
|
|
2294
|
+
h('div', { className: 'tg-conn' }, h('span', { className: 'tag ok', textContent: 'connected' }), h('span', {}, 'Sending to ', h('b', { textContent: t.chatName }), ' through ', h('a', { href: `https://t.me/${t.bot}`, target: '_blank', rel: 'noopener', textContent: `@${t.bot}` })), h('span', { className: 'mono muted', textContent: t.hint })),
|
|
2295
|
+
h('label', { className: 'opt' }, h('div', { className: 't' }, h('b', { textContent: 'Send notifications' }), h('span', { textContent: 'Off: nothing is sent, the setup stays.' })),
|
|
2296
|
+
sw({ checked: t.on, 'aria-label': 'Send notifications', onchange: (e) => act('/api/telegram/set', { on: e.target.checked }, `Telegram notifications: ${e.target.checked ? 'on' : 'off'}`) })),
|
|
2297
|
+
h('div', { className: 'actions' },
|
|
2298
|
+
h('button', { type: 'button', textContent: 'Send a test', onclick: () => act('/api/telegram/test', {}, 'Test sent: check Telegram') }),
|
|
2299
|
+
h('button', { className: 'ghost', type: 'button', textContent: 'Disconnect', onclick: () => confirm('Stop sending notifications to Telegram and forget the bot token?') && act('/api/telegram/remove', {}, 'Telegram disconnected') })))
|
|
2300
|
+
}
|
|
2301
|
+
put($('tg-events'), Object.entries(t.names ?? {}).map(([k, label]) => h('label', { className: 'opt' + (t.connected ? '' : ' tg-off') },
|
|
2302
|
+
h('div', { className: 't' }, h('b', { textContent: label }), h('span', { textContent: TG_EVENT_INFO[k] ?? '' })),
|
|
2303
|
+
sw({ checked: t.events?.[k] !== false, disabled: !t.connected, 'aria-label': label, onchange: (e) => act('/api/telegram/set', { event: k, value: e.target.checked }, `${label}: ${e.target.checked ? 'on' : 'off'}`) }))))
|
|
2304
|
+
}
|
|
2305
|
+
const TG_EVENT_INFO = {
|
|
2306
|
+
done: 'The task, how long it took, and the answer.',
|
|
2307
|
+
failed: 'The task and the error.',
|
|
2308
|
+
waiting: 'The question or permission it stopped at, so you can come back and answer.',
|
|
2309
|
+
}
|
|
2310
|
+
async function tgConnect(again = false) {
|
|
2311
|
+
const token = again === true ? '' : $('tg-token')?.value.trim()
|
|
2312
|
+
const r = await act('/api/telegram/connect', { token })
|
|
2313
|
+
if (!r) return
|
|
2314
|
+
toast(r.found ? `Connected: sending to ${r.found}` : r.telegram?.bot ? `Token works. Now press Start in @${r.telegram.bot}, then Find my chat` : 'Saved')
|
|
2315
|
+
}
|
|
2064
2316
|
|
|
2065
2317
|
// --- Logging: the two switches, how much of each request; the requests logged (live) ---
|
|
2066
2318
|
const logSwitch = (s, k, title, about) => h('label', { className: 'opt' },
|
|
@@ -2347,7 +2599,9 @@ function drawSkills(s) {
|
|
|
2347
2599
|
}
|
|
2348
2600
|
}
|
|
2349
2601
|
$('k-install').onclick = install
|
|
2350
|
-
$('k-url').onkeydown = (e) =>
|
|
2602
|
+
$('k-url').onkeydown = (e) => {
|
|
2603
|
+
if (e.key === 'Enter') install()
|
|
2604
|
+
}
|
|
2351
2605
|
$('k-import').onclick = openImport
|
|
2352
2606
|
masterDetail('skills', $('k-items'), $('k-detail'), [{ title: mine.length && theirs.length ? 'Yours' : '', items: mine.map(item) }, { title: 'From projects', items: theirs.map(item) }], (x) => {
|
|
2353
2607
|
if (!x) return h('div', { className: 'card' }, h('h2', { textContent: 'No skills yet' }), h('p', { className: 'sub', textContent: 'A skill is a prompt you use again and again, like "review this" or "write the release notes". Make one with + New skill, install one from GitHub above, or bring them from Claude Code and others with /import in HeartCode.' }))
|
|
@@ -2389,7 +2643,7 @@ let sbDrag = null // the chip being dragged: { id, from: 'palette' | { line, sid
|
|
|
2389
2643
|
let sbSaveTimer = null
|
|
2390
2644
|
const SB_DEFAULT = () => [
|
|
2391
2645
|
{ left: ['provider', 'model'], right: ['mode', 'thinking', 'images'] },
|
|
2392
|
-
{ left: ['ctx', 'tps', 'autocompact'], right: ['permissions', 'worktree', 'cost'] },
|
|
2646
|
+
{ left: ['ctx', 'tps', 'autocompact'], right: ['background', 'permissions', 'worktree', 'cost'] },
|
|
2393
2647
|
]
|
|
2394
2648
|
const sbLabel = (id) => (SB_ITEMS.find((i) => i.id === id) || {}).label || id
|
|
2395
2649
|
const sbSample = (id) => (SB_ITEMS.find((i) => i.id === id) || {}).sample || id
|
|
@@ -2511,6 +2765,7 @@ function render(s) {
|
|
|
2511
2765
|
drawUsing(s)
|
|
2512
2766
|
drawGeneral(s)
|
|
2513
2767
|
drawStatusBar(s)
|
|
2768
|
+
drawNotify(s)
|
|
2514
2769
|
drawLogging(s)
|
|
2515
2770
|
if (REQS) drawReqs()
|
|
2516
2771
|
drawPrompts(s)
|