@ngockhoale/ckit 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.env.example +3 -3
  2. package/README.md +2 -2
  3. package/dist/src/gui/server.d.ts +2 -2
  4. package/dist/src/gui/server.js +5 -2
  5. package/dist/src/team/config.js +4 -2
  6. package/dist/src/team/types.d.ts +2 -0
  7. package/gui/app.css +178 -0
  8. package/gui/app.js +278 -65
  9. package/gui/assets/ckit-oriental-avatar-pack/README.md +5 -0
  10. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-01.png +0 -0
  11. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-02.png +0 -0
  12. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-03.png +0 -0
  13. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-04.png +0 -0
  14. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-05.png +0 -0
  15. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-06.png +0 -0
  16. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-07.png +0 -0
  17. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-08.png +0 -0
  18. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-09.png +0 -0
  19. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-01.png +0 -0
  20. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-02.png +0 -0
  21. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-03.png +0 -0
  22. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-04.png +0 -0
  23. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-05.png +0 -0
  24. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-06.png +0 -0
  25. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-07.png +0 -0
  26. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-08.png +0 -0
  27. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-09.png +0 -0
  28. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-01.png +0 -0
  29. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-02.png +0 -0
  30. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-03.png +0 -0
  31. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-04.png +0 -0
  32. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-05.png +0 -0
  33. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-06.png +0 -0
  34. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-07.png +0 -0
  35. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-08.png +0 -0
  36. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-09.png +0 -0
  37. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-01.png +0 -0
  38. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-02.png +0 -0
  39. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-03.png +0 -0
  40. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-04.png +0 -0
  41. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-05.png +0 -0
  42. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-06.png +0 -0
  43. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-07.png +0 -0
  44. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-08.png +0 -0
  45. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-09.png +0 -0
  46. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-01.png +0 -0
  47. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-02.png +0 -0
  48. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-03.png +0 -0
  49. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-04.png +0 -0
  50. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-05.png +0 -0
  51. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-06.png +0 -0
  52. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-07.png +0 -0
  53. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-08.png +0 -0
  54. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-09.png +0 -0
  55. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-01.png +0 -0
  56. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-02.png +0 -0
  57. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-03.png +0 -0
  58. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-04.png +0 -0
  59. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-05.png +0 -0
  60. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-06.png +0 -0
  61. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-07.png +0 -0
  62. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-08.png +0 -0
  63. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-09.png +0 -0
  64. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-01.png +0 -0
  65. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-02.png +0 -0
  66. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-03.png +0 -0
  67. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-04.png +0 -0
  68. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-05.png +0 -0
  69. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-06.png +0 -0
  70. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-07.png +0 -0
  71. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-08.png +0 -0
  72. package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-09.png +0 -0
  73. package/gui/assets/ckit-oriental-avatar-pack/manifest.json +447 -0
  74. package/gui/index.html +28 -12
  75. package/gui/network.js +108 -20
  76. package/package.json +2 -1
package/gui/index.html CHANGED
@@ -4,7 +4,8 @@
4
4
  <body>
5
5
  <div id="app">
6
6
  <header id="top">
7
- <div class="logo"><span class="dia">◆</span> CKIT <span class="dot">·</span> AGENT COMPANY</div>
7
+ <div class="logo"><span class="dia" aria-hidden="true"></span><span class="lk">CKIT</span> <span class="dot">·</span> <span class="lc">AGENT COMPANY</span></div>
8
+ <div class="wsbox" id="wsbox" title="Workspace"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M1.5 3.5h4l1.5 1.5h7.5v8h-13z" fill="none" stroke="currentColor" stroke-width="1.3"/></svg><span id="wsboxn" class="mono">—</span><span class="caret" aria-hidden="true">▾</span></div>
8
9
  <div class="goal" id="goal" title="">No active run</div>
9
10
  <div class="meta"><span class="ml">RUN</span><span class="mv mono" id="runid">—</span></div>
10
11
  <div class="badge" id="badge"><i></i><span>IDLE</span></div>
@@ -14,30 +15,44 @@
14
15
  <div class="metric"><span class="ml">MESSAGES</span><span class="mv big mono" id="msgs">0</span></div>
15
16
  <div class="metric"><span class="ml">ACTIVE</span><span class="mv big mono" id="active">0</span></div>
16
17
  <nav class="btns">
17
- <button id="bLive" class="tab on">Live</button><button id="bComic" class="tab">📖 Comic</button>
18
- <button id="bCfg">⚙ Config</button><button id="bRuns">Runs</button><button id="bNew" class="primary">+ New run</button>
18
+ <button id="bLive" class="tab on" hidden>Live</button><button id="bComic" class="tab" title="Retell the run as comic panels">▤ Comic</button>
19
+ <button id="bCfg" title="Configure teams and agents">⚙ Config</button><button id="bRuns" title="Past runs and replay">Runs</button><button id="bNew" class="primary">+ New run</button>
19
20
  </nav>
20
21
  </header>
