@theoremjs/agents 0.3.4-next.484.g20d8b9d → 0.3.4-next.522.g9e684cd

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 (95) hide show
  1. package/README.md +61 -51
  2. package/esm/mod.d.ts +2 -2
  3. package/esm/mod.js +1 -1
  4. package/esm/src/guardrails/credential-scan.d.ts +1 -1
  5. package/esm/src/guardrails/credential-scan.js +41 -18
  6. package/esm/src/guardrails/destinations.js +6 -2
  7. package/esm/src/guardrails/detect-at.d.ts +5 -5
  8. package/esm/src/guardrails/detect-at.js +51 -41
  9. package/esm/src/guardrails/detect-reply.d.ts +1 -1
  10. package/esm/src/guardrails/detect-reply.js +4 -2
  11. package/esm/src/guardrails/egress-automata.js +203 -202
  12. package/esm/src/guardrails/egress-compiler.js +1 -4
  13. package/esm/src/guardrails/egress-stream.js +10 -3
  14. package/esm/src/guardrails/egress-urls.js +4 -2
  15. package/esm/src/guardrails/error.d.ts +1 -1
  16. package/esm/src/guardrails/error.js +19 -2
  17. package/esm/src/guardrails/host-patterns.d.ts +1 -4
  18. package/esm/src/guardrails/host-patterns.js +1 -10
  19. package/esm/src/guardrails/injection-patterns.d.ts +3 -1
  20. package/esm/src/guardrails/injection-patterns.js +87 -4
  21. package/esm/src/guardrails/labels.d.ts +2 -2
  22. package/esm/src/guardrails/labels.js +7 -5
  23. package/esm/src/guardrails/mod.d.ts +2 -2
  24. package/esm/src/guardrails/mod.js +1 -1
  25. package/esm/src/guardrails/normalize.js +4 -2
  26. package/esm/src/guardrails/prompt-echo.js +4 -2
  27. package/esm/src/guardrails/sanitize.d.ts +1 -1
  28. package/esm/src/guardrails/sanitize.js +4 -3
  29. package/esm/src/guardrails/sensitive.d.ts +2 -2
  30. package/esm/src/guardrails/sensitive.js +1 -1
  31. package/esm/src/host/client-turn.js +8 -1
  32. package/esm/src/interface/profile-interface.js +13 -0
  33. package/esm/src/kernel/answer-tool.d.ts +14 -0
  34. package/esm/src/kernel/answer-tool.js +26 -0
  35. package/esm/src/kernel/engine/decision-references.d.ts +14 -0
  36. package/esm/src/kernel/engine/decision-references.js +55 -0
  37. package/esm/src/kernel/engine/decision.d.ts +3 -3
  38. package/esm/src/kernel/engine/decision.js +38 -22
  39. package/esm/src/kernel/engine/embedding.js +0 -2
  40. package/esm/src/kernel/engine/runner/gates.js +40 -5
  41. package/esm/src/kernel/engine/runner/mod.js +13 -5
  42. package/esm/src/kernel/engine/runner/state.d.ts +9 -1
  43. package/esm/src/kernel/engine/runner/state.js +10 -1
  44. package/esm/src/kernel/engine/runner/steps.js +50 -13
  45. package/esm/src/kernel/engine/runner/stream.d.ts +14 -8
  46. package/esm/src/kernel/engine/runner/stream.js +25 -13
  47. package/esm/src/kernel/engine/turn-trace.js +2 -2
  48. package/esm/src/kernel/mod.d.ts +1 -1
  49. package/esm/src/kernel/mod.js +1 -1
  50. package/esm/src/kernel/profile-presence.js +12 -0
  51. package/esm/src/kernel/profile-scope.js +14 -14
  52. package/esm/src/kernel/protocols/binding.d.ts +3 -1
  53. package/esm/src/kernel/protocols/binding.js +6 -0
  54. package/esm/src/kernel/protocols/limits.d.ts +10 -11
  55. package/esm/src/kernel/protocols/limits.js +9 -23
  56. package/esm/src/kernel/protocols/runtime.d.ts +3 -2
  57. package/esm/src/kernel/protocols/runtime.js +3 -4
  58. package/esm/src/kernel/provider-budget.d.ts +2 -2
  59. package/esm/src/kernel/provider-budget.js +22 -12
  60. package/esm/src/kernel/provider-runtime.js +8 -5
  61. package/esm/src/kernel/registry/profiles.js +3 -3
  62. package/esm/src/kernel/registry/resolve.js +4 -0
  63. package/esm/src/kernel/registry/schemas.js +1 -1
  64. package/esm/src/kernel/schema.js +28 -2
  65. package/esm/src/kernel/tools/execute.js +3 -1
  66. package/esm/src/kernel/tools/image-fetch.d.ts +2 -4
  67. package/esm/src/kernel/tools/image-fetch.js +19 -20
  68. package/esm/src/kernel/tools/mcp-sessions.d.ts +7 -2
  69. package/esm/src/kernel/tools/mcp-sessions.js +21 -12
  70. package/esm/src/kernel/tools/registry.js +21 -0
  71. package/esm/src/kernel/tools/remote.d.ts +0 -2
  72. package/esm/src/kernel/tools/remote.js +28 -23
  73. package/esm/src/kernel/tools/types.d.ts +30 -4
  74. package/esm/src/kernel/turn-events.d.ts +2 -0
  75. package/esm/src/kernel/turn-events.js +1 -0
  76. package/esm/src/kernel/types.d.ts +4 -2
  77. package/esm/src/observability/spans.js +7 -8
  78. package/esm/src/observability/trace-catalog.js +1 -0
  79. package/esm/src/providers/embedding-limits.js +4 -4
  80. package/esm/src/providers/gemini/{embedding-protocol.d.ts → embeddings-protocol.d.ts} +3 -3
  81. package/esm/src/providers/gemini/{embedding-protocol.js → embeddings-protocol.js} +3 -3
  82. package/esm/src/providers/gemini/live-protocol.js +4 -1
  83. package/esm/src/providers/gemini/provider.js +2 -2
  84. package/esm/src/providers/local/embeddings-protocol.d.ts +7 -0
  85. package/esm/src/providers/local/{embedding-protocol.js → embeddings-protocol.js} +2 -2
  86. package/esm/src/providers/local/provider.js +2 -2
  87. package/esm/src/providers/mod.d.ts +3 -3
  88. package/esm/src/providers/mod.js +3 -3
  89. package/esm/src/providers/openrouter/decisions-protocol.js +11 -8
  90. package/esm/src/providers/openrouter/embeddings-protocol.d.ts +6 -0
  91. package/esm/src/providers/openrouter/{embedding-protocol.js → embeddings-protocol.js} +2 -2
  92. package/esm/src/providers/openrouter/provider.js +2 -2
  93. package/package.json +1 -1
  94. package/esm/src/providers/local/embedding-protocol.d.ts +0 -7
  95. package/esm/src/providers/openrouter/embedding-protocol.d.ts +0 -6
