@thothdev/pink 1.0.27 → 1.0.29

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/CHANGELOG.md CHANGED
@@ -3,10 +3,19 @@
3
3
  O Pink é um fork do Pi (MIT, veja `LICENSE-PI.txt` e `NOTICE.md`). Aqui só entra o que mudou no Pink; a base de cada
4
4
  versão está no campo `upstream` do `rebrand.json` do repositório.
5
5
 
6
- ## [1.0.27] - 2026-11-28
7
-
8
- - `/agente` (OpenCode e outros ACP): a resposta que o agente manda depois do fim do turno (subagente ou comando em segundo plano que terminou) agora aparece no chat; antes era descartada e o agente parecia ter parado. Pedidos de permissão nesse intervalo continuam sendo perguntados.
9
-
6
+ ## [1.0.29] - 2026-11-28
7
+
8
+ - Nos modelos logados no Pink e no `/agente`: ao lançar subagentes, o chat mostra o bloco "N subagentes lançados" com o nome e a tarefa de cada um, sem ficar escondido no resumo.
9
+
10
+ ## [1.0.28] - 2026-11-28
11
+
12
+ - `/agente opencode`: subagente que o OpenCode lança sozinho, depois da resposta, volta a aparecer na lista, e o que está trabalhando não aparece mais como pausado.
13
+ - `/agente`: o trabalho que o agente faz depois do fim do turno sai num bloco só; antes cada passo virava um bloco repetindo o nome do agente e o modelo.
14
+
15
+ ## [1.0.27] - 2026-11-28
16
+
17
+ - `/agente` (OpenCode e outros ACP): a resposta que o agente manda depois do fim do turno (subagente ou comando em segundo plano que terminou) agora aparece no chat; antes era descartada e o agente parecia ter parado. Pedidos de permissão nesse intervalo continuam sendo perguntados.
18
+
10
19
  ## [1.0.26] - 2026-11-28
11
20
 
12
21
  - `web_search` usa o servidor wigolo local (`127.0.0.1:3333`) quando ele está no ar; sem ele, ou se a resposta não for dele, segue no DuckDuckGo como antes. Nada novo para configurar.