21
- <div id="strip"><div id="stages"></div><div id="lanename" hidden></div><div id="caption"></div><div id="ws"><span class="ml">WORKSPACE</span><b class="mono" id="cwdn"></b><span class="mono" id="cwd"></span></div></div>
22
+ <div id="strip"><div id="stages" role="list" aria-label="Execution flow"></div><div id="lanename" hidden></div><div id="caption"></div><div id="ws"><span class="ml">WORKSPACE</span><b class="mono" id="cwdn"></b><span class="mono" id="cwd"></span></div></div>
23
+ <div id="body">
24
+ <nav id="rail" aria-label="Main navigation">
25
+ <button class="rb" id="rHome" type="button" title="Mission control" aria-label="Mission control"><svg viewBox="0 0 24 24"><path d="M3 11l9-7 9 7v9h-6v-6H9v6H3z"/></svg></button>
26
+ <button class="rb on" id="rAgents" type="button" title="Agents" aria-label="Agents"><svg viewBox="0 0 24 24"><circle cx="9" cy="8" r="3.2"/><circle cx="17" cy="9" r="2.4"/><path d="M3 19c.5-3.5 3-5.5 6-5.5s5.5 2 6 5.5zM15.5 13.6c2.6-.2 4.8 1.6 5.2 5.4h-4"/></svg></button>
27
+ <button class="rb" id="rTopo" type="button" title="Topology (comic retelling)" aria-label="Topology"><svg viewBox="0 0 24 24"><circle cx="6" cy="6" r="2.5"/><circle cx="18" cy="6" r="2.5"/><circle cx="12" cy="18" r="2.5"/><path d="M8 7.5l3 8M16 7.5l-3 8M8.5 6h7" fill="none"/></svg></button>
28
+ <button class="rb" id="rCode" type="button" title="Workspace files" aria-label="Workspace files"><svg viewBox="0 0 24 24"><path d="M8 7l-5 5 5 5M16 7l5 5-5 5M14 4l-4 16" fill="none"/></svg></button>
29
+ <button class="rb" id="rData" type="button" title="Run artifacts (report)" aria-label="Run artifacts"><svg viewBox="0 0 24 24"><ellipse cx="12" cy="6" rx="7" ry="2.6" fill="none"/><path d="M5 6v12c0 1.4 3.1 2.6 7 2.6s7-1.2 7-2.6V6M5 12c0 1.4 3.1 2.6 7 2.6s7-1.2 7-2.6" fill="none"/></svg></button>
30
+ <button class="rb" id="rHist" type="button" title="Run history" aria-label="Run history"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5" fill="none"/><path d="M12 7v5l3.5 2" fill="none"/></svg></button>
31
+ <span class="rsp"></span>
32
+ <button class="rb" id="rSet" type="button" title="Config" aria-label="Config"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="3" fill="none"/><path d="M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.2 5.2l2.1 2.1M16.7 16.7l2.1 2.1M5.2 18.8l2.1-2.1M16.7 7.3l2.1-2.1" fill="none"/></svg></button>
33
+ </nav>
22
34
  <main id="live">
23
- <aside id="roster"></aside>
35
+ <aside id="roster" aria-label="Agents"></aside>
24
36
  <section id="center">
25
- <canvas id="net"></canvas>
37
+ <canvas id="net" aria-label="Agent topology"></canvas>
26
38
  <div id="bubbles"></div>
39
+ <div id="mission"><span class="mtag" id="mtag">READY</span><span id="mgoal">No active run — type a mission below.</span><button class="primary" id="bHint" type="button">+ New run</button></div>
27
40
  <div id="now"><span class="nowtag">NOW</span><span id="nowtext">Waiting for a mission…</span></div>
28
41
  <div id="hobanner"></div>
29
- <div id="idleHint"><span class="nowtag">READY</span><span>Type a mission in the box below and press Enter.</span><button class="primary" id="bHint">+ New run</button></div>
42
+ <div id="idleHint"><span class="nowtag">READY</span><span>Type a mission in the box below and press Enter.</span></div>
30
43
  <button id="bRoster">◧ Team</button><button id="bInsp">Inspector ◨</button>
31
44
  </section>
32
- <aside id="inspector"></aside>
45
+ <aside id="inspector" aria-label="Inspector"></aside>
33
46
  <section id="dock">
34
- <div id="feedwrap"><div class="dh"><span class="ml">CONVERSATION</span><span class="ml" id="feedcount"></span></div><div id="feed"></div></div>
47
+ <div id="feedwrap">
48
+ <div class="dh"><span class="ml dtitle"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 3h12v8H6l-4 3z" fill="none" stroke="currentColor" stroke-width="1.4"/></svg>CONVERSATION</span><div id="ctabs" role="tablist" aria-label="Conversation filter"></div><span class="ml" id="feedcount"></span><span class="dtools"><button class="chip ghost" id="bSplit" type="button" title="Split view: messages and the raw event stream side by side" aria-pressed="false">◫ Split View</button><button class="chip ghost" id="bTerm" type="button" title="Terminal: raw event stream of this run" aria-pressed="false">&gt;_ Terminal</button></span></div>
49
+ <div id="feedarea"><div id="feed" aria-live="polite"></div><pre id="term" hidden></pre></div>
50
+ </div>
35
51
  <div id="composer">
36
- <div class="dh"><span class="ml" id="clabel">OWNER → DIRECTOR</span><span class="ctools"><button class="chip" id="enh" title="Rewrite your request so the Director cannot misread it. You decide whether to use the result.">✦ Enhance</button><button class="chip" id="attach" title="Attach any files: images, PDF, Word, Excel, drawio, XML… You can also drop or paste them here.">📎 Attach files</button></span><input type="file" id="file" multiple hidden></div>
52
+ <div class="dh"><span class="ml" id="clabel">OWNER → DIRECTOR</span><span class="ctools"><button class="chip" id="enh" title="Rewrite your request so the Director cannot misread it. You decide whether to use the result.">✦ Enhance</button></span><input type="file" id="file" multiple hidden><span id="cnote"></span></div>
37
53
  <div class="chips" id="chips"></div><div class="chips" id="wbtns" hidden></div><span id="lanewrap" hidden><select id="lane" title="Lane for this request. Auto: the Director decides which lane fits."></select></span>
