@ngockhoale/ckit 0.3.1 → 0.4.1
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/README.md +14 -2
- package/dist/src/cli/ckit.js +0 -0
- package/dist/src/gui/server.d.ts +3 -1
- package/dist/src/gui/server.js +41 -15
- package/dist/src/team/bus.d.ts +60 -0
- package/dist/src/team/bus.js +172 -0
- package/dist/src/team/config.js +5 -4
- package/dist/src/team/engine.d.ts +33 -1
- package/dist/src/team/engine.js +1151 -176
- package/dist/src/team/mcp/hub.d.ts +16 -0
- package/dist/src/team/mcp/hub.js +99 -0
- package/dist/src/team/mcp/stdio-server.d.ts +2 -0
- package/dist/src/team/mcp/stdio-server.js +103 -0
- package/dist/src/team/runners.d.ts +4 -0
- package/dist/src/team/runners.js +8 -2
- package/dist/src/team/scheduler.d.ts +20 -0
- package/dist/src/team/scheduler.js +73 -0
- package/dist/src/team/sessions/claude.d.ts +16 -5
- package/dist/src/team/sessions/claude.js +127 -13
- package/dist/src/team/sessions/codex.d.ts +3 -2
- package/dist/src/team/sessions/codex.js +21 -3
- package/dist/src/team/sessions/fallback.js +6 -2
- package/dist/src/team/sessions/index.d.ts +1 -1
- package/dist/src/team/sessions/index.js +3 -3
- package/dist/src/team/sessions/omp.d.ts +12 -3
- package/dist/src/team/sessions/omp.js +95 -8
- package/dist/src/team/sessions/proc.d.ts +20 -2
- package/dist/src/team/sessions/proc.js +64 -18
- package/dist/src/team/sessions/types.d.ts +23 -2
- package/dist/src/team/telemetry.d.ts +32 -0
- package/dist/src/team/telemetry.js +135 -0
- package/dist/src/team/types.d.ts +173 -1
- package/dist/src/tui/team/model.js +10 -0
- package/gui/app.css +23 -0
- package/gui/app.js +208 -6
- package/gui/comic/engine.js +44 -0
- package/gui/index.html +1 -1
- package/package.json +1 -1
package/gui/app.js
CHANGED
|
@@ -98,7 +98,7 @@
|
|
|
98
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 = '';
|
|
99
99
|
$('feed').innerHTML = ''; comicCall('reset'); $('bubbles').innerHTML = ''; S.bubbles = {}; S.lastPanelSub = {};
|
|
100
100
|
$('overlay').hidden = true; $('hobanner').classList.remove('on');
|
|
101
|
-
S.lane = null; S.laneBy = ''; S.waiting = null; net.setActiveTeams(null);
|
|
101
|
+
S.lane = null; S.laneBy = ''; S.waiting = null; net.setActiveTeams(null); xReset();
|
|
102
102
|
if (S.config) { setupAgents(S.config); comicCtx(S.config); }
|
|
103
103
|
net.reset(); setNarr('Waiting for a mission…'); S.dirty = true;
|
|
104
104
|
}
|
|
@@ -248,12 +248,14 @@
|
|
|
248
248
|
function runBase() { return '/api/runs/' + encodeURIComponent((S.run && S.run.runId) || 'current'); }
|
|
249
249
|
function onEvent(e) {
|
|
250
250
|
if (S.run && S.run.runId && e.runId && e.runId !== S.run.runId) return; /* another run's event: not for this view */
|
|
251
|
+
xEvent(e);
|
|
251
252
|
if (e.type === 'run.started') comicCtx(e.config);
|
|
252
253
|
if (e.type === 'agent.delta') { /* live typing preview: per-agent buffer only, never stored in the event list */
|
|
253
254
|
var da = e.agentId ? A(e.agentId) : null;
|
|
254
255
|
if (da && typeof e.text === 'string') { da.live = ((da.live || '') + e.text).slice(-2000); S.dirty = true; }
|
|
255
256
|
return;
|
|
256
257
|
}
|
|
258
|
+
if (e.type === 'agent.tool') return; /* live-only execution stream: shown in Agent Lanes / Live Feed, not in the event list */
|
|
257
259
|
comicCall('push', e);
|
|
258
260
|
S.events.push(e); S.dirty = true;
|
|
259
261
|
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) : ''));
|
|
@@ -595,7 +597,7 @@
|
|
|
595
597
|
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})]);
|
|
596
598
|
}
|
|
597
599
|
function renderInspector() {
|
|
598
|
-
var r = $('
|
|
600
|
+
var r = $('ipane'), keep = $('inspector').scrollTop, frag = document.createDocumentFragment();
|
|
599
601
|
var a = S.selected && A(S.selected);
|
|
600
602
|
if (a) {
|
|
601
603
|
var c = TC[a.cfg.team] || '#8A9AAF';
|
|
@@ -637,7 +639,7 @@
|
|
|
637
639
|
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})])); });
|
|
638
640
|
if (!act.length) ab.appendChild(h('div', {class: 'iempty', text: 'Nothing has happened yet.'}));
|
|
639
641
|
frag.appendChild(ab);
|
|
640
|
-
r.innerHTML = ''; r.appendChild(frag);
|
|
642
|
+
r.innerHTML = ''; r.appendChild(frag); $('inspector').scrollTop = keep;
|
|
641
643
|
}
|
|
642
644
|
function renderStrip() {
|
|
643
645
|
var st = $('stages'); st.innerHTML = '';
|
|
@@ -661,7 +663,7 @@
|
|
|
661
663
|
mt.textContent = live ? (S.waiting ? 'WAITING' : S.replay ? 'REPLAY' : 'RUNNING') : S.outcome ? String(S.outcome).toUpperCase() : 'READY';
|
|
662
664
|
mt.className = 'mtag ' + (live ? (S.waiting ? 'wait' : 'run') : S.outcome === 'delivered' ? 'ok' : S.outcome ? 'bad' : '');
|
|
663
665
|
if (mg.textContent !== mtxt) { mg.textContent = mtxt; mg.title = mtxt; }
|
|
664
|
-
$('bHint').hidden = !!live;
|
|
666
|
+
$('bHint').hidden = !!live; xCtl(live);
|
|
665
667
|
net.setHubStats(S.run || S.msgs ? ['⏱ ' + $('elapsed').textContent, String(S.msgs) + ' MSG', fmtN(S.tokens) + ' TOK'] : []);
|
|
666
668
|
renderTabs(); flushTerm();
|
|
667
669
|
/* composer: talks to the Director during a run, starts a mission when nothing is running */
|
|
@@ -689,10 +691,210 @@
|
|
|
689
691
|
var lastRender = 0;
|
|
690
692
|
function loop(now) {
|
|
691
693
|
tickBubbles(now);
|
|
692
|
-
if (now - lastRender > 400 || S.dirty) { lastRender = now; S.dirty = false; if (S.view === 'live') { renderRoster(); renderInspector(); renderStrip(); } renderTop(); }
|
|
694
|
+
if (now - lastRender > 400 || S.dirty) { lastRender = now; S.dirty = false; if (S.view === 'live') { renderRoster(); if (xTab === 'inspect') renderInspector(); renderStrip(); } renderTop(); }
|
|
695
|
+
if (S.view === 'live') xFrame(now);
|
|
693
696
|
requestAnimationFrame(loop);
|
|
694
697
|
}
|
|
695
698
|
|
|
699
|
+
|
|
700
|
+
/* ===== Run controls, Live Feed, Agent Lanes, Decision Board, Task Graph, telemetry strip =====
|
|
701
|
+
All text from agents / owner goes in through textContent (h() helper) only. State is per selected run and rebuilt from that run's stream. */
|
|
702
|
+
var XT = [['inspect', 'Inspector'], ['feed', 'Live Feed'], ['lanes', 'Agent Lanes'], ['board', 'Decision Board'], ['tasks', 'Task Graph']];
|
|
703
|
+
var xTab = 'inspect', X = null, xLast = 0, xDirty = true, xFeedF = {agent: '', team: '', type: ''}, xTele = null;
|
|
704
|
+
var FEED_MAX = 500, FEED_TYPES = [['', 'All types'], ['message', 'Messages'], ['mail', 'Mail'], ['contribution', 'Contributions'], ['decision', 'Decisions'], ['task', 'Tasks'], ['tool', 'Tools'], ['wait', 'Waits'], ['control', 'Pause / resume'], ['flow', 'Flow / verdicts'], ['loop', 'Loops / mode']];
|
|
705
|
+
function xReset() { X = {feed: [], pend: [], lanes: {}, contribs: {}, decisions: {}, tasks: {}, taskOrder: [], skipped: [], paused: false, feedBuilt: -1}; xDirty = true; }
|
|
706
|
+
xReset();
|
|
707
|
+
function xClip(t, n) { t = String(t == null ? '' : t).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; }
|
|
708
|
+
function xLane(id) { return X.lanes[id] || (X.lanes[id] = {wait: '', detail: '', tool: '', live: '', fin: false, turns: 0, tokens: 0, act: '', at: ''}); }
|
|
709
|
+
var SEV_RANK = {critical: 0, high: 1, medium: 2, low: 3, info: 4};
|
|
710
|
+
function topSev(fs) { var b = ''; (fs || []).forEach(function (f) { if (SEV_RANK[f.severity] != null && (b === '' || SEV_RANK[f.severity] < SEV_RANK[b])) b = f.severity; }); return b; }
|
|
711
|
+
function xRow(e, type, agentId, text, team0) {
|
|
712
|
+
var team = team0 || (agentId && A(agentId) ? A(agentId).cfg.team : '');
|
|
713
|
+
X.feed.push({at: e.at, agent: agentId || '', team: team, type: type, text: xClip(text, 220), kind: e.type});
|
|
714
|
+
if (X.feed.length > FEED_MAX) X.feed.splice(0, X.feed.length - FEED_MAX);
|
|
715
|
+
X.pend.push(X.feed[X.feed.length - 1]);
|
|
716
|
+
}
|
|
717
|
+
function xEvent(e) {
|
|
718
|
+
var id = e.agentId, L;
|
|
719
|
+
switch (e.type) {
|
|
720
|
+
case 'agent.started': L = xLane(id); L.turns++; L.live = ''; L.fin = false; L.tool = ''; L.wait = 'starting'; L.detail = ''; L.act = String(e.task || ''); L.at = e.at; break;
|
|
721
|
+
case 'agent.activity': case 'agent.step': L = xLane(id); L.act = String(e.type === 'agent.step' ? e.label || '' : e.text || ''); L.at = e.at; xDirty = true; return;
|
|
722
|
+
case 'agent.delta': L = xLane(id); if (L.fin) { L.live = ''; L.fin = false; } L.live = (L.live + String(e.text || '')).slice(-1500); xDirty = true; return;
|
|
723
|
+
case 'agent.tool': L = xLane(id); L.tool = e.phase === 'call' ? e.name : ''; xRow(e, 'tool', id, (e.phase === 'call' ? '▶ ' : '◀ ') + e.name + (e.text ? ': ' + e.text : '')); break;
|
|
724
|
+
case 'agent.wait': L = xLane(id); L.wait = e.reason; L.detail = e.detail || ''; xRow(e, 'wait', id, 'waiting: ' + e.reason + (e.detail ? ' · ' + e.detail : '')); break;
|
|
725
|
+
case 'agent.message': L = xLane(id); L.live = String(e.text || '').slice(0, 1500); L.fin = true; L.tool = ''; L.wait = 'idle'; L.detail = ''; L.tokens += e.tokens || 0; xRow(e, 'message', id, '→ ' + nm(e.to) + ': ' + plain(String(e.text || ''))); break;
|
|
726
|
+
case 'agent.failed': L = xLane(id); L.tool = ''; L.wait = ''; L.live = ''; xRow(e, 'message', id, 'failed: ' + plain(String(e.reason || ''))); break;
|
|
727
|
+
case 'agent.mail': xRow(e, 'mail', e.from, '✉ ' + nm(e.from) + ' → ' + nm(e.to) + (e.kind && e.kind !== 'mail' ? ' (' + e.kind + ')' : '') + ': ' + (e.subject ? e.subject + ' — ' : '') + plain(String(e.text || ''))); break;
|
|
728
|
+
case 'contribution.published': {
|
|
729
|
+
var c = e.contribution || {}, fs = c.findings || [], ts = topSev(fs);
|
|
730
|
+
X.contribs[c.contributionId] = c;
|
|
731
|
+
xRow(e, 'contribution', c.agentId, fs.length + ' finding' + (fs.length === 1 ? '' : 's') + (ts ? ' · top ' + ts : '') + ' · ' + c.status); break;
|
|
732
|
+
}
|
|
733
|
+
case 'decision.recorded': {
|
|
734
|
+
var d = e.decision || {}, old = X.decisions[d.id];
|
|
735
|
+
if (!old || (d.revision || 0) >= (old.revision || 0)) X.decisions[d.id] = d;
|
|
736
|
+
xRow(e, 'decision', S.config ? S.config.director.id : '', (d.title || d.id) + ' · ' + d.status + (d.revision > 1 ? ' (rev ' + d.revision + ')' : '')); break;
|
|
737
|
+
}
|
|
738
|
+
case 'task.created':
|
|
739
|
+
if (!X.tasks[e.taskId]) X.taskOrder.push(e.taskId);
|
|
740
|
+
X.tasks[e.taskId] = {id: e.taskId, team: e.team, title: e.title, deps: (e.deps || []).slice(), status: 'pending', note: ''};
|
|
741
|
+
xRow(e, 'task', '', 'task ' + e.taskId + ' (' + teamLbl(e.team) + '): ' + e.title + (e.deps && e.deps.length ? ' · after ' + e.deps.join(', ') : '')); break;
|
|
742
|
+
case 'task.updated':
|
|
743
|
+
if (X.tasks[e.taskId]) { X.tasks[e.taskId].status = e.status; X.tasks[e.taskId].note = e.note || ''; }
|
|
744
|
+
xRow(e, 'task', '', 'task ' + e.taskId + ' → ' + e.status + (e.note ? ': ' + e.note : '')); break;
|
|
745
|
+
case 'loop.detected': xRow(e, 'loop', '', 'loop guard (' + e.kind + ') ' + nm(e.from) + ': ' + e.reason); break;
|
|
746
|
+
case 'mode.chosen': xRow(e, 'loop', '', 'mode ' + e.mode + ': ' + e.reason); break;
|
|
747
|
+
case 'team.skipped': X.skipped.push({team: e.team, reason: String(e.reason || '')}); xRow(e, 'flow', '', 'team ' + teamLbl(e.team) + ' skipped: ' + e.reason, e.team); break;
|
|
748
|
+
case 'run.paused': X.paused = true; xRow(e, 'control', '', 'run paused' + (e.by === 'interrupt' ? ' (interrupt)' : '')); break;
|
|
749
|
+
case 'run.resumed': X.paused = false; xRow(e, 'control', '', 'run resumed'); break;
|
|
750
|
+
case 'agent.interrupted': xLane(id).tool = ''; xRow(e, 'control', id, 'turn interrupted'); break;
|
|
751
|
+
case 'flow.back': xRow(e, 'flow', '', (e.kind === 'ask' ? 'ask ' : 'return ') + teamLbl(e.from) + ' → ' + teamLbl(e.to) + ': ' + e.reason); break;
|
|
752
|
+
case 'qc.verdict': case 'review.verdict': xRow(e, 'flow', '', (e.type === 'qc.verdict' ? 'QC ' : 'review ') + e.verdict + ': ' + e.summary); break;
|
|
753
|
+
case 'run.completed': X.paused = false; Object.keys(X.lanes).forEach(function (k) { X.lanes[k].tool = ''; X.lanes[k].wait = ''; }); break;
|
|
754
|
+
default: return;
|
|
755
|
+
}
|
|
756
|
+
xDirty = true;
|
|
757
|
+
}
|
|
758
|
+
function xCtl(live) {
|
|
759
|
+
var box = $('rctl'), id = S.run && S.run.runId, on = !!(live && !S.replay && id && S.run.goal !== '(replay)');
|
|
760
|
+
box.hidden = !on; if (!on) return;
|
|
761
|
+
var paused = X.paused, sig = String(paused);
|
|
762
|
+
if (box.dataset.sig === sig) return; box.dataset.sig = sig; box.innerHTML = '';
|
|
763
|
+
var call = function (what) { var rid = S.run && S.run.runId; if (!rid) return; api('POST', '/api/runs/' + encodeURIComponent(rid) + '/' + what).then(function (r) { if (r.status !== 200) toast((r.body && r.body.error) || ('could not ' + what)); }); };
|
|
764
|
+
box.appendChild(paused ? h('button', {type: 'button', class: 'chip', text: '▶ Resume', title: 'Let agents start new turns again', onclick: function () { call('resume'); }}) : h('button', {type: 'button', class: 'chip', text: '⏸ Pause', title: 'No new agent turn starts; running turns finish', onclick: function () { call('pause'); }}));
|
|
765
|
+
box.appendChild(h('button', {type: 'button', class: 'chip', text: '⚡ Interrupt', title: 'Cancel running turns now and pause; they are redone after Resume', onclick: function () { call('interrupt'); }}));
|
|
766
|
+
box.appendChild(h('button', {type: 'button', class: 'chip dng', text: '■ Stop', title: 'Stop this run', onclick: function () { call('stop'); }}));
|
|
767
|
+
}
|
|
768
|
+
/* inspector tabs */
|
|
769
|
+
(function () {
|
|
770
|
+
var ins = $('inspector'), tabs = h('div', {id: 'itabs', role: 'tablist'}), tele = h('div', {id: 'xtele'}), ip = h('div', {id: 'ipane'}), xp = h('div', {id: 'xpane', hidden: true});
|
|
771
|
+
XT.forEach(function (t) { tabs.appendChild(h('button', {type: 'button', role: 'tab', 'data-t': t[0], class: 'itab' + (t[0] === xTab ? ' on' : ''), text: t[1], onclick: function () { xSetTab(t[0]); }})); });
|
|
772
|
+
ins.appendChild(tabs); ins.appendChild(tele); ins.appendChild(ip); ins.appendChild(xp);
|
|
773
|
+
})();
|
|
774
|
+
function xSetTab(t) {
|
|
775
|
+
xTab = t; xDirty = true; X.feedBuilt = -1;
|
|
776
|
+
Array.prototype.forEach.call($('itabs').children, function (b) { var on = b.getAttribute('data-t') === t; b.classList.toggle('on', on); b.setAttribute('aria-selected', String(on)); });
|
|
777
|
+
$('ipane').hidden = t !== 'inspect'; $('xpane').hidden = t === 'inspect'; $('xpane').innerHTML = ''; $('xpane').dataset.built = '';
|
|
778
|
+
if (t === 'inspect') renderInspector();
|
|
779
|
+
}
|
|
780
|
+
function xTeleStrip() {
|
|
781
|
+
var el = $('xtele'), t = xTele;
|
|
782
|
+
if (!t || !S.run) { el.hidden = true; return; }
|
|
783
|
+
el.hidden = false; el.innerHTML = '';
|
|
784
|
+
[['turns', t.turns], ['model calls', t.modelCalls], ['director', t.directorTurns], ['tokens', fmtN(t.tokens || 0)], ['wall', fmtT(t.wallMs || 0)], ['max ∥', t.maxParallelAgents], ['mode', t.mode || '—']].forEach(function (kv2) {
|
|
785
|
+
el.appendChild(h('span', {class: 'xt', title: kv2[0]}, [h('em', {text: kv2[0]}), h('b', {class: 'mono', text: String(kv2[1])})]));
|
|
786
|
+
});
|
|
787
|
+
if (t.paused) el.appendChild(h('span', {class: 'xt pz', text: 'PAUSED'}));
|
|
788
|
+
}
|
|
789
|
+
function xPoll() {
|
|
790
|
+
var id = S.run && S.run.runId; if (!id || S.view !== 'live' || document.hidden) return;
|
|
791
|
+
api('GET', '/api/state').then(function (r) {
|
|
792
|
+
if (r.status !== 200 || !S.run || S.run.runId !== id) return;
|
|
793
|
+
var me = (r.body.runs || []).filter(function (x) { return x.runId === id; })[0];
|
|
794
|
+
xTele = me && me.telemetry || null; xDirty = true;
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
setInterval(xPoll, 2000);
|
|
798
|
+
function feedMatch(f) { return (!xFeedF.agent || f.agent === xFeedF.agent) && (!xFeedF.team || f.team === xFeedF.team) && (!xFeedF.type || f.type === xFeedF.type); }
|
|
799
|
+
function feedEl(f) {
|
|
800
|
+
var col = f.agent ? tcol(f.agent) : '#8A9AAF';
|
|
801
|
+
return h('div', {class: 'xr xr-' + f.type, style: '--tc:' + col}, [h('span', {class: 'mono tm', text: clock(f.at)}), h('b', {text: f.agent ? nm(f.agent) : 'system'}), f.team ? h('span', {class: 'xteam', text: teamLbl(f.team)}) : null, h('span', {class: 'xty', text: f.kind}), h('span', {class: 'xtx', text: f.text})]);
|
|
802
|
+
}
|
|
803
|
+
function xFeedPane(p) {
|
|
804
|
+
if (!p.dataset.built) {
|
|
805
|
+
p.dataset.built = 'feed'; p.innerHTML = '';
|
|
806
|
+
var ag = h('select', {'aria-label': 'Filter by agent', onchange: function () { xFeedF.agent = this.value; X.feedBuilt = -1; xDirty = true; }}, [h('option', {value: '', text: 'All agents'})].concat(S.order.map(function (id) { return h('option', {value: id, text: nm(id)}); })));
|
|
807
|
+
var teams = []; S.order.forEach(function (id) { var a = A(id), t = a && a.cfg.team; if (t && teams.indexOf(t) < 0) teams.push(t); });
|
|
808
|
+
var tm = h('select', {id: 'xfeed-team', 'aria-label': 'Filter by team', onchange: function () { xFeedF.team = this.value; X.feedBuilt = -1; xDirty = true; }}, [h('option', {value: '', text: 'All teams'})].concat(teams.map(function (t) { return h('option', {value: t, text: teamLbl(t)}); })));
|
|
809
|
+
var ty = h('select', {'aria-label': 'Filter by type', onchange: function () { xFeedF.type = this.value; X.feedBuilt = -1; xDirty = true; }}, FEED_TYPES.map(function (t) { return h('option', {value: t[0], text: t[1]}); }));
|
|
810
|
+
ag.id = 'xfeed-agent'; ty.id = 'xfeed-type';
|
|
811
|
+
ag.value = xFeedF.agent; tm.value = xFeedF.team; ty.value = xFeedF.type;
|
|
812
|
+
p.appendChild(h('div', {class: 'xfilters'}, [ag, tm, ty]));
|
|
813
|
+
p.appendChild(h('div', {id: 'xfeed', class: 'xfeed'}));
|
|
814
|
+
}
|
|
815
|
+
var box = $('xfeed'); if (!box) return;
|
|
816
|
+
var stick = box.scrollHeight - box.scrollTop - box.clientHeight < 40;
|
|
817
|
+
if (X.feedBuilt !== X.feed.length || X.pend.length === 0 && X.feedBuilt < 0) { /* fallthrough below */ }
|
|
818
|
+
if (X.feedBuilt < 0) {
|
|
819
|
+
box.innerHTML = ''; var fr = document.createDocumentFragment(); X.feed.filter(feedMatch).forEach(function (f) { fr.appendChild(feedEl(f)); }); box.appendChild(fr); X.pend = []; X.feedBuilt = 0; stick = true;
|
|
820
|
+
} else if (X.pend.length) {
|
|
821
|
+
var fr2 = document.createDocumentFragment(); X.pend.forEach(function (f) { if (feedMatch(f)) fr2.appendChild(feedEl(f)); }); X.pend = []; box.appendChild(fr2);
|
|
822
|
+
while (box.childElementCount > FEED_MAX) box.removeChild(box.firstElementChild);
|
|
823
|
+
}
|
|
824
|
+
if (stick) box.scrollTop = box.scrollHeight;
|
|
825
|
+
}
|
|
826
|
+
var WAIT_TXT = {starting: 'starting', 'waiting-first-output': 'waiting for first output', generating: 'generating', 'executing-tool': 'running a tool', 'waiting-dependency': 'waiting for a dependency', 'waiting-agent': 'waiting for another agent', 'waiting-owner': 'waiting for you', 'waiting-resource': 'waiting for a resource', paused: 'paused', recovering: 'recovering', idle: 'idle'};
|
|
827
|
+
function xLanesPane(p) {
|
|
828
|
+
var keeps = {}; Array.prototype.forEach.call(p.querySelectorAll('.xlive'), function (n) { keeps[n.dataset.a] = n.scrollTop; });
|
|
829
|
+
p.innerHTML = ''; p.dataset.built = 'lanes';
|
|
830
|
+
var wrap = h('div', {id: 'xlanes', class: 'xlanes'});
|
|
831
|
+
S.order.forEach(function (id) {
|
|
832
|
+
var L = X.lanes[id] || xLane(id), a = A(id), col = tcol(id);
|
|
833
|
+
var live = h('div', {class: 'xlive', 'data-a': id, text: L.live || ''});
|
|
834
|
+
wrap.appendChild(h('div', {class: 'xlane', style: '--tc:' + col}, [
|
|
835
|
+
h('div', {class: 'xlh'}, [h('b', {text: nm(id)}), h('span', {class: 'xteam', text: a ? teamLbl(a.cfg.team) : ''})]),
|
|
836
|
+
h('div', {class: 'xlw ' + (L.wait || 'none'), text: L.wait ? (WAIT_TXT[L.wait] || L.wait) + (L.detail ? ' · ' + xClip(L.detail, 60) : '') : '—'}),
|
|
837
|
+
L.tool ? h('div', {class: 'xlt mono', text: '⚙ ' + xClip(L.tool, 40)}) : null,
|
|
838
|
+
L.act ? h('div', {class: 'xla', text: xClip(L.act, 90)}) : null, live,
|
|
839
|
+
h('div', {class: 'xlf mono', text: L.turns + ' turns · ' + fmtN(L.tokens) + ' tok' + (L.at ? ' · last progress ' + clock(L.at) : '')})]));
|
|
840
|
+
if (keeps[id] != null) setTimeout(function () { live.scrollTop = L.fin ? 0 : 1e9; }, 0); else live.scrollTop = 1e9;
|
|
841
|
+
});
|
|
842
|
+
p.appendChild(wrap);
|
|
843
|
+
}
|
|
844
|
+
function xBoardPane(p0) {
|
|
845
|
+
p0.innerHTML = ''; p0.dataset.built = 'board';
|
|
846
|
+
var p = h('div', {id: 'xboard'}); p0.appendChild(p);
|
|
847
|
+
p.appendChild(secHead('CONTRIBUTIONS'));
|
|
848
|
+
var by = {}; Object.keys(X.contribs).forEach(function (k) { var c = X.contribs[k]; (by[c.agentId] = by[c.agentId] || []).push(c); });
|
|
849
|
+
var ids = Object.keys(by);
|
|
850
|
+
ids.forEach(function (aid) {
|
|
851
|
+
var card = h('div', {class: 'icard xb', style: '--tc:' + tcol(aid)}, [h('b', {text: nm(aid)})]);
|
|
852
|
+
by[aid].forEach(function (c) {
|
|
853
|
+
card.appendChild(h('div', {class: 'ml', text: (c.taskId ? 'task ' + c.taskId + ' · ' : '') + c.status}));
|
|
854
|
+
(c.findings || []).forEach(function (f) { card.appendChild(h('div', {class: 'xfind'}, [h('span', {class: 'sev ' + f.severity, text: f.severity}), h('span', {text: xClip(f.summary, 200)})])); });
|
|
855
|
+
if (!(c.findings || []).length) card.appendChild(h('div', {class: 'iempty', text: 'no findings'}));
|
|
856
|
+
});
|
|
857
|
+
p.appendChild(card);
|
|
858
|
+
});
|
|
859
|
+
if (!ids.length) p.appendChild(h('div', {class: 'iempty', text: 'No contributions yet.'}));
|
|
860
|
+
p.appendChild(secHead('DECISIONS'));
|
|
861
|
+
var dk = Object.keys(X.decisions);
|
|
862
|
+
dk.forEach(function (k) {
|
|
863
|
+
var d = X.decisions[k];
|
|
864
|
+
p.appendChild(h('div', {class: 'icard xb'}, [h('div', {class: 'xdh'}, [h('b', {text: d.title || d.id}), h('span', {class: 'dst ' + d.status, text: d.status + (d.revision > 1 ? ' · rev ' + d.revision : '')})]),
|
|
865
|
+
d.selected ? h('div', {class: 'xsel', text: 'selected: ' + xClip(d.selected, 240)}) : null, d.rationale ? h('div', {class: 'xrat', text: xClip(d.rationale, 400)}) : null]));
|
|
866
|
+
});
|
|
867
|
+
if (!dk.length) p.appendChild(h('div', {class: 'iempty', text: 'No decisions recorded yet.'}));
|
|
868
|
+
}
|
|
869
|
+
/* why a task has not started: open dependencies, else what its team's agents are waiting for (e.g. a free agent slot / the workspace) */
|
|
870
|
+
function xWhy(t, open) {
|
|
871
|
+
if (open.length) return 'waiting for: ' + open.join(', ');
|
|
872
|
+
var w = S.order.filter(function (id) { var a = A(id); return a && a.cfg.team === t.team && X.lanes[id] && X.lanes[id].wait && X.lanes[id].wait !== 'idle'; })
|
|
873
|
+
.map(function (id) { var L = X.lanes[id]; return nm(id) + ': ' + (WAIT_TXT[L.wait] || L.wait) + (L.detail ? ' (' + xClip(L.detail, 60) + ')' : ''); });
|
|
874
|
+
return w.length ? w.join(' · ') : 'ready: starts when the Director dispatches it';
|
|
875
|
+
}
|
|
876
|
+
function xTasksPane(p0) {
|
|
877
|
+
p0.innerHTML = ''; p0.dataset.built = 'tasks';
|
|
878
|
+
var p = h('div', {id: 'xgraph'}); p0.appendChild(p);
|
|
879
|
+
X.skipped.forEach(function (k) { p.appendChild(h('div', {class: 'icard xtask skipped'}, [h('div', {class: 'xdh'}, [h('b', {text: teamLbl(k.team)}), h('span', {class: 'tst skipped', text: 'skipped'})]), h('div', {class: 'xrat', text: xClip(k.reason, 200)})])); });
|
|
880
|
+
if (!X.taskOrder.length) { p.appendChild(h('div', {class: 'iempty', text: 'The Director has not planned a task graph for this run.'})); return; }
|
|
881
|
+
X.taskOrder.forEach(function (id) {
|
|
882
|
+
var t = X.tasks[id], open = t.deps.filter(function (d) { return !X.tasks[d] || X.tasks[d].status !== 'done'; });
|
|
883
|
+
p.appendChild(h('div', {class: 'icard xtask ' + t.status}, [h('div', {class: 'xdh'}, [h('b', {class: 'mono', text: id}), h('span', {class: 'tst ' + t.status, text: t.status}), h('span', {class: 'xteam', text: teamLbl(t.team)})]), h('div', {text: t.title}),
|
|
884
|
+
t.deps.length ? h('div', {class: 'ml', text: 'deps: ' + t.deps.join(', ')}) : null,
|
|
885
|
+
t.status === 'pending' ? h('div', {class: 'xwait', text: 'not started · ' + xWhy(t, open)}) : null, t.note ? h('div', {class: 'xrat', text: xClip(t.note, 200)}) : null]));
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
function xFrame(now) {
|
|
889
|
+
if (now - xLast < 250) return; xLast = now;
|
|
890
|
+
if (xTab === 'inspect') { if (xDirty) xTeleStrip(); xDirty = false; return; }
|
|
891
|
+
if (!xDirty && !(xTab === 'feed' && X.pend.length)) return;
|
|
892
|
+
var p = $('xpane'), wasDirty = xDirty; xDirty = false; xTeleStrip();
|
|
893
|
+
if (xTab === 'feed') { if (p.dataset.built !== 'feed') X.feedBuilt = -1; xFeedPane(p); }
|
|
894
|
+
else if (!wasDirty) return;
|
|
895
|
+
else if (xTab === 'lanes') xLanesPane(p); else if (xTab === 'board') xBoardPane(p); else if (xTab === 'tasks') xTasksPane(p);
|
|
896
|
+
}
|
|
897
|
+
|
|
696
898
|
/* views */
|
|
697
899
|
function setView(v) {
|
|
698
900
|
S.view = v; ['live', 'settings', 'runs'].forEach(function (x) { $(x).hidden = x !== v; });
|
|
@@ -1218,7 +1420,7 @@
|
|
|
1218
1420
|
}
|
|
1219
1421
|
function limits() {
|
|
1220
1422
|
var f = h('div'); f.appendChild(h('div', {class: 'sec', text: 'LIMITS'}));
|
|
1221
|
-
f.appendChild(h('div', {class: 'row3'}, [fld('Discussion rounds per team', bind(h('input', {type: 'number', value: draft.limits.baRounds, min:
|
|
1423
|
+
f.appendChild(h('div', {class: 'row3'}, [fld('Discussion rounds per team (0 = parallel contributions)', bind(h('input', {type: 'number', value: draft.limits.baRounds, min: 0}), draft.limits, 'baRounds', true)), fld('Max send-backs per team', bind(h('input', {type: 'number', value: draft.limits.qcLoops, min: 0}), draft.limits, 'qcLoops', true)), fld('Agent timeout (ms)', bind(h('input', {type: 'number', value: draft.limits.agentTimeoutMs}), draft.limits, 'agentTimeoutMs', true))]));
|
|
1222
1424
|
return f;
|
|
1223
1425
|
}
|
|
1224
1426
|
render();
|
package/gui/comic/engine.js
CHANGED
|
@@ -165,8 +165,26 @@
|
|
|
165
165
|
touch(b);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
// live text of a running turn: shown as the status line of that agent's open working beat (real text only, replaced by the final message)
|
|
169
|
+
function delta(e) {
|
|
170
|
+
if (!e.agentId || typeof e.text !== 'string') return;
|
|
171
|
+
var b = S.open[e.agentId];
|
|
172
|
+
if (!b) return;
|
|
173
|
+
b._live = ((b._live || '') + e.text).slice(-600);
|
|
174
|
+
var t = clip(normalize(b._live), 160);
|
|
175
|
+
if (!t) return;
|
|
176
|
+
b._status = t; b.status = t;
|
|
177
|
+
var ls = [];
|
|
178
|
+
if (b._par) ls.push(line(null, 'narration', b._par));
|
|
179
|
+
ls.push(line(e.agentId, 'quote', t));
|
|
180
|
+
if (b._ops) ls.push(line(null, 'status', 'Đã thực hiện ' + b._ops + ' thao tác công cụ'));
|
|
181
|
+
b.lines = ls; touch(b);
|
|
182
|
+
}
|
|
183
|
+
var SEV = ['critical', 'high', 'medium', 'low', 'info'];
|
|
184
|
+
|
|
168
185
|
function push(e) {
|
|
169
186
|
added = []; updated = [];
|
|
187
|
+
if (e && e.type === 'agent.delta') { try { delta(e); } catch (err) { /* live preview only */ } return { added: added, updated: updated }; }
|
|
170
188
|
if (!e || typeof e.seq !== 'number') return { added: added, updated: updated };
|
|
171
189
|
var key = (e.runId || '') + ':' + e.seq;
|
|
172
190
|
if (S.seen[key]) return { added: [], updated: [] };
|
|
@@ -299,6 +317,32 @@
|
|
|
299
317
|
case 'lane.chosen':
|
|
300
318
|
mk(e, { type: 'lane', title: (e.by === 'owner' ? 'Chủ dự án chọn quy trình ' : e.by === 'fallback' ? 'Hệ thống chọn quy trình mặc định ' : 'Director chọn quy trình ') + (normalize(e.name || e.laneId || '', 60)), team: 'director', scene: 'briefing', weight: 'small', cast: e.by === 'owner' ? [cast('owner', 'center', 'presenting', true)] : e.by === 'fallback' ? [] : [cast(S.ctx.directorId, 'center', 'presenting', true)], lines: e.reason ? [line(null, 'narration', clip(normalize(e.reason), 160))] : [], truth: 'confirmed', status: e.by === 'fallback' ? 'Quy trình mặc định' : 'Đã chọn quy trình' });
|
|
301
319
|
return;
|
|
320
|
+
case 'agent.mail': {
|
|
321
|
+
var mf = endpoint(e.from), mt = endpoint(e.to), body = e.subject ? e.subject + (e.text ? ': ' + e.text : '') : e.text;
|
|
322
|
+
mk(e, { type: 'mail', title: mf.label + ' gửi thư cho ' + mt.label, team: teamOf(e.from), scene: 'handoff', weight: 'small', cast: pushCast(pushCast([], castEp(mf, 'left', 'sending', true)), castEp(mt, 'right', 'listening', false)), lines: [line(mf.agentId, 'quote', excerpt(body || '', 160), fullText(body || ''))], truth: 'reported', status: e.kind === 'ask' ? 'Câu hỏi' : e.kind === 'answer' ? 'Trả lời' : 'Thư', transfer: { from: mf.agentId || e.from, to: mt.agentId || e.to }, props: ['document'] });
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
case 'task.created': {
|
|
326
|
+
var tk = teamName(e.team), dep = (e.deps || []).length ? ' (sau: ' + e.deps.join(', ') + ')' : '';
|
|
327
|
+
mk(e, { type: 'task', title: 'Task ' + e.taskId + ' cho ' + tk, team: e.team, scene: 'briefing', weight: 'small', cast: [cast(S.ctx.directorId, 'center', 'presenting', true)], lines: [line(S.ctx.directorId, 'narration', clip(normalize(e.title || ''), 140) + dep, fullText(e.title || ''))], truth: 'planned', status: 'Task mới' });
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
case 'task.updated': {
|
|
331
|
+
var tdone = e.status === 'done', tbad = e.status === 'failed' || e.status === 'blocked';
|
|
332
|
+
mk(e, { type: 'task', title: 'Task ' + e.taskId + ': ' + e.status, team: 'director', scene: tbad ? 'blocked' : 'briefing', weight: 'small', cast: [cast(S.ctx.directorId, 'center', tbad ? 'concerned' : 'speaking', true)], lines: [line(null, 'narration', 'Task ' + e.taskId + ' → ' + e.status + (e.note ? ': ' + clip(normalize(e.note), 120) : ''))], truth: tdone ? 'confirmed' : tbad ? 'failed' : 'reported', status: e.status });
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
case 'contribution.published': {
|
|
336
|
+
var ct = e.contribution || {}, fl = ct.findings || [], top = '';
|
|
337
|
+
for (var si = 0; si < SEV.length && !top; si++) for (var fi = 0; fi < fl.length; fi++) if (fl[fi].severity === SEV[si]) { top = SEV[si]; break; }
|
|
338
|
+
mk(e, { type: 'contribution', title: who(ct.agentId) + ' đóng góp', team: teamOf(ct.agentId), scene: 'discussion', weight: 'small', cast: [cast(ct.agentId, 'center', 'presenting', true)], lines: [line(ct.agentId, 'quote', fl.length + (fl.length === 1 ? ' finding' : ' findings') + (top ? ' (cao nhất: ' + top + ')' : '') + (ct.status === 'partial' ? ' - tạm thời' : ''))], truth: 'reported', status: 'Đóng góp' });
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
case 'decision.recorded': {
|
|
342
|
+
var dr = e.decision || {}, dz = S.ctx.directorId;
|
|
343
|
+
mk(e, { type: 'decision', title: 'Director ghi quyết định', team: 'director', scene: 'briefing', weight: 'small', cast: [cast(dz, 'center', 'presenting', true)], lines: [line(dz, 'quote', clip(normalize(dr.title || ''), 160), fullText(dr.title || ''))], truth: dr.status === 'committed' || dr.status === 'verified' ? 'confirmed' : 'planned', status: dr.status || 'Quyết định' });
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
302
346
|
case 'run.completed': {
|
|
303
347
|
closeAll(e.at); S.completed = true; S.waiting = false;
|
|
304
348
|
var di3 = S.ctx.directorId, rep2 = e.report || '', rv = S.ep && S.rv[S.ep.id];
|
package/gui/index.html
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<div id="runtabs" hidden></div>
|
|
38
38
|
<canvas id="net" aria-label="Agent topology"></canvas>
|
|
39
39
|
<div id="bubbles"></div>
|
|
40
|
-
<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>
|
|
40
|
+
<div id="mission"><span class="mtag" id="mtag">READY</span><span id="mgoal">No active run — type a mission below.</span><span id="rctl" hidden></span><button class="primary" id="bHint" type="button">+ New run</button></div>
|
|
41
41
|
<div id="now"><span class="nowtag">NOW</span><span id="nowtext">Waiting for a mission…</span></div>
|
|
42
42
|
<div id="hobanner"></div>
|
|
43
43
|
<div id="idleHint"><span class="nowtag">READY</span><span>Type a mission in the box below and press Enter.</span></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngockhoale/ckit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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": {
|