ei-tui 0.6.3 → 0.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ei-tui",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "author": "Flare576",
5
5
  "repository": {
6
6
  "type": "git",
@@ -123,6 +123,7 @@ export async function handleTopicUpdate(response: LLMResponse, state: StateManag
123
123
  const roomId = response.request.data.roomId as string | undefined;
124
124
  const candidateCategory = response.request.data.candidateCategory as string | undefined;
125
125
  const candidateName = response.request.data.candidateName as string | undefined;
126
+ const candidateDescription = response.request.data.candidateDescription as string | undefined;
126
127
 
127
128
  const personaIds = personaId.split("|").filter(Boolean);
128
129
  const primaryId = personaIds[0] ?? personaId;
@@ -145,10 +146,15 @@ export async function handleTopicUpdate(response: LLMResponse, state: StateManag
145
146
  const existingTopic = isNewItem ? undefined : human.topics.find(t => t.id === existingItemId);
146
147
 
147
148
  const resolvedName = result.name || existingTopic?.name || candidateName;
148
- const resolvedDescription = typeof result.description === 'string' ? result.description : existingTopic?.description;
149
+ const resolvedDescription = typeof result.description === 'string' ? result.description : existingTopic?.description ?? candidateDescription;
150
+ const resolvedSentiment = result.sentiment !== undefined ? result.sentiment : existingTopic?.sentiment ?? 0;
149
151
 
150
- if (!resolvedName || !resolvedDescription || result.sentiment === undefined) {
151
- throw new Error(`[handleTopicUpdate] Missing required fields: name=${resolvedName}, description=${!!resolvedDescription}, sentiment=${result.sentiment}`);
152
+ if (!resolvedName || !resolvedDescription) {
153
+ if (isNewItem) {
154
+ throw new Error(`[handleTopicUpdate] Cannot create new topic — missing required fields: name=${resolvedName}, description=${!!resolvedDescription}`);
155
+ }
156
+ console.log(`[handleTopicUpdate] Skipping update for "${resolvedName ?? existingItemId}" — no description available and existing record preserved`);
157
+ return;
152
158
  }
153
159
 
154
160
  let embedding: number[] | undefined;
@@ -173,7 +179,7 @@ export async function handleTopicUpdate(response: LLMResponse, state: StateManag
173
179
  id: itemId,
174
180
  name: resolvedName,
175
181
  description: resolvedDescription,
176
- sentiment: result.sentiment,
182
+ sentiment: resolvedSentiment,
177
183
  category: result.category ?? candidateCategory ?? existingTopic?.category,
178
184
  exposure_current: calculateExposureCurrent(exposureImpact, existingTopic?.exposure_current ?? 0),
179
185
  exposure_desired: result.exposure_desired ?? 0.5,
@@ -217,6 +223,7 @@ export async function handlePersonUpdate(response: LLMResponse, state: StateMana
217
223
  const candidateIdentifiers = (response.request.data.candidateIdentifiers ?? []) as PersonIdentifier[];
218
224
 
219
225
  const candidateName = response.request.data.candidateName as string;
226
+ const candidateDescription = response.request.data.candidateDescription as string | undefined;
220
227
  const personaIds = personaId.split("|").filter(Boolean);
221
228
  const primaryId = personaIds[0] ?? personaId;
222
229
 
@@ -237,11 +244,15 @@ export async function handlePersonUpdate(response: LLMResponse, state: StateMana
237
244
 
238
245
  const existingPerson = isNewItem ? undefined : human.people.find(p => p.id === existingItemId);
239
246
 
240
- const resolvedDescription = typeof result.description === 'string' ? result.description : existingPerson?.description;
241
- const resolvedSentiment = result.sentiment !== undefined ? result.sentiment : existingPerson?.sentiment;
247
+ const resolvedDescription = typeof result.description === 'string' ? result.description : existingPerson?.description ?? candidateDescription;
248
+ const resolvedSentiment = result.sentiment !== undefined ? result.sentiment : existingPerson?.sentiment ?? 0;
242
249
 
243
- if (!resolvedDescription || resolvedSentiment === undefined) {
244
- throw new Error(`[handlePersonUpdate] Missing required fields: description=${!!resolvedDescription}, sentiment=${resolvedSentiment}`);
250
+ if (!resolvedDescription) {
251
+ if (isNewItem) {
252
+ throw new Error(`[handlePersonUpdate] Cannot create new person "${candidateName}" — no description available`);
253
+ }
254
+ console.log(`[handlePersonUpdate] Skipping update for "${candidateName}" — no description available and existing record preserved`);
255
+ return;
245
256
  }
246
257
 
247
258
  let embedding: number[] | undefined;
@@ -423,6 +423,7 @@ export function queueTopicUpdate(
423
423
  isNewItem,
424
424
  existingItemId: existingItem?.id,
425
425
  candidateName: isNewItem ? context.candidateName : undefined,
426
+ candidateDescription: isNewItem ? context.candidateDescription : undefined,
426
427
  candidateCategory: context.candidateCategory,
427
428
  analyze_from_timestamp: getAnalyzeFromTimestamp(chunk),
428
429
  },
@@ -586,6 +587,7 @@ export function queuePersonUpdate(
586
587
  isNewItem,
587
588
  existingItemId: existingItem?.id,
588
589
  candidateName: context.candidateName,
590
+ candidateDescription: isNewItem ? context.candidateDescription : undefined,
589
591
  candidateRelationship: context.candidateRelationship,
590
592
  candidateIdentifiers: isNewItem ? candidateIdentifiers : undefined,
591
593
  analyze_from_timestamp: getAnalyzeFromTimestamp(chunk),