@@ -471,7 +471,7 @@ const FORWARD_AUTOMATON = {
471
471
  18938, 18985, 18998, 19054, 19136, 19239, 19332, 19427, 19537, 19610, 19694, 19810, 19918,
472
472
  20026, 20121, 20186, 20221, 20294, 20383, 20493, 20562, 20656, 20822, 20930, 21075, 21227,
473
473
  21365, 21450, 21533, 21617, 21643, 21672, 21700, 21733, 21750, 21856, 21881, 21921, 21975,
474
- 21994, 22019, 22028, 22035, 22054, 22072, 22075, 22092, 22109, 22127, 22145, 22182, 22197,
474
+ 21995, 22020, 22029, 22036, 22055, 22073, 22076, 22093, 22110, 22128, 22146, 22183, 22198,
475
475
  ],
476
476
  leads: [
477
477
  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -22492,229 +22492,230 @@ const FORWARD_AUTOMATON = {
22492
22492
  [272, 0, 21989, 85],
22493
22493
  [272, 0, 21990, 85],
22494
22494
  [272, 0, 21991, 85],
22495
- [272, 1, 21991, 85, 21992, 86],
22496
- [272, 1, 21993, 86],
22495
+ [272, 1, 21992, 85, 21993, 86],
22496
+ [272, 1, 21992, 85, 21993, 86],
22497
+ [272, 1, 21994, 86],
22497
22498
  [272, 1],
22498
- [273, 0, 21995, 80],
22499
22499
  [273, 0, 21996, 80],
22500
- [273, 0, 21997, 6, 21998, 80],
22501
- [273, 0, 21998, 80],
22500
+ [273, 0, 21997, 80],
22501
+ [273, 0, 21998, 6, 21999, 80],
22502
22502
  [273, 0, 21999, 80],
22503
- [273, 0, 22000, 6, 22001, 80],
22504
- [273, 0, 22001, 80],
22503
+ [273, 0, 22000, 80],
22504
+ [273, 0, 22001, 6, 22002, 80],
22505
22505
  [273, 0, 22002, 80],
22506
- [273, 0, 22003, 6, 22004, 80],
22507
- [273, 0, 22004, 80],
22506
+ [273, 0, 22003, 80],
22507
+ [273, 0, 22004, 6, 22005, 80],
22508
22508
  [273, 0, 22005, 80],
22509
- [273, 0, 22006, 6, 22007, 80],
22510
- [273, 0, 22007, 80],
22509
+ [273, 0, 22006, 80],
22510
+ [273, 0, 22007, 6, 22008, 80],
22511
22511
  [273, 0, 22008, 80],
22512
- [273, 0, 22009, 6, 22010, 80],
22513
- [273, 0, 22010, 80],
22512
+ [273, 0, 22009, 80],
22513
+ [273, 0, 22010, 6, 22011, 80],
22514
22514
  [273, 0, 22011, 80],
22515
- [273, 0, 22012, 6, 22013, 80],
22516
- [273, 0, 22013, 80],
22515
+ [273, 0, 22012, 80],
22516
+ [273, 0, 22013, 6, 22014, 80],
22517
22517
  [273, 0, 22014, 80],
22518
- [273, 0, 22015, 6, 22016, 80],
22519
- [273, 0, 22016, 80],
22518
+ [273, 0, 22015, 80],
22519
+ [273, 0, 22016, 6, 22017, 80],
22520
22520
  [273, 0, 22017, 80],
22521
- [273, 1, 22018, 6, 22016, 80],
22522
- [273, 1, 22016, 80],
22523
- [274, 0, 22020, 144],
22524
- [274, 0, 22021, 171],
22525
- [274, 0, 22022, 144],
22526
- [274, 0, 22023, 171],
22527
- [274, 0, 22024, 144],
22528
- [274, 0, 22025, 171],
22529
- [274, 0, 22024, 144, 22026, 144],
22530
- [274, 1, 22027, 26],
22521
+ [273, 0, 22018, 80],
22522
+ [273, 1, 22019, 6, 22017, 80],
22523
+ [273, 1, 22017, 80],
22524
+ [274, 0, 22021, 144],
22525
+ [274, 0, 22022, 171],
22526
+ [274, 0, 22023, 144],
22527
+ [274, 0, 22024, 171],
22528
+ [274, 0, 22025, 144],
22529
+ [274, 0, 22026, 171],
22530
+ [274, 0, 22025, 144, 22027, 144],
22531
+ [274, 1, 22028, 26],
22531
22532
  [274, 1],
22532
- [275, 0, 22029, 144],
22533
- [275, 0, 22029, 144, 22030, 51],
22534
- [275, 0, 22031, 144],
22535
- [275, 0, 22031, 144, 22032, 51],
22536
- [275, 0, 22031, 144, 22033, 144],
22537
- [275, 1, 22033, 144, 22034, 26],
22533
+ [275, 0, 22030, 144],
22534
+ [275, 0, 22030, 144, 22031, 51],
22535
+ [275, 0, 22032, 144],
22536
+ [275, 0, 22032, 144, 22033, 51],
22537
+ [275, 0, 22032, 144, 22034, 144],
22538
+ [275, 1, 22034, 144, 22035, 26],
22538
22539
  [275, 1],
22539
- [276, 0, 22036, 184],
22540
- [276, 0, 22037, 50],
22541
- [276, 0, 22038, 49, 22039, 138, 22040, 49, 22041, 48],
22542
- [276, 0, 22042, 142, 22039, 185],
22543
- [276, 0, 22038, 49, 22039, 138, 22040, 49, 22041, 48],
22544
- [276, 0, 22043, 142, 22041, 48],
22545
- [276, 0, 22044, 186],
22546
- [276, 0, 22042, 142, 22039, 185],
22547
- [276, 0, 22043, 142, 22041, 48],
22548
- [276, 0, 22045, 142, 22046, 49, 22047, 44, 22048, 93, 22049, 187],
22549
- [276, 0, 22045, 142, 22046, 49, 22047, 44, 22048, 93, 22049, 187],
22550
- [276, 0, 22050, 142, 22047, 44, 22048, 93, 22049, 187],
22551
- [276, 0, 22051, 93, 22052, 188, 22053, 47],
22552
- [276, 0, 22049, 185],
22553
- [276, 1, 22048, 93, 22049, 187],
22554
- [276, 0, 22050, 142, 22047, 44, 22048, 93, 22049, 187],
22555
- [276, 0, 22052, 138],
22556
- [276, 0, 22051, 93, 22052, 188, 22053, 47],
22540
+ [276, 0, 22037, 184],
22541
+ [276, 0, 22038, 50],
22542
+ [276, 0, 22039, 49, 22040, 138, 22041, 49, 22042, 48],
22543
+ [276, 0, 22043, 142, 22040, 185],
22544
+ [276, 0, 22039, 49, 22040, 138, 22041, 49, 22042, 48],
22545
+ [276, 0, 22044, 142, 22042, 48],
22546
+ [276, 0, 22045, 186],
22547
+ [276, 0, 22043, 142, 22040, 185],
22548
+ [276, 0, 22044, 142, 22042, 48],
22549
+ [276, 0, 22046, 142, 22047, 49, 22048, 44, 22049, 93, 22050, 187],
22550
+ [276, 0, 22046, 142, 22047, 49, 22048, 44, 22049, 93, 22050, 187],
22551
+ [276, 0, 22051, 142, 22048, 44, 22049, 93, 22050, 187],
22552
+ [276, 0, 22052, 93, 22053, 188, 22054, 47],
22553
+ [276, 0, 22050, 185],
22554
+ [276, 1, 22049, 93, 22050, 187],
22555
+ [276, 0, 22051, 142, 22048, 44, 22049, 93, 22050, 187],
22556
+ [276, 0, 22053, 138],
22557
+ [276, 0, 22052, 93, 22053, 188, 22054, 47],
22557
22558
  [276, 1],
22558
- [277, 0, 22055, 49, 22056, 171, 22057, 50],
22559
- [277, 0, 22056, 171, 22057, 50],
22560
- [277, 0, 22058, 171, 22057, 50],
22561
- [277, 0, 22059, 93, 22060, 189],
22562
- [277, 0, 22061, 171, 22057, 50],
22563
- [277, 0, 22060, 33],
22564
- [277, 0, 22059, 93, 22060, 189, 22062, 48],
22565
- [277, 0, 22057, 50],
22566
- [277, 0, 22063, 23],
22567
- [277, 0, 22064, 142, 22065, 49, 22066, 44, 22067, 185],
22568
- [277, 0, 22064, 142, 22065, 49, 22066, 44, 22067, 185],
22569
- [277, 0, 22068, 142, 22066, 44, 22067, 185],
22570
- [277, 0, 22069, 93, 22070, 188, 22071, 47],
22571
- [277, 1, 22067, 185],
22572
- [277, 0, 22068, 142, 22066, 44, 22067, 185],
22573
- [277, 0, 22070, 138],
22574
- [277, 0, 22069, 93, 22070, 188, 22071, 47],
22559
+ [277, 0, 22056, 49, 22057, 171, 22058, 50],
22560
+ [277, 0, 22057, 171, 22058, 50],
22561
+ [277, 0, 22059, 171, 22058, 50],
22562
+ [277, 0, 22060, 93, 22061, 189],
22563
+ [277, 0, 22062, 171, 22058, 50],
22564
+ [277, 0, 22061, 33],
22565
+ [277, 0, 22060, 93, 22061, 189, 22063, 48],
22566
+ [277, 0, 22058, 50],
22567
+ [277, 0, 22064, 23],
22568
+ [277, 0, 22065, 142, 22066, 49, 22067, 44, 22068, 185],
22569
+ [277, 0, 22065, 142, 22066, 49, 22067, 44, 22068, 185],
22570
+ [277, 0, 22069, 142, 22067, 44, 22068, 185],
22571
+ [277, 0, 22070, 93, 22071, 188, 22072, 47],
22572
+ [277, 1, 22068, 185],
22573
+ [277, 0, 22069, 142, 22067, 44, 22068, 185],
22574
+ [277, 0, 22071, 138],
22575
+ [277, 0, 22070, 93, 22071, 188, 22072, 47],
22575
22576
  [277, 1],
22576
- [278, 0, 22073, 184],
22577
- [278, 0, 22074, 50],
22577
+ [278, 0, 22074, 184],
22578
+ [278, 0, 22075, 50],
22578
22579
  [278, 1],
22579
- [279, 0, 22076, 44],
22580
- [279, 0, 22077, 144],
22581
- [279, 0, 22078, 190, 22079, 190, 22080, 191, 22081, 47],
22582
- [279, 0, 22078, 190, 22079, 190, 22080, 191, 22081, 47],
22583
- [279, 0, 22082, 192, 22083, 193, 22084, 86, 22079, 190, 22080, 191, 22081, 47],
22584
- [279, 0, 22079, 190, 22080, 191, 22081, 47],
22580
+ [279, 0, 22077, 44],
22581
+ [279, 0, 22078, 144],
22582
+ [279, 0, 22079, 190, 22080, 190, 22081, 191, 22082, 47],
22583
+ [279, 0, 22079, 190, 22080, 190, 22081, 191, 22082, 47],
22584
+ [279, 0, 22083, 192, 22084, 193, 22085, 86, 22080, 190, 22081, 191, 22082, 47],
22585
+ [279, 0, 22080, 190, 22081, 191, 22082, 47],
22585
22586
  [279, 1],
22586
- [279, 0, 22082, 192, 22083, 193, 22084, 86, 22079, 190, 22080, 191, 22081, 47],
22587
- [279, 0, 22083, 193, 22084, 86, 22079, 190, 22080, 191, 22081, 47],
22588
- [279, 0, 22085, 193, 22086, 143, 22087, 28, 22088, 194, 22079, 190, 22080, 191, 22081, 47],
22589
- [279, 0, 22085, 193, 22086, 143, 22087, 28, 22088, 194, 22079, 190, 22080, 191, 22081, 47],
22590
- [279, 0, 22089, 147, 22080, 143],
22591
- [279, 0, 22090, 149, 22080, 28],
22592
- [279, 0, 22091, 195, 22079, 190, 22080, 191, 22081, 47],
22593
- [279, 0, 22089, 147, 22080, 143],
22594
- [279, 0, 22090, 149, 22080, 28],
22595
- [279, 0, 22091, 195, 22079, 190, 22080, 191, 22081, 47],
22596
- [280, 0, 22093, 44],
22597
- [280, 0, 22094, 14],
22598
- [280, 0, 22095, 15],
22599
- [280, 0, 22096, 16],
22600
- [280, 0, 22097, 9],
22601
- [280, 0, 22098, 5],
22602
- [280, 0, 22099, 196],
22603
- [280, 0, 22100, 33, 22101, 44],
22604
- [280, 0, 22100, 33, 22101, 44],
22605
- [280, 0, 22102, 46],
22606
- [280, 0, 22103, 14],
22607
- [280, 0, 22104, 15],
22608
- [280, 0, 22105, 16],
22609
- [280, 0, 22106, 9],
22610
- [280, 0, 22107, 5],
22611
- [280, 0, 22108, 196],
22587
+ [279, 0, 22083, 192, 22084, 193, 22085, 86, 22080, 190, 22081, 191, 22082, 47],
22588
+ [279, 0, 22084, 193, 22085, 86, 22080, 190, 22081, 191, 22082, 47],
22589
+ [279, 0, 22086, 193, 22087, 143, 22088, 28, 22089, 194, 22080, 190, 22081, 191, 22082, 47],
22590
+ [279, 0, 22086, 193, 22087, 143, 22088, 28, 22089, 194, 22080, 190, 22081, 191, 22082, 47],
22591
+ [279, 0, 22090, 147, 22081, 143],
22592
+ [279, 0, 22091, 149, 22081, 28],
22593
+ [279, 0, 22092, 195, 22080, 190, 22081, 191, 22082, 47],
22594
+ [279, 0, 22090, 147, 22081, 143],
22595
+ [279, 0, 22091, 149, 22081, 28],
22596
+ [279, 0, 22092, 195, 22080, 190, 22081, 191, 22082, 47],
22597
+ [280, 0, 22094, 44],
22598
+ [280, 0, 22095, 14],
22599
+ [280, 0, 22096, 15],
22600
+ [280, 0, 22097, 16],
22601
+ [280, 0, 22098, 9],
22602
+ [280, 0, 22099, 5],
22603
+ [280, 0, 22100, 196],
22604
+ [280, 0, 22101, 33, 22102, 44],
22605
+ [280, 0, 22101, 33, 22102, 44],
22606
+ [280, 0, 22103, 46],
22607
+ [280, 0, 22104, 14],
22608
+ [280, 0, 22105, 15],
22609
+ [280, 0, 22106, 16],
22610
+ [280, 0, 22107, 9],
22611
+ [280, 0, 22108, 5],
22612
+ [280, 0, 22109, 196],
22612
22613
  [280, 1],
22613
- [281, 0, 22110, 50],
22614
- [281, 0, 22111, 49, 22112, 138, 22113, 49, 22114, 48],
22615
- [281, 0, 22115, 142, 22112, 185],
22616
- [281, 0, 22111, 49, 22112, 138, 22113, 49, 22114, 48],
22617
- [281, 0, 22116, 142, 22114, 48],
22618
- [281, 0, 22117, 186],
22619
- [281, 0, 22115, 142, 22112, 185],
22620
- [281, 0, 22116, 142, 22114, 48],
22621
- [281, 0, 22118, 142, 22119, 49, 22120, 44, 22121, 93, 22122, 187],
22622
- [281, 0, 22118, 142, 22119, 49, 22120, 44, 22121, 93, 22122, 187],
22623
- [281, 0, 22123, 142, 22120, 44, 22121, 93, 22122, 187],
22624
- [281, 0, 22124, 93, 22125, 188, 22126, 47],
22625
- [281, 0, 22122, 185],
22626
- [281, 1, 22121, 93, 22122, 187],
22627
- [281, 0, 22123, 142, 22120, 44, 22121, 93, 22122, 187],
22628
- [281, 0, 22125, 138],
22629
- [281, 0, 22124, 93, 22125, 188, 22126, 47],
22614
+ [281, 0, 22111, 50],
22615
+ [281, 0, 22112, 49, 22113, 138, 22114, 49, 22115, 48],
22616
+ [281, 0, 22116, 142, 22113, 185],
22617
+ [281, 0, 22112, 49, 22113, 138, 22114, 49, 22115, 48],
22618
+ [281, 0, 22117, 142, 22115, 48],
22619
+ [281, 0, 22118, 186],
22620
+ [281, 0, 22116, 142, 22113, 185],
22621
+ [281, 0, 22117, 142, 22115, 48],
22622
+ [281, 0, 22119, 142, 22120, 49, 22121, 44, 22122, 93, 22123, 187],
22623
+ [281, 0, 22119, 142, 22120, 49, 22121, 44, 22122, 93, 22123, 187],
22624
+ [281, 0, 22124, 142, 22121, 44, 22122, 93, 22123, 187],
22625
+ [281, 0, 22125, 93, 22126, 188, 22127, 47],
22626
+ [281, 0, 22123, 185],
22627
+ [281, 1, 22122, 93, 22123, 187],
22628
+ [281, 0, 22124, 142, 22121, 44, 22122, 93, 22123, 187],
22629
+ [281, 0, 22126, 138],
22630
+ [281, 0, 22125, 93, 22126, 188, 22127, 47],
22630
22631
  [281, 1],
22631
- [282, 0, 22128, 49, 22129, 171, 22130, 50],
22632
- [282, 0, 22129, 171, 22130, 50],
22633
- [282, 0, 22131, 171, 22130, 50],
22634
- [282, 0, 22132, 93, 22133, 189],
22635
- [282, 0, 22134, 171, 22130, 50],
22636
- [282, 0, 22133, 33],
22637
- [282, 0, 22132, 93, 22133, 189, 22135, 48],
22638
- [282, 0, 22130, 50],
22639
- [282, 0, 22136, 23],
22640
- [282, 0, 22137, 142, 22138, 49, 22139, 44, 22140, 185],
22641
- [282, 0, 22137, 142, 22138, 49, 22139, 44, 22140, 185],
22642
- [282, 0, 22141, 142, 22139, 44, 22140, 185],
22643
- [282, 0, 22142, 93, 22143, 188, 22144, 47],
22644
- [282, 1, 22140, 185],
22645
- [282, 0, 22141, 142, 22139, 44, 22140, 185],
22646
- [282, 0, 22143, 138],
22647
- [282, 0, 22142, 93, 22143, 188, 22144, 47],
22632
+ [282, 0, 22129, 49, 22130, 171, 22131, 50],
22633
+ [282, 0, 22130, 171, 22131, 50],
22634
+ [282, 0, 22132, 171, 22131, 50],
22635
+ [282, 0, 22133, 93, 22134, 189],
22636
+ [282, 0, 22135, 171, 22131, 50],
22637
+ [282, 0, 22134, 33],
22638
+ [282, 0, 22133, 93, 22134, 189, 22136, 48],
22639
+ [282, 0, 22131, 50],
22640
+ [282, 0, 22137, 23],
22641
+ [282, 0, 22138, 142, 22139, 49, 22140, 44, 22141, 185],
22642
+ [282, 0, 22138, 142, 22139, 49, 22140, 44, 22141, 185],
22643
+ [282, 0, 22142, 142, 22140, 44, 22141, 185],
22644
+ [282, 0, 22143, 93, 22144, 188, 22145, 47],
22645
+ [282, 1, 22141, 185],
22646
+ [282, 0, 22142, 142, 22140, 44, 22141, 185],
22647
+ [282, 0, 22144, 138],
22648
+ [282, 0, 22143, 93, 22144, 188, 22145, 47],
22648
22649
  [282, 1],
22649
- [283, 0, 22146, 44],
22650
- [283, 0, 22147, 144],
22651
- [283, 0, 22148, 197],
22652
- [283, 0, 22149, 197, 22150, 23],
22653
- [283, 0, 22151, 197, 22150, 23],
22654
- [283, 0, 22152, 198, 22153, 47],
22655
- [283, 0, 22154, 197, 22150, 23],
22656
- [283, 0, 22152, 198, 22153, 47],
22650
+ [283, 0, 22147, 44],
22651
+ [283, 0, 22148, 144],
22652
+ [283, 0, 22149, 197],
22653
+ [283, 0, 22150, 197, 22151, 23],
22654
+ [283, 0, 22152, 197, 22151, 23],
22655
+ [283, 0, 22153, 198, 22154, 47],
22656
+ [283, 0, 22155, 197, 22151, 23],
22657
+ [283, 0, 22153, 198, 22154, 47],
22657
22658
  [283, 1],
22658
- [283, 0, 22155, 197, 22150, 23],
22659
- [283, 0, 22156, 197, 22150, 23],
22660
- [283, 0, 22157, 197, 22150, 23],
22661
- [283, 0, 22158, 197, 22150, 23],
22662
- [283, 0, 22159, 197, 22150, 23],
22663
- [283, 0, 22160, 197, 22150, 23],
22664
- [283, 0, 22161, 197, 22150, 23],
22665
- [283, 0, 22162, 197, 22150, 23],
22666
- [283, 0, 22163, 197, 22150, 23],
22667
- [283, 0, 22164, 197, 22150, 23],
22668
- [283, 0, 22165, 197, 22150, 23],
22669
- [283, 0, 22166, 197, 22150, 23],
22670
- [283, 0, 22167, 197, 22150, 23],
22671
- [283, 0, 22168, 197, 22150, 23],
22672
- [283, 0, 22169, 197, 22150, 23],
22673
- [283, 0, 22170, 197, 22150, 23],
22674
- [283, 0, 22171, 197, 22150, 23],
22675
- [283, 0, 22172, 197, 22150, 23],
22676
- [283, 0, 22173, 197, 22150, 23],
22677
- [283, 0, 22174, 197, 22150, 23],
22678
- [283, 0, 22175, 197, 22150, 23],
22679
- [283, 0, 22176, 197, 22150, 23],
22680
- [283, 0, 22177, 197, 22150, 23],
22681
- [283, 0, 22178, 197, 22150, 23],
22682
- [283, 0, 22179, 197, 22150, 23],
22683
- [283, 0, 22180, 197, 22150, 23],
22684
- [283, 0, 22181, 197, 22150, 23],
22685
- [283, 0, 22150, 23],
22686
- [284, 0, 22183, 21, 22184, 18, 22185, 22],
22687
- [284, 0, 22186, 15],
22659
+ [283, 0, 22156, 197, 22151, 23],
22660
+ [283, 0, 22157, 197, 22151, 23],
22661
+ [283, 0, 22158, 197, 22151, 23],
22662
+ [283, 0, 22159, 197, 22151, 23],
22663
+ [283, 0, 22160, 197, 22151, 23],
22664
+ [283, 0, 22161, 197, 22151, 23],
22665
+ [283, 0, 22162, 197, 22151, 23],
22666
+ [283, 0, 22163, 197, 22151, 23],
22667
+ [283, 0, 22164, 197, 22151, 23],
22668
+ [283, 0, 22165, 197, 22151, 23],
22669
+ [283, 0, 22166, 197, 22151, 23],
22670
+ [283, 0, 22167, 197, 22151, 23],
22671
+ [283, 0, 22168, 197, 22151, 23],
22672
+ [283, 0, 22169, 197, 22151, 23],
22673
+ [283, 0, 22170, 197, 22151, 23],
22674
+ [283, 0, 22171, 197, 22151, 23],
22675
+ [283, 0, 22172, 197, 22151, 23],
22676
+ [283, 0, 22173, 197, 22151, 23],
22677
+ [283, 0, 22174, 197, 22151, 23],
22678
+ [283, 0, 22175, 197, 22151, 23],
22679
+ [283, 0, 22176, 197, 22151, 23],
22680
+ [283, 0, 22177, 197, 22151, 23],
22681
+ [283, 0, 22178, 197, 22151, 23],
22682
+ [283, 0, 22179, 197, 22151, 23],
22683
+ [283, 0, 22180, 197, 22151, 23],
22684
+ [283, 0, 22181, 197, 22151, 23],
22685
+ [283, 0, 22182, 197, 22151, 23],
22686
+ [283, 0, 22151, 23],
22687
+ [284, 0, 22184, 21, 22185, 18, 22186, 22],
22688
22688
  [284, 0, 22187, 15],
22689
- [284, 0, 22188, 22],
22690
- [284, 0, 22189, 15],
22691
- [284, 0, 22190, 8],
22692
- [284, 0, 22191, 22],
22693
- [284, 0, 22192, 8],
22694
- [284, 0, 22193, 23],
22695
- [284, 0, 22194, 78],
22696
- [284, 0, 22190, 14, 22193, 23],
22689
+ [284, 0, 22188, 15],
22690
+ [284, 0, 22189, 22],
22691
+ [284, 0, 22190, 15],
22692
+ [284, 0, 22191, 8],
22693
+ [284, 0, 22192, 22],
22694
+ [284, 0, 22193, 8],
22695
+ [284, 0, 22194, 23],
22696
+ [284, 0, 22195, 78],
22697
+ [284, 0, 22191, 14, 22194, 23],
22698
+ [284, 0, 22196, 46],
22699
+ [284, 1, 22197, 199],
22697
22700
  [284, 0, 22195, 46],
22698
- [284, 1, 22196, 199],
22699
- [284, 0, 22194, 46],
22700
- [284, 1, 22196, 199],
22701
- [285, 0, 22198, 44],
22702
- [285, 0, 22199, 144],
22703
- [285, 0, 22200, 190, 22201, 190, 22202, 191, 22203, 47],
22704
- [285, 0, 22200, 190, 22201, 190, 22202, 191, 22203, 47],
22705
- [285, 0, 22204, 192, 22205, 193, 22206, 86, 22201, 190, 22202, 191, 22203, 47],
22706
- [285, 0, 22201, 190, 22202, 191, 22203, 47],
22701
+ [284, 1, 22197, 199],
22702
+ [285, 0, 22199, 44],
22703
+ [285, 0, 22200, 144],
22704
+ [285, 0, 22201, 190, 22202, 190, 22203, 191, 22204, 47],
22705
+ [285, 0, 22201, 190, 22202, 190, 22203, 191, 22204, 47],
22706
+ [285, 0, 22205, 192, 22206, 193, 22207, 86, 22202, 190, 22203, 191, 22204, 47],
22707
+ [285, 0, 22202, 190, 22203, 191, 22204, 47],
22707
22708
  [285, 1],
22708
- [285, 0, 22204, 192, 22205, 193, 22206, 86, 22201, 190, 22202, 191, 22203, 47],
22709
- [285, 0, 22205, 193, 22206, 86, 22201, 190, 22202, 191, 22203, 47],
22710
- [285, 0, 22207, 193, 22208, 143, 22209, 28, 22210, 194, 22201, 190, 22202, 191, 22203, 47],
22711
- [285, 0, 22207, 193, 22208, 143, 22209, 28, 22210, 194, 22201, 190, 22202, 191, 22203, 47],
22712
- [285, 0, 22211, 147, 22202, 143],
22713
- [285, 0, 22212, 149, 22202, 28],
22714
- [285, 0, 22213, 195, 22201, 190, 22202, 191, 22203, 47],
22715
- [285, 0, 22211, 147, 22202, 143],
22716
- [285, 0, 22212, 149, 22202, 28],
22717
- [285, 0, 22213, 195, 22201, 190, 22202, 191, 22203, 47],
22709
+ [285, 0, 22205, 192, 22206, 193, 22207, 86, 22202, 190, 22203, 191, 22204, 47],
22710
+ [285, 0, 22206, 193, 22207, 86, 22202, 190, 22203, 191, 22204, 47],
22711
+ [285, 0, 22208, 193, 22209, 143, 22210, 28, 22211, 194, 22202, 190, 22203, 191, 22204, 47],
22712
+ [285, 0, 22208, 193, 22209, 143, 22210, 28, 22211, 194, 22202, 190, 22203, 191, 22204, 47],
22713
+ [285, 0, 22212, 147, 22203, 143],
22714
+ [285, 0, 22213, 149, 22203, 28],
22715
+ [285, 0, 22214, 195, 22202, 190, 22203, 191, 22204, 47],
22716
+ [285, 0, 22212, 147, 22203, 143],
22717
+ [285, 0, 22213, 149, 22203, 28],
22718
+ [285, 0, 22214, 195, 22202, 190, 22203, 191, 22204, 47],
22718
22719
  ],
22719
22720
  };
