tool folding
This commit is contained in:
Vendored
+31
-9
@@ -313,12 +313,18 @@ export function mountChat(root, src, makeHead) {
|
||||
};
|
||||
const runHead = (run) => [subagentTag(run.parent, ctx), runSummary(run.calls)];
|
||||
const addToRun = (el, call, parent) => {
|
||||
const run = ctx.run;
|
||||
if (!run || run.parent !== parent) {
|
||||
ctx.run = { first: el, group: undefined, calls: call ? [call] : [], parent };
|
||||
put(el);
|
||||
const sub = ctx.subagents.get(parent);
|
||||
if (sub) {
|
||||
sub.run = extendRun(sub.run, el, call, parent, (e) => sub.body.append(e));
|
||||
return;
|
||||
}
|
||||
ctx.run = extendRun(ctx.run, el, call, parent, put);
|
||||
};
|
||||
const extendRun = (run, el, call, parent, place) => {
|
||||
if (!run || run.parent !== parent) {
|
||||
place(el);
|
||||
return { first: el, group: undefined, calls: call ? [call] : [], parent };
|
||||
}
|
||||
if (call) {
|
||||
run.calls.push(call);
|
||||
}
|
||||
@@ -333,6 +339,7 @@ export function mountChat(root, src, makeHead) {
|
||||
}
|
||||
run.group.body.append(el);
|
||||
replace(run.group.summary, ...runHead(run));
|
||||
return run;
|
||||
};
|
||||
let stream;
|
||||
const dropStream = () => {
|
||||
@@ -429,9 +436,16 @@ export function mountChat(root, src, makeHead) {
|
||||
markReview(button, r);
|
||||
}
|
||||
}
|
||||
const sub = ctx.subagents.get(parent);
|
||||
if (ev.kind === "agent.tool_call" && isSubagentCall(p)) {
|
||||
const el = renderSubagent(p, ctx);
|
||||
if (sub) {
|
||||
sub.run = undefined;
|
||||
sub.body.append(el);
|
||||
continue;
|
||||
}
|
||||
ctx.run = undefined;
|
||||
put(renderSubagent(p, ctx));
|
||||
put(el);
|
||||
continue;
|
||||
}
|
||||
if (ev.kind === "agent.tool_call") {
|
||||
@@ -446,6 +460,11 @@ export function mountChat(root, src, makeHead) {
|
||||
addToRun(el, undefined, parent);
|
||||
continue;
|
||||
}
|
||||
if (sub) {
|
||||
sub.run = undefined;
|
||||
sub.body.append(el);
|
||||
continue;
|
||||
}
|
||||
ctx.run = undefined;
|
||||
if (ev.kind === "turn.ended") {
|
||||
ctx.open = false;
|
||||
@@ -785,8 +804,10 @@ function subagentTag(parent, ctx) {
|
||||
if (!parent) {
|
||||
return null;
|
||||
}
|
||||
const sub = ctx.subagents.get(parent);
|
||||
return h("span", { class: "subagent-tag", title: sub?.description ?? "" }, `↳ ${sub?.type ?? "subagent"}`);
|
||||
if (ctx.subagents.has(parent)) {
|
||||
return null;
|
||||
}
|
||||
return h("span", { class: "subagent-tag" }, "↳ subagent");
|
||||
}
|
||||
function renderToolCall(p, ctx) {
|
||||
const result = h("div", { class: "tool-result pending" }, "running…");
|
||||
@@ -814,10 +835,11 @@ function renderSubagent(p, ctx) {
|
||||
const description = String(input["description"] ?? "");
|
||||
const status = h("span", { class: "subagent-status" }, "starting…");
|
||||
const result = h("div", { class: "tool-result pending" }, "running…");
|
||||
const body = h("div", { class: "subagent-body" });
|
||||
const tag = subagentTag(parentOf(p), ctx);
|
||||
ctx.tools.set(id, result);
|
||||
ctx.subagents.set(id, { type, description, status });
|
||||
return h("details", { class: "tool subagent" }, h("summary", {}, tag, h("span", { class: "tool-name" }, `${p["name"]} ${type}`), " ", h("span", { class: "tool-brief" }, description), " ", status), markdown(String(input["prompt"] ?? ""), "text md subagent-prompt", { taskId: ctx.taskId }), result);
|
||||
ctx.subagents.set(id, { type, description, status, body, run: undefined });
|
||||
return h("details", { class: "tool subagent" }, h("summary", {}, tag, h("span", { class: "tool-name" }, `${p["name"]} ${type}`), " ", h("span", { class: "tool-brief" }, description), " ", status), markdown(String(input["prompt"] ?? ""), "text md subagent-prompt", { taskId: ctx.taskId }), body, result);
|
||||
}
|
||||
function claudeTaskStatus(p, ctx) {
|
||||
if (p["type"] !== "system") {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user