palabre 0.7.0 → 0.8.1

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.
@@ -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.summaryAgent ?? options.agentB
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();