22720
22721
  /** Each reversed injection pattern, loosened the same way. */
@@ -25,7 +25,7 @@ import { JS, NFA } from 'refa';
25
25
  import { analyse } from 'scslre';
26
26
  import { EGRESS_PATTERNS } from './egress-patterns.js';
27
27
  import { TheoremError } from './error.js';
28
- import { MAX_PATTERNS, PATTERN_COMPILER_VERSION, patternProblem, patternSources, } from './host-patterns.js';
28
+ import { PATTERN_COMPILER_VERSION, patternProblem, patternSources, } from './host-patterns.js';
29
29
  const MAX_CHAR = 0xffff;
30
30
  /**
31
31
  * A bounded repeat longer than this is read as unbounded: the hold cannot
@@ -355,9 +355,6 @@ function slowPatternProblem(source, flags = '') {
355
355
  * backreference to text that varies).
356
356
  */
357
357
  function compilePatterns(patterns) {
358
- if (patterns.length > MAX_PATTERNS) {
359
- throw patternError(`${patterns.length} patterns; a detector takes at most ${MAX_PATTERNS}`); // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
360
- }
361
358
  patterns.forEach((pattern, index) => {
362
359
  const problem = patternProblem(`patterns[${index}]`, pattern);
363
360
  if (problem !== undefined)
@@ -20,6 +20,7 @@
20
20
  import { EGRESS_PATTERNS, notePattern, } from './egress-patterns.js';
21
21
  import { IMAGE_PATTERNS, imageReadings, LINK_PATTERNS, linkReadings, } from './egress-urls.js';
22
22
  import { decodeUrlRuns, INJECTION_BLOBS, TYPO_TARGETS, tryLeet, tryRot13, typoNormalize, } from './injection.js';
23
+ import { freshPattern } from './injection-patterns.js';
23
24
  import { REVERSED_INJECTION_PATTERNS } from './injection-reversed.js';
24
25
  import { isEmoji, normalizeCodePoint } from './normalize.js';
25
26
  import { detectRule } from './rules.js';
@@ -471,7 +472,7 @@ function forwardPatterns(detectors, { given, allow, skipImages }) {
471
472
  out.push({
472
473
  ...rule,
473
474
  id,
474
- regex: new RegExp(entry.pattern.source, entry.pattern.flags),
475
+ regex: freshPattern(entry.pattern),
475
476
  ...patternReading(entry.kind, entry.pattern, urls),
476
477
  });
477
478
  });
@@ -487,7 +488,7 @@ function injectionPatterns() {
487
488
  out.push({
488
489
  ...INJECTION_RULE,
489
490
  id,
490
- regex: new RegExp(pattern.source, pattern.flags),
491
+ regex: freshPattern(pattern),
491
492
  ...(hit ? { hit } : {}),
492
493
  });
493
494
  });
@@ -649,6 +650,12 @@ function createScan(view, automaton, patterns) {
649
650
  resume[p] = Math.max(from, at) + 1;
650
651
  return { rule, severity, start: view.rawAt(at), detector };
651
652
  }
653
+ let lowered = { text: '', lower: '' };
654
+ const lower = () => {
655
+ if (lowered.text !== view.text)
656
+ lowered = { text: view.text, lower: view.text.toLowerCase() };
657
+ return lowered.lower;
658
+ };
652
659
  /** A regex pattern's hit up to `settledTo`. */
653
660
  function matched(p, settledTo) {
654
661
  if (!reached[p] && !recheck[p]) {
@@ -667,7 +674,7 @@ function createScan(view, automaton, patterns) {
667
674
  return undefined;
668
675
  }
669
676
  const [blob] = match;
670
- if (blob && (!hit || hit(blob, text, match.index))) {
677
+ if (blob && (!hit || hit(blob, text, match.index, lower))) {
671
678
  // why: The scan reads on from the end of the match, so the next call finds the one after it.
672
679
  resume[p] = regex.lastIndex;
673
680
  recheck[p] = 1;
@@ -448,8 +448,10 @@ function inlineLeaks(text, openers, scope, meter) {
448
448
  while (next < openers.length && openers[next].open < end) {
449
449
  inside.push(openers[next++]);
450
450
  }
451
- if (inside.length > 0)
452
- spans.push(...paragraphLeaks(text, start, end, inside, scope, meter));
451
+ if (inside.length > 0) {
452
+ for (const span of paragraphLeaks(text, start, end, inside, scope, meter))
453
+ spans.push(span);
454
+ }
453
455
  }
454
456
  return spans;
455
457
  }
@@ -16,7 +16,7 @@ declare function kindOfHttpStatus(status: number): ErrorKind;
16
16
  declare function errorCopyText(copy: ErrorCopies, labels?: LabelOverrides): string;
17
17
  /** Pass the profile's `labels`, or the profile's wording is skipped. */
18
18
  declare function publicError(err: unknown, labels?: LabelOverrides): string;
19
- /** Raw diagnostic for hosts, traces, and logs; never shown to end users. */
19
+ /** Raw diagnostic for hosts, traces, and logs; never shown to end users. Each cause that says something new follows on its own line. */
20
20
  declare function describeError(err: unknown): string;
21
21
  type ProducedError = TurnEventOf<'error'> & {
22
22
  errorInternal: string;
@@ -61,8 +61,7 @@ function errorCopyText(copy, labels) {
61
61
  function publicError(err, labels) {
62
62
  return wording(errorKind(err), err instanceof TheoremError ? err.copy : undefined, labels);
63
63
  }
64
- /** Raw diagnostic for hosts, traces, and logs; never shown to end users. */
65
- function describeError(err) {
64
+ function messageOf(err) {
66
65
  if (typeof err === 'string') {
67
66
  return err;
68
67
  }
@@ -71,6 +70,24 @@ function describeError(err) {
71
70
  }
72
71
  return String(err);
73
72
  }
73
+ /** Raw diagnostic for hosts, traces, and logs; never shown to end users. Each cause that says something new follows on its own line. */
74
+ function describeError(err) {
75
+ const lines = [messageOf(err)];
76
+ const seen = new Set([err]);
77
+ let said = messageOf(err);
78
+ let cause = err instanceof Error ? err.cause : undefined;
79
+ while (cause !== undefined && cause !== null && !seen.has(cause)) {
80
+ seen.add(cause);
81
+ const message = messageOf(cause);
82
+ if (message !== said) {
83
+ const name = cause instanceof Error && cause.name !== 'Error' ? `${cause.name}: ` : '';
84
+ lines.push(`caused by: ${name}${message}`);
85
+ said = message;
86
+ }
87
+ cause = cause instanceof Error ? cause.cause : undefined;
88
+ }
89
+ return lines.join('\n');
90
+ }
74
91
  /** No user wording yet: `withPublicLabels` adds it where the event reaches the host, the one place that knows the profile. */
75
92
  function toErrorEvent(err) {
76
93
  return {
@@ -59,9 +59,6 @@ interface HostMatcher {
59
59
  }
60
60
  /** Bumped whenever the compiled table's layout or meaning changes. */
61
61
  declare const PATTERN_COMPILER_VERSION = 3;
62
- /** The most patterns one detector takes, and the longest each may be once written as a regular expression. */
63
- declare const MAX_PATTERNS = 64;
64
- declare const MAX_PATTERN_LENGTH = 1024;
65
62
  /** The patterns as a compiled table records them. */
66
63
  declare function patternSources(patterns: readonly HostPattern[]): PatternSource[];
67
64
  /** What is wrong with one pattern, or `undefined` when it runs. */
@@ -82,4 +79,4 @@ declare function listsPatterns(detect: unknown): boolean;
82
79
  /** `patterns`, valid, ready to run. */
83
80
  declare function matchersOf(patterns: readonly HostPattern[]): readonly HostMatcher[];
84
81
  export type { AutomatonData, CompiledPatterns, HostMatcher, HostPattern, PatternSource };
85
- export { listsPatterns, MAX_PATTERN_LENGTH, MAX_PATTERNS, matchersOf, PATTERN_COMPILER_VERSION, patternListProblem, patternProblem, patternSources, patternsProblem, };
82
+ export { listsPatterns, matchersOf, PATTERN_COMPILER_VERSION, patternListProblem, patternProblem, patternSources, patternsProblem, };
@@ -2,9 +2,6 @@
2
2
  // `detectors.ts` can read a host's patterns without a cycle.
3
3
  /** Bumped whenever the compiled table's layout or meaning changes. */
4
4
  const PATTERN_COMPILER_VERSION = 3;
5
- /** The most patterns one detector takes, and the longest each may be once written as a regular expression. */
6
- const MAX_PATTERNS = 64;
7
- const MAX_PATTERN_LENGTH = 1024;
8
5
  const PATTERN_FLAGS = 'imsu';
9
6
  /** A letter, digit, or underscore in any script: what a word may not touch on either side. */
10
7
  const WORD_UNIT = '[\\p{L}\\p{N}_]';
@@ -79,9 +76,6 @@ function patternProblem(path, pattern) {
79
76
  if (shape !== undefined)
80
77
  return shape;
81
78
  const { source, flags } = patternSource(pattern);
82
- if (source.length > MAX_PATTERN_LENGTH) {
83
- return `${path} is ${source.length} characters as a regular expression; the most is ${MAX_PATTERN_LENGTH}`;
84
- }
85
79
  let regex;
86
80
  try {
87
81
  // why: this only checks that the pattern parses and tests it on the empty text; a pattern that
@@ -134,9 +128,6 @@ function patternsProblem(path, patterns, compiled) {
134
128
  function patternListProblem(path, patterns) {
135
129
  if (!Array.isArray(patterns))
136
130
  return `${path}.patterns must be a list`;
137
- if (patterns.length > MAX_PATTERNS) {
138
- return `${path}.patterns lists ${patterns.length} patterns; the most is ${MAX_PATTERNS}`;
139
- }
140
131
  const names = new Set();
141
132
  for (const [index, pattern] of patterns.entries()) {
142
133
  const at = `${path}.patterns[${index}]`;
@@ -170,4 +161,4 @@ function matchersOf(patterns) {
170
161
  }
171
162
  return matchers;
172
163
  }
173
- export { listsPatterns, MAX_PATTERN_LENGTH, MAX_PATTERNS, matchersOf, PATTERN_COMPILER_VERSION, patternListProblem, patternProblem, patternSources, patternsProblem, };
164
+ export { listsPatterns, matchersOf, PATTERN_COMPILER_VERSION, patternListProblem, patternProblem, patternSources, patternsProblem, };
@@ -17,4 +17,6 @@ declare const HEX_BLOB: RegExp;
17
17
  declare const SPACED_LETTERS: RegExp;
18
18
  /** Three+ alphabetic tokens joined by `|` (no shell spaces around pipes). */
19
19
  declare const PIPE_SEPARATED: RegExp;
20
- export { BASE64_BLOB, HEX_BLOB, INJECTION_PATTERNS, overrideFrame, PIPE_SEPARATED, SPACED_LETTERS };
20
+ /** A pattern of its own for one scan to move `lastIndex` on, of the same class as `pattern`. */
21
+ declare function freshPattern(pattern: RegExp): RegExp;
22
+ export { BASE64_BLOB, freshPattern, HEX_BLOB, INJECTION_PATTERNS, overrideFrame, PIPE_SEPARATED, SPACED_LETTERS, };