38
54
  <div class="attlist" id="atts"></div>
39
- <div class="cbox"><textarea id="msg" rows="2" placeholder="Message the Director… (Enter to send, @ for a file)"></textarea><button class="primary" id="send">Send ▸</button></div>
40
- <div id="cnote"></div>
55
+ <div class="cbox"><button class="cattach" id="attach" type="button" title="Attach any files: images, PDF, Word, Excel, drawio, XML… You can also drop or paste them here." aria-label="Attach files"><svg viewBox="0 0 24 24"><path d="M20 11.5l-8 8a5 5 0 01-7-7l8.5-8.5a3.3 3.3 0 014.7 4.7L9.6 17.3a1.7 1.7 0 01-2.4-2.4L15 7" fill="none"/></svg></button><textarea id="msg" rows="1" placeholder="Gửi tin nhắn cho Director… (Enter to send, @ for a file)" aria-label="Message"></textarea><span class="kbd" aria-hidden="true">Enter ↵</span><button class="primary" id="send" aria-label="Send">Send ▸</button></div>
41
56
  </div>
42
57
  </section>
43
58
  <div class="rz col" id="rzL" title="Drag to resize · double-click to reset"></div><div class="rz col" id="rzR" title="Drag to resize · double-click to reset"></div><div class="rz row" id="rzD" title="Drag to resize · double-click to reset"></div><div class="rz col" id="rzC" title="Drag to resize · double-click to reset"></div>
@@ -45,6 +60,7 @@
45
60
  </main>
46
61
  <main id="settings" hidden></main>
47
62
  <main id="runs" hidden></main>
63
+ </div>
48
64
  </div>
49
65
  <div id="modal" hidden></div>
50
66
  <div id="overlay" hidden></div>
package/gui/network.js CHANGED
@@ -9,6 +9,14 @@
9
9
  function hexA(hex, a) { var n = parseInt(hex.slice(1), 16); return 'rgba(' + (n >> 16) + ',' + ((n >> 8) & 255) + ',' + (n & 255) + ',' + a + ')'; }
10
10
  function rnd(a, b) { return a + Math.random() * (b - a); }
11
11
  function bez(p0, c, p1, t) { var u = 1 - t; return {x: u * u * p0.x + 2 * u * t * c.x + t * t * p1.x, y: u * u * p0.y + 2 * u * t * c.y + t * t * p1.y}; }
12
+ var avatarResolver = null, engineResolver = null, imgCache = {};
13
+ var RM = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {matches: false};
14
+ function portrait(a) {
15
+ var url = a && avatarResolver ? avatarResolver(a) : null; if (!url) return null;
16
+ var im = imgCache[url];
17
+ if (!im) { im = imgCache[url] = new Image(); im.decoding = 'async'; im.src = url; im.onerror = function () { im.bad = true; }; }
18
+ return im.complete && im.naturalWidth && !im.bad ? im : null;
19
+ }
12
20
  function ctrl(a, b, bend) { var mx = (a.x + b.x) / 2, my = (a.y + b.y) / 2, dx = b.x - a.x, dy = b.y - a.y; return {x: mx - dy * bend, y: my + dx * bend}; }
13
21
 
14
22
  function create(canvas) {
@@ -17,7 +25,13 @@
17
25
  var agents = [], nodes = {}, zones = {}, hub = {x: 0, y: 0, r: 44};
18
26
  var particles = [], sparks = [], packages = [], flashes = {}, hot = {}, ambient = [], noise = [];
19
27
  var stageIdx = -1, stageDone = 0, stageLoop = 1, selected = null, hover = null, onSelect = null, onFrame = null;
20
- var slow = false, grid = null, t0 = performance.now(), verdictFlash = null;
28
+ var hubStats = null, slow = false, grid = null, t0 = performance.now(), verdictFlash = null, labels = [], linkTitle = {};
29
+ function addLabel(A, B, text, color, bend) {
30
+ if (!text) return; text = String(text).replace(/\s+/g, ' ').trim(); if (!text) return;
31
+ if (text.length > 22) text = text.slice(0, 21) + '…';
32
+ labels.push({a: A, b: B, text: text, color: color || '#21D6E8', bend: bend || .18, until: performance.now() + 3200});
33
+ if (labels.length > 6) labels.shift(); /* bounded */
34
+ }
21
35
 
22
36
  function initAmbient() {
23
37
  ambient = []; for (var i = 0; i < 80; i++) ambient.push({x: Math.random(), y: Math.random(), vx: rnd(-.004, .004), vy: rnd(-.004, .004), r: rnd(.6, 1.8), p: Math.random() * 6});
@@ -32,6 +46,17 @@
32
46
  for (var x2 = 0; x2 < W; x2 += 120) { g.moveTo(x2 + .5, 0); g.lineTo(x2 + .5, H); }
33
47
  for (var y2 = 0; y2 < H; y2 += 120) { g.moveTo(0, y2 + .5); g.lineTo(W, y2 + .5); }
34
48
  g.stroke();
49
+ /* terrain silhouette along the bottom edge (static, drawn once per resize) */
50
+ var base = H, amp = Math.min(70, H * .11);
51
+ [[.10, .55, 'rgba(33,214,232,0.05)'], [.05, 1, 'rgba(12,20,36,0.85)']].forEach(function (L, li) {
52
+ g.beginPath(); g.moveTo(0, base);
53
+ for (var tx = 0; tx <= W; tx += 8) {
54
+ var k = tx / W, yv = Math.sin(k * 9 + li * 2) * .35 + Math.sin(k * 23 + li) * .18 + Math.sin(k * 3.7) * .47;
55
+ g.lineTo(tx, base - amp * (L[1] * .55 + .45 * Math.abs(yv)) - (li ? 0 : amp * .25));
56
+ }
57
+ g.lineTo(W, base); g.closePath(); g.fillStyle = L[2]; g.fill();
58
+ if (li) { g.strokeStyle = 'rgba(33,214,232,0.18)'; g.lineWidth = 1; g.stroke(); }
59
+ });
35
60
  }
36
61
  function layout() {
37
62
  /* wide = short/letterbox canvas: everything on one row so nothing overlaps or gets clipped */
@@ -62,7 +87,7 @@
62
87
  S = Math.max(.4, Math.min(S * .8, W / Math.max(bottom.length, 2) / zw));
63
88
  }
64
89
  }