@@ -468,8 +468,11 @@ export function acpModels(session: any): ModelChoice[] {
468
468
  export type Resume = { id?: string; keep?: boolean; live?: AcpConn; late?: LateTurn };
469
469
  // o que o agente manda sozinho, sem turno aberto: um subagente ou comando em segundo plano terminou e ele respondeu
470
470
  // (owner 2026-11-28: o Pink descartava e o agente "parava"); quem abriu o agente diz como montar e mostrar
471
- export type LateTurn = { fresh: () => any; deliver: (result: any) => void; ask?: () => Ask | undefined; quietMs?: number };
472
- export const LATE_QUIET_MS = 4000; // o ACP não avisa o fim desse turno: silêncio por este tempo fecha a resposta
471
+ export type LateTurn = { fresh: () => any; deliver: (result: any) => void; ask?: () => Ask | undefined; quietMs?: number; idleMs?: number };
472
+ // o ACP não avisa o fim desse turno. Silêncio depois de texto fecha a resposta; depois de pensamento ou comando o agente
473
+ // ainda está trabalhando e espera bem mais, senão cada passo vira um bloco com o nome do agente (owner 2026-11-28)
474
+ export const LATE_QUIET_MS = 8000;
475
+ export const LATE_IDLE_MS = 180000;
473
476
  // `force` (Esc): um agente preso (ex.: opencode esperando um subagente que não abre) ignora o fim da entrada, e no Windows
474
477
  // o kill pega só o cmd do npm: o opencode.exe seguia vivo, segurando os pipes, e o Esc não soltava (owner 2026-11-26)
475
478
  export function closeKept(resume?: Resume, force = false, kill: typeof spawn = spawn) {
@@ -746,12 +749,14 @@ function flushLate(conn: AcpConn, resume?: Resume) {
746
749
  function lateUpdate(conn: AcpConn, update: any, resume?: Resume) {
747
750
  if (!resume?.late) return;
748
751
  // só começa com algo que a pessoa veria: avisos de uso e de comandos não viram resposta
749
- if (!conn.lateBuffer && !["agent_message_chunk", "agent_thought_chunk", "tool_call"].includes(update?.sessionUpdate)) return;
752
+ const kind = update?.sessionUpdate;
753
+ if (!conn.lateBuffer && !["agent_message_chunk", "agent_thought_chunk", "tool_call"].includes(kind)) return;
750
754
  conn.lateBuffer ??= { result: resume.late.fresh(), state: { text: "" } };
751
755
  if (conn.model) conn.lateBuffer.result.model = conn.model;
752
756
  applyAcpUpdate(update, conn.lateBuffer.result, conn.lateBuffer.state, () => {});
757
+ if (!["agent_message_chunk", "agent_thought_chunk", "tool_call", "tool_call_update"].includes(kind)) return; // uso e comandos não mexem no prazo
753
758
  clearTimeout(conn.lateTimer);
754
- conn.lateTimer = setTimeout(() => flushLate(conn, resume), resume.late.quietMs ?? LATE_QUIET_MS);
759
+ conn.lateTimer = setTimeout(() => flushLate(conn, resume), kind === "agent_message_chunk" || update?.rawOutput?.metadata?.status === "running" ? (resume.late.quietMs ?? LATE_QUIET_MS) : (resume.late.idleMs ?? LATE_IDLE_MS));
755
760
  conn.lateTimer.unref?.();
756
761
  }
757
762
  function acpOpen(child: any, name: string, exited: Promise<number>, resume?: Resume): AcpConn {
@@ -130,12 +130,14 @@ export function contextFor(entries: any[] | undefined, agent: string, max = 1600
130
130
  export const handoffText = (agent: string, asks: string[]) =>
131
131
  `${t(`O ${agent} foi interrompido na troca de modelo. O que ele já fez está acima; continue este pedido:`, `${agent} fue interrumpido al cambiar de modelo. Lo que ya hizo está arriba; continúa este pedido:`, `${agent} was stopped by the model switch. What it already did is above; continue this request:`)}\n\n${asks.filter((ask) => ask.trim()).join("\n\n")}`;
132
132
  export const CHILD_DONE_SHOWN_MS = 15000;
133
- function childState(row: any): { state: "running" | "paused" | "done" | "failed" | "stopped"; end?: number } {
133
+ function childState(row: any, now: number): { state: "running" | "paused" | "done" | "failed" | "stopped"; end?: number } {
134
134
  if (row.last === undefined) {
135
135
  const busy = Number(row.busy) || 0;
136
136
  const idle = Number(row.idle) || 0;
137
137
  if (idle && idle >= busy) return { state: row.outcome === "failed" ? "failed" : row.outcome === "interrupted" ? "stopped" : "done", end: idle };
138
- if (row.suspended && Number(row.suspended) >= busy) return { state: "paused" };
138
+ // o opencode grava time_suspended também na sessão que está trabalhando (owner 2026-11-28: aparecia "pausado");
139
+ // só vale como pausa se ela parou de gravar. shortcut: um comando mudo por mais de 5 min também aparece pausado
140
+ if (row.suspended && Number(row.suspended) >= busy && now - Number(row.updated) > 5 * 60000) return { state: "paused" };
139
141
  return { state: "running" };
140
142
  }
141
143
  let last: any = {};
@@ -150,7 +152,7 @@ const CHILD_MARK: Record<string, string | undefined> = { running: undefined, pau
150
152
  export function childAgents(rows: any[], now: number) {
151
153
  const out: any[] = [];
152
154
  for (const row of rows ?? []) {
153
- const { state, end } = childState(row);
155
+ const { state, end } = childState(row, now);
154
156
  if (end && now - end > CHILD_DONE_SHOWN_MS) continue; // terminou há tempo: sai da lista
155
157
  if (!end && now - Number(row.updated) > 10 * 60000) continue; // parado há 10 min: o processo morreu
156
158
  const title = String(row.title ?? "");
@@ -275,7 +277,10 @@ export function steps(result: any, cwd = "") {
275
277
  if (part.type === "text" && part.text?.trim()) out.push({ kind: "text", text: part.text });
276
278
  // o pensamento chega de uma vez: tempo quase 0 não diz nada; o texto fica para abrir com clique ou ctrl+t (owner 2026-11-25)
277
279
  else if (part.type === "thinking") out.push({ kind: "thinking", ms: part.ms >= 100 ? part.ms : 0, text: String(part.thinking ?? "").trim().slice(0, THOUGHT_MAX) });
278
- else if (part.type === "toolCall") out.push({ kind: "tool", line: pinkTool(part, cwd) });
280
+ else if (part.type === "toolCall") {
281
+ const child = result.subagents?.[part.id]; // lançamento de subagente: bloco próprio com nome e tarefa
282
+ out.push(child ? { kind: "agents", list: [{ agent: child.agent, task: child.task }] } : { kind: "tool", line: pinkTool(part, cwd) });
283
+ }
279
284
  }
280
285
  }
281
286
  return out;
@@ -283,10 +288,19 @@ export function steps(result: any, cwd = "") {
283
288
 
284
289
  // como no Claude Code: ferramentas seguidas viram uma linha de resumo. A tela vira "tela · 16 ações: list_windows,
285
290
  // get_window_state ×5, click ×4..." e linhas iguais em sequência viram "linha ×N" (antes eram dezenas de linhas iguais)
291
+ // como no Claude Code: "● 3 subagentes lançados" e uma linha por subagente, com a tarefa (owner 2026-11-28)
292
+ export function agentLines(list: { agent: string; task?: string }[]) {
293
+ const head = list.length === 1 ? t("1 subagente lançado", "1 subagente lanzado", "1 subagent launched") : `${list.length} ${t("subagentes lançados", "subagentes lanzados", "subagents launched")}`;
294
+ return { head, items: list.map((item, index) => ({ branch: index === list.length - 1 ? "└" : "├", agent: clean(item.agent), task: clean(item.task) })) };
295
+ }
286
296
  export function compact(list: any[]) {
287
297
  const out: any[] = [];
288
298
  for (const step of list) {
289
299
  const last = out.at(-1);
300
+ if (step.kind === "agents" && last?.kind === "agents") {
301
+ out[out.length - 1] = { kind: "agents", list: [...last.list, ...step.list] };
302
+ continue;
303
+ }
290
304
  const screen = step.kind === "tool" && String(step.line).startsWith("tela · ");
291
305
  if (screen && last?.screen) last.actions.push(String(step.line).split(" ")[2]);
292
306
  else if (step.kind === "tool" && last?.kind === "tool" && !last.screen && last.base === step.line) last.count++;
@@ -306,7 +320,7 @@ export function compact(list: any[]) {
306
320
 
307
321
  export function render(result: any, cwd = ""): string {
308
322
  const all = compact(steps(result, cwd));
309
- const tools = all.filter((step) => step.kind === "tool").map((step) => `→ ${step.line}`);
323
+ const tools = all.filter((step) => step.kind === "tool" || step.kind === "agents").map((step) => (step.kind === "tool" ? `→ ${step.line}` : step.list.map((item: any) => `→ ${t("subagente", "subagente", "subagent")} ${item.agent}: ${item.task}`).join("\n")));
310
324
  const answer = all.filter((step) => step.kind === "text").at(-1)?.text ?? "";
311
325
  const body = [tools.join("\n"), answer].filter(Boolean).join("\n\n");
312
326
  if (result.stopReason === "error") return [body, `⚠ ${result.errorMessage}`].filter(Boolean).join("\n\n");
@@ -320,7 +334,13 @@ export function liveLines(result: any, width: number, cwd = ""): string[] {
320
334
  const room = Math.max(10, width - 4);
321
335
  const head = (text: unknown) => { const line = clean(text); return line.length > room ? `${line.slice(0, room - 1)}…` : line; };
322
336
  const tail = (text: unknown) => tailLine(text, room);
323
- const done = compact(steps(result, cwd)).map((step: any) => (step.kind === "tool" ? `→ ${head(step.line)}` : step.kind === "thinking" ? thinkingLabel(step.ms) : `● ${head(step.text)}`));
337
+ const done = compact(steps(result, cwd)).flatMap((step: any) => {
338
+ if (step.kind === "agents") {
339
+ const block = agentLines(step.list);
340
+ return [`● ${block.head}`, ...block.items.map((item) => ` ${item.branch} ${head(`${item.agent}${item.task ? ` (${item.task})` : ""}`)}`)];
341
+ }
342
+ return [step.kind === "tool" ? `→ ${head(step.line)}` : step.kind === "thinking" ? thinkingLabel(step.ms) : `● ${head(step.text)}`];
343
+ });
324
344
  const part = result.partial;
325
345
  const now = !part?.text ? [] : part.kind === "thinking"
326
346
  ? thinkingNow(part.text, room)
@@ -444,13 +464,17 @@ export default function (pink: any, list: typeof externalAgents = externalAgents
444
464
  };
445
465
  const watchChildren = (ui: any, read = readChildren, dbFile = opencodeDb()) => {
446
466
  if (childTimer || !ui?.setWidget) return;
467
+ let shown = false;
447
468
  const tick = () => {
448
469
  // opencode: o banco dele mostra também os de segundo plano; os outros (e o opencode sem node:sqlite): o fluxo
449
470
  const opencode = isOpencode(active?.agent);
450
471
  const fromDb = opencode && active?.resume?.id ? read(dbFile, active.resume.id) : [];
451
472
  const items = fromDb.length ? fromDb : liveAgents(active?.live, Date.now());
452
473
  (globalThis as any).__pinkAgentChildren = items; // a lateral mostra em SUBAGENTES, abaixo da SESSÃO
453
- if (!items.length && !active?.controller) return stopChildren(ui);
474
+ // segue olhando enquanto o /agente estiver ligado: o agente lança subagente sozinho, depois da resposta
475
+ if (!active) return stopChildren(ui);
476
+ if (!items.length && !shown) return;
477
+ shown = items.length > 0;
454
478
  const side = (globalThis as any).__pinkRightOn === true; // lateral ligada (pink-ui): os subagentes ficam só nela, como os do Pink
455
479
  ui.setWidget(CHILDREN, items.length && !side ? (_screen: any, theme: any) => ({
456
480
  render: (width: number) => items.map((item: any) => {
@@ -541,11 +565,17 @@ export default function (pink: any, list: typeof externalAgents = externalAgents
541
565
  box.addChild(clickable(new tui.Text(theme.fg("thinkingText", head), pad, 0), () => (opened.thoughts.has(index) ? opened.thoughts.delete(index) : opened.thoughts.add(index))));
542
566
  if (open && step.text) box.addChild(new tui.Text(theme.italic ? theme.italic(theme.fg("thinkingText", step.text)) : theme.fg("thinkingText", step.text), pad + 2, 0));
543
567
  };
568
+ const drawAgents = (box: any, step: any) => {
569
+ const block = agentLines(step.list);
570
+ box.addChild(new tui.Text(`${theme.fg("success", "●")} ${theme.fg("text", block.head)}`, pad, 0));
571
+ for (const item of block.items) box.addChild(new tui.Text(`${theme.fg("muted", item.branch)} ${bold(theme, theme.fg("text", item.agent))}${item.task ? theme.fg("muted", ` (${item.task})`) : ""}`, pad + 2, 0));
572
+ };
544
573
  const drawSteps = (box: any, steps: any[], offset: number) => {
545
574
  for (const [index, step] of steps.entries()) {
546
575
  // ferramentas seguidas ficam juntas (uma busca na tela são dezenas de chamadas: com linha em branco virava uma tela inteira)
547
576
  if (index && !(step.kind === "tool" && steps[index - 1]?.kind === "tool")) box.addChild(new tui.Spacer(1));
548
577
  if (step.kind === "thinking") thought(box, step, offset + index);
578
+ else if (step.kind === "agents") drawAgents(box, step);
549
579
  else if (step.kind === "tool") box.addChild(new tui.Text(theme.fg("muted", `→ ${step.line}`), pad, 0));
550
580
  else box.addChild(bulleted(new tui.Markdown(String(step.text).trim(), pad, 0, coding.getMarkdownTheme())));
551
581
  }
@@ -558,6 +588,7 @@ export default function (pink: any, list: typeof externalAgents = externalAgents
558
588
  const open = opened.work || all();
559
589
  box.addChild(clickable(new tui.Text(theme.fg("muted", `${open ? "−" : "+"} ${summary}`), pad, 0), () => (opened.work = !opened.work)));
560
590
  if (open) box.addChild(new tui.Spacer(1)), drawSteps(box, work, 0);
591
+ else for (const step of work) if (step.kind === "agents") box.addChild(new tui.Spacer(1)), drawAgents(box, step); // lançamento não fica escondido no resumo
561
592
  if (answer.length) box.addChild(new tui.Spacer(1));
562
593
  drawSteps(box, answer, work.length);
563
594
  } else drawSteps(box, list, 0);
@@ -1307,7 +1307,7 @@ export function toolSummary(name, args = {}, result) {
1307
1307
 
1308
1308
  // chamadas seguidas sem texto do modelo no meio viram uma linha só, como no Claude Code ("Rodou 3 comandos, leu 2 arquivos");
1309
1309
  // edit, write e o plano ficam de fora: cada um tem a própria linha (e o diff)
1310
- const GROUP_SKIP = new Set(["edit", "write", "todowrite"]);
1310
+ const GROUP_SKIP = new Set(["edit", "write", "todowrite", "subagent"]);
1311
1311
  export function toolGroups(entries) {
1312
1312
  const groups = new Map();
1313
1313
  let group;
@@ -1367,6 +1367,16 @@ function groupOf(id) {
1367
1367
  return PINK.groups.map.get(id);
1368
1368
  }
1369
1369
 
1370
+ // lançamento de subagentes nos modelos do Pink, no mesmo formato do /agente: nome e tarefa de cada um (owner 2026-11-28)
1371
+ export function subagentLaunch(args, theme, pad, width) {
1372
+ const list = (Array.isArray(args?.tasks) ? args.tasks : Array.isArray(args?.chain) ? args.chain : [args]).filter((item) => item?.agent);
1373
+ if (!list.length) return [];
1374
+ const flat = (text) => String(text ?? "").replace(/\{previous\}/g, "").replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim();
1375
+ const head = list.length === 1 ? t("1 subagente lançado", "1 subagente lanzado", "1 subagent launched") : `${list.length} ${t("subagentes lançados", "subagentes lanzados", "subagents launched")}`;
1376
+ const margin = " ".repeat(pad);
1377
+ return [`${margin}${theme.fg("success", "●")} ${theme.fg("text", head)}${args.background ? theme.fg("dim", t(" em segundo plano", " en segundo plano", " in the background")) : ""}`, ...list.map((item, index) => `${margin} ${theme.fg("muted", index === list.length - 1 ? "└" : "├")} ${theme.fg("text", flat(item.agent))}${flat(item.task) ? theme.fg("muted", ` (${flat(item.task)})`) : ""}`)].map((row) => fit(row, width));
1378
+ }
1379
+
1370
1380
  export function compactToolRenderer(toolName, next) {
1371
1381
  const base = next?.();
1372
1382
  const empty = { render: () => [], invalidate() {} };
@@ -1396,6 +1406,7 @@ export function compactToolRenderer(toolName, next) {
1396
1406
  renderShell: "self",
1397
1407
  renderCall(args, theme, context) {
1398
1408
  if (context.expanded) return wrap(base?.renderCall?.(args, theme, context) ?? line(theme, 0, `${toolName} ${shorten(JSON.stringify(args ?? {}), 80)}`), context.outputPad);
1409
+ if (toolName === "subagent") return { render: (width) => subagentLaunch(args, theme, context.outputPad, width), invalidate() {} };
1399
1410
  return context.isPartial ? grouped(theme, context.outputPad, context.toolCallId, line(theme, context.outputPad, toolSummary(toolName, args ?? {}), theme.fg("dim", " …"))) : empty;
1400
1411
  },
1401
1412
  renderResult(result, options, theme, context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thothdev/pink",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Open-source AI coding agent for the terminal that also drives Claude Code, Codex, OpenCode and other agents, with parallel sessions, visible plan and changes, and real undo.",
5
5
  "type": "module",
6
6
  "piConfig": {