@o-lang/legal-extractor 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/capability.js +42 -3
  2. package/package.json +1 -1
package/capability.js CHANGED
@@ -319,16 +319,55 @@ async function resolve(action, context = {}, options = {}) {
319
319
 
320
320
  console.log(`[legal-extractor] ✅ Extracted: ${parties.length} parties, ${clauses.length} clauses, ${dates.length} dates, ${obligations.length} obligations, ${risks.length} risk flags`);
321
321
 
322
- return {
322
+ return {
323
323
  summary, parties, clauses, dates, obligations, risks,
324
324
  jurisdiction: jurisdictionLabel, doc_type: docTypeLabel, word_count: wordCount,
325
325
  document_ref, extracted_at: new Date().toISOString(),
326
- preprocessed: originalLength > 10000
326
+ preprocessed: originalLength > 10000,
327
+
328
+ // ── Pre-stringified fields for safe LLM interpolation ──────────────
329
+ // RuntimeAPI._safeInterpolate cannot inject arrays/objects into prompts.
330
+ // These flat strings are what the workflow's {extracted.xxx_text} tokens resolve to.
331
+ parties_text: parties.length
332
+ ? '- ' + parties.join('\n- ')
333
+ : 'No parties identified',
334
+
335
+ clauses_text: clauses.length
336
+ ? clauses.map(c => `${c.type}:\n ${c.excerpt}`).join('\n\n')
337
+ : 'No clauses identified',
338
+
339
+ dates_text: dates.length
340
+ ? dates.join(', ')
341
+ : 'No dates found',
342
+
343
+ obligations_text: obligations.length
344
+ ? '- ' + obligations.slice(0, 5).join('\n- ')
345
+ : 'No obligations extracted',
346
+
347
+ risks_text: risks.length
348
+ ? risks.map(r => `[${r.severity.toUpperCase()}] ${r.flag}`).join('\n')
349
+ : 'No risk flags identified',
327
350
  };
328
351
 
329
352
  } catch (err) {
330
353
  console.error('[legal-extractor] 💥 Error:', err.message);
331
- return { summary: `Extraction failed: ${err.message}`, parties: [], clauses: [], dates: [], obligations: [], risks: [], jurisdiction: 'Unknown', doc_type: 'Unknown', word_count: 0, error: err.message };
354
+ return {
355
+ summary: `Extraction failed: ${err.message}`,
356
+ parties: [],
357
+ clauses: [],
358
+ dates: [],
359
+ obligations: [],
360
+ risks: [],
361
+ jurisdiction: 'Unknown',
362
+ doc_type: 'Unknown',
363
+ word_count: 0,
364
+ error: err.message,
365
+ parties_text: 'Extraction failed',
366
+ clauses_text: 'Extraction failed',
367
+ dates_text: 'Extraction failed',
368
+ obligations_text: 'Extraction failed',
369
+ risks_text: 'Extraction failed',
370
+ };
332
371
  }
333
372
  }
334
373
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/legal-extractor",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "O-Lang resolver for structured legal document extraction. Extract-only — never provides legal advice.",
5
5
  "main": "index.js",
6
6
  "keywords": [