65
- hub = {x: W * hp[0], y: H * hp[1], r: 50 * S};
90
+ hub = {x: W * hp[0], y: H * hp[1], r: 54 * S};
66
91
  zones = {}; nodes = {};
67
92
  teamIds.forEach(function (tid) {
68
93
  var list = agents.filter(function (a) { return a.team === tid; }), n = Math.max(1, list.length);
@@ -102,8 +127,9 @@
102
127
  opt = opt || {};
103
128
  particles.push({a: a, b: b, bend: bend, t: -(opt.delay || 0), speed: opt.speed || .55, color: color, size: opt.size || 3, trail: [], back: opt.back || false, bounces: opt.bounces || 0});
104
129
  }
105
- function pulse(from, to, kind) {
130
+ function pulse(from, to, kind, label) {
106
131
  var A = endpoint(from), B = endpoint(to), ta = teamOf(from), tb = teamOf(to);
132
+ if (label && from !== to) addLabel(A, B, label, kind === 'fail' ? '#F05668' : kind === 'pass' ? '#4AD69A' : TEAM_COLOR[ta], ta === tb ? .45 : .18);
107
133
  var color = kind === 'fail' ? '#F05668' : kind === 'pass' ? '#4AD69A' : TEAM_COLOR[ta] || '#21D6E8';
108
134
  var key = [from, to].sort().join('|'); hot[key] = {until: performance.now() + 2200, c1: TEAM_COLOR[ta], c2: TEAM_COLOR[tb]};
109
135
  if (from === to) { burst(A.x, A.y, color, 8); return; }
@@ -125,6 +151,8 @@
125
151
  packages.push({a: A, b: B, t: 0, dur: dur, title: title || 'HANDOFF', color: TEAM_COLOR[fromTeam] || '#A36BFF', c2: TEAM_COLOR[toTeam] || '#21D6E8', start: performance.now()});
126
152
  hot[['ho', fromTeam, toTeam].join('|')] = {until: performance.now() + dur * 1000 + 1500, c1: TEAM_COLOR[fromTeam], c2: TEAM_COLOR[toTeam], thick: true, a: A, b: B};
127
153
  burst(A.x, A.y, TEAM_COLOR[fromTeam] || '#fff', 26);
154
+ addLabel(A, B, title || 'Handoff', TEAM_COLOR[toTeam] || '#21D6E8', -.16);
155
+ if (title && zones[toTeam]) linkTitle[toTeam] = String(title);
128
156
  }
129
157
  function verdict(v) {
130
158
  var q = zones.qc || hub, c = v === 'PASS' ? '#4AD69A' : '#F05668';
@@ -138,7 +166,7 @@
138
166
  }
139
167
  function setState(id, st) { if (nodes[id]) nodes[id].state = st; }
140
168
  function setStep(id, prog) { if (nodes[id]) nodes[id].prog = prog; }
141
- function reset() { subs = {}; particles = []; packages = []; sparks = []; hot = {}; stageIdx = -1; stageDone = 0; Object.keys(nodes).forEach(function (k) { nodes[k].state = 'idle'; nodes[k].prog = null; }); }
169
+ function reset() { subs = {}; particles = []; packages = []; sparks = []; hot = {}; labels = []; linkTitle = {}; stageIdx = -1; stageDone = 0; Object.keys(nodes).forEach(function (k) { nodes[k].state = 'idle'; nodes[k].prog = null; }); }
142
170
 
143
171
  /* ---------- drawing ---------- */
144
172
  function drawThread(a, b, bend, color1, color2, alpha, width) {
@@ -196,7 +224,7 @@
196
224
  }
197
225
  ctx.globalCompositeOperation = 'source-over';
198
226
  /* stage ring */
199
- var rr2 = r * 2.05, gap = .08, seg = 6.283 / STAGE_COUNT;
227
+ var rr2 = r * 1.42, gap = .08, seg = 6.283 / STAGE_COUNT;
200
228
  for (var s = 0; s < STAGE_COUNT; s++) {
201
229
  var a0 = -Math.PI / 2 + s * seg + gap / 2, a1 = a0 + seg - gap, col, al;
202
230
  if (stageIdx < 0) { col = '#34445B'; al = .7; }
@@ -211,26 +239,61 @@
211
239
  /* outer fine ring, rotating dashes */
212
240
  ctx.setLineDash([2, 7]); ctx.lineDashOffset = -tms / 120; ctx.strokeStyle = hexA(c, .4); ctx.lineWidth = 1;
213
241
  ctx.beginPath(); ctx.arc(x, y, rr2 + 9 * S, 0, 6.283); ctx.stroke(); ctx.setLineDash([]);
214
- /* core */
215
- var cg = ctx.createRadialGradient(x - r * .3, y - r * .3, 1, x, y, r * pulseK);
242
+ /* core: avatar portrait inside a purple energy ring */
243
+ var cr = r * .86 * pulseK, dn = nodes.director, im = dn ? portrait(dn.agent) : null;
244
+ var cg = ctx.createRadialGradient(x - r * .3, y - r * .3, 1, x, y, cr);
216
245
  cg.addColorStop(0, '#F3E6FF'); cg.addColorStop(.35, '#B98BFF'); cg.addColorStop(.8, '#7A3FD0'); cg.addColorStop(1, '#3a1d70');
217
246
  ctx.shadowColor = c; ctx.shadowBlur = 30 * pulseK; ctx.fillStyle = cg;
218
- ctx.beginPath(); ctx.arc(x, y, r * .86 * pulseK, 0, 6.283); ctx.fill(); ctx.shadowBlur = 0;
219
- ctx.strokeStyle = hexA('#F04F9B', .9); ctx.lineWidth = 2; ctx.beginPath(); ctx.arc(x, y, r * .86 * pulseK, 0, 6.283); ctx.stroke();
247
+ ctx.beginPath(); ctx.arc(x, y, cr, 0, 6.283); ctx.fill(); ctx.shadowBlur = 0;
248
+ if (im) { ctx.save(); ctx.beginPath(); ctx.arc(x, y, cr - 3, 0, 6.283); ctx.clip(); ctx.drawImage(im, x - cr + 3, y - cr + 3, (cr - 3) * 2, (cr - 3) * 2); ctx.restore(); }
249
+ ctx.strokeStyle = hexA('#F04F9B', .9); ctx.lineWidth = 2.5; ctx.beginPath(); ctx.arc(x, y, cr, 0, 6.283); ctx.stroke();
250
+ ctx.strokeStyle = hexA('#C9A6FF', .55); ctx.lineWidth = 1; ctx.beginPath(); ctx.arc(x, y, cr + 6 * S, 0, 6.283); ctx.stroke();
220
251
  /* thinking arc */
221
252
  if (anyThink) { ctx.strokeStyle = '#fff'; ctx.lineWidth = 2.5; ctx.beginPath(); var ra = tms / 300; ctx.arc(x, y, r * 1.12, ra, ra + 1.6); ctx.stroke(); }
222
- ctx.fillStyle = 'rgba(10,6,24,.9)'; ctx.font = '800 ' + Math.round(19 * S) + 'px system-ui,sans-serif'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
223
- var dlab = nodes.director ? initials(nodes.director.agent) : 'DIR'; if (dlab.length > 3) ctx.font = '800 ' + Math.round(16 * S) + 'px system-ui,sans-serif'; ctx.fillStyle = '#fff'; ctx.fillText(dlab, x, y + .5);
253
+ ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
254
+ var dlab = dn ? initials(dn.agent) : 'DIR';
255
+ if (!im) { ctx.font = '800 ' + Math.round((dlab.length > 3 ? 16 : 19) * S) + 'px system-ui,sans-serif'; ctx.fillStyle = '#fff'; ctx.fillText(dlab, x, y + .5); }
256
+ else {
257
+ /* DIR tag on the ring */
258
+ ctx.font = '800 ' + Math.round(10 * Math.max(.9, S)) + 'px ui-monospace,Menlo,monospace';
259
+ var tgw = ctx.measureText(dlab).width + 14, tgy = y + cr - 2;
260
+ ctx.fillStyle = '#2a1458'; roundRect(x - tgw / 2, tgy - 8, tgw, 16, 8); ctx.fill(); ctx.strokeStyle = '#C9A6FF'; ctx.lineWidth = 1; ctx.stroke();
261
+ ctx.fillStyle = '#fff'; ctx.fillText(dlab, x, tgy + .5);
262
+ }
263
+ if (dn) drawEngine(dn.agent, x + cr * .72, y - cr * .72, Math.max(8, 10 * S));
224
264
  if (wide) { ctx.restore(); return; } /* no room under the hub on a letterbox canvas */
225
265
  /* label */
226
266
  ctx.font = '600 ' + Math.round(11 * Math.max(.9, S)) + 'px ui-monospace,Menlo,monospace';
227
- var lab = 'DIRECTOR', tw = ctx.measureText(lab).width + 24, ly = y + rr2 + 24 * S;
267
+ var lab = '♛ ' + (dn ? cut(dn.agent.name, 22) : 'DIRECTOR'), tw = ctx.measureText(lab).width + 24, ly = y + rr2 + 24 * S;
228
268
  ctx.fillStyle = 'rgba(8,13,22,.92)'; roundRect(x - tw / 2, ly - 11, tw, 22, 11); ctx.fill();
229
269
  ctx.strokeStyle = hexA(c, .8); ctx.lineWidth = 1; ctx.stroke(); ctx.fillStyle = '#E6EEFA'; ctx.fillText(lab, x, ly + .5);
230
- if (stageLoop > 1 && stageIdx >= 1) { ctx.fillStyle = '#F3A544'; ctx.fillText('QC LOOP ' + stageLoop, x, ly + 20 * S); }
270
+ var sub = stageLoop > 1 && stageIdx >= 1 ? 'LOOP ' + stageLoop : dn && dn.state === 'thinking' ? 'Orchestrating…' : '';
271
+ if (sub) { ctx.font = '600 10.5px ui-monospace,Menlo,monospace'; ctx.fillStyle = stageLoop > 1 && stageIdx >= 1 ? '#F3A544' : '#C9A6FF'; ctx.fillText(sub, x, ly + 19); }
272
+ if (hubStats && hubStats.length) {
273
+ /* real run counters only (elapsed · messages · tokens) */
274
+ ctx.font = '600 10.5px ui-monospace,Menlo,monospace'; var gap2 = 6, ws = hubStats.map(function (t) { return ctx.measureText(t).width + 16; }), tot = ws.reduce(function (a2, b2) { return a2 + b2; }, 0) + gap2 * (ws.length - 1), cx2 = x - tot / 2, cy2 = ly + (sub ? 38 : 22);
275
+ hubStats.forEach(function (t, i) { ctx.fillStyle = 'rgba(8,13,22,.9)'; roundRect(cx2, cy2 - 9, ws[i], 18, 4); ctx.fill(); ctx.strokeStyle = 'rgba(120,140,180,.45)'; ctx.lineWidth = 1; ctx.stroke(); ctx.fillStyle = '#DCE6F5'; ctx.fillText(t, cx2 + ws[i] / 2, cy2 + .5); cx2 += ws[i] + gap2; });
276
+ }
231
277
  ctx.restore();
232
278
  }
233
279
  function initials(a) { if (a.short) return String(a.short).toUpperCase().slice(0, 4); if (a.team === 'director') return 'DIR'; var m = a.name.replace(/[^\p{L}\p{N} ·]/gu, '').split(/[ ·]+/).filter(Boolean); return ((m[0] || '?')[0] + ((m[1] || m[0] || '')[1] || (m[1] || '')[0] || '')).toUpperCase().slice(0, 2); }
280
+ function drawEngine(a, bx, by, br) {
281
+ var e = engineResolver ? engineResolver(a) : null; if (!e) return;
282
+ ctx.save(); ctx.fillStyle = '#05070D'; ctx.beginPath(); ctx.arc(bx, by, br + 2, 0, 6.283); ctx.fill();
283
+ ctx.fillStyle = e.color; ctx.beginPath(); ctx.arc(bx, by, br, 0, 6.283); ctx.fill();
284
+ ctx.fillStyle = '#05070D'; ctx.font = '800 ' + Math.round(br * (e.mark.length > 1 ? .95 : 1.25)) + 'px ui-monospace,Menlo,monospace'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
285
+ ctx.fillText(e.mark, bx, by + .5); ctx.restore();
286
+ }
287
+ function drawLabels(now) {
288
+ for (var i = labels.length - 1; i >= 0; i--) {
289
+ var L = labels[i], left = L.until - now; if (left <= 0) { labels.splice(i, 1); continue; }
290
+ var al = Math.min(1, left / 500, (3200 - left) / 250), c = ctrl(L.a, L.b, L.bend), m = bez(L.a, c, L.b, .5);
291
+ ctx.save(); ctx.globalAlpha = Math.max(0, al); ctx.font = '600 10.5px ui-monospace,Menlo,monospace'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
292
+ var tw = ctx.measureText(L.text).width + 18;
293
+ ctx.fillStyle = 'rgba(7,11,20,.94)'; roundRect(m.x - tw / 2, m.y - 10, tw, 20, 5); ctx.fill(); ctx.strokeStyle = hexA(L.color, .85); ctx.lineWidth = 1; ctx.stroke();
294
+ ctx.fillStyle = '#E6EEFA'; ctx.fillText(L.text, m.x, m.y + .5); ctx.restore();
295
+ }
296
+ }
234
297
  function cut(t, n) { return t.length > n ? t.slice(0, n - 1) + '…' : t; }
235
298
  var dimTeams = null;
236
299
  function drawNode(n, tms) {
@@ -265,8 +328,18 @@
265
328
  for (var d = 0; d < 3; d++) { var da = tms / 500 + d * 2.09; ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(x + Math.cos(da) * (r + 25 * S), y + Math.sin(da) * (r + 25 * S), 1.8, 0, 6.283); ctx.fill(); }
266
329
  }
267
330
  if (sel) { ctx.strokeStyle = 'rgba(255,255,255,.8)'; ctx.setLineDash([3, 3]); ctx.lineWidth = 1; ctx.beginPath(); ctx.arc(x, y, r + 15 * S, 0, 6.283); ctx.stroke(); ctx.setLineDash([]); }
331
+ var pim = portrait(n.agent);
332
+ if (pim) { ctx.save(); ctx.beginPath(); ctx.arc(x, y, r - 2.5 * S, 0, 6.283); ctx.clip(); ctx.globalAlpha = (dim ? .78 : 1) * na; ctx.drawImage(pim, x - r, y - r, r * 2, r * 2); ctx.restore(); ctx.strokeStyle = ring; ctx.lineWidth = 2.5 * S; ctx.beginPath(); ctx.arc(x, y, r - 1, 0, 6.283); ctx.stroke(); }
268
333
  var badge = initials(n.agent); ctx.fillStyle = '#F4F8FF'; ctx.font = '800 ' + Math.round(r * (badge.length > 3 ? .42 : badge.length > 2 ? .5 : .6)) + 'px system-ui,sans-serif'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
269
- ctx.shadowColor = 'rgba(0,0,0,.7)'; ctx.shadowBlur = 6; ctx.fillText(badge, x, y + 1); ctx.shadowBlur = 0;
334
+ if (!pim) { ctx.shadowColor = 'rgba(0,0,0,.7)'; ctx.shadowBlur = 6; ctx.fillText(badge, x, y + 1); ctx.shadowBlur = 0; }
335
+ else {
336
+ /* short tag under the portrait */
337
+ ctx.font = '800 ' + Math.round(Math.max(8, 9.5 * S)) + 'px ui-monospace,Menlo,monospace'; var bw = ctx.measureText(badge).width + 10, by2 = y + r - 1;
338
+ ctx.fillStyle = 'rgba(7,11,20,.95)'; roundRect(x - bw / 2, by2 - 7, bw, 14, 7); ctx.fill(); ctx.strokeStyle = hexA(c, .9); ctx.lineWidth = 1; ctx.stroke();
339
+ ctx.fillStyle = c; ctx.fillText(badge, x, by2 + .5);
340
+ }
341
+ drawEngine(n.agent, x - r * .74, y - r * .74, Math.max(7, 8.5 * S));
342
+ if (st === 'thinking' || st === 'idle') { var sx = x + r * .72, sy = y + r * .62; ctx.fillStyle = '#05070D'; ctx.beginPath(); ctx.arc(sx, sy, 5.5, 0, 6.283); ctx.fill(); ctx.fillStyle = st === 'thinking' ? '#4AD69A' : '#5B6B82'; ctx.beginPath(); ctx.arc(sx, sy, 3.6, 0, 6.283); ctx.fill(); }
270
343
  if (st === 'done' || st === 'failed') { var bx = x + r * .74, by = y - r * .74, bb = Math.max(6, 8 * S); ctx.fillStyle = '#05070D'; ctx.beginPath(); ctx.arc(bx, by, bb + 2, 0, 6.283); ctx.fill(); ctx.fillStyle = ring; ctx.beginPath(); ctx.arc(bx, by, bb, 0, 6.283); ctx.fill(); ctx.fillStyle = '#05070D'; ctx.font = '800 ' + Math.round(bb * 1.3) + 'px sans-serif'; ctx.fillText(st === 'done' ? '✓' : '!', bx, by + .5); }
271
344
  /* name plate: name, then engine/model, or the live step while working */
272
345
  var subs = S < .72 ? [] : thinking && n.prog && n.prog.label ? ['STEP ' + n.prog.step + (n.prog.total ? '/' + n.prog.total : '') + ' · ' + n.prog.label] : [n.agent.cli || '', n.agent.model || ''].filter(Boolean);
@@ -291,7 +364,7 @@
291
364
  var gx = ctx.createLinearGradient(pos.x - w / 2, 0, pos.x + w / 2, 0); gx.addColorStop(0, hexA(p.color, .95)); gx.addColorStop(1, hexA(p.c2, .95));
292
365
  ctx.shadowColor = p.c2; ctx.shadowBlur = 26; ctx.fillStyle = 'rgba(8,13,22,.96)'; roundRect(pos.x - w / 2, pos.y - h / 2 + bob, w, h, 9); ctx.fill();
293
366
  ctx.lineWidth = 2; ctx.strokeStyle = gx; ctx.stroke(); ctx.shadowBlur = 0;
294
- ctx.font = '18px system-ui'; ctx.textAlign = 'left'; ctx.textBaseline = 'middle'; ctx.fillStyle = '#fff'; ctx.fillText('📦', pos.x - w / 2 + 9, pos.y + 1 + bob);
367
+ ctx.font = '18px system-ui'; ctx.textAlign = 'left'; ctx.textBaseline = 'middle'; ctx.fillStyle = '#fff'; ctx.strokeStyle = p.c2; ctx.lineWidth = 1.5; ctx.strokeRect(pos.x - w / 2 + 10, pos.y - 7 + bob, 14, 14); ctx.beginPath(); ctx.moveTo(pos.x - w / 2 + 10, pos.y - 2 + bob); ctx.lineTo(pos.x - w / 2 + 24, pos.y - 2 + bob); ctx.stroke();
295
368
  ctx.font = '700 10px ui-monospace,Menlo,monospace'; ctx.fillStyle = '#9FB0C6'; ctx.fillText('HANDOFF', pos.x - w / 2 + 36, pos.y - 7 + bob);
296
369
  var t = p.title.length > 17 ? p.title.slice(0, 16) + '…' : p.title; ctx.font = '600 11px system-ui,sans-serif'; ctx.fillStyle = '#EAF2FF'; ctx.fillText(t, pos.x - w / 2 + 36, pos.y + 8 + bob);
297
370
  ctx.restore();
@@ -346,7 +419,8 @@
346
419
  requestAnimationFrame(frame);
347
420
  }
348
421
  function draw(now) {
349
- var dt = Math.max(0, Math.min(.05, (now - last) / 1000)); last = now; var tms = now - t0;
422
+ var dt = Math.max(0, Math.min(.05, (now - last) / 1000)); last = now; var tms = RM.matches ? 0 : now - t0;
423
+ if (RM.matches) { particles.length = 0; sparks.length = 0; }
350
424
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, W, H);
351
425
  ctx.drawImage(grid, 0, 0, W, H);
352
426
  var bg = ctx.createRadialGradient(hub.x, hub.y, 10, hub.x, hub.y, Math.max(W, H) * .7); bg.addColorStop(0, 'rgba(40,24,80,.28)'); bg.addColorStop(1, 'rgba(5,7,13,0)');
@@ -361,6 +435,17 @@
361
435
  var zl = zones, pairs = [['ba', 'implement'], ['implement', 'qc'], ['qc', 'ba']];
362
436
  pairs.forEach(function (p) { if (zl[p[0]] && zl[p[1]]) drawThread(zl[p[0]], zl[p[1]], -.14, null, null, .28, 1); });
363
437
  if (zl.qc && zl.implement) drawThread(zl.qc, zl.implement, .2, '#F05668', '#F3A544', .12, 1);
438
+ /* persistent Director -> team links; chip shows the latest real handoff title to that team */
439
+ Object.keys(zones).forEach(function (tid) {
440
+ var z = zones[tid], col = TEAM_COLOR[tid] || '#21D6E8';
441
+ drawThread(hub, z, -.08, '#A36BFF', col, .5, 1.6);
442
+ var t = linkTitle[tid]; if (!t) return;
443
+ var m = bez(hub, ctrl(hub, z, -.08), z, .55);
444
+ ctx.save(); ctx.font = '600 10px ui-monospace,Menlo,monospace'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
445
+ t = cut(t, 22); var tw = ctx.measureText(t).width + 16;
446
+ ctx.fillStyle = 'rgba(7,11,20,.92)'; roundRect(m.x - tw / 2, m.y - 9, tw, 18, 4); ctx.fill(); ctx.strokeStyle = hexA(col, .7); ctx.lineWidth = 1; ctx.stroke();
447
+ ctx.fillStyle = '#DCE6F5'; ctx.fillText(t, m.x, m.y + .5); ctx.restore();
448
+ });
364
449
  /* hub -> agents */
365
450
  Object.keys(nodes).forEach(function (id) { var n = nodes[id]; if (n.agent.team !== 'director') drawThread(hub, n, .1, null, null, .22, 1); });
366
451
  /* intra team */
@@ -380,7 +465,7 @@
380
465
  /* ambient */
381
466
  ctx.globalCompositeOperation = 'lighter';
382
467
  ambient.forEach(function (a) {
383
- a.x += a.vx * dt; a.y += a.vy * dt; if (a.x < 0) a.x = 1; if (a.x > 1) a.x = 0; if (a.y < 0) a.y = 1; if (a.y > 1) a.y = 0;
468
+ if (!RM.matches) { a.x += a.vx * dt; a.y += a.vy * dt; } if (a.x < 0) a.x = 1; if (a.x > 1) a.x = 0; if (a.y < 0) a.y = 1; if (a.y > 1) a.y = 0;
384
469
  ctx.fillStyle = 'rgba(150,200,255,' + (.12 + .14 * Math.sin(tms / 900 + a.p)) + ')'; ctx.beginPath(); ctx.arc(a.x * W, a.y * H, a.r, 0, 6.283); ctx.fill();
385
470
  });
386
471
  ctx.globalCompositeOperation = 'source-over';
@@ -410,6 +495,7 @@
410
495
  if (pk.t >= pk.dur) { burst(pk.b.x, pk.b.y, pk.c2, 34); flashes[pk.b.id || 'x'] = now + 1200; packages.splice(k2, 1); continue; }
411
496
  drawPackage(pk, tms);
412
497
  }
