@realtimex/folio 0.1.7 → 0.1.9

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.
@@ -299,7 +299,7 @@ export class IngestionService {
299
299
  if (insertErr || !ingestion) throw new Error(`Failed to create ingestion record: ${insertErr?.message}`);
300
300
 
301
301
  logger.info(`Processing ingestion ${ingestion.id}: ${filename}`);
302
- Actuator.logEvent(ingestion.id, userId, "info", "Triage", { action: "Ingestion started", source, filename, fileSize }, supabase);
302
+ Actuator.logEvent(ingestion.id, userId, "info", "Triage", { action: "Ingestion started", source, filename, fileSize, is_high_intent: true }, supabase);
303
303
 
304
304
  // 2. Document Triage
305
305
  let isFastPath = false;
@@ -580,7 +580,7 @@ export class IngestionService {
580
580
  .update({ status: "processing", error_message: null, policy_id: null, policy_name: null, extracted: {}, actions_taken: [], summary: null })
581
581
  .eq("id", ingestionId);
582
582
 
583
- Actuator.logEvent(ingestionId, userId, "info", "Triage", { action: "Re-run Initiated" }, supabase);
583
+ Actuator.logEvent(ingestionId, userId, "info", "Triage", { action: "Re-run Initiated", is_high_intent: true }, supabase);
584
584
 
585
585
  const filename = ingestion.filename;
586
586
  const filePath = ingestion.storage_path;
@@ -635,7 +635,7 @@ export class IngestionService {
635
635
  isFastPath = true;
636
636
  extractionContent = pdfData.text;
637
637
  }
638
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
638
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
639
639
  } catch (err) {
640
640
  // ignore
641
641
  }
@@ -200,6 +200,7 @@ export class ModelCapabilityService {
200
200
  "invalid content type",
201
201
  "invalid image",
202
202
  "unrecognized content type",
203
+ "invalid model", // e.g. text-only models fed image payloads in realtimexai provider
203
204
  ];
204
205
 
205
206
  if (capabilityHints.some((hint) => message.includes(hint))) {
@@ -465,7 +465,7 @@ async function evaluateCondition(condition: MatchCondition, doc: DocumentObject,
465
465
  role: "user",
466
466
  content: buildMessageContent(`Question: ${prompt}`, doc.text, true)
467
467
  }
468
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
468
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
469
469
  ] as any,
470
470
  { provider, model }
471
471
  );
@@ -592,7 +592,7 @@ ${fieldDescriptions}`;
592
592
  : [
593
593
  { role: "system", content: "You are a precise data extraction engine. Return only valid JSON." },
594
594
  { role: "user", content: buildMessageContent(prompt, doc.text) }
595
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
595
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
596
596
  ] as any,
597
597
  { provider, model }
598
598
  );
@@ -733,7 +733,7 @@ Rules:
733
733
  : [
734
734
  { role: "system", content: "You are a precise data extraction engine. Return only valid JSON." },
735
735
  { role: "user", content: buildMessageContent(prompt, doc.text) },
736
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
736
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
737
737
  ] as any,
738
738
  { provider, model }
739
739
  );
@@ -1136,7 +1136,7 @@ export class PolicyEngine {
1136
1136
  : [
1137
1137
  { role: "system", content: systemPrompt },
1138
1138
  { role: "user", content: buildMessageContent(userPrompt, doc.text) },
1139
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1139
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1140
1140
  ] as any,
1141
1141
  { provider, model }
1142
1142
  );
@@ -1155,6 +1155,7 @@ export class PolicyEngine {
1155
1155
  if (!parsed) {
1156
1156
  logger.warn("Baseline extraction returned unparseable JSON", { raw: raw.slice(0, 300) });
1157
1157
  Actuator.logEvent(doc.ingestionId, doc.userId, "error", "Baseline Extraction", { action: "Baseline extraction unparseable", raw_response: raw.slice(0, 300) }, doc.supabase);
1158
+ if (isVlmPayload) throw new Error("Unparseable JSON from VLM extraction");
1158
1159
  return { entities: {}, uncertain_fields: [], tags: [] };
1159
1160
  }
1160
1161
 
@@ -1172,6 +1173,7 @@ export class PolicyEngine {
1172
1173
  } catch (err) {
1173
1174
  logger.error("Baseline extraction failed", { err });
1174
1175
  Actuator.logEvent(doc.ingestionId, doc.userId, "error", "Baseline Extraction", { action: "Baseline extraction failed", error: String(err) }, doc.supabase);
1176
+ if (isVlmPayload) throw err;
1175
1177
  return { entities: {}, uncertain_fields: [], tags: [] };
1176
1178
  }
1177
1179
  }
@@ -214,7 +214,7 @@ export class IngestionService {
214
214
  if (insertErr || !ingestion)
215
215
  throw new Error(`Failed to create ingestion record: ${insertErr?.message}`);
216
216
  logger.info(`Processing ingestion ${ingestion.id}: ${filename}`);
217
- Actuator.logEvent(ingestion.id, userId, "info", "Triage", { action: "Ingestion started", source, filename, fileSize }, supabase);
217
+ Actuator.logEvent(ingestion.id, userId, "info", "Triage", { action: "Ingestion started", source, filename, fileSize, is_high_intent: true }, supabase);
218
218
  // 2. Document Triage
219
219
  let isFastPath = false;
220
220
  let isVlmFastPath = false;
@@ -471,7 +471,7 @@ export class IngestionService {
471
471
  .from("ingestions")
472
472
  .update({ status: "processing", error_message: null, policy_id: null, policy_name: null, extracted: {}, actions_taken: [], summary: null })
473
473
  .eq("id", ingestionId);
474
- Actuator.logEvent(ingestionId, userId, "info", "Triage", { action: "Re-run Initiated" }, supabase);
474
+ Actuator.logEvent(ingestionId, userId, "info", "Triage", { action: "Re-run Initiated", is_high_intent: true }, supabase);
475
475
  const filename = ingestion.filename;
476
476
  const filePath = ingestion.storage_path;
477
477
  if (!filePath)
@@ -132,6 +132,7 @@ export class ModelCapabilityService {
132
132
  "invalid content type",
133
133
  "invalid image",
134
134
  "unrecognized content type",
135
+ "invalid model", // e.g. text-only models fed image payloads in realtimexai provider
135
136
  ];
136
137
  if (capabilityHints.some((hint) => message.includes(hint))) {
137
138
  return { isCapabilityError: true, reason: "capability_mismatch" };
@@ -954,6 +954,8 @@ export class PolicyEngine {
954
954
  if (!parsed) {
955
955
  logger.warn("Baseline extraction returned unparseable JSON", { raw: raw.slice(0, 300) });
956
956
  Actuator.logEvent(doc.ingestionId, doc.userId, "error", "Baseline Extraction", { action: "Baseline extraction unparseable", raw_response: raw.slice(0, 300) }, doc.supabase);
957
+ if (isVlmPayload)
958
+ throw new Error("Unparseable JSON from VLM extraction");
957
959
  return { entities: {}, uncertain_fields: [], tags: [] };
958
960
  }
959
961
  const entities = parsed.entities ?? parsed;
@@ -970,6 +972,8 @@ export class PolicyEngine {
970
972
  catch (err) {
971
973
  logger.error("Baseline extraction failed", { err });
972
974
  Actuator.logEvent(doc.ingestionId, doc.userId, "error", "Baseline Extraction", { action: "Baseline extraction failed", error: String(err) }, doc.supabase);
975
+ if (isVlmPayload)
976
+ throw err;
973
977
  return { entities: {}, uncertain_fields: [], tags: [] };
974
978
  }
975
979
  }