@adoptai/genui-components 0.1.56 → 0.1.58

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 (52) hide show
  1. package/dist/builders/BuilderForm.d.ts.map +1 -1
  2. package/dist/composites/decision-card/resolver.cjs +634 -0
  3. package/dist/composites/decision-card/resolver.cjs.map +1 -0
  4. package/dist/composites/decision-card/resolver.d.ts +13 -0
  5. package/dist/composites/decision-card/resolver.d.ts.map +1 -0
  6. package/dist/composites/decision-card/resolver.js +627 -0
  7. package/dist/composites/decision-card/resolver.js.map +1 -0
  8. package/dist/composites/document-field-extraction/FieldAuditLog.d.ts +27 -0
  9. package/dist/composites/document-field-extraction/FieldAuditLog.d.ts.map +1 -0
  10. package/dist/composites/document-field-extraction/FieldDetail.d.ts +22 -0
  11. package/dist/composites/document-field-extraction/FieldDetail.d.ts.map +1 -0
  12. package/dist/composites/document-field-extraction/FieldDetails.d.ts +18 -0
  13. package/dist/composites/document-field-extraction/FieldDetails.d.ts.map +1 -0
  14. package/dist/composites/document-field-extraction/bboxTransform.d.ts +25 -0
  15. package/dist/composites/document-field-extraction/bboxTransform.d.ts.map +1 -0
  16. package/dist/composites/document-field-extraction/fieldLabels.d.ts +2 -0
  17. package/dist/composites/document-field-extraction/fieldLabels.d.ts.map +1 -0
  18. package/dist/composites/document-field-extraction/resolver.d.ts +16 -0
  19. package/dist/composites/document-field-extraction/resolver.d.ts.map +1 -0
  20. package/dist/composites/workflow-stepper/resolver.cjs +4 -1
  21. package/dist/composites/workflow-stepper/resolver.cjs.map +1 -1
  22. package/dist/composites/workflow-stepper/resolver.js +4 -1
  23. package/dist/composites/workflow-stepper/resolver.js.map +1 -1
  24. package/dist/index.cjs +2735 -382
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.ts +7 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2530 -183
  29. package/dist/index.js.map +1 -1
  30. package/dist/renderer.cjs +2410 -178
  31. package/dist/renderer.cjs.map +1 -1
  32. package/dist/renderer.js +2267 -35
  33. package/dist/renderer.js.map +1 -1
  34. package/dist/resolver.cjs +2409 -177
  35. package/dist/resolver.cjs.map +1 -1
  36. package/dist/resolver.d.ts.map +1 -1
  37. package/dist/resolver.js +2267 -35
  38. package/dist/resolver.js.map +1 -1
  39. package/dist/schemas/decision-card.d.ts +149 -0
  40. package/dist/schemas/decision-card.d.ts.map +1 -0
  41. package/dist/schemas/document-field-extraction.d.ts +258 -0
  42. package/dist/schemas/document-field-extraction.d.ts.map +1 -0
  43. package/dist/schemas/index.cjs +283 -1
  44. package/dist/schemas/index.cjs.map +1 -1
  45. package/dist/schemas/index.d.ts +407 -0
  46. package/dist/schemas/index.d.ts.map +1 -1
  47. package/dist/schemas/index.js +283 -1
  48. package/dist/schemas/index.js.map +1 -1
  49. package/dist/shared/InteractionContext.d.ts +10 -0
  50. package/dist/shared/InteractionContext.d.ts.map +1 -1
  51. package/dist/tool-definitions.json +359 -3
  52. package/package.json +1 -1
@@ -3453,6 +3453,286 @@ var workflowStepperTool = {
3453
3453
  required: ["type", "title", "steps"]
3454
3454
  }
3455
3455
  };
