@double_geste/agent-standup 1.30.0 → 1.32.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.
- package/bin/agent-standup.js +4 -1
- package/codex.js +6 -4
- package/kokoro-worker.js +35 -4
- package/kokoro.js +26 -10
- package/package.json +1 -1
- package/public/index.html +582 -166
- package/public/locales/README.md +5 -2
- package/public/locales/da.json +44 -10
- package/public/locales/de.json +44 -10
- package/public/locales/en.json +42 -8
- package/public/locales/es.json +44 -10
- package/public/locales/ja.json +44 -10
- package/public/locales/ko.json +44 -10
- package/public/locales/pt-BR.json +44 -10
- package/public/locales/zh-CN.json +44 -10
- package/public/locales/zh-TW.json +44 -10
- package/server.js +342 -82
- package/vibe.js +12 -7
package/public/index.html
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
.tile.slow { border-color:#ff9f1c !important; animation:slowp 1.6s ease-in-out infinite } @keyframes slowp { 50% { box-shadow:0 0 0 4px rgba(255,159,28,.35) } }
|
|
31
31
|
.tile.quiet { opacity:.72 }
|
|
32
32
|
.tag .tk { color:#aab2c5; font-size:10px } .tag .tk:empty { display:none }
|
|
33
|
+
.tile.focus .tag .tk, #pcam .tag .tk { font-size:11.5px; color:#cfd6e6 } body:not(.compact):not(.presenting) .tile.focus .tag .tk:not(:empty)::after { content:' ' attr(data-w) } /* what an agent has used so far, readable where there is room: the large tile (with the word) and the camera of the one who shares a screen */
|
|
33
34
|
.keys { padding:6px 10px 4px; color:var(--dim); font-size:10.5px; line-height:1.5 }
|
|
34
35
|
/* the status of the session: a pill in the header of a wide window, a line of its own under the header from 1080 px down (#sline), where it stays readable in the narrowest side panel. Two lines at most, the whole text in the tooltip */
|
|
35
36
|
#pill, #sline { font-weight:600; background:var(--panel2); color:var(--dim); cursor:default; overflow:hidden; -webkit-box-orient:vertical; -webkit-line-clamp:2 }
|
|
@@ -38,6 +39,14 @@
|
|
|
38
39
|
:is(#pill, #sline).working { color:var(--gold) } :is(#pill, #sline).turn { color:#0b1020; background:var(--accent) } #pill:is(.working, .blocked, .stalled, .turn, .idle) { letter-spacing:0 } :is(#pill, #sline):focus-visible { outline:2px solid var(--accent); outline-offset:-2px }
|
|
39
40
|
@media (max-width:1080px) { #pill { display:none } #sline { display:-webkit-box } } @media (max-width:760px) { #sline::after { content:attr(data-sub); font-weight:400; opacity:.8 } } @media (max-width:400px) { #sline { -webkit-line-clamp:3 } }
|
|
40
41
|
@media (min-width:1081px) { header .brand { min-width:150px } #pill { flex-shrink:20 } .tok, .ctxp { flex-shrink:0 } } /* wide: a long status gives way before the name and the counters */
|
|
42
|
+
/* several sessions at once (live): the sessions of the moment as tabs under the header, the one the call is in among them, each with its state; and a visitor from another session that needs you, who takes you there on a click */
|
|
43
|
+
#tabs { display:none; flex:none; align-items:center; gap:5px; padding:4px 10px; border-bottom:1px solid var(--line); overflow-x:auto; scrollbar-width:none } #tabs::-webkit-scrollbar { display:none } #tabs:not(:empty) { display:flex }
|
|
44
|
+
.stab { flex:0 1 auto; min-width:92px; max-width:190px; display:flex; align-items:center; gap:5px; padding:2px 9px; border-radius:99px; border:1px solid var(--line); color:var(--dim); font-size:11.5px; line-height:1.5; white-space:nowrap } .stab span { overflow:hidden; text-overflow:ellipsis } .stab i { flex:none; font-style:normal; font-size:9px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; padding:0 5px; border-radius:99px; border:1px solid currentColor; opacity:.85 } .stab:hover { color:var(--text); border-color:var(--accent) }
|
|
45
|
+
.stab.on { flex-shrink:0; max-width:min(320px,62vw); background:var(--panel2); color:var(--text); font-weight:600; border-color:var(--accent) } .stab.turn:not(.on) { color:var(--accent) } .stab.blocked:not(.on) { color:#fff; background:#c0392b; border-color:#ff8a80; font-weight:600 } .stab.all { flex:none; min-width:0; padding:2px 8px } /* a narrow panel: the tabs keep a readable width and the row scrolls */
|
|
46
|
+
#visit { position:absolute; right:12px; bottom:14px; z-index:6; display:none; align-items:flex-end; gap:8px; max-width:min(380px,calc(100% - 24px)); cursor:pointer } #visit.on { display:flex; animation:visit .45s cubic-bezier(.2,1.3,.4,1) } @keyframes visit { from { transform:translateX(120%) } } body.react #visit { bottom:140px }
|
|
47
|
+
#visit .vsay { position:relative; min-width:0; background:#fff; color:#1b1d27; border-radius:11px 11px 2px 11px; padding:7px 10px; font-size:12.5px; line-height:1.35; box-shadow:0 4px 14px rgba(0,0,0,.4); overflow-wrap:anywhere } #visit .vsay small { display:block; color:#5a6072; font-size:11px; margin-bottom:2px } #visit .vgo { display:inline-block; margin-top:5px; padding:1px 10px; border-radius:99px; background:var(--accent); color:#0b1020; font-weight:600; font-size:11.5px }
|
|
48
|
+
#visit .vwho { flex:none; width:88px; height:66px; border-radius:12px; overflow:hidden; border:2px solid var(--accent); box-shadow:0 4px 14px rgba(0,0,0,.45); background:#222 } #visit.blocked .vwho { border-color:#ff5252 } #visit.speaking .vwho { box-shadow:0 0 0 3px rgba(124,156,255,.4), 0 4px 14px rgba(0,0,0,.45) } #visit .vwho svg { width:100%; height:100%; display:block }
|
|
49
|
+
#visit .vx { position:absolute; top:-9px; left:-9px; width:20px; height:20px; border-radius:50%; background:var(--panel2); border:1px solid var(--line); color:var(--dim); font-size:11px; line-height:18px } #visit .vx:hover { color:var(--text) }
|
|
41
50
|
@keyframes pulse { 50% { opacity:.3 } }
|
|
42
51
|
.seg { display:flex; background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:2px }
|
|
43
52
|
.seg button { padding:4px 11px; border-radius:6px; color:var(--dim); font-size:12.5px }
|
|
@@ -59,6 +68,7 @@
|
|
|
59
68
|
.rr:hover { background:#2a2f45 } .rr.sel { outline:1px solid var(--accent) }
|
|
60
69
|
.rr .n { display:flex; align-items:center; gap:7px; min-width:0 } .rr .dot { width:9px; height:9px; border-radius:50%; flex:none } .rr b { font-size:12.5px } .rr .ro { color:var(--dim); font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0 }
|
|
61
70
|
.rr .st { font-size:11.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
|
|
71
|
+
.rr .rt { margin-left:auto; flex:none; padding-left:6px; color:#aab2c5; font-size:10.5px; white-space:nowrap } .rr.left { opacity:.72; padding-top:4px; padding-bottom:4px } .rr.left:hover { opacity:1 } /* what each agent has used so far; those who left the call keep their line, and their count with it */
|
|
62
72
|
.rr.k-working { border-left-color:var(--gold) } .rr.k-working .st { color:var(--gold) } .rr.k-waiting { border-left-color:#8fd3ff } .rr.k-waiting .st { color:#8fd3ff }
|
|
63
73
|
.rr.k-blocked { border-left-color:#ff5252; background:rgba(192,57,43,.28) } .rr.k-blocked .st { color:#fff; font-weight:700 } .rr.k-stalled { border-left-color:#ffb347 } .rr.k-stalled .st { color:#ffb347; font-weight:700 }
|
|
64
74
|
.rr.k-done { opacity:.82 } .rr.k-done .st { color:var(--ok) } .rr.turn { opacity:1; border-left-color:var(--accent) } .rr.turn .st { color:var(--accent); font-weight:700 } .rr.k-idle .st { color:var(--dim) } .rr.speaking { box-shadow:0 0 0 2px rgba(124,156,255,.5) }
|
|
@@ -68,12 +78,27 @@
|
|
|
68
78
|
.bcard { text-align:left; background:var(--panel2); border:1px solid var(--line); border-radius:12px; padding:11px 13px; display:flex; flex-direction:column; gap:5px; cursor:pointer }
|
|
69
79
|
.bcard:hover { border-color:var(--accent) } .bcard.blocked { border-color:#ff5252; box-shadow:0 0 0 2px rgba(255,82,82,.25) } .bcard.working { border-color:rgba(240,160,32,.7) } .bcard.waiting { border-color:rgba(110,190,255,.8) } .bcard.idle { opacity:.8 }
|
|
70
80
|
.bcard .bt { font-weight:600; font-size:13.5px; overflow:hidden; text-overflow:ellipsis; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical } .bcard .bp, .bcard .bm { color:var(--dim); font-size:11.5px }
|
|
71
|
-
.bcard .stc { align-self:flex-start }
|
|
81
|
+
.bcard .stc { align-self:flex-start } .bcard .bh { display:flex; align-items:center; gap:6px; min-width:0 } .bcard .bh .stc { overflow:hidden; text-overflow:ellipsis }
|
|
82
|
+
.bcard .bq { font-size:12.5px; color:var(--text); border-left:2px solid #ff5252; padding-left:8px; overflow:hidden; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical }
|
|
83
|
+
.bsec { margin-bottom:18px } .bhd { display:flex; align-items:center; gap:7px; margin:0 0 9px; font-size:12.5px; font-weight:700; color:var(--dim) } .bhd.blocked { color:#ff8a80 } .bhd.turn { color:var(--text) }
|
|
84
|
+
.bhd .bl { display:inline-block } .bhd .bl::first-letter { text-transform:uppercase } .bhd i { font-style:normal; font-weight:600; font-size:11.5px; padding:0 7px; border-radius:99px; background:var(--panel2); border:1px solid var(--line) }
|
|
85
|
+
.bdone summary { cursor:pointer; list-style:none } .bdone summary::-webkit-details-marker { display:none } .bdone summary::after { content:'▸' } .bdone[open] summary::after { content:'▾' } .bdone .bcard { opacity:.7 }
|
|
86
|
+
.bdo, .bpr { flex:none; font:inherit; font-size:11.5px; line-height:1.5; color:var(--dim); background:none; border:1px solid var(--line); border-radius:99px; padding:0 8px; cursor:pointer } .bh .stc + .bpr, .bh .stc + .bdo { margin-left:auto } .bdo:hover, .bpr:hover, .bdo:focus-visible, .bpr:focus-visible { color:var(--text); border-color:var(--accent) }
|
|
72
87
|
.stc { font-size:11.5px; padding:2px 9px; border-radius:99px; background:rgba(14,15,24,.6); white-space:nowrap } .stc.working { color:var(--gold) } .stc.waiting { color:#8fd3ff } .stc.blocked { color:#fff; background:#c0392b; font-weight:700 } .stc.stalled { color:#1b1d27; background:#ffb347; font-weight:700 } .stc.done, .stc.turn { color:var(--ok) } .stc.idle { color:var(--dim) }
|
|
73
88
|
.ctxp { font-size:11px; font-weight:600; padding:3px 9px; border-radius:99px; background:var(--panel2); white-space:nowrap; cursor:default } .ctxp.lo, .cx.lo { color:#7ee2a8 } .ctxp.mid, .cx.mid { color:#ffc857 } .ctxp.hi, .cx.hi { color:#fff; background:#c0392b }
|
|
74
89
|
.cx:empty { display:none } .tag .cx { font-size:10px }
|
|
75
90
|
#hl { display:none; flex:0 0.01 auto; min-height:30px; max-height:66px; overflow-y:auto; scrollbar-width:thin; flex-wrap:wrap; gap:6px; padding:5px 12px; border-top:1px solid var(--line); background:var(--panel) } body.replay #hl.has { display:flex } body.board #hl, body.tree #hl { display:none !important }
|
|
76
91
|
.hlc { font-size:11.5px; padding:3px 10px; border-radius:99px; background:var(--panel2); border:1px solid var(--line); color:var(--text) } .hlc:hover { border-color:var(--accent) }
|
|
92
|
+
/* shared files: the files the session created, the way a call shows what was shared in it. One quiet line under the call when a turn ends (it scrolls sideways, as the session tabs do); the files of the turn that just ended carry a dot; the list of all of them opens above it */
|
|
93
|
+
#files { display:none; flex:none; align-items:center; gap:6px; padding:5px 12px; border-top:1px solid var(--line); background:var(--panel); overflow-x:auto; scrollbar-width:none } #files::-webkit-scrollbar { display:none } #files.on { display:flex; animation:fadein .4s } body.board #files, body.board #fpop { display:none !important }
|
|
94
|
+
.sfh { flex:none; padding:3px 4px 3px 0; color:var(--dim); font-size:11.5px; font-weight:600; white-space:nowrap } .sfh:hover, .sfh[aria-expanded=true] { color:var(--text) }
|
|
95
|
+
.sfc { flex:0 0 auto; max-width:210px; display:inline-flex; align-items:center; gap:5px; font-size:11.5px; line-height:1.45; padding:3px 10px; border-radius:99px; background:var(--panel2); border:1px solid var(--line); color:var(--text); white-space:nowrap } .sfc:hover { border-color:var(--accent) } .sfc i { font-style:normal; flex:none } .sfc span { overflow:hidden; text-overflow:ellipsis } .sfc.more { color:var(--dim) }
|
|
96
|
+
.sfc.new::before { content:''; flex:none; width:6px; height:6px; border-radius:50%; background:var(--accent) } .sfr.new b::after { content:''; display:inline-block; width:6px; height:6px; margin-left:7px; border-radius:50%; background:var(--accent); vertical-align:1px }
|
|
97
|
+
.sfc.gone, .sfr.gone { opacity:.5 } .sfc.gone span, .sfr.gone b { text-decoration:line-through }
|
|
98
|
+
#fpop { position:absolute; left:10px; z-index:8; width:min(360px,calc(100% - 20px)); max-height:min(46vh,340px); overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; background:var(--panel); border:1px solid var(--line); border-radius:12px; box-shadow:0 14px 40px rgba(0,0,0,.55); padding:6px; animation:fadein .15s }
|
|
99
|
+
#fpop h4 { margin:6px 10px 4px; font-size:10.5px; letter-spacing:.08em; text-transform:uppercase; color:var(--dim); font-weight:600 }
|
|
100
|
+
.sfr { display:grid; grid-template-columns:auto 1fr; gap:0 9px; align-items:center; width:100%; text-align:left; padding:6px 10px; border-radius:8px } .sfr:hover { background:var(--panel2) } .sfr i { font-style:normal; grid-row:span 2 } .sfr b, .sfr em { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap } .sfr b { font-size:12.5px; font-weight:600 } .sfr em { font-style:normal; font-size:11px; color:var(--dim) }
|
|
101
|
+
body:not(.replay) #center:has(#files.on) #toasts { bottom:46px } body:not(.replay):not(.react) #center:has(#files.on) #visit { bottom:48px } /* live: the line is the bottom of the call, and what pops up there stays above it */
|
|
77
102
|
.tbadge .l { color:#ff9f1c } .tbadge span { font-size:11px } .tbadge .q { color:#b4bcd4 }
|
|
78
103
|
.ic:active, .btn:active { transform:scale(.96) } .rr, .ic, .bcard { transition:background .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease) }
|
|
79
104
|
.meet { font-size:11.5px; color:var(--dim); white-space:nowrap; display:flex; gap:8px; align-items:center } .meet i { width:8px; height:8px; border-radius:50%; background:#ff4d4d; animation:pulse 1.6s infinite }
|
|
@@ -97,6 +122,16 @@
|
|
|
97
122
|
.pbar .r { background:#ff5f57 } .pbar .y { background:#febc2e } .pbar .g { background:#28c840 } #ptitle { margin:0 0 0 14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0 }
|
|
98
123
|
#pbody { flex:1; overflow:hidden; padding:10px 14px; font:12.5px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace; color:#d6dae6 } .pwin.editor #pbody { background:#1a1b26; padding:0 }
|
|
99
124
|
.pwin.image #pbody { display:flex; gap:8px; align-items:center; justify-content:center; background:#0b0c11; padding:8px } .pwin.image #pbody img { flex:0 1 auto; min-width:0; max-width:100%; max-height:100%; object-fit:contain; border-radius:4px } .pmore { color:#9aa0b4; font-size:12px } .dimg { display:block; max-width:100%; border-radius:6px; margin:4px 0 }
|
|
125
|
+
/* an artifact (a page the session published on claude.ai) on the shared screen: a browser window, with the page in a frame. Shared, it is shown whole and small, as a screen is; pinned (a click on it, or on its name in the line of files) it takes the room and can be read and used */
|
|
126
|
+
.pwin.web { flex-basis:1100px } .pwin.web #pbody { display:flex; flex-direction:column; padding:0; background:#0b0c11; font:12px -apple-system,system-ui,sans-serif }
|
|
127
|
+
.pnav { flex:none; display:flex; align-items:center; gap:6px; padding:5px 8px; background:#161925; border-bottom:1px solid #232637 } .pnn { flex:none; color:#8b95b0; font-size:11px }
|
|
128
|
+
.purl { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; background:#0d1117; border:1px solid #2a2d3d; border-radius:99px; padding:2px 12px; color:#9aa0b4; font-size:11.5px }
|
|
129
|
+
.pnb { flex:none; padding:2px 9px; border-radius:6px; border:1px solid #2a2d3d; background:#1c1f2b; color:#d6dae6; font-size:11.5px; white-space:nowrap } .pnb:hover { border-color:var(--accent) } .pnb.lib { border-color:rgba(240,160,32,.6); color:#ffd24a }
|
|
130
|
+
.pweb { flex:1; min-height:0; position:relative; overflow:hidden; background:#fff } .pweb iframe { position:absolute; left:0; top:0; border:0; width:calc(100% / var(--z,1)); height:calc(100% / var(--z,1)); transform:scale(var(--z,1)); transform-origin:0 0; background:#fff }
|
|
131
|
+
.pzoom { position:absolute; inset:0; width:100%; cursor:zoom-in }
|
|
132
|
+
.pcard { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:7px; padding:14px; text-align:center; background:#0d1117; color:#d6dae6 } .pcard i { font-style:normal; font-size:30px } .pcard b { font-size:16px } .pcard p { margin:0; max-width:520px; color:#9aa0b4; font-size:12.5px } .pcard em { font-style:normal; color:#6b7089; font-size:11.5px }
|
|
133
|
+
#present.pin { height:clamp(240px,74vh,1000px) } #present.pin #pcam, #present.pin #pcap, #present.pin #pbadge { display:none } #present:has(.pwin.web) #pcam { width:110px; height:82px }
|
|
134
|
+
body.narrow #present.pin { height:clamp(220px,70vh,900px) } #present.pin:has(.pcard), body.narrow #present.pin:has(.pcard) { height:clamp(190px,34vh,300px) } /* nothing to read there but a title and a link */
|
|
100
135
|
.ptab { display:flex; align-items:center; gap:10px; background:#16161e; padding:5px 12px; border-bottom:1px solid #2a2b3d; font:11.5px -apple-system,system-ui,sans-serif } .ptab span { background:#1a1b26; padding:3px 10px; border-radius:6px 6px 0 0; color:#e9eaf0 } .ptab em { color:#6b7089; font-style:normal }
|
|
101
136
|
.ln { display:flex; gap:10px; padding:0 12px; white-space:pre-wrap; word-break:break-all } .ln b { width:12px; flex:none; color:#7a7f98; font-weight:400 } .ln.add { background:rgba(63,185,80,.16); color:#9be9a8 } .ln.del { background:rgba(248,81,73,.16); color:#ffa198 }
|
|
102
137
|
.tl { white-space:pre-wrap; word-break:break-word } .tl .ps { color:#7ee787 } .tl.cmd { color:#e6edf3 } .tl.tool { color:#8b95b0 } .dotg { color:#58a6ff }
|
|
@@ -175,6 +210,7 @@
|
|
|
175
210
|
@keyframes flash2 { 40% { opacity:.9 } }
|
|
176
211
|
.puff { position:fixed; left:0; top:0; z-index:9; pointer-events:none; border-radius:50% }
|
|
177
212
|
#toasts { position:absolute; left:12px; bottom:12px; z-index:6; display:flex; flex-direction:column; gap:6px; pointer-events:none }
|
|
213
|
+
.toast.offer { pointer-events:auto; animation:none; display:flex; align-items:center; gap:8px; padding:4px 6px 4px 12px; order:9 } .toast.offer .btn { padding:3px 10px; font-size:12px; white-space:nowrap } .toast.offer .ic { font-size:11px; padding:2px 6px } /* the offer of the real voices: stays until answered, under the passing toasts */
|
|
178
214
|
.toast { background:rgba(27,29,39,.92); border:1px solid var(--line); border-radius:99px; padding:5px 12px; font-size:12px; animation:toast 3s ease forwards } @keyframes toast { 0% { opacity:0; transform:translateY(6px) } 10%, 80% { opacity:1; transform:none } 100% { opacity:0 } }
|
|
179
215
|
.eye { transform-box:fill-box; transform-origin:center; animation:blink 4.6s infinite; animation-delay:var(--d,0s) } @keyframes blink { 0%,94%,100% { transform:scaleY(1) } 97% { transform:scaleY(.08) } }
|
|
180
216
|
.brow { transform-box:fill-box; transform-origin:center; transition:transform .25s } .tile.speaking .brow { animation:brow .7s ease-in-out infinite } @keyframes brow { 50% { transform:translateY(-1.1px) } }
|
|
@@ -195,6 +231,7 @@
|
|
|
195
231
|
/* ---------- overlays ---------- */
|
|
196
232
|
#gate, #empty { position:absolute; inset:0; z-index:4; display:none; flex-direction:column; align-items:center; justify-content:center; gap:14px; text-align:center; padding:24px; background:rgba(18,19,26,.82); backdrop-filter:blur(3px) }
|
|
197
233
|
#gate.on, #empty.on { display:flex } #empty { background:var(--bg) } #empty.on ~ #gate { display:none } /* no session at all: nothing to join, the empty state and its demo button are what there is to see */
|
|
234
|
+
body:has(#gate.on) .toast.offer, body:has(#empty.on) .toast.offer { display:none !important } /* the lines that offer something wait for the call: over the join screen of a small panel they covered its button, and the click fell on theirs */
|
|
198
235
|
#gate h2, #empty h2 { margin:0; font:800 22px "Comic Sans MS","Chalkboard SE",system-ui,sans-serif } #gate p, #empty p { margin:0; color:var(--dim); max-width:380px } #eP b { color:var(--text) }
|
|
199
236
|
.cta { background:var(--accent); color:#0b1020; font-weight:700; padding:10px 22px; border-radius:99px; font-size:14px } .cta:hover { filter:brightness(1.1) } .cta:empty { display:none }
|
|
200
237
|
.btn { background:var(--panel2); border:1px solid var(--line); padding:6px 12px; border-radius:8px } .btn:hover { border-color:var(--accent) }
|
|
@@ -266,12 +303,14 @@
|
|
|
266
303
|
<button class="ic" id="bMenu" title="Réglages">⚙</button>
|
|
267
304
|
</header>
|
|
268
305
|
<div id="sline"></div>
|
|
306
|
+
<div id="tabs" role="tablist" aria-label="Sessions"></div>
|
|
269
307
|
|
|
270
308
|
<div id="menu">
|
|
271
309
|
<input id="menuQ" type="search" placeholder="Search settings…" aria-label="Search settings" style="margin:4px 8px 2px;width:calc(100% - 16px)">
|
|
272
310
|
<div class="hint" id="menuNone" style="display:none;padding-top:6px;color:var(--dim)" data-fr="Aucun réglage trouvé" data-en="No setting found">Aucun réglage trouvé</div>
|
|
273
311
|
<h4 data-fr="Langue" data-en="Language">Langue</h4>
|
|
274
312
|
<div class="box"><select id="langSel" aria-label="Language"></select></div>
|
|
313
|
+
<button class="mi" data-t="callTr" id="callTrMi" style="display:none"><span data-fr="Appel dans cette langue (traduit avec votre Claude Code)" data-en="Call in this language (translated with your Claude Code)">Appel dans cette langue (traduit avec votre Claude Code)</span><i class="sw"></i></button>
|
|
275
314
|
<div class="hint" id="trHint" style="display:none"></div>
|
|
276
315
|
<h4 data-fr="Son" data-en="Sound">Son</h4>
|
|
277
316
|
<button class="mi" data-t="voice"><span data-fr="Voix des agents" data-en="Agent voices">Voix des agents</span><i class="sw"></i></button>
|
|
@@ -280,7 +319,7 @@
|
|
|
280
319
|
<button class="mi" data-t="notify"><span data-fr="Me prévenir quand les agents ont fini" data-en="Notify me when agents finish">Me prévenir quand les agents ont fini</span><i class="sw"></i></button>
|
|
281
320
|
<button class="mi" data-t="music"><span data-fr="Musique d’ambiance (radio FIP)" data-en="Office music (FIP radio)">Musique d’ambiance (radio FIP)</span><i class="sw"></i></button>
|
|
282
321
|
<div class="box" id="musicBox" style="display:none"><select id="station"></select><input id="musicVol" type="range" min="0" max="1" step="0.05" style="width:100%" aria-label="Music volume"></div>
|
|
283
|
-
<div class="box" id="vstyleBox"><label class="lbl" for="vstyle" data-fr="Style des voix" data-en="Voice style">Style des voix</label><select id="vstyle"></select></div>
|
|
322
|
+
<div class="box" id="vstyleBox"><label class="lbl" for="vstyle" data-fr="Style des voix" data-en="Voice style">Style des voix</label><select id="vstyle"></select><div class="hint" id="vstyleTip" style="padding:6px 0 0;display:none" data-fr="Pour la meilleure expérience, choisissez les voix naturelles." data-en="For the best experience, pick the natural voices.">Pour la meilleure expérience, choisissez les voix naturelles.</div></div>
|
|
284
323
|
<div class="box" id="kokoroBox" style="display:none"><button class="btn" id="kokoroInstall" style="width:100%"></button><div class="hint" id="kokoroHint" style="padding:2px 0 6px"></div></div>
|
|
285
324
|
<h4 data-fr="Affichage" data-en="Display">Affichage</h4>
|
|
286
325
|
<button class="mi" data-t="roster"><span data-fr="Liste des agents (à gauche)" data-en="Agents list (left)">Liste des agents (à gauche)</span><i class="sw"></i></button>
|
|
@@ -289,6 +328,10 @@
|
|
|
289
328
|
<div class="box"><div class="lbl"><span data-fr="Bavardage entre agents" data-en="Chatter between agents">Bavardage entre agents</span></div><select id="chatSel"><option value="quiet" data-fr="Discret" data-en="Quiet">Discret</option><option value="normal" data-fr="Normal" data-en="Normal">Normal</option><option value="lively" data-fr="Animé" data-en="Lively">Animé</option></select></div>
|
|
290
329
|
<button class="mi" data-t="vanish"><span data-fr="Retirer les agents terminés (2 min)" data-en="Remove finished agents (2 min)">Retirer les agents terminés (2 min)</span><i class="sw"></i></button>
|
|
291
330
|
<button class="mi" data-t="epi"><span data-fr="Réactions et blagues" data-en="Reactions & jokes">Réactions et blagues</span><i class="sw"></i></button>
|
|
331
|
+
<button class="mi" data-t="files"><span data-fr="Fichiers créés pour vous, à la fin d’un tour" data-en="Files made for you, when a turn ends">Fichiers créés pour vous, à la fin d’un tour</span><i class="sw"></i></button>
|
|
332
|
+
<button class="mi" data-t="artNet"><span data-fr="Artifacts : charger leurs bibliothèques (depuis Internet)" data-en="Artifacts: load their libraries (from the internet)">Artifacts : charger leurs bibliothèques (depuis Internet)</span><i class="sw"></i></button>
|
|
333
|
+
<button class="mi" data-t="visits"><span data-fr="Un visiteur quand une autre session vous attend" data-en="A visitor when another session needs you">Un visiteur quand une autre session vous attend</span><i class="sw"></i></button>
|
|
334
|
+
<button class="mi" data-t="followTab" id="mFollowTab" style="display:none"><span data-fr="Suivre l’onglet Claude Code affiché" data-en="Follow the Claude Code tab I am on">Suivre l’onglet Claude Code affiché</span><i class="sw"></i></button>
|
|
292
335
|
<h4 data-fr="Source" data-en="Source">Source</h4>
|
|
293
336
|
<div class="box"><div class="seg" style="width:100%" id="modeSeg"><button data-m="live" style="flex:1" data-fr="Live" data-en="Live">Live</button><button data-m="replay" style="flex:1" data-fr="Replay" data-en="Replay">Replay</button><button data-m="demo" style="flex:1" data-fr="Démo" data-en="Demo">Demo</button></div>
|
|
294
337
|
<select id="liveProj" style="display:none;margin-top:6px" title="Project to follow"></select>
|
|
@@ -307,6 +350,7 @@
|
|
|
307
350
|
<button class="mi" data-t="hideCode"><span data-fr="Masquer code et fichiers dans les vidéos" data-en="Hide code & file names in videos">Masquer code et fichiers dans les vidéos</span><i class="sw"></i></button>
|
|
308
351
|
<div class="keys">Space ⏯ · M 🔇 · T tree · R recap · L log · Esc ✕</div>
|
|
309
352
|
<button class="mi" id="mBrowser" style="display:none"><span data-fr="↗ Ouvrir dans le navigateur" data-en="↗ Open in browser">↗ Ouvrir dans le navigateur</span></button>
|
|
353
|
+
<button class="mi" id="mReport"><span data-fr="🐞 Signaler un problème" data-en="🐞 Report a problem">🐞 Signaler un problème</span></button>
|
|
310
354
|
</div>
|
|
311
355
|
|
|
312
356
|
<main>
|
|
@@ -315,9 +359,10 @@
|
|
|
315
359
|
<div id="present"><div class="pwin term"><div class="pbar"><i class="r"></i><i class="y"></i><i class="g"></i><span id="ptitle"></span><span id="pbadge"></span></div><div id="pbody"></div><div id="pstat"></div></div><div id="ptodo" style="display:none"></div><div id="pcap"></div><div id="pcam" class="tile working"></div></div>
|
|
316
360
|
<div id="stage"></div><div id="tree"></div><div id="boardv"></div>
|
|
317
361
|
<div id="reactBar" aria-label="Reactions"><button data-e="👍">👍</button><button data-e="👏">👏</button><button data-e="☕">☕</button><button data-e="🔥">🔥</button><button data-e="🙌">🙌</button></div>
|
|
362
|
+
<div id="files"></div>
|
|
318
363
|
<div id="hl"></div>
|
|
319
364
|
<canvas id="gantt" height="90"></canvas>
|
|
320
|
-
<div id="toasts" role="status" aria-live="polite"></div>
|
|
365
|
+
<div id="toasts" role="status" aria-live="polite"><div class="toast offer" id="vOffer" style="display:none"><span id="vOfferT"></span><button class="btn" id="vOfferB"></button><button class="ic" id="vOfferX" aria-label="Close">✕</button></div><div class="toast offer" id="trNote" style="display:none"><span id="trNoteT"></span><button class="btn" id="trNoteOk"></button><button class="btn" id="trNoteOff"></button></div></div><div id="visit" role="status" aria-live="polite"></div>
|
|
321
366
|
<div id="empty"><h2 id="eT"></h2><p id="eP"></p><button class="cta" id="eDemo"></button></div>
|
|
322
367
|
<div id="gate"><h2 id="gT"></h2><p id="gP"></p><button class="cta" id="gB"></button></div>
|
|
323
368
|
<div id="detail"><div class="hd"><b id="dname"></b><button class="ic" id="dclose">✕</button></div><div id="dbody"></div></div>
|
|
@@ -336,6 +381,19 @@
|
|
|
336
381
|
// =====================================================================
|
|
337
382
|
// helpers, prefs, i18n
|
|
338
383
|
// =====================================================================
|
|
384
|
+
// The page's own errors are written to the local log (errors.log beside the settings, see logError in server.js): nothing leaves the computer. ⚙ › Report a problem shows them.
|
|
385
|
+
// Twenty a page at most, each message once; what is not a fault of the app is left out (a sound the browser refuses to play, the server that went away, an interrupted request).
|
|
386
|
+
const ERRS = { n: 0, seen: new Set() };
|
|
387
|
+
function reportError(where, e) {
|
|
388
|
+
try {
|
|
389
|
+
const msg = String((e && e.message) || e || '').slice(0, 500), name = (e && e.name) || '';
|
|
390
|
+
if (!msg || ERRS.n >= 20 || ERRS.seen.has(msg) || /^(AbortError|NotAllowedError|NotSupportedError)$/.test(name) || /^Script error\.?$|ResizeObserver loop|Failed to fetch|NetworkError|Load failed/i.test(msg)) return;
|
|
391
|
+
ERRS.seen.add(msg); ERRS.n++;
|
|
392
|
+
fetch('/api/errors', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ where, msg, stack: String((e && e.stack) || '').slice(0, 4000) }) }).catch(() => {});
|
|
393
|
+
} catch {}
|
|
394
|
+
}
|
|
395
|
+
addEventListener('error', (ev) => { if (ev.error || ev.message) reportError('error', ev.error || { message: ev.message, stack: `at ${ev.filename}:${ev.lineno}:${ev.colno}` }); });
|
|
396
|
+
addEventListener('unhandledrejection', (ev) => reportError('promise', ev.reason));
|
|
339
397
|
const $ = (s) => document.querySelector(s);
|
|
340
398
|
const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&':'&', '<':'<', '>':'>', '"':'"' }[c]));
|
|
341
399
|
const hash = (s) => { let h = 2166136261; for (const c of s) h = Math.imul(h ^ c.charCodeAt(0), 16777619); return h >>> 0; };
|
|
@@ -345,11 +403,15 @@ const CID = Math.random().toString(36).slice(2, 12); // identifies this window
|
|
|
345
403
|
const Q = new URLSearchParams(location.search);
|
|
346
404
|
const EMBED = Q.get('embed') === '1' || window.parent !== window;
|
|
347
405
|
|
|
348
|
-
let prefs = { lang: 'en', voice: true, roster: true, banter: true, reactions: false, office: false, officeVol: 0.8, vstyle: '
|
|
406
|
+
let prefs = { lang: 'en', voice: true, roster: true, banter: true, reactions: false, office: false, officeVol: 0.8, vstyle: 'kokoro', notify: false, epi: false, vanish: true, music: false, station: 'fip', musicVol: 0.35, view: 'call', hideCode: false, ownNames: true, visits: true, followTab: true, files: true, callTr: true };
|
|
349
407
|
{ let loc = {}; try { loc = JSON.parse(localStorage.getItem('cc.prefs') || '{}') || {}; } catch {} // the settings file (shared by every window) and this origin's copy: the more recent one wins
|
|
350
408
|
const sv = window.SAVED_PREFS && typeof window.SAVED_PREFS === 'object' ? window.SAVED_PREFS : {}; Object.assign(prefs, (sv._t || 0) > (loc._t || 0) ? sv : loc); }
|
|
351
409
|
if (prefs.vstyle === 'babble') prefs.vstyle = 'animal', prefs.vstyleChosen = true;
|
|
352
|
-
|
|
410
|
+
// Two styles since 1.32.0: the natural voices (the model, the default, which babble until they are installed) and the Animal Crossing babble. The cartoon voices, Simlish and the plain system voices are no longer offered:
|
|
411
|
+
// whoever had Simlish is on the other babble, everyone else on the natural voices. The cartoon voices read the words with no install, so the call offers the real ones once more to who had closed that line.
|
|
412
|
+
if (prefs.vstyle === 'cartoon' && prefs.voiceOffer === 'no') delete prefs.voiceOffer;
|
|
413
|
+
if (prefs.vstyle === 'sims' && prefs.vstyleChosen) prefs.vstyle = 'animal';
|
|
414
|
+
if (prefs.vstyle !== 'animal' || !prefs.vstyleChosen) prefs.vstyle = 'kokoro';
|
|
353
415
|
if (!prefs.notifyChosen) prefs.notify = true; // “tell me when the agents are done” is on unless the person chose otherwise
|
|
354
416
|
let prefsTimer = null;
|
|
355
417
|
const savePrefs = () => { prefs._t = Date.now(); try { localStorage.setItem('cc.prefs', JSON.stringify(prefs)); } catch {} clearTimeout(prefsTimer); prefsTimer = setTimeout(() => { fetch('/api/prefs', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(prefs) }).catch(() => {}); }, 400); };
|
|
@@ -358,17 +420,35 @@ const savePrefs = () => { prefs._t = Date.now(); try { localStorage.setItem('cc.
|
|
|
358
420
|
const LANGS = [['en', 'English', 'en'], ['fr', 'Français', 'fr'], ['zh-TW', '繁體中文', 'zh-Hant-TW'], ['zh-CN', '简体中文', 'zh-Hans-CN'], ['es', 'Español', 'es'], ['de', 'Deutsch', 'de'], ['da', 'Dansk', 'da'], ['pt-BR', 'Português (Brasil)', 'pt-BR'], ['ja', '日本語', 'ja'], ['ko', '한국어', 'ko']];
|
|
359
421
|
let LOC = {};
|
|
360
422
|
const FR = () => prefs.lang === 'fr';
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
423
|
+
// The language the call is held in: what the agents say is translated into it, the little built-in lines exist in it and its voices are used. A French interface means a French call, as it always did.
|
|
424
|
+
// Spanish and Brazilian Portuguese are one too, unless the person switches it off (⚙ → Language). Translating sends the lines to Anthropic through their own Claude Code and counts on their plan, which
|
|
425
|
+
// nobody who picked one of these two languages before had agreed to: the first call held in one of them says so, once, with the way out (callNote). With any other interface language, or the switch off,
|
|
426
|
+
// the call is the session as it is, with the built-in lines in English.
|
|
427
|
+
const CALL_LANG = { fr: 'fr', es: 'es', 'pt-BR': 'pt' };
|
|
428
|
+
let noTr = false; // no Claude Code and no API key on this computer: nothing can be translated, and a Spanish or Portuguese call is not held (French goes on saying what is missing, as it always did)
|
|
429
|
+
const CALL = () => { const l = CALL_LANG[prefs.lang]; return l && (l === 'fr' || (prefs.callTr && !noTr)) ? l : 'en'; }, TRL = () => CALL() !== 'en';
|
|
430
|
+
const FR_L = 'le|la|les|des|une|un|et|est|pour|dans|que|qui|pas|sur|avec|je|tu|nous|vous|ce|cette|ça|du|au|aux|mais|sont|été|fait|plus|ne|ont|il|elle|ils|elles|très|aussi|donc|bien|tout|voici|voilà|merci|oui|non|comme|où|déjà|encore', FR_W = new RegExp('\\b(' + FR_L + ')\\b', 'gi'), EN_W = /\b(the|and|is|are|to|of|in|that|with|for|this|it|on|you|we|not|have|has|was|be|will|can|from|your|at|as|but|all|now|also|done|here|there|which|what|then|just|so)\b/gi;
|
|
431
|
+
// Spanish and Portuguese: only words that are neither French nor English words, and that the other of the two does not have (para, por, como, este… say nothing). Accents are not ASCII: the edges are spelled out.
|
|
432
|
+
const wordsRe = (w) => new RegExp('(^|[^\\p{L}\\p{N}_])(?:' + w + ')(?![\\p{L}\\p{N}_])', 'giu');
|
|
433
|
+
const ES_W = wordsRe('el|los|las|una|unos|y|es|con|del|al|pero|más|muy|también|ya|hay|están|esto|donde|sí|gracias|aquí|ahora|hecho|listo|ha|han|lo|sus|yo|tú|sin|cuando|puede|hacer|tiene|voy|estoy|tengo|puedo|necesito|quiero|creo|pruebas|archivo|archivos|cambios'),
|
|
434
|
+
PT_W = wordsRe('o|um|uma|uns|e(?!\\.)|é|em|com|não|da|dos|das|na|nas|mas|são|mais|muito|também|já|há|estão|isso|isto|esse|essa|onde|sim|obrigado|aqui|agora|tudo|feito|pronto|você|vocês|eu|meu|minha|seu|sua|foi|tem|vou|fazer|pode|sem|quando|ao|pelo|pela|estou|tenho|posso|preciso|quero|acho|testes|arquivo|arquivos|alterações');
|
|
435
|
+
const FR_S = wordsRe(FR_L); // the French words with the same edges: \b reads "está" as "est" and "quién" as "qui"
|
|
436
|
+
// German, Danish, Japanese, Korean and Chinese are told apart too, though no call is held in them and the model has no voice for them: a line in one of them goes to a system voice of that language, not to an English voice.
|
|
437
|
+
const DE_W = wordsRe('der|die|und|ist|nicht|ich|mit|für|auf|ein|eine|einen|zu|dem|wir|sie|auch|wird|sind|von|noch|aber|oder|wenn|dass|habe|kann|jetzt|hier|nur|schon|mehr|dann|nach|wurde|werden|keine|diese|dieser|datei|dateien|fehler|nein|bitte|danke'),
|
|
438
|
+
DA_W = wordsRe('og|det|jeg|ikke|til|på|har|vi|som|vil|skal|også|eller|fra|så|nu|kun|mere|efter|ved|blev|bliver|ingen|denne|dette|filen|filer|fejl|være|været|hvis|når|af|tak|nej');
|
|
439
|
+
const langOf = (t) => { // the language a line clearly reads as ('fr', 'en', 'es', 'pt', 'de', 'da', 'ja', 'ko', 'zh'), else null: the voice then follows the language of the call
|
|
440
|
+
t = String(t || ''); const n = (re) => (t.match(re) || []).length, kana = n(/[\u3040-\u30ff]/g), hang = n(/[\uac00-\ud7af]/g), han = n(/[\u4e00-\u9fff]/g), cjk = kana + hang + han;
|
|
441
|
+
if (cjk >= 2 && cjk * 3 > n(/[A-Za-z]/g)) return kana || (prefs.lang === 'ja' && !hang) ? 'ja' : hang > han ? 'ko' : 'zh'; // by the script; Japanese without a single kana is rare, and then the interface says
|
|
442
|
+
const fr = n(FR_W) + n(/[éèêàçùâîôûœ]/g), en = n(EN_W), [[lo, top], [, next]] = [['es', n(ES_W) + n(/[ñ¿¡]/g)], ['pt', n(PT_W) + n(/[ãõ]/g)], ['de', n(DE_W) + n(/[äöüß]/g)], ['da', n(DA_W) + n(/[æøå]/g)]].sort((a, b) => b[1] - a[1]);
|
|
443
|
+
if (top >= 2 && top > next * 1.5 && top > n(FR_S) * 1.5 && top > en * 1.5) return lo; // against the French words alone: é, à, ç are Portuguese and Spanish letters too
|
|
444
|
+
return fr >= 2 && fr > en * 1.5 && fr > n(/[áíóúñ¿¡ãõ]/g) * 2 ? 'fr' : en >= 2 && en > fr * 1.5 ? 'en' : null; // á, í, ó, ú, ñ, ã are never French: "está" and "quién" would count as "est" and "qui"
|
|
365
445
|
};
|
|
366
446
|
const tr = (en) => (prefs.lang === 'en' || prefs.lang === 'fr' ? en : LOC[en] || en);
|
|
367
447
|
const L = (fr, en) => (FR() ? fr : tr(en));
|
|
368
448
|
async function loadLocale(code) { LOC = {}; if (code === 'en' || code === 'fr') return; try { const r = await fetch('/locales/' + encodeURIComponent(code) + '.json'); if (r.ok) LOC = await r.json(); } catch {} }
|
|
369
449
|
async function setLang(code, save) {
|
|
370
450
|
if (!LANGS.some((l) => l[0] === code)) code = 'en'; prefs.lang = code; await loadLocale(code); if (save) { prefs.langChosen = true; savePrefs(); }
|
|
371
|
-
if (
|
|
451
|
+
if (TRL()) fetch('/api/warm?lang=' + CALL()).catch(() => {}); AUD.stopAll(); synth && synth.cancel(); applyLang(); if (TRL()) prefetchTr(S.idx); kokoroUI(); voiceOffer(); callNote(); /* its texts, and the offer to add the voices of this language */
|
|
372
452
|
}
|
|
373
453
|
|
|
374
454
|
// =====================================================================
|
|
@@ -530,7 +610,7 @@ function avatarSVG(p, o, uid = '') { // uid keeps SVG ids unique per instance:
|
|
|
530
610
|
const S = { owner: null, errRun: {}, exQ: [], agents: {}, events: [], idx: 0, playing: false, token: 0, status: {}, tc: {}, cur: null, live: true, userPaused: false, boost: 1, stopAt: 0,
|
|
531
611
|
speakers: new Set(), say: {}, lastTool: {}, level: {}, detail: null, collapsed: new Set(), title: '', idle: false, locked: true, logTo: 0, trOk: true,
|
|
532
612
|
clock: 0, doneAt: {}, gone: new Set(), leaving: new Set(), demo: false, hold: false, late: [], byK: new Map(), pos: 0 };
|
|
533
|
-
if (Q.get('pin')) S.
|
|
613
|
+
if (Q.get('pin')) S.pick = { proj: Q.get('pproj') || '', id: Q.get('pin') }; // pproj: where that session is kept, when it is not the folder the window follows (a Vibe or Codex session, see openPanel in extension.js). A session asked for in the address (the status bar opens the call on one): set here, once S exists (set above it, it stopped the whole page)
|
|
534
614
|
const VANISH_MS = 120000; // a finished agent leaves the call after 2 minutes (playback time)
|
|
535
615
|
// Live: how far the call is behind the real session, and what to do about it (speak faster, say less, skip decoration) so it keeps the rhythm of the real conversation
|
|
536
616
|
const lagMs = (i = S.idx) => { // how much newer the newest event of the session is than the one being played: 0 when the call is up to date, however long the session has been idle
|
|
@@ -593,35 +673,37 @@ const speakable = (t) => t.replace(/https?:\/\/(?:www\.)?([\w-]+(?:\.[\w-]+)*)\S
|
|
|
593
673
|
.replace(/\s*[—–]\s*/g, ', ').replace(/\(([^)]{0,40})\)/g, ', $1,').replace(/\s+/g, ' ').trim();
|
|
594
674
|
|
|
595
675
|
// ---------- translation (local claude CLI) ----------
|
|
596
|
-
const
|
|
676
|
+
const trMaps = {}, trMap = (l = CALL()) => (trMaps[l] = trMaps[l] || new Map()), trPending = new Map();
|
|
677
|
+
const trMem = { has: (t) => trMap().has(t), get: (t) => trMap().get(t), set: (t, v, l) => trMap(l).set(t, v) }; // one memory per language of the call: what was translated into French is not what is said in Spanish
|
|
597
678
|
const baseText = (ev, max) => short(ev.text, max || (S.live ? (ev.kind === 'order' ? 220 : 180) : (ev.kind === 'order' ? 200 : 230)));
|
|
598
679
|
function ensureTr(texts) {
|
|
599
|
-
|
|
600
|
-
|
|
680
|
+
const lang = CALL(), pk = (t) => lang + '|' + t; if (lang === 'en') return Promise.resolve([]);
|
|
681
|
+
texts = [...new Set(texts)].filter((t) => t && !trMem.has(t)).filter((t) => langOf(t) !== lang); // already in the language of the call: nothing to translate
|
|
682
|
+
const waits = texts.filter((t) => trPending.has(pk(t))).map((t) => trPending.get(pk(t))), fresh = texts.filter((t) => !trPending.has(pk(t)));
|
|
601
683
|
if (fresh.length) {
|
|
602
|
-
const pr = fetch('/api/translate', { method: 'POST', body: JSON.stringify({ texts: fresh }) }).then((r) => r.json()).then((d) => {
|
|
603
|
-
(d.texts || []).forEach((
|
|
684
|
+
const pr = fetch('/api/translate', { method: 'POST', body: JSON.stringify({ texts: fresh, lang }) }).then((r) => r.json()).then((d) => {
|
|
685
|
+
(d.texts || []).forEach((x, i) => trMem.set(fresh[i], x, lang)); S.trOk = d.ok !== false; if (!S.trOk) loadHealth(); else updateHint();
|
|
604
686
|
clearTimeout(S.relog); S.relog = setTimeout(() => renderLog(true), 500);
|
|
605
|
-
}).catch(() => { S.trOk = false; loadHealth(); }).finally(() => fresh.forEach((t) => trPending.delete(t)));
|
|
606
|
-
fresh.forEach((t) => trPending.set(t, pr)); waits.push(pr);
|
|
687
|
+
}).catch(() => { S.trOk = false; loadHealth(); }).finally(() => fresh.forEach((t) => trPending.delete(pk(t))));
|
|
688
|
+
fresh.forEach((t) => trPending.set(pk(t), pr)); waits.push(pr);
|
|
607
689
|
}
|
|
608
690
|
return Promise.all(waits);
|
|
609
691
|
}
|
|
610
692
|
function trNew(from) { // live: start translating every new line the moment it arrives (small parallel calls)
|
|
611
|
-
if (!
|
|
693
|
+
if (!TRL()) return; for (let k = from; k < S.events.length; k++) if (!quiet(S.events[k])) ensureTr([baseText(S.events[k])]);
|
|
612
694
|
}
|
|
613
695
|
function prefetchTr(i) {
|
|
614
|
-
if (!
|
|
696
|
+
if (!TRL() || S.live) return; const t = [];
|
|
615
697
|
for (let k = i; k < Math.min(S.events.length, i + 120) && t.length < 24; k++) if (!quiet(S.events[k])) t.push(baseText(S.events[k]));
|
|
616
698
|
ensureTr(t);
|
|
617
699
|
}
|
|
618
700
|
function spoken(ev) {
|
|
619
|
-
let t = baseText(ev); if (
|
|
701
|
+
let t = baseText(ev); if (TRL() && trMem.has(t)) t = trMem.get(t);
|
|
620
702
|
if (ev.kind === 'order') return `${nameOf(ev.to)}, ${t}`;
|
|
621
703
|
if (ev.kind === 'report') return L('Terminé. ', 'Done. ') + t;
|
|
622
704
|
return t;
|
|
623
705
|
}
|
|
624
|
-
async function loadHealth() { try { S.health = await (await fetch('/api/health')).json(); } catch {} updateHint(); }
|
|
706
|
+
async function loadHealth() { try { S.health = await (await fetch('/api/health')).json(); noTr = S.health.claude === null && !S.health.apiKey; } catch {} updateHint(); }
|
|
625
707
|
function trProblem() { // why translation can't work, with what to do about it
|
|
626
708
|
const h = S.health || {};
|
|
627
709
|
if (h.claude === null && !h.apiKey) return L('Claude Code est introuvable : installez-le (npm i -g @anthropic-ai/claude-code) ou indiquez son chemin dans le réglage « agentStandup.claudePath ».', 'Claude Code not found: install it (npm i -g @anthropic-ai/claude-code) or set its path in the “agentStandup.claudePath” setting.');
|
|
@@ -630,7 +712,7 @@ function trProblem() { // why translation can't work, with what to do about it
|
|
|
630
712
|
return L('Traduction indisponible pour l’instant : vérifiez que « claude » fonctionne dans un terminal.', 'Translation unavailable right now: check that “claude” works in a terminal.');
|
|
631
713
|
}
|
|
632
714
|
function updateHint() {
|
|
633
|
-
const h = $('#trHint'), noFr = FR() && TTS.server && !TTS.pool.fr.length, noTts = prefs.voice && !TTS.server && TTS.platform !== '', noRadio = prefs.music && RADIO.err, other = elsewhere(), bad = (
|
|
715
|
+
const h = $('#trHint'), noFr = FR() && TTS.server && !babbles() && !TTS.pool.fr.length, noTts = prefs.voice && prefs.vstyle === 'cartoon' && !TTS.server && TTS.platform !== '', noRadio = prefs.music && RADIO.err, other = elsewhere(), bad = (TRL() && !S.trOk) || noFr || noTts || noRadio || other;
|
|
634
716
|
h.style.display = bad ? '' : 'none';
|
|
635
717
|
h.textContent = other ? L('Le son est joué dans une autre fenêtre Agent Standup. Cliquez sur 🔈 pour le reprendre ici.', 'Sound is playing in another Agent Standup window. Click 🔈 to take it over here.') : noRadio ? L('Radio injoignable : vérifiez votre connexion ou changez de station.', 'Radio unreachable: check your connection or pick another station.') : noFr ? L('Aucune voix française installée (Windows : Paramètres › Heure et langue › Voix).', 'No French voice installed (Windows: Settings › Time & language › Speech).') : noTts ? L('Aucune voix système trouvée : les agents marmonneront.', 'No system voice found: agents will mumble.') : trProblem();
|
|
636
718
|
}
|
|
@@ -671,6 +753,10 @@ const AUD = {
|
|
|
671
753
|
const s = c.createBufferSource(); s.buffer = b; const hp = c.createBiquadFilter(); hp.type = 'highpass'; hp.frequency.value = 1800 + Math.random() * 1500; const g = c.createGain(); g.gain.value = 0.18; s.connect(hp).connect(g).connect(this.sfx); s.start();
|
|
672
754
|
},
|
|
673
755
|
join() { this.tone(523, .14, 'triangle', .1); this.tone(784, .2, 'triangle', .1, .12); },
|
|
756
|
+
knock() { // someone at the door: a visitor from another session. Like the chime above, it is heard with the ambience off
|
|
757
|
+
if (!this.ctx || this.off()) return; const c = this.ctx;
|
|
758
|
+
[[196, 0], [196, 0.17], [247, 0.34]].forEach(([f, w]) => { const t = c.currentTime + w, o = c.createOscillator(), g = c.createGain(); o.type = 'triangle'; o.frequency.value = f; g.gain.setValueAtTime(0.22, t); g.gain.exponentialRampToValueAtTime(0.001, t + 0.12); o.connect(g).connect(c.destination); o.start(t); o.stop(t + 0.13); });
|
|
759
|
+
},
|
|
674
760
|
ding() { this.tone(988, .5, 'triangle', .14); this.tone(1318, .5, 'sine', .06, .02); },
|
|
675
761
|
murmur(pitch, dur, vol = 1) { // cartoon mumble, used when there is no real voice (vol: lower for a thought that escapes)
|
|
676
762
|
if (!this.ctx || !prefs.voice) return; const c = this.ctx, t = c.currentTime, o = c.createOscillator(); o.type = 'sawtooth';
|
|
@@ -763,34 +849,37 @@ const estMs = (text) => Math.min(9000, 900 + text.length * 42) / spd();
|
|
|
763
849
|
|
|
764
850
|
const NOVELTY = /grandma|grandpa|rocko|bad news|bahh|bells|boing|bubbles|cellos|good news|jester|organ|superstar|trinoids|whisper|wobble|zarvox|albert|fred|junior|kathy|ralph|hysterical|deranged|pipe/i;
|
|
765
851
|
const ROBOT = /^(eddy|flo|reed|sandy|shelley)\b/i; /* Apple's synthetic voices: understandable, and plainly a machine. Kept for when nothing else is installed */
|
|
766
|
-
const GOOD = /premium|enhanced|natural|siri|neural|améli|amelie|thomas|jacques|audrey|aurélie|aurelie|marie|samantha|daniel|karen|moira|serena|oliver|google|hortense|julie|paul|denise|henri|eloise|zira|david|hazel|mark|aria|guy/i;
|
|
852
|
+
const GOOD = /premium|enhanced|natural|siri|neural|améli|amelie|thomas|jacques|audrey|aurélie|aurelie|marie|samantha|daniel|karen|moira|serena|oliver|google|hortense|julie|paul\b|denise|henri|eloise|zira|david|hazel|mark|aria|guy/i;
|
|
767
853
|
const voiceScore = (n) => (/premium|enhanced|natural|neural|siri/i.test(n) ? 100 : 0) + (GOOD.test(n) ? 30 : 0) - (ROBOT.test(n) ? 50 : 0) - (NOVELTY.test(n) ? 200 : 0);
|
|
768
|
-
const
|
|
854
|
+
const VLANGS = ['fr', 'en', 'es', 'pt', 'de', 'da', 'ja', 'ko', 'zh'], HOME = { fr: 'fr_FR', es: 'es_ES', pt: 'pt_BR', de: 'de_DE', da: 'da_DK', ja: 'ja_JP', ko: 'ko_KR', zh: 'zh_CN' }; /* the languages a line can be said in; where each is from when the computer does not say */
|
|
855
|
+
const noVoices = () => Object.fromEntries(VLANGS.map((l) => [l, []]));
|
|
856
|
+
const homeOf = (lang) => (lang === 'zh' && /^zh-/.test(prefs.lang) ? prefs.lang.replace('-', '_') : null) || [...(navigator.languages || []), navigator.language || ''].map((l) => String(l).replace('-', '_')).find((l) => new RegExp('^' + lang + '_[A-Z]{2}$').test(l)) || HOME[lang]; /* French from France unless the computer itself is set to another French */
|
|
769
857
|
function rankVoices(list, lang) { // [{ name, locale }] → names, best distinct voices first. The synthetic ones only when fewer than two others exist
|
|
770
|
-
const home = lang
|
|
858
|
+
const home = HOME[lang] ? homeOf(lang) : '', sc = (v) => voiceScore(v.name) + (home && v.locale === home ? 10 : 0), seen = new Set(), out = [];
|
|
771
859
|
[...list].sort((a, b) => sc(b) - sc(a)).forEach((v) => { const base = v.name.replace(/\s*\(.*$/, ''), x = sc(v); if (x > -100 && (x >= 0 || out.length < 2) && !seen.has(base)) { seen.add(base); out.push(v.name); } });
|
|
772
860
|
return out.slice(0, 5);
|
|
773
861
|
}
|
|
774
862
|
const TTS = {
|
|
775
|
-
server: false, engine: 'system', platform: '', pool:
|
|
863
|
+
server: false, engine: 'system', platform: '', pool: noVoices(), sys: noVoices(), kv: new Set(), cache: new Map(), made: new Map(), q: [], busy: false, now: 0,
|
|
776
864
|
async init() {
|
|
777
|
-
this.engine = 'system'; this.server = false; this.pool =
|
|
865
|
+
this.engine = 'system'; this.server = false; this.pool = noVoices(); this.sys = noVoices(); this.kv = new Set(); this.cache.clear(); this.made.clear(); this.q = [];
|
|
778
866
|
try {
|
|
779
|
-
let k = null; if (prefs.vstyle === 'kokoro') { try { k = await (await fetch('/api/voices?engine=kokoro')).json(); } catch {} if (!k || !k.available || !k.ready) k = null; } //
|
|
867
|
+
let k = null; if (prefs.vstyle === 'kokoro') { try { k = await (await fetch('/api/voices?engine=kokoro')).json(); } catch {} if (!k || !k.available || !k.ready) k = null; } // the real voices, installed on demand; until they are ready the agents babble (see babbles)
|
|
780
868
|
let d = { available: false, voices: [] }; try { d = await (await fetch('/api/voices')).json(); } catch {}
|
|
781
|
-
this.platform = d.platform || (k && k.platform) || ''; const sys = {}
|
|
782
|
-
|
|
869
|
+
this.platform = d.platform || (k && k.platform) || ''; const sys = {}, of = (l) => { const all = d.voices.filter((v) => v.locale.startsWith(l + '_')), home = all.filter((v) => v.locale === homeOf(l)); return l === 'zh' && home.length ? home : all; }; /* Chinese: the voices of one place only, a Cantonese voice does not read Mandarin */
|
|
870
|
+
for (const l of VLANGS) sys[l] = d.available ? rankVoices(of(l), l) : [];
|
|
871
|
+
if (k) { // Kokoro speaks the languages the server lists voices for (English, and French, Spanish and Portuguese once their phonemizer is installed); a line in another language (German, Japanese…) is read by a system voice of that language, each character keeping one of its own
|
|
783
872
|
this.server = true; this.engine = 'kokoro'; this.sys = sys;
|
|
784
|
-
for (const l of
|
|
873
|
+
for (const l of VLANGS) { const kv = k.voices.filter((v) => v.locale.startsWith(l + '_')).map((v) => v.name); kv.forEach((v) => this.kv.add(v)); this.pool[l] = kv.length ? kv : sys[l]; }
|
|
785
874
|
return;
|
|
786
875
|
}
|
|
787
876
|
if (!d.available) return; this.server = true; this.pool = sys; } catch {}
|
|
788
877
|
},
|
|
789
|
-
voiceFor(p,
|
|
878
|
+
voiceFor(p, lo = CALL()) { const pool = this.pool[lo].length || lo === 'fr' ? this.pool[lo] : this.pool.en; return pool.length ? (p.id === 'main' ? pool[0] : pool[(p.vi >>> 2) % pool.length]) : null; },
|
|
790
879
|
rate() { return Math.round(Math.max(120, Math.min(330, 178 * (S.live ? 1.12 * lagFactor() * (S.boost > 1 ? 1.25 : 1) : +$('#speed').value))) / 10) * 10; },
|
|
791
880
|
rateAt(k, boost) { const i = S.idx, b = S.boost; S.idx = k; S.boost = boost; const r = this.rate(); S.idx = i; S.boost = b; return r; }, // the rate rate() will give once playback is at event k
|
|
792
881
|
buf(text, voice, rate, ahead) { // ahead: made in advance (see warmTTS); otherwise the line is wanted now
|
|
793
|
-
const eng = this.kv.has(voice) ? 'kokoro' : 'system', fb = eng === 'kokoro' && this.sys.
|
|
882
|
+
const eng = this.kv.has(voice) ? 'kokoro' : 'system', vl = VLANGS.find((l) => this.pool[l].includes(voice)) || 'en', fb = eng === 'kokoro' && this.sys[vl].length ? this.sys[vl][Math.max(0, this.pool[vl].indexOf(voice)) % this.sys[vl].length] : ''; /* fb: the system voice of the same language that reads the line if Kokoro cannot */
|
|
794
883
|
const vt = eng + '|' + voice + '|' + text, K = (r) => eng + '|' + voice + '|' + r + '|' + text, key = K(rate), got = this.made.get(vt) || []; // got: the rates at which this text is ready in this voice
|
|
795
884
|
if (!ahead && S.live && !got.includes(rate)) { const r = got.find((x) => Math.abs(x - rate) <= rate * 0.2 && this.cache.has(K(x))); if (r) return this.cache.get(K(r)); } // made ahead at the rate of a moment ago (the call fell behind or caught up since): played as it is, a second of silence is worse than a slightly different pace
|
|
796
885
|
if (!this.cache.has(key)) {
|
|
@@ -806,6 +895,7 @@ const TTS = {
|
|
|
806
895
|
const end = () => { this.busy = false; this.pump(); }; this.buf(j.text, j.voice, j.rate, true).then(end, end);
|
|
807
896
|
},
|
|
808
897
|
};
|
|
898
|
+
const babbles = () => prefs.vstyle !== 'kokoro' || TTS.engine !== 'kokoro'; // babble: by choice (Animal Crossing), or because the real voices are not there yet (not installed, downloading, loading, stopped). A system voice only reads a line of a language the model lacks
|
|
809
899
|
// The lines to come are synthesized ahead of time, so that a voice starts with its line and not a second later. What is made must be what will be asked for: the same text (the lead-in, the part
|
|
810
900
|
// that is read when the call is behind), the same voice and the same rate. So this follows what run() will do with the next events if nothing else arrives before then: how it groups them
|
|
811
901
|
// (sub-agents back to back, orders in a row) and how it sets the pace. Keep the two in step: a difference costs nothing but the benefit (the line is then made when it is said).
|
|
@@ -815,7 +905,7 @@ function paceAt(k) {
|
|
|
815
905
|
return { hurry, pace: Math.min(q > 7 ? 70 : q > 3 ? 130 : 260, lg > 30 ? 70 : lg > 15 ? 130 : lg > 6 ? 200 : 260), boost: hurry || S.events.length - k > 60 ? 3 : 1 };
|
|
816
906
|
}
|
|
817
907
|
function warmTTS(i) { // called by run() before each line (i is that line) and when new events arrive (i is the first of them)
|
|
818
|
-
if (!TTS.server || !AUD.ctx || AUD.off() || !prefs.voice ||
|
|
908
|
+
if (!TTS.server || !AUD.ctx || AUD.off() || !prefs.voice || babbles()) return;
|
|
819
909
|
const fresh = i <= S.idx, from = fresh ? i : S.idx + 1, len = S.events.length, jobs = []; let n = 0; if (!fresh && !S.playing) return; // new events while a line is being read: the lines after it are planned again, they may now be read shorter and faster
|
|
820
910
|
for (let k = from; k < Math.min(len, from + 400) && n < 4;) {
|
|
821
911
|
const e = S.events[k]; if (quiet(e)) { k++; continue; }
|
|
@@ -825,8 +915,8 @@ function warmTTS(i) { // called by run() before each line (i is that line) and
|
|
|
825
915
|
else if (isSub(e.agent)) { while (j < Math.min(len, k + 28) && group.length < 3) { const e2 = S.events[j]; if (quiet(e2)) j++; else if (e2.kind !== 'order' && isSub(e2.agent) && !group.some((g) => g.agent === e2.agent)) { group.push(e2); j++; } else break; } }
|
|
826
916
|
const pl = paceAt(k), many = e.kind === 'order' && group.length > 1, rate = TTS.rateAt(many || !S.live ? k : j - 1, pl.boost);
|
|
827
917
|
for (const g of many ? [e] : group) { // orders in a row: only the first is read out
|
|
828
|
-
n++; const p = S.agents[g.agent], bt = baseText(g); if ((pl.hurry && g.kind !== 'user') || !p || (
|
|
829
|
-
const said = clipSpeech(talkLine(g), pl.pace), text = speakable(said), voice = TTS.voiceFor(p,
|
|
918
|
+
n++; const p = S.agents[g.agent], bt = baseText(g); if ((pl.hurry && g.kind !== 'user') || !p || (TRL() && !trMem.has(bt) && langOf(bt) !== CALL())) continue; // not translated yet: what will be said is not known
|
|
919
|
+
const said = clipSpeech(talkLine(g), pl.pace), text = speakable(said), voice = TTS.voiceFor(p, sessVoice(said, g)); if (text && voice) jobs.push({ k, text, voice, rate });
|
|
830
920
|
}
|
|
831
921
|
k = j;
|
|
832
922
|
}
|
|
@@ -856,7 +946,7 @@ const vowelKey = (ch) => ({ à: 'a', â: 'a', ä: 'a', é: 'e', è: 'e', ê: 'e'
|
|
|
856
946
|
async function speakBabble(text, p, gain, token) {
|
|
857
947
|
const c = AUD.ctx, sims = prefs.vstyle === 'sims', clean = speakable(text).toLowerCase(), dur = estMs(text) / 1000, noise = OFFICE.noise();
|
|
858
948
|
const base = p.lead ? 150 : p.id === 'user' ? 190 : 200 + ((p.vi >>> 2) % 9) * 30, an = c.createAnalyser(); an.fftSize = 256;
|
|
859
|
-
const g = c.createGain(); g.gain.value = gain * (sims ? 0.4 : 0.
|
|
949
|
+
const g = c.createGain(); g.gain.value = gain * (sims ? 0.4 : 0.45 * Math.max(0.7, Math.min(1.25, 300 / base))); an.connect(g); g.connect(AUD.voice); // the blips of a high voice came out twice as loud as those of the lead: evened out
|
|
860
950
|
const clauses = clean.match(/[^.!?;:]+[.!?;:]*/g) || [clean], nodes = []; let t = c.currentTime + 0.03; const end = t + dur;
|
|
861
951
|
let tail = 0; const track = (o) => { AUD.live.add(o); nodes.push(o); tail = t; }; // tail: when the last sound starts
|
|
862
952
|
const vowelGroups = (w) => w.match(new RegExp(`[^${VOW}]*[${VOW}]+(?:[^${VOW}]+(?![${VOW}]))?`, 'g')) || [w];
|
|
@@ -872,8 +962,8 @@ async function speakBabble(text, p, gain, token) {
|
|
|
872
962
|
for (const ch of w) {
|
|
873
963
|
const code = ch.charCodeAt(0), f = base * m * 2 ** (((code % 7) * 2 - 4 + (VOW.includes(ch) ? 3 : 0)) / 12), vw = [...'aeiou'][code % 5];
|
|
874
964
|
const o = c.createOscillator(), bp = c.createBiquadFilter(), env = c.createGain(); o.type = 'triangle'; o.frequency.setValueAtTime(f, t); o.frequency.linearRampToValueAtTime(f * (1 + ((code % 3) - 1) * 0.07), t + letterStep);
|
|
875
|
-
bp.type = 'bandpass'; bp.frequency.value = FORM[vw][0] * 1.3; bp.Q.value = 1.4; env.gain.setValueAtTime(0
|
|
876
|
-
o.connect(bp).connect(env).connect(an); o.start(t); o.stop(t + letterStep); track(o); t += letterStep;
|
|
965
|
+
bp.type = 'bandpass'; bp.frequency.value = FORM[vw][0] * 1.3; bp.Q.value = 1.4; env.gain.setValueAtTime(0, t); env.gain.linearRampToValueAtTime(1, t + 0.008); env.gain.setTargetAtTime(0, t + 0.008, letterStep * 0.2); // a blip, not a click: it used to jump to full level in 2 ms and be gone 10 ms later, too short for its note to be heard. Same notes, same rhythm, a rounder start and a tail
|
|
966
|
+
o.connect(bp).connect(env).connect(an); o.start(t); o.stop(t + letterStep * 1.5); track(o); t += letterStep;
|
|
877
967
|
}
|
|
878
968
|
t += letterStep * 0.8;
|
|
879
969
|
} else {
|
|
@@ -897,12 +987,12 @@ async function speakBabble(text, p, gain, token) {
|
|
|
897
987
|
await new Promise((res) => { if (lastN) lastN.onended = res; setTimeout(res, lastN ? (t - c.currentTime) * 1000 + 600 : Math.max(100, (Math.min(t, end) - c.currentTime) * 1000 + 80)); }); // the line ends when its last sound does (a long last word used to go on after it), or when Pause stops it
|
|
898
988
|
nodes.forEach((o) => AUD.live.delete(o)); delete S.level[p.id];
|
|
899
989
|
}
|
|
900
|
-
async function speakServer(text, p, gain, token,
|
|
901
|
-
const voice = TTS.voiceFor(p,
|
|
990
|
+
async function speakServer(text, p, gain, token, lo = CALL()) {
|
|
991
|
+
const voice = TTS.voiceFor(p, lo); if (!voice) throw new Error('no voice');
|
|
902
992
|
const buf = await TTS.buf(speakable(text), voice, TTS.rate()); if (token !== S.token) return;
|
|
903
993
|
const c = AUD.ctx, src = c.createBufferSource(); src.buffer = buf;
|
|
904
994
|
const an = c.createAnalyser(); an.fftSize = 256; const g = c.createGain(); g.gain.value = gain; let stops = [];
|
|
905
|
-
if (prefs.vstyle === '
|
|
995
|
+
if (prefs.vstyle === 'cartoon') { const ch = fxChain(c, src, fxFor(p)); stops = ch.stops; ch.node.connect(an); } else src.connect(an);
|
|
906
996
|
an.connect(g); g.connect(AUD.voice);
|
|
907
997
|
const data = new Uint8Array(an.fftSize);
|
|
908
998
|
S.level[p.id] = () => { an.getByteTimeDomainData(data); let s = 0; for (const v of data) { const x = (v - 128) / 128; s += x * x; } return Math.sqrt(s / data.length); }; // drives the mouth
|
|
@@ -911,10 +1001,10 @@ async function speakServer(text, p, gain, token, fr = FR()) {
|
|
|
911
1001
|
captionRun(p.id, text, ms); await new Promise((res) => { src.onended = res; setTimeout(res, ms + 1000); src.start(); }); // the line ends when its sound ends (or when Pause stops it); the timer only covers a sound that never starts
|
|
912
1002
|
try { src.stop(); } catch {} AUD.live.delete(src); delete S.level[p.id]; stops.forEach((o) => { try { o.stop(); } catch {} });
|
|
913
1003
|
}
|
|
914
|
-
function speakBrowser(text, p, token,
|
|
1004
|
+
function speakBrowser(text, p, token, lo = CALL()) { // the browser's own voice, when the server could not make the line
|
|
915
1005
|
return new Promise((resolve) => {
|
|
916
|
-
const vs = synth.getVoices().filter((v) => v.lang.toLowerCase().startsWith(
|
|
917
|
-
const ranked = rankVoices(vs.map((v) => ({ name: v.name, locale: v.lang.replace('-', '_') })),
|
|
1006
|
+
const vs = synth.getVoices().filter((v) => v.lang.toLowerCase().startsWith(lo)); if (!vs.length) return resolve(false);
|
|
1007
|
+
const ranked = rankVoices(vs.map((v) => ({ name: v.name, locale: v.lang.replace('-', '_') })), lo), voice = vs.find((v) => v.name === (p.id === 'main' ? ranked[0] : ranked[(p.vi >>> 2) % ranked.length])) || vs[0];
|
|
918
1008
|
const parts = speakable(text).match(/[^.!?;:]+[.!?;:]*/g) || [text]; synth.cancel(); let i = 0, done = false, started = false, t0 = 0, said = 0; const all = parts.reduce((n, x) => n + x.length, 0);
|
|
919
1009
|
const fin = (ok) => { if (!done) { done = true; resolve(ok); } };
|
|
920
1010
|
setTimeout(() => { if (!started && !done) { synth.cancel(); fin(false); } }, 2500); // engine never started (e.g. inside a webview)
|
|
@@ -923,7 +1013,7 @@ function speakBrowser(text, p, token, fr = FR()) { // fallback where no server
|
|
|
923
1013
|
if (i >= parts.length || done || token !== S.token) return fin(true);
|
|
924
1014
|
if (t0 && said >= 20) { const el = performance.now() - t0; captionRun(p.id, text, el * all / said, el); } // the length of the audio is not known in advance here: the subtitles are set again on the pace the voice really has, after each sentence
|
|
925
1015
|
said += parts[i].length; const part = parts[i++].trim(); if (!part) return next();
|
|
926
|
-
const u = new SpeechSynthesisUtterance(part); u.lang =
|
|
1016
|
+
const u = new SpeechSynthesisUtterance(part); u.lang = lo === 'en' ? 'en-US' : homeOf(lo).replace('_', '-'); u.voice = voice; u.pitch = prefs.vstyle !== 'cartoon' ? 0.95 + ((p.vi >>> 5) % 5) * 0.03 : p.id === 'main' ? 0.8 : [1.5, 0.6, 1.2, 1.7, 0.9, 0.5, 1.35][(p.vi >>> 3) % 7]; u.rate = Math.min(1.7, 0.97 * spd());
|
|
927
1017
|
u.onstart = () => { started = true; if (!t0) { t0 = performance.now(); captionRun(p.id, text, estMs(text)); } }; u.onend = () => setTimeout(next, 120); u.onerror = () => fin(started); synth.speak(u);
|
|
928
1018
|
};
|
|
929
1019
|
next();
|
|
@@ -953,34 +1043,36 @@ function captionRun(id, text, totalMs, from = 0) { // from: how far into the l
|
|
|
953
1043
|
for (const x of ps) { const when = at - from; if (when <= 0) cur = x; else timers.push(setTimeout(() => setCaption(id, x), when)); at += totalMs * x.length / n; }
|
|
954
1044
|
setCaption(id, cur); capTimers.set(id, timers);
|
|
955
1045
|
}
|
|
956
|
-
|
|
1046
|
+
// In a Spanish or Portuguese call every line is meant to be in that language (it was translated into it) unless it is plainly English: Spanish, Portuguese and French share too many short words to be told apart on one line.
|
|
1047
|
+
const inCall = (lo) => { const c = CALL(); return !lo ? c : (c === 'es' || c === 'pt') && lo !== 'en' ? c : lo; };
|
|
1048
|
+
const voiceLang = (t) => inCall(langOf(t)); // a French line gets a French voice whatever the language of the call, and the same for the others
|
|
957
1049
|
// A line of the session that is too short to tell ("OK.", a file name) does not follow the interface language: in a French session watched in English, the lead would change voice for that
|
|
958
1050
|
// one line and change back. It follows, in this order: the whole line it is cut from, what the same character said just before (its voice goes on) or says next, the language of the session so far.
|
|
959
|
-
// The session's language is counted once per line as the events arrive;
|
|
960
|
-
const SL = { ev0: null, ui: null, n: 0,
|
|
961
|
-
function sessLang() { //
|
|
962
|
-
const ev = S.events, ui =
|
|
963
|
-
if (ev[0] !== SL.ev0 || ui !== SL.ui || ev.length < SL.n) Object.assign(SL, { ev0: ev[0], ui, n: 0,
|
|
964
|
-
for (; SL.n < ev.length; SL.n++) { const e = ev[SL.n]; if (quiet(e) || typeof e.text !== 'string') continue; const t = baseText(e); if (
|
|
1051
|
+
// The session's language is counted once per line as the events arrive; when the call is translated, a line counts for what is said, i.e. its translation once it is there.
|
|
1052
|
+
const SL = { ev0: null, ui: null, n: 0, c: {}, pend: [] };
|
|
1053
|
+
function sessLang() { // the majority among the lines of the session that langOf can decide; null when there is none
|
|
1054
|
+
const ev = S.events, ui = CALL(), add = (t) => { const lo = langOf(t); if (lo) SL.c[lo] = (SL.c[lo] || 0) + 1; };
|
|
1055
|
+
if (ev[0] !== SL.ev0 || ui !== SL.ui || ev.length < SL.n) Object.assign(SL, { ev0: ev[0], ui, n: 0, c: {}, pend: [] }); // another session, or another language of the call
|
|
1056
|
+
for (; SL.n < ev.length; SL.n++) { const e = ev[SL.n]; if (quiet(e) || typeof e.text !== 'string') continue; const t = baseText(e); if (ui === 'en') add(t); else if (trMem.has(t)) add(trMem.get(t)); else if (langOf(t) === ui) SL.c[ui] = (SL.c[ui] || 0) + 1; else SL.pend.push(t); }
|
|
965
1057
|
if (SL.pend.length) SL.pend = SL.pend.filter((t) => !trMem.has(t) || add(trMem.get(t))); // translations that have arrived since
|
|
966
|
-
|
|
1058
|
+
const top = Object.entries(SL.c).sort((a, b) => b[1] - a[1]); return top.length && (top.length < 2 || top[0][1] > top[1][1]) ? top[0][0] : null;
|
|
967
1059
|
}
|
|
968
|
-
function
|
|
1060
|
+
function sessVoice(text, ev) { // for the lines that come from the session (ev: the event, when there is one); the little built-in lines keep voiceLang, they are written in the language of the call
|
|
969
1061
|
let lo = langOf(text);
|
|
970
1062
|
if (!lo && ev) {
|
|
971
|
-
const now = (e) => { const t = baseText(e); return langOf(
|
|
1063
|
+
const now = (e) => { const t = baseText(e); return langOf(TRL() && trMem.has(t) ? trMem.get(t) : t); }, at = S.events.indexOf(ev, Math.max(0, S.idx - 60)); lo = now(ev);
|
|
972
1064
|
for (let k = at - 1, n = 0; !lo && k >= 0 && k > at - 5000 && n < 6; k--) { const e = S.events[k]; if (e.agent === ev.agent && !quiet(e) && typeof e.text === 'string') { lo = now(e); n++; } }
|
|
973
1065
|
for (let k = at + 1, n = 0; !lo && at >= 0 && k < S.events.length && k < at + 5000 && n < 6; k++) { const e = S.events[k]; if (e.agent === ev.agent && !quiet(e) && typeof e.text === 'string') { lo = now(e); n++; } } // its first words: what it says next, when that is already there
|
|
974
1066
|
}
|
|
975
|
-
return (lo ?? sessLang()
|
|
1067
|
+
return inCall(lo ?? sessLang());
|
|
976
1068
|
}
|
|
977
|
-
async function speakLine(text, p, primary, token,
|
|
1069
|
+
async function speakLine(text, p, primary, token, lo = voiceLang(text), always = false) { // always: your own lines are voiced even when the call is behind
|
|
978
1070
|
captionRun(p.id, text, estMs(text));
|
|
979
1071
|
if (AUD.off() || !prefs.voice) { if (!AUD.off() && prefs.office) AUD.murmur(0.5 + (p.vi % 5) / 10, estMs(text) / 1000); return sleep(estMs(text)); }
|
|
980
1072
|
if (S.hurry && !always) return sleep(estMs(text));
|
|
981
|
-
|
|
982
|
-
if (TTS.server && AUD.ctx) { try { await speakServer(text, p, primary ? 1 : 0.5, token,
|
|
983
|
-
if (primary && synth && !EMBED && (await speakBrowser(text, p, token,
|
|
1073
|
+
const bab = babbles(); if (bab && AUD.ctx) { try { await speakBabble(text, p, primary ? 1 : 0.5, token); return; } catch {} }
|
|
1074
|
+
if (!bab && TTS.server && AUD.ctx) { try { await speakServer(text, p, primary ? 1 : 0.5, token, lo); return; } catch {} }
|
|
1075
|
+
if (!bab && primary && synth && !EMBED && (await speakBrowser(text, p, token, lo))) return;
|
|
984
1076
|
if (token !== S.token) return; // paused while a voice was being tried: no mumble after the fact
|
|
985
1077
|
const ms = estMs(text), o = AUD.murmur(0.5 + (p.vi % 5) / 10, ms / 1000); captionRun(p.id, text, ms);
|
|
986
1078
|
return o ? new Promise((res) => { o.addEventListener('ended', res); setTimeout(res, ms + 500); }) : sleep(ms); // the mumble that stands in for a voice: the line ends with it, also when Pause stops it
|
|
@@ -996,7 +1088,7 @@ function addTile(p) {
|
|
|
996
1088
|
}
|
|
997
1089
|
function buildStage() { // the tiles, and the presenter camera with them: a character change must never leave the old look in the corner of the shared screen
|
|
998
1090
|
$('#stage').innerHTML = ''; Object.values(S.agents).forEach(addTile); S.camFor = null;
|
|
999
|
-
const pr = S.present && S.agents[S.present]; if (pr) { $('#pcam').innerHTML = avatarSVG(pr, undefined, 'c' + pr.gid + '_') + `<div class="tag"><b>${esc(pr.name)}</b></div>`; S.camFor = pr.id; }
|
|
1091
|
+
const pr = S.present && S.agents[S.present]; if (pr) { $('#pcam').innerHTML = avatarSVG(pr, undefined, 'c' + pr.gid + '_') + `<div class="tag"><b>${esc(pr.name)}</b><span class="tk"></span></div>`; S.camFor = pr.id; camTok(); }
|
|
1000
1092
|
}
|
|
1001
1093
|
const layout = () => {
|
|
1002
1094
|
const st = $('#stage'), w = st.clientWidth - 28 || 600, nar = $('#center').clientWidth < 480, cols = nar ? (w >= 300 ? 2 : 1) : Math.max(1, Math.floor((w + 12) / 212)), colw = (w - 12 * (cols - 1)) / cols;
|
|
@@ -1053,6 +1145,7 @@ const applyStatus = (ev) => {
|
|
|
1053
1145
|
if (ev.kind === 'user' || (ev.agent === 'main' && (ev.kind === 'say' || ev.kind === 'tools' || (ev.kind === 'order' && !ev.wf)))) S.turnOver = !!ev.end; // Claude Code marks the message that closes the lead's turn; anything after it opens the next one (not the agents a workflow launches by itself)
|
|
1054
1146
|
};
|
|
1055
1147
|
function recomputeStatus(upTo) {
|
|
1148
|
+
S.files = new Map(); S.cands = new Map(); S.turnN = 0; S.turnSaid = ''; S.arts = new Map(); S.artCalls = new Map();
|
|
1056
1149
|
S.term = {}; S.todos = {}; S.run = {}; S.act = {}; S.usage = {}; S.errs = {}; S.lastAct = {}; S.waitOn = {}; S.orderTs = {}; S.prevState = {}; S.lastTool = {}; S.mainBusyAt = 0; S.turnOver = false; S.th = {}; S.ctx = {}; S.model = {}; S.cw = {}; S.compacts = {}; S.ctxWarned = {}; S.rep = {}; S.loops = {}; S.recomputing = true; document.querySelectorAll('.tile').forEach((t) => { clearTimeout(t._byeT); t.classList.remove('bye'); }); hidePresent();
|
|
1057
1150
|
S.status = {}; S.tc = {}; S.doneAt = {}; S.gone.clear(); S.leaving.clear(); document.querySelectorAll('.tile.vanishing').forEach((t) => t.classList.remove('vanishing')); const doneIdx = {}; document.querySelectorAll('.ticker').forEach((x) => { x.classList.remove('on'); x.innerHTML = ''; });
|
|
1058
1151
|
for (let i = 0; i < upTo; i++) {
|
|
@@ -1066,13 +1159,14 @@ function recomputeStatus(upTo) {
|
|
|
1066
1159
|
}
|
|
1067
1160
|
function syncUI() {
|
|
1068
1161
|
$('#bPlay').textContent = S.playing ? '⏸' : '▶';
|
|
1069
|
-
paintPill();
|
|
1162
|
+
paintPill(); paintTabs();
|
|
1070
1163
|
document.body.classList.toggle('replay', !S.live);
|
|
1071
1164
|
}
|
|
1072
1165
|
|
|
1073
1166
|
// ---------- tool ticker, shared screen, flying messages ----------
|
|
1074
1167
|
// ---------- what each agent is doing: tool calls with their real outputs ----------
|
|
1075
1168
|
S.term = {}; S.todos = {}; S.run = {}; S.act = {}; S.usage = {}; S.errs = {}; S.lastAct = {}; S.waitOn = {}; S.orderTs = {}; S.prevState = {}; S.ctx = {}; S.model = {}; S.cw = {}; S.compacts = {}; S.ctxWarned = {}; S.rep = {}; S.loops = {}; S.present = null; S.camFor = null; let presentTimer = null;
|
|
1169
|
+
S.files = new Map(); S.cands = new Map(); S.turnN = 0; S.turnSaid = ''; S.fgone = new Set(); S.fmade = new Map(); S.arts = new Map(); S.artCalls = new Map(); S.artOk = new Map(); S.artPin = null; // files: path → the Write call that created it, in the order they were written · cands: the documents the commands name (see candFile) · turnN: how many orders you gave so far · turnSaid: what you and the lead said in this turn · fgone: the files found missing on a click · fmade: what the server answered about a document a command names
|
|
1076
1170
|
const later = (k, fn, ms = 160) => { later.p = later.p || {}; if (later.p[k]) return; later.p[k] = setTimeout(() => { later.p[k] = 0; fn(); }, ms); }; // coalesce bursts of repaints
|
|
1077
1171
|
const fmtTok = (n) => (n < 1000 ? String(n) : n < 1e6 ? (n / 1000).toFixed(n < 1e4 ? 1 : 0) + 'k' : (n / 1e6).toFixed(n < 1e7 ? 2 : 1) + 'M');
|
|
1078
1172
|
const tokTotal = (u) => (u ? u.i + u.o + u.w : 0); // headline = input + output + cache writes; cache reads are cheap and shown separately
|
|
@@ -1087,10 +1181,11 @@ function loopStep(R, ev) { // R: per-agent repetition state; returns a detecti
|
|
|
1087
1181
|
}
|
|
1088
1182
|
const WIN1M = /(opus-4-[78]|opus-5|sonnet-5|fable-5)/;
|
|
1089
1183
|
function ctxWin(model, ctx) { const base = WIN1M.test(model || '') ? 1e6 : 2e5; return ctx > base ? 1e6 : base; } // the transcript does not say which window is in use: infer it, a bigger observed context proves the 1M window
|
|
1090
|
-
function tally(ev) { // numbers that pile up over a session: token usage, errors, last sign of life
|
|
1184
|
+
function tally(ev) { // numbers that pile up over a session: token usage, errors, last sign of life, the files it created
|
|
1185
|
+
noteFiles(ev);
|
|
1091
1186
|
if (ev.kind === 'compact') { S.compacts[ev.agent] = (S.compacts[ev.agent] || 0) + 1; delete S.ctxWarned[ev.agent]; }
|
|
1092
1187
|
const det = loopStep(S.rep, ev); if (det) { S.loops[ev.agent] = det; later('badges', renderBadges, 300); } else if (S.loops[ev.agent] && (ev.kind === 'results' ? (S.loops[ev.agent].kind === 'errors' && ev.items.every((it) => !it.err)) : (ev.kind === 'tools' && S.rep[ev.agent].n < 2))) { delete S.loops[ev.agent]; later('badges', renderBadges, 300); }
|
|
1093
|
-
if (ev.kind === 'usage') { const c = ev.u.i + ev.u.r + ev.u.w; if (c > 0 && ev.model !== '<synthetic>') { S.ctx[ev.agent] = c; S.model[ev.agent] = ev.model; if (ev.cw) S.cw[ev.agent] = ev.cw;
|
|
1188
|
+
if (ev.kind === 'usage') { const c = ev.u.i + ev.u.r + ev.u.w; if (c > 0 && ev.model !== '<synthetic>') { S.ctx[ev.agent] = c; S.model[ev.agent] = ev.model; if (ev.cw) S.cw[ev.agent] = ev.cw; } const u = (S.usage[ev.agent] = S.usage[ev.agent] || { i: 0, o: 0, r: 0, w: 0 }); u.i += ev.u.i; u.o += ev.u.o; u.r += ev.u.r; u.w += ev.u.w; later('tok', renderTokens, 300); } // which also redraws the context chips. Asking for those first, under the same name, left this one unasked: the counts on the tiles and in the header stood still during a live call
|
|
1094
1189
|
else if (ev.kind === 'results') ev.items.forEach((it) => { if (it.err) { S.errs[ev.agent] = (S.errs[ev.agent] || 0) + 1; later('badges', renderBadges, 300); oops(ev.agent); noteTrouble(ev.agent, false); } else noteTrouble(ev.agent, true); });
|
|
1095
1190
|
else if (ev.kind === 'tools' || ev.kind === 'say') S.lastAct[ev.agent] = ev.ts;
|
|
1096
1191
|
if (ev.th) S.th[ev.agent] = { text: ev.th, ts: ev.ts }; else if (ev.kind === 'user') delete S.th.main; // your order starts a new chain of thought: what the lead thought before is no longer what it is on
|
|
@@ -1109,8 +1204,12 @@ function renderTokens() {
|
|
|
1109
1204
|
renderCtx();
|
|
1110
1205
|
const all = { i: 0, o: 0, r: 0, w: 0 }; for (const id in S.usage) for (const k in all) all[k] += S.usage[id][k];
|
|
1111
1206
|
const b = $('#tok'), tot = tokTotal(all); b.style.display = tot ? '' : 'none';
|
|
1112
|
-
if (tot) { b.textContent = `⚡ ${fmtTok(tot)} ${L('jetons', 'tokens')}`; b.title = tokTip(all); }
|
|
1113
|
-
for (const id in S.agents) { const t = $('#t-' + id); if (!t) continue; const u = S.usage[id], el = t.querySelector('.tk'); el.textContent = u && tokTotal(u) ? `⚡${fmtTok(tokTotal(u))}` : ''; if (u) t.title = tokTip(u); }
|
|
1207
|
+
if (tot) { b.textContent = `⚡ ${fmtTok(tot)} ${L('jetons', 'tokens')}`; b.title = tokTip(all) + '\n' + Object.keys(S.usage).filter((id) => S.agents[id] && tokTotal(S.usage[id])).sort((x, y) => tokTotal(S.usage[y]) - tokTotal(S.usage[x])).slice(0, 14).map((id) => `\n${nameOf(id)} ⚡${fmtTok(tokTotal(S.usage[id]))}`).join(''); } // and who used what, the biggest first
|
|
1208
|
+
for (const id in S.agents) { const t = $('#t-' + id); if (!t) continue; const u = S.usage[id], el = t.querySelector('.tk'); el.textContent = u && tokTotal(u) ? `⚡${fmtTok(tokTotal(u))}` : ''; el.dataset.w = L('jetons', 'tokens'); if (u) t.title = tokTip(u); }
|
|
1209
|
+
camTok(); if (S.events.length && document.body.classList.contains('rost')) paintStates(); // the list of agents carries the counts too
|
|
1210
|
+
}
|
|
1211
|
+
function camTok() { // the one who shares a screen: what it has used so far, next to its name in the camera, as on its tile
|
|
1212
|
+
const el = $('#pcam .tk'), u = S.present && S.usage[S.present]; if (!el) return; el.textContent = u && tokTotal(u) ? `⚡${fmtTok(tokTotal(u))}` : ''; $('#pcam').title = u ? tokTip(u) : '';
|
|
1114
1213
|
}
|
|
1115
1214
|
// One boring signal per tile: working · waiting on another agent · may need you · stalled · done. Stalled hand-offs are what really cost time.
|
|
1116
1215
|
// file edits are instant, so one that stays pending is almost surely an approval prompt; a Bash command may legitimately run long (⏳ badge instead)
|
|
@@ -1118,7 +1217,7 @@ const NEEDS_OK = /^(Edit|Write|MultiEdit|NotebookEdit|AskUserQuestion|ExitPlanMo
|
|
|
1118
1217
|
const atTail = () => S.idx >= S.events.length - 3; // only trust wall-clock ages when playback has caught up with the live end
|
|
1119
1218
|
function agentState(id, now) {
|
|
1120
1219
|
let s = S.status[id]; const r = S.run[id], w = S.waitOn[id], la = S.lastAct[id];
|
|
1121
|
-
if (id === 'main' && !s) { // the lead is at work until the message that closes its turn, even while it thinks
|
|
1220
|
+
if (id === 'main' && !s) { // the lead is at work until the message that closes its turn, even while it thinks, and from its first turn on (the server says which transcripts carry that mark); one without it falls back on "quiet for 25 s", and a turn cut short on 3 minutes of silence
|
|
1122
1221
|
const open = S.live && la && (S.sawEnd ? !S.turnOver && now - la < 180000 : now - la < 25000);
|
|
1123
1222
|
if (r || (w && w.size) || open) s = 'working'; else if (S.live && la) return { k: 'done', txt: '✓ ' + L('à vous', 'your turn') };
|
|
1124
1223
|
}
|
|
@@ -1146,14 +1245,14 @@ function paintStates() {
|
|
|
1146
1245
|
if (st.k === 'done' && was && was !== 'done' && was !== 'idle') { pr.textContent = '🎉'; pr.className = 'prop cheer'; setTimeout(() => { if (pr.classList.contains('cheer')) { pr.textContent = ''; pr.className = 'prop'; } }, 1200); }
|
|
1147
1246
|
else if (!pr.classList.contains('cheer')) { if (pr.textContent !== want) pr.textContent = want; pr.className = 'prop ' + (want ? st.k : ''); }
|
|
1148
1247
|
if (shown && !S.gone.has(p.id)) ros.push({ p, st });
|
|
1149
|
-
if (p.id === 'main' && st.k === 'done' && was && was !== 'done' && was !== 'idle' && S.live && S.playing
|
|
1248
|
+
if (p.id === 'main' && st.k === 'done' && was && was !== 'done' && was !== 'idle' && S.live && S.playing) { S.wrap = was; if (Date.now() - (S.mainBusyAt || 0) > 45000) confetti(); } // the lead is done, its face says so: it always has a word for it (see wrapUp, which needs to know what it was doing just before), and confetti after a long turn
|
|
1150
1249
|
if (p.id === 'main') { if (st.k === 'working' || st.k === 'waiting') S.mainBusyAt = S.mainBusyAt || Date.now(); else if (st.k === 'done') S.mainBusyAt = 0; }
|
|
1151
1250
|
S.prevState[p.id] = st.k; const tip = `${p.name} — ${p.role}${st.txt ? '\n' + st.txt : ''}${S.lastTool[p.id] ? '\n' + S.lastTool[p.id] : ''}`; if (t.title !== tip) t.title = tip;
|
|
1152
1251
|
}
|
|
1153
1252
|
paintPill();
|
|
1154
1253
|
const b = $('#board'), parts = [['working', '⚙', L('au travail', 'working')], ['waiting', '🔗', L('en attente', 'waiting')], ['blocked', '✋', L('vous attendent', 'need you')], ['stalled', '⚠', L('bloqués', 'stalled')], ['done', '✓', L('terminés', 'done')]]
|
|
1155
1254
|
.filter(([k]) => n[k] && !S.pillSess).map(([k, i, l]) => `<span class="${k}" title="${n[k]} ${l}">${i} ${n[k]}<em> ${l}</em></span>`).join('');
|
|
1156
|
-
if (b.innerHTML !== parts) b.innerHTML = parts; fitBoard(); S.nBlocked = n.blocked + n.stalled; S.attn = attn; paintRoster(ros); return n;
|
|
1255
|
+
if (b.innerHTML !== parts) b.innerHTML = parts; fitBoard(); S.nBlocked = n.blocked + n.stalled; S.attn = attn; paintRoster(ros); paintFiles(); return n;
|
|
1157
1256
|
}
|
|
1158
1257
|
function fitBoard(force) { // the chips lose their words when they do not all fit (a long language, a narrower window): a chip is never cut mid-word. Tried again with the words only when the window or the texts around have changed
|
|
1159
1258
|
const b = $('#board'), key = innerWidth + '|' + b.textContent.length + '|' + $('#pill').textContent.length + '|' + $('#subtitle').textContent.length;
|
|
@@ -1162,15 +1261,19 @@ function fitBoard(force) { // the chips lose their words when they do not all
|
|
|
1162
1261
|
}
|
|
1163
1262
|
addEventListener('resize', () => fitBoard(true)); new ResizeObserver(() => requestAnimationFrame(() => fitBoard(true))).observe($('#board')); /* the room the chips have also changes when the texts beside them do (a title, a longer status) */
|
|
1164
1263
|
const RORDER = { blocked: 0, stalled: 1, working: 2, waiting: 3, idle: 4, done: 5 };
|
|
1264
|
+
const TOOL = { _codex: 'Codex', _vibe: 'Vibe', _cowork: 'Cowork' }, leadTool = (p) => (p.id === 'main' && S.cur && TOOL[S.cur.proj] ? ' · ' + TOOL[S.cur.proj] : ''); // a session that is not a Claude Code one says which tool runs it: on its tab, and next to its lead, who has the same name in every call
|
|
1265
|
+
const rosTok = (id) => { const u = S.usage[id]; return u && tokTotal(u) ? `<span class="rt" title="${esc(tokTip(u))}">⚡${fmtTok(tokTotal(u))}</span>` : ''; };
|
|
1165
1266
|
function paintRoster(ros) { // a fixed list beside the call: who is doing what, urgent first, readable even with dozens of agents
|
|
1166
1267
|
const box = $('#roster'); if (!box || !document.body.classList.contains('rost')) return;
|
|
1167
1268
|
ros.sort((a, b) => (a.p.id === 'main' ? -1 : b.p.id === 'main' ? 1 : (RORDER[a.st.k] - RORDER[b.st.k]) || (S.lastAct[b.p.id] || 0) - (S.lastAct[a.p.id] || 0)));
|
|
1168
|
-
const rows = ros.slice(0, 60).map(({ p, st }) => `<div class="rr k-${st.k}${isTurn(p.id, st) ? ' turn' : ''}${S.focus === p.id ? ' sel' : ''}${S.speakers.has(p.id) ? ' speaking' : ''}" data-id="${esc(p.id)}" tabindex="0" role="button" aria-label="${esc(p.name)}, ${esc(st.txt || '')}"><div class="n"><span class="dot" style="background:${p.shirt}"></span><b>${esc(p.name)}</b><span class="ro">${esc(p.role)}</span
|
|
1169
|
-
const
|
|
1269
|
+
const rows = ros.slice(0, 60).map(({ p, st }) => `<div class="rr k-${st.k}${isTurn(p.id, st) ? ' turn' : ''}${S.focus === p.id ? ' sel' : ''}${S.speakers.has(p.id) ? ' speaking' : ''}" data-id="${esc(p.id)}" tabindex="0" role="button" aria-label="${esc(p.name)}, ${esc(st.txt || '')}"><div class="n"><span class="dot" style="background:${p.shirt}"></span><b>${esc(p.name)}</b><span class="ro">${esc(p.role + leadTool(p))}</span>${rosTok(p.id)}</div><div class="st">${esc(st.txt || L('en veille', 'standing by'))}${S.loops[p.id] ? ' 🔁' : ''}</div></div>`).join('');
|
|
1270
|
+
const left = Object.values(S.agents).filter((p) => S.gone.has(p.id) && p.id !== 'main' && p.id !== 'user').sort((a, b) => (S.lastAct[b.id] || 0) - (S.lastAct[a.id] || 0)); // a finished agent's tile leaves the stage: its line stays here, with what it used
|
|
1271
|
+
const gone = left.slice(0, 40).map((p) => `<div class="rr left" data-id="${esc(p.id)}" tabindex="0" role="button" aria-label="${esc(p.name)}"><div class="n"><span class="dot" style="background:${p.shirt}"></span><b>${esc(p.name)}</b><span class="ro">${esc(p.role)}</span>${rosTok(p.id)}</div></div>`).join('');
|
|
1272
|
+
const html = `<h3>${L('Agents', 'Agents')} · ${ros.length}</h3>${rows}${ros.length > 60 ? `<div class="ro" style="padding:4px 8px">+${ros.length - 60}</div>` : ''}${left.length ? `<h3 style="margin-top:8px">${L('terminés', 'done')} · ${left.length}</h3>${gone}` : ''}`;
|
|
1170
1273
|
if (box.dataset.h !== html) { box.dataset.h = html; box.innerHTML = html; }
|
|
1171
1274
|
}
|
|
1172
|
-
$('#roster').onclick = (e) => { const r = e.target.closest('.rr'); if (!r) return; S.focusLock = Date.now() + 25000; setFocus(r.dataset.id); paintStates(); };
|
|
1173
|
-
$('#roster').onkeydown = (e) => { const r = e.target.closest('.rr'); if (r && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); S.focusLock = Date.now() + 25000; setFocus(r.dataset.id); paintStates(); } else if (r && e.key === 'i') openDetail(r.dataset.id); };
|
|
1275
|
+
$('#roster').onclick = (e) => { const r = e.target.closest('.rr'); if (!r) return; if (r.classList.contains('left')) { openDetail(r.dataset.id); return; } S.focusLock = Date.now() + 25000; setFocus(r.dataset.id); paintStates(); };
|
|
1276
|
+
$('#roster').onkeydown = (e) => { const r = e.target.closest('.rr'); if (r && r.classList.contains('left') && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); openDetail(r.dataset.id); } else if (r && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); S.focusLock = Date.now() + 25000; setFocus(r.dataset.id); paintStates(); } else if (r && e.key === 'i') openDetail(r.dataset.id); };
|
|
1174
1277
|
$('#roster').ondblclick = (e) => { const r = e.target.closest('.rr'); if (r) openDetail(r.dataset.id); };
|
|
1175
1278
|
function renderBadges() { // per tile: failed tool calls, a command that has been running a long time, an agent that went quiet
|
|
1176
1279
|
const now = Date.now();
|
|
@@ -1224,6 +1327,7 @@ function activityLabel(t) { // the short "what is on their screen" tag
|
|
|
1224
1327
|
case 'grep': return L('Cherche « ', 'Searching “') + String(d.pattern || '').slice(0, 22) + L(' »', '”');
|
|
1225
1328
|
case 'glob': return L('Liste ', 'Listing ') + String(d.pattern || '').slice(0, 24);
|
|
1226
1329
|
case 'todo': return L('Met à jour sa todo', 'Updating todo list');
|
|
1330
|
+
case 'artifact': return L('Publie ', 'Publishing ') + (d.title || f).slice(0, 30);
|
|
1227
1331
|
case 'web': return d.url ? L('Consulte ', 'Fetching ') + d.url.replace(/^https?:\/\//, '').slice(0, 26) : L('Recherche sur le web', 'Web search');
|
|
1228
1332
|
case 'text': { const w = d.what; if (w === 'question') return L('Pose une question', 'Asking a question'); if (w === 'skill') return L('Utilise ', 'Using skill ') + (d.v || ''); if (w === 'mcp') return d.v || t.name; if (w === 'toolsearch') return L('Cherche un outil', 'Looking for a tool'); return t.name; }
|
|
1229
1333
|
default: return t.name;
|
|
@@ -1238,7 +1342,7 @@ function pushTerm(id, tool) {
|
|
|
1238
1342
|
}
|
|
1239
1343
|
function applyResults(ev, silent) { // the output of a tool call arrives
|
|
1240
1344
|
const buf = S.term[ev.agent] || []; let last = null;
|
|
1241
|
-
for (const it of ev.items) for (let i = buf.length - 1; i >= 0; i--) if (buf[i].id === it.id) { Object.assign(buf[i], { out: it.out, err: it.err, end: ev.ts, img: it.img || 0, picAt: it.img && !silent ? performance.now() : 0 }); last = buf[i]; break; }
|
|
1345
|
+
for (const it of ev.items) for (let i = buf.length - 1; i >= 0; i--) if (buf[i].id === it.id) { Object.assign(buf[i], { out: it.out, err: it.err, end: ev.ts, img: it.img || 0, picAt: it.img && !silent ? performance.now() : 0, art: it.art || null }); last = buf[i]; break; }
|
|
1242
1346
|
if (S.run[ev.agent] && ev.items.some((it) => it.id === S.run[ev.agent].id)) delete S.run[ev.agent];
|
|
1243
1347
|
if (silent || !last) return;
|
|
1244
1348
|
setTicker(ev.agent, last); if (S.present === ev.agent) { renderPresent(); armPresent(); }
|
|
@@ -1271,6 +1375,7 @@ const mediaUrl = (agent, tool, n) => `/api/media?proj=${encodeURIComponent(S.cur
|
|
|
1271
1375
|
function termModel(id) {
|
|
1272
1376
|
const buf = S.term[id] || [], last = buf[buf.length - 1], lines = [], more = (n) => ({ c: 'dim', t: `… +${n} ${L('lignes', 'lines')}` });
|
|
1273
1377
|
const pic = S.cur && buf.slice(-12).reverse().find((e) => e.img), fresh = pic && performance.now() - pic.picAt < (S.live ? 8000 : 2500 / spd()); // a picture a tool returned (screenshot, image file) stays up for a few seconds whatever comes next, then for the next few calls: a screenshot is usually followed by a click or two
|
|
1378
|
+
const web = last && last.k === 'artifact' && last.art ? S.arts.get(last.art.url) : null; if (web) return artModel(web, id); // a page that was just published: the browser window, until the agent does something else
|
|
1274
1379
|
if (pic && (fresh || (buf.length - buf.indexOf(pic) <= 4 && (pic === last || !/^(edit|write|read)$/.test(last.k))))) return { view: 'image', title: pic.k === 'read' ? base(pic.tool.d.file) : pic.tool.name.split('__').pop(), imgs: Array.from({ length: Math.min(pic.img, 3) }, (_, n) => mediaUrl(id, pic.id, n)), more: pic.img - 3, lines, stat: statOf(last, id) };
|
|
1275
1380
|
if (last && (last.k === 'edit' || last.k === 'write' || last.k === 'read')) {
|
|
1276
1381
|
const d = last.tool.d, rows = (txt, c) => String(txt || '').split('\n').slice(0, 14).map((t) => ({ c, t }));
|
|
@@ -1296,35 +1401,139 @@ const lineHtml = (l, view) => view === 'editor'
|
|
|
1296
1401
|
|
|
1297
1402
|
// ---------- screen sharing: a real video-call presentation (window + presenter camera) ----------
|
|
1298
1403
|
function renderPresent() {
|
|
1299
|
-
const id = S.present, p = S.agents[id]; if (!p) return;
|
|
1300
|
-
|
|
1404
|
+
const id = S.present, p = S.agents[id]; if (!p) return; if (S.artPin && !S.arts.has(S.artPin)) { S.artPin = null; armPresent(); }
|
|
1405
|
+
const pinned = S.artPin ? S.arts.get(S.artPin) : null, m = pinned ? artModel(pinned, id) : termModel(id), shape = m.view === 'web' && pinned ? 'pin' : m.view === 'web' || m.view === 'image' ? 'pic' : '';
|
|
1406
|
+
$('#present .pwin').className = 'pwin ' + (m.view === 'term' ? 'term' : m.view); $('#present').classList.toggle('pic', shape === 'pic'); $('#present').classList.toggle('pin', shape === 'pin'); if (shape !== S.picUp) { S.picUp = shape; layout(); } // a picture or a page gets a taller window, a pinned page the tallest
|
|
1301
1407
|
$('#ptitle').textContent = m.view === 'term' ? `${p.name} — zsh — 96×24` : m.title;
|
|
1302
|
-
const pb = $('#pbody'), shown = m.view === 'image' ? m.imgs.join(' ') : '';
|
|
1303
|
-
if (shown) { if (pb.dataset.img !== shown) pb.innerHTML = m.imgs.map((u) => `<img src="${esc(u)}" alt="">`).join('') + (m.more > 0 ? `<span class="pmore">+${m.more}</span>` : ''); } // the same pictures are left in place: redrawing them would make them blink
|
|
1408
|
+
const pb = $('#pbody'), shown = m.view === 'image' ? m.imgs.join(' ') : m.view === 'web' ? m.key : ''; pb.dataset.art = m.view === 'web' ? m.a.url : '';
|
|
1409
|
+
if (shown) { if (pb.dataset.img !== shown) pb.innerHTML = m.view === 'web' ? artHtml(m) : m.imgs.map((u) => `<img src="${esc(u)}" alt="">`).join('') + (m.more > 0 ? `<span class="pmore">+${m.more}</span>` : ''); } // the same pictures are left in place: redrawing them would make them blink
|
|
1304
1410
|
else pb.innerHTML = (m.view === 'editor' ? `<div class="ptab"><span>${esc(m.tab.file)}</span><em>${esc(m.tab.path)}</em></div>` : '') + m.lines.map((l) => lineHtml(l, m.view)).join('') + (m.view === 'term' ? '<div class="tl"><span class="ps">❯</span> <span class="cursor"></span></div>' : '');
|
|
1305
|
-
pb.dataset.img = shown; pb.scrollTop = m.view === 'term' ? pb.scrollHeight : 0; $('#pstat').textContent = m.stat;
|
|
1306
|
-
const td = S.todos[id], el = $('#ptodo'), tk = td && td.length ? prefs.lang + '\n' + td.map((x) => x.s + ' ' + x.c).join('\n') : ''; el.style.display = tk ? '' : 'none'; $('#present').classList.toggle('has-todo', !!tk);
|
|
1411
|
+
pb.dataset.img = shown; pb.scrollTop = m.view === 'term' ? pb.scrollHeight : 0; $('#pstat').textContent = m.stat; if (m.view === 'web') fitArt();
|
|
1412
|
+
const td = S.todos[id], el = $('#ptodo'), tk = m.view !== 'web' && td && td.length ? prefs.lang + '\n' + td.map((x) => x.s + ' ' + x.c).join('\n') : ''; el.style.display = tk ? '' : 'none'; $('#present').classList.toggle('has-todo', !!tk);
|
|
1307
1413
|
if (tk && el.dataset.k !== tk) { // redrawn only when it changes, so it stays where you scrolled it; the task in progress is brought into view
|
|
1308
1414
|
el.innerHTML = `<h5>${L('Tâches', 'Tasks')} · ${td.filter((x) => x.s === 'completed').length}/${td.length}</h5>` + td.map((x) => `<div class="td ${x.s}"><i>${x.s === 'completed' ? '☑' : x.s === 'in_progress' ? '◐' : '☐'}</i>${esc(x.c)}</div>`).join('');
|
|
1309
1415
|
const cur = el.querySelector('.in_progress'); el.scrollTop = cur ? Math.max(0, cur.offsetTop - el.clientHeight / 2) : 0;
|
|
1310
1416
|
}
|
|
1311
1417
|
el.dataset.k = tk;
|
|
1312
1418
|
$('#pbadge').textContent = `🖥 ${p.name} ${L('partage son écran', 'is sharing their screen')}`;
|
|
1313
|
-
if (S.camFor !== id) { $('#pcam').innerHTML = avatarSVG(p, undefined, 'c' + p.gid + '_') + `<div class="tag"><b>${esc(p.name)}</b></div>`; S.camFor = id; }
|
|
1419
|
+
if (S.camFor !== id) { $('#pcam').innerHTML = avatarSVG(p, undefined, 'c' + p.gid + '_') + `<div class="tag"><b>${esc(p.name)}</b><span class="tk"></span></div>`; S.camFor = id; }
|
|
1420
|
+
camTok();
|
|
1314
1421
|
$('#pcam').classList.toggle('speaking', S.speakers.has(id));
|
|
1315
1422
|
}
|
|
1316
|
-
function armPresent() { // stays up while a command is still running, then ~4 s after the last action (~9 s when it shows a picture)
|
|
1317
|
-
clearTimeout(presentTimer); if (S.hold) return;
|
|
1318
|
-
presentTimer = setTimeout(() => { if (S.present && S.run[S.present] && S.playing) armPresent(); else hidePresent(); }, ($('#present').classList.contains('pic') ? 9000 : 4200) / Math.max(1, spd() / 1.2));
|
|
1423
|
+
function armPresent() { // stays up while a command is still running, then ~4 s after the last action (~9 s when it shows a picture, ~20 s for the page of an artifact; a pinned page stays until it is closed)
|
|
1424
|
+
clearTimeout(presentTimer); if (S.hold || S.artPin) return;
|
|
1425
|
+
presentTimer = setTimeout(() => { if (S.present && S.run[S.present] && S.playing) armPresent(); else hidePresent(); }, ($('#present .pwin').classList.contains('web') ? 20000 : $('#present').classList.contains('pic') ? 9000 : 4200) / Math.max(1, spd() / 1.2));
|
|
1319
1426
|
}
|
|
1320
1427
|
function showPresent(id) {
|
|
1321
|
-
if (S.boost > 1 || (S.speakers.size && !S.speakers.has(id))) return; // catching up, or someone else has the floor
|
|
1428
|
+
if (S.artPin || S.boost > 1 || (S.speakers.size && !S.speakers.has(id))) return; // a page you pinned stays up · catching up, or someone else has the floor
|
|
1322
1429
|
const first = S.present !== id; S.present = id; $('#present').classList.add('on'); document.body.classList.add('presenting'); document.querySelectorAll('.tile.presenter').forEach((t) => t.classList.remove('presenter')); const pt = $('#t-' + id); if (pt) pt.classList.add('presenter'); renderPresent(); if (first) { layout(); AUD.tone(880, .12, 'sine', .05); }
|
|
1323
1430
|
armPresent();
|
|
1324
1431
|
}
|
|
1325
1432
|
function hidePresent() {
|
|
1326
|
-
clearTimeout(presentTimer); if (!S.present
|
|
1433
|
+
clearTimeout(presentTimer); if (!S.present || S.artPin) return; if ($('#pbody').dataset.art) { $('#pbody').innerHTML = ''; $('#pbody').dataset.img = $('#pbody').dataset.art = ''; } /* the page of an artifact does not go on running behind a closed window */
|
|
1434
|
+
S.present = null; $('#present').classList.remove('on'); document.body.classList.remove('presenting'); document.querySelectorAll('.tile.presenter').forEach((t) => t.classList.remove('presenter')); $('#pcap').textContent = ''; layout();
|
|
1435
|
+
}
|
|
1436
|
+
// ---------- artifacts: the pages the session published on claude.ai, shown the way a call shows a browser window someone shares ----------
|
|
1437
|
+
// When a publish succeeds its author shares the page for a moment; afterwards it is in the line of files, and a click there pins it: the window takes the room, stays until you close it (✕, Esc),
|
|
1438
|
+
// follows the next versions and steps through the other artifacts of the session (‹ ›). The page itself comes from the server, which puts it together from the session file (claude.ai lets nobody frame it):
|
|
1439
|
+
// a frame that can reach neither the app nor, unless you ask for the libraries, the network. Where there is no page to show (made from a claude.ai template, or written another way) the window says so and gives the link.
|
|
1440
|
+
const artSrc = (a) => `/api/artifact?proj=${encodeURIComponent(S.cur.proj)}&id=${encodeURIComponent(S.cur.id)}&agent=${encodeURIComponent(a.agent)}&tool=${encodeURIComponent(a.id)}`;
|
|
1441
|
+
function noteArts(ev) { // one entry per artifact, the last publish of it: published again, it is the newest and shows its new version
|
|
1442
|
+
if (ev.kind === 'tools') { for (const t of ev.tools) if (t.d && t.d.kind === 'artifact') S.artCalls.set(t.id, { agent: ev.agent, title: t.d.title || '', note: t.d.note || '' }); return; }
|
|
1443
|
+
if (ev.kind !== 'results') return;
|
|
1444
|
+
for (const it of ev.items) { const c = it.art && S.artCalls.get(it.id); if (!c) continue; const u = it.art.url, was = S.arts.get(u) || {}; S.arts.delete(u); S.arts.set(u, { url: u, title: it.art.title || c.title || was.title || 'Artifact', note: c.note || was.note || '', agent: c.agent, id: it.id, v: it.art.v || 0, typed: !!it.art.typed, turn: S.turnN }); if (S.artPin === u) later('art', renderPresent); }
|
|
1445
|
+
}
|
|
1446
|
+
function askArt(a) { // is there a page to show for that publish? Asked once: null while the answer is on its way
|
|
1447
|
+
if (S.artOk.has(a.id)) return S.artOk.get(a.id); if (a.typed || S.demo || !S.cur) { S.artOk.set(a.id, { ok: false }); return S.artOk.get(a.id); }
|
|
1448
|
+
const cur = S.cur; S.artOk.set(a.id, null);
|
|
1449
|
+
fetch(artSrc(a) + '&check=1').then((r) => r.json()).then((j) => { if (S.cur !== cur) return; S.artOk.set(a.id, { ok: !!j.ok, net: !!j.net }); if (S.present) renderPresent(); }).catch(() => { if (S.cur === cur) S.artOk.delete(a.id); });
|
|
1450
|
+
return null;
|
|
1327
1451
|
}
|
|
1452
|
+
function artModel(a, id) {
|
|
1453
|
+
const st = askArt(a), all = [...S.arts.keys()], pinned = S.artPin === a.url, buf = S.term[id] || [];
|
|
1454
|
+
return { view: 'web', title: a.title, lines: [], a, st, pinned, n: all.length, i: all.indexOf(a.url), stat: a.note || statOf(buf[buf.length - 1], id), key: [a.url, a.id, st ? (st.ok ? 'ok' : 'no') : '?', st && st.net ? 'n' : '', prefs.artNet ? 'N' : '', pinned ? 'p' + all.indexOf(a.url) + '/' + all.length : '', prefs.lang].join('|') };
|
|
1455
|
+
}
|
|
1456
|
+
function artHtml(m) {
|
|
1457
|
+
const a = m.a, ok = m.st && m.st.ok, libs = ok && m.st.net && !prefs.artNet, open = esc(L('Ouvrir sur claude.ai', 'Open on claude.ai'));
|
|
1458
|
+
const nav = m.pinned && m.n > 1 ? `<button class="pnb" data-go="-1">‹</button><span class="pnn">${m.i + 1}/${m.n}</span><button class="pnb" data-go="1">›</button>` : '';
|
|
1459
|
+
const bar = `<div class="pnav">${nav}<span class="purl">🔒 ${esc(a.url.replace(/^https:\/\//, ''))}</span>${a.v > 1 ? `<span class="pnn">v${a.v}</span>` : ''}${libs ? `<button class="pnb lib" data-lib title="${esc(L('Cette page utilise des bibliothèques hébergées ailleurs : elles ne sont chargées que si vous le demandez', 'This page uses libraries kept on other servers: they are loaded only if you ask'))}">${esc(L('Charger ses bibliothèques', 'Load its libraries'))}</button>` : ''}<button class="pnb" data-open title="${open}" aria-label="${open}">↗</button>${m.pinned ? `<button class="pnb" data-x title="${esc(L('Fermer', 'Close'))}" aria-label="${esc(L('Fermer', 'Close'))}">✕</button>` : ''}</div>`;
|
|
1460
|
+
const page = ok ? `<iframe sandbox="allow-scripts" referrerpolicy="no-referrer" title="${esc(a.title)}" src="${esc(artSrc(a) + (prefs.artNet ? '&net=1' : ''))}"></iframe>` + (m.pinned ? '' : `<button class="pzoom" data-pin title="${esc(L('Cliquer pour agrandir', 'Click to enlarge'))}" aria-label="${esc(L('Cliquer pour agrandir', 'Click to enlarge'))}"></button>`)
|
|
1461
|
+
: `<div class="pcard"><i>🌐</i><b>${esc(a.title)}</b>${a.note ? `<p>${esc(a.note)}</p>` : ''}${m.st ? `<em>${esc(L('Pas d’aperçu ici : la page est sur claude.ai', 'No preview here: the page is on claude.ai'))}</em><button class="pnb" data-open>${open} ↗</button>` : '<span class="spin"></span>'}</div>`;
|
|
1462
|
+
return bar + `<div class="pweb">${page}</div>`;
|
|
1463
|
+
}
|
|
1464
|
+
function fitArt() { const w = $('#pbody .pweb'); if (w) w.style.setProperty('--z', (S.artPin ? 1 : Math.min(1, Math.max(.2, w.clientWidth / 1100))).toFixed(3)); } // shared: the page is laid out 1100 px wide and shown smaller, as a screen is; pinned: at its real size
|
|
1465
|
+
function pinArt(url) {
|
|
1466
|
+
const a = S.arts.get(url); if (!a) return; const id = S.agents[a.agent] ? a.agent : 'main', first = S.present !== id; filesPop(false); clearTimeout(presentTimer); S.artPin = url; S.present = id;
|
|
1467
|
+
$('#present').classList.add('on'); document.body.classList.add('presenting'); document.querySelectorAll('.tile.presenter').forEach((t) => t.classList.remove('presenter')); const pt = $('#t-' + id); if (pt) pt.classList.add('presenter'); renderPresent(); if (first) layout();
|
|
1468
|
+
}
|
|
1469
|
+
function unpinArt() { if (!S.artPin) return; S.artPin = null; hidePresent(); }
|
|
1470
|
+
$('#present').addEventListener('click', (e) => {
|
|
1471
|
+
const b = e.target.closest('[data-open], [data-x], [data-go], [data-lib], [data-pin]'), a = b && S.arts.get($('#pbody').dataset.art || ''); if (!a) return; const d = b.dataset;
|
|
1472
|
+
if ('open' in d) openExternal(a.url); else if ('x' in d) unpinArt(); else if ('pin' in d) pinArt(a.url);
|
|
1473
|
+
else if ('lib' in d) { prefs.artNet = true; savePrefs(); const sw = document.querySelector('#menu .mi[data-t="artNet"] .sw'); if (sw) sw.classList.add('on'); renderPresent(); }
|
|
1474
|
+
else if ('go' in d) { const all = [...S.arts.keys()]; pinArt(all[(all.indexOf(a.url) + +d.go + all.length) % all.length]); }
|
|
1475
|
+
});
|
|
1476
|
+
addEventListener('keydown', (e) => { if (e.key === 'Escape' && S.artPin) unpinArt(); });
|
|
1477
|
+
new ResizeObserver(() => fitArt()).observe($('#pbody'));
|
|
1478
|
+
const artTip = (a) => `${a.url}\n${a.agent !== 'main' && S.agents[a.agent] ? nameOf(a.agent) + ' · ' : ''}${L('Cliquer pour la présenter dans l’appel', 'Click to present it in the call')}`;
|
|
1479
|
+
// ---------- shared files: the files the session created (its Write calls), the way a call shows what was shared in it ----------
|
|
1480
|
+
// They show when a turn ends, the moment you would go and look for them: one line under the call, the newest first, a dot on those of the turn that just ended. A click shows the file in its folder
|
|
1481
|
+
// (the server opens Finder, Explorer or the file manager, and only for a file this session wrote). Nothing shows while the team works.
|
|
1482
|
+
// The line names the files made for you, not everything that was written: those the lead names when it speaks to you in that turn (or that you asked for by name); in a turn where it names none, the ones that are documents by their type.
|
|
1483
|
+
// A session that writes fifteen source files shows none of them there. All of them are in the list, behind "+N". Off in ⚙ › Display.
|
|
1484
|
+
// A document made by a command (not by a Write call) shows too, when the lead names it: see candFile.
|
|
1485
|
+
const FSKIP = /^(\/private)?\/(tmp|var\/folders)\/|[\\/]AppData[\\/]Local[\\/]Temp[\\/]|[\\/]\.claude[\\/]projects[\\/]/i; // not documents: scratch files in a temporary folder, and the notes an agent keeps for itself
|
|
1486
|
+
const FICON = [[/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i, '🖼'], [/\.(csv|tsv|xlsx?|json|ya?ml|sql)$/i, '📊']], FMAX = 8; // FMAX: how many files the line names; the others are in the list
|
|
1487
|
+
const FDOC = /\.(html?|md|markdown|txt|rtf|pdf|docx?|pptx?|xlsx?|csv|tsv|png|jpe?g|gif|webp|svg)$/i; // read or looked at, not run
|
|
1488
|
+
const namesFile = (text, name) => { for (let i = name ? text.indexOf(name) : -1; i >= 0; i = text.indexOf(name, i + 1)) if (!/[\w.\-]/.test(text[i - 1] || ' ') && !/[\w\-]/.test(text[i + name.length] || ' ')) return true; return false; }; // the whole name: "report.md" is not named by "old-report.md"
|
|
1489
|
+
const filesForYou = (all) => { const named = new Set(all.filter((f) => f.named).map((f) => f.turn)); return all.filter((f) => f.named || (!named.has(f.turn) && FDOC.test(f.name))); };
|
|
1490
|
+
const fileParts = (f) => { const p = String(f || '').split(/[\\/]/), name = p.pop() || ''; return { name, dir: p.slice(-3).join(' › '), icon: (FICON.find(([re]) => re.test(name)) || [0, '📄'])[1] }; };
|
|
1491
|
+
function noteFiles(ev) { // a file written twice is one file, of the turn that wrote it last; a write that failed created nothing
|
|
1492
|
+
noteArts(ev);
|
|
1493
|
+
if (ev.kind === 'user') { S.turnN++; S.turnSaid = String(ev.text || ''); }
|
|
1494
|
+
else if (ev.kind === 'say' && ev.agent === 'main') { const t = String(ev.text || ''); S.turnSaid = (S.turnSaid + '\n' + t).slice(-20000); for (const f of S.files.values()) if (!f.named && namesFile(t, f.name)) f.named = true; for (const c of S.cands.values()) if (namesFile(t, c.name)) c.want = S.turnN; } // named before it is written ("I will put it in plan.md") or after: both count
|
|
1495
|
+
else if (ev.kind === 'tools') { for (const t of ev.tools) { const d = t.d || {}, was = S.files.get(d.file); if (d.kind === 'cmd' && d.outs) for (const f of d.outs) candFile(f, t.id, ev.agent); if (d.kind !== 'write' || !d.file || FSKIP.test(d.file) || (was && was.id === t.id)) continue; const name = fileParts(d.file).name; S.files.delete(d.file); S.files.set(d.file, { file: d.file, name, id: t.id, agent: ev.agent, turn: S.turnN, named: !!(was && was.named) || namesFile(S.turnSaid, name), was }); } }
|
|
1496
|
+
else if (ev.kind === 'results') { for (const it of ev.items) { if (it.err) { for (const [k, f] of S.files) if (f.id === it.id) { if (f.was) S.files.set(k, f.was); else S.files.delete(k); } for (const [k, c] of S.cands) if (c.id === it.id) S.cands.delete(k); } else if (it.files) for (const f of it.files) candFile(f, it.id, ev.agent); } }
|
|
1497
|
+
}
|
|
1498
|
+
// A document a command made (an export, a report written by a script, a package) is one of the files made for you when the lead names it. The transcript only says that a command names it:
|
|
1499
|
+
// when the turn ends the server is asked whether it is there and was written since that command started. One that was only read, listed or removed is not shown.
|
|
1500
|
+
function candFile(file, id, agent) {
|
|
1501
|
+
if (!file || FSKIP.test(file) || S.files.has(file) || S.cands.has(file)) return; if (S.cands.size >= 300) S.cands.delete(S.cands.keys().next().value);
|
|
1502
|
+
const c = { file, name: fileParts(file).name, id, agent }; S.cands.set(file, c); if (namesFile(S.turnSaid, c.name)) c.want = S.turnN;
|
|
1503
|
+
}
|
|
1504
|
+
function askMade(c) { // once per file and per turn in which it is named: a command that runs in the background may write it after the first time it is named
|
|
1505
|
+
const key = c.want + '|' + c.file, ok = S.fmade.get(key), cur = S.cur; if (ok === true) { S.files.set(c.file, { file: c.file, name: c.name, id: c.id, agent: c.agent, turn: c.want, named: true, cmd: true }); return; }
|
|
1506
|
+
if (ok !== undefined || S.demo || !cur) return; S.fmade.set(key, null);
|
|
1507
|
+
fetch('/api/reveal', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ proj: cur.proj, id: cur.id, file: c.file, check: true }) }).then((r) => { if (S.cur !== cur) return; S.fmade.set(key, r.ok); if (r.ok) paintFiles(); }).catch(() => { if (S.cur === cur) S.fmade.delete(key); });
|
|
1508
|
+
}
|
|
1509
|
+
const turnDone = () => S.events.length > 0 && !S.locked && (S.live ? agentState('main', Date.now()).k === 'done' : !!S.turnOver || S.idx >= S.events.length - 1); // replay: the mark that closes the lead's turn, or the end of a session that has none
|
|
1510
|
+
const fileTip = (f) => `${f.file}\n${f.agent !== 'main' && S.agents[f.agent] ? nameOf(f.agent) + ' · ' : ''}${S.fgone.has(f.file) ? L('Ce fichier n’existe plus', 'This file is no longer there') : L('Cliquer pour l’afficher dans son dossier', 'Click to show it in its folder')}`;
|
|
1511
|
+
const fileCls = (f) => (f.turn === S.turnN ? ' new' : '') + (S.fgone.has(f.file) ? ' gone' : '');
|
|
1512
|
+
function paintFiles() { // called with every repaint of the states: touches the page only when the line would read differently
|
|
1513
|
+
if (prefs.files !== false && S.cands.size && turnDone()) for (const c of S.cands.values()) if (c.want != null && !S.files.has(c.file)) askMade(c); // the documents the commands made, among those the lead named
|
|
1514
|
+
if (S.artPin && !S.arts.has(S.artPin)) unpinArt(); // the call went back to before that page was published
|
|
1515
|
+
const el = $('#files'), all = [...S.files.values()].reverse(), mine = prefs.files !== false ? filesForYou(all) : [], arts = prefs.files !== false ? [...S.arts.values()].reverse() : [], on = mine.length + arts.length > 0 && turnDone(), rest = all.length - Math.min(mine.length, FMAX);
|
|
1516
|
+
const key = on ? prefs.lang + '|' + S.turnN + '|' + all.map((f) => f.file + (S.fgone.has(f.file) ? '!' : '')).join('|') + '||' + mine.map((f) => f.file).join('|') + '||' + arts.map((a) => a.id + a.title).join('|') : ''; if (el.dataset.k === key) return;
|
|
1517
|
+
const open = on && !!$('#fpop'), ttl = L('Fichiers créés pendant cette session', 'Files created in this session'); el.dataset.k = key; filesPop(false); if (el.classList.contains('on') !== on) { el.classList.toggle('on', on); later('lay', layout); }
|
|
1518
|
+
el.innerHTML = !on ? '' : `<button class="sfh" id="fAll" aria-expanded="false" title="${esc(ttl)}">📎 ${esc(L('Fichiers', 'Files'))}</button>` + arts.slice(0, 4).map((a) => `<button class="sfc${a.turn === S.turnN ? ' new' : ''}" data-a="${esc(a.url)}" title="${esc(artTip(a))}"><i>🌐</i><span>${esc(a.title)}</span></button>`).join('') + mine.slice(0, FMAX).map((f) => `<button class="sfc${fileCls(f)}" data-f="${esc(f.file)}" title="${esc(fileTip(f))}"><i>${fileParts(f.file).icon}</i><span>${esc(f.name)}</span></button>`).join('') + (rest > 0 ? `<button class="sfc more" title="${esc(ttl)}" aria-label="${esc(ttl)}">+${rest}</button>` : '');
|
|
1519
|
+
el.scrollLeft = 0; if (open) filesPop(true);
|
|
1520
|
+
}
|
|
1521
|
+
function filesPop(open) { // the whole list, above the line: every file with the folder it is in and who created it
|
|
1522
|
+
const old = $('#fpop'), b = $('#fAll'); if (old) old.remove(); if (b) b.setAttribute('aria-expanded', String(!!open)); if (!open) return;
|
|
1523
|
+
const all = [...S.files.values()].reverse(), p = document.createElement('div'), ttl = L('Fichiers créés pendant cette session', 'Files created in this session'); p.id = 'fpop'; p.setAttribute('role', 'dialog'); p.setAttribute('aria-label', ttl);
|
|
1524
|
+
p.innerHTML = `<h4>${esc(ttl)} · ${all.length + S.arts.size}</h4>` + [...S.arts.values()].reverse().map((a) => `<button class="sfr${a.turn === S.turnN ? ' new' : ''}" data-a="${esc(a.url)}" title="${esc(artTip(a))}"><i>🌐</i><b>${esc(a.title)}</b><em>${esc(['claude.ai', a.v > 1 ? 'v' + a.v : '', a.agent !== 'main' && S.agents[a.agent] ? nameOf(a.agent) : ''].filter(Boolean).join(' · '))}</em></button>`).join('') + all.map((f) => { const x = fileParts(f.file), who = f.agent !== 'main' && S.agents[f.agent] ? nameOf(f.agent) : ''; return `<button class="sfr${fileCls(f)}" data-f="${esc(f.file)}" title="${esc(fileTip(f))}"><i>${x.icon}</i><b>${esc(x.name)}</b><em>${esc([x.dir, who].filter(Boolean).join(' · '))}</em></button>`; }).join('');
|
|
1525
|
+
p.style.bottom = Math.round($('#center').getBoundingClientRect().bottom - $('#files').getBoundingClientRect().top) + 6 + 'px'; p.onclick = filesClick; $('#center').appendChild(p);
|
|
1526
|
+
}
|
|
1527
|
+
async function revealFile(file) {
|
|
1528
|
+
if (S.demo || !S.cur) { toast(L('Fichier de la démo : rien à ouvrir', 'A file of the demo: nothing to open')); return; }
|
|
1529
|
+
let r = null; try { r = await fetch('/api/reveal', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ proj: S.cur.proj, id: S.cur.id, file }) }); } catch {}
|
|
1530
|
+
if (r && r.ok) { if (S.fgone.delete(file)) paintFiles(); return; }
|
|
1531
|
+
if (r && r.status === 410) { S.fgone.add(file); paintFiles(); toast(L('Ce fichier n’existe plus', 'This file is no longer there')); } else toast(L('Impossible d’ouvrir le dossier', 'Could not open the folder'));
|
|
1532
|
+
}
|
|
1533
|
+
function filesClick(e) { const a = e.target.closest('[data-a]'), f = e.target.closest('[data-f]'); if (a) pinArt(a.dataset.a); else if (f) revealFile(f.dataset.f); else if (e.target.closest('.sfh, .more')) filesPop(!$('#fpop')); }
|
|
1534
|
+
$('#files').onclick = filesClick;
|
|
1535
|
+
addEventListener('click', (e) => { if ($('#fpop') && !e.target.closest('#fpop, #files')) filesPop(false); });
|
|
1536
|
+
addEventListener('keydown', (e) => { if (e.key === 'Escape' && $('#fpop')) { filesPop(false); const b = $('#fAll'); if (b) b.focus(); } });
|
|
1328
1537
|
// the speaker always gets the spotlight (and keeps it until someone else talks)
|
|
1329
1538
|
function setFocus(id) {
|
|
1330
1539
|
if (S.focus === id) return; const o = $('#t-' + S.focus); if (o) o.classList.remove('focus'); S.focus = id; const t = $('#t-' + id);
|
|
@@ -1352,10 +1561,12 @@ function poof(tile, color) {
|
|
|
1352
1561
|
{ duration: 650 + Math.random() * 450, easing: 'cubic-bezier(.2,.7,.4,1)', delay: 120 }).onfinish = () => d.remove();
|
|
1353
1562
|
}
|
|
1354
1563
|
}
|
|
1355
|
-
function toast(msg) { const t = document.createElement('div'); t.className = 'toast'; t.textContent = msg; const c = $('#toasts'); c.appendChild(t); while (c.
|
|
1564
|
+
function toast(msg) { const t = document.createElement('div'); t.className = 'toast'; t.textContent = msg; const c = $('#toasts'); c.appendChild(t); while (c.querySelectorAll('.toast:not(.offer)').length > 3) c.querySelector('.toast:not(.offer)').remove(); setTimeout(() => t.remove(), 3100); }
|
|
1356
1565
|
const BYE = { en: ['Bye, everyone!', 'Off I go. 👋', 'Thanks, see you!', 'My work here is done.', 'Catch you later!', 'Logging off, bye!', 'That’s a wrap!', 'Good luck with the rest!', 'Mic drop. 🎤', 'Leaving the call… ☕'],
|
|
1357
|
-
fr: ['Salut tout le monde !', 'Je file. 👋', 'Merci, à plus !', 'Ma mission est terminée.', 'À tout à l’heure !', 'Je me déconnecte, ciao !', 'C’est dans la boîte !', 'Bon courage pour la suite !', 'Mic drop. 🎤', 'Je quitte l’appel… ☕']
|
|
1358
|
-
|
|
1566
|
+
fr: ['Salut tout le monde !', 'Je file. 👋', 'Merci, à plus !', 'Ma mission est terminée.', 'À tout à l’heure !', 'Je me déconnecte, ciao !', 'C’est dans la boîte !', 'Bon courage pour la suite !', 'Mic drop. 🎤', 'Je quitte l’appel… ☕'],
|
|
1567
|
+
es: ['¡Adiós a todos!', 'Me voy. 👋', '¡Gracias, nos vemos!', 'Mi trabajo aquí ha terminado.', '¡Hasta luego!', 'Me desconecto, ¡chao!', '¡Listo, eso es todo!', '¡Suerte con lo que queda!', 'Mic drop. 🎤', 'Salgo de la llamada… ☕'],
|
|
1568
|
+
pt: ['Tchau, pessoal!', 'Estou indo. 👋', 'Valeu, até mais!', 'Meu trabalho aqui está feito.', 'Até logo!', 'Estou saindo, tchau!', 'Pronto, é isso!', 'Boa sorte com o resto!', 'Mic drop. 🎤', 'Saindo da chamada… ☕'] };
|
|
1569
|
+
function byeLine(id) { const P = BYE[CALL()], seed = hash(id + String(S.clock | 0)); let l = P[seed % P.length]; if (l === S.lastBye) l = P[(seed + 1) % P.length]; return (S.lastBye = l); }
|
|
1359
1570
|
function vanish(id) {
|
|
1360
1571
|
S.gone.add(id); const t = $('#t-' + id), p = S.agents[id]; if (!t || !p) return;
|
|
1361
1572
|
toast(`${p.name} ${L('a quitté l’appel', 'left the call')} 👋`);
|
|
@@ -1395,7 +1606,6 @@ setInterval(() => { // now and then a busy agent has a little thought; never w
|
|
|
1395
1606
|
}, 7000);
|
|
1396
1607
|
function oops(id) { if (!prefs.banter || !S.playing || S.recomputing) return; const t = $('#t-' + id); if (!t || t.style.display === 'none' || (t._oops && Date.now() - t._oops < 4000)) return; t._oops = Date.now(); t.classList.remove('oops'); void t.offsetWidth; t.classList.add('oops'); thought(id, '😬'); }
|
|
1397
1608
|
function confetti() {
|
|
1398
|
-
S.wrap = true; // the lead is done: if the end of its last message was never read, it is read now (see wrapUp)
|
|
1399
1609
|
if (!prefs.banter || document.hidden) return; const box = $('#center'), cols = ['#f5c04a', '#7c9cff', '#ff7a6b', '#5ad19a', '#c58bff'];
|
|
1400
1610
|
for (let i = 0; i < 26; i++) { const c = document.createElement('i'); c.className = 'confetti'; c.style.left = Math.random() * 100 + '%'; c.style.background = cols[i % cols.length]; c.style.animationDelay = Math.random() * 0.6 + 's'; c.style.animationDuration = 1.8 + Math.random() * 1.4 + 's'; box.appendChild(c); setTimeout(() => c.remove(), 4200); }
|
|
1401
1611
|
}
|
|
@@ -1420,9 +1630,13 @@ const THINK = {
|
|
|
1420
1630
|
todo: ['One thing at a time: {x}.', '{x}… then the next one.'], next: ['After this: {x}.'], grep: ['Where is “{x}” hiding?', '“{x}”… it has to be somewhere.'], web: ['“{x}”… let’s see what comes up.'], grep0: ['It has to be somewhere in here.', 'Where is that thing hiding?'], task: ['{x}. Stay on it.', '{x}… getting there, I think.'] },
|
|
1421
1631
|
fr: { run: ['Toujours en cours… {x}.', 'Allez… {x}.', '{x}. Ça arrive.'], err: ['Pourquoi ça a planté ?', 'Encore cette erreur… qu’est-ce que je rate ?', 'Pas ce que j’attendais de « {x} ».'], two: ['{a}, puis {b}… quel est le lien ?', '{a} et {b}. C’est forcément dans l’un des deux.'], one: ['Il y a un truc dans {a} qui ne colle pas.', '{a}… c’était où, déjà ?'], again: ['Retour à {a}. Encore.', '{a}, une fois de plus. Je rate quelque chose.'],
|
|
1422
1632
|
todo: ['Une chose à la fois : {x}.', '{x}… puis la suite.'], next: ['Après ça : {x}.'], grep: ['Où se cache « {x} » ?', '« {x} »… c’est forcément quelque part.'], web: ['« {x} »… voyons ce que ça donne.'], grep0: ['C’est forcément quelque part là-dedans.', 'Où est-ce que ça se cache ?'], task: ['{x}. On reste dessus.', '{x}… j’y arrive, je crois.'] },
|
|
1633
|
+
es: { run: ['Sigue en marcha… {x}.', 'Vamos… {x}.', '{x}. Ya casi.'], err: ['¿Por qué ha fallado?', 'Otra vez ese error… ¿qué se me escapa?', 'No es lo que esperaba de “{x}”.'], two: ['{a}, luego {b}… ¿qué los une?', '{a} y {b}. Tiene que estar en uno de los dos.'], one: ['Algo en {a} no cuadra.', '{a}… ¿dónde estaba esa parte?'], again: ['De vuelta a {a}. Otra vez.', '{a}, una vez más. Algo se me escapa.'],
|
|
1634
|
+
todo: ['Una cosa a la vez: {x}.', '{x}… y luego lo siguiente.'], next: ['Después de esto: {x}.'], grep: ['¿Dónde se esconde “{x}”?', '“{x}”… tiene que estar en algún sitio.'], web: ['“{x}”… a ver qué sale.'], grep0: ['Tiene que estar por aquí.', '¿Dónde se esconde eso?'], task: ['{x}. Sigo con ello.', '{x}… creo que ya casi.'] },
|
|
1635
|
+
pt: { run: ['Ainda rodando… {x}.', 'Vamos… {x}.', '{x}. Já vai.'], err: ['Por que isso falhou?', 'Esse erro de novo… o que estou deixando passar?', 'Não era o que eu esperava de “{x}”.'], two: ['{a}, depois {b}… qual é a ligação?', '{a} e {b}. Tem que estar em um dos dois.'], one: ['Alguma coisa em {a} não bate.', '{a}… onde ficava essa parte mesmo?'], again: ['De volta a {a}. De novo.', '{a}, mais uma vez. Estou deixando passar alguma coisa.'],
|
|
1636
|
+
todo: ['Uma coisa de cada vez: {x}.', '{x}… depois a próxima.'], next: ['Depois disso: {x}.'], grep: ['Onde “{x}” está se escondendo?', '“{x}”… tem que estar em algum lugar.'], web: ['“{x}”… vamos ver o que aparece.'], grep0: ['Tem que estar em algum lugar aqui.', 'Onde isso está se escondendo?'], task: ['{x}. Sigo nisso.', '{x}… estou chegando lá, acho.'] },
|
|
1423
1637
|
};
|
|
1424
1638
|
function thoughtFor(id) {
|
|
1425
|
-
const now = Date.now(), W = THINK[
|
|
1639
|
+
const now = Date.now(), W = THINK[CALL()], seen = (TH.said[id] = TH.said[id] || []), cut = (x, n) => { x = String(x || '').replace(/\s+/g, ' ').trim(); return (x.length > n ? x.slice(0, n).replace(/\s+\S*$/, '') : x).replace(/[.…,;:\s]+$/, ''); }; // the line it goes into brings its own punctuation
|
|
1426
1640
|
const real = realThought(id); if (real) return real; // its own words first, always: the rest is only for when there are none (left)
|
|
1427
1641
|
const buf = (S.term[id] || []).slice(-8), last = buf[buf.length - 1], r = S.run[id], hot = [], out = [], add = (to, k, v) => { for (const tpl of W[k]) to.push(tpl.replace(/\{(\w+)\}/g, (m, key) => v[key]).replace(/([?!])[.…]+/g, '$1').replace(/([?!]) (\p{Ll})/u, (m, a, b) => a + ' ' + b.toUpperCase())); }; // "Why is it slow?" keeps its own mark, without a full stop after it
|
|
1428
1642
|
const cmd = (t) => String(t || '').trim().replace(/^(?:cd\s+\S+\s*(?:&&|;)\s*)+/, '').replace(/^(?:[A-Za-z_]\w*=\S*\s+)+/, '').split(/\s+(?:&&|\|\||[|;>])/)[0].split(/\s+/).slice(0, 3).join(' '); // the command itself: not the folder it starts from, nor what it is piped into
|
|
@@ -1462,11 +1676,11 @@ const clearThoughts = () => { document.querySelectorAll('.tile.musing').forEach(
|
|
|
1462
1676
|
function stopMumble() { const v = TH.voice; if (v) { TH.voice = null; try { v.src.stop(); } catch {} } }
|
|
1463
1677
|
async function mumble(id, text) { // lips closed: the mouth does not move, the music does not make room, and anyone who starts to speak cuts it
|
|
1464
1678
|
const p = S.agents[id], t = $('#t-' + id); if (!p || !t || !prefs.voice || AUD.off() || !AUD.ctx || S.speakers.size || TH.voice) return;
|
|
1465
|
-
if (!TTS.server ||
|
|
1466
|
-
const voice = TTS.voiceFor(p,
|
|
1679
|
+
if (!TTS.server || babbles()) { const o = AUD.murmur(0.5 + (p.vi % 5) / 10, Math.min(2.2, estMs(text) / 1000), 0.4); if (o) { TH.voice = { id, src: o }; o.addEventListener('ended', () => { if (TH.voice && TH.voice.src === o) TH.voice = null; }); } return; }
|
|
1680
|
+
const voice = TTS.voiceFor(p, voiceLang(text)), token = S.token; if (!voice) return; let buf; try { buf = await TTS.buf(speakable(text), voice, TTS.rate(), true); } catch { return; } // made like a line prepared ahead: it never delays a real one
|
|
1467
1681
|
if (token !== S.token || S.speakers.size || TH.voice || !t.classList.contains('musing')) return; // someone spoke meanwhile, or the thought is gone
|
|
1468
1682
|
const c = AUD.ctx, src = c.createBufferSource(), lp = c.createBiquadFilter(), g = c.createGain(); src.buffer = buf; lp.type = 'lowpass'; lp.frequency.value = 1100; g.gain.value = 0.2; let stops = [];
|
|
1469
|
-
if (prefs.vstyle === '
|
|
1683
|
+
if (prefs.vstyle === 'cartoon') { const ch = fxChain(c, src, fxFor(p)); stops = ch.stops; ch.node.connect(lp); } else src.connect(lp);
|
|
1470
1684
|
lp.connect(g); g.connect(AUD.voice); AUD.live.add(src); TH.voice = { id, src };
|
|
1471
1685
|
src.onended = () => { AUD.live.delete(src); stops.forEach((o) => { try { o.stop(); } catch {} }); if (TH.voice && TH.voice.src === src) TH.voice = null; }; src.start();
|
|
1472
1686
|
}
|
|
@@ -1624,13 +1838,15 @@ function openRecap() {
|
|
|
1624
1838
|
// episode mode: title cards and reactions
|
|
1625
1839
|
// =====================================================================
|
|
1626
1840
|
const REACT = { fr: { ack: ['Compris, chef.', 'C’est parti.', 'Encore du boulot…', 'Je m’en occupe.', 'Ok ok ok.'], done: ['Ça compile chez moi.', 'Oh là là, encore des bugs.', 'Qui a écrit ce code ?', 'Super, on a fini.', 'Classique.'] },
|
|
1627
|
-
en: { ack: ['Got it, boss.', 'On it.', 'More work, great.', 'I’ll handle it.', 'Okay okay okay.'], done: ['Works on my machine.', 'Oh man, more bugs.', 'Who wrote this code?', 'Nice, we are done.', 'Classic.'] }
|
|
1841
|
+
en: { ack: ['Got it, boss.', 'On it.', 'More work, great.', 'I’ll handle it.', 'Okay okay okay.'], done: ['Works on my machine.', 'Oh man, more bugs.', 'Who wrote this code?', 'Nice, we are done.', 'Classic.'] },
|
|
1842
|
+
es: { ack: ['Entendido, jefe.', 'Vamos allá.', 'Más trabajo, genial.', 'Yo me encargo.', 'Vale, vale, vale.'], done: ['En mi máquina funciona.', 'Madre mía, más bugs.', '¿Quién escribió este código?', 'Genial, hemos terminado.', 'Un clásico.'] },
|
|
1843
|
+
pt: { ack: ['Entendido, chefe.', 'Vamos lá.', 'Mais trabalho, que ótimo.', 'Deixa comigo.', 'Tá, tá, tá.'], done: ['Na minha máquina funciona.', 'Nossa, mais bugs.', 'Quem escreveu esse código?', 'Boa, terminamos.', 'Clássico.'] } };
|
|
1628
1844
|
const quipMem = new Map();
|
|
1629
1845
|
function prefetchQuips(i) {
|
|
1630
1846
|
if (!prefs.epi) return; const texts = [];
|
|
1631
1847
|
for (let k = i; k < Math.min(S.events.length, i + 60) && texts.length < 6; k++) if (S.events[k].kind === 'report') texts.push(baseText(S.events[k], 160));
|
|
1632
1848
|
const need = texts.filter((t) => !quipMem.has(t)); if (!need.length) return; need.forEach((t) => quipMem.set(t, null));
|
|
1633
|
-
fetch('/api/quips', { method: 'POST', body: JSON.stringify({ texts: need, lang:
|
|
1849
|
+
fetch('/api/quips', { method: 'POST', body: JSON.stringify({ texts: need, lang: CALL() }) }).then((r) => r.json()).then((d) => (d.texts || []).forEach((q, i) => d.ok && q && q !== need[i] && quipMem.set(need[i], q))).catch(() => {});
|
|
1634
1850
|
}
|
|
1635
1851
|
|
|
1636
1852
|
// Little lines that make the call feel alive. They never appear in the transcript and never replace real content: they are short, local (no API) and can be turned off in ⚙.
|
|
@@ -1641,11 +1857,17 @@ const ACK = {
|
|
|
1641
1857
|
fr: { tests: ['Je lance les tests, comme d’hab.', 'Des tests ? Toujours.', 'On va voir ce qui casse.', 'Vert ou rouge, je te dirai.'], review: ['Je mets mes lunettes de relecteur.', 'Je relis tout deux fois.', 'Je serai gentil. Peut-être.', 'Audit en cours, je reviens.'], explore: ['Je pars explorer le code.', 'Je grep comme si c’était la fin du monde.', 'Allez, on creuse.', 'Je vais le trouver.'],
|
|
1642
1858
|
fix: ['L’heure de la chasse aux bugs.', 'Je sens un bug.', 'Mode débogueur : activé.', 'Qui a cassé ça ?'], docs: ['Je rédige ça.', 'La doc, mon truc préféré.', 'Des mots arrivent.'], ui: ['Pixels, me voilà.', 'On va rendre ça joli.', 'Je regarde la mise en page.'], cleanup: ['Je nettoie ce désordre.', 'Séance de rangement.', 'Je supprime. Prudemment.'],
|
|
1643
1859
|
perf: ['On va rendre ça rapide.', 'Je profile, un instant.', 'À la chasse aux millisecondes.'], any: ['Je m’en occupe !', 'Compris, chef.', 'Je lis le brief.', 'C’est comme fait. Sûrement.', 'Ok ok ok.', 'Pas un mot de plus.', 'Je suis déjà parti.', 'Reçu cinq sur cinq.', 'D’abord un café. Ensuite ça.'] },
|
|
1860
|
+
es: { tests: ['Lanzo las pruebas, como siempre.', '¿Pruebas? Siempre.', 'A ver qué se rompe.', 'Verde o rojo, te aviso.'], review: ['Me pongo las gafas de revisor.', 'Lo leo todo dos veces.', 'Seré amable. Quizá.', 'Auditando, ahora vuelvo.'], explore: ['Me voy a explorar el código.', 'Haciendo grep como si no hubiera un mañana.', 'Hora de escarbar.', 'Lo encontraré.'],
|
|
1861
|
+
fix: ['Hora de cazar bugs.', 'Huelo un bug.', 'Modo depurador: activado.', '¿Quién ha roto esto?'], docs: ['Lo pongo por escrito.', 'Documentación, mi favorita.', 'Se vienen palabras.'], ui: ['Píxeles, allá voy.', 'Vamos a dejarlo bonito.', 'Déjame ver el diseño.'], cleanup: ['Limpiando el desorden.', 'Hora de ordenar.', 'Borrando cosas. Con cuidado.'],
|
|
1862
|
+
perf: ['Vamos a hacerlo rápido.', 'Perfilando, un momento.', 'A la caza de milisegundos.'], any: ['¡Voy!', 'Entendido, jefe.', 'Leyendo el encargo.', 'Dalo por hecho. Probablemente.', 'Vale, vale, vale.', 'No digas más.', 'Ya estoy en ello.', 'Recibido.', 'Primero un café. Luego esto.'] },
|
|
1863
|
+
pt: { tests: ['Rodando os testes, como sempre.', 'Testes? Sempre.', 'Vamos ver o que quebra.', 'Verde ou vermelho, eu aviso.'], review: ['Colocando meus óculos de revisor.', 'Lendo tudo duas vezes.', 'Vou ser legal. Talvez.', 'Auditando, já volto.'], explore: ['Vou explorar o código.', 'Dando grep como se não houvesse amanhã.', 'Hora de cavar.', 'Eu vou achar.'],
|
|
1864
|
+
fix: ['Hora de caçar bugs.', 'Sinto cheiro de bug.', 'Modo depurador: ligado.', 'Quem quebrou isso?'], docs: ['Vou escrever isso.', 'Documentação, minha favorita.', 'Palavras a caminho.'], ui: ['Pixels, aí vou eu.', 'Vamos deixar bonito.', 'Deixa eu ver o layout.'], cleanup: ['Limpando a bagunça.', 'Hora de arrumar.', 'Apagando coisas. Com cuidado.'],
|
|
1865
|
+
perf: ['Vamos deixar rápido.', 'Fazendo o profiling, um momento.', 'Caçando milissegundos.'], any: ['Deixa comigo!', 'Entendido, chefe.', 'Lendo o briefing.', 'Considere feito. Provavelmente.', 'Tá, tá, tá.', 'Nem precisa dizer mais.', 'Já estou indo.', 'Entendido.', 'Primeiro um café. Depois isso.'] },
|
|
1644
1866
|
};
|
|
1645
1867
|
const ACK_RE = [['tests', /test|qa\b|spec|jest|vitest|coverage/], ['review', /review|audit|check|inspect|lint|critique/], ['explore', /explor|search|research|find|investigat|look|map|scan/], ['fix', /fix|bug|debug|error|crash|broken/], ['docs', /\bdoc|readme|write|changelog|spec/], ['ui', /\bui\b|design|css|style|layout|front|page|component/], ['cleanup', /refactor|clean|tidy|dead code/], ['perf', /perf|speed|slow|optimi|latenc|profil/]];
|
|
1646
1868
|
function ackLine(ev) {
|
|
1647
1869
|
// classify on role and title only: the prompt text is too noisy
|
|
1648
|
-
const R = ACK[
|
|
1870
|
+
const R = ACK[CALL()], text = `${ev.title || ''} ${(S.agents[ev.to] || {}).role || ''}`.toLowerCase(), cat = (ACK_RE.find(([, re]) => re.test(text)) || [])[0];
|
|
1649
1871
|
const pool = cat && hash(String(ev.ts)) % 4 ? R[cat] : R.any, seed = hash(String(ev.ts) + ev.to); let line = pool[seed % pool.length];
|
|
1650
1872
|
if (line === S.lastAck) line = pool[(seed + 1) % pool.length]; S.lastAck = line; return line;
|
|
1651
1873
|
}
|
|
@@ -1653,8 +1875,9 @@ function ackLine(ev) {
|
|
|
1653
1875
|
// conversation: short exchanges between agents at the right moments, built from what really happened in the session
|
|
1654
1876
|
// =====================================================================
|
|
1655
1877
|
const CHAT = { quiet: 0.45, normal: 1, lively: 1.8 }, chatMul = () => CHAT[prefs.chat] || 1; // normal unless chosen otherwise
|
|
1656
|
-
const EXW = { en: { edit: ['edit', 'edits'], call: ['tool call', 'tool calls'], error: ['error', 'errors'] }, fr: { edit: ['modification', 'modifications'], call: ['appel d’outil', 'appels d’outils'], error: ['erreur', 'erreurs']
|
|
1657
|
-
|
|
1878
|
+
const EXW = { en: { edit: ['edit', 'edits'], call: ['tool call', 'tool calls'], error: ['error', 'errors'], file: ['file', 'files'] }, fr: { edit: ['modification', 'modifications'], call: ['appel d’outil', 'appels d’outils'], error: ['erreur', 'erreurs'], file: ['fichier', 'fichiers'] },
|
|
1879
|
+
es: { edit: ['cambio', 'cambios'], call: ['llamada a herramienta', 'llamadas a herramientas'], error: ['error', 'errores'], file: ['archivo', 'archivos'] }, pt: { edit: ['alteração', 'alterações'], call: ['chamada de ferramenta', 'chamadas de ferramentas'], error: ['erro', 'erros'], file: ['arquivo', 'arquivos'] } };
|
|
1880
|
+
const P = (k, n) => { const w = EXW[CALL()][k]; return `${n} ${n === 1 ? w[0] : w[1]}`; };
|
|
1658
1881
|
const EXCH = {
|
|
1659
1882
|
en: { done: ['All done.', 'Finished.', 'Okay, that’s done.', 'Done on my side.', 'That’s wrapped up.'],
|
|
1660
1883
|
ask: ['Quick question: is that the whole scope?', 'Anything else I should touch?', 'Any constraints I should know about?', 'Should I check with you before big changes?'],
|
|
@@ -1676,15 +1899,35 @@ const EXCH = {
|
|
|
1676
1899
|
chime: [(b) => `Bon boulot, ${b}.`, () => 'Joli.', (b) => `Super, ${b}.`],
|
|
1677
1900
|
trouble: [(b) => `${b}, ça va ? Ça fait beaucoup d’erreurs.`, (b) => `${b}, besoin d’un coup de main avec ces erreurs ?`], troubleBack: ['Je m’en occupe.', 'Oui, j’y suis presque.', 'Donne-moi une minute.', 'Je gère, merci.'],
|
|
1678
1901
|
sync: ['Petit point rapide : où en est-on ?', 'Point d’étape, tout le monde ?', 'On fait un tour de table rapide.'], syncAns: [(a) => `Toujours dessus : ${a}.`, (a) => `${a}, ça avance bien.`, (a) => `En ce moment : ${a}.`] },
|
|
1902
|
+
es: { done: ['Todo hecho.', 'Terminado.', 'Vale, ya está.', 'Listo por mi parte.', 'Eso ya está cerrado.'],
|
|
1903
|
+
ask: ['Una pregunta rápida: ¿eso es todo el alcance?', '¿Algo más que deba tocar?', '¿Alguna restricción que deba conocer?', '¿Te aviso antes de los cambios grandes?'],
|
|
1904
|
+
askBack: ['Solo eso, gracias.', 'No, céntrate en eso.', 'Usa tu criterio.', 'Nada especial, adelante.', 'Eso es todo, gracias.'],
|
|
1905
|
+
ok: [(f) => `Bien, ${f.what} y sin errores.`, (f) => (f.file ? `Bien, ${f.file} tiene buena pinta.` : 'Bien, tiene buena pinta.'), (f, b) => `Perfecto${f.dur ? ', ha llevado ' + f.dur : ''}. Gracias, ${b}.`, (f) => `Genial, ${f.what}. Limpio.`],
|
|
1906
|
+
err: [(f) => `He visto ${P('error', f.errs)} por el camino. ¿Todo bien ahora?`, (f) => `${P('error', f.errs)} por el camino, ¿es sólido?`],
|
|
1907
|
+
errBack: ['Sí, solo eran reintentos.', 'Todo arreglado al final.', 'Sí, algún tropiezo, nada grave.', 'Ahora es sólido.'],
|
|
1908
|
+
slow: [(f) => `Ha llevado ${f.dur}. ¿Algo te bloquea?`, (f) => `${f.dur}, ha sido largo. ¿Todo bien?`], slowBack: ['No, es que era grande.', 'Nada me bloquea, había mucho que leer.', 'Todo bien, era pesado.'],
|
|
1909
|
+
chime: [(b) => `Buen trabajo, ${b}.`, () => 'Muy bien.', (b) => `Genial, ${b}.`],
|
|
1910
|
+
trouble: [(b) => `${b}, ¿todo bien? Son muchos errores.`, (b) => `${b}, ¿te echo una mano con esos errores?`], troubleBack: ['Estoy en ello.', 'Sí, ya casi lo tengo.', 'Dame un minuto.', 'Me encargo, gracias.'],
|
|
1911
|
+
sync: ['Repaso rápido: ¿cómo vamos?', '¿Estado, equipo?', 'Hagamos una ronda rápida.'], syncAns: [(a) => `Sigo con ello: ${a}.`, (a) => `${a}, va bien.`, (a) => `Ahora mismo: ${a}.`] },
|
|
1912
|
+
pt: { done: ['Tudo feito.', 'Terminei.', 'Pronto, está feito.', 'Feito do meu lado.', 'Isso está fechado.'],
|
|
1913
|
+
ask: ['Pergunta rápida: esse é o escopo todo?', 'Mais alguma coisa em que eu deva mexer?', 'Alguma restrição que eu deva saber?', 'Aviso você antes das mudanças grandes?'],
|
|
1914
|
+
askBack: ['Só isso, valeu.', 'Não, mantenha o foco.', 'Use o seu critério.', 'Nada de especial, pode ir.', 'É só isso, valeu.'],
|
|
1915
|
+
ok: [(f) => `Boa, ${f.what} e nenhum erro.`, (f) => (f.file ? `Bom, ${f.file} parece certo.` : 'Bom, parece certo.'), (f, b) => `Perfeito${f.dur ? ', levou ' + f.dur : ''}. Valeu, ${b}.`, (f) => `Ótimo, ${f.what}. Limpo.`],
|
|
1916
|
+
err: [(f) => `Vi ${P('error', f.errs)} pelo caminho. Tudo certo agora?`, (f) => `${P('error', f.errs)} pelo caminho, está firme?`],
|
|
1917
|
+
errBack: ['Sim, eram só novas tentativas.', 'Tudo resolvido no final.', 'Sim, uns tropeços, nada sério.', 'Agora está firme.'],
|
|
1918
|
+
slow: [(f) => `Levou ${f.dur}. Alguma coisa travando você?`, (f) => `${f.dur}, foi demorado. Tudo bem?`], slowBack: ['Não, é que era grande.', 'Nada travando, só tinha muito para ler.', 'Tudo bem, era pesado.'],
|
|
1919
|
+
chime: [(b) => `Bom trabalho, ${b}.`, () => 'Boa.', (b) => `Ótimo, ${b}.`],
|
|
1920
|
+
trouble: [(b) => `${b}, tudo bem? É muito erro.`, (b) => `${b}, precisa de uma mão com esses erros?`], troubleBack: ['Estou cuidando disso.', 'Sim, estou quase lá.', 'Me dá um minuto.', 'Deixa comigo, valeu.'],
|
|
1921
|
+
sync: ['Alinhamento rápido: como estamos?', 'Status, pessoal?', 'Vamos fazer uma rodada rápida.'], syncAns: [(a) => `Sigo nisso: ${a}.`, (a) => `${a}, indo bem.`, (a) => `No momento: ${a}.`] },
|
|
1679
1922
|
};
|
|
1680
1923
|
const exPick = (arr, seed, ...args) => { let k = seed % arr.length; if (arr[k] === S.lastX && arr.length > 1) k = (k + 1) % arr.length; S.lastX = arr[k]; return typeof arr[k] === 'function' ? arr[k](...args) : arr[k]; };
|
|
1681
|
-
function exchFacts(i, agent) { // what this agent did since it received its order: edits, tool calls, errors, the
|
|
1682
|
-
const ev = S.events; let o = -1;
|
|
1683
|
-
for (let k = i; k >= Math.max(0, i - 600); k--)
|
|
1684
|
-
const f = { tools: 0, edits: 0, errs: 0, file: '', dur: '', ms: 0 };
|
|
1924
|
+
function exchFacts(i, agent) { // what this agent did since it received its order: edits, tool calls, errors, the files it changed, how long it took
|
|
1925
|
+
const ev = S.events, lead = agent === 'main'; let o = -1; // the lead: back to your message, or to the message that closed its previous stretch when it was woken without you (a background task that finished)
|
|
1926
|
+
for (let k = i, acted = false; k >= Math.max(0, i - (lead ? 6000 : 600)); k--) { const e = ev[k]; if (lead ? e.kind === 'user' || (e.end && acted) : e.kind === 'order' && e.to === agent) { o = e.end ? k + 1 : k; break; } if (e.agent === 'main' && (e.end || e.kind === 'say' || e.kind === 'tools')) acted = true; }
|
|
1927
|
+
const f = { tools: 0, edits: 0, errs: 0, file: '', files: [], dur: '', ms: 0 };
|
|
1685
1928
|
for (let k = o >= 0 ? o : Math.max(0, i - 250); k <= i; k++) {
|
|
1686
1929
|
const e = ev[k]; if (e.agent !== agent) continue;
|
|
1687
|
-
if (e.kind === 'tools') for (const t of e.tools) { f.tools++; if (/^(Edit|Write|MultiEdit|NotebookEdit)/.test(t.name)) { f.edits++; f.file = base((t.d || {}).file || t.arg) || f.file; } }
|
|
1930
|
+
if (e.kind === 'tools') for (const t of e.tools) { f.tools++; if (/^(Edit|Write|MultiEdit|NotebookEdit)/.test(t.name)) { f.edits++; f.file = base((t.d || {}).file || t.arg) || f.file; if (f.file && !f.files.includes(f.file)) f.files.push(f.file); } }
|
|
1688
1931
|
else if (e.kind === 'results') f.errs += e.items.filter((it) => it.err).length;
|
|
1689
1932
|
}
|
|
1690
1933
|
if (o >= 0 && ev[i].ts && ev[o].ts) { f.ms = Math.max(0, ev[i].ts - ev[o].ts); f.dur = fmtShort(f.ms); }
|
|
@@ -1704,18 +1947,18 @@ function noteTrouble(agent, ok) { // three errors in a row: someone asks if ev
|
|
|
1704
1947
|
}
|
|
1705
1948
|
function pickOther(not, prefer) { const ids = Object.keys(S.agents).filter((id) => id !== 'user' && !not.includes(id) && exVisible(id)); const pr = ids.filter(prefer || (() => false)); const a = pr.length ? pr : ids; return a.length ? a[Math.floor(Math.random() * a.length)] : null; }
|
|
1706
1949
|
async function handoffX(g, seed, token) { // an order: the new agent asks a question, the lead answers
|
|
1707
|
-
const E = EXCH[
|
|
1950
|
+
const E = EXCH[CALL()], b = g.to, a = g.agent; if (!exVisible(a) || !exVisible(b)) return false; exLog('handoff');
|
|
1708
1951
|
return (await exSay(b, exPick(E.ask, seed), token)) && (await exSay(a, exPick(E.askBack, seed >>> 3), token));
|
|
1709
1952
|
}
|
|
1710
1953
|
async function reportX(g, i, seed, token) { // a report: the receiver reacts to what really happened
|
|
1711
|
-
const E = EXCH[
|
|
1954
|
+
const E = EXCH[CALL()], b = g.agent, a = g.to; if (a === 'user' || !exVisible(a) || !exVisible(b)) return false; const f = exchFacts(i, b);
|
|
1712
1955
|
if (f.errs > 0) { exLog('report-errors'); return (await exSay(a, exPick(E.err, seed, f), token)) && (await exSay(b, exPick(E.errBack, seed >>> 3), token)); }
|
|
1713
1956
|
if (f.ms >= 120000) { exLog('report-slow'); return (await exSay(a, exPick(E.slow, seed, f), token)) && (await exSay(b, exPick(E.slowBack, seed >>> 3), token)); }
|
|
1714
1957
|
exLog('report-ok'); if (!(await exSay(a, exPick(E.ok, seed, f, nameOf(b)), token))) return false;
|
|
1715
1958
|
const c = (seed >>> 5) % 100 < 35 ? pickOther([a, b]) : null; if (c) await exSay(c, exPick(E.chime, seed >>> 7, nameOf(b)), token); return true;
|
|
1716
1959
|
}
|
|
1717
1960
|
async function troubleX(token) { // someone keeps failing: a colleague checks in
|
|
1718
|
-
const E = EXCH[
|
|
1961
|
+
const E = EXCH[CALL()]; while (S.exQ && S.exQ.length) {
|
|
1719
1962
|
const x = S.exQ.shift(); if (!exVisible(x)) continue; const h = pickOther([x], (id) => id === 'main'); if (!h) continue; const seed = hash('t' + x + Date.now());
|
|
1720
1963
|
exLog('trouble'); return (await exSay(h, exPick(E.trouble, seed, nameOf(x)), token)) && (await exSay(x, exPick(E.troubleBack, seed >>> 3), token));
|
|
1721
1964
|
}
|
|
@@ -1724,7 +1967,7 @@ async function troubleX(token) { // someone keeps failing: a colleague checks
|
|
|
1724
1967
|
async function syncX(g, token) { // every few minutes of the session: the lead asks where everyone is, the busy agents answer
|
|
1725
1968
|
if (chatMul() < 0.9 || !g.ts || g.ts - (S.syncTs || 0) < 180000 || !exVisible('main')) return false;
|
|
1726
1969
|
const now = Date.now(), busy = Object.keys(S.agents).filter((id) => id !== 'user' && id !== 'main' && exVisible(id) && agentState(id, now).k === 'working').slice(0, 3); if (busy.length < 2) return false;
|
|
1727
|
-
S.syncTs = g.ts; const E = EXCH[
|
|
1970
|
+
S.syncTs = g.ts; const E = EXCH[CALL()], seed = hash('s' + g.ts); exLog('sync');
|
|
1728
1971
|
if (!(await exSay('main', exPick(E.sync, seed), token))) return false;
|
|
1729
1972
|
for (const [n, id] of busy.entries()) { const act = (S.act[id] || '').replace(/^\S+\s/, '') || L('au travail', 'working'); if (!(await exSay(id, exPick(E.syncAns, seed >>> (n + 1), act.charAt(0).toLowerCase() + act.slice(1)), token))) return false; }
|
|
1730
1973
|
return true;
|
|
@@ -1743,12 +1986,12 @@ async function converse(g, token) { // after a line has been said: an exchange
|
|
|
1743
1986
|
}
|
|
1744
1987
|
// What is said out loud for an order or a report: a natural lead-in, then the text
|
|
1745
1988
|
function talkLine(g) {
|
|
1746
|
-
const E = EXCH[
|
|
1989
|
+
const E = EXCH[CALL()], seed = hash('l' + g.ts + g.agent), t = spoken(g);
|
|
1747
1990
|
if (g.kind === 'report') return t.replace(/^(Terminé\.|Done\.)\s*/, E.done[seed % E.done.length] + ' ');
|
|
1748
1991
|
return t;
|
|
1749
1992
|
}
|
|
1750
1993
|
async function react(ev, token) {
|
|
1751
|
-
if ((!prefs.epi && !prefs.banter) || S.boost > 1 || S.hurry || !nearLive()) return; const seed = hash(String(ev.ts) + ev.agent), R = REACT[
|
|
1994
|
+
if ((!prefs.epi && !prefs.banter) || S.boost > 1 || S.hurry || !nearLive()) return; const seed = hash(String(ev.ts) + ev.agent), R = REACT[CALL()]; let who, line, thanks = false;
|
|
1752
1995
|
if (ev.kind === 'order') { if (!prefs.banter && seed % 100 > 55) return; who = ev.to; line = prefs.banter ? ackLine(ev) : R.ack[seed % R.ack.length]; }
|
|
1753
1996
|
else if (ev.kind === 'report') {
|
|
1754
1997
|
const r = seed % 100, joke = prefs.epi ? 60 : prefs.chat === 'quiet' ? -1 : 35; // a remark from someone else, or (a little less often) a word of thanks from whoever receives the report
|
|
@@ -1767,6 +2010,12 @@ const FILL = {
|
|
|
1767
2010
|
fr: { share: ['Vous voyez bien mon écran ?', 'Deux secondes, ça charge.', 'Désolé, ma machine rame aujourd’hui.', 'C’est assez gros pour tout le monde ?', 'Une seconde… j’y suis presque.', 'Dites-moi si je vais trop vite.'],
|
|
1768
2011
|
busy: ['Toujours là, je suis dessus.', 'Pardon, j’étais en muet.', 'Petit point : j’avance.', 'Pas de point bloquant de mon côté.', 'Vous m’entendez ?', 'C’est moi, ou c’est calme ?', 'Je vous fais un retour dans une minute.'],
|
|
1769
2012
|
wait: ['Vous m’entendez ?', 'Vous êtes toujours là ?', 'Allô ? Je crois que ton micro est coupé.', 'On a perdu quelqu’un ?', 'C’est ma connexion ?', 'On en reparle en off ?', 'On refait un point quand tu veux.', 'Je vous rends une minute.', 'D’autres sujets ?', 'Pardon, vas-y. Non, toi d’abord.'] },
|
|
2013
|
+
es: { share: ['¿Se ve bien mi pantalla?', 'Un momento, está cargando.', 'Perdón, mi máquina va lenta hoy.', '¿Se ve lo bastante grande?', 'Un segundo… ya casi.', 'Avisa si voy demasiado rápido.'],
|
|
2014
|
+
busy: ['Sigo aquí, a lo mío.', 'Perdón, estaba en silencio.', 'Novedades: sigo con ello.', 'Sin bloqueos por mi parte.', '¿Se me oye?', '¿Soy yo, o está todo muy callado?', 'Tendré novedades en un minuto.'],
|
|
2015
|
+
wait: ['¿Se me oye?', '¿Sigue alguien ahí?', '¿Hola? Creo que tienes el micro apagado.', '¿Hemos perdido a alguien?', '¿Es mi conexión?', '¿Lo hablamos fuera de la reunión?', 'Lo retomamos cuando quieras.', 'Un minuto libre para todos.', '¿Algún otro tema?', 'Perdón, sigue. No, tú primero.'] },
|
|
2016
|
+
pt: { share: ['Todo mundo está vendo a minha tela?', 'Só um instante, está carregando.', 'Desculpa, minha máquina está lenta hoje.', 'Está grande o suficiente para todo mundo?', 'Um segundo… quase lá.', 'Me avisem se eu estiver indo rápido demais.'],
|
|
2017
|
+
busy: ['Ainda estou aqui, focando no trabalho.', 'Desculpa, eu estava no mudo.', 'Atualização rápida: sigo nisso.', 'Sem bloqueios do meu lado.', 'Vocês estão me ouvindo?', 'É impressão minha, ou está tudo quieto?', 'Trago novidades em um minuto.'],
|
|
2018
|
+
wait: ['Vocês estão me ouvindo?', 'Vocês ainda estão aí?', 'Alô? Acho que você está no mudo.', 'Perdemos alguém?', 'É a minha conexão?', 'Vamos falar disso depois da reunião?', 'A gente retoma quando você quiser.', 'Devolvo um minuto para todo mundo.', 'Mais algum assunto?', 'Desculpa, pode falar. Não, você primeiro.'] },
|
|
1770
2019
|
};
|
|
1771
2020
|
// A little more talk between agents: a word of thanks when a report comes in, a word from whoever has been thinking for a long time.
|
|
1772
2021
|
const TALK = {
|
|
@@ -1774,8 +2023,12 @@ const TALK = {
|
|
|
1774
2023
|
think: ['Hmm, let me think.', 'Give me a second, I’m thinking.', 'Interesting… let me think this through.', 'One moment, I’m working it out.', 'Hang on, I want to get this right.', 'Let me double-check something.', 'Still thinking… almost there.', 'That one needs a bit of thought.'] },
|
|
1775
2024
|
fr: { thanks: ['Merci, ça m’aide.', 'Bien reçu, merci.', 'C’est noté. Je prends la suite.', 'Parfait, c’est ce qu’il me fallait.', 'Merci, bon boulot.', 'Bon à savoir, merci.', 'Compris, merci.', 'Super, un souci de moins.'],
|
|
1776
2025
|
think: ['Hmm, laissez-moi réfléchir.', 'Une seconde, je réfléchis.', 'Intéressant… je creuse ça.', 'Un instant, je fais le point.', 'Attendez, je veux être sûr.', 'Je vérifie un truc.', 'Je réfléchis encore… j’y suis presque.', 'Ça demande un peu de réflexion.'] },
|
|
2026
|
+
es: { thanks: ['Gracias, eso ayuda.', 'Entendido, gracias.', 'Anotado. Sigo yo desde aquí.', 'Perfecto, es lo que necesitaba.', 'Gracias, buen trabajo.', 'Bueno saberlo, gracias.', 'Comprendido, gracias.', 'Genial, una cosa menos de la que preocuparse.'],
|
|
2027
|
+
think: ['Mmm, déjame pensar.', 'Dame un segundo, estoy pensando.', 'Interesante… déjame pensarlo bien.', 'Un momento, lo estoy resolviendo.', 'Espera, quiero hacerlo bien.', 'Déjame comprobar una cosa.', 'Sigo pensando… ya casi.', 'Esto requiere pensarlo un poco.'] },
|
|
2028
|
+
pt: { thanks: ['Valeu, isso ajuda.', 'Entendi, valeu.', 'Anotado. Eu sigo daqui.', 'Perfeito, era o que eu precisava.', 'Valeu, bom trabalho.', 'Bom saber, valeu.', 'Entendido, agradeço.', 'Ótimo, uma preocupação a menos.'],
|
|
2029
|
+
think: ['Hmm, deixa eu pensar.', 'Me dá um segundo, estou pensando.', 'Interessante… deixa eu pensar melhor.', 'Um momento, estou resolvendo isso.', 'Espera, quero fazer isso direito.', 'Deixa eu conferir uma coisa.', 'Ainda pensando… quase lá.', 'Essa pede um pouco de reflexão.'] },
|
|
1777
2030
|
};
|
|
1778
|
-
function varied(kind, seed) { const P = TALK[
|
|
2031
|
+
function varied(kind, seed) { const P = TALK[CALL()][kind]; let line = P[seed % P.length]; if (line === S.lastTalk) line = P[(seed + 1) % P.length]; return (S.lastTalk = line); } // never the same line twice in a row
|
|
1779
2032
|
// Who is thinking once this event has happened: the agent whose tool just answered, the lead after your message or a report, a sub-agent that just got its order. After a line or a tool call, nobody is.
|
|
1780
2033
|
const thinkerOf = (e) => (e.kind === 'results' ? e.agent : e.kind === 'user' ? 'main' : e.kind === 'report' || e.kind === 'finish' || e.kind === 'order' ? e.to : null);
|
|
1781
2034
|
const before = (i) => { let k = i - 1; while (k >= 0 && (S.events[k].kind === 'usage' || S.events[k].kind === 'compact')) k--; return S.events[k]; };
|
|
@@ -1787,21 +2040,41 @@ async function ponder(i, token) { // replay: an agent that really took a long
|
|
|
1787
2040
|
const LEAD = {
|
|
1788
2041
|
en: { in: ['Got it.', 'Okay.', 'On it.', 'Sure.', 'Right.'], read: 'Let me look at ', edit: 'I’m editing ', write: 'I’m writing ', cmd: 'I’m running ', note: 'I’m running a command: ', grep: 'Let me search the code.', glob: 'Let me see which files we have.', todo: 'Let me lay out a plan.', web: 'Let me check the web.', question: 'I have a question for you.', any: 'Let me get started.', and: ' and ' },
|
|
1789
2042
|
fr: { in: ['D’accord.', 'Compris.', 'Très bien.', 'Entendu.', 'Ça marche.'], read: 'Je regarde ', edit: 'Je modifie ', write: 'J’écris ', cmd: 'Je lance ', note: 'Je lance une commande : ', grep: 'Je cherche dans le code.', glob: 'Je regarde quels fichiers on a.', todo: 'Je fais mon plan.', web: 'Je vais voir sur le web.', question: 'J’ai une question pour vous.', any: 'Je m’y mets.', and: ' et ' },
|
|
2043
|
+
es: { in: ['Entendido.', 'Vale.', 'Voy.', 'Claro.', 'De acuerdo.'], read: 'Voy a mirar ', edit: 'Estoy editando ', write: 'Estoy escribiendo ', cmd: 'Estoy ejecutando ', note: 'Ejecuto un comando: ', grep: 'Voy a buscar en el código.', glob: 'Voy a ver qué archivos tenemos.', todo: 'Voy a trazar un plan.', web: 'Voy a mirar en la web.', question: 'Tengo una pregunta para ti.', any: 'Me pongo a ello.', and: ' y ' },
|
|
2044
|
+
pt: { in: ['Entendi.', 'Certo.', 'Deixa comigo.', 'Claro.', 'Tá bom.'], read: 'Vou dar uma olhada em ', edit: 'Estou editando ', write: 'Estou escrevendo ', cmd: 'Estou rodando ', note: 'Estou rodando um comando: ', grep: 'Vou procurar no código.', glob: 'Vou ver quais arquivos temos.', todo: 'Vou montar um plano.', web: 'Vou conferir na web.', question: 'Tenho uma pergunta para você.', any: 'Vou começar.', and: ' e ' },
|
|
1790
2045
|
};
|
|
1791
2046
|
async function leadAck(ev, token) {
|
|
1792
2047
|
if (!prefs.banter || !S.agents.main) { S.owed = false; return; } if (S.hurry || S.boost > 1 || !nearLive() || S.speakers.size) return; S.owed = false; // reading your order took a while: the first tool is rarely less than 6 s old; if now is a bad moment, the next tool will do
|
|
1793
|
-
const W = LEAD[
|
|
2048
|
+
const W = LEAD[CALL()], d = ev.tools[0].d || {}, k = d.kind === 'text' ? d.what : d.kind; let what = W[k] || W.any;
|
|
1794
2049
|
if (k === 'read' || k === 'edit' || k === 'write') { const files = [...new Set(ev.tools.filter((t) => (t.d || {}).kind === k).map((t) => base(t.d.file)).filter(Boolean))].slice(0, 2); what = files.length ? what + files.join(W.and) + '.' : W.any; }
|
|
1795
2050
|
else if (k === 'cmd') { const note = (d.note || '').trim().replace(/[.\s]+$/, ''), cmd = String(d.text || '').trim().split(/\s+/).slice(0, 2).join(' ').slice(0, 26); what = note ? W.note + note + '.' : cmd ? what + cmd + '.' : W.any; }
|
|
1796
2051
|
await sayLine('main', `${W.in[hash('k' + ev.ts) % W.in.length]} ${what}`, '💬', token);
|
|
1797
2052
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2053
|
+
// Live, each time the lead is done (the happy face), it has a word. From its own message when part of it was left unread (wrapUp); else what it just did, taken from the session, and how it ends:
|
|
2054
|
+
// you: its turn is over, the floor goes back to you. step: it only went quiet, nothing says its turn is over. team: the agents it waited for are all back, and Claude Code wakes it with their reports.
|
|
2055
|
+
// The last two are the wins in the middle of a turn: about one closing message in five is followed by more work without a word from you.
|
|
2056
|
+
const CLOSE = {
|
|
2057
|
+
en: { edit: [(a) => `I changed ${a}.`, (a) => `I updated ${a}.`, (a) => `My changes are in ${a}.`], calls: [(w, d) => `That was ${w}${d ? ' in ' + d : ''}.`, (w, d) => `In total: ${w}${d ? ' in ' + d : ''}.`], said: ['That’s my answer.', 'That’s all from me.', 'Nothing more from me.'], ask: ['I’ll wait for your answer.', 'Your call.', 'Tell me what you prefer.'], you: ['Your turn.', 'Over to you.', 'Back to you.'], step: ['One step done.', 'That part is done.', 'So far so good.'], team: ['The team is back. I’ll go through the reports.', 'All the reports are in. Let me read them.', 'Everyone has reported. I’ll take it from here.'], and: ' and ' },
|
|
2058
|
+
fr: { edit: [(a) => `J’ai modifié ${a}.`, (a) => `J’ai mis à jour ${a}.`, (a) => `Mes changements sont dans ${a}.`], calls: [(w, d) => `Ça fait ${w}${d ? ' en ' + d : ''}.`, (w, d) => `Au total : ${w}${d ? ' en ' + d : ''}.`], said: ['Voilà ma réponse.', 'C’est tout pour moi.', 'Rien de plus de mon côté.'], ask: ['J’attends votre réponse.', 'À vous de décider.', 'Dites-moi ce que vous préférez.'], you: ['À vous.', 'C’est à vous.', 'Je vous rends la main.'], step: ['Une étape de faite.', 'Cette partie est faite.', 'Jusqu’ici, tout va bien.'], team: ['L’équipe est de retour. Je parcours les rapports.', 'Tous les rapports sont là. Je les lis.', 'Tout le monde a rendu son rapport. Je prends la suite.'], and: ' et ' },
|
|
2059
|
+
es: { edit: [(a) => `He cambiado ${a}.`, (a) => `He actualizado ${a}.`, (a) => `Mis cambios están en ${a}.`], calls: [(w, d) => `Eso suma ${w}${d ? ' en ' + d : ''}.`, (w, d) => `En total: ${w}${d ? ' en ' + d : ''}.`], said: ['Esa es mi respuesta.', 'Eso es todo por mi parte.', 'Nada más por mi parte.'], ask: ['Espero tu respuesta.', 'Tú decides.', 'Dime qué prefieres.'], you: ['Tu turno.', 'Te toca.', 'Te devuelvo la palabra.'], step: ['Un paso hecho.', 'Esa parte está hecha.', 'Hasta aquí, todo bien.'], team: ['El equipo ha vuelto. Voy a repasar los informes.', 'Ya están todos los informes. Voy a leerlos.', 'Todos han informado. Sigo yo desde aquí.'], and: ' y ' },
|
|
2060
|
+
pt: { edit: [(a) => `Alterei ${a}.`, (a) => `Atualizei ${a}.`, (a) => `Minhas alterações estão em ${a}.`], calls: [(w, d) => `Isso deu ${w}${d ? ' em ' + d : ''}.`, (w, d) => `No total: ${w}${d ? ' em ' + d : ''}.`], said: ['Essa é a minha resposta.', 'Isso é tudo da minha parte.', 'Nada mais da minha parte.'], ask: ['Aguardo sua resposta.', 'Você decide.', 'Me diga o que prefere.'], you: ['Sua vez.', 'É com você.', 'Passo a palavra para você.'], step: ['Uma etapa feita.', 'Essa parte está feita.', 'Até aqui, tudo certo.'], team: ['A equipe voltou. Vou passar pelos relatórios.', 'Todos os relatórios chegaram. Vou ler.', 'Todo mundo entregou. Eu sigo daqui.'], and: ' e ' },
|
|
2061
|
+
};
|
|
2062
|
+
function closeLine(e, tail) { // e: the message that closed this stretch of work; none when there is no new one, and then the line is only how it ends
|
|
2063
|
+
const W = CLOSE[CALL()], f = e ? exchFacts(S.pos - 1, 'main') : null, n = f ? f.files.length : 0, ask = tail === 'you' && !!e && /[??]$/.test(plain(e.text)); // it ends on a question: the floor is yours, to answer it
|
|
2064
|
+
const make = (s) => { const end = W[tail][(s >>> 3) % W[tail].length]; if (!e) return end; if (ask) return W.ask[s % W.ask.length];
|
|
2065
|
+
const did = n ? W.edit[s % W.edit.length](n < 3 ? f.files.join(W.and) : P('file', n)) : f.tools ? W.calls[s % W.calls.length](P('call', f.tools), f.ms >= 20000 ? f.dur : '') : tail === 'you' ? W.said[s % W.said.length] : ''; return (did ? did + ' ' : '') + end; };
|
|
2066
|
+
const s = hash('c' + (e ? e.ts : Date.now())); let line = make(s); if (line === S.lastClose) line = make(s + 8); return (S.lastClose = line); // never the same line twice in a row
|
|
2067
|
+
}
|
|
2068
|
+
async function wrapUp(token, brief) { // brief: the call already has more to play (the lead went on, or you typed): the short line only, not the rest of a message that is no longer the news
|
|
2069
|
+
if (!S.wrap || S.speakers.size || !prefs.voice && !prefs.banter) return false; const was = S.wrap; S.wrap = false;
|
|
2070
|
+
if (agentState('main', Date.now()).k !== 'done') return false; // back at work before it had the floor
|
|
2071
|
+
if (was === 'waiting') { if (!prefs.banter) return false; await sayLine('main', closeLine(null, 'team'), '🎉', token); return true; } // its last message dates from before the wait
|
|
2072
|
+
let k = Math.min(S.pos, S.events.length) - 1; while (k >= 0 && !(S.events[k].agent === 'main' && S.events[k].kind === 'say')) k--; const e = k >= 0 ? S.events[k] : null, m = S.mainSaid; // among what the call has played
|
|
2073
|
+
const fresh = !!e && S.wrapped !== e && e.ts > (S.from || 0); if (fresh) S.wrapped = e; // a message counts once: the lead's state can flip to done several times (a short command, a silence) without a new message
|
|
2074
|
+
const mine = fresh && !!m && m.ev === e; let line = ''; // mine: this very message was read, in full or cut short. Otherwise it was never read, and is summed up from its start
|
|
2075
|
+
if (fresh && !brief && !(mine && m.full)) { const rest = gist(e.text, mine ? plain(e.text).slice(0, m.said) : ''); if (rest.length >= 25) line = (mine ? L('Pour résumer : ', 'To sum up: ') : '') + rest; }
|
|
2076
|
+
if (!line && prefs.banter) line = closeLine(fresh ? e : null, S.turnOver ? 'you' : 'step'); // nothing of its message is left to read: a little line of the call, off with the others in ⚙
|
|
2077
|
+
if (!line) return false; await sayLine('main', line, '🎉', token); return true;
|
|
1805
2078
|
}
|
|
1806
2079
|
async function smallTalk(token) {
|
|
1807
2080
|
if (prefs.chat === 'quiet') return; // quiet: nothing to fill the silences, only the real exchanges
|
|
@@ -1810,7 +2083,7 @@ async function smallTalk(token) {
|
|
|
1810
2083
|
const p = before(S.events.length), muser = S.live && !n && !S.mused && p ? thinkerOf(p) : null, think = !!muser && here.includes(muser) && quiet > 6000 && Date.now() - p.ts > 20000 && Date.now() - p.ts < 180000; // live: 20 s without a word from whoever is thinking, once per silence
|
|
1811
2084
|
if (!think && (quiet < (S.live ? 45000 : 12000 / spd()) * [1, 2.5, 6][n] || (S.live && Date.now() - last.ts > 6e5))) return; // live: a session untouched for ten minutes is a call that is over
|
|
1812
2085
|
const busy = here.filter((id) => agentState(id, Date.now()).k === 'working'), who = think ? muser : S.present && here.includes(S.present) ? S.present : pick(busy.length ? busy : here); if (!who) return; // whoever shares their screen speaks, so the screen stays up
|
|
1813
|
-
const P = FILL[
|
|
2086
|
+
const P = FILL[CALL()][who === S.present ? 'share' : busy.length ? 'busy' : 'wait']; let line = think ? varied('think', Math.floor(Math.random() * 97)) : pick(P); if (!think && line === S.lastFill) line = P[(P.indexOf(line) + 1) % P.length]; if (!think) S.lastFill = line;
|
|
1814
2087
|
startTalk(who, line, think ? '💭' : '💬'); if (think) S.mused = true; else S.fill = n + 1; await speakLine(line, S.agents[who], true, token); stopTalk(who);
|
|
1815
2088
|
}
|
|
1816
2089
|
async function card(text, sub, ms = 2500) {
|
|
@@ -1831,6 +2104,8 @@ async function run(i) {
|
|
|
1831
2104
|
while (token === S.token) {
|
|
1832
2105
|
const lim = S.stopAt || S.events.length; S.pos = i;
|
|
1833
2106
|
if (S.live && S.late.length) { await converse(S.late.shift(), token); if (token !== S.token) return; continue; } // a line that turned out to be a report after it was read
|
|
2107
|
+
if (S.live && S.knock && !S.hurry) { const v = S.knock; S.knock = null; await visitSay(v, token); if (token !== S.token) return; continue; } // a visitor from another session: between two lines of the call, never over one
|
|
2108
|
+
if (S.live && S.wrap && i < lim && !S.hurry && S.boost <= 1 && nearLive()) { if (await wrapUp(token, true)) { if (token !== S.token) return; continue; } } // the lead's word for what it just finished comes before what happened next: a win in the middle of a turn is followed by more work within seconds
|
|
1834
2109
|
if (i >= lim) { if (S.live && !S.stopAt) { if (!S.idle) { S.idle = true; syncUI(); } if (await wrapUp(token)) continue; await smallTalk(token); await sleep(350); continue; } break; }
|
|
1835
2110
|
if (S.idle) { S.idle = false; syncUI(); }
|
|
1836
2111
|
if (S.live) { // way behind: skip ahead to stay current, but only count what is actually said: sub-agents produce thousands of silent tool events
|
|
@@ -1851,7 +2126,7 @@ async function run(i) {
|
|
|
1851
2126
|
const backlog = S.live ? S.events.length - i : 0, quick = S.live ? Math.min(1, 40 / Math.max(1, backlog)) : 1; // live: hundreds of tool events from parallel sub-agents must not take minutes to scroll past
|
|
1852
2127
|
if (ev.kind === 'results') { applyResults(ev, S.boost > 1); await sleep((S.boost === 1 && S.present === ev.agent && ev.items.some((it) => it.img) ? (S.live ? 900 : 1800) : S.demo ? 900 : S.live ? 30 * quick : 80) / spd()); i++; continue; } // a picture gets a moment on screen
|
|
1853
2128
|
if (ev.kind === 'tools') { applyStatus(ev); tickTools(ev); AUD.click(); OFFICE.kick(ev.tools[ev.tools.length - 1].name); paintStatus(); if (S.live && S.owed && ev.agent === 'main') { await leadAck(ev, token); if (token !== S.token) return; } if (quick === 1) await smallTalk(token); await sleep((S.demo ? 1100 : S.live ? 110 * quick : 250) / spd()); i++; continue; }
|
|
1854
|
-
const group = [ev]; let j = i + 1; // sub-agents talking back-to-back were running in parallel:
|
|
2129
|
+
const group = [ev]; let j = i + 1; // sub-agents talking back-to-back were running in parallel: their lines are taken together and said one after the other
|
|
1855
2130
|
if (ev.kind === 'order') { // several orders in a row (a parallel launch): the new agents all appear now, the first order is read, the others are named in one line
|
|
1856
2131
|
while (j < Math.min(S.events.length, i + 40) && group.length < 8) { const e2 = S.events[j]; if (e2.kind === 'usage' || e2.kind === 'compact') { tally(e2); j++; continue; } if (e2.kind === 'order' && e2.agent === ev.agent) { group.push(e2); j++; } else break; }
|
|
1857
2132
|
if (group.length > 1) { for (const g of group) applyStatus(g); paintStatus(); }
|
|
@@ -1866,16 +2141,16 @@ async function run(i) {
|
|
|
1866
2141
|
if (e2.kind !== 'order' && isSub(e2.agent) && !group.some((g) => g.agent === e2.agent)) { group.push(e2); j++; } else break;
|
|
1867
2142
|
}
|
|
1868
2143
|
}
|
|
1869
|
-
if (
|
|
2144
|
+
if (TRL() && !S.hurry) { prefetchTr(i); await Promise.race([ensureTr(group.map((g) => baseText(g))), sleep(S.live ? 7000 : 14000)]); if (token !== S.token) return; }
|
|
1870
2145
|
prefetchQuips(i); warmTTS(i);
|
|
1871
2146
|
const playOne = (g) => {
|
|
1872
|
-
applyStatus(g); g._as = g.kind; if (g.agent === 'user') S.owed = true; else if (g.agent === 'main') S.owed = false; // your order waits for a word from the lead
|
|
2147
|
+
applyStatus(g); if (g.end) paintStates(); g._as = g.kind; if (g.agent === 'user') S.owed = true; else if (g.agent === 'main') S.owed = false; // your order waits for a word from the lead
|
|
1873
2148
|
const label = g.kind === 'order' ? `${L('pour', 'to')} ${nameOf(g.to)}` : g.kind === 'report' ? `${L('rapport à', 'report to')} ${nameOf(g.to)}` : '', line = talkLine(g);
|
|
1874
2149
|
startTalk(g.agent, line, label);
|
|
1875
2150
|
if (g.kind === 'order') { S.status[g.to] = 'working'; AUD.join(); setTimeout(() => { paintStatus(); fly(g.agent, g.to, '📨'); popTile(g.to); }, 30); }
|
|
1876
2151
|
if (g.kind === 'report') { AUD.ding(); setTimeout(() => { fly(g.agent, g.to, '✅'); popTile(g.agent); }, 30); }
|
|
1877
2152
|
const said = clipSpeech(line, S.pace); if (g.agent === 'main' && g.kind === 'say') { const full = plain(g.text), key = said.replace(/…$/, '').trim().slice(-30), pos = key ? full.indexOf(key) : -1, n = pos >= 0 ? pos + key.length : said.length; S.mainSaid = { ev: g, said: n, full: n >= full.length - 5 }; }
|
|
1878
|
-
return speakLine(said, S.agents[g.agent], true, token,
|
|
2153
|
+
return speakLine(said, S.agents[g.agent], true, token, sessVoice(said, g), g.kind === 'user').then(() => { if (token === S.token) stopTalk(g.agent); });
|
|
1879
2154
|
};
|
|
1880
2155
|
let plays;
|
|
1881
2156
|
if (ev.kind === 'order' && group.length > 1) { // the first order in full, then "Also Remy on X, Iris on Y"
|
|
@@ -1883,8 +2158,8 @@ async function run(i) {
|
|
|
1883
2158
|
setTimeout(() => rest.forEach((o, k) => setTimeout(() => { fly(o.agent, o.to, '📨'); popTile(o.to); }, k * 120)), 30);
|
|
1884
2159
|
plays = [playOne(ev).then(() => { if (token !== S.token) return; startTalk(ev.agent, line, ''); return speakLine(clipSpeech(line, S.pace), S.agents[ev.agent], true, token).then(() => { if (token === S.token) stopTalk(ev.agent); }); })];
|
|
1885
2160
|
}
|
|
1886
|
-
else
|
|
1887
|
-
S.idx = j - 1; paintStatus(); await Promise.all(plays); if (token !== S.token) return;
|
|
2161
|
+
else plays = [group.reduce((turn, g) => turn.then(() => { if (token !== S.token) return null; if (!S.live) { S.idx = S.events.indexOf(g); paintStatus(); } return playOne(g); }), Promise.resolve())]; // one voice at a time, live and in replay: each waits for the one before to finish, so every line is heard. In a replay the place follows the one who speaks: paused there, the replay resumes with that line and loses none of the next ones
|
|
2162
|
+
S.idx = j - 1; paintStatus(); await Promise.all(plays); if (token !== S.token) return; S.idx = j - 1;
|
|
1888
2163
|
for (const g of (ev.kind === 'order' ? group.slice(0, 3) : group)) { await converse(g, token); if (token !== S.token) return; } // a parallel launch: the first three answer, as long as the call keeps up
|
|
1889
2164
|
i = j;
|
|
1890
2165
|
}
|
|
@@ -1925,24 +2200,28 @@ async function loadSession(proj, id) {
|
|
|
1925
2200
|
const data = await (await fetch(`/api/session?proj=${encodeURIComponent(proj)}&id=${id}`)).json();
|
|
1926
2201
|
if (mine !== S.loadN || data.error) return false;
|
|
1927
2202
|
S.term = {}; S.camFor = null; S.focus = null; S.agents = {}; for (const k in nameBook) delete nameBook[k]; [{ id: 'user' }, ...data.agents].forEach((a) => (S.agents[a.id] = persona(a)));
|
|
1928
|
-
clearThoughts(); Object.assign(TH, { since: {}, next: {}, said: {}, last: 0 }); S.events = data.events; stampT(0); S.byK = new Map(data.events.map((e) => [e.k, e])); S.seq = data.seq || 0; S.ep = data.ep || ''; S.sawEnd = data.events.some((e) => e.end); S.late = []; S.pos = 0; S.joinAt = Date.now(); S.idx = 0; S.status = {}; S.tc = {}; S.cur = { proj, id }; S.logTo = 0; S.detail = null; $('#detail').classList.remove('on');
|
|
2203
|
+
clearThoughts(); Object.assign(TH, { since: {}, next: {}, said: {}, last: 0 }); S.events = data.events; stampT(0); S.byK = new Map(data.events.map((e) => [e.k, e])); S.seq = data.seq || 0; S.ep = data.ep || ''; S.sawEnd = !!data.marks || data.events.some((e) => e.end); S.late = []; S.pos = 0; S.joinAt = Date.now(); S.idx = 0; S.status = {}; S.tc = {}; S.cur = { proj, id }; S.logTo = 0; S.detail = null; $('#detail').classList.remove('on'); S.fgone = new Set(); S.fmade = new Map(); S.artOk = new Map(); S.artPin = null;
|
|
1929
2204
|
const opt = $('#sessions').selectedOptions[0]; S.title = (S.live ? niceProj(proj) : opt && opt.dataset.title) || '';
|
|
1930
|
-
if (proj === '_demo') S.events.forEach((e) => { if (e.fr) trMem.set(baseText(e), e.fr); }); // the demo ships its own French
|
|
2205
|
+
if (proj === '_demo') S.events.forEach((e) => { if (e.fr) trMem.set(baseText(e), e.fr, 'fr'); }); // the demo ships its own French
|
|
1931
2206
|
$('#subtitle').textContent = S.title; recomputeStatus(0); buildStage(); renderHighlights(); setFocus('main'); renderLog(true); computeGantt(); layout(); paintStatus(); prefetchTr(0); return true;
|
|
1932
2207
|
}
|
|
1933
|
-
const niceProj = (p) => (p === '_demo' ? '' : p === '_codex' ? 'Codex' : p === '_vibe' ? 'Mistral Vibe' : String(p).replace(/^-+/, '').replace(/-/g, '/').split('/').slice(-2).join('/'));
|
|
2208
|
+
const niceProj = (p) => (p === '_demo' ? '' : p === '_codex' ? 'Codex' : p === '_vibe' ? 'Mistral Vibe' : p === '_cowork' ? 'Cowork' : String(p).replace(/^-+/, '').replace(/-/g, '/').split('/').slice(-2).join('/'));
|
|
1934
2209
|
async function fillProjects() { // live view: follow the latest activity anywhere, or pin one project
|
|
1935
2210
|
const sel = $('#liveProj'); let rows = []; try { rows = await (await fetch('/api/projects')).json(); } catch {}
|
|
1936
2211
|
sel.innerHTML = `<option value="">${L('Tous les projets (le plus récent)', 'All projects (most recent)')}</option>` + rows.map((r) => `<option value="${esc(r.proj)}">${esc(niceProj(r.proj))}</option>`).join('');
|
|
1937
2212
|
sel.value = prefs.proj && rows.some((r) => r.proj === prefs.proj) ? prefs.proj : ''; sel.style.display = rows.length > 1 ? '' : 'none';
|
|
1938
2213
|
}
|
|
1939
|
-
$('#liveProj').onchange = () => { Q.delete('proj'); prefs.proj = $('#liveProj').value; S.
|
|
2214
|
+
$('#liveProj').onchange = () => { Q.delete('proj'); prefs.proj = $('#liveProj').value; S.pick = null; savePrefs(); S.cur = null; followCurrent(); };
|
|
1940
2215
|
async function followCurrent() {
|
|
1941
|
-
const
|
|
2216
|
+
const at = S.pick, enc = encodeURIComponent, watch = Q.get('proj') || prefs.proj || ''; // at: the session you went to by hand (see goSession). The server says whether the call is still to be kept there: it is, until you type somewhere
|
|
2217
|
+
const cur = await (await fetch('/api/current?proj=' + enc(watch) + (at ? '&pproj=' + enc(at.proj || watch) + '&pid=' + enc(at.id) + (at.since != null ? '&since=' + at.since : '') + (at.pin ? '&pin=1' : '') : '') + (S.cur ? '&sproj=' + enc(S.cur.proj) + '&sid=' + enc(S.cur.id) : ''))).json();
|
|
2218
|
+
if (S.pick !== at) return false; // asked before a click or a tab sent the call elsewhere: the answer to act on is the one asked since. This one undid the click
|
|
2219
|
+
if (!cur.pick) { S.pick = null; S.wide = !!cur.wide; } else if (at.since == null) at.since = cur.asked || 0; /* not kept there any more: you typed somewhere since, or that session is gone · wide: the folder the call follows has no session, the server looked everywhere, and so do the tabs (inWatch). An answer about a session you went to says nothing of that folder · since: the latest order there was when you went there, which a later one is told from */
|
|
1942
2220
|
if (!cur.id) { $('#empty').classList.add('on'); return false; } $('#empty').classList.remove('on');
|
|
1943
|
-
if (S.pin && cur.id !== S.pin) S.pin = ''; // the pinned session is gone: follow the latest one instead of staying silently pinned
|
|
1944
2221
|
if (S.cur && S.cur.id === cur.id && S.cur.proj === cur.proj) return false;
|
|
2222
|
+
const key = cur.proj + '/' + cur.id, was = S.lastKey, moved = !!was && was !== key && !S.locked; if (moved) S.left[was] = Date.now(); // what was said of the session the call leaves is not said again when it comes back to it
|
|
1945
2223
|
if (!(await loadSession(cur.proj, cur.id))) return false;
|
|
2224
|
+
S.lastKey = key; if (moved) { const r = rowOf(cur); toast('↪ ' + (r ? tabName(r) : niceProj(cur.proj))); } paintTabs(); sessPoll();
|
|
1946
2225
|
const start = liveStart(); if (!S.locked && !S.userPaused) run(start); return true;
|
|
1947
2226
|
}
|
|
1948
2227
|
// Live: a call starts when you join it. Only what happened since then, and was not said yet, is said (the last 16 events at most, when a session is picked up on the way);
|
|
@@ -1953,13 +2232,13 @@ function midWork() { // someone is in the middle of something: the session doe
|
|
|
1953
2232
|
}
|
|
1954
2233
|
function liveStart() {
|
|
1955
2234
|
const n = S.events.length; if (!S.locked && !S.since) S.since = Date.now() - (midWork() ? JOIN_BACK_MS : 0); // S.since 0: joining now
|
|
1956
|
-
const since = S.locked ? Date.now() : S.since; let i = n; while (i > Math.max(0, n - 16) && S.events[i - 1].ts > since) i--;
|
|
2235
|
+
const since = S.locked ? Date.now() : Math.max(S.since, (S.cur && S.left[S.cur.proj + '/' + S.cur.id]) || 0); let i = n; while (i > Math.max(0, n - 16) && S.events[i - 1].ts > since) i--;
|
|
1957
2236
|
recomputeStatus(i); S.idx = S.pos = i; S.from = since; trNew(Math.max(0, n - 16)); paintStatus(); return i;
|
|
1958
2237
|
}
|
|
1959
2238
|
function amend(e, was) { // the server corrected an event the call already has: another tool call in the same message, a last line that turns out to be a report, the mark that closes the lead's turn
|
|
1960
2239
|
const i = S.events.indexOf(e), row = $(`#log .row[data-i="${i}"]`); if (row) row.outerHTML = logRow(i);
|
|
1961
2240
|
if (e.end) S.sawEnd = true; if (S.locked || S.recomputing || !S.live) return; const past = i < S.pos; // at the door everything is worked out again on Join
|
|
1962
|
-
if (e.kind === 'tools') { const done = e._n != null ? e._n : past ? was.n : null; if (done != null && e.tools.length > done) { const more = { ...e, tools: e.tools.slice(done) }; e._n = e.tools.length; applyStatus(more); tickTools(more); } }
|
|
2241
|
+
if (e.kind === 'tools') { const done = e._n != null ? e._n : past ? was.n : null; if (done != null && e.tools.length > done) { const more = { ...e, tools: e.tools.slice(done) }; e._n = e.tools.length; applyStatus(more); tickTools(more); noteFiles(more); } }
|
|
1963
2242
|
if (e.kind === 'report' && was.kind === 'say' && (e._as === 'say' || past)) { // it was read as an ordinary line: the report still counts (the agent is done, a ding, perhaps a word of thanks), without reading it again
|
|
1964
2243
|
applyStatus(e); AUD.ding(); fly(e.agent, e.to, '✅'); popTile(e.agent); if (e._as === 'say') { e._as = 'report'; S.late.push(e); }
|
|
1965
2244
|
}
|
|
@@ -1973,7 +2252,7 @@ setInterval(async () => {
|
|
|
1973
2252
|
if (switched || !S.cur) return;
|
|
1974
2253
|
const cur = S.cur, d = await (await fetch(`/api/session?proj=${encodeURIComponent(cur.proj)}&id=${cur.id}&after=${S.seq}&ep=${encodeURIComponent(S.ep)}`)).json();
|
|
1975
2254
|
if (d.error || cur !== S.cur) return; if (d.resync) { S.cur = null; return; } // the server no longer has our place (restarted, transcript rewritten): reload next tick
|
|
1976
|
-
S.seq = d.seq; if (!d.events || !d.events.length) return;
|
|
2255
|
+
S.seq = d.seq; if (d.marks) S.sawEnd = true; if (!d.events || !d.events.length) return;
|
|
1977
2256
|
for (const a of d.agents) if (!S.agents[a.id]) { S.agents[a.id] = persona(a); addTile(S.agents[a.id]); }
|
|
1978
2257
|
const from = S.events.length, fresh = [], changed = []; // the session is not written in order: what is new goes at the end (the order the call got it in), what the server corrected is corrected in place
|
|
1979
2258
|
for (const e of d.events) { const old = S.byK.get(e.k); if (old) { changed.push([old, { kind: old.kind, n: old.tools ? old.tools.length : 0, end: old.end }]); Object.assign(old, e); } else { S.byK.set(e.k, e); fresh.push(e); } }
|
|
@@ -1986,9 +2265,10 @@ setInterval(async () => {
|
|
|
1986
2265
|
}, 400);
|
|
1987
2266
|
|
|
1988
2267
|
|
|
1989
|
-
window.addEventListener('message', (e) => { //
|
|
2268
|
+
window.addEventListener('message', (e) => { // VS Code asks for a given session: the one the status bar was clicked for, or the one of the Claude Code tab you went to (the message is named 'pin' on both sides, from when the call was pinned there)
|
|
1990
2269
|
const d = e.data; if (!EMBED || e.source !== window.parent || !d || d.agentStandup !== 'pin' || typeof d.id !== 'string') return;
|
|
1991
|
-
prefs.
|
|
2270
|
+
if (d.tab) { if (prefs.followTab !== false && S.live && !S.demo && typeof d.proj === 'string' && !(S.pick && S.pick.pin)) goSession(d.proj, d.id); return; } // the Claude Code tab you went to: the call goes with you (followTab in extension.js; off in ⚙), unless you pinned a call (📌): that one stays while you go through your tabs
|
|
2271
|
+
const dp = typeof d.proj === 'string' ? d.proj : ''; if (!TOOL[dp]) prefs.proj = dp; S.pick = { proj: dp, id: d.id }; S.cur = null; setView('call'); if (S.live) { fillProjects(); followCurrent(); } else setMode('live');
|
|
1992
2272
|
});
|
|
1993
2273
|
// ---------- meeting chrome: participants and a clock ----------
|
|
1994
2274
|
function renderMeet() {
|
|
@@ -2011,25 +2291,42 @@ $('#reactBar').onclick = (e) => {
|
|
|
2011
2291
|
const BSTATE = { blocked: ['✋', 'needs you?', 'attend vous ?'], working: ['⚙', 'working', 'au travail'], waiting: ['🔗', 'waiting on sub-agents', 'attend ses sous-agents'], turn: ['✓', 'your turn', 'à vous'], idle: ['💤', 'idle', 'inactif'] };
|
|
2012
2292
|
const BORDER = ['blocked', 'working', 'waiting', 'turn', 'idle'];
|
|
2013
2293
|
const agoStr = (ms) => (ms < 90e3 ? Math.max(1, Math.round(ms / 1000)) + 's' : ms < 5400e3 ? Math.round(ms / 60e3) + ' min' : Math.round(ms / 3600e3) + ' h');
|
|
2014
|
-
|
|
2294
|
+
const BGROUP = ['blocked', 'turn', 'working', 'waiting', 'idle']; // the board is in sections, what waits for you first
|
|
2295
|
+
let boardBusy = false, boardAll = null, boardDoneOpen = false;
|
|
2296
|
+
const isDone = (r) => !!r.done; // put away by you, until the session moves again: the server says so, to every window
|
|
2297
|
+
function bcard(r, now, done) {
|
|
2298
|
+
const [ic, en, fr] = BSTATE[r.state], extra = r.state === 'blocked' ? ` · ${r.ask ? '' : esc(r.tool) + ' '}${agoStr(r.ageMs)}` : r.state === 'working' && r.tool ? ` · ${esc(r.tool)}` : r.state === 'idle' || r.state === 'turn' ? ` · ${agoStr(now - r.mtime)}` : '';
|
|
2299
|
+
const pr = r.pr ? `<button class="bpr" data-url="${esc(r.pr.url)}" title="${esc(L('Ouvrir la pull request', 'Open the pull request'))}">PR #${+r.pr.n} ↗</button>` : '';
|
|
2300
|
+
const put = done ? `<button class="bdo" data-undo="1" title="${esc(L('Rouvrir', 'Reopen'))}" aria-label="${esc(L('Rouvrir', 'Reopen'))}">↩</button>` : r.state === 'turn' || r.state === 'idle' ? `<button class="bdo" title="${esc(L('Marquer comme traitée', 'Mark as done'))}" aria-label="${esc(L('Marquer comme traitée', 'Mark as done'))}">✓</button>` : '';
|
|
2301
|
+
return `<div class="bcard ${r.state}" tabindex="0" role="button" data-p="${esc(r.proj)}" data-i="${esc(r.id)}"><div class="bh"><span class="stc ${r.state}">${ic} ${L(fr, en)}${extra}</span>${pr}${put}</div><div class="bt">${esc(/^[0-9a-f]{8}-[0-9a-f-]{27}$/.test(r.title) ? L('Session sans titre', 'Untitled session') : r.title)}</div>${r.ask ? `<div class="bq">${esc(r.ask)}</div>` : ''}<div class="bp">${esc(niceProj(r.proj))}</div>${r.subTotal ? `<div class="bm">👥 ${r.subActive}/${r.subTotal} ${L('sous-agents actifs', 'sub-agents active')}</div>` : ''}</div>`;
|
|
2302
|
+
}
|
|
2303
|
+
function paintBoard() {
|
|
2304
|
+
if (!boardAll || !document.body.classList.contains('board')) return; const now = Date.now(), recent = (a, b) => b.mtime - a.mtime;
|
|
2305
|
+
const live = boardAll.filter((r) => !isDone(r)), done = boardAll.filter(isDone).sort(recent), head = (k, label, n) => `${BSTATE[k] ? BSTATE[k][0] : '✓'} <span class="bl">${label}</span><i>${n}</i>`;
|
|
2306
|
+
const secs = BGROUP.map((k) => [k, live.filter((r) => r.state === k).sort(recent)]).filter(([, rs]) => rs.length).map(([k, rs]) => `<section class="bsec"><h3 class="bhd ${k}">${head(k, L(BSTATE[k][2], BSTATE[k][1]), rs.length)}</h3><div class="bgrid">${rs.map((r) => bcard(r, now, false)).join('')}</div></section>`).join('');
|
|
2307
|
+
const put = done.length ? `<details class="bsec bdone"${boardDoneOpen ? ' open' : ''}><summary class="bhd">${head('', L('Traitées', 'Done'), done.length)}</summary><div class="bgrid">${done.map((r) => bcard(r, now, true)).join('')}</div></details>` : '';
|
|
2308
|
+
$('#boardv').innerHTML = secs + put || `<div class="bsum"><span>${L('Aucune session récente', 'No recent session')}</span></div>`;
|
|
2309
|
+
}
|
|
2015
2310
|
async function renderBoardView() {
|
|
2016
2311
|
if (!document.body.classList.contains('board') || boardBusy) return; boardBusy = true;
|
|
2017
2312
|
try {
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
const cnt = {}; rows.forEach((r) => (cnt[r.state] = (cnt[r.state] || 0) + 1));
|
|
2021
|
-
const sum = BORDER.filter((k) => cnt[k]).map((k) => `<span class="stc ${k}">${BSTATE[k][0]} ${cnt[k]} ${L(BSTATE[k][2], BSTATE[k][1])}</span>`).join('');
|
|
2022
|
-
$('#boardv').innerHTML = `<div class="bsum">${sum || `<span>${L('Aucune session récente', 'No recent session')}</span>`}</div><div class="bgrid">${rows.map((r) => {
|
|
2023
|
-
const [ic, en, fr] = BSTATE[r.state], extra = r.state === 'blocked' ? ` · ${esc(r.tool)} ${agoStr(r.ageMs)}` : r.state === 'working' && r.tool ? ` · ${esc(r.tool)}` : r.state === 'idle' || r.state === 'turn' ? ` · ${agoStr(now - r.mtime)}` : '';
|
|
2024
|
-
return `<div class="bcard ${r.state}" tabindex="0" role="button" data-p="${esc(r.proj)}" data-i="${esc(r.id)}"><div><span class="stc ${r.state}">${ic} ${L(fr, en)}${extra}</span></div><div class="bt">${esc(/^[0-9a-f]{8}-[0-9a-f-]{27}$/.test(r.title) ? L('Session sans titre', 'Untitled session') : r.title)}</div><div class="bp">${esc(niceProj(r.proj))}</div>${r.subTotal ? `<div class="bm">👥 ${r.subActive}/${r.subTotal} ${L('sous-agents actifs', 'sub-agents active')}</div>` : ''}</div>`; }).join('')}</div>`;
|
|
2313
|
+
boardAll = await (await fetch('/api/board')).json();
|
|
2314
|
+
paintBoard();
|
|
2025
2315
|
} catch {} finally { boardBusy = false; }
|
|
2026
2316
|
}
|
|
2317
|
+
$('#boardv').addEventListener('toggle', (e) => { if (e.target.classList && e.target.classList.contains('bdone')) boardDoneOpen = e.target.open; }, true);
|
|
2027
2318
|
$('#boardv').onkeydown = (e) => { if ((e.key === 'Enter' || e.key === ' ') && e.target.classList.contains('bcard')) { e.preventDefault(); e.target.click(); } };
|
|
2028
2319
|
async function openSession(proj, id) {
|
|
2029
|
-
prefs.proj = proj; S.
|
|
2320
|
+
if (!TOOL[proj]) prefs.proj = proj; S.pick = { proj, id }; savePrefs(); setView('call'); // a Vibe or Codex session is listed under its tool, which is not a folder to follow: kept as the project, it left a window with no folder showing that tool's sessions only, for good
|
|
2030
2321
|
if (S.live || S.demo) { if (S.demo) await setMode('live'); S.cur = null; fillProjects(); await followCurrent(); } else await setMode('live');
|
|
2031
2322
|
}
|
|
2032
|
-
$('#boardv').onclick = (e) => {
|
|
2323
|
+
$('#boardv').onclick = (e) => {
|
|
2324
|
+
const pr = e.target.closest('.bpr'), put = e.target.closest('.bdo'), c = e.target.closest('.bcard'); if (pr) return openExternal(pr.dataset.url); if (!c) return;
|
|
2325
|
+
if (put) { const proj = c.dataset.p, id = c.dataset.i, on = !put.dataset.undo; // shown at once here, and told to the server, which the other windows ask
|
|
2326
|
+
for (const list of [boardAll || [], S.rows]) { const r = list.find((x) => x.proj === proj && x.id === id); if (r) { if (on) r.done = 1; else delete r.done; } }
|
|
2327
|
+
paintBoard(); paintTabs(); fetch('/api/done', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ proj, id, on }) }).catch(() => {}); return; }
|
|
2328
|
+
openSession(c.dataset.p, c.dataset.i);
|
|
2329
|
+
};
|
|
2033
2330
|
// Cmd/Ctrl+K: jump to any session from any view
|
|
2034
2331
|
async function openSwitcher() {
|
|
2035
2332
|
let sw = $('#switcher'); if (sw) { closeSwitcher(); return; }
|
|
@@ -2049,6 +2346,74 @@ async function openSwitcher() {
|
|
|
2049
2346
|
}
|
|
2050
2347
|
function closeSwitcher() { const sw = $('#switcher'); if (sw) sw.remove(); }
|
|
2051
2348
|
setInterval(() => { if (!document.hidden) renderBoardView(); }, 2500);
|
|
2349
|
+
// ---------- several sessions at once (live): the sessions of the moment as tabs under the header, and a visitor when another one needs you ----------
|
|
2350
|
+
// The row is there only when there is something to tell apart: a second session at work or waiting for you. With a single session the header is as it always was.
|
|
2351
|
+
// The tabs keep the order in which the sessions showed up, so the one the call is in stays where it was. The call is in the session you last touched: the one you typed in or started,
|
|
2352
|
+
// or the one you went to since (a click on its tab, the visitor, the list; in VS Code, the Claude Code tab you are on: ⚙, and followTab in extension.js). Nothing is pinned and nothing is to be let go:
|
|
2353
|
+
// the next thing you type, wherever it is, takes the call there. The rule itself is in server.js (currentSession).
|
|
2354
|
+
S.rows = []; S.tabOrder = []; S.knockAt = {}; S.left = {}; S.visit = S.knock = null; S.pick = S.pick || null;
|
|
2355
|
+
const UNTITLED = /^[0-9a-f]{8}-[0-9a-f-]{27}$/, sessKey = (r) => r.proj + '/' + r.id, tabName = (r) => (r.title && !UNTITLED.test(r.title) ? r.title : r.title ? L('Session sans titre', 'Untitled session') : niceProj(r.proj) || L('Session sans titre', 'Untitled session'));
|
|
2356
|
+
const inWatch = (r) => { const k = Q.get('proj') || prefs.proj || ''; return !k || S.wide || [r.proj, r.dir || ''].some((d) => d === k || d.startsWith(k + '-')); }; // the folder the live view follows, when it follows one and that folder has sessions (S.wide: it has none, see followCurrent)
|
|
2357
|
+
const rowOf = (c) => (c && S.rows.find((r) => r.proj === c.proj && r.id === c.id)) || null;
|
|
2358
|
+
function paintTabs() {
|
|
2359
|
+
const el = $('#tabs'), cur = S.cur; if (!S.live || S.demo) { if (paintTabs.html) el.innerHTML = paintTabs.html = ''; if (S.visit) hideVisit(); return; } if (!cur) return; // between two sessions the tabs stay as they are: the row does not come and go
|
|
2360
|
+
const ck = sessKey(cur), by = new Map(S.rows.filter((r) => sessKey(r) === ck || (r.state !== 'idle' && !r.done && inWatch(r))).map((r) => [sessKey(r), r])); if (!by.has(ck)) by.set(ck, { proj: cur.proj, id: cur.id, title: '', state: '' }); // the call's own session always has its tab, also before the list knows it
|
|
2361
|
+
for (const k of by.keys()) if (!S.tabOrder.includes(k)) S.tabOrder.push(k); // a session keeps its place while it has no tab: the call now goes by itself to a session that is started, sometimes before the list has the one it leaves, which then came back second
|
|
2362
|
+
const ks = S.tabOrder.filter((k) => by.has(k)).slice(0, 8); if (!ks.includes(ck)) ks[ks.length - 1] = ck; // the others are in ⋯
|
|
2363
|
+
const html = by.size < 2 ? '' : ks.map((k) => { const r = by.get(k), on = k === ck, st = BSTATE[r.state]; // one session: no row, there is nothing to tell apart
|
|
2364
|
+
const pinned = on && !!S.pick && !!S.pick.pin && sessKey(S.pick) === k, tip = tabName(r) + '\n' + niceProj(r.proj) + (st ? ' · ' + L(st[2], st[1]) : '') + (pinned ? '\n' + L('Épinglé : cliquez pour désépingler', 'Pinned: click to unpin') : '');
|
|
2365
|
+
return `<button class="stab ${r.state}${on ? ' on' : ''}" role="tab" aria-selected="${on}" data-k="${esc(k)}" title="${esc(tip)}">${st ? st[0] : ''}${TOOL[r.proj] ? `<i>${TOOL[r.proj]}</i>` : ''}<span>${esc(tabName(r))}</span>${pinned ? '📌' : ''}</button>`; }).join('')
|
|
2366
|
+
+ `<button class="stab all" title="${esc(L('Aller à une session', 'Go to a session'))} (Cmd / Ctrl + K)" aria-label="${esc(L('Aller à une session', 'Go to a session'))}">⋯</button>`;
|
|
2367
|
+
if (html === paintTabs.html) return; if (!html) paintTabs.cur = ''; el.innerHTML = paintTabs.html = html;
|
|
2368
|
+
if (paintTabs.cur !== ck) { paintTabs.cur = ck; const on = el.querySelector('.on'); if (on) on.scrollIntoView({ block: 'nearest', inline: 'nearest' }); }
|
|
2369
|
+
}
|
|
2370
|
+
function goSession(proj, id, pin) { // you go to this session: the call is kept there until you type somewhere (since: filled by the first answer, see followCurrent)
|
|
2371
|
+
// pin: by a click on its tab. The call is pinned there (📌): it stays while you go through the Claude Code tabs of the editor and while you type in it, until you ask something in another session. A click on that tab again unpins it
|
|
2372
|
+
const held = !!pin && !!S.pick && !!S.pick.pin && S.pick.proj === proj && S.pick.id === id; S.pick = pin && !held ? { proj, id, pin: true } : { proj, id };
|
|
2373
|
+
if (S.cur && S.cur.proj === proj && S.cur.id === id) { paintTabs(); return; } // already there: the call no longer leaves it for a session still at work
|
|
2374
|
+
hideVisit(); S.cur = null; followCurrent();
|
|
2375
|
+
}
|
|
2376
|
+
$('#tabs').onclick = (e) => {
|
|
2377
|
+
const b = e.target.closest('.stab'); if (!b) return; if (b.classList.contains('all')) { openSwitcher(); return; }
|
|
2378
|
+
const [p, i] = b.dataset.k.split('/'); goSession(p, i, true);
|
|
2379
|
+
};
|
|
2380
|
+
// The visitor: another session has just stopped for you (a question, an edit that waits for your go-ahead, or its turn is over). Someone from there leans in at the edge of the call and says so,
|
|
2381
|
+
// between two lines and never over one; a click takes the call there. One at a time, a session that needs you before one that is merely done. Off in ⚙; its line exists in English and French, as the other little lines.
|
|
2382
|
+
const VISIT = {
|
|
2383
|
+
en: { ask: [(t) => `Knock knock. They have a question for you in “${t}”.`, (t) => `Sorry to cut in: “${t}” has a question for you.`], ok: [(t) => `Knock knock. “${t}” is waiting for your go-ahead.`, (t) => `Excuse me, you are wanted in “${t}”: it waits for your approval.`], turn: [(t) => `Just passing by: “${t}” is done, it is your turn over there.`, (t) => `News from “${t}”: they are finished and wait for you.`] },
|
|
2384
|
+
fr: { ask: [(t) => `Toc toc. On a une question pour vous dans « ${t} ».`, (t) => `Pardon de vous couper : « ${t} » a une question pour vous.`], ok: [(t) => `Toc toc. « ${t} » attend votre feu vert.`, (t) => `Excusez-moi, on vous demande dans « ${t} » : on y attend votre accord.`], turn: [(t) => `Je ne fais que passer : « ${t} » a fini, c’est à vous là-bas.`, (t) => `Des nouvelles de « ${t} » : ils ont fini et vous attendent.`] },
|
|
2385
|
+
es: { ask: [(t) => `Toc, toc. Tienen una pregunta para ti en “${t}”.`, (t) => `Perdona que interrumpa: “${t}” tiene una pregunta para ti.`], ok: [(t) => `Toc, toc. “${t}” espera tu visto bueno.`, (t) => `Disculpa, te buscan en “${t}”: esperan tu aprobación.`], turn: [(t) => `Solo pasaba por aquí: “${t}” ha terminado, te toca allí.`, (t) => `Noticias de “${t}”: han terminado y te esperan.`] },
|
|
2386
|
+
pt: { ask: [(t) => `Toc, toc. Tem uma pergunta para você em “${t}”.`, (t) => `Desculpe interromper: “${t}” tem uma pergunta para você.`], ok: [(t) => `Toc, toc. “${t}” está esperando o seu sinal verde.`, (t) => `Com licença, estão chamando você em “${t}”: esperam a sua aprovação.`], turn: [(t) => `Só de passagem: “${t}” terminou, é a sua vez lá.`, (t) => `Notícias de “${t}”: terminaram e esperam por você.`] },
|
|
2387
|
+
};
|
|
2388
|
+
function knocks() {
|
|
2389
|
+
const now = Date.now(), first = !knocks.seen, seen = knocks.seen || (knocks.seen = {}), ck = S.cur ? sessKey(S.cur) : ''; let best = null;
|
|
2390
|
+
for (const r of S.rows) {
|
|
2391
|
+
const k = sessKey(r), was = seen[k], st = r.state === 'turn' && now - r.mtime < 6000 ? 'working' : r.state; // a session that does not mark the end of its turns: a line less than 6 s old may only be a pause before the next call
|
|
2392
|
+
const kind = first || !was || was === st || k === ck || !inWatch(r) ? '' : st === 'blocked' ? (/^AskUserQuestion/.test(r.tool) ? 'ask' : 'ok') : st === 'turn' && !r.cut && /^(working|waiting|blocked)$/.test(was) ? 'turn' : ''; // cut: you stopped that session yourself (Esc), which is no news
|
|
2393
|
+
if (kind && now - (S.knockAt[k] || 0) < 20000) continue; // a stop less than 20 s after the last visit for that session is not noted yet: it is told when the 20 s are over, if it still holds
|
|
2394
|
+
seen[k] = st; if (kind && (!best || (kind !== 'turn' && best.kind === 'turn'))) best = { r, kind, k };
|
|
2395
|
+
}
|
|
2396
|
+
const v = S.visit, vr = v && S.rows.find((r) => sessKey(r) === v.k); if (v && (!vr || v.k === ck || (v.kind === 'turn' ? !/^(turn|idle)$/.test(vr.state) : vr.state !== 'blocked'))) hideVisit(); // answered there, or the call went there: the visitor leaves
|
|
2397
|
+
if (best && prefs.visits !== false && !S.locked && !(S.visit && S.visit.kind !== 'turn' && best.kind === 'turn')) { S.knockAt[best.k] = now; showVisit(best); }
|
|
2398
|
+
}
|
|
2399
|
+
function showVisit(v) { // the same face and name each time for a given session; with your own characters, one of them
|
|
2400
|
+
const h = hash('visit' + v.k), p = persona0({ id: 'visit:' + v.k, name: NAMES[h % NAMES.length], role: '' }), W = VISIT[CALL()][v.kind], t = tabName(v.r), el = $('#visit');
|
|
2401
|
+
p.custom = CHARS.pool.length ? CHARS.pool[h % CHARS.pool.length] : null; v.p = p; v.line = W[(h + (showVisit.n = (showVisit.n || 0) + 1)) % W.length](t.length > 46 ? t.slice(0, 44).replace(/\s+\S*$/, '') + '…' : t);
|
|
2402
|
+
el.className = 'on ' + (v.kind === 'turn' ? 'turn' : 'blocked');
|
|
2403
|
+
el.innerHTML = `<div class="vsay"><button class="vx" aria-label="${esc(L('Fermer', 'Close'))}">✕</button><small>${esc(p.name)} · ${esc(niceProj(v.r.proj))}</small>${esc(v.line)}<br><button class="vgo">${esc(L('Y aller', 'Go there'))} →</button></div><div class="vwho">${avatarSVG(p, undefined, 'v' + p.gid + '_')}</div>`;
|
|
2404
|
+
S.visit = S.knock = v; AUD.knock(); clearTimeout(showVisit.t); showVisit.t = setTimeout(() => { if (S.visit === v) hideVisit(); }, v.kind === 'turn' ? 16000 : 45000); // the tab of that session keeps its state after the visitor has left
|
|
2405
|
+
}
|
|
2406
|
+
function hideVisit() { clearTimeout(showVisit.t); S.visit = S.knock = null; const el = $('#visit'); if (el.className) { el.className = ''; el.innerHTML = ''; } }
|
|
2407
|
+
async function visitSay(v, token) {
|
|
2408
|
+
if (S.visit !== v || AUD.off() || !prefs.voice) return; const el = $('#visit'); el.classList.add('speaking'); AUD.duck(true);
|
|
2409
|
+
await speakLine(v.line, v.p, true, token); el.classList.remove('speaking'); if (!S.speakers.size) AUD.duck(false);
|
|
2410
|
+
}
|
|
2411
|
+
$('#visit').onclick = (e) => { const v = S.visit; if (!v) return; if (e.target.closest('.vx')) hideVisit(); else goSession(v.r.proj, v.r.id); };
|
|
2412
|
+
async function sessPoll() {
|
|
2413
|
+
if (!S.live || S.demo || document.hidden || sessPoll.busy) return; sessPoll.busy = true;
|
|
2414
|
+
try { const rows = await (await fetch('/api/board')).json(); if (Array.isArray(rows) && S.live && !S.demo) { S.rows = rows; knocks(); paintTabs(); } } catch {} finally { sessPoll.busy = false; }
|
|
2415
|
+
}
|
|
2416
|
+
setInterval(sessPoll, 3000);
|
|
2052
2417
|
async function setMode(m) {
|
|
2053
2418
|
if (m === 'demo') { // a built-in fictional session: nothing to install, nothing private on screen
|
|
2054
2419
|
pause(); S.live = false; S.demo = true; S.userPaused = false; S.cur = null; $('#empty').classList.remove('on');
|
|
@@ -2107,11 +2472,11 @@ function drawFrame(cv, mark = 0) { // mark: 1 = a clip to share (site address
|
|
|
2107
2472
|
const x = 20, y = 50, w = W - 40, ed = m.view === 'editor', col = { cmd: '#e6edf3', out: '#aab2c5', err: '#ff7b72', tool: '#8b95b0', dim: '#6b7089', run: '#ffd24a', add: '#9be9a8', del: '#ffa198', ctx: '#d6dae6' };
|
|
2108
2473
|
c.fillStyle = ed ? '#1a1b26' : '#0d1117'; c.beginPath(); c.roundRect(x, y, w, bh, 12); c.fill(); c.fillStyle = '#1c1f2b'; c.fillRect(x, y, w, 28);
|
|
2109
2474
|
['#ff5f57', '#febc2e', '#28c840'].forEach((cl, i) => { c.fillStyle = cl; c.beginPath(); c.arc(x + 16 + i * 18, y + 14, 5, 0, 7); c.fill(); });
|
|
2110
|
-
c.font = '13px sans-serif'; c.fillStyle = '#9aa0b4'; c.fillText(ed ? (hide ? m.title.split(' — ').pop() : m.title) : m.view === 'image' ? (hide ? '' : m.title) : S.agents[S.present].name + ' — zsh', x + 90, y + 19); c.font = '14px monospace';
|
|
2111
|
-
if (m.view === 'image') { // masked like the code: a picture from the session is replaced by an empty frame
|
|
2112
|
-
const im = hide ? null : mediaImg(m.imgs[0]), ax = x + 14, ay = y + 38, aw = w - 238, ah = bh - 82, k = im && im.complete && im.naturalWidth ? Math.min(aw / im.naturalWidth, ah / im.naturalHeight, 1.5) : 0;
|
|
2475
|
+
c.font = '13px sans-serif'; c.fillStyle = '#9aa0b4'; c.fillText(ed ? (hide ? m.title.split(' — ').pop() : m.title) : m.view === 'image' || m.view === 'web' ? (hide ? '' : m.title) : S.agents[S.present].name + ' — zsh', x + 90, y + 19); c.font = '14px monospace';
|
|
2476
|
+
if (m.view === 'image' || m.view === 'web') { // masked like the code: a picture from the session is replaced by an empty frame. The page of an artifact always is: a video cannot draw what is in a frame
|
|
2477
|
+
const im = hide || m.view === 'web' ? null : mediaImg(m.imgs[0]), ax = x + 14, ay = y + 38, aw = w - 238, ah = bh - 82, k = im && im.complete && im.naturalWidth ? Math.min(aw / im.naturalWidth, ah / im.naturalHeight, 1.5) : 0;
|
|
2113
2478
|
if (k) c.drawImage(im, ax + (aw - im.naturalWidth * k) / 2, ay + (ah - im.naturalHeight * k) / 2, im.naturalWidth * k, im.naturalHeight * k);
|
|
2114
|
-
else { c.fillStyle = 'rgba(255,255,255,.07)'; c.beginPath(); c.roundRect(ax + aw / 2 - 170, ay + 10, 340, ah - 20, 10); c.fill(); c.font = '64px sans-serif'; c.textAlign = 'center'; c.fillStyle = '#6b7089'; c.fillText('🖼', ax + aw / 2, ay + ah / 2 + 22); c.textAlign = 'start'; }
|
|
2479
|
+
else { c.fillStyle = 'rgba(255,255,255,.07)'; c.beginPath(); c.roundRect(ax + aw / 2 - 170, ay + 10, 340, ah - 20, 10); c.fill(); c.font = '64px sans-serif'; c.textAlign = 'center'; c.fillStyle = '#6b7089'; c.fillText(m.view === 'web' ? '🌐' : '🖼', ax + aw / 2, ay + ah / 2 + 22); c.textAlign = 'start'; }
|
|
2115
2480
|
c.font = '14px monospace';
|
|
2116
2481
|
}
|
|
2117
2482
|
const rows = ed ? m.lines.slice(0, 13) : m.lines.slice(-13), cw = c.measureText('M').width;
|
|
@@ -2162,6 +2527,7 @@ function applyLang() {
|
|
|
2162
2527
|
document.documentElement.lang = (LANGS.find((l) => l[0] === prefs.lang) || LANGS[0])[2];
|
|
2163
2528
|
document.querySelectorAll('[data-fr]').forEach((el) => (el.textContent = FR() ? el.dataset.fr : tr(el.dataset.en)));
|
|
2164
2529
|
document.querySelectorAll('#viewSeg button').forEach((b) => { b.title = b.textContent; }); // in a narrow window they are icons: the name stays as a tooltip
|
|
2530
|
+
$('#callTrMi').style.display = CALL_LANG[prefs.lang] && !FR() ? '' : 'none';
|
|
2165
2531
|
const sel = $('#langSel'); if (!sel.options.length) sel.innerHTML = LANGS.map(([c, n]) => `<option value="${c}">${n}</option>`).join(''); sel.value = prefs.lang;
|
|
2166
2532
|
[['#bPlay', L('Pause / Lecture (espace)', 'Pause / Play (space)')], ['#bLog', 'Transcript'], ['#bMute', L('Son (touche M)', 'Sound (M key)')], ['#bMenu', L('Réglages', 'Settings')], ['#dclose', L('Fermer', 'Close')], ['#officeVol', L('Volume de l’ambiance', 'Ambience volume')], ['#musicVol', L('Volume de la musique', 'Music volume')], ['#liveProj', L('Projet à suivre', 'Project to follow')], ['#reactBar', L('Réactions', 'Reactions')], ['#logQ', L('Rechercher dans la transcription', 'Search the transcript')], ['#roster', L('Agents', 'Agents')]].forEach(([q, t]) => { const el = $(q); if (!el) return; el.title = t; el.setAttribute('aria-label', t); }); $('#logQ').placeholder = L('Rechercher…', 'Search…'); $('#menuQ').placeholder = L('Chercher un réglage…', 'Search settings…'); document.querySelectorAll('#reactBar button').forEach((b) => b.setAttribute('aria-label', b.dataset.e));
|
|
2167
2533
|
$('#gT').textContent = L('Rejoindre l’appel', 'Join the call'); $('#gP').textContent = L('Cliquez pour activer le son et suivre votre session Claude Code en direct.', 'Click to enable sound and follow your Claude Code session live.'); $('#gB').textContent = L('▶ Rejoindre', '▶ Join');
|
|
@@ -2207,29 +2573,56 @@ function menuInit() {
|
|
|
2207
2573
|
$('#menuNone').style.display = q && !secs.some((sc) => sc.items.some((e) => !e.classList.contains('mhide'))) ? '' : 'none';
|
|
2208
2574
|
};
|
|
2209
2575
|
}
|
|
2210
|
-
$('#menu').onclick = (e) => { const b = e.target.closest('.mi[data-t]'); if (!b) return; prefs[b.dataset.t] = !prefs[b.dataset.t]; savePrefs(); if (prefs[b.dataset.t] && ['voice', 'office', 'music', 'notify'].includes(b.dataset.t)) claimAudio(); b.querySelector('.sw').classList.toggle('on', prefs[b.dataset.t]); AUD.apply(); if (b.dataset.t === 'office') $('#officeBox').style.display = prefs.office ? '' : 'none'; if (b.dataset.t === 'customLaptop') { for (const k in imgCache) delete imgCache[k]; buildStage(); paintStatus(); } if (b.dataset.t === 'ownNames') renameAll(); if (b.dataset.t === 'reactions') document.body.classList.toggle('react', prefs.reactions); if (b.dataset.t === 'roster') { document.body.classList.toggle('rost', prefs.roster); paintStates(); } if (b.dataset.t === 'notify') { prefs.notifyChosen = true; savePrefs(); } if (b.dataset.t === 'notify' && prefs.notify) askNotify(); if (b.dataset.t === 'vanish' && !prefs.vanish) { S.gone.clear(); paintStatus(); }
|
|
2576
|
+
$('#menu').onclick = (e) => { const b = e.target.closest('.mi[data-t]'); if (!b) return; prefs[b.dataset.t] = !prefs[b.dataset.t]; savePrefs(); if (prefs[b.dataset.t] && ['voice', 'office', 'music', 'notify'].includes(b.dataset.t)) claimAudio(); b.querySelector('.sw').classList.toggle('on', prefs[b.dataset.t]); AUD.apply(); if (b.dataset.t === 'office') $('#officeBox').style.display = prefs.office ? '' : 'none'; if (b.dataset.t === 'callTr') { prefs.callTrSeen = true; savePrefs(); setLang(prefs.lang); } if (b.dataset.t === 'voice') voiceOffer(); if (b.dataset.t === 'customLaptop') { for (const k in imgCache) delete imgCache[k]; buildStage(); paintStatus(); } if (b.dataset.t === 'files') paintFiles(); if (b.dataset.t === 'artNet' && S.present) renderPresent(); if (b.dataset.t === 'ownNames') renameAll(); if (b.dataset.t === 'reactions') document.body.classList.toggle('react', prefs.reactions); if (b.dataset.t === 'roster') { document.body.classList.toggle('rost', prefs.roster); paintStates(); } if (b.dataset.t === 'notify') { prefs.notifyChosen = true; savePrefs(); } if (b.dataset.t === 'notify' && prefs.notify) askNotify(); if (b.dataset.t === 'vanish' && !prefs.vanish) { S.gone.clear(); paintStatus(); }
|
|
2211
2577
|
if (b.dataset.t === 'music') { $('#musicBox').style.display = prefs.music ? '' : 'none'; if (prefs.music) { AUD.init(); AUD.apply(); } } };
|
|
2212
2578
|
$('#station').innerHTML = STATIONS.map((s) => `<option value="${s.id}">📻 ${s.name}</option>`).join('');
|
|
2213
2579
|
$('#station').value = prefs.station; $('#musicVol').value = prefs.musicVol; $('#musicBox').style.display = prefs.music ? '' : 'none';
|
|
2214
2580
|
$('#station').onchange = (e) => { prefs.station = e.target.value; savePrefs(); AUD.init(); RADIO.sync(); };
|
|
2215
2581
|
$('#chatSel').value = ['quiet', 'normal', 'lively'].includes(prefs.chat) ? prefs.chat : 'normal'; $('#chatSel').onchange = () => { prefs.chat = $('#chatSel').value; savePrefs(); };
|
|
2216
|
-
$('#vstyle').innerHTML = [['animal', 'Animal Crossing (babillage)', 'Animal Crossing (babble)'], ['
|
|
2582
|
+
$('#vstyle').innerHTML = [['animal', 'Animal Crossing (babillage)', 'Animal Crossing (babble)'], ['kokoro', 'Voix naturelles (à installer)', 'Natural voices (installs on demand)']].map(([v, fr, en]) => `<option value="${v}" data-fr="${fr}" data-en="${en}">${L(fr, en)}</option>`).join(''); $('#vstyle').value = prefs.vstyle; $('#vstyle').onchange = () => { prefs.vstyle = $('#vstyle').value; prefs.vstyleChosen = true; savePrefs(); TTS.init().then(kokoroUI); kokoroUI(); };
|
|
2217
2583
|
// ---- ⚙ → very natural voices (Kokoro): install box and status, polled while installing
|
|
2218
2584
|
let kokoroTimer = null;
|
|
2219
2585
|
async function kokoroUI() {
|
|
2220
|
-
const box = $('#kokoroBox'), on = prefs.vstyle === 'kokoro'; box.style.display = on ? '' : 'none'; if (!on) { clearInterval(kokoroTimer); kokoroTimer = null; return; }
|
|
2586
|
+
const box = $('#kokoroBox'), on = prefs.vstyle === 'kokoro'; box.style.display = on ? '' : 'none'; $('#vstyleTip').style.display = on ? 'none' : ''; if (!on) { clearInterval(kokoroTimer); kokoroTimer = null; return; }
|
|
2221
2587
|
let st; try { st = await (await fetch('/api/kokoro')).json(); } catch { return; }
|
|
2222
|
-
const b = $('#kokoroInstall'), h = $('#kokoroHint'); b.style.display = st.installed ? 'none' : '';
|
|
2223
|
-
b.disabled = st.installing || !st.npm; b.textContent = st.installing ? L('Installation…', 'Installing…') : L(`Installer (${st.sizeMb} Mo)`, `Install (${st.sizeMb} MB)`);
|
|
2224
|
-
h.textContent = st.installing ? L('Téléchargement en cours, vous pouvez continuer : les
|
|
2588
|
+
const b = $('#kokoroInstall'), h = $('#kokoroHint'), addFr = st.installed && !st.g2p && !!CALL_LANG[prefs.lang]; b.style.display = st.installed && !addFr ? 'none' : ''; /* addFr: installed before French, Spanish and Portuguese were added, which is one small package more. Offered where one of them is the interface language: a session in that language is then read by these voices, translated or not */
|
|
2589
|
+
b.disabled = st.installing || !st.npm; b.textContent = st.installing ? L('Installation…', 'Installing…') : addFr ? L('Ajouter les voix françaises', 'Add the voices of this language') + L(` (${st.g2pMb} Mo)`, ` (${st.g2pMb} MB)`) : L(`Installer (${st.sizeMb} Mo)`, `Install (${st.sizeMb} MB)`);
|
|
2590
|
+
h.textContent = st.installing ? L('Téléchargement en cours, vous pouvez continuer : les agents babillent en attendant.', 'Downloading, you can carry on: the agents babble meanwhile.')
|
|
2225
2591
|
: st.error ? st.error : !st.npm && !st.installed ? L('npm est introuvable : installez Node.js pour activer cette option.', 'npm not found: install Node.js to enable this option.')
|
|
2226
|
-
: st.installed ? (st.gaveUp ? L('Le moteur s’est arrêté : les
|
|
2227
|
-
: L('Voix locales de bonne qualité, en
|
|
2592
|
+
: st.installed ? (st.gaveUp ? L('Le moteur s’est arrêté : les agents babillent à la place.', 'The engine stopped: the agents babble instead.') : st.ready ? (addFr ? L('Voix prêtes en anglais. Le français est encore lu par les voix du système.', 'Voices ready in English. This language is still read by the system voices.') : L('Voix prêtes.', 'Voices ready.')) : L('Chargement du modèle (téléchargé au premier usage, environ 305 Mo)…', 'Loading the model (downloaded on first use, about 305 MB)…'))
|
|
2593
|
+
: CALL_LANG[prefs.lang] ? L('Voix locales de bonne qualité, en français et en anglais. Gratuit, rien n’est envoyé nulle part.', 'Good-quality local voices, in this language and in English. Free, nothing leaves your machine.') : L('Voix locales de bonne qualité, en anglais. Gratuit, rien n’est envoyé nulle part.', 'Good-quality local voices, in English. Free, nothing leaves your machine.');
|
|
2228
2594
|
if ((st.installing || (st.installed && !st.ready && !st.gaveUp)) && !kokoroTimer) kokoroTimer = setInterval(async () => { await kokoroUI(); }, 2500);
|
|
2229
|
-
if (!st.installing && (st.ready || st.gaveUp || !st.installed) && kokoroTimer) { clearInterval(kokoroTimer); kokoroTimer = null; if (st.ready && TTS.engine !== 'kokoro') TTS.init(); }
|
|
2595
|
+
if (!st.installing && (st.ready || st.gaveUp || !st.installed) && kokoroTimer) { clearInterval(kokoroTimer); kokoroTimer = null; if (st.ready && (TTS.engine !== 'kokoro' || (st.g2p && !TTS.pool.fr.some((v) => TTS.kv.has(v))))) TTS.init(); } /* also when the voices of the other languages have just been added */
|
|
2230
2596
|
}
|
|
2231
|
-
$('#kokoroInstall').onclick = async () => { try { await fetch('/api/kokoro/install', { method: 'POST' }); } catch {} kokoroUI(); };
|
|
2597
|
+
$('#kokoroInstall').onclick = async () => { try { await fetch('/api/kokoro/install', { method: 'POST' }); } catch {} kokoroUI(); voiceOffer(); };
|
|
2232
2598
|
kokoroUI();
|
|
2599
|
+
// ---- on the call: one line that says the real voices exist, to whoever does not have them. Nothing outside ⚙ said so, and without them the agents babble. One click installs them (and the style changes
|
|
2600
|
+
// to them once they are ready, not before); ✕ and the line never comes back. Not in the scripted demo (?demo=1), which is what the pictures and videos are made from.
|
|
2601
|
+
let offerTimer = null;
|
|
2602
|
+
async function voiceOffer() {
|
|
2603
|
+
const el = $('#vOffer'), hide = () => { el.style.display = 'none'; clearInterval(offerTimer); offerTimer = null; };
|
|
2604
|
+
if (!prefs.voice || prefs.voiceOffer === 'no' || Q.get('demo')) return hide();
|
|
2605
|
+
let st; try { st = await (await fetch('/api/kokoro')).json(); } catch { return; }
|
|
2606
|
+
const add = st.installed && st.ready && !st.g2p && !!CALL_LANG[prefs.lang] && prefs.vstyle === 'kokoro'; // the voices are there, from before French, Spanish and Portuguese were added: one small package more, said on the call where one of them is the language of the interface (⚙ said it, and nothing else)
|
|
2607
|
+
if (st.ready && prefs.voiceOffer === 'want' && !st.installing && !add) { prefs.voiceOffer = 'no'; prefs.vstyle = 'kokoro'; prefs.vstyleChosen = true; savePrefs(); $('#vstyle').value = 'kokoro'; hide(); await TTS.init(); kokoroUI(); toast(L('Voix prêtes.', 'Voices ready.')); return; }
|
|
2608
|
+
const busy = st.installing || (st.installed && !st.ready && !st.gaveUp && prefs.voiceOffer === 'want');
|
|
2609
|
+
if (busy && !st.installing && !voiceOffer.woke) { voiceOffer.woke = true; fetch('/api/voices?engine=kokoro').catch(() => {}); } // installed in an earlier run, closed before the model was ready: nothing else starts the engine while another style is in use, and the line would say “Downloading” for good
|
|
2610
|
+
if ((st.installed && !busy && !add) || !st.npm) return hide(); // they have them; or cannot have them (no npm), which ⚙ explains
|
|
2611
|
+
$('#vOfferT').textContent = busy ? L('Téléchargement des vraies voix… vous pouvez continuer.', 'Downloading the real voices… you can carry on.') : st.error || (add ? L('Voix prêtes en anglais. Le français est encore lu par les voix du système.', 'Voices ready in English. This language is still read by the system voices.') : L('Vos agents peuvent parler avec de vraies voix.', 'Your agents can speak with real voices.'));
|
|
2612
|
+
$('#vOfferB').style.display = busy ? 'none' : ''; $('#vOfferB').textContent = add ? L('Ajouter les voix françaises', 'Add the voices of this language') + L(` (${st.g2pMb} Mo)`, ` (${st.g2pMb} MB)`) : L('Installer', 'Install') + L(` (${st.sizeMb} Mo)`, ` (${st.sizeMb} MB)`); el.style.display = '';
|
|
2613
|
+
if (busy && !offerTimer) offerTimer = setInterval(voiceOffer, 2500); if (!busy && offerTimer) { clearInterval(offerTimer); offerTimer = null; }
|
|
2614
|
+
}
|
|
2615
|
+
$('#vOfferB').onclick = async () => { prefs.voiceOffer = 'want'; savePrefs(); try { await fetch('/api/kokoro/install', { method: 'POST' }); } catch {} voiceOffer(); kokoroUI(); };
|
|
2616
|
+
$('#vOfferX').onclick = () => { prefs.voiceOffer = 'no'; savePrefs(); voiceOffer(); };
|
|
2617
|
+
voiceOffer();
|
|
2618
|
+
// ---- on the call: the first time one is held in Spanish or Portuguese on this computer, a line says that it is translated, and with what. Nobody asked for it (it follows the interface language, as French
|
|
2619
|
+
// always did), and it sends what the agents say to Anthropic through the person's own Claude Code. Said once; "Turn off" is the switch of ⚙ → Language.
|
|
2620
|
+
function callNote() {
|
|
2621
|
+
const on = TRL() && !FR() && !prefs.callTrSeen && !Q.get('demo'); $('#trNote').style.display = on ? '' : 'none'; if (!on) return;
|
|
2622
|
+
$('#trNoteT').textContent = L('L’appel est maintenant traduit dans cette langue, avec votre Claude Code.', 'The call is now translated into this language, with your Claude Code.'); $('#trNoteOk').textContent = L('Garder', 'Keep'); $('#trNoteOff').textContent = L('Désactiver', 'Turn off');
|
|
2623
|
+
}
|
|
2624
|
+
$('#trNoteOk').onclick = () => { prefs.callTrSeen = true; savePrefs(); callNote(); };
|
|
2625
|
+
$('#trNoteOff').onclick = () => { prefs.callTrSeen = true; prefs.callTr = false; savePrefs(); setLang(prefs.lang); };
|
|
2233
2626
|
$('#officeVol').value = prefs.officeVol; $('#officeBox').style.display = prefs.office ? '' : 'none';
|
|
2234
2627
|
$('#officeVol').oninput = (e) => { prefs.officeVol = +e.target.value; savePrefs(); AUD.applyMusic(); };
|
|
2235
2628
|
$('#musicVol').oninput = (e) => { prefs.musicVol = +e.target.value; savePrefs(); AUD.applyMusic(); };
|
|
@@ -2353,21 +2746,44 @@ function openKeys() {
|
|
|
2353
2746
|
$('#recapx').onclick = () => $('#recap').classList.remove('on'); $('#recap').classList.add('on');
|
|
2354
2747
|
}
|
|
2355
2748
|
$('#mKeys').onclick = () => { $('#menu').classList.remove('on'); openKeys(); };
|
|
2749
|
+
// ⚙ › Report a problem: the last errors of the local log, shown exactly as they would be sent, and the draft of an issue on GitHub that carries them. Nothing leaves from here:
|
|
2750
|
+
// the person reads the draft on GitHub, says what happened and sends it. The text of the report is in English whatever the language: it is read by the developer.
|
|
2751
|
+
const ISSUES = 'https://github.com/Atoll92/agent-standup/issues/new';
|
|
2752
|
+
async function openReport() {
|
|
2753
|
+
let r = null; try { r = await (await fetch('/api/errors')).json(); } catch {}
|
|
2754
|
+
const str = (x) => (typeof x === 'string' ? x.replace(/```/g, "'''") : ''), whole = (s) => (s.toWellFormed ? s.toWellFormed() : s.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])/g, '').replace(/(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]/g, '$1')); // whole: no half of an emoji left by a cut, which a link cannot carry
|
|
2755
|
+
const errs = ((r && Array.isArray(r.errors) && r.errors) || []).filter((e) => e && typeof e === 'object').slice(-5).reverse(), one = (e) => `${str(e.t)} · ${str(e.v)} · ${str(e.where)}\n${str(e.msg)}${str(e.stack) ? '\n' + str(e.stack).split('\n').slice(0, 5).map((l) => ' ' + l.slice(0, 200)).join('\n') : ''}`;
|
|
2756
|
+
const app = r ? [`Agent Standup ${r.version}${r.host ? ' · ' + r.host : ''}`, `${r.platform} · Node ${r.node}${r.electron ? ' · Electron ' + r.electron : ''}`] : ['Agent Standup']; app.push(navigator.userAgent, 'Language: ' + (prefs.lang || ''));
|
|
2757
|
+
const body = (list) => whole('**What happened?**\n\n\n**App**\n' + app.join('\n') + '\n\n**Last errors in the local log**\n' + (list.length ? '```\n' + list.map(one).join('\n\n') + '\n```' : 'none'));
|
|
2758
|
+
let list = errs; while (list.length > 1 && encodeURIComponent(body(list)).length > 5500) list = list.slice(0, -1); // the draft travels in the address: the oldest errors give way
|
|
2759
|
+
let text = body(list); while (encodeURIComponent(text).length > 5500) text = whole(text.slice(0, Math.floor(text.length * 0.8))) + '\n…\n```'; // one error alone that is too long is cut, and its block closed
|
|
2760
|
+
const url = ISSUES + '?title=' + encodeURIComponent(list[0] ? whole(`[${str(r && r.version)}] ${str(list[0].msg).slice(0, 90)}`) : '') + '&body=' + encodeURIComponent(text);
|
|
2761
|
+
$('#recap .box').innerHTML = `<h1>${L('Signaler un problème', 'Report a problem')}</h1>
|
|
2762
|
+
<p>${L('Rien n’est envoyé d’ici. Le bouton ouvre un brouillon sur GitHub avec le texte ci-dessous : relisez-le, dites ce qui s’est passé, puis envoyez-le vous-même.', 'Nothing is sent from here. The button opens a draft on GitHub with the text below: read it, say what happened, then send it yourself.')}</p>
|
|
2763
|
+
<pre id="reportTxt" style="margin:12px 0;padding:12px 14px;max-height:44vh;overflow:auto;white-space:pre-wrap;word-break:break-word;background:var(--bg);border:1px solid var(--line);border-radius:10px;font:12px ui-monospace,Menlo,monospace"></pre>
|
|
2764
|
+
${r && r.file ? `<p class="dim" style="font-size:12px">${L('Les erreurs de l’app sont gardées dans un fichier sur cet ordinateur :', 'The app’s errors are kept in a file on this computer:')} <span class="f">${esc(r.file)}</span></p>` : ''}
|
|
2765
|
+
<p style="text-align:right;margin:18px 0 0"><button class="btn" id="reportCopy">📋 ${L('Copier', 'Copy')}</button> <button class="btn" id="recapx">${L('Fermer', 'Close')}</button> <button class="cta" id="reportGo">${L('Ouvrir le brouillon sur GitHub', 'Open the draft on GitHub')}</button></p>`;
|
|
2766
|
+
$('#reportTxt').textContent = text;
|
|
2767
|
+
$('#reportCopy').onclick = async () => { let ok = false; try { await navigator.clipboard.writeText(text); ok = true; } catch { try { const ta = document.createElement('textarea'); ta.value = text; ta.style.cssText = 'position:fixed;opacity:0'; document.body.appendChild(ta); ta.select(); ok = document.execCommand('copy'); ta.remove(); } catch {} } $('#reportCopy').textContent = ok ? '✓ ' + L('Copié', 'Copied') : L('Copie impossible', 'Copy failed'); setTimeout(() => { if ($('#reportCopy')) $('#reportCopy').textContent = '📋 ' + L('Copier', 'Copy'); }, 2000); };
|
|
2768
|
+
$('#reportGo').onclick = () => openExternal(url);
|
|
2769
|
+
$('#recapx').onclick = () => $('#recap').classList.remove('on'); $('#recap').classList.add('on');
|
|
2770
|
+
}
|
|
2771
|
+
$('#mReport').onclick = () => { $('#menu').classList.remove('on'); openReport(); };
|
|
2356
2772
|
addEventListener('keydown', (e) => {
|
|
2357
2773
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); openSwitcher(); return; }
|
|
2358
2774
|
if (/INPUT|SELECT|TEXTAREA/.test(e.target.tagName) || e.metaKey || e.ctrlKey || e.altKey) return; // browser shortcuts (Cmd+R, Ctrl+N…) stay the browser's
|
|
2359
2775
|
if (e.key === '?') { openKeys(); return; }
|
|
2360
2776
|
if (e.key === ' ') { if (e.target.closest && e.target.closest('button, .tile, .rr, .bcard, a, [role=button]')) return; e.preventDefault(); togglePlay(); } else if (e.key.toLowerCase() === 'm') toggleMute(); else if (e.key.toLowerCase() === 't') { const toTree = !document.body.classList.contains('tree'); setView(toTree ? 'tree' : 'call'); if (toTree) toast(L('Vue arbre : T pour revenir, ? pour l’aide', 'Tree view: T to go back, ? for help')); } else if (e.key.toLowerCase() === 'r') openRecap(); else if (e.key.toLowerCase() === 'l') $('#bLog').click(); else if (e.key === 'ArrowRight' && !S.live) { e.preventDefault(); stepEvent(1); } else if (e.key === 'ArrowLeft' && !S.live) { e.preventDefault(); stepEvent(-1); } else if (e.key.toLowerCase() === 'n') stepHighlight(e.shiftKey ? -1 : 1); else if (e.key.toLowerCase() === 'j') jumpAttn(1); else if (e.key.toLowerCase() === 'k') jumpAttn(-1); else if (e.key === 'Escape') { $('#recap').classList.remove('on'); $('#menu').classList.remove('on'); }
|
|
2361
2777
|
});
|
|
2362
|
-
if (EMBED) $('#mBrowser').style.display = '';
|
|
2778
|
+
if (EMBED) $('#mBrowser').style.display = $('#mFollowTab').style.display = '';
|
|
2363
2779
|
|
|
2364
2780
|
(async function init() {
|
|
2365
|
-
if (!LANGS.some((l) => l[0] === prefs.lang)) prefs.lang = 'en'; await loadLocale(prefs.lang); await loadChars();
|
|
2781
|
+
if (!LANGS.some((l) => l[0] === prefs.lang)) prefs.lang = 'en'; await loadLocale(prefs.lang); voiceOffer(); kokoroUI(); await loadChars();
|
|
2366
2782
|
document.body.classList.toggle('rost', prefs.roster !== false); document.body.classList.toggle('react', !!prefs.reactions); setView(prefs.view); menuInit(); addEventListener('click', () => { try { if (prefs.notify && !EMBED && 'Notification' in window && Notification.permission === 'default') Notification.requestPermission(); } catch {} }, { once: true }); applyLang(); applyMute(); TTS.init().then(updateHint);
|
|
2367
2783
|
loadHealth().then(() => { // French by default only if translation can actually work; otherwise stay in English without a warning
|
|
2368
2784
|
const h = S.health || {};
|
|
2369
2785
|
if (!prefs.langChosen && FR() && h.claude === null && !h.apiKey) { prefs.lang = 'en'; applyLang(); }
|
|
2370
|
-
if (
|
|
2786
|
+
if (TRL()) { fetch('/api/warm?lang=' + CALL()).catch(() => {}); prefetchTr(S.idx); } callNote();
|
|
2371
2787
|
});
|
|
2372
2788
|
if (Q.get('lang')) { await setLang(Q.get('lang'), false); }
|
|
2373
2789
|
if (Q.get('demo')) {
|