498
+ drawLabels(now);
413
499
  if (verdictFlash && verdictFlash.until > now) {
414
500
  var al2 = (verdictFlash.until - now) / 1600, q2 = zones.qc || hub;
415
501
  ctx.save(); ctx.font = '800 ' + Math.round(26 * S) + 'px ui-monospace,Menlo,monospace'; ctx.textAlign = 'center'; ctx.fillStyle = hexA(verdictFlash.color, al2);
@@ -428,11 +514,13 @@
428
514
  return {
429
515
  spawnSub: spawnSub, subActivity: subActivity, finishSub: finishSub, subCount: subCount, setAgents: setAgents, setState: setState, setStep: setStep, pulse: pulse, handoff: handoff, verdict: verdict, setStage: setStage, setActiveTeams: function (l) { dimTeams = l && l.length ? l : null; }, reset: reset, resize: resize,
430
516
  select: function (id) { selected = id; }, onSelect: function (f) { onSelect = f; }, onFrame: function (f) { onFrame = f; },
431
- setSlow: function (v) { slow = !!v; },
517
+ setSlow: function (v) { slow = !!v; }, setHubStats: function (l) { hubStats = l; },
432
518
  getNodePos: function (id) { var n = nodes[id]; if (n) return {x: n.x, y: n.y, r: n.r, w: W, h: H}; return {x: hub.x, y: hub.y, r: hub.r, w: W, h: H}; },
433
519
  zonePos: function (id) { return zones[id]; },
434
- initials: initials, TEAM_COLOR: TEAM_COLOR
520
+ initials: initials, TEAM_COLOR: TEAM_COLOR,
521
+ refreshAgents: function (list) { var m = {}; list.forEach(function (a) { m[a.id] = a; }); agents = agents.map(function (a) { return m[a.id] || a; }); Object.keys(nodes).forEach(function (k) { if (m[k]) nodes[k].agent = m[k]; }); }
435
522
  };
436
523
  }
437
- window.CKNet = {create: create, TEAM_COLOR: TEAM_COLOR, TEAM_LABEL: TEAM_LABEL};
524
+ window.CKNet = {create: create, TEAM_COLOR: TEAM_COLOR, TEAM_LABEL: TEAM_LABEL,
525
+ setAvatarResolver: function (f) { avatarResolver = f; }, setEngineResolver: function (f) { engineResolver = f; }};
438
526
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngockhoale/ckit",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "CKit — local Agent Company: a Director plus BA / Implement / QC teams running your own codex, claude and omp CLIs, with a web Mission Control (ckit gui).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,6 +9,7 @@
9
9
  "files": [
10
10
  "dist/src",
11
11
  "gui",
12
+ "!gui/assets/**/preview.png",
12
13
  "!dist/src/**/*.map",
13
14
  "!dist/src/testing",
14
15
  "!dist/src/host/t00-04-harness.*",