@thothdev/pink 1.0.9 → 1.0.11
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 +51 -26
- package/NOTICE.md +4 -0
- package/dist/bundle/chunks/chunk-MM3LKT73.js +3 -3
- package/examples/extensions/subagent/external.ts +82 -2
- package/extensions/pink-agente.ts +208 -26
- package/extensions/pink-microfone-lock.json +221 -0
- package/extensions/pink-microfone.ts +372 -0
- package/extensions/pink-ui.ts +92 -18
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import os from "node:os";
|
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { closeKept, externalAgents, listModels, pinkExtras, runExternal, warmKept } from "../examples/extensions/subagent/external.ts";
|
|
14
|
-
import { bulleted, fit, runLabel, shortModel, streamedTokens, thinkingLabel, toolSummary, userLines, workingLabel } from "./pink-ui.ts";
|
|
14
|
+
import { bulleted, elapsedLabel, fit, runLabel, shortModel, streamedTokens, thinkingLabel, toolSummary, userLines, workingLabel } from "./pink-ui.ts";
|
|
15
15
|
|
|
16
16
|
// o Pink junto (card 1dfwh7kgfjx): MCPs do mcp.json, AGENTS.md e skills do Pink, mais o próprio Pink como MCP
|
|
17
17
|
const readJson = (file: string) => {
|
|
@@ -84,7 +84,77 @@ export function gatherExtras(pink: any, dir = process.env.PINK_CODING_AGENT_DIR
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
const STATUS = "pink-agente";
|
|
87
|
+
// subagentes do opencode (owner 2026-11-25: "ta usando subagente, mas eu não vejo"): pelo ACP só chega a chamada da
|
|
88
|
+
// ferramenta; cada subagente é uma sessão filha no banco do opencode, com a última mensagem dizendo se terminou
|
|
89
|
+
export function opencodeDb(env: NodeJS.ProcessEnv = process.env, home = os.homedir()) {
|
|
90
|
+
return path.join(env.XDG_DATA_HOME || path.join(home, ".local", "share"), "opencode", "opencode.db");
|
|
91
|
+
}
|
|
92
|
+
const tree = (table: string) => `WITH RECURSIVE tree(id, depth) AS (SELECT id, 1 FROM ${table} WHERE parent_id = ? UNION ALL SELECT s.id, depth + 1 FROM ${table} s JOIN tree ON s.parent_id = tree.id WHERE depth < 3)`;
|
|
93
|
+
// opencode 2.x: session_v2 diz o estado (ocupado, ocioso com o resultado, suspenso)
|
|
94
|
+
const CHILDREN_SQL = `${tree("session_v2")}
|
|
95
|
+
SELECT s.title, s.agent, s.time_created AS created, s.time_updated AS updated, s.time_busy AS busy, s.time_idle AS idle, s.idle_outcome AS outcome, s.time_suspended AS suspended
|
|
96
|
+
FROM session_v2 s JOIN tree ON s.id = tree.id WHERE s.time_updated > ? ORDER BY s.time_created`;
|
|
97
|
+
// opencode 1.x (até 14/10): a última mensagem diz se terminou
|
|
98
|
+
const LEGACY_SQL = `${tree("session")}
|
|
99
|
+
SELECT s.title, s.agent, s.time_created AS created, s.time_updated AS updated, (SELECT data FROM message m WHERE m.session_id = s.id ORDER BY m.time_created DESC LIMIT 1) AS last
|
|
100
|
+
FROM session s JOIN tree ON s.id = tree.id WHERE s.time_updated > ? ORDER BY s.time_created`;
|
|
101
|
+
export const CHILD_DONE_SHOWN_MS = 15000;
|
|
102
|
+
function childState(row: any): { state: "running" | "paused" | "done" | "failed" | "stopped"; end?: number } {
|
|
103
|
+
if (row.last === undefined) {
|
|
104
|
+
const busy = Number(row.busy) || 0;
|
|
105
|
+
const idle = Number(row.idle) || 0;
|
|
106
|
+
if (idle && idle >= busy) return { state: row.outcome === "failed" ? "failed" : row.outcome === "interrupted" ? "stopped" : "done", end: idle };
|
|
107
|
+
if (row.suspended && Number(row.suspended) >= busy) return { state: "paused" };
|
|
108
|
+
return { state: "running" };
|
|
109
|
+
}
|
|
110
|
+
let last: any = {};
|
|
111
|
+
try {
|
|
112
|
+
last = row.last ? JSON.parse(row.last) : {};
|
|
113
|
+
} catch {}
|
|
114
|
+
if (last.error) return { state: "failed", end: Number(row.updated) };
|
|
115
|
+
const done = last.role === "assistant" && Boolean(last.time?.completed) && Boolean(last.finish) && last.finish !== "tool-calls";
|
|
116
|
+
return done ? { state: "done", end: Number(row.updated) } : { state: "running" };
|
|
117
|
+
}
|
|
118
|
+
const CHILD_MARK: Record<string, string | undefined> = { running: undefined, paused: "‖", done: "✓", failed: "✗", stopped: "−" };
|
|
119
|
+
export function childAgents(rows: any[], now: number) {
|
|
120
|
+
const out: any[] = [];
|
|
121
|
+
for (const row of rows ?? []) {
|
|
122
|
+
const { state, end } = childState(row);
|
|
123
|
+
if (end && now - end > CHILD_DONE_SHOWN_MS) continue; // terminou há tempo: sai da lista
|
|
124
|
+
if (!end && now - Number(row.updated) > 10 * 60000) continue; // parado há 10 min: o processo morreu
|
|
125
|
+
const title = String(row.title ?? "");
|
|
126
|
+
const named = title.match(/^(.*?)\s*\(@([\w.-]+) subagent\)\s*$/);
|
|
127
|
+
out.push({ agent: named?.[2] ?? (row.agent || "subagente"), task: (named?.[1] ?? title).trim(), started: Number(row.created), mark: CHILD_MARK[state], clock: end ? `${Math.round((end - Number(row.created)) / 1000)}s` : state === "paused" ? t("pausado", "pausado", "paused") : undefined, running: !end });
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
export function readChildren(file: string, rootId: string, now = Date.now(), open = (f: string) => new (process.getBuiltinModule?.("node:sqlite") as any).DatabaseSync(f, { readOnly: true })) {
|
|
132
|
+
if (!rootId || !fs.existsSync(file)) return [];
|
|
133
|
+
let db: any;
|
|
134
|
+
try {
|
|
135
|
+
db = open(file);
|
|
136
|
+
const since = now - 10 * 60000;
|
|
137
|
+
const has = (table: string) => Boolean(db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table));
|
|
138
|
+
const rows = [...(has("session_v2") ? db.prepare(CHILDREN_SQL).all(rootId, since) : []), ...(has("session") ? db.prepare(LEGACY_SQL).all(rootId, since) : [])];
|
|
139
|
+
return childAgents(rows, now);
|
|
140
|
+
} catch {
|
|
141
|
+
return []; // banco trancado, versão sem a tabela ou Node sem node:sqlite: só não mostra
|
|
142
|
+
} finally {
|
|
143
|
+
try {
|
|
144
|
+
db?.close?.();
|
|
145
|
+
} catch {}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// os subagentes que o próprio fluxo do agente contou (Claude, Codex e ACP: pink-external-agents marca início e fim)
|
|
150
|
+
export function liveAgents(result: any, now: number) {
|
|
151
|
+
return Object.values(result?.subagents ?? {})
|
|
152
|
+
.filter((item: any) => !item.end || now - item.end <= CHILD_DONE_SHOWN_MS)
|
|
153
|
+
.map((item: any) => ({ agent: item.agent, task: item.task, started: item.started, mark: item.state === "failed" ? "✗" : item.end ? "✓" : undefined, clock: item.end ? `${Math.round((item.end - item.started) / 1000)}s` : undefined, running: !item.end }));
|
|
154
|
+
}
|
|
155
|
+
|
|
87
156
|
const WIDGET = "pink-agente-trabalhando";
|
|
157
|
+
const CHILDREN = "pink-agente-subagentes";
|
|
88
158
|
const QUEUE = "pink-agente-fila";
|
|
89
159
|
// o id da conversa do agente fica nos detalhes de cada resposta gravada na sessão do Pink: reabrir a sessão e escolher o
|
|
90
160
|
// mesmo agente retoma a conversa dele (claude --resume, codex thread/resume, ACP session/load)
|
|
@@ -93,6 +163,21 @@ export const lastAgentSession = (entries: any[] | undefined, name: string): stri
|
|
|
93
163
|
// fila como no Claude Code (owner 2026-11-24): cada mensagem esperando aparece em cinza acima da caixa, numa linha
|
|
94
164
|
export const queueLines = (queue: string[], width: number) => queue.map((text) => fit(`> ${String(text).replace(/\s+/g, " ").trim()}`, width));
|
|
95
165
|
const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
166
|
+
const THOUGHT_MAX = 8000; // o pensamento guardado na sessão, por passo
|
|
167
|
+
// como o OpenCode: o trabalho antes da resposta vira uma linha "+ 4 comandos, 4 pensamentos" que abre com clique
|
|
168
|
+
export function workSummary(list: any[]) {
|
|
169
|
+
const tools = list.filter((step) => step.kind === "tool").reduce((sum, step) => sum + (Number(String(step.line).match(/ ×(\d+)$/)?.[1]) || 1), 0);
|
|
170
|
+
const thoughts = list.filter((step) => step.kind === "thinking").length;
|
|
171
|
+
const parts = [];
|
|
172
|
+
if (tools) parts.push(`${tools} ${tools === 1 ? t("comando", "comando", "command") : t("comandos", "comandos", "commands")}`);
|
|
173
|
+
if (thoughts) parts.push(`${thoughts} ${thoughts === 1 ? t("pensamento", "pensamiento", "thought") : t("pensamentos", "pensamientos", "thoughts")}`);
|
|
174
|
+
return parts.join(", ");
|
|
175
|
+
}
|
|
176
|
+
// a resposta final fica de fora do grupo; o que vem antes dela (pensamentos, ferramentas e textos do meio) entra
|
|
177
|
+
export function splitWork(list: any[]) {
|
|
178
|
+
const last = list.map((step) => step.kind).lastIndexOf("text");
|
|
179
|
+
return last < 0 ? { work: list, answer: [] } : { work: list.slice(0, last), answer: list.slice(last) };
|
|
180
|
+
}
|
|
96
181
|
|
|
97
182
|
const fresh = () => ({ messages: [] as any[], stderr: "", exitCode: 0, usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 } });
|
|
98
183
|
|
|
@@ -129,7 +214,8 @@ export function steps(result: any, cwd = "") {
|
|
|
129
214
|
for (const message of result.messages) {
|
|
130
215
|
for (const part of message.content ?? []) {
|
|
131
216
|
if (part.type === "text" && part.text?.trim()) out.push({ kind: "text", text: part.text });
|
|
132
|
-
|
|
217
|
+
// 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)
|
|
218
|
+
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) });
|
|
133
219
|
else if (part.type === "toolCall") out.push({ kind: "tool", line: pinkTool(part, cwd) });
|
|
134
220
|
}
|
|
135
221
|
}
|
|
@@ -220,7 +306,7 @@ export async function pick(ctx: any, title: string, options: string[], load: ()
|
|
|
220
306
|
export default function (pink: any, list: typeof externalAgents = externalAgents, run: typeof runExternal = runExternal, models: typeof listModels = listModels, extras: (tela?: { pipe: string; key: string }) => any = (tela) => gatherExtras(pink, undefined, tela), load: () => Promise<any[]> = loadTui, bridge: typeof telaBridge = telaBridge, warm: typeof warmKept = run === runExternal ? warmKept : () => undefined) {
|
|
221
307
|
let screen: ReturnType<typeof telaBridge> | undefined; // pink_tela: aberto no primeiro /agente, fechado ao sair do Pink
|
|
222
308
|
let screenCtx: any; // a janela deste Pink, onde a tela pede confirmação
|
|
223
|
-
let active: { agent: any; resume: any; controller?: AbortController; queue?: string[] } | undefined;
|
|
309
|
+
let active: { agent: any; resume: any; controller?: AbortController; queue?: string[]; live?: any } | undefined;
|
|
224
310
|
let ticker: ReturnType<typeof setInterval> | undefined;
|
|
225
311
|
let lastUi: any;
|
|
226
312
|
|
|
@@ -233,40 +319,89 @@ export default function (pink: any, list: typeof externalAgents = externalAgents
|
|
|
233
319
|
loader?.stop?.();
|
|
234
320
|
loader = undefined;
|
|
235
321
|
lastUi?.setWidget?.(WIDGET, undefined);
|
|
322
|
+
(globalThis as any).__pinkAgentBusy = false; // a caixa volta às dicas de sempre (pink-ui)
|
|
236
323
|
};
|
|
324
|
+
// a fila em cinza fica em cima do "Trabalhando" e uma linha vazia o separa da caixa (owner 2026-11-25, como o Claude Code)
|
|
325
|
+
const around = (lines: string[], width: number, theme: any) => [...queueLines(active?.queue ?? [], width).map((line) => theme.fg("dim", line)), ...lines, ""];
|
|
237
326
|
const busy = (ui: any, output: () => number) => {
|
|
238
327
|
idle();
|
|
239
328
|
lastUi = ui;
|
|
240
329
|
if (!ui?.setWidget) return;
|
|
241
330
|
const started = Date.now();
|
|
242
331
|
const message = () => workingLabel({ ms: Date.now() - started, output: output() });
|
|
332
|
+
(globalThis as any).__pinkAgentBusy = true; // a caixa mostra "esc interromper · ctrl+enter envia agora" (pink-ui)
|
|
243
333
|
// a área dos widgets já deixa uma linha em branco antes: a linha vazia do topo do Loader sai
|
|
244
334
|
if (tui?.Loader) {
|
|
245
335
|
ui.setWidget(WIDGET, (screen: any, theme: any) => {
|
|
336
|
+
screenRef = screen;
|
|
337
|
+
loader?.stop?.(); // a fábrica pode ser chamada de novo: o Loader anterior para de girar
|
|
246
338
|
loader = new tui.Loader(screen, (s: string) => theme.fg("accent", s), (s: string) => theme.fg("muted", s), message());
|
|
247
339
|
const own = loader;
|
|
248
|
-
return { render: (width: number) => own.render(width).slice(1), invalidate: () => own.invalidate?.() };
|
|
340
|
+
return { render: (width: number) => around(own.render(width).slice(1), width, theme), invalidate: () => own.invalidate?.() };
|
|
249
341
|
}, { placement: "aboveEditor" });
|
|
250
342
|
ticker = setInterval(() => loader?.setMessage?.(message()), 1000);
|
|
251
343
|
} else {
|
|
252
344
|
let frame = 0;
|
|
253
|
-
const draw = () => ui.setWidget(WIDGET, [` ${FRAMES[frame
|
|
345
|
+
const draw = () => ui.setWidget(WIDGET, (_screen: any, theme: any) => ({ render: (width: number) => around([` ${FRAMES[frame % FRAMES.length]} ${message()}`], width, theme), invalidate() {} }), { placement: "aboveEditor" });
|
|
254
346
|
draw();
|
|
255
|
-
ticker = setInterval(draw, 120);
|
|
347
|
+
ticker = setInterval(() => (frame++, draw()), 120);
|
|
256
348
|
}
|
|
257
349
|
ticker.unref?.();
|
|
258
350
|
};
|
|
259
351
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
352
|
+
// subagentes do opencode acima da caixa, a cada 2 s, enquanto a mensagem roda ou algum subagente segue vivo (os de
|
|
353
|
+
// segundo plano continuam depois da resposta, como no Claude Code)
|
|
354
|
+
let childTimer: ReturnType<typeof setInterval> | undefined;
|
|
355
|
+
const stopChildren = (ui?: any) => {
|
|
356
|
+
if (childTimer) clearInterval(childTimer);
|
|
357
|
+
childTimer = undefined;
|
|
358
|
+
(globalThis as any).__pinkAgentChildren = undefined;
|
|
359
|
+
(ui ?? lastUi)?.setWidget?.(CHILDREN, undefined);
|
|
360
|
+
};
|
|
361
|
+
const watchChildren = (ui: any, read = readChildren, dbFile = opencodeDb()) => {
|
|
362
|
+
if (childTimer || !ui?.setWidget) return;
|
|
363
|
+
const tick = () => {
|
|
364
|
+
// opencode: o banco dele mostra também os de segundo plano; os outros (e o opencode sem node:sqlite): o fluxo
|
|
365
|
+
const opencode = /opencode/i.test(String(active?.agent?.external ?? active?.agent?.name ?? ""));
|
|
366
|
+
const fromDb = opencode && active?.resume?.id ? read(dbFile, active.resume.id) : [];
|
|
367
|
+
const items = fromDb.length ? fromDb : liveAgents(active?.live, Date.now());
|
|
368
|
+
(globalThis as any).__pinkAgentChildren = items; // a lateral mostra em SUBAGENTES, abaixo da SESSÃO
|
|
369
|
+
if (!items.length && !active?.controller) return stopChildren(ui);
|
|
370
|
+
const side = Date.now() - Number((globalThis as any).__pinkSideAt ?? 0) < 5000; // lateral desenhada há pouco: está na tela
|
|
371
|
+
ui.setWidget(CHILDREN, items.length && !side ? (_screen: any, theme: any) => ({
|
|
372
|
+
render: (width: number) => items.map((item: any) => {
|
|
373
|
+
const clock = item.clock ?? elapsedLabel(Date.now() - item.started);
|
|
374
|
+
const mark = theme.fg(item.mark === "✗" ? "error" : item.mark === "✓" ? "success" : "accent", item.mark ?? "●");
|
|
375
|
+
return fit(` ${mark} ${theme.fg("text", item.agent)} ${theme.fg("muted", item.task)} ${theme.fg("dim", clock)}`, width);
|
|
376
|
+
}),
|
|
377
|
+
invalidate() {},
|
|
378
|
+
}) : undefined, { placement: "aboveEditor" });
|
|
379
|
+
screenRef?.requestRender?.(); // a lateral relê a lista mesmo com a conversa parada
|
|
380
|
+
};
|
|
381
|
+
tick();
|
|
382
|
+
childTimer = setInterval(tick, 2000);
|
|
383
|
+
childTimer.unref?.();
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// a fila é desenhada dentro do widget do "Trabalhando" (around): aqui só pede o redesenho
|
|
387
|
+
let screenRef: any;
|
|
388
|
+
const showQueue = (_ui: any) => screenRef?.requestRender?.();
|
|
389
|
+
// ctrl+enter com o agente trabalhando: o texto entra na fila e o agente é interrompido; a fila sai na hora, numa mensagem
|
|
390
|
+
(globalThis as any).__pinkAgentSendNow = (text: string) => {
|
|
391
|
+
if (!active?.controller) return false;
|
|
392
|
+
const value = String(text ?? "").trim();
|
|
393
|
+
if (value) (active.queue ??= []).push(value);
|
|
394
|
+
active.controller.abort();
|
|
395
|
+
return true;
|
|
263
396
|
};
|
|
264
397
|
const stop = (ctx?: any) => {
|
|
265
|
-
(ctx?.ui ?? lastUi)?.setWidget?.(QUEUE, undefined); // a
|
|
398
|
+
(ctx?.ui ?? lastUi)?.setWidget?.(QUEUE, undefined); // fila de versões antigas do widget (a de agora some junto com o agente)
|
|
399
|
+
if (active) active.queue = []; // a fila é descartada junto
|
|
266
400
|
active?.controller?.abort();
|
|
267
401
|
closeKept(active?.resume); // fecha o processo do agente que ficou aberto entre as mensagens
|
|
268
402
|
active = undefined;
|
|
269
403
|
idle();
|
|
404
|
+
stopChildren(ctx?.ui);
|
|
270
405
|
(globalThis as any).__pinkExternalAgent = undefined; // o rótulo da caixa volta a "Build · modelo" (pink-ui)
|
|
271
406
|
ctx?.ui?.setStatus?.(STATUS, undefined);
|
|
272
407
|
};
|
|
@@ -290,23 +425,68 @@ export default function (pink: any, list: typeof externalAgents = externalAgents
|
|
|
290
425
|
if (!tui || !coding?.getMarkdownTheme) return undefined;
|
|
291
426
|
const details = message.details ?? {};
|
|
292
427
|
const pad = options.outputPad ?? 1;
|
|
293
|
-
const box = new tui.Container();
|
|
294
428
|
const list = compact(Array.isArray(details.steps) ? details.steps : [{ kind: "text", text: textOf(message) }]);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
429
|
+
const { work, answer } = splitWork(list);
|
|
430
|
+
const summary = workSummary(work);
|
|
431
|
+
const grouped = work.length >= 2 && Boolean(summary);
|
|
432
|
+
// aberto pelo clique (esta mensagem) ou por ctrl+t (todas: o Pink avisa em __pinkThinkingShown)
|
|
433
|
+
const opened = { work: false, thoughts: new Set<number>() };
|
|
434
|
+
const all = () => (globalThis as any).__pinkThinkingShown === true;
|
|
435
|
+
const MouseRegion = tui.MouseRegion;
|
|
436
|
+
let current: any;
|
|
437
|
+
let drawnWithAll = all();
|
|
438
|
+
const clickable = (child: any, toggle: () => void) =>
|
|
439
|
+
MouseRegion
|
|
440
|
+
? new MouseRegion(child, (event: any) => {
|
|
441
|
+
if (event?.type !== "click" || event.button !== "left") return undefined;
|
|
442
|
+
toggle();
|
|
443
|
+
current = build();
|
|
444
|
+
return { handled: true };
|
|
445
|
+
})
|
|
446
|
+
: child;
|
|
447
|
+
const thought = (box: any, step: any, index: number) => {
|
|
448
|
+
const open = all() || opened.thoughts.has(index);
|
|
449
|
+
const head = open && step.text ? `− ${thinkingLabel(step.ms).slice(2)}` : thinkingLabel(step.ms);
|
|
450
|
+
box.addChild(clickable(new tui.Text(theme.fg("thinkingText", head), pad, 0), () => (opened.thoughts.has(index) ? opened.thoughts.delete(index) : opened.thoughts.add(index))));
|
|
451
|
+
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));
|
|
452
|
+
};
|
|
453
|
+
const drawSteps = (box: any, steps: any[], offset: number) => {
|
|
454
|
+
for (const [index, step] of steps.entries()) {
|
|
455
|
+
// ferramentas seguidas ficam juntas (uma busca na tela são dezenas de chamadas: com linha em branco virava uma tela inteira)
|
|
456
|
+
if (index && !(step.kind === "tool" && steps[index - 1]?.kind === "tool")) box.addChild(new tui.Spacer(1));
|
|
457
|
+
if (step.kind === "thinking") thought(box, step, offset + index);
|
|
458
|
+
else if (step.kind === "tool") box.addChild(new tui.Text(theme.fg("muted", `→ ${step.line}`), pad, 0));
|
|
459
|
+
else box.addChild(bulleted(new tui.Markdown(String(step.text).trim(), pad, 0, coding.getMarkdownTheme())));
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
const build = () => {
|
|
463
|
+
drawnWithAll = all();
|
|
464
|
+
const box = new tui.Container();
|
|
465
|
+
// o Pink já põe uma linha em branco antes de cada mensagem: entre o pedido e a resposta fica só ela, como no Claude Code
|
|
466
|
+
if (grouped) {
|
|
467
|
+
const open = opened.work || all();
|
|
468
|
+
box.addChild(clickable(new tui.Text(theme.fg("muted", `${open ? "−" : "+"} ${summary}`), pad, 0), () => (opened.work = !opened.work)));
|
|
469
|
+
if (open) box.addChild(new tui.Spacer(1)), drawSteps(box, work, 0);
|
|
470
|
+
if (answer.length) box.addChild(new tui.Spacer(1));
|
|
471
|
+
drawSteps(box, answer, work.length);
|
|
472
|
+
} else drawSteps(box, list, 0);
|
|
473
|
+
if (details.error) box.addChild(new tui.Spacer(1)), box.addChild(new tui.Text(theme.fg("error", `⚠ ${details.error}`), pad, 0));
|
|
474
|
+
const footer = [bold(theme, theme.fg("accent", details.agent ?? t("agente", "agente", "agent")))];
|
|
475
|
+
if (details.model) footer.push(theme.fg("text", shortModel(details.model)));
|
|
476
|
+
if (details.ms !== undefined) footer.push(theme.fg("muted", runLabel({ ms: details.ms, output: details.output ?? 0 })));
|
|
477
|
+
box.addChild(new tui.Spacer(1));
|
|
478
|
+
box.addChild(new tui.Text(footer.join(theme.fg("dim", " · ")), pad, 0));
|
|
479
|
+
return box;
|
|
480
|
+
};
|
|
481
|
+
current = build();
|
|
482
|
+
return {
|
|
483
|
+
render: (width: number) => {
|
|
484
|
+
if (all() !== drawnWithAll) current = build(); // ctrl+t abriu ou fechou o pensamento de todas
|
|
485
|
+
return current.render(width);
|
|
486
|
+
},
|
|
487
|
+
invalidate: () => current.invalidate?.(),
|
|
488
|
+
handleMouse: (event: any) => current.handleMouse?.(event),
|
|
489
|
+
};
|
|
310
490
|
});
|
|
311
491
|
|
|
312
492
|
const send = async (text: string, ctx: any) => {
|
|
@@ -317,6 +497,7 @@ export default function (pink: any, list: typeof externalAgents = externalAgents
|
|
|
317
497
|
const name = current.agent.name;
|
|
318
498
|
pink.sendMessage({ customType: "pink-agente-pedido", display: true, content: `› ${name}: ${text}`, details: { agent: name, text } });
|
|
319
499
|
const result = fresh();
|
|
500
|
+
current.live = result; // os subagentes desta mensagem (liveAgents)
|
|
320
501
|
const started = Date.now();
|
|
321
502
|
const lastTool = () => result.messages.at(-1)?.content?.find((part: any) => part.type === "toolCall")?.name;
|
|
322
503
|
const status = () => {
|
|
@@ -325,6 +506,7 @@ export default function (pink: any, list: typeof externalAgents = externalAgents
|
|
|
325
506
|
};
|
|
326
507
|
status();
|
|
327
508
|
if (ctx.hasUI) busy(ctx.ui, () => outputOf(result));
|
|
509
|
+
if (ctx.hasUI) watchChildren(ctx.ui);
|
|
328
510
|
(globalThis as any).__pinkExternalAsk = ctx.hasUI ? (title: string, body: string) => ctx.ui.confirm(title, body) : undefined;
|
|
329
511
|
try {
|
|
330
512
|
await run(current.agent, text, ctx.cwd, controller.signal, result, status, undefined, undefined, current.resume);
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
{
|
|
2
|
+
"why": "motor do /microfone: o npm ci instala só estas versões, conferidas pelo sha512 de cada pacote",
|
|
3
|
+
"package": {
|
|
4
|
+
"name": "pink-microfone",
|
|
5
|
+
"private": true,
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"sherpa-onnx-node": "2.0.1",
|
|
8
|
+
"decibri": "5.8.0"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"lock": {
|
|
12
|
+
"name": "pink-microfone",
|
|
13
|
+
"lockfileVersion": 3,
|
|
14
|
+
"requires": true,
|
|
15
|
+
"packages": {
|
|
16
|
+
"": {
|
|
17
|
+
"name": "pink-microfone",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"decibri": "5.8.0",
|
|
20
|
+
"sherpa-onnx-node": "2.0.1"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"node_modules/@decibri/decibri-darwin-arm64": {
|
|
24
|
+
"version": "5.8.0",
|
|
25
|
+
"resolved": "https://registry.npmjs.org/@decibri/decibri-darwin-arm64/-/decibri-darwin-arm64-5.8.0.tgz",
|
|
26
|
+
"integrity": "sha512-dv86BvRoP+IlS/ucJ73vGP/mzGgRcLvyoS0MxoCAkSnrlWKFhKzW6fbm7rqberIkODsiJPHjUfXuSIAd06KC+g==",
|
|
27
|
+
"cpu": [
|
|
28
|
+
"arm64"
|
|
29
|
+
],
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"optional": true,
|
|
32
|
+
"os": [
|
|
33
|
+
"darwin"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"node_modules/@decibri/decibri-linux-arm64-gnu": {
|
|
37
|
+
"version": "5.8.0",
|
|
38
|
+
"resolved": "https://registry.npmjs.org/@decibri/decibri-linux-arm64-gnu/-/decibri-linux-arm64-gnu-5.8.0.tgz",
|
|
39
|
+
"integrity": "sha512-wlzVMVh5aWzVyZgaSNJ0ZfpUfyGsb+plNGdlEcg5bLZ5KFhnT5D/y9YBA+Q+NKLdyzO/mgrsuZpf9VS6ZDJHbw==",
|
|
40
|
+
"cpu": [
|
|
41
|
+
"arm64"
|
|
42
|
+
],
|
|
43
|
+
"license": "Apache-2.0",
|
|
44
|
+
"optional": true,
|
|
45
|
+
"os": [
|
|
46
|
+
"linux"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"node_modules/@decibri/decibri-linux-x64-gnu": {
|
|
50
|
+
"version": "5.8.0",
|
|
51
|
+
"resolved": "https://registry.npmjs.org/@decibri/decibri-linux-x64-gnu/-/decibri-linux-x64-gnu-5.8.0.tgz",
|
|
52
|
+
"integrity": "sha512-+43s3AzpktZiDy2ws47v59TzUivhFo8TQYUKU/EcDdRRebYCnlEHGSeoSDkjI30lW4m85nURETfxEWsGbKtcGg==",
|
|
53
|
+
"cpu": [
|
|
54
|
+
"x64"
|
|
55
|
+
],
|
|
56
|
+
"license": "Apache-2.0",
|
|
57
|
+
"optional": true,
|
|
58
|
+
"os": [
|
|
59
|
+
"linux"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"node_modules/@decibri/decibri-win32-arm64-msvc": {
|
|
63
|
+
"version": "5.8.0",
|
|
64
|
+
"resolved": "https://registry.npmjs.org/@decibri/decibri-win32-arm64-msvc/-/decibri-win32-arm64-msvc-5.8.0.tgz",
|
|
65
|
+
"integrity": "sha512-FS1yvuj0UpG9WDTG3JIcDR1UyGDBNKw+Ht7LVhqJDs4uoJmSnrMTTuHzqyY5QuznVE6jyFkTCIl+/XKku48GoA==",
|
|
66
|
+
"cpu": [
|
|
67
|
+
"arm64"
|
|
68
|
+
],
|
|
69
|
+
"license": "Apache-2.0",
|
|
70
|
+
"optional": true,
|
|
71
|
+
"os": [
|
|
72
|
+
"win32"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"node_modules/@decibri/decibri-win32-x64-msvc": {
|
|
76
|
+
"version": "5.8.0",
|
|
77
|
+
"resolved": "https://registry.npmjs.org/@decibri/decibri-win32-x64-msvc/-/decibri-win32-x64-msvc-5.8.0.tgz",
|
|
78
|
+
"integrity": "sha512-pAmKh6fp3VLaOVD6bChCZFLqThM+pzohb/2BYDN99+3thrb9/cZYgfTocXZ/WjRuHHvR6ErjgQ1wed63unQKYQ==",
|
|
79
|
+
"cpu": [
|
|
80
|
+
"x64"
|
|
81
|
+
],
|
|
82
|
+
"license": "Apache-2.0",
|
|
83
|
+
"optional": true,
|
|
84
|
+
"os": [
|
|
85
|
+
"win32"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"node_modules/decibri": {
|
|
89
|
+
"version": "5.8.0",
|
|
90
|
+
"resolved": "https://registry.npmjs.org/decibri/-/decibri-5.8.0.tgz",
|
|
91
|
+
"integrity": "sha512-mAIFQ0jMmGj4UqF56UDHtX53PvUMpEE4odTUfhvR8ejG2VvohiSPc4hSk83IUNRxj1unrEuSeF0G6RPtaegR6Q==",
|
|
92
|
+
"cpu": [
|
|
93
|
+
"x64",
|
|
94
|
+
"arm64"
|
|
95
|
+
],
|
|
96
|
+
"license": "Apache-2.0",
|
|
97
|
+
"os": [
|
|
98
|
+
"win32",
|
|
99
|
+
"darwin",
|
|
100
|
+
"linux"
|
|
101
|
+
],
|
|
102
|
+
"engines": {
|
|
103
|
+
"node": ">=18.0.0"
|
|
104
|
+
},
|
|
105
|
+
"optionalDependencies": {
|
|
106
|
+
"@decibri/decibri-darwin-arm64": "5.8.0",
|
|
107
|
+
"@decibri/decibri-linux-arm64-gnu": "5.8.0",
|
|
108
|
+
"@decibri/decibri-linux-x64-gnu": "5.8.0",
|
|
109
|
+
"@decibri/decibri-win32-arm64-msvc": "5.8.0",
|
|
110
|
+
"@decibri/decibri-win32-x64-msvc": "5.8.0"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"node_modules/sherpa-onnx-darwin-arm64": {
|
|
114
|
+
"version": "2.0.1",
|
|
115
|
+
"resolved": "https://registry.npmjs.org/sherpa-onnx-darwin-arm64/-/sherpa-onnx-darwin-arm64-2.0.1.tgz",
|
|
116
|
+
"integrity": "sha512-agXmbbwiVPUSMViMhWhYAt59iG21ui7x6HxQFU35XzHOfQe9x6Pg9V160Pzak/66x0ePMjixsLUtMaaUrLfCwQ==",
|
|
117
|
+
"cpu": [
|
|
118
|
+
"arm64"
|
|
119
|
+
],
|
|
120
|
+
"license": "Apache-2.0",
|
|
121
|
+
"optional": true,
|
|
122
|
+
"os": [
|
|
123
|
+
"darwin"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
"node_modules/sherpa-onnx-darwin-x64": {
|
|
127
|
+
"version": "2.0.1",
|
|
128
|
+
"resolved": "https://registry.npmjs.org/sherpa-onnx-darwin-x64/-/sherpa-onnx-darwin-x64-2.0.1.tgz",
|
|
129
|
+
"integrity": "sha512-SBnHa3LDOSI/5/rpBHGxKQDFq+yIdxowYY0InLzfojTUx+yGgqu7cYBrRxjzvHOiOKi0O4rmlFVZboyhIqpDgA==",
|
|
130
|
+
"cpu": [
|
|
131
|
+
"x64"
|
|
132
|
+
],
|
|
133
|
+
"license": "Apache-2.0",
|
|
134
|
+
"optional": true,
|
|
135
|
+
"os": [
|
|
136
|
+
"darwin"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"node_modules/sherpa-onnx-linux-arm64": {
|
|
140
|
+
"version": "2.0.1",
|
|
141
|
+
"resolved": "https://registry.npmjs.org/sherpa-onnx-linux-arm64/-/sherpa-onnx-linux-arm64-2.0.1.tgz",
|
|
142
|
+
"integrity": "sha512-5CJvLjFYIg23oELCsT7l07fMLT3PdquZ3tqh7KZK3Pzi+c2YiPKRe1DDUxoNdtCaw3ZiS4aQSQPBblB9JStuDA==",
|
|
143
|
+
"cpu": [
|
|
144
|
+
"arm64"
|
|
145
|
+
],
|
|
146
|
+
"license": "Apache-2.0",
|
|
147
|
+
"optional": true,
|
|
148
|
+
"os": [
|
|
149
|
+
"linux"
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"node_modules/sherpa-onnx-linux-x64": {
|
|
153
|
+
"version": "2.0.1",
|
|
154
|
+
"resolved": "https://registry.npmjs.org/sherpa-onnx-linux-x64/-/sherpa-onnx-linux-x64-2.0.1.tgz",
|
|
155
|
+
"integrity": "sha512-w5mRRrIvPvcNWac7rQ8AN/t/cwElPGoRpH+ceCRBV7XfjCIQ9Rcr3Ig/kXcJLNOxgK4bGmef+Y47lIWiesDODw==",
|
|
156
|
+
"cpu": [
|
|
157
|
+
"x64"
|
|
158
|
+
],
|
|
159
|
+
"license": "Apache-2.0",
|
|
160
|
+
"optional": true,
|
|
161
|
+
"os": [
|
|
162
|
+
"linux"
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
"node_modules/sherpa-onnx-node": {
|
|
166
|
+
"version": "2.0.1",
|
|
167
|
+
"resolved": "https://registry.npmjs.org/sherpa-onnx-node/-/sherpa-onnx-node-2.0.1.tgz",
|
|
168
|
+
"integrity": "sha512-1PSACfQgPXAD7ExwCv1QW09EXTjcNlpZKBqDY+jxSdIzlyOSq0M13SILBoUQUfeJqiTTXnqp6Ha9jjMUQ6efXg==",
|
|
169
|
+
"license": "Apache-2.0",
|
|
170
|
+
"optionalDependencies": {
|
|
171
|
+
"sherpa-onnx-darwin-arm64": "2.0.1",
|
|
172
|
+
"sherpa-onnx-darwin-x64": "2.0.1",
|
|
173
|
+
"sherpa-onnx-linux-arm64": "2.0.1",
|
|
174
|
+
"sherpa-onnx-linux-x64": "2.0.1",
|
|
175
|
+
"sherpa-onnx-win-arm64": "2.0.1",
|
|
176
|
+
"sherpa-onnx-win-ia32": "2.0.1",
|
|
177
|
+
"sherpa-onnx-win-x64": "2.0.1"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"node_modules/sherpa-onnx-win-arm64": {
|
|
181
|
+
"version": "2.0.1",
|
|
182
|
+
"resolved": "https://registry.npmjs.org/sherpa-onnx-win-arm64/-/sherpa-onnx-win-arm64-2.0.1.tgz",
|
|
183
|
+
"integrity": "sha512-Mb9iqy2Zp7GC5a99dk5E8EQJsEBnapf+IcwHLVCgtIf5mxYHO9Q8YptnAoOHZOD0Zi+R+MblFyG9qv0Q6tin4Q==",
|
|
184
|
+
"cpu": [
|
|
185
|
+
"arm64"
|
|
186
|
+
],
|
|
187
|
+
"license": "Apache-2.0",
|
|
188
|
+
"optional": true,
|
|
189
|
+
"os": [
|
|
190
|
+
"win32"
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
"node_modules/sherpa-onnx-win-ia32": {
|
|
194
|
+
"version": "2.0.1",
|
|
195
|
+
"resolved": "https://registry.npmjs.org/sherpa-onnx-win-ia32/-/sherpa-onnx-win-ia32-2.0.1.tgz",
|
|
196
|
+
"integrity": "sha512-q7qFCA3FK+tYc8pexC9Kzu9WGGoZ9X//UkpxVp6iT4E4W5tPhOEirPyvawS6zgfEW6K/GOISMcYe996Yc7d6iw==",
|
|
197
|
+
"cpu": [
|
|
198
|
+
"ia32"
|
|
199
|
+
],
|
|
200
|
+
"license": "Apache-2.0",
|
|
201
|
+
"optional": true,
|
|
202
|
+
"os": [
|
|
203
|
+
"win32"
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
"node_modules/sherpa-onnx-win-x64": {
|
|
207
|
+
"version": "2.0.1",
|
|
208
|
+
"resolved": "https://registry.npmjs.org/sherpa-onnx-win-x64/-/sherpa-onnx-win-x64-2.0.1.tgz",
|
|
209
|
+
"integrity": "sha512-7vwdAw9PGEb0JLSpK7UFxAdp1vabBHK9Nhw2jFRBWSFgtslUPHIB0T6syJfRgiUGyCeNW9fJvcFAk2F2u7hBEw==",
|
|
210
|
+
"cpu": [
|
|
211
|
+
"x64"
|
|
212
|
+
],
|
|
213
|
+
"license": "Apache-2.0",
|
|
214
|
+
"optional": true,
|
|
215
|
+
"os": [
|
|
216
|
+
"win32"
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|