diff --git a/hive-ag3nt/assets/app.js b/hive-ag3nt/assets/app.js
index f5a2afd..709d9bd 100644
--- a/hive-ag3nt/assets/app.js
+++ b/hive-ag3nt/assets/app.js
@@ -656,6 +656,79 @@
log.innerHTML = '';
function trim(s, n) { return s.length > n ? s.slice(0, n) + '…' : s; }
+ // Render a message body as markdown into a new
.
+ // Wraps `marked.parse` so the per-row body element carries the
+ // `.md` class (CSS in TERMINAL_CSS scopes paragraph/code/list
+ // styles to it). Falls back to a plain text node if marked isn't
+ // loaded (network glitch, asset 404) so the body still renders.
+ function mdNode(text) {
+ const div = document.createElement('div');
+ div.className = 'md';
+ const src = String(text || '');
+ if (window.marked && typeof window.marked.parse === 'function') {
+ try {
+ marked.setOptions({ breaks: true, gfm: true });
+ div.innerHTML = marked.parse(src);
+ } catch (err) {
+ console.warn('marked failed', err);
+ div.textContent = src;
+ }
+ } else {
+ div.textContent = src;
+ }
+ return div;
+ }
+ // Build a default-open details row whose body is markdown-rendered.
+ // Used by send / ask / answer tool_use renderers and by `recv`
+ // tool_result so message-bearing rows show their content inline
+ // without an extra click.
+ function detailsOpenMd(api, cls, summary, body) {
+ const d = api.details(cls, summary, '');
+ d.open = true;
+ const pre = d.querySelector('pre.tool-body');
+ if (pre) {
+ pre.replaceWith(mdNode(body));
+ } else {
+ d.appendChild(mdNode(body));
+ }
+ return d;
+ }
+ // Generic args-pretty-printer for unknown / extra-MCP tools. The
+ // built-in switch handles the common claude/hyperhive tools; this
+ // is the fallback so an `mcp__matrix__send_message` or similar
+ // doesn't dump raw JSON. Heuristics: single string-valued field →
+ // `Name field: "value"`; single dict-valued field → `Name field
+ // {…}`; otherwise compact JSON. Always trimmed to fit a row.
+ function fmtArgsGeneric(name, input) {
+ const keys = Object.keys(input || {});
+ if (keys.length === 0) return name + '()';
+ if (keys.length === 1) {
+ const k = keys[0];
+ const v = input[k];
+ if (typeof v === 'string') {
+ const oneline = v.replace(/\s+/g, ' ').trim();
+ return name + ' ' + k + ': ' + JSON.stringify(trim(oneline, 100));
+ }
+ if (typeof v === 'number' || typeof v === 'boolean') {
+ return name + ' ' + k + ': ' + JSON.stringify(v);
+ }
+ }
+ // Multi-field: render `k: v` pairs with strings/numbers inlined and
+ // anything else summarised by type so the row stays readable.
+ const pretty = keys.slice(0, 4).map((k) => {
+ const v = input[k];
+ if (v == null) return k + ': null';
+ if (typeof v === 'string') {
+ const oneline = v.replace(/\s+/g, ' ').trim();
+ return k + ': ' + JSON.stringify(trim(oneline, 40));
+ }
+ if (typeof v === 'number' || typeof v === 'boolean') return k + ': ' + v;
+ if (Array.isArray(v)) return k + `: [${v.length}]`;
+ return k + ': {…}';
+ });
+ const tail = keys.length > 4 ? ' …+' + (keys.length - 4) : '';
+ return name + ' ' + pretty.join(' · ') + tail;
+ }
// Pretty-print a tool call: per-known-tool format, fallback to JSON
// for unknown tools.
function fmtToolUse(c) {
@@ -678,7 +751,7 @@
case 'mcp__hyperhive__kill': return short + ' ' + (input.name || '');
case 'mcp__hyperhive__request_apply_commit':
return short + ' ' + (input.agent || '') + ' @ ' + (input.commit_ref || '').slice(0, 12);
- default: return name + ' ' + trim(JSON.stringify(input), 200);
+ default: return fmtArgsGeneric(short, input);
}
}
// Build a "rich" tool_use row for tools whose input has a body we
@@ -709,37 +782,73 @@
+ '\n'
+ newLines.map(l => '+ ' + l).join('\n');
}
- const summary = '→ ' + name + ' ' + path + ' · '
+ // Summaries on expandable rows omit the row's directional glyph
+ // (`→`) — the disclosure marker (`▸/▾`) from CSS sits in the
+ // prefix column for every row kind, and the row's cyan colour
+ // already signals "outbound tool".
+ const summary = name + ' ' + path + ' · '
+ (minus ? '-' + minus + ' ' : '') + '+' + plus;
return api.detailsDiff('tool-use', summary, body);
}
+ // Message-bearing tools render default-open with a markdown body so
+ // the operator sees the content without an extra click. send / ask
+ // address a target; answer attaches to an existing question id.
if (name === 'mcp__hyperhive__send') {
const to = input.to || '?';
const body = String(input.body || '');
- const headline = body.replace(/\s+/g, ' ').trim().slice(0, 80);
const lines = body.split('\n').length;
- const summary = '→ send → ' + to + (lines > 1 ? ` · ${lines}L` : '')
- + (headline ? ' · ' + headline + (body.length > 80 ? '…' : '') : '');
- return api.details('tool-use', summary, body);
+ return detailsOpenMd(api, 'tool-use',
+ 'send → ' + to + (lines > 1 ? ` · ${lines}L` : ''),
+ body);
+ }
+ if (name === 'mcp__hyperhive__ask') {
+ const to = input.to || 'operator';
+ const q = String(input.question || '');
+ const lines = q.split('\n').length;
+ return detailsOpenMd(api, 'tool-use',
+ 'ask → ' + to + (lines > 1 ? ` · ${lines}L` : ''),
+ q);
+ }
+ if (name === 'mcp__hyperhive__answer') {
+ const id = input.id != null ? String(input.id) : '?';
+ const a = String(input.answer || '');
+ const lines = a.split('\n').length;
+ return detailsOpenMd(api, 'tool-use',
+ 'answer #' + id + (lines > 1 ? ` · ${lines}L` : ''),
+ a);
}
return null;
}
+ // Track tool_use_id → tool name so we can decide on rendering when the
+ // matching tool_result lands later. Lets us default-open the body for
+ // message-bearing tools (`recv`) while keeping shell/file tool output
+ // collapsed unless the operator clicks. Cleared on /clear; otherwise
+ // grows with the session — entries are tiny strings.
+ const toolNameById = new Map();
function renderToolResult(c, api) {
const txt = Array.isArray(c.content)
? c.content.map(p => p.text || '').join('')
: (c.content || '');
- const summary = '← ' + (() => {
- const trimmed = txt.replace(/\s+/g, ' ').trim();
+ const sourceName = c.tool_use_id ? toolNameById.get(c.tool_use_id) : null;
+ const isMessageBearing = sourceName === 'mcp__hyperhive__recv';
+ const trimmed = txt.replace(/\s+/g, ' ').trim();
+ const summaryBody = (() => {
if (!trimmed) return '(empty)';
if (trimmed.length <= 120) return trimmed;
const lines = txt.split('\n').filter(l => l.length).length;
const headline = trimmed.slice(0, 90) + '…';
return `${lines}L · ${headline}`;
})();
+ // Flat row: keep the `←` glyph in the prefix column. Details rows
+ // drop it — the `▸/▾` disclosure marker sits in that column via CSS.
+ if (isMessageBearing && txt.trim()) {
+ return detailsOpenMd(api, 'tool-result-block',
+ 'recv ← ' + summaryBody, txt);
+ }
if (!txt.trim() || txt.length <= 120) {
- api.row('tool-result', summary);
+ api.row('tool-result', '← ' + summaryBody);
} else {
- api.details('tool-result-block', summary, txt);
+ api.details('tool-result-block', summaryBody, txt);
}
}
// Pretty-render claude's background-task subagent events
@@ -783,12 +892,19 @@
}
if (v.type === 'assistant' && v.message && v.message.content) {
for (const c of v.message.content) {
- if (c.type === 'text' && c.text && c.text.trim()) api.row('text', c.text);
+ if (c.type === 'text' && c.text && c.text.trim()) {
+ // Assistant prose renders with markdown — claude often
+ // emits bullets / fenced code / inline code; raw text
+ // loses the structure.
+ const row = api.row('text', '');
+ row.appendChild(mdNode(c.text));
+ }
else if (c.type === 'thinking') {
const txt = (c.thinking || c.text || '').trim();
api.row('thinking', txt ? '· ' + txt : '· thinking …');
}
else if (c.type === 'tool_use') {
+ if (c.id && c.name) toolNameById.set(c.id, c.name);
if (!renderRichToolUse(c, api)) {
api.row('tool-use', '→ ' + fmtToolUse(c));
}
@@ -802,7 +918,10 @@
}
return;
}
- api.row('sys', '· ' + trim(JSON.stringify(v), 200));
+ // Catch-all for unrecognised stream-json shapes. Loud (orange) so
+ // silently-dropped event types surface in the scrollback for
+ // follow-up classification.
+ api.row('sys', '! ' + trim(JSON.stringify(v), 200));
}
// Count open turns across the backfill replay so the live banner +
@@ -844,7 +963,22 @@
(ev.ok ? '✓' : '✗') + ' turn ' + (ev.ok ? 'ok' : 'fail')
+ (ev.note ? ' — ' + ev.note : ''));
},
- note(ev, api) { api.row('note', '· ' + ev.text); },
+ note(ev, api) {
+ const t = String(ev.text || '');
+ // stderr lines coming off the claude pump get an orange `!`
+ // glyph so they're not visually fused with ambient harness
+ // chatter. Operator-initiated notes (/cancel, /compact,
+ // /model, new-session) get a mauve italic affordance so the
+ // scrollback distinguishes "the operator did this" from
+ // "the harness did this on its own."
+ if (t.startsWith('stderr:')) {
+ api.row('note stderr', '! ' + t);
+ } else if (t.startsWith('operator:')) {
+ api.row('note op', '· ' + t);
+ } else {
+ api.row('note', '· ' + t);
+ }
+ },
stream(ev, api) {
const v = Object.assign({}, ev); delete v.kind;
renderStream(v, api);
diff --git a/hive-ag3nt/assets/index.html b/hive-ag3nt/assets/index.html
index a0c86e7..8635a32 100644
--- a/hive-ag3nt/assets/index.html
+++ b/hive-ag3nt/assets/index.html
@@ -39,6 +39,7 @@
+