@firstlovecenter/ai-chat 0.2.1 → 0.2.3

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.
@@ -128,8 +128,46 @@ async function runAgent(input) {
128
128
  transcript
129
129
  };
130
130
  }
131
+ if (allBlocksEmpty(presentPayload.blocks)) {
132
+ const lastAssistantText = [...transcript].reverse().find((e) => e.kind === "assistant_text");
133
+ const text = lastAssistantText?.text.trim();
134
+ if (text) {
135
+ const topic = input.question.length > 80 ? input.question.slice(0, 77) + "..." : input.question;
136
+ presentPayload = {
137
+ blocks: [
138
+ {
139
+ kind: "paragraph_brief",
140
+ topic,
141
+ key_facts: [text]
142
+ }
143
+ ],
144
+ raw_numbers: presentPayload.raw_numbers ?? {}
145
+ };
146
+ }
147
+ }
131
148
  return { ok: true, structured: presentPayload, toolCallCount, transcript };
132
149
  }
150
+ function allBlocksEmpty(blocks) {
151
+ if (blocks.length === 0) return true;
152
+ return blocks.every((b) => {
153
+ if (b.kind === "paragraph_brief") {
154
+ return b.key_facts.length === 0 || b.key_facts.every((f) => !f.trim());
155
+ }
156
+ if (b.kind === "list") {
157
+ return b.items.length === 0 || b.items.every((i) => !i.trim());
158
+ }
159
+ if (b.kind === "callout") {
160
+ return !b.text.trim();
161
+ }
162
+ if (b.kind === "chart") {
163
+ return b.data.length === 0;
164
+ }
165
+ if (b.kind === "table") {
166
+ return b.rows.length === 0;
167
+ }
168
+ return false;
169
+ });
170
+ }
133
171
  var ClaudeToolProvider = class {
134
172
  id = "claude";
135
173
  client;