3456
+ var bbox = z.tuple([z.number(), z.number(), z.number(), z.number()]);
3457
+ var fieldSchema = z.object({
3458
+ field_key: z.string(),
3459
+ label: z.string(),
3460
+ value: z.string(),
3461
+ page: z.number(),
3462
+ // 0-indexed, matches PageDimension.page
3463
+ bbox: bbox.nullable().optional(),
3464
+ confidence: z.number().optional(),
3465
+ confidence_tier: z.enum(["green", "amber", "red"]).optional(),
3466
+ badge: z.enum(["SC", "CN", "AB", "SW"]).optional(),
3467
+ state: z.enum(["ok", "corrected", "missing", "warn"]).optional(),
3468
+ entity_type: z.string().optional(),
3469
+ is_primary: z.boolean().optional(),
3470
+ // Set after a human correction (extractor output, or an optimistic in-card
3471
+ // edit) so the editable field card can show old → new and who changed it.
3472
+ previous_value: z.string().nullable().optional(),
3473
+ corrected_by: z.string().nullable().optional()
3474
+ });
3475
+ var pageSchema = z.object({
3476
+ page: z.number(),
3477
+ // 0-indexed
3478
+ imageUrl: z.string().optional(),
3479
+ // host-resolved from the durable image_ref
3480
+ width_pt: z.number(),
3481
+ height_pt: z.number()
3482
+ });
3483
+ var summaryStatSchema = z.object({
3484
+ field_key: z.string(),
3485
+ label: z.string(),
3486
+ value: z.string(),
3487
+ caption: z.string().nullable().optional()
3488
+ });
3489
+ var summaryFactSchema = z.object({
3490
+ field_key: z.string(),
3491
+ label: z.string(),
3492
+ value: z.string(),
3493
+ badge: z.string().nullable().optional()
3494
+ });
3495
+ var summarySchema = z.object({
3496
+ display_name: z.string().nullable().optional(),
3497
+ short_name: z.string().nullable().optional(),
3498
+ organization: z.string().nullable().optional(),
3499
+ domain: z.string().nullable().optional(),
3500
+ domain_group: z.string().nullable().optional(),
3501
+ tax_year: z.union([z.string(), z.number()]).nullable().optional(),
3502
+ crumbs: z.array(z.string()).optional(),
3503
+ tags: z.array(z.string()).optional(),
3504
+ stats: z.array(summaryStatSchema).optional(),
3505
+ facts: z.array(summaryFactSchema).optional()
3506
+ });
3507
+ var documentFieldExtractionSchema = z.object({
3508
+ type: z.literal("document-field-extraction"),
3509
+ doc_type: z.string().optional(),
3510
+ // Original uploaded filename (e.g. "2024_gl.pdf"); preferred over doc_type for
3511
+ // the card title since doc_type is often the "generic_fallback" schema name.
3512
+ file_name: z.string().optional(),
3513
+ // Server-side token; resolved by the host into pages/fields before render.
3514
+ payload_ref: z.string().optional(),
3515
+ // Present for persisted workstream docs; absent for pre-existing cards.
3516
+ store_id: z.string().optional(),
3517
+ doc_id: z.string().optional(),
3518
+ pages: z.array(pageSchema).max(100).optional(),
3519
+ fields: z.array(fieldSchema).max(1e3).optional(),
3520
+ // Page-count metadata for the Details tab ("N of M pages extracted").
3521
+ page_count: z.number().optional(),
3522
+ pages_processed: z.number().optional(),
3523
+ // Deterministic document summary for the Details tab.
3524
+ summary: summarySchema.nullable().optional()
3525
+ });
3526
+ var documentFieldExtractionTool = {
3527
+ name: "render_document_field_extraction",
3528
+ description: "Render extracted document fields as an interactive overlay on the page image(s) \u2014 colored bounding boxes per field plus a synced field-card list. Use after the extract_document tool returns; pass the returned payload_ref (the host expands it). For invoices, statements, tax forms, receipts, KYC/loan docs, POs where the user wants to SEE where each value sits on the page.",
3529
+ input_schema: {
3530
+ type: "object",
3531
+ properties: {
3532
+ type: { type: "string", enum: ["document-field-extraction"] },
3533
+ doc_type: { type: "string" },
3534
+ file_name: {
3535
+ type: "string",
3536
+ description: "Original uploaded filename; shown as the card title."
3537
+ },
3538
+ payload_ref: {
3539
+ type: "string",
3540
+ description: "Durable store key returned by extract_document; the GenUI host expands it into pages/fields at render time. Pass this verbatim \u2014 do NOT hand-build pages/fields."
3541
+ },
3542
+ store_id: {
3543
+ type: "string",
3544
+ description: "Docstore store id; present for persisted workstream docs. The host uses this to open the editable viewer."
3545
+ },
3546
+ doc_id: {
3547
+ type: "string",
3548
+ description: "Docstore document id; present for persisted workstream docs. Required for the editable viewer."
3549
+ },
3550
+ pages: {
3551
+ type: "array",
3552
+ items: {
3553
+ type: "object",
3554
+ properties: {
3555
+ page: { type: "number", description: "0-indexed page number" },
3556
+ imageUrl: { type: "string" },
3557
+ width_pt: { type: "number" },
3558
+ height_pt: { type: "number" }
3559
+ },
3560
+ required: ["page", "width_pt", "height_pt"]
3561
+ }
3562
+ },
3563
+ fields: {
3564
+ type: "array",
3565
+ items: {
3566
+ type: "object",
3567
+ properties: {
3568
+ field_key: { type: "string" },
3569
+ label: { type: "string" },
3570
+ value: { type: "string" },
3571
+ page: { type: "number", description: "0-indexed page number" },
3572
+ bbox: {
3573
+ type: "array",
3574
+ items: { type: "number" },
3575
+ description: "[x0,y0,x1,y1] PDF points, origin bottom-left; null if unlocated"
3576
+ },
3577
+ confidence: { type: "number" },
3578
+ confidence_tier: { type: "string", enum: ["green", "amber", "red"] },
3579
+ badge: { type: "string", enum: ["SC", "CN", "AB", "SW"] },
3580
+ state: { type: "string", enum: ["ok", "corrected", "missing", "warn"] },
3581
+ entity_type: { type: "string" },
3582
+ is_primary: { type: "boolean" }
3583
+ },
3584
+ required: ["field_key", "label", "value", "page"]
3585
+ }
3586
+ },
3587
+ page_count: { type: "number" },
3588
+ pages_processed: { type: "number" },
3589
+ summary: {
3590
+ type: "object",
3591
+ description: "Deterministic document summary for the Details tab (display_name, organization, domain, stats, facts, tags). Produced by the extractor \u2014 pass through verbatim.",
3592
+ properties: {
3593
+ display_name: { type: "string" },
3594
+ short_name: { type: "string" },
3595
+ organization: { type: "string" },
3596
+ domain: { type: "string" },
3597
+ domain_group: { type: "string" },
3598
+ tax_year: { type: "string" },
3599
+ crumbs: { type: "array", items: { type: "string" } },
3600
+ tags: { type: "array", items: { type: "string" } },
3601
+ stats: {
3602
+ type: "array",
3603
+ items: {
3604
+ type: "object",
3605
+ properties: {
3606
+ field_key: { type: "string" },
3607
+ label: { type: "string" },
3608
+ value: { type: "string" },
3609
+ caption: { type: "string" }
3610
+ },
3611
+ required: ["field_key", "label", "value"]
3612
+ }
3613
+ },
3614
+ facts: {
3615
+ type: "array",
3616
+ items: {
3617
+ type: "object",
3618
+ properties: {
3619
+ field_key: { type: "string" },
3620
+ label: { type: "string" },
3621
+ value: { type: "string" },
3622
+ badge: { type: "string" }
3623
+ },
3624
+ required: ["field_key", "label", "value"]
3625
+ }
3626
+ }
3627
+ }
3628
+ }
3629
+ },
3630
+ required: ["type"]
3631
+ }
3632
+ };
3633
+ var decisionCardSchema = z.object({
3634
+ type: z.literal("decision-card"),
3635
+ id: z.string().optional(),
3636
+ decision_type: z.string().optional(),
3637
+ title: z.string(),
3638
+ question: z.string(),
3639
+ amount: z.number().optional(),
3640
+ currency: z.string().optional(),
3641
+ amount_label: z.string().optional(),
3642
+ severity: z.enum(["low", "medium", "high"]).optional(),
3643
+ flags: z.array(
3644
+ z.object({
3645
+ field: z.string().optional(),
3646
+ issue: z.string(),
3647
+ severity: z.enum(["low", "medium", "high"]).optional()
3648
+ })
3649
+ ).max(6).optional(),
3650
+ options: z.array(
3651
+ z.object({
3652
+ id: z.string().optional(),
3653
+ label: z.string(),
3654
+ recommended: z.boolean().optional()
3655
+ })
3656
+ ).min(1).max(5),
3657
+ source: z.object({
3658
+ label: z.string().optional(),
3659
+ url: z.string().optional()
3660
+ }).optional(),
3661
+ resolved: z.object({
3662
+ option: z.string()
3663
+ }).optional()
3664
+ });
3665
+ var decisionCardTool = {
3666
+ name: "render_decision_card",
3667
+ description: "Render an inline human-in-the-loop (HITL) decision card \u2014 a single judgment the agent needs from the user, resolved in-thread. Shows a titled question with an optional dollar amount at stake, optional data-quality flags, and 2-5 mutually-exclusive resolution options (the first or `recommended` one renders as the primary action), plus an optional 'view source' link. Use for inline approve/choose decisions the user resolves directly in the conversation. NOT for handing off to an external review portal (use escalation-card) and NOT for collecting multiple typed fields (use render_builder).",
3668
+ input_schema: {
3669
+ type: "object",
3670
+ properties: {
3671
+ type: { type: "string", enum: ["decision-card"] },
3672
+ id: { type: "string", description: "Stable id for update-in-place rendering" },
3673
+ decision_type: {
3674
+ type: "string",
3675
+ description: "Short category shown in the eyebrow, e.g. 'Cross-check', 'Allocation', 'Reserve'"
3676
+ },
3677
+ title: { type: "string", description: "The decision headline, e.g. 'AR reserve adequacy'" },
3678
+ question: { type: "string", description: "The full question / context the user must judge" },
3679
+ amount: { type: "number", description: "Dollar value at stake, e.g. 27100" },
3680
+ currency: { type: "string", description: "ISO currency code; defaults to USD" },
3681
+ amount_label: { type: "string", description: "Caption above the amount, e.g. 'At stake'" },
3682
+ severity: {
3683
+ type: "string",
3684
+ enum: ["low", "medium", "high"],
3685
+ description: "Severity of the decision; tints the accent rail"
3686
+ },
3687
+ flags: {
3688
+ type: "array",
3689
+ maxItems: 6,
3690
+ description: "Optional data-quality flags surfaced on the card",
3691
+ items: {
3692
+ type: "object",
3693
+ properties: {
3694
+ field: { type: "string" },
3695
+ issue: { type: "string" },
3696
+ severity: { type: "string", enum: ["low", "medium", "high"] }
3697
+ },
3698
+ required: ["issue"]
3699
+ }
3700
+ },
3701
+ options: {
3702
+ type: "array",
3703
+ minItems: 1,
3704
+ maxItems: 5,
3705
+ description: "Mutually-exclusive resolution choices; mark one `recommended` to make it primary",
3706
+ items: {
3707
+ type: "object",
3708
+ properties: {
3709
+ id: { type: "string" },
3710
+ label: { type: "string" },
3711
+ recommended: { type: "boolean" }
3712
+ },
3713
+ required: ["label"]
3714
+ }
3715
+ },
3716
+ source: {
3717
+ type: "object",
3718
+ description: "Optional provenance link for the figure",
3719
+ properties: {
3720
+ label: { type: "string" },
3721
+ url: { type: "string" }
3722
+ }
3723
+ },
3724
+ resolved: {
3725
+ type: "object",
3726
+ description: "Pre-resolved state for transcript replay",
3727
+ properties: {
3728
+ option: { type: "string" }
3729
+ },
3730
+ required: ["option"]
3731
+ }
3732
+ },
3733
+ required: ["type", "title", "question", "options"]
3734
+ }
3735
+ };
3456
3736
 
3457
3737
  // src/schemas/buildRenderUITool.ts
3458
3738
  function buildRenderUITool(selectedSchemas) {
@@ -3571,7 +3851,9 @@ var schemaRegistry = {
3571
3851
  "connect-integration": { schema: connectIntegrationSchema, tool: connectIntegrationTool },
3572
3852
  "integrations-list": { schema: integrationsListSchema, tool: integrationsListTool },
3573
3853
  "pipeline-preview": { schema: pipelinePreviewSchema, tool: pipelinePreviewTool },
3574
- "workflow-stepper": { schema: workflowStepperSchema, tool: workflowStepperTool }
3854
+ "workflow-stepper": { schema: workflowStepperSchema, tool: workflowStepperTool },
3855
+ "document-field-extraction": { schema: documentFieldExtractionSchema, tool: documentFieldExtractionTool },
3856
+ "decision-card": { schema: decisionCardSchema, tool: decisionCardTool }
3575
3857
  };
3576
3858
 
3577
3859
  export { buildRenderUITool, schemaRegistry, validatePayload };