palabre 0.7.0 → 0.8.0
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 +99 -63
- package/dist/agentRegistry.js +3 -2
- package/dist/args.js +19 -1
- package/dist/config.js +37 -3
- package/dist/configWizard.js +12 -2
- package/dist/discovery.js +3 -1
- package/dist/doctor.js +4 -0
- package/dist/index.js +508 -27
- package/dist/messages/agents.js +4 -2
- package/dist/messages/common.js +4 -0
- package/dist/messages/config.js +16 -8
- package/dist/messages/help.js +58 -2
- package/dist/messages/index.js +2 -0
- package/dist/messages/init.js +2 -2
- package/dist/messages/new.js +14 -0
- package/dist/messages/output.js +10 -0
- package/dist/messages/preview.js +4 -2
- package/dist/messages/prompt.js +46 -2
- package/dist/messages/renderers.js +2 -2
- package/dist/messages/tui.js +192 -0
- package/dist/messages/update.js +16 -2
- package/dist/new.js +158 -4
- package/dist/orchestrator.js +156 -5
- package/dist/output.js +31 -8
- package/dist/presets.js +48 -0
- package/dist/prompt.js +61 -10
- package/dist/renderers/console.js +39 -3
- package/dist/renderers/ndjson.js +30 -1
- package/dist/renderers/tui.js +932 -0
- package/dist/update.js +2 -0
- package/package.json +2 -1
package/dist/output.js
CHANGED
|
@@ -7,7 +7,8 @@ import { createTranslator } from "./i18n.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export async function writeDebateMarkdown(outputDir, options, debateMessages, summary, stopReason, messages = createTranslator("fr"), failure) {
|
|
9
9
|
const safeDate = new Date().toISOString().replace(/[:.]/g, "-");
|
|
10
|
-
const
|
|
10
|
+
const extension = options.mode === "ask" ? "ask" : "debate";
|
|
11
|
+
const fileName = `palabre-${slugifyTopic(options.topic)}-${safeDate}.${extension}.md`;
|
|
11
12
|
const filePath = path.resolve(outputDir, fileName);
|
|
12
13
|
await mkdir(path.dirname(filePath), { recursive: true });
|
|
13
14
|
await writeFile(filePath, renderDebateMarkdown(options, debateMessages, summary, stopReason, messages, failure), "utf8");
|
|
@@ -30,7 +31,7 @@ function slugifyTopic(topic) {
|
|
|
30
31
|
*/
|
|
31
32
|
export function renderDebateMarkdown(options, debateMessages, summary, stopReason, messages = createTranslator("fr"), failure) {
|
|
32
33
|
const lines = [
|
|
33
|
-
messages.output.title,
|
|
34
|
+
options.mode === "ask" ? messages.output.askTitle : messages.output.title,
|
|
34
35
|
"",
|
|
35
36
|
...renderSessionHeader(options, debateMessages, stopReason, messages),
|
|
36
37
|
"",
|
|
@@ -38,7 +39,7 @@ export function renderDebateMarkdown(options, debateMessages, summary, stopReaso
|
|
|
38
39
|
"",
|
|
39
40
|
...renderFileList(options.files, messages),
|
|
40
41
|
"",
|
|
41
|
-
messages.output.exchangesTitle,
|
|
42
|
+
options.mode === "ask" ? messages.output.askResponsesTitle : messages.output.exchangesTitle,
|
|
42
43
|
""
|
|
43
44
|
];
|
|
44
45
|
for (const message of debateMessages) {
|
|
@@ -90,12 +91,19 @@ function normalizeMarkdownForWindowsPreview(content) {
|
|
|
90
91
|
function renderSessionHeader(options, debateMessages, stopReason, messages) {
|
|
91
92
|
const rows = [
|
|
92
93
|
[messages.output.fields.subject, options.topic],
|
|
93
|
-
[messages.output.fields.
|
|
94
|
+
[messages.output.fields.mode, options.mode],
|
|
95
|
+
[messages.output.fields.agents, formatAgentsForHeader(options)],
|
|
94
96
|
[messages.output.fields.autoPullOllama, options.pullModels ? messages.output.yes : messages.output.no],
|
|
95
|
-
[messages.output.fields.summary, options.summaryEnabled ? options
|
|
96
|
-
[
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
[messages.output.fields.summary, options.summaryEnabled ? formatSummaryAgent(options) : messages.output.disabled],
|
|
98
|
+
[
|
|
99
|
+
options.mode === "ask" ? messages.output.fields.requestedResponses : messages.output.fields.requestedTurns,
|
|
100
|
+
String(options.mode === "ask" ? options.askAgents?.length ?? debateMessages.length : options.turns)
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
options.mode === "ask" ? messages.output.fields.receivedResponses : messages.output.fields.playedTurns,
|
|
104
|
+
String(debateMessages.length)
|
|
105
|
+
],
|
|
106
|
+
[messages.output.fields.earlyStop, options.mode === "debate" ? stopReason ?? messages.output.no : messages.output.no],
|
|
99
107
|
[messages.output.fields.localDate, options.session.localDate],
|
|
100
108
|
[messages.output.fields.timeZone, options.session.timeZone],
|
|
101
109
|
[messages.output.fields.cwd, options.session.cwd],
|
|
@@ -116,3 +124,18 @@ function renderFileList(files, messages) {
|
|
|
116
124
|
}
|
|
117
125
|
return files.map((file) => `- \`${file.path}\` (${file.sizeBytes} ${messages.output.fileSizeUnit})`);
|
|
118
126
|
}
|
|
127
|
+
function formatSummaryAgent(options) {
|
|
128
|
+
if (options.summaryAgent) {
|
|
129
|
+
return options.summaryAgent;
|
|
130
|
+
}
|
|
131
|
+
if (options.mode === "ask" && options.askAgents && options.askAgents.length > 0) {
|
|
132
|
+
return options.askAgents[options.askAgents.length - 1] ?? options.agentB;
|
|
133
|
+
}
|
|
134
|
+
return options.agentB;
|
|
135
|
+
}
|
|
136
|
+
function formatAgentsForHeader(options) {
|
|
137
|
+
if (options.mode === "ask") {
|
|
138
|
+
return (options.askAgents && options.askAgents.length > 0 ? options.askAgents : [options.agentA, options.agentB]).join(", ");
|
|
139
|
+
}
|
|
140
|
+
return `${options.agentA} <-> ${options.agentB}`;
|
|
141
|
+
}
|
package/dist/presets.js
CHANGED
|
@@ -16,6 +16,14 @@ const presets = {
|
|
|
16
16
|
agentA: "opencode",
|
|
17
17
|
agentB: "codex"
|
|
18
18
|
},
|
|
19
|
+
"codex-vibe": {
|
|
20
|
+
agentA: "codex",
|
|
21
|
+
agentB: "vibe"
|
|
22
|
+
},
|
|
23
|
+
"vibe-codex": {
|
|
24
|
+
agentA: "vibe",
|
|
25
|
+
agentB: "codex"
|
|
26
|
+
},
|
|
19
27
|
"codex-antigravity": {
|
|
20
28
|
agentA: "codex",
|
|
21
29
|
agentB: "antigravity"
|
|
@@ -32,6 +40,14 @@ const presets = {
|
|
|
32
40
|
agentA: "opencode",
|
|
33
41
|
agentB: "claude"
|
|
34
42
|
},
|
|
43
|
+
"claude-vibe": {
|
|
44
|
+
agentA: "claude",
|
|
45
|
+
agentB: "vibe"
|
|
46
|
+
},
|
|
47
|
+
"vibe-claude": {
|
|
48
|
+
agentA: "vibe",
|
|
49
|
+
agentB: "claude"
|
|
50
|
+
},
|
|
35
51
|
"claude-antigravity": {
|
|
36
52
|
agentA: "claude",
|
|
37
53
|
agentB: "antigravity"
|
|
@@ -48,6 +64,14 @@ const presets = {
|
|
|
48
64
|
agentA: "opencode",
|
|
49
65
|
agentB: "gemini"
|
|
50
66
|
},
|
|
67
|
+
"gemini-vibe": {
|
|
68
|
+
agentA: "gemini",
|
|
69
|
+
agentB: "vibe"
|
|
70
|
+
},
|
|
71
|
+
"vibe-gemini": {
|
|
72
|
+
agentA: "vibe",
|
|
73
|
+
agentB: "gemini"
|
|
74
|
+
},
|
|
51
75
|
"gemini-antigravity": {
|
|
52
76
|
agentA: "gemini",
|
|
53
77
|
agentB: "antigravity"
|
|
@@ -64,6 +88,22 @@ const presets = {
|
|
|
64
88
|
agentA: "antigravity",
|
|
65
89
|
agentB: "opencode"
|
|
66
90
|
},
|
|
91
|
+
"opencode-vibe": {
|
|
92
|
+
agentA: "opencode",
|
|
93
|
+
agentB: "vibe"
|
|
94
|
+
},
|
|
95
|
+
"vibe-opencode": {
|
|
96
|
+
agentA: "vibe",
|
|
97
|
+
agentB: "opencode"
|
|
98
|
+
},
|
|
99
|
+
"antigravity-vibe": {
|
|
100
|
+
agentA: "antigravity",
|
|
101
|
+
agentB: "vibe"
|
|
102
|
+
},
|
|
103
|
+
"vibe-antigravity": {
|
|
104
|
+
agentA: "vibe",
|
|
105
|
+
agentB: "antigravity"
|
|
106
|
+
},
|
|
67
107
|
"opencode-ollama": {
|
|
68
108
|
agentA: "opencode",
|
|
69
109
|
agentB: "ollama-local"
|
|
@@ -72,6 +112,14 @@ const presets = {
|
|
|
72
112
|
agentA: "ollama-local",
|
|
73
113
|
agentB: "opencode"
|
|
74
114
|
},
|
|
115
|
+
"vibe-ollama": {
|
|
116
|
+
agentA: "vibe",
|
|
117
|
+
agentB: "ollama-local"
|
|
118
|
+
},
|
|
119
|
+
"ollama-vibe": {
|
|
120
|
+
agentA: "ollama-local",
|
|
121
|
+
agentB: "vibe"
|
|
122
|
+
},
|
|
75
123
|
"codex-ollama": {
|
|
76
124
|
agentA: "codex",
|
|
77
125
|
agentB: "ollama-local"
|
package/dist/prompt.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { createTranslator } from "./i18n.js";
|
|
2
2
|
/**
|
|
3
3
|
* Formate le prompt complet transmis à l'adapter.
|
|
4
|
-
* Dispatche vers le format
|
|
4
|
+
* Dispatche vers le format ask ou synthèse si demandé, sinon construit le prompt de débat standard.
|
|
5
5
|
*/
|
|
6
6
|
export function formatAgentPrompt(input) {
|
|
7
7
|
const messages = createTranslator(input.language ?? "fr").prompt;
|
|
8
8
|
if (input.mode === "summary") {
|
|
9
9
|
return formatSummaryPrompt(input, messages);
|
|
10
10
|
}
|
|
11
|
+
if (input.mode === "ask") {
|
|
12
|
+
return formatAskPrompt(input, messages);
|
|
13
|
+
}
|
|
11
14
|
const transcript = formatTranscript(input.transcript);
|
|
12
15
|
return [
|
|
13
16
|
messages.subject(input.topic),
|
|
@@ -41,13 +44,43 @@ export function formatAgentPrompt(input) {
|
|
|
41
44
|
.filter(Boolean)
|
|
42
45
|
.join("\n");
|
|
43
46
|
}
|
|
47
|
+
/** Formate le prompt d'une réponse indépendante en mode ask. */
|
|
48
|
+
function formatAskPrompt(input, messages) {
|
|
49
|
+
return [
|
|
50
|
+
messages.subject(input.topic),
|
|
51
|
+
"",
|
|
52
|
+
messages.askIntro(input.selfName),
|
|
53
|
+
messages.role(input.selfName, input.selfRole),
|
|
54
|
+
messages.roleInstruction(input.selfRole),
|
|
55
|
+
"",
|
|
56
|
+
messages.sessionTitle,
|
|
57
|
+
messages.sessionSource,
|
|
58
|
+
messages.localDate(input.session.localDate),
|
|
59
|
+
messages.timeZone(input.session.timeZone),
|
|
60
|
+
messages.cwd(input.session.cwd),
|
|
61
|
+
messages.sessionStartedAt(input.session.startedAt),
|
|
62
|
+
"",
|
|
63
|
+
messages.responseLanguageInstruction,
|
|
64
|
+
"",
|
|
65
|
+
messages.objectiveTitle,
|
|
66
|
+
...messages.askObjectives,
|
|
67
|
+
"",
|
|
68
|
+
input.files.length > 0 ? messages.fileContextTitle : "",
|
|
69
|
+
formatFileContext(input.files),
|
|
70
|
+
input.files.length > 0 ? "" : "",
|
|
71
|
+
messages.answerTitle
|
|
72
|
+
]
|
|
73
|
+
.filter(Boolean)
|
|
74
|
+
.join("\n");
|
|
75
|
+
}
|
|
44
76
|
/** Formate le prompt de synthèse finale. Impose un format structuré : Consensus / Désaccords / Actions / Conclusion. */
|
|
45
77
|
function formatSummaryPrompt(input, messages) {
|
|
46
78
|
const transcript = formatTranscript(input.transcript);
|
|
79
|
+
const isAskSummary = input.peerName === "ask-responses";
|
|
47
80
|
return [
|
|
48
81
|
messages.subject(input.topic),
|
|
49
82
|
"",
|
|
50
|
-
messages.summaryIntro(input.selfName),
|
|
83
|
+
isAskSummary ? messages.askSummaryIntro(input.selfName) : messages.summaryIntro(input.selfName),
|
|
51
84
|
messages.role(input.selfName, input.selfRole),
|
|
52
85
|
messages.roleInstruction("summarizer"),
|
|
53
86
|
"",
|
|
@@ -61,29 +94,47 @@ function formatSummaryPrompt(input, messages) {
|
|
|
61
94
|
messages.responseLanguageInstruction,
|
|
62
95
|
"",
|
|
63
96
|
messages.objectiveTitle,
|
|
64
|
-
...messages.summaryObjectives,
|
|
97
|
+
...(isAskSummary ? messages.askSummaryObjectives : messages.summaryObjectives),
|
|
65
98
|
"",
|
|
66
99
|
input.files.length > 0 ? messages.fileContextTitle : "",
|
|
67
100
|
formatFileContext(input.files),
|
|
68
101
|
input.files.length > 0 ? "" : "",
|
|
69
|
-
messages.transcriptTitle,
|
|
102
|
+
isAskSummary ? messages.askResponsesTitle : messages.transcriptTitle,
|
|
70
103
|
transcript || messages.noMessage,
|
|
71
104
|
"",
|
|
72
105
|
messages.expectedFormatTitle,
|
|
106
|
+
...(isAskSummary ? askSummaryHeadings(messages) : debateSummaryHeadings(messages)),
|
|
107
|
+
"",
|
|
108
|
+
isAskSummary ? messages.askFinalProseInstruction : messages.finalProseInstruction,
|
|
109
|
+
"",
|
|
110
|
+
messages.summaryAnswerTitle
|
|
111
|
+
]
|
|
112
|
+
.filter(Boolean)
|
|
113
|
+
.join("\n");
|
|
114
|
+
}
|
|
115
|
+
function debateSummaryHeadings(messages) {
|
|
116
|
+
return [
|
|
73
117
|
messages.consensusHeading,
|
|
74
118
|
"",
|
|
75
119
|
messages.disagreementsHeading,
|
|
76
120
|
"",
|
|
77
121
|
messages.actionsHeading,
|
|
78
122
|
"",
|
|
79
|
-
messages.conclusionHeading
|
|
123
|
+
messages.conclusionHeading
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
function askSummaryHeadings(messages) {
|
|
127
|
+
return [
|
|
128
|
+
messages.askAgentSummariesHeading,
|
|
80
129
|
"",
|
|
81
|
-
messages.
|
|
130
|
+
messages.askComparisonHeading,
|
|
82
131
|
"",
|
|
83
|
-
messages.
|
|
84
|
-
|
|
85
|
-
.
|
|
86
|
-
|
|
132
|
+
messages.askWatchpointsHeading,
|
|
133
|
+
"",
|
|
134
|
+
messages.actionsHeading,
|
|
135
|
+
"",
|
|
136
|
+
messages.conclusionHeading
|
|
137
|
+
];
|
|
87
138
|
}
|
|
88
139
|
/** Formate les fichiers projet en blocs de code annotés pour l'injection dans le prompt. */
|
|
89
140
|
function formatFileContext(files) {
|
|
@@ -33,7 +33,7 @@ class PrettyConsoleRenderer {
|
|
|
33
33
|
this.c("cyan", `┌─ ${title} ${"─".repeat(Math.max(1, 54 - title.length))}`),
|
|
34
34
|
this.c("cyan", `│`) + ` ${this.messages.renderers.subject(options.topic)}`,
|
|
35
35
|
this.c("cyan", `│`) + ` ${this.messages.renderers.agents(formatAgentPair(options, agents))}`,
|
|
36
|
-
this.c("cyan", `│`) + ` ${this.messages.renderers.responsesSummary(options
|
|
36
|
+
this.c("cyan", `│`) + ` ${this.messages.renderers.responsesSummary(formatResponseCount(options), formatSummary(options, this.messages))}`,
|
|
37
37
|
this.c("cyan", `│`) + ` ${this.messages.renderers.context(formatContext(options, this.messages))}`,
|
|
38
38
|
this.c("cyan", `│`) + ` ${this.messages.renderers.options(options.earlyStopOnAgreement, options.pullModels)}`,
|
|
39
39
|
this.c("cyan", `└${"─".repeat(57)}`),
|
|
@@ -58,6 +58,15 @@ class PrettyConsoleRenderer {
|
|
|
58
58
|
""
|
|
59
59
|
].join("\n"));
|
|
60
60
|
}
|
|
61
|
+
askResponseStart(response, totalResponses, agent, role) {
|
|
62
|
+
this.renderingSummary = false;
|
|
63
|
+
process.stdout.write([
|
|
64
|
+
"",
|
|
65
|
+
this.c("orange", `◆ ${agent}`) + this.dim(` · ${role} · réponse ${response}/${totalResponses}`),
|
|
66
|
+
this.dim("─".repeat(60)),
|
|
67
|
+
""
|
|
68
|
+
].join("\n"));
|
|
69
|
+
}
|
|
61
70
|
/** Démarre le spinner de réflexion (ou affiche une ligne fixe si non interactif). */
|
|
62
71
|
thinkingStart(agent, role) {
|
|
63
72
|
this.thinkingEnd();
|
|
@@ -89,6 +98,9 @@ class PrettyConsoleRenderer {
|
|
|
89
98
|
const trimmed = content.trim();
|
|
90
99
|
process.stdout.write(`${this.renderingSummary ? this.formatSummaryMessage(trimmed) : trimmed}\n`);
|
|
91
100
|
}
|
|
101
|
+
askResponseMessage(content) {
|
|
102
|
+
this.message(content);
|
|
103
|
+
}
|
|
92
104
|
/** Affiche l'en-tête de section synthèse et active le mode formatage de résumé. */
|
|
93
105
|
summaryStart(agent, role) {
|
|
94
106
|
this.renderingSummary = true;
|
|
@@ -153,7 +165,7 @@ class PlainConsoleRenderer {
|
|
|
153
165
|
start(options, agents = []) {
|
|
154
166
|
process.stdout.write(this.messages.renderers.subject(options.topic) + "\n");
|
|
155
167
|
process.stdout.write(this.messages.renderers.agents(formatAgentPair(options, agents)) + "\n");
|
|
156
|
-
process.stdout.write(this.messages.renderers.responsesSummaryContext(options
|
|
168
|
+
process.stdout.write(this.messages.renderers.responsesSummaryContext(formatResponseCount(options), formatSummary(options, this.messages), formatContext(options, this.messages)) + "\n");
|
|
157
169
|
}
|
|
158
170
|
/** Écrit un avertissement sur `stderr`. */
|
|
159
171
|
warning(message) {
|
|
@@ -167,6 +179,9 @@ class PlainConsoleRenderer {
|
|
|
167
179
|
turnStart(turn, totalTurns, agent, role) {
|
|
168
180
|
process.stdout.write(`\n[${turn}/${totalTurns}] ${agent} (${role})...\n`);
|
|
169
181
|
}
|
|
182
|
+
askResponseStart(response, totalResponses, agent, role) {
|
|
183
|
+
process.stdout.write(`\n[${response}/${totalResponses}] ${agent} (${role})...\n`);
|
|
184
|
+
}
|
|
170
185
|
/** No-op : pas de spinner en mode plain. */
|
|
171
186
|
thinkingStart(_agent, _role) { }
|
|
172
187
|
/** No-op : pas de spinner à arrêter en mode plain. */
|
|
@@ -175,6 +190,9 @@ class PlainConsoleRenderer {
|
|
|
175
190
|
message(content) {
|
|
176
191
|
process.stdout.write(`${content.trim()}\n`);
|
|
177
192
|
}
|
|
193
|
+
askResponseMessage(content) {
|
|
194
|
+
this.message(content);
|
|
195
|
+
}
|
|
178
196
|
/** Affiche l'en-tête de la section synthèse en texte brut. */
|
|
179
197
|
summaryStart(agent, role) {
|
|
180
198
|
process.stdout.write(`\n[${this.messages.renderers.summaryTitle}] ${agent} (${role})...\n`);
|
|
@@ -194,6 +212,12 @@ class PlainConsoleRenderer {
|
|
|
194
212
|
* @param agents - Infos de démarrage des agents (type, rôle, nom).
|
|
195
213
|
*/
|
|
196
214
|
function formatAgentPair(options, agents) {
|
|
215
|
+
if (options.mode === "ask") {
|
|
216
|
+
if (agents.length > 0) {
|
|
217
|
+
return agents.map(formatAgentLabel).join(", ");
|
|
218
|
+
}
|
|
219
|
+
return (options.askAgents ?? [options.agentA, options.agentB]).join(", ");
|
|
220
|
+
}
|
|
197
221
|
if (agents.length >= 2) {
|
|
198
222
|
return `${formatAgentLabel(agents[0])} <-> ${formatAgentLabel(agents[1])}`;
|
|
199
223
|
}
|
|
@@ -214,7 +238,19 @@ function formatAgentLabel(agent) {
|
|
|
214
238
|
* @param options - Options du débat.
|
|
215
239
|
*/
|
|
216
240
|
function formatSummary(options, messages) {
|
|
217
|
-
|
|
241
|
+
if (!options.summaryEnabled) {
|
|
242
|
+
return messages.renderers.disabled;
|
|
243
|
+
}
|
|
244
|
+
if (options.summaryAgent) {
|
|
245
|
+
return options.summaryAgent;
|
|
246
|
+
}
|
|
247
|
+
if (options.mode === "ask" && options.askAgents && options.askAgents.length > 0) {
|
|
248
|
+
return options.askAgents[options.askAgents.length - 1] ?? options.agentB;
|
|
249
|
+
}
|
|
250
|
+
return options.agentB;
|
|
251
|
+
}
|
|
252
|
+
function formatResponseCount(options) {
|
|
253
|
+
return options.mode === "ask" ? options.askAgents?.length ?? 2 : options.turns;
|
|
218
254
|
}
|
|
219
255
|
/**
|
|
220
256
|
* Renvoie un résumé du contexte injecté (nombre de fichiers ou mention d'absence).
|
package/dist/renderers/ndjson.js
CHANGED
|
@@ -25,12 +25,13 @@ export class NdjsonRenderer {
|
|
|
25
25
|
start(options, agents = []) {
|
|
26
26
|
this.emit({
|
|
27
27
|
type: "start",
|
|
28
|
+
mode: options.mode,
|
|
28
29
|
topic: options.topic,
|
|
29
30
|
turns: options.turns,
|
|
30
31
|
agents: agents.map((a) => ({ name: a.name, role: a.role, type: a.type })),
|
|
31
32
|
summaryEnabled: options.summaryEnabled,
|
|
32
33
|
summaryAgent: options.summaryEnabled
|
|
33
|
-
? options
|
|
34
|
+
? resolveSummaryAgent(options)
|
|
34
35
|
: null,
|
|
35
36
|
earlyStop: options.earlyStopOnAgreement,
|
|
36
37
|
filesCount: options.files.length,
|
|
@@ -58,6 +59,13 @@ export class NdjsonRenderer {
|
|
|
58
59
|
this.currentRole = role;
|
|
59
60
|
this.emit({ type: "turn-start", turn, totalTurns, agent, role });
|
|
60
61
|
}
|
|
62
|
+
askResponseStart(response, totalResponses, agent, role) {
|
|
63
|
+
this.currentSection = "ask";
|
|
64
|
+
this.currentTurn = response;
|
|
65
|
+
this.currentAgent = agent;
|
|
66
|
+
this.currentRole = role;
|
|
67
|
+
this.emit({ type: "ask-response-start", response, totalResponses, agent, role });
|
|
68
|
+
}
|
|
61
69
|
/**
|
|
62
70
|
* Émet `thinking-start`. Les consommateurs UI peuvent l'utiliser pour un
|
|
63
71
|
* indicateur "agent en cours" ; les consommateurs purement data peuvent
|
|
@@ -84,6 +92,15 @@ export class NdjsonRenderer {
|
|
|
84
92
|
content,
|
|
85
93
|
});
|
|
86
94
|
}
|
|
95
|
+
else if (this.currentSection === "ask") {
|
|
96
|
+
this.emit({
|
|
97
|
+
type: "ask-response",
|
|
98
|
+
response: this.currentTurn,
|
|
99
|
+
agent: this.currentAgent,
|
|
100
|
+
role: this.currentRole,
|
|
101
|
+
content,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
87
104
|
else {
|
|
88
105
|
this.emit({
|
|
89
106
|
type: "message",
|
|
@@ -94,6 +111,9 @@ export class NdjsonRenderer {
|
|
|
94
111
|
});
|
|
95
112
|
}
|
|
96
113
|
}
|
|
114
|
+
askResponseMessage(content) {
|
|
115
|
+
this.message(content);
|
|
116
|
+
}
|
|
97
117
|
/** Émet `summary-start` et bascule la section courante en synthèse. */
|
|
98
118
|
summaryStart(agent, role) {
|
|
99
119
|
this.currentSection = "summary";
|
|
@@ -114,6 +134,15 @@ export class NdjsonRenderer {
|
|
|
114
134
|
process.stdout.write(JSON.stringify({ v: this.schemaVersion, ...event }) + "\n");
|
|
115
135
|
}
|
|
116
136
|
}
|
|
137
|
+
function resolveSummaryAgent(options) {
|
|
138
|
+
if (options.summaryAgent) {
|
|
139
|
+
return options.summaryAgent;
|
|
140
|
+
}
|
|
141
|
+
if (options.mode === "ask" && options.askAgents && options.askAgents.length > 0) {
|
|
142
|
+
return options.askAgents[options.askAgents.length - 1] ?? options.agentB;
|
|
143
|
+
}
|
|
144
|
+
return options.agentB;
|
|
145
|
+
}
|
|
117
146
|
/** Factory pratique pour conserver la symétrie avec `createConsoleRenderer`. */
|
|
118
147
|
export function createNdjsonRenderer() {
|
|
119
148
|
return new NdjsonRenderer();
|