@ngockhoale/ckit 0.2.6 → 0.2.8
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/dist/src/adapters/launch/executor.d.ts +2 -0
- package/dist/src/adapters/launch/executor.js +12 -1
- package/dist/src/gui/server.js +1 -1
- package/dist/src/team/config.js +4 -2
- package/dist/src/team/engine.d.ts +10 -0
- package/dist/src/team/engine.js +118 -10
- package/dist/src/team/journal.d.ts +2 -0
- package/dist/src/team/journal.js +28 -3
- package/dist/src/team/runners.d.ts +4 -0
- package/dist/src/team/runners.js +16 -2
- package/dist/src/team/types.d.ts +6 -0
- package/dist/src/tui/team/model.js +2 -0
- package/gui/app.css +178 -18
- package/gui/app.js +318 -115
- package/gui/assets/ckit-oriental-avatar-pack/README.md +5 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-01.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-02.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-03.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-04.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-05.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-06.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-07.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-08.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-architect-09.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-01.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-02.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-03.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-04.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-05.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-06.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-07.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-08.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-data-ai-09.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-01.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-02.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-03.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-04.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-05.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-06.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-07.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-08.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-developer-09.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-01.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-02.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-03.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-04.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-05.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-06.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-07.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-08.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-devops-09.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-01.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-02.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-03.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-04.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-05.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-06.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-07.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-08.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-pm-09.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-01.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-02.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-03.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-04.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-05.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-06.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-07.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-08.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-qa-09.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-01.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-02.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-03.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-04.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-05.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-06.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-07.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-08.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/avatars/oriental-security-09.png +0 -0
- package/gui/assets/ckit-oriental-avatar-pack/manifest.json +447 -0
- package/gui/comic/assets/backgrounds/command-center.svg +1 -0
- package/gui/comic/assets/backgrounds/developer-workshop.svg +1 -0
- package/gui/comic/assets/backgrounds/handoff-corridor.svg +1 -0
- package/gui/comic/assets/backgrounds/incident-room.svg +1 -0
- package/gui/comic/assets/backgrounds/mission-overview.svg +1 -0
- package/gui/comic/assets/backgrounds/quality-lab.svg +1 -0
- package/gui/comic/assets/backgrounds/reporting-hall.svg +1 -0
- package/gui/comic/assets/backgrounds/research-library.svg +1 -0
- package/gui/comic/assets/backgrounds/review-chamber.svg +1 -0
- package/gui/comic/assets/backgrounds/strategy-room.svg +1 -0
- package/gui/comic/assets/effects/check-burst.svg +1 -0
- package/gui/comic/assets/effects/focus-lines.svg +1 -0
- package/gui/comic/assets/effects/glow.svg +1 -0
- package/gui/comic/assets/effects/particles.svg +1 -0
- package/gui/comic/assets/effects/speed-lines.svg +1 -0
- package/gui/comic/assets/effects/warning-flash.svg +1 -0
- package/gui/comic/assets/frame/episode-banner.svg +1 -0
- package/gui/comic/assets/frame/panel-corner.svg +1 -0
- package/gui/comic/assets/props/approval-seal.svg +1 -0
- package/gui/comic/assets/props/bug-warning.svg +1 -0
- package/gui/comic/assets/props/capsule.svg +1 -0
- package/gui/comic/assets/props/checklist.svg +1 -0
- package/gui/comic/assets/props/code-display.svg +1 -0
- package/gui/comic/assets/props/document.svg +1 -0
- package/gui/comic/assets/props/files.svg +1 -0
- package/gui/comic/assets/props/folder.svg +1 -0
- package/gui/comic/assets/props/magnifier.svg +1 -0
- package/gui/comic/assets/props/package.svg +1 -0
- package/gui/comic/assets/props/rejection-mark.svg +1 -0
- package/gui/comic/assets/props/report.svg +1 -0
- package/gui/comic/assets/props/scroll.svg +1 -0
- package/gui/comic/assets/props/shield.svg +1 -0
- package/gui/comic/assets/props/tablet.svg +1 -0
- package/gui/comic/assets/props/workstation.svg +1 -0
- package/gui/comic/comic.css +130 -0
- package/gui/comic/contact-sheet.html +15 -0
- package/gui/comic/contact-sheet.js +41 -0
- package/gui/comic/engine.js +366 -0
- package/gui/comic/manifests/backgrounds.json +216 -0
- package/gui/comic/manifests/characters.json +96 -0
- package/gui/comic/manifests/effects.json +96 -0
- package/gui/comic/manifests/props.json +246 -0
- package/gui/comic/manifests/scenes.json +205 -0
- package/gui/comic/render.js +594 -0
- package/gui/index.html +30 -14
- package/gui/network.js +253 -254
- package/package.json +2 -1
package/gui/app.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
Object.keys(attrs || {}).forEach(function (k) {
|
|
16
16
|
var v = attrs[k]; if (v === false || v == null) return;
|
|
17
17
|
if (k === 'class') e.className = v; else if (k === 'text') e.textContent = v; else if (k.slice(0, 2) === 'on') e.addEventListener(k.slice(2), v);
|
|
18
|
-
else if (k === 'style') e.setAttribute('
|
|
18
|
+
else if (k === 'style' || k === 'role' || k.indexOf('-') > 0) e.setAttribute(k, v === true ? '' : String(v)); else e[k] = v === true ? true : v;
|
|
19
19
|
});
|
|
20
20
|
(kids || []).forEach(function (c) { if (c != null) e.appendChild(typeof c === 'string' ? document.createTextNode(c) : c); });
|
|
21
21
|
return e;
|
|
@@ -69,18 +69,80 @@
|
|
|
69
69
|
cfgAgents(cfg).forEach(function (a) { S.order.push(a.id); S.agents[a.id] = {cfg: a, state: 'idle', task: '', activity: '', step: 0, total: null, label: '', tokens: 0, t0: 0, spark: [], outputs: [], subs: {}, msgs: 0}; });
|
|
70
70
|
net.setAgents(cfgAgents(cfg));
|
|
71
71
|
}
|
|
72
|
+
/* comic: the renderer (gui/comic/render.js) owns the panels; the engine decides what each event becomes */
|
|
73
|
+
function comicCtx(cfg) {
|
|
74
|
+
if (!cfg) return;
|
|
75
|
+
try {
|
|
76
|
+
var ag = {}, tm = {director: {name: 'Director'}, ba: {name: 'BA'}, implement: {name: 'Implement'}, qc: {name: 'QC'}};
|
|
77
|
+
extrasOf(cfg).forEach(function (t) { tm[t.id] = {name: t.name}; });
|
|
78
|
+
cfgAgents(cfg).forEach(function (a) { ag[a.id] = {name: a.name, team: a.team, short: net.initials(a)}; });
|
|
79
|
+
comicCall('setContext', {agents: ag, teams: tm, directorId: cfg.director.id});
|
|
80
|
+
} catch (err) { if (window.console) console.warn('comic context skipped:', err); }
|
|
81
|
+
}
|
|
82
|
+
var comicWarned = false;
|
|
83
|
+
function comicCall(m, a) { try { comic[m](a); } catch (err) { if (!comicWarned) { comicWarned = true; if (window.console) console.warn('comic disabled for this call:', err); } } }
|
|
84
|
+
var comic;
|
|
85
|
+
try {
|
|
86
|
+
if (!window.CKComic || !window.CKComicEngine) throw new Error('comic scripts missing');
|
|
87
|
+
comic = window.CKComic.create($('comicpanels'), {
|
|
88
|
+
avatarUrl: function (id) { return A(id) ? avatarUrl(avatarId(A(id).cfg)) : ''; },
|
|
89
|
+
agentInfo: function (id) { var a = A(id); if (!a) return {name: String(id), short: String(id).slice(0, 2).toUpperCase(), team: 'director', color: '#8A9AAF'}; return {name: a.cfg.name, short: net.initials(a.cfg), team: a.cfg.team, color: TC[a.cfg.team] || '#8A9AAF', cli: a.cfg.cli, model: a.cfg.model}; },
|
|
90
|
+
teamColor: function (t) { return TC[t] || TC.director; },
|
|
91
|
+
teamName: function (t) { return t === 'director' ? 'Director' : teamLbl(t); }
|
|
92
|
+
});
|
|
93
|
+
} catch (err) {
|
|
94
|
+
if (window.console) console.warn('comic unavailable:', err);
|
|
95
|
+
comic = {push: function () {}, reset: function () {}, setContext: function () {}, setHistory: function () {}, setMotion: function () {}};
|
|
96
|
+
}
|
|
72
97
|
function resetRun() {
|
|
73
98
|
S.events = []; S.atts = []; S.fails = []; S.msgs = 0; S.tokens = 0; S.stageIdx = -1; S.stageKey = ''; S.loop = 1; S.stageTimes = {}; S.started = 0; S.ended = 0; S.outcome = null; S.handoffs = []; S.flowBacks = []; S.verdicts = []; S.buckets = []; S.tokBuckets = []; S.lastStageAt = 0; S.narr = '';
|
|
74
|
-
$('feed').innerHTML = '';
|
|
99
|
+
$('feed').innerHTML = ''; comicCall('reset'); $('bubbles').innerHTML = ''; S.bubbles = {}; S.lastPanelSub = {};
|
|
75
100
|
$('overlay').hidden = true; $('hobanner').classList.remove('on');
|
|
76
101
|
S.lane = null; S.laneBy = ''; S.waiting = null; net.setActiveTeams(null);
|
|
77
|
-
if (S.config) setupAgents(S.config);
|
|
102
|
+
if (S.config) { setupAgents(S.config); comicCtx(S.config); }
|
|
78
103
|
net.reset(); setNarr('Waiting for a mission…'); S.dirty = true;
|
|
79
104
|
}
|
|
80
105
|
function A(id) { return S.agents[id]; }
|
|
81
106
|
function nm(id) { return A(id) ? A(id).cfg.name : id === 'all' ? 'everyone' : TL[id] || id; }
|
|
82
107
|
function tcol(id) { return A(id) ? TC[A(id).cfg.team] || '#8A9AAF' : TC[id] || '#8A9AAF'; }
|
|
83
108
|
function ini(id) { return A(id) ? net.initials(A(id).cfg) : '?'; }
|
|
109
|
+
/* avatars: one shared helper. Ids come from the bundled pack (gui/assets/ckit-oriental-avatar-pack); any role may use any avatar. */
|
|
110
|
+
var AV_BASE = '/assets/ckit-oriental-avatar-pack/', AVATARS = [], AV_CATS = ['architect', 'data-ai', 'developer', 'devops', 'pm', 'qa', 'security'];
|
|
111
|
+
var TEAM_CAT = {director: 'pm', ba: 'architect', implement: 'developer', qc: 'qa'}, XCAT = ['data-ai', 'devops', 'security'];
|
|
112
|
+
var AV_RE = /^[a-z0-9-]{1,64}$/, RM = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {matches: false};
|
|
113
|
+
fetch(AV_BASE + 'manifest.json').then(function (r) { return r.ok ? r.json() : null; }).then(function (m) { if (m && Array.isArray(m.avatars)) { AVATARS = m.avatars.filter(function (a) { return a && AV_RE.test(a.id); }); S.dirty = true; } }).catch(function () { /* offline-safe: initials fallback */ });
|
|
114
|
+
/* stable default: team category + position inside the team (01..09); an explicit cfg.avatar always wins */
|
|
115
|
+
function avatarId(cfg) {
|
|
116
|
+
if (!cfg) return '';
|
|
117
|
+
if (cfg.avatar && AV_RE.test(cfg.avatar)) return cfg.avatar;
|
|
118
|
+
var cat = TEAM_CAT[cfg.team];
|
|
119
|
+
if (!cat) { var xi = extrasOf(S.config).map(function (t) { return t.id; }).indexOf(cfg.team); cat = XCAT[(xi < 0 ? 0 : xi) % XCAT.length]; }
|
|
120
|
+
var mates = S.config ? cfgAgents(S.config).filter(function (a) { return a.team === cfg.team; }).map(function (a) { return a.id; }) : [], i = mates.indexOf(cfg.id);
|
|
121
|
+
if (i < 0) { i = 0; for (var k = 0; k < String(cfg.id).length; k++) i = (i * 31 + String(cfg.id).charCodeAt(k)) % 9; }
|
|
122
|
+
return 'oriental-' + cat + '-' + String(i % 9 + 1).padStart(2, '0');
|
|
123
|
+
}
|
|
124
|
+
function avatarUrl(id) { return id && AV_RE.test(id) ? AV_BASE + 'avatars/' + id + '.png' : ''; }
|
|
125
|
+
/* engine identity: one registry, text marks (no emoji) */
|
|
126
|
+
var ENG = {'claude-code': {mark: 'C', color: '#E8875B', label: 'Claude Code'}, codex: {mark: 'X', color: '#DCE6F5', label: 'Codex'}, omp: {mark: 'O', color: '#4AD69A', label: 'omp'},
|
|
127
|
+
api: {mark: 'A', color: '#4F8CFF', label: 'API'}, auto: {mark: 'D', color: '#A36BFF', label: 'Built-in'}, simulated: {mark: 'S', color: '#8A9AAF', label: 'Simulated'}};
|
|
128
|
+
function eng(cli) { return ENG[cli] || {mark: '?', color: '#8A9AAF', label: String(cli || 'unknown')}; }
|
|
129
|
+
window.CKNet.setAvatarResolver(function (a) { return avatarUrl(avatarId(a)); });
|
|
130
|
+
window.CKNet.setEngineResolver(function (a) { return eng(a.cli); });
|
|
131
|
+
var IMGC = {};
|
|
132
|
+
/* avatar block: portrait (initials if the image is missing), engine badge, status dot. slot keeps one live node per place so 400 ms re-renders do not flicker. */
|
|
133
|
+
function avatarEl(cfg, size, opt) {
|
|
134
|
+
opt = opt || {}; var c = TC[cfg.team] || '#8A9AAF', url = avatarUrl(opt.id || avatarId(cfg)), e = eng(cfg.cli);
|
|
135
|
+
var box = h('div', {class: 'ava' + (opt.cls ? ' ' + opt.cls : ''), style: '--s:' + size + 'px;--tc:' + c + ';--tg:' + hexA(c, .35)});
|
|
136
|
+
var fb = h('span', {class: 'ini', text: net.initials(cfg)});
|
|
137
|
+
if (url) {
|
|
138
|
+
var key = (opt.slot || '') + '|' + url, im = opt.slot && IMGC[key];
|
|
139
|
+
if (!im) { im = h('img', {src: url, alt: '', loading: 'lazy', decoding: 'async', draggable: false}); im.addEventListener('error', function () { im.dataset.bad = '1'; im.replaceWith(h('span', {class: 'ini', text: net.initials(cfg)})); }); if (opt.slot) IMGC[key] = im; }
|
|
140
|
+
box.appendChild(im.dataset.bad ? fb : im);
|
|
141
|
+
} else box.appendChild(fb);
|
|
142
|
+
if (!opt.noEngine) box.appendChild(h('span', {class: 'eng', title: e.label, style: '--ec:' + e.color, text: e.mark}));
|
|
143
|
+
if (opt.state) box.appendChild(h('span', {class: 'dot ' + opt.state, title: opt.state}));
|
|
144
|
+
return box;
|
|
145
|
+
}
|
|
84
146
|
function setNarr(t) { S.narr = t; $('nowtext').textContent = t; $('now').classList.toggle('ask', !!S.waiting); }
|
|
85
147
|
|
|
86
148
|
function activeSubs() { var n = 0; S.order.forEach(function (id) { Object.keys(A(id).subs).forEach(function (k) { if (A(id).subs[k].state === 'run') n++; }); }); return n; }
|
|
@@ -113,14 +175,15 @@
|
|
|
113
175
|
var full = text, flat = plain(full), long = flat.length > 150, show = long ? flat.slice(0, 149) + '…' : flat, col = tcol(id);
|
|
114
176
|
var el = h('div', {class: 'bub', style: '--bc:' + col + ';--bg2:' + hexA(col, .5) + ';--bg3:' + hexA(col, .22)});
|
|
115
177
|
var body = h('span'), cur = h('span', {class: 'cur', text: '▍'});
|
|
116
|
-
el.appendChild(h('div', {class: 'who'}, [
|
|
178
|
+
el.appendChild(h('div', {class: 'who'}, [avatarEl(n.cfg, 22, {noEngine: true}), h('b', {text: nm(id)}), h('em', {text: '→ ' + nm(to)})]));
|
|
117
179
|
el.appendChild(h('div', {class: 'btx'}, [body, cur]));
|
|
118
180
|
if (long) el.appendChild(h('div', {class: 'more', text: 'Read full message ⤢'}));
|
|
119
181
|
el.addEventListener('click', function () { showMessage({from: id, to: to, at: e.at, tokens: e.tokens, text: full}); });
|
|
120
182
|
var rec = {el: el, hover: false, id: id, typed: 0};
|
|
121
183
|
el.addEventListener('mouseenter', function () { rec.hover = true; }); el.addEventListener('mouseleave', function () { rec.hover = false; if (rec.typed) rec.typed = performance.now() - 3000; });
|
|
122
184
|
$('bubbles').appendChild(el); S.bubbles[id] = rec;
|
|
123
|
-
|
|
185
|
+
if (RM.matches) { body.textContent = show; rec.typed = performance.now(); }
|
|
186
|
+
else { var i = 0; rec.timer = setInterval(function () { i += 1; body.textContent = show.slice(0, i); if (i >= show.length) { clearInterval(rec.timer); rec.typed = performance.now(); } }, 26); }
|
|
124
187
|
placeBubble(rec);
|
|
125
188
|
}
|
|
126
189
|
function placeBubble(rec) {
|
|
@@ -182,13 +245,15 @@
|
|
|
182
245
|
|
|
183
246
|
/* reducer */
|
|
184
247
|
function onEvent(e) {
|
|
248
|
+
if (e.type === 'run.started') comicCtx(e.config);
|
|
249
|
+
comicCall('push', e);
|
|
185
250
|
S.events.push(e); S.dirty = true;
|
|
251
|
+
if (e.type !== 'agent.message') termLine(e.at, e.type + (e.agentId ? ' ' + e.agentId : '') + (e.stage ? ' ' + e.stage : '') + (e.from ? ' ' + e.from + '→' + e.to : '') + (e.verdict ? ' ' + e.verdict : '') + (e.label ? ' · ' + e.label : e.text && e.type !== 'user.message' ? ' · ' + plain(String(e.text)).slice(0, 120) : ''));
|
|
186
252
|
var now = performance.now(), a = e.agentId ? A(e.agentId) : null;
|
|
187
253
|
if (e.type === 'run.started') {
|
|
188
254
|
S.started = Date.parse(e.at); S.config = e.config; S.simulated = e.simulated; S.run = S.run || {}; S.run.runId = e.runId; S.run.goal = e.goal; S.run.running = true; S.lane = null; S.laneBy = ''; net.setActiveTeams(null); setupAgents(e.config);
|
|
189
255
|
$('goal').textContent = e.goal; $('goal').title = e.goal; $('runid').textContent = e.runId.replace('team-', '');
|
|
190
256
|
setNarr('Mission: ' + e.goal.slice(0, 120)); feedBanner('dir', '◆ MISSION STARTED — ' + e.goal); feedAtts(e.attachments);
|
|
191
|
-
comicCaption('Episode 1: ' + e.goal.slice(0, 90), 'director');
|
|
192
257
|
}
|
|
193
258
|
S.lastAt = Date.parse(e.at);
|
|
194
259
|
if (S.waiting && (e.type === 'agent.started' || e.type === 'user.message' || e.type === 'run.completed' || e.type === 'stage.changed')) { S.waiting = null; if (e.type !== 'run.completed') setNarr('Director is working on your answer…'); }
|
|
@@ -200,7 +265,6 @@
|
|
|
200
265
|
if (prevKey && S.lastStageAt) S.stageTimes[prevKey + (e.loop > 1 && (prevKey === 'implement' || prevKey === 'qc') ? '#' + e.loop : '')] = Date.parse(e.at) - S.lastStageAt;
|
|
201
266
|
S.stageKey = key; S.lastStageAt = Date.parse(e.at); S.loop = e.loop; S.stageIdx = idx; net.setStage(idx, e.loop, sl.length); narrate(xt ? 'extra-team' : e.stage);
|
|
202
267
|
feedPhase(xt ? xt.name + ' team at work' + (e.loop > 1 ? ' · loop ' + e.loop : '') : PHASE[e.stage] + (e.loop > 1 ? ' · loop ' + e.loop : ''), xt ? xt.id : STAGE_TEAM[e.stage]);
|
|
203
|
-
comicCaption(e.stage === 'review' ? 'The Director checks the result against your request…' : xt ? 'Meanwhile, at Team ' + xt.name + '…' : ['Meanwhile, at the Director’s desk…', 'Team BA huddles to debate the requirements…', 'Meanwhile, at Team IMPLEMENT…' + (e.loop > 1 ? ' (round ' + e.loop + ')' : ''), 'Meanwhile, at Team QC…', 'The Director prepares the final report…'][e.stage === 'director-intake' ? 0 : e.stage === 'ba-discussion' ? 1 : e.stage === 'implement' ? 2 : e.stage === 'qc' ? 3 : 4], xt ? xt.id : STAGE_TEAM[e.stage]);
|
|
204
268
|
break;
|
|
205
269
|
}
|
|
206
270
|
case 'agent.started':
|
|
@@ -211,41 +275,40 @@
|
|
|
211
275
|
case 'agent.message':
|
|
212
276
|
S.msgs++; S.tokens += e.tokens || 0; if (a) { a.state = 'done'; a.tokens += e.tokens || 0; a.msgs++; a.label = ''; a.outputs.unshift({text: e.text, to: e.to, at: e.at, tokens: e.tokens}); a.outputs.length = Math.min(a.outputs.length, 5); net.setState(e.agentId, 'done'); a.activity = 'finished turn'; }
|
|
213
277
|
S.tokBuckets.push([Date.parse(e.at), S.tokens]); S.buckets.push(Date.parse(e.at));
|
|
214
|
-
if (!S.history) { net.pulse(e.agentId, e.to === 'all' ? S.config.director.id : e.to); bubbleFor(e.agentId, e.text, e, e.to); }
|
|
215
|
-
|
|
278
|
+
if (!S.history) { net.pulse(e.agentId, e.to === 'all' || e.to === 'director' ? S.config.director.id : e.to, undefined, e.round ? 'Round ' + e.round : plain(e.text).slice(0, 20)); bubbleFor(e.agentId, e.text, e, e.to); }
|
|
279
|
+
termLine(e.at, nm(e.agentId) + ' → ' + nm(e.to) + (e.tokens ? ' (' + e.tokens + ' tok)' : '') + ': ' + plain(e.text).slice(0, 160));
|
|
280
|
+
feedMsg(e);
|
|
216
281
|
break;
|
|
217
282
|
case 'agent.failed': if (a) { a.state = 'failed'; a.activity = e.reason; net.setState(e.agentId, 'failed'); } S.fails.push(e); feedBanner('fail', '✕ ' + nm(e.agentId) + ' failed: ' + plain(e.reason).slice(0, 220) + ' (click for details)', function () { showFailure(); }); break;
|
|
218
283
|
case 'handoff.created':
|
|
219
|
-
S.handoffs.push(e); if (!S.history) { net.handoff(e.from, e.to, e.title); showHoBanner('
|
|
220
|
-
feedBanner('ho', '
|
|
221
|
-
S.order.forEach(function (id) { if (A(id).cfg.team === e.from) { A(id).state = 'idle'; net.setState(id, 'idle'); } });
|
|
284
|
+
S.handoffs.push(e); if (!S.history) { net.handoff(e.from, e.to, e.title); showHoBanner('HANDOFF ' + TL[e.from] + ' → ' + TL[e.to]); }
|
|
285
|
+
feedBanner('ho', '⇢ HANDOFF ' + teamLbl(e.from) + ' → ' + teamLbl(e.to) + ' · ' + e.title, e.text ? function () { showMessage({from: e.from, to: e.to, at: e.at, text: e.text}); } : null);
|
|
286
|
+
if (e.from !== 'director') S.order.forEach(function (id) { if (A(id).cfg.team === e.from) { A(id).state = 'idle'; net.setState(id, 'idle'); } });
|
|
222
287
|
break;
|
|
223
288
|
case 'flow.back': {
|
|
224
289
|
var fb = e.kind === 'ask' ? '? ' + teamLbl(e.from) + ' asked ' + teamLbl(e.to) + ': ' + e.reason : '↩ ' + teamLbl(e.from) + ' returned to ' + teamLbl(e.to) + ': ' + e.reason;
|
|
225
290
|
S.flowBacks.push(e); feedBanner(e.kind === 'ask' ? 'ask' : 'ret', fb);
|
|
226
|
-
comicSimple(e.kind === 'ask' ? 'director' : 'you', (e.kind === 'ask' ? 'ASK-BACK · ' : 'RETURN · ') + teamLbl(e.from) + ' → ' + teamLbl(e.to), e.reason);
|
|
227
291
|
break;
|
|
228
292
|
}
|
|
229
293
|
case 'qc.verdict': S.verdicts.push(e); if (!S.history) net.verdict(e.verdict);
|
|
230
294
|
feedBanner(e.verdict === 'PASS' ? 'pass' : 'fail', (e.verdict === 'PASS' ? '✔ QC PASS' : '✕ QC FAIL') + ' · loop ' + e.loop + ' — ' + e.summary);
|
|
231
|
-
|
|
295
|
+
setNarr(e.verdict === 'FAIL' ? 'QC phát hiện lỗi → trả về Implement để sửa.' : 'QC PASS — sản phẩm đạt yêu cầu!');
|
|
232
296
|
break;
|
|
233
|
-
case 'user.message': feedBanner('you', '▸ OWNER: ' + e.text); feedAtts(e.attachments);
|
|
234
|
-
case 'director.
|
|
297
|
+
case 'user.message': feedBanner('you', '▸ OWNER: ' + e.text); feedAtts(e.attachments); break;
|
|
298
|
+
case 'director.consult': feedBanner('dir', '◆ Director consults ' + nm(e.agentId) + ': ' + e.question); if (!S.history) net.pulse(S.config.director.id, e.agentId, undefined, e.question.slice(0, 24)); break;
|
|
299
|
+
case 'director.decision': feedBanner('dir', '◆ DIRECTOR ' + e.decision.toUpperCase() + ' — ' + e.note); break;
|
|
235
300
|
case 'lane.chosen': {
|
|
236
301
|
var ln = ((S.config && S.config.lanes) || []).filter(function (l) { return l.id === e.laneId; })[0];
|
|
237
302
|
S.lane = ln ? {id: ln.id, name: ln.name, order: ln.order.slice()} : {id: e.laneId, name: e.name, order: []}; S.laneBy = e.by; net.setActiveTeams(S.lane.order);
|
|
238
303
|
feedBanner('dir', e.by === 'owner' ? '◆ Owner fixed lane ' + e.name : e.by === 'fallback' ? '◆ Lane chosen by fallback: ' + e.name + (e.reason ? ' · ' + e.reason : '') : '◆ Director chose lane ' + e.name + ': ' + e.reason);
|
|
239
|
-
comicSimple('director', 'LANE · ' + e.name, e.reason || e.by);
|
|
240
304
|
break;
|
|
241
305
|
}
|
|
242
306
|
case 'review.verdict': S.verdicts.push(e); if (!S.history) net.verdict(e.verdict);
|
|
243
307
|
feedBanner(e.verdict === 'PASS' ? 'pass' : 'fail', 'Director review · ' + e.verdict + ' — ' + e.summary);
|
|
244
|
-
comicSimple('director', 'DIRECTOR REVIEW · ' + e.verdict, e.summary);
|
|
245
308
|
break;
|
|
246
309
|
case 'run.waiting': S.waiting = {round: e.round, questions: e.questions, assumptions: e.assumptions, team: e.team || ''}; feedQuestions(e); setNarr('Director needs your answer'); break;
|
|
247
310
|
case 'subagent.started':
|
|
248
|
-
if (a) { a.subs[e.childId] = {kind: e.kind || 'sub', text: e.task, state: 'run'}; net.spawnSub(e.agentId, e.childId, e.kind); feedSub(e.agentId, '◆ spawned ' + (e.kind || 'subagent') + ': ' + e.task);
|
|
311
|
+
if (a) { a.subs[e.childId] = {kind: e.kind || 'sub', text: e.task, state: 'run'}; net.spawnSub(e.agentId, e.childId, e.kind); feedSub(e.agentId, '◆ spawned ' + (e.kind || 'subagent') + ': ' + e.task); }
|
|
249
312
|
break;
|
|
250
313
|
case 'subagent.activity': if (a && a.subs[e.childId]) { a.subs[e.childId].text = e.text; net.subActivity(e.childId, e.text); } break;
|
|
251
314
|
case 'subagent.finished': if (a && a.subs[e.childId]) { a.subs[e.childId].state = e.ok ? 'done' : 'failed'; net.finishSub(e.childId, e.ok); feedSub(e.agentId, (e.ok ? '✓ ' : '✕ ') + a.subs[e.childId].kind + ': ' + e.summary); } break;
|
|
@@ -255,7 +318,7 @@
|
|
|
255
318
|
if (e.outcome === 'delivered') { var sl2 = stageList(S.config); S.stageIdx = sl2.length; S.stageKey = 'done'; net.setStage(sl2.length, S.loop, sl2.length); }
|
|
256
319
|
S.order.forEach(function (id) { if (A(id).state === 'thinking') { A(id).state = 'idle'; net.setState(id, 'idle'); } });
|
|
257
320
|
if (e.outcome === 'declined') feedBanner('fail', '◆ Director could not take this request');
|
|
258
|
-
setNarr(e.outcome === 'delivered' ? 'MISSION DELIVERED ✔' : e.outcome === 'declined' ? 'Director could not take this request' : 'Run ended: ' + e.outcome + (e.outcome === 'failed' ? ' · click to see why' : '')); $('now').classList.toggle('click', e.outcome === 'failed');
|
|
321
|
+
setNarr(e.outcome === 'delivered' ? 'MISSION DELIVERED ✔' : e.outcome === 'declined' ? 'Director could not take this request' : 'Run ended: ' + e.outcome + (e.outcome === 'failed' ? ' · click to see why' : '')); $('now').classList.toggle('click', e.outcome === 'failed');
|
|
259
322
|
showOverlay(e);
|
|
260
323
|
break;
|
|
261
324
|
}
|
|
@@ -264,10 +327,49 @@
|
|
|
264
327
|
function bump(a) { a.spark.push(Date.now()); if (a.spark.length > 80) a.spark.shift(); }
|
|
265
328
|
|
|
266
329
|
/* feed */
|
|
267
|
-
|
|
330
|
+
/* auto-scroll only while the reader is already at the bottom; reading older messages is never interrupted */
|
|
331
|
+
var feedStick = true;
|
|
332
|
+
$('feed').addEventListener('scroll', function () { var f = $('feed'); feedStick = f.scrollHeight - f.scrollTop - f.clientHeight < 48; });
|
|
333
|
+
function feedScroll() { var f = $('feed'); if (feedStick) f.scrollTop = f.scrollHeight; trimFeed(f); }
|
|
334
|
+
function trimFeed(f) { while (f.childElementCount > 600) f.removeChild(f.firstElementChild); }
|
|
335
|
+
/* terminal: bounded raw event stream (text only) */
|
|
336
|
+
var TERM = [], termDirty = false;
|
|
337
|
+
function termLine(at, t) { TERM.push(clock(at) + ' ' + String(t).replace(/[\u0000-\u0008\u000b-\u001f]/g, '')); if (TERM.length > 400) TERM.splice(0, TERM.length - 400); termDirty = true; }
|
|
338
|
+
function flushTerm() { var el = $('term'); if (!termDirty || el.hidden) return; termDirty = false; var stick = el.scrollHeight - el.scrollTop - el.clientHeight < 40; el.textContent = TERM.join('\n'); if (stick) el.scrollTop = el.scrollHeight; }
|
|
339
|
+
/* conversation tabs: All + one per agent; same selection as roster / topology */
|
|
340
|
+
var curTab = '';
|
|
341
|
+
function setTab(id) {
|
|
342
|
+
curTab = id && A(id) ? id : ''; $('feed').dataset.filter = curTab;
|
|
343
|
+
Array.prototype.forEach.call($('feed').children, function (n) { n.classList.toggle('fhide', !!curTab && n.dataset.agent !== curTab); });
|
|
344
|
+
renderTabs();
|
|
345
|
+
if (curTab) { var f = $('feed'); f.scrollTop = f.scrollHeight; feedStick = true; }
|
|
346
|
+
}
|
|
347
|
+
function renderTabs() {
|
|
348
|
+
var box = $('ctabs'), ids = S.order.slice(0, 12), sig = curTab + '|' + ids.join(',');
|
|
349
|
+
if (box.dataset.sig === sig) return; box.dataset.sig = sig; box.innerHTML = '';
|
|
350
|
+
var mk = function (id, label, col, cfg) {
|
|
351
|
+
var on = curTab === id, b = h('button', {class: 'ctab' + (on ? ' on' : ''), type: 'button', role: 'tab', 'aria-selected': String(on), style: col ? '--tc:' + col : '', title: id ? 'Show only ' + label : 'Show the whole conversation', onclick: function () { selectAgent(id || null); }}, [cfg ? avatarEl(cfg, 18, {noEngine: true, slot: 't'}) : null, h('span', {text: label})]);
|
|
352
|
+
box.appendChild(b);
|
|
353
|
+
};
|
|
354
|
+
mk('', 'All', '', null);
|
|
355
|
+
ids.forEach(function (id) { var a = A(id); mk(id, a.cfg.name, tcol(id), a.cfg); });
|
|
356
|
+
box.appendChild(h('button', {class: 'ctab add', type: 'button', text: '+', title: 'Add an agent (opens Config)', 'aria-label': 'Add an agent', onclick: function () { setView('settings'); }}));
|
|
357
|
+
}
|
|
358
|
+
function dockView(v) {
|
|
359
|
+
UI.dockView = v; saveUI();
|
|
360
|
+
var fa = $('feedarea'), term = v === 'term' || v === 'split';
|
|
361
|
+
fa.classList.toggle('split', v === 'split'); fa.classList.toggle('termonly', v === 'term');
|
|
362
|
+
$('term').hidden = !term; $('feed').hidden = v === 'term';
|
|
363
|
+
$('bSplit').setAttribute('aria-pressed', String(v === 'split')); $('bTerm').setAttribute('aria-pressed', String(v === 'term'));
|
|
364
|
+
$('bSplit').classList.toggle('on', v === 'split'); $('bTerm').classList.toggle('on', v === 'term');
|
|
365
|
+
termDirty = true; flushTerm();
|
|
366
|
+
}
|
|
367
|
+
/* view toggles only change what is shown; they never touch the run or an agent session */
|
|
368
|
+
$('bSplit').onclick = function () { dockView(UI.dockView === 'split' ? 'chat' : 'split'); };
|
|
369
|
+
$('bTerm').onclick = function () { dockView(UI.dockView === 'term' ? 'chat' : 'term'); };
|
|
268
370
|
function teamLbl(id) { if (id === 'director') return 'Director'; var t = extrasOf(S.config).filter(function (x) { return x.id === id; })[0]; return t ? t.name : ({ba: 'BA', implement: 'Implement', qc: 'QC'})[id] || id; }
|
|
269
371
|
function feedPhase(t, team) { $('feed').appendChild(h('div', {class: 'fphase', style: 'color:' + TC[team], text: '▍' + t})); feedScroll(); }
|
|
270
|
-
function feedBanner(kind, t, onclick) { $('feed').appendChild(h('div', {class: 'fban ' + kind + (onclick ? ' click' : ''), text: t, onclick: onclick})); feedScroll(); count(); }
|
|
372
|
+
function feedBanner(kind, t, onclick) { $('feed').appendChild(h('div', {class: 'fban ' + kind + (onclick ? ' click' : '') + (curTab ? ' fhide' : ''), text: t, onclick: onclick})); feedScroll(); count(); }
|
|
271
373
|
function fmtSize(n) { return n >= 1048576 ? (n / 1048576).toFixed(1) + ' MB' : n >= 1024 ? Math.round(n / 1024) + ' KB' : n + ' B'; }
|
|
272
374
|
function attUrl(a) { return '/api/runs/' + encodeURIComponent((S.run && S.run.runId) || 'current') + '/attachment/' + encodeURIComponent(a.name) + '?t=' + encodeURIComponent(TOKEN); }
|
|
273
375
|
/* a stored attachment: thumbnail for images, name + size for everything else; click opens / downloads it */
|
|
@@ -288,55 +390,25 @@
|
|
|
288
390
|
h('div', {class: 'qhint', text: as.length ? 'Type your answer in the ANSWER box (you can attach files and use @), or choose Proceed with assumptions.' : e.team ? 'Type your answer in the ANSWER box (you can attach files and use @). The run is paused until you answer.' : 'Type your answer in the ANSWER box (you can attach files and use @). No team starts until you answer.'}),
|
|
289
391
|
h('button', {class: 'primary qgo', type: 'button', text: 'Answer now ▸', onclick: function () { $('msg').focus(); }})])); feedScroll(); count();
|
|
290
392
|
}
|
|
291
|
-
function feedSub(parent, t) { $('feed').appendChild(h('div', {class: 'fsub', text: '↳ ' + nm(parent) + ' ' + t})); feedScroll(); }
|
|
393
|
+
function feedSub(parent, t) { $('feed').appendChild(h('div', {class: 'fsub' + (curTab && curTab !== parent ? ' fhide' : ''), 'data-agent': parent, text: '↳ ' + nm(parent) + ' ' + t})); feedScroll(); }
|
|
292
394
|
function count() { $('feedcount').textContent = S.events.filter(function (e) { return e.type === 'agent.message'; }).length + ' MESSAGES'; }
|
|
293
395
|
function typeInto(el, text) {
|
|
294
396
|
if (S.history) { el.textContent = text; return; }
|
|
295
|
-
|
|
397
|
+
if (RM.matches) { el.textContent = text; return; }
|
|
398
|
+
/* typewriter: one character per tick, long texts speed up so a message never takes more than ~6 s */
|
|
399
|
+
var i = 0, step = Math.max(1, Math.ceil(text.length / 240)), t = setInterval(function () { i += step; el.textContent = text.slice(0, i); feedScroll(); if (i >= text.length) clearInterval(t); }, 24);
|
|
296
400
|
}
|
|
297
401
|
function feedMsg(e) {
|
|
298
402
|
var col = tcol(e.agentId), short = plain(e.text); if (short.length > 280) short = short.slice(0, 279) + '…';
|
|
299
403
|
var txt = h('div', {class: 'ft'});
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
404
|
+
var a = A(e.agentId), arts = (e.text.match(/(?:^|[\s`(])((?:[\w.-]+\/)*[\w-]+\.(?:ts|js|mjs|tsx|jsx|vue|css|html|json|md|py|go|rs|java|sql|yml|yaml|sh|txt))(?=[\s`),.:;]|$)/g) || []).map(function (x) { return x.replace(/^[\s`(]/, ''); }).filter(function (x, i, l) { return l.indexOf(x) === i; }).slice(0, 4);
|
|
405
|
+
var row = h('div', {class: 'fm' + (curTab && curTab !== e.agentId ? ' fhide' : ''), 'data-agent': e.agentId, role: 'button', tabIndex: 0, style: '--tc:' + col + ';--tg:' + hexA(col, .3) + ';--tg2:' + hexA(col, .1), onclick: function () { showMessage({from: e.agentId, to: e.to, at: e.at, tokens: e.tokens, text: e.text}); }, onkeydown: function (ev) { if (ev.key === 'Enter') this.click(); }}, [
|
|
406
|
+
a ? avatarEl(a.cfg, 48, {cls: 'fava'}) : h('div', {class: 'fav', text: ini(e.agentId)}),
|
|
407
|
+
h('div', {class: 'fb'}, [h('div', {class: 'fh'}, [h('b', {text: nm(e.agentId)}), h('span', {class: 'to', text: '→ ' + nm(e.to)}), e.round ? h('span', {class: 'rnd', text: 'round ' + e.round}) : null, h('span', {class: 'tm', text: clock(e.at) + (e.tokens ? ' · ' + e.tokens + ' tok' : '')})]), txt, arts.length ? h('div', {class: 'farts'}, arts.map(function (f) { return h('span', {class: 'fart mono', title: 'File named in this message', text: f}); })) : null])]);
|
|
303
408
|
$('feed').appendChild(row); typeInto(txt, short); feedScroll(); count();
|
|
304
409
|
}
|
|
305
410
|
|
|
306
|
-
|
|
307
|
-
function panelEl(team, cls) { var c = TC[team] || TC.director; return h('div', {class: 'panel ' + (cls || ''), style: '--pc:' + c + ';--pg:' + hexA(c, .35)}); }
|
|
308
|
-
function addPanel(p) { $('comicpanels').appendChild(p); var c = $('comic'); if (!c.hidden) c.scrollTop = c.scrollHeight; }
|
|
309
|
-
function comicCaption(t, team) { var p = panelEl(team, 'wide'); p.appendChild(h('div', {class: 'cap', text: t})); addPanel(p); }
|
|
310
|
-
function comicSimple(team, who, text) {
|
|
311
|
-
var p = panelEl(team); p.appendChild(h('div', {class: 'cap', text: who}));
|
|
312
|
-
p.appendChild(h('div', {class: 'cscene'}, [h('div', {class: 'cav', text: who[0]}), h('div', {class: 'cbub', text: text.slice(0, 200)})])); addPanel(p);
|
|
313
|
-
}
|
|
314
|
-
function comicMsg(e) {
|
|
315
|
-
var a = A(e.agentId), team = a ? a.cfg.team : 'director', left = !a || S.order.filter(function (i) { return A(i).cfg.team === team; }).indexOf(e.agentId) % 2 === 0;
|
|
316
|
-
var p = panelEl(team), full = e.text, text = full.replace(/\s+/g, ' ').trim(); if (text.length > 220) text = text.slice(0, 219) + '…';
|
|
317
|
-
var tx = h('span', {class: 'tx'});
|
|
318
|
-
var b = h('div', {class: 'cbub', onclick: function () { showMessage({from: e.agentId, to: e.to, at: e.at, tokens: e.tokens, text: full}); }}, [h('span', {class: 'to', text: '→ ' + nm(e.to).toUpperCase()}), tx]);
|
|
319
|
-
var av = h('div', {}, [h('div', {class: 'cav', text: ini(e.agentId)}), h('div', {class: 'cwho', text: nm(e.agentId)})]);
|
|
320
|
-
p.appendChild(h('div', {class: 'cscene' + (left ? '' : ' r')}, [av, b])); addPanel(p);
|
|
321
|
-
if (S.history) tx.textContent = text; else { var i = 0, t = setInterval(function () { i += 2; tx.textContent = text.slice(0, i); if (i >= text.length) clearInterval(t); }, 22); }
|
|
322
|
-
}
|
|
323
|
-
function comicHandoff(e) {
|
|
324
|
-
var p = panelEl(e.from, 'wide'); p.style.setProperty('--pg', hexA(TC[e.to] || TC.director, .5));
|
|
325
|
-
p.appendChild(h('div', {class: 'cap', text: 'HANDOFF!'}));
|
|
326
|
-
p.appendChild(h('div', {class: 'cscene', style: 'justify-content:space-around;align-items:center'}, [h('div', {class: 'cwho', style: 'color:' + TC[e.from], text: TL[e.from]}), h('div', {class: 'onom', text: '📦 WHOOSH!'}), h('div', {class: 'cwho', style: 'color:' + TC[e.to], text: TL[e.to]})]));
|
|
327
|
-
p.appendChild(h('div', {class: 'sm', text: e.title})); addPanel(p);
|
|
328
|
-
}
|
|
329
|
-
function comicVerdict(e) {
|
|
330
|
-
var ok = e.verdict === 'PASS', col = ok ? '#4AD69A' : '#F05668', p = panelEl('qc', 'wide'); p.style.setProperty('--pc', col); p.style.setProperty('--pg', hexA(col, .45));
|
|
331
|
-
p.appendChild(h('div', {class: 'cap', text: 'QC verdict — loop ' + e.loop}));
|
|
332
|
-
p.appendChild(h('div', {style: 'text-align:center;padding:10px'}, [ok ? h('span', {class: 'stamp', style: 'color:' + col + ';border-color:' + col, text: 'PASS ✔'}) : h('span', {class: 'onom', style: 'color:' + col, text: 'BUG!! ✕'})]));
|
|
333
|
-
p.appendChild(h('div', {class: 'sm', text: e.summary})); addPanel(p);
|
|
334
|
-
}
|
|
335
|
-
function comicSub(e) {
|
|
336
|
-
var key = e.agentId + ':' + S.stageIdx + ':' + S.loop, p = S.lastPanelSub[key];
|
|
337
|
-
if (!p) { p = S.lastPanelSub[key] = panelEl(A(e.agentId).cfg.team); p.appendChild(h('div', {class: 'cap', text: nm(e.agentId) + ' calls in the subagent squad!'})); p.appendChild(h('div', {class: 'dron'})); addPanel(p); }
|
|
338
|
-
p.querySelector('.dron').appendChild(h('span', {text: '◆ ' + (e.kind || 'sub') + ' · ' + e.task.slice(0, 50)}));
|
|
339
|
-
}
|
|
411
|
+
|
|
340
412
|
|
|
341
413
|
/* small text dialog (replaces window.prompt); sits above the Config modal. Resolves the trimmed text, or null when cancelled. */
|
|
342
414
|
function askText(o) {
|
|
@@ -412,29 +484,68 @@
|
|
|
412
484
|
var mx = Math.max(1, Math.max.apply(null, c)), pts = c.map(function (v, i) { return (i / (B - 1) * 100).toFixed(1) + ',' + (15 - v / mx * 14).toFixed(1); }).join(' ');
|
|
413
485
|
return '<svg class="spark" viewBox="0 0 100 16" preserveAspectRatio="none"><polyline fill="none" stroke="' + color + '" stroke-width="1.4" points="' + pts + '"/></svg>';
|
|
414
486
|
}
|
|
487
|
+
var UI = (function () { try { return JSON.parse(localStorage.getItem('ckit-ui') || '{}') || {}; } catch (e) { return {}; } })();
|
|
488
|
+
UI.collapsed = UI.collapsed || {};
|
|
489
|
+
function saveUI() { try { localStorage.setItem('ckit-ui', JSON.stringify({collapsed: UI.collapsed, dockView: UI.dockView, activeOnly: UI.activeOnly})); } catch (e) { /* private mode */ } }
|
|
490
|
+
var ICON = {
|
|
491
|
+
chat: '<svg viewBox="0 0 16 16"><path d="M2 3h12v8H6l-4 3z" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',
|
|
492
|
+
crown: '<svg viewBox="0 0 16 16"><path d="M2 12h12l1-7-4 3-3-5-3 5-4-3z" fill="currentColor"/></svg>',
|
|
493
|
+
filter: '<svg viewBox="0 0 16 16"><path d="M2 4h12M4 8h8M6 12h4" stroke="currentColor" stroke-width="1.6" fill="none"/></svg>',
|
|
494
|
+
search: '<svg viewBox="0 0 16 16"><circle cx="7" cy="7" r="4.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M10.5 10.5L14 14" stroke="currentColor" stroke-width="1.5"/></svg>',
|
|
495
|
+
arrow: '<svg viewBox="0 0 16 16"><path d="M2 8h11M9 4l4 4-4 4" fill="none" stroke="currentColor" stroke-width="1.6"/></svg>',
|
|
496
|
+
check: '<svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="6.5" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M5 8.2l2 2 4-4.4" fill="none" stroke="currentColor" stroke-width="1.6"/></svg>',
|
|
497
|
+
cross: '<svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="6.5" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M5.5 5.5l5 5M10.5 5.5l-5 5" stroke="currentColor" stroke-width="1.6"/></svg>',
|
|
498
|
+
back: '<svg viewBox="0 0 16 16"><path d="M6 4L2 8l4 4M2 8h8a4 4 0 010 8" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>'};
|
|
499
|
+
function ico(name, cls) { var sp = h('span', {class: 'ico' + (cls ? ' ' + cls : '')}); sp.innerHTML = ICON[name] || ''; return sp; } /* static markup only */
|
|
500
|
+
function stateWord(a) { return a.state === 'thinking' ? (a.label || a.activity || 'working…') : a.state === 'done' ? 'finished turn' : a.state === 'failed' ? 'failed' : a.task ? 'waiting' : 'idle'; }
|
|
501
|
+
function rosterShell() {
|
|
502
|
+
var r = $('roster'); if (r.querySelector('.rlist')) return r;
|
|
503
|
+
var q = h('input', {type: 'search', class: 'rq', placeholder: 'Tìm agent…', 'aria-label': 'Search agents', spellcheck: false, autocomplete: 'off'});
|
|
504
|
+
q.addEventListener('input', function () { S.dirty = true; });
|
|
505
|
+
q.addEventListener('keydown', function (e) { if (e.key === 'Escape') { q.value = ''; S.dirty = true; q.blur(); } });
|
|
506
|
+
var fbtn = h('button', {class: 'iconbtn' + (UI.activeOnly ? ' on' : ''), type: 'button', title: 'Show only working agents', 'aria-label': 'Filter: only working agents', onclick: function () { UI.activeOnly = !UI.activeOnly; fbtn.classList.toggle('on', !!UI.activeOnly); fbtn.setAttribute('aria-pressed', String(!!UI.activeOnly)); saveUI(); S.dirty = true; }});
|
|
507
|
+
fbtn.appendChild(ico('filter'));
|
|
508
|
+
r.appendChild(h('div', {class: 'rhead'}, [h('span', {class: 'ml rtitle'}, ['AGENTS ', h('b', {class: 'rcount', text: '(0)'})]), fbtn]));
|
|
509
|
+
r.appendChild(h('label', {class: 'rsearch'}, [ico('search'), q, h('kbd', {text: '⌘K'})]));
|
|
510
|
+
r.appendChild(h('div', {class: 'rlist'}));
|
|
511
|
+
r.appendChild(h('button', {class: 'rnew', type: 'button', title: 'Agents are added in Config (one place for all settings)', text: '+ Tạo Agent mới', onclick: function () { setView('settings'); }}));
|
|
512
|
+
document.addEventListener('keydown', function (e) { if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k' && S.view === 'live') { e.preventDefault(); drawer('roster', true); q.focus(); q.select(); } });
|
|
513
|
+
return r;
|
|
514
|
+
}
|
|
415
515
|
function renderRoster() {
|
|
416
|
-
var r =
|
|
516
|
+
var r = rosterShell(), list = r.querySelector('.rlist'), keep = list.scrollTop, q = r.querySelector('.rq').value.trim().toLowerCase();
|
|
517
|
+
var frag = document.createDocumentFragment(), total = 0;
|
|
417
518
|
var dimmed = function (t) { return !!S.lane && t !== 'director' && S.lane.order.indexOf(t) < 0; };
|
|
418
519
|
['director'].concat(orderOf(S.config)).forEach(function (team) {
|
|
419
|
-
var
|
|
420
|
-
|
|
520
|
+
var all = S.order.filter(function (i) { return A(i).cfg.team === team; }); if (!all.length) return; total += all.length;
|
|
521
|
+
var ids = all.filter(function (id) { var a = A(id), c = a.cfg; if (UI.activeOnly && a.state !== 'thinking') return false; return !q || (c.name + ' ' + c.cli + ' ' + (c.model || '') + ' ' + (TL[team] || '') + ' ' + (c.short || '')).toLowerCase().indexOf(q) >= 0; });
|
|
522
|
+
if (!ids.length && (q || UI.activeOnly)) return;
|
|
523
|
+
var col = !!UI.collapsed[team] && !q, c = TC[team];
|
|
524
|
+
var hd = h('button', {class: 'rteam' + (dimmed(team) ? ' dim' : '') + (col ? ' col' : ''), type: 'button', style: 'color:' + c, 'aria-expanded': String(!col), title: col ? 'Expand' : 'Collapse', onclick: function () { UI.collapsed[team] = !UI.collapsed[team]; saveUI(); S.dirty = true; }}, [h('i', {style: 'background:' + c}), h('span', {text: TL[team] + ' (' + all.length + ')'}), team === 'director' ? ico('crown', 'crown') : null, h('span', {class: 'chev', text: col ? '▸' : '▾'})]);
|
|
525
|
+
frag.appendChild(hd); if (col) return;
|
|
421
526
|
ids.forEach(function (id) {
|
|
422
|
-
var a = A(id),
|
|
423
|
-
var
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (work) {
|
|
527
|
+
var a = A(id), work = a.state === 'thinking', sel = S.selected === id;
|
|
528
|
+
var el = h('div', {class: 'tile ' + a.state + (sel ? ' sel' : '') + (dimmed(team) ? ' dim' : ''), role: 'button', tabIndex: 0, 'aria-pressed': String(sel), style: '--tc:' + c + ';--tg:' + hexA(c, .35), title: a.cfg.name + ' — ' + a.cfg.cli + (a.cfg.model ? ' · ' + a.cfg.model : ''),
|
|
529
|
+
onclick: function () { selectAgent(sel ? null : id); }, onkeydown: function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); selectAgent(sel ? null : id); } }});
|
|
530
|
+
var elapsed = work && a.t0 ? fmtT(performance.now() - a.t0) : '';
|
|
531
|
+
el.appendChild(avatarEl(a.cfg, 44, {slot: 'r', state: a.state}));
|
|
532
|
+
el.appendChild(h('div', {class: 'tmain'}, [
|
|
533
|
+
h('div', {class: 'tl1'}, [h('b', {class: 'tname', text: a.cfg.name}), team === 'director' ? ico('crown', 'crown') : null, h('span', {class: 'tel mono', text: elapsed})]),
|
|
534
|
+
h('div', {class: 'tact ' + a.state}, [h('i'), h('span', {text: stateWord(a)})]),
|
|
535
|
+
h('div', {class: 'tl3'}, [h('span', {class: 'tcli mono'}, [h('span', {text: eng(a.cfg.cli).label}), h('span', {class: 'tmodel', text: a.cfg.model || 'default model'})]), h('span', {class: 'tstat mono'}, [ico('chat'), h('span', {text: String(a.msgs)}), h('b', {text: fmtN(a.tokens)})])])]));
|
|
536
|
+
if (work && a.total) el.appendChild(h('div', {class: 'bar', title: 'Step ' + a.step + ' of ' + a.total}, [h('b', {style: 'width:' + Math.min(100, a.step / a.total * 100) + '%'})]));
|
|
432
537
|
var run = Object.keys(a.subs).filter(function (k) { return a.subs[k].state === 'run'; });
|
|
433
538
|
if (run.length) { var sb = h('div', {class: 'subs'}, [h('span', {class: 'ml', text: 'Subagents (' + run.length + ' active)'})]); run.forEach(function (k) { sb.appendChild(h('div', {class: 'subl'}, [h('b', {text: '◆ ' + a.subs[k].kind + ' '}), a.subs[k].text])); }); el.appendChild(sb); }
|
|
434
|
-
|
|
539
|
+
frag.appendChild(el);
|
|
435
540
|
});
|
|
436
541
|
});
|
|
437
|
-
|
|
542
|
+
if (!frag.childNodes.length) frag.appendChild(h('div', {class: 'rempty', text: q ? 'No agent matches “' + q + '”.' : UI.activeOnly ? 'No agent is working right now.' : 'No agents configured.'}));
|
|
543
|
+
list.innerHTML = ''; list.appendChild(frag); list.scrollTop = keep;
|
|
544
|
+
r.querySelector('.rcount').textContent = '(' + total + ')';
|
|
545
|
+
}
|
|
546
|
+
/* one selection drives roster, topology, inspector and the conversation tab */
|
|
547
|
+
function selectAgent(id) {
|
|
548
|
+
S.selected = id || null; net.select(S.selected); setTab(S.selected || ''); S.dirty = true;
|
|
438
549
|
}
|
|
439
550
|
function kv(k, v) { return h('div', {class: 'kv'}, [h('span', {text: k}), h('span', {class: 'mono', text: String(v)})]); }
|
|
440
551
|
function lineSvg(vals, col) {
|
|
@@ -447,39 +558,76 @@
|
|
|
447
558
|
var mx = Math.max(1, Math.max.apply(null, c));
|
|
448
559
|
return '<svg class="spark" style="height:32px" viewBox="0 0 100 32" preserveAspectRatio="none">' + c.map(function (v, i) { return '<rect x="' + (i * 10 + 1) + '" y="' + (32 - v / mx * 30) + '" width="8" height="' + (v / mx * 30) + '" fill="#A36BFF"/>'; }).join('') + '</svg>';
|
|
449
560
|
}
|
|
561
|
+
function hm(iso) { var d = new Date(iso); return isNaN(d) ? '' : d.toTimeString().slice(0, 5); }
|
|
562
|
+
function abbr(id) { if (id === 'director') return 'DIR'; if (A(id)) return net.initials(A(id).cfg); return String(teamLbl(id)).toUpperCase().slice(0, 4); }
|
|
563
|
+
function secHead(title, extra) { return h('div', {class: 'ish'}, [h('span', {text: title}), extra || null]); }
|
|
564
|
+
function flowRows(max) {
|
|
565
|
+
var rows = [];
|
|
566
|
+
S.handoffs.forEach(function (e) { rows.push({at: e.at, icon: 'arrow', cls: 'ho', a: e.from, b: e.to, t: e.title, open: e.text ? function () { showMessage({from: e.from, to: e.to, at: e.at, text: e.text}); } : null}); });
|
|
567
|
+
S.verdicts.forEach(function (e) { var pass = e.verdict === 'PASS'; rows.push({at: e.at, icon: pass ? 'check' : 'cross', cls: pass ? 'pass' : 'fail', a: e.type === 'review.verdict' ? 'director' : 'qc', b: e.type === 'review.verdict' ? 'delivery' : pass ? 'director' : 'implement', t: (e.type === 'review.verdict' ? 'Review ' : 'QC ') + e.verdict + (e.loop ? ' · loop ' + e.loop : '') + ' — ' + e.summary}); });
|
|
568
|
+
S.flowBacks.forEach(function (e) { rows.push({at: e.at, icon: 'back', cls: 'ret', a: e.from, b: e.to, t: (e.kind === 'ask' ? 'asked: ' : 'returned: ') + e.reason}); });
|
|
569
|
+
rows.sort(function (x, y) { return Date.parse(x.at) - Date.parse(y.at); });
|
|
570
|
+
return rows.slice(-max);
|
|
571
|
+
}
|
|
572
|
+
function activityRows(max, only) {
|
|
573
|
+
var out = [];
|
|
574
|
+
for (var i = S.events.length - 1; i >= 0 && out.length < max; i--) {
|
|
575
|
+
var e = S.events[i], t = '';
|
|
576
|
+
if (only && e.agentId !== only) continue;
|
|
577
|
+
if (e.type === 'agent.started') t = 'started: ' + plain(String(e.task || '')); else if (e.type === 'agent.step') t = 'step ' + e.step + (e.total ? '/' + e.total : '') + ' · ' + e.label;
|
|
578
|
+
else if (e.type === 'agent.activity') t = e.text; else if (e.type === 'agent.message') t = '→ ' + nm(e.to) + ': ' + plain(e.text); else if (e.type === 'agent.failed') t = 'failed: ' + plain(String(e.reason || ''));
|
|
579
|
+
else if (e.type === 'subagent.started') t = 'spawned ' + (e.kind || 'subagent'); else continue;
|
|
580
|
+
out.push({at: e.at, id: e.agentId, t: t, k: e.type});
|
|
581
|
+
}
|
|
582
|
+
return out;
|
|
583
|
+
}
|
|
584
|
+
function teleRow(label, value, na, frac) {
|
|
585
|
+
return h('div', {class: 'trw' + (na ? ' na' : '')}, [h('span', {class: 'ml', text: label}), frac != null ? h('span', {class: 'tbar'}, [h('b', {style: 'width:' + Math.round(frac * 100) + '%'})]) : h('span', {class: 'tbar empty'}), h('span', {class: 'mono tv', title: na ? 'No data source for this metric' : '', text: value})]);
|
|
586
|
+
}
|
|
450
587
|
function renderInspector() {
|
|
451
|
-
var r = $('inspector'), keep = r.scrollTop
|
|
588
|
+
var r = $('inspector'), keep = r.scrollTop, frag = document.createDocumentFragment();
|
|
452
589
|
var a = S.selected && A(S.selected);
|
|
453
590
|
if (a) {
|
|
454
|
-
var c = TC[a.cfg.team];
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
kv('Engine', a.cfg.cli), kv('Model', a.cfg.model || 'default'), kv('Access', a.cfg.access === 'write' ? 'read + write' : 'read only'), a.cfg.baseUrl ? kv('Endpoint', a.cfg.baseUrl.replace(/^https?:\/\//, '').slice(0, 26)) : null, kv('State', a.
|
|
458
|
-
|
|
591
|
+
var c = TC[a.cfg.team] || '#8A9AAF';
|
|
592
|
+
frag.appendChild(secHead('AGENT INSPECTOR', h('button', {class: 'iconbtn', type: 'button', title: 'Close inspector', 'aria-label': 'Deselect agent', text: '✕', onclick: function () { selectAgent(null); }})));
|
|
593
|
+
frag.appendChild(h('div', {class: 'icard agent', style: '--tc:' + c}, [h('div', {class: 'aghead'}, [avatarEl(a.cfg, 64, {slot: 'i', state: a.state}), h('div', {class: 'agid'}, [h('b', {text: a.cfg.name}), h('div', {class: 'ml', style: 'color:' + c, text: TL[a.cfg.team]}), h('button', {class: 'chip', type: 'button', text: 'Change avatar', title: 'Pick a portrait. The agent keeps running; only the picture changes.', onclick: function () { avatarPicker(a.cfg, function (v) { saveAvatar(a.cfg.id, v); }); }})])]),
|
|
594
|
+
kv('Engine', eng(a.cfg.cli).label + ' (' + a.cfg.cli + ')'), kv('Model', a.cfg.model || 'default'), kv('Access', a.cfg.access === 'write' ? 'read + write' : 'read only'), a.cfg.baseUrl ? kv('Endpoint', a.cfg.baseUrl.replace(/^https?:\/\//, '').slice(0, 26)) : null, kv('State', stateWord(a)), kv('Messages', a.msgs), kv('Tokens', fmtN(a.tokens)),
|
|
595
|
+
a.total ? kv('Step', a.step + ' / ' + a.total) : null,
|
|
596
|
+
h('div', {class: 'ml', style: 'margin-top:6px', text: 'Current task'}), h('div', {class: 'agtask', text: a.task || '—'})]));
|
|
459
597
|
var af = (S.fails || []).filter(function (f) { return f.agentId === a.cfg.id; }).pop();
|
|
460
|
-
if (af)
|
|
461
|
-
|
|
462
|
-
a.outputs.forEach(function (o) {
|
|
463
|
-
if (!a.outputs.length)
|
|
464
|
-
r.appendChild(h('button', {text: '× deselect', style: 'margin-top:6px', onclick: function () { S.selected = null; net.select(null); S.dirty = true; }}));
|
|
598
|
+
if (af) frag.appendChild(h('div', {class: 'card fail failcard'}, [h('b', {class: 'bad', text: 'WHY IT FAILED'}), h('pre', {text: af.reason}), h('div', {class: 'fix'}, [h('b', {text: 'How to fix '}), fixHint(af.reason, a.cfg)]), h('div', {style: 'display:flex;gap:6px;margin-top:8px'}, [h('button', {text: 'Full details', onclick: showFailure}), h('button', {class: 'primary', text: 'Open Config', onclick: function () { setView('settings'); }})])]));
|
|
599
|
+
frag.appendChild(secHead('RECENT OUTPUTS', a.outputs.length > 2 ? h('span', {class: 'ml', text: '2 / ' + a.outputs.length}) : null));
|
|
600
|
+
a.outputs.slice(0, 2).forEach(function (o) { frag.appendChild(h('div', {class: 'out', text: o.text.replace(/\s+/g, ' '), onclick: function () { showMessage({from: a.cfg.id, to: o.to, at: o.at, tokens: o.tokens, text: o.text}); }})); });
|
|
601
|
+
if (!a.outputs.length) frag.appendChild(h('div', {class: 'iempty', text: 'No output yet.'}));
|
|
465
602
|
} else {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
S.
|
|
472
|
-
if (!S.handoffs.length && !S.verdicts.length) r.appendChild(h('div', {class: 'tact', text: 'Click an agent to inspect it.'}));
|
|
473
|
-
if (S.atts && S.atts.length) { r.appendChild(h('h3', {style: 'margin-top:12px', text: 'Attachments · ' + S.atts.length})); r.appendChild(h('div', {class: 'tact', text: 'Every team gets these with the request.'})); r.appendChild(h('div', {class: 'fatts', style: 'margin-top:6px'}, S.atts.map(attChip))); }
|
|
603
|
+
frag.appendChild(secHead('HANDOFFS & VERDICTS', h('span', {class: 'ml', text: String(S.handoffs.length + S.verdicts.length)})));
|
|
604
|
+
var rows = flowRows(6), box = h('div', {class: 'icard rows'});
|
|
605
|
+
rows.forEach(function (x) { box.appendChild(h('div', {class: 'frow ' + x.cls + (x.open ? ' click' : ''), title: x.t, onclick: x.open, role: x.open ? 'button' : null, tabIndex: x.open ? 0 : null}, [ico(x.icon), h('span', {class: 'fr'}, [h('b', {class: 'mono', text: abbr(x.a) + ' → ' + abbr(x.b)}), ' · ' + x.t]), h('span', {class: 'mono tm', text: hm(x.at)})])); });
|
|
606
|
+
if (!rows.length) box.appendChild(h('div', {class: 'iempty', text: 'No handoff or verdict yet. They appear here as the teams pass work along.'}));
|
|
607
|
+
frag.appendChild(box);
|
|
608
|
+
if (S.atts && S.atts.length) { frag.appendChild(secHead('ATTACHMENTS · ' + S.atts.length)); frag.appendChild(h('div', {class: 'fatts', style: 'margin-bottom:8px'}, S.atts.map(attChip))); }
|
|
474
609
|
}
|
|
475
|
-
|
|
476
|
-
var
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
var
|
|
482
|
-
|
|
610
|
+
/* telemetry: only measured values; what CKit cannot measure says N/A */
|
|
611
|
+
var sl = stageList(S.config), n = sl.length, doneN = S.outcome === 'delivered' ? n : Math.max(0, Math.min(n, S.stageIdx)), pct = S.stageIdx < 0 && !S.outcome ? 0 : doneN / Math.max(1, n);
|
|
612
|
+
frag.appendChild(secHead('TELEMETRY'));
|
|
613
|
+
var tele = h('div', {class: 'icard tele2'}), gauge = h('div', {class: 'gauge2'}), circ = 2 * Math.PI * 30;
|
|
614
|
+
gauge.innerHTML = '<svg width="78" height="78" viewBox="0 0 78 78" role="img" aria-label="Flow progress"><circle cx="39" cy="39" r="30" fill="none" stroke="#16223a" stroke-width="7"/><circle cx="39" cy="39" r="30" fill="none" stroke="#21D6E8" stroke-width="7" stroke-linecap="round" stroke-dasharray="' + (circ * pct).toFixed(1) + ' ' + circ.toFixed(1) + '" transform="rotate(-90 39 39)"/><text x="39" y="44" text-anchor="middle" fill="#fff" font-family="ui-monospace,Menlo,monospace" font-size="16" font-weight="700">' + Math.round(pct * 100) + '%</text></svg>';
|
|
615
|
+
gauge.appendChild(h('span', {class: 'ml', text: 'STAGES ' + doneN + '/' + n}));
|
|
616
|
+
var last = S.verdicts[S.verdicts.length - 1], verified = !!last && last.verdict === 'PASS';
|
|
617
|
+
var nums = h('div', {class: 'tnums'}, [kv('TOKENS', S.tokens.toLocaleString('en-US')), kv('MESSAGES', S.msgs), kv('COST (est.)', 'N/A'), kv('OUTCOME', S.outcome ? (S.outcome === 'delivered' ? (verified ? 'delivered · verified' : 'delivered · unverified') : S.outcome) : S.run ? 'in progress' : '—')]);
|
|
618
|
+
nums.lastChild.title = 'Delivered = the run finished. Verified = the last QC / Director review verdict was PASS.';
|
|
619
|
+
tele.appendChild(h('div', {class: 'tgrid'}, [gauge, nums]));
|
|
620
|
+
tele.appendChild(teleRow('CPU', 'N/A', true)); tele.appendChild(teleRow('RAM', 'N/A', true));
|
|
621
|
+
var tk = h('div', {class: 'tspark'}); tk.innerHTML = '<span class="ml">TOKENS / TIME</span>' + lineSvg(S.tokBuckets.map(function (x) { return x[1]; }), '#4F8CFF'); tele.appendChild(tk);
|
|
622
|
+
var st = Object.keys(S.stageTimes).slice(-4);
|
|
623
|
+
if (st.length) tele.appendChild(h('div', {class: 'tstages'}, st.map(function (k) { return h('span', {class: 'mono', text: k.replace('director-intake', 'intake').replace('ba-discussion', 'ba').replace(/^x:/, '') + ' ' + fmtT(S.stageTimes[k])}); })));
|
|
624
|
+
frag.appendChild(tele);
|
|
625
|
+
frag.appendChild(secHead('RECENT ACTIVITY'));
|
|
626
|
+
var act = activityRows(a ? 6 : 8, a ? a.cfg.id : null), ab = h('div', {class: 'icard rows'});
|
|
627
|
+
act.forEach(function (x) { var col = tcol(x.id); ab.appendChild(h('div', {class: 'arow', title: x.t}, [h('i', {style: 'background:' + (x.k === 'agent.failed' ? '#F05668' : col)}), h('span', {class: 'mono tm', text: clock(x.at)}), h('b', {style: 'color:' + col, text: nm(x.id)}), h('span', {class: 'at', text: x.t})])); });
|
|
628
|
+
if (!act.length) ab.appendChild(h('div', {class: 'iempty', text: 'Nothing has happened yet.'}));
|
|
629
|
+
frag.appendChild(ab);
|
|
630
|
+
r.innerHTML = ''; r.appendChild(frag); r.scrollTop = keep;
|
|
483
631
|
}
|
|
484
632
|
function renderStrip() {
|
|
485
633
|
var st = $('stages'); st.innerHTML = '';
|
|
@@ -487,7 +635,7 @@
|
|
|
487
635
|
$('lanename').textContent = S.lane ? 'Lane: ' + S.lane.name : ''; $('lanename').hidden = !S.lane;
|
|
488
636
|
list.forEach(function (x, i) {
|
|
489
637
|
var cls = cur > i ? 'done' : cur === i ? 'cur' : '', dur = S.stageTimes[x.key], xs = x.key.slice(0, 2) === 'x:';
|
|
490
|
-
st.appendChild(h('div', {class: 'st ' + cls + (x.key === 'review' ? ' rv' : ''), style: xs ? 'border-color:' + hexA(TC[x.team] || '#8A9AAF', .6) : ''}, [x.label, cls === 'done' && dur ? h('small', {text: fmtT(dur)}) : null, x.key === 'qc' && S.loop > 1 ? h('small', {text: 'loop ' + S.loop}) : null]));
|
|
638
|
+
st.appendChild(h('div', {class: 'st ' + cls + (x.key === 'review' ? ' rv' : ''), role: 'listitem', 'aria-current': cls === 'cur' ? 'step' : null, title: x.label + (cls === 'done' ? ' · done' + (dur ? ' in ' + fmtT(dur) : '') : cls === 'cur' ? ' · in progress' : ' · pending'), style: '--sc:' + (TC[x.team] || '#8A9AAF') + (xs ? ';border-color:' + hexA(TC[x.team] || '#8A9AAF', .6) : '')}, [cls === 'done' ? h('span', {class: 'sok', text: '✓'}) : null, String(x.label).toUpperCase(), cls === 'done' && dur ? h('small', {text: fmtT(dur)}) : null, x.key === 'qc' && S.loop > 1 ? h('small', {text: 'loop ' + S.loop}) : null]));
|
|
491
639
|
});
|
|
492
640
|
}
|
|
493
641
|
function renderTop() {
|
|
@@ -498,12 +646,19 @@
|
|
|
498
646
|
var end = S.outcome || S.replay ? (S.lastAt || S.started) : Date.now();
|
|
499
647
|
$('elapsed').textContent = S.started ? fmtT(end - S.started) : '00:00'; $('tokens').textContent = fmtN(S.tokens); $('msgs').textContent = S.msgs;
|
|
500
648
|
$('active').textContent = S.order.filter(function (i) { return A(i).state === 'thinking'; }).length + activeSubs();
|
|
501
|
-
$('idleHint').style.display =
|
|
649
|
+
$('idleHint').style.display = 'none'; $('now').style.display = S.run ? '' : 'none';
|
|
650
|
+
var mt = $('mtag'), mg = $('mgoal'), mtxt = S.run ? (S.run.goal || 'Run ' + (S.run.runId || '')) : 'No active run — describe a mission in the box below and press Enter.';
|
|
651
|
+
mt.textContent = live ? (S.waiting ? 'WAITING' : S.replay ? 'REPLAY' : 'RUNNING') : S.outcome ? String(S.outcome).toUpperCase() : 'READY';
|
|
652
|
+
mt.className = 'mtag ' + (live ? (S.waiting ? 'wait' : 'run') : S.outcome === 'delivered' ? 'ok' : S.outcome ? 'bad' : '');
|
|
653
|
+
if (mg.textContent !== mtxt) { mg.textContent = mtxt; mg.title = mtxt; }
|
|
654
|
+
$('bHint').hidden = !!live;
|
|
655
|
+
net.setHubStats(S.run || S.msgs ? ['⏱ ' + $('elapsed').textContent, String(S.msgs) + ' MSG', fmtN(S.tokens) + ' TOK'] : []);
|
|
656
|
+
renderTabs(); flushTerm();
|
|
502
657
|
/* composer: talks to the Director during a run, starts a mission when nothing is running */
|
|
503
658
|
var sim = simDefault(), wt = !!(live && S.waiting), mode = wt ? 'wait' + (S.waiting.assumptions ? 'A' : '') + S.waiting.round + (S.waiting.team || '') : live ? 'live' : sim ? 'sim' : 'real';
|
|
504
659
|
if (S.cmode !== mode) {
|
|
505
660
|
S.cmode = mode; $('clabel').textContent = wt ? 'ANSWER → DIRECTOR' : live ? 'OWNER → DIRECTOR' : 'NEW MISSION → DIRECTOR'; $('send').textContent = wt ? 'Send answer ▸' : live ? 'Send ▸' : 'Start ▸'; $('chips').style.display = live && !wt ? '' : 'none';
|
|
506
|
-
$('composer').classList.toggle('wait', wt); $('msg').placeholder = wt ? 'Type your answer and press Enter… (@ for a file, 📎 to attach)' : live ? '
|
|
661
|
+
$('composer').classList.toggle('wait', wt); $('msg').placeholder = wt ? 'Type your answer and press Enter… (@ for a file, 📎 to attach)' : live ? 'Gửi tin nhắn cho Director… (Enter to send, @ for a file)' : 'Describe the mission and press Enter to start the team… Type @ to point at a file or folder.';
|
|
507
662
|
$('cnote').textContent = wt ? (S.waiting.team ? 'The run is paused: the Director is waiting for your decision.' : 'The Director is waiting for you: no team has started and nothing is running.') : live ? '' : sim ? 'Demo mode: no real agent is configured, so this starts a simulated run.' : 'Starts real agents in ' + shortPath(S.projectRoot); $('cnote').title = S.projectRoot || '';
|
|
508
663
|
waitButtons(wt); if (wt) setTimeout(function () { $('msg').focus(); }, 30);
|
|
509
664
|
}
|
|
@@ -531,13 +686,26 @@
|
|
|
531
686
|
/* views */
|
|
532
687
|
function setView(v) {
|
|
533
688
|
S.view = v; ['live', 'settings', 'runs'].forEach(function (x) { $(x).hidden = x !== v; });
|
|
534
|
-
$('strip').hidden = v !== 'live'; $('bLive').classList.toggle('on', v === 'live' && !S.comic); $('bCfg').classList.toggle('on', v === 'settings');
|
|
689
|
+
$('strip').hidden = v !== 'live'; $('bLive').classList.toggle('on', v === 'live' && !S.comic); $('bCfg').classList.toggle('on', v === 'settings'); railSync();
|
|
535
690
|
if (v === 'settings') mountEditor($('settings'), false);
|
|
536
691
|
if (v === 'runs') renderRuns();
|
|
537
692
|
if (v === 'live') setTimeout(net.resize, 30);
|
|
538
693
|
if (location.hash.slice(1) !== v) history.replaceState(null, '', '#' + v);
|
|
539
694
|
}
|
|
540
|
-
function setComic(on) { S.comic = on; $('comic').hidden = !on; document.body.classList.toggle('comicmode', on); $('bComic').classList.toggle('on', on); $('bLive').classList.toggle('on', !on); if (on) $('comic').scrollTop = 1e9; }
|
|
695
|
+
function setComic(on) { S.comic = on; $('comic').hidden = !on; document.body.classList.toggle('comicmode', on); $('bComic').classList.toggle('on', on); $('bLive').classList.toggle('on', !on); if (on) $('comic').scrollTop = 1e9; railSync(); }
|
|
696
|
+
function railSync() {
|
|
697
|
+
var on = {rHome: S.view === 'live' && !S.comic, rTopo: S.view === 'live' && !!S.comic, rHist: S.view === 'runs', rSet: S.view === 'settings', rAgents: S.view === 'live' && !document.body.classList.contains('noroster')};
|
|
698
|
+
Object.keys(on).forEach(function (k) { var b = $(k); if (b) { b.classList.toggle('on', on[k]); b.setAttribute('aria-pressed', String(on[k])); } });
|
|
699
|
+
}
|
|
700
|
+
$('rHome').onclick = function () { setComic(false); setView('live'); };
|
|
701
|
+
$('rAgents').onclick = function () { if (S.view !== 'live') setView('live'); if (matchMedia('(max-height:720px),(max-width:1180px)').matches) drawer('roster'); else { document.body.classList.toggle('noroster'); setTimeout(net.resize, 30); } railSync(); };
|
|
702
|
+
$('rTopo').onclick = function () { setView('live'); setComic(!S.comic); };
|
|
703
|
+
$('rCode').onclick = function () { if (window.__ckExplorer) window.__ckExplorer.open(''); };
|
|
704
|
+
$('rData').onclick = function () { if (S.run && S.outcome) showArtifact('Run report', 'report.md'); else toast('The report appears here when a run finishes.'); };
|
|
705
|
+
$('rHist').onclick = function () { setView('runs'); };
|
|
706
|
+
$('rSet').onclick = function () { setView('settings'); };
|
|
707
|
+
$('wsbox').onclick = function () { if (window.__ckExplorer) window.__ckExplorer.open(''); };
|
|
708
|
+
$('wsbox').setAttribute('role', 'button'); $('wsbox').tabIndex = 0; $('wsbox').onkeydown = function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); $('wsbox').onclick(); } };
|
|
541
709
|
$('bLive').onclick = function () { setComic(false); setView('live'); };
|
|
542
710
|
$('bComic').onclick = function () { setView('live'); setComic(!S.comic); };
|
|
543
711
|
$('bRuns').onclick = function () { setView('runs'); };
|
|
@@ -735,16 +903,50 @@
|
|
|
735
903
|
/* compact layout: roster/inspector are drawers */
|
|
736
904
|
var picked = false;
|
|
737
905
|
function drawer(id, on) { $(id).classList.toggle('pop', on === undefined ? !$(id).classList.contains('pop') : on); }
|
|
738
|
-
net.onSelect(function (id) { S.selected = id; S.dirty = true; picked = true; drawer('inspector', true); });
|
|
906
|
+
net.onSelect(function (id) { S.selected = id; setTab(id || ''); S.dirty = true; picked = true; drawer('inspector', true); });
|
|
739
907
|
$('net').addEventListener('click', function () { if (picked) { picked = false; return; } drawer('roster', false); drawer('inspector', false); });
|
|
740
908
|
$('now').addEventListener('click', function () { if ($('now').classList.contains('click')) showFailure(); });
|
|
741
909
|
$('bRoster').onclick = function () { drawer('roster'); }; $('bInsp').onclick = function () { drawer('inspector'); };
|
|
742
910
|
document.addEventListener('keydown', function (e) { if (e.key === 'Escape') { drawer('roster', false); drawer('inspector', false); } });
|
|
743
911
|
|
|
912
|
+
/* avatar picker: category filter, search, preview, Random / Apply / Cancel. onApply(id) gets '' for "use the default". */
|
|
913
|
+
function avatarPicker(cfg, onApply) {
|
|
914
|
+
var cur = cfg.avatar || '', pick = cur || avatarId(cfg), cat = '', q = '';
|
|
915
|
+
var grid = h('div', {class: 'avgrid', role: 'listbox', 'aria-label': 'Avatars'}), prev = h('div', {class: 'avprev'}), cats = h('div', {class: 'avcats', role: 'tablist'});
|
|
916
|
+
var search = h('input', {type: 'search', placeholder: 'Search avatars…', 'aria-label': 'Search avatars', oninput: function () { q = search.value.trim().toLowerCase(); draw(); }});
|
|
917
|
+
function list() { return AVATARS.filter(function (x) { return (!cat || x.category === cat) && (!q || x.id.indexOf(q) >= 0 || x.category.indexOf(q) >= 0); }); }
|
|
918
|
+
function drawPrev() { prev.innerHTML = ''; prev.appendChild(avatarEl(cfg, 112, {id: pick, noEngine: true})); prev.appendChild(h('b', {text: cfg.name})); prev.appendChild(h('span', {class: 'mono ml', text: pick + (cur ? '' : pick === avatarId(cfg) ? ' (default)' : '')})); }
|
|
919
|
+
function draw() {
|
|
920
|
+
cats.innerHTML = ''; [''].concat(AV_CATS).forEach(function (c) { cats.appendChild(h('button', {type: 'button', role: 'tab', class: 'chip' + (cat === c ? ' on' : ''), 'aria-selected': String(cat === c), text: c || 'All', onclick: function () { cat = c; draw(); }})); });
|
|
921
|
+
grid.innerHTML = ''; var l = list();
|
|
922
|
+
l.forEach(function (x) { var on = x.id === pick; grid.appendChild(h('button', {type: 'button', role: 'option', 'aria-selected': String(on), class: 'avopt' + (on ? ' on' : ''), title: x.id, onclick: function () { pick = x.id; draw(); }, ondblclick: function () { pick = x.id; ok(); }}, [h('img', {src: AV_BASE + 'avatars/' + x.id + '.png', alt: x.id, loading: 'lazy', width: 64, height: 64})])); });
|
|
923
|
+
if (!l.length) grid.appendChild(h('div', {class: 'iempty', text: AVATARS.length ? 'No avatar matches.' : 'Avatar pack not available — initials are used.'}));
|
|
924
|
+
drawPrev();
|
|
925
|
+
}
|
|
926
|
+
function ok() { closeModal(); onApply(pick === avatarId(Object.assign({}, cfg, {avatar: ''})) && !cur ? '' : pick); }
|
|
927
|
+
openModal(h('div', {class: 'dlg wide avdlg', role: 'dialog', 'aria-label': 'Choose avatar'}, [
|
|
928
|
+
h('header', {}, [h('b', {text: 'Choose avatar · ' + cfg.name}), h('button', {text: '✕', 'aria-label': 'Close', onclick: closeModal})]),
|
|
929
|
+
h('div', {class: 'body avbody'}, [h('div', {class: 'avside'}, [prev, h('p', {class: 'clinote', text: 'Any portrait fits any role. Changing it never restarts the agent or its session.'})]), h('div', {class: 'avmain'}, [h('div', {class: 'avtools'}, [cats, search]), grid])]),
|
|
930
|
+
h('footer', {}, [h('button', {type: 'button', text: 'Random', onclick: function () { var l = list().length ? list() : AVATARS; if (l.length) { pick = l[Math.floor(Math.random() * l.length)].id; draw(); } }}), cur ? h('button', {type: 'button', text: 'Use default', onclick: function () { closeModal(); onApply(''); }}) : null, h('span', {style: 'flex:1'}), h('button', {type: 'button', text: 'Cancel', onclick: closeModal}), h('button', {class: 'primary', type: 'button', text: 'Apply', onclick: ok})])]));
|
|
931
|
+
draw(); setTimeout(function () { search.focus(); }, 30);
|
|
932
|
+
}
|
|
933
|
+
/* persist one agent's avatar: config only, no setupAgents, no run restart, no session reset */
|
|
934
|
+
function saveAvatar(id, v) {
|
|
935
|
+
if (!S.config) return;
|
|
936
|
+
var next = JSON.parse(JSON.stringify(S.config)), ag = cfgAgents(next).filter(function (x) { return x.id === id; })[0]; if (!ag) return;
|
|
937
|
+
if (v) ag.avatar = v; else delete ag.avatar;
|
|
938
|
+
api('PUT', '/api/config', strip(next)).then(function (r) {
|
|
939
|
+
if (r.status !== 200) { toast('Could not save avatar: ' + ((r.body && r.body.error) || r.status)); return; }
|
|
940
|
+
var live = cfgAgents(S.config).filter(function (x) { return x.id === id; })[0]; if (live) { if (v) live.avatar = v; else delete live.avatar; }
|
|
941
|
+
if (A(id)) { if (v) A(id).cfg.avatar = v; else delete A(id).cfg.avatar; }
|
|
942
|
+
net.refreshAgents(cfgAgents(S.config)); $('ctabs').dataset.sig = ''; S.dirty = true; toast('Avatar saved');
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
if (UI.dockView && UI.dockView !== 'chat') dockView(UI.dockView);
|
|
744
946
|
/* config editor (settings view + popup) */
|
|
745
947
|
function strip(cfg) {
|
|
746
948
|
var c = JSON.parse(JSON.stringify(cfg));
|
|
747
|
-
cfgAgents(c).forEach(function (a) { delete a.hasKey; delete a._auto; if (a.baseUrl === '') delete a.baseUrl; if (!a.persona) delete a.persona; if (!a.short) delete a.short; if (typeof a.cliArgs !== 'string' || !a.cliArgs.trim()) delete a.cliArgs; else a.cliArgs = a.cliArgs.trim(); });
|
|
949
|
+
cfgAgents(c).forEach(function (a) { delete a.hasKey; delete a._auto; if (a.baseUrl === '') delete a.baseUrl; if (!a.persona) delete a.persona; if (!a.short) delete a.short; if (!a.avatar) delete a.avatar; if (typeof a.cliArgs !== 'string' || !a.cliArgs.trim()) delete a.cliArgs; else a.cliArgs = a.cliArgs.trim(); });
|
|
748
950
|
['ba', 'implement', 'qc'].forEach(function (k) { if (!c.teams[k]) c.teams[k] = []; });
|
|
749
951
|
if (c.missions) { Object.keys(c.missions).forEach(function (k) { if (!String(c.missions[k] || '').trim()) delete c.missions[k]; }); if (!Object.keys(c.missions).length) delete c.missions; }
|
|
750
952
|
if (c.extraTeams && !c.extraTeams.length) delete c.extraTeams;
|
|
@@ -917,7 +1119,8 @@
|
|
|
917
1119
|
f.appendChild(h('div', {class: 'sec', text: 'IDENTITY'}));
|
|
918
1120
|
var sn = h('input', {value: a.short || '', maxLength: 4, placeholder: net.initials({name: a.name || '?', team: a.team}), style: 'text-transform:uppercase;font-family:var(--mono);font-weight:700;letter-spacing:.08em', title: 'Shown inside the agent circle. 1-4 letters or digits. Empty = ' + net.initials({name: a.name || '?', team: a.team}) + ' (from the name).'});
|
|
919
1121
|
sn.addEventListener('input', function () { var v = sn.value.replace(/[^\p{L}\p{N}]/gu, '').toUpperCase().slice(0, 4); if (v !== sn.value) sn.value = v; });
|
|
920
|
-
|
|
1122
|
+
var avb = h('button', {class: 'avpick', type: 'button', title: 'Change avatar (any portrait fits any role)', 'aria-label': 'Change avatar', onclick: function () { avatarPicker(a, function (v) { if (v) a.avatar = v; else delete a.avatar; mark(); render(); }); }}, [avatarEl(a, 52, {noEngine: true}), h('span', {class: 'ml', text: 'CHANGE'})]);
|
|
1123
|
+
f.appendChild(h('div', {class: 'row2', style: 'grid-template-columns:72px 150px 1fr 1fr;align-items:end'}, [avb, fld('Short name (max 4)', bind(sn, a, 'short')), fld('Name', bind(h('input', {value: a.name}), a, 'name')), fld('Team', h('input', {value: a.team, disabled: true}))]));
|
|
921
1124
|
var pta = bind(h('textarea', {rows: 2, value: a.persona || ''}), a, 'persona');
|
|
922
1125
|
f.appendChild(fld('Persona / extra guidance (optional)', pta));
|
|
923
1126
|
f.appendChild(enhance('persona', {team: a.team, agent: a.id}, pta, function (v) { a.persona = v; }));
|
|
@@ -1016,8 +1219,8 @@
|
|
|
1016
1219
|
function connect() {
|
|
1017
1220
|
var es = new EventSource('/api/events?t=' + encodeURIComponent(TOKEN));
|
|
1018
1221
|
es.onmessage = function (m) { try { onEvent(JSON.parse(m.data)); } catch (err) { console.error(err); } };
|
|
1019
|
-
es.addEventListener('reset', function () { resetRun(); S.history = true; });
|
|
1020
|
-
es.addEventListener('ready', function () { S.history = false; S.dirty = true; shots(); });
|
|
1222
|
+
es.addEventListener('reset', function () { resetRun(); S.history = true; comicCall('setHistory', true); });
|
|
1223
|
+
es.addEventListener('ready', function () { S.history = false; comicCall('setHistory', false); S.dirty = true; shots(); });
|
|
1021
1224
|
es.addEventListener('replaystop', replayStopped);
|
|
1022
1225
|
}
|
|
1023
1226
|
api('GET', '/api/clis').then(function (r) { if (r.status === 200) { CLIS = r.body.clis || []; S.configFile = r.body.configFile; if (S.view === 'settings') setView('settings'); } });
|
|
@@ -1030,9 +1233,9 @@
|
|
|
1030
1233
|
return;
|
|
1031
1234
|
}
|
|
1032
1235
|
if (r.status !== 200) { document.body.innerHTML = '<p style="padding:40px;color:#F05668;font-family:monospace">Missing or invalid session token. Open the URL printed by `ckit gui`.</p>'; return; }
|
|
1033
|
-
S.config = r.body.config; S.configExists = r.body.configExists !== false; S.projectRoot = r.body.projectRoot || ''; staleNotice(r.body.version, r.body.diskVersion); (function (root) { var name = root.split(/[\\/]/).filter(Boolean).pop() || root, ws = $('cwd').parentNode; $('cwdn').textContent = name; $('cwd').textContent = '\u200e' + root; document.title = name + ' · CKit'; ws.title = 'Open workspace files\n' + root; ws.style.cursor = 'pointer'; ws.setAttribute('role', 'button'); ws.tabIndex = 0; ws.onclick = function () { if (window.__ckExplorer) window.__ckExplorer.open(''); }; ws.onkeydown = function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); ws.onclick(); } }; })(S.projectRoot); S.simulatedDefault = r.body.simulatedDefault; S.run = r.body.run ? {runId: r.body.run.runId, running: r.body.run.running, goal: r.body.run.goal} : null;
|
|
1236
|
+
S.config = r.body.config; S.configExists = r.body.configExists !== false; S.projectRoot = r.body.projectRoot || ''; staleNotice(r.body.version, r.body.diskVersion); (function (root) { var name = root.split(/[\\/]/).filter(Boolean).pop() || root, ws = $('cwd').parentNode; $('cwdn').textContent = name; $('cwd').textContent = '\u200e' + root; $('wsboxn').textContent = name; $('wsbox').title = 'Workspace: ' + root + '\nClick to open files'; document.title = name + ' · CKit'; ws.title = 'Open workspace files\n' + root; ws.style.cursor = 'pointer'; ws.setAttribute('role', 'button'); ws.tabIndex = 0; ws.onclick = function () { if (window.__ckExplorer) window.__ckExplorer.open(''); }; ws.onkeydown = function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); ws.onclick(); } }; })(S.projectRoot); S.simulatedDefault = r.body.simulatedDefault; S.run = r.body.run ? {runId: r.body.run.runId, running: r.body.run.running, goal: r.body.run.goal} : null;
|
|
1034
1237
|
S.replay = !!(r.body.run && r.body.run.goal === '(replay)'); S.replaySpeed = r.body.run && r.body.run.replay ? r.body.run.replay.speed : 0; $('bStopRp').onclick = stopReplay;
|
|
1035
|
-
setupAgents(S.config);
|
|
1238
|
+
setupAgents(S.config); comicCtx(S.config);
|
|
1036
1239
|
// First run (no .ckit/team.json, nothing running): land on Config so setup starts in the GUI.
|
|
1037
1240
|
var v = location.hash.slice(1); setView(['live', 'settings', 'runs'].indexOf(v) >= 0 ? v : (!S.configExists && !r.body.run && !SHOT && Q.get('demo') !== '1') ? 'settings' : 'live');
|
|
1038
1241
|
connect(); requestAnimationFrame(loop);
|