@genesislcap/ai-assistant 15.43.0 → 15.45.0

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 (56) hide show
  1. package/dist/ai-assistant.api.json +34 -19
  2. package/dist/ai-assistant.d.ts +36 -2
  3. package/dist/chat-driver.cjs +89 -10
  4. package/dist/chat-driver.cjs.map +2 -2
  5. package/dist/chat-driver.mjs +89 -10
  6. package/dist/chat-driver.mjs.map +2 -2
  7. package/dist/custom-elements.json +466 -285
  8. package/dist/dts/components/chat-driver/chat-driver.d.ts +15 -2
  9. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  10. package/dist/dts/components/chat-driver/interaction-controller.d.ts +26 -3
  11. package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
  12. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts +6 -0
  13. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
  14. package/dist/dts/genesis/config.d.ts +28 -1
  15. package/dist/dts/genesis/config.d.ts.map +1 -1
  16. package/dist/dts/genesis/consumes.d.ts.map +1 -1
  17. package/dist/dts/genesis/index.d.ts +2 -1
  18. package/dist/dts/genesis/index.d.ts.map +1 -1
  19. package/dist/dts/genesis/register-genesis-assistant.d.ts.map +1 -1
  20. package/dist/dts/genesis/review-model.d.ts +72 -1
  21. package/dist/dts/genesis/review-model.d.ts.map +1 -1
  22. package/dist/dts/genesis/types.d.ts +32 -0
  23. package/dist/dts/genesis/types.d.ts.map +1 -1
  24. package/dist/dts/genesis/write-review/write-review.d.ts +22 -1
  25. package/dist/dts/genesis/write-review/write-review.d.ts.map +1 -1
  26. package/dist/dts/genesis/write-review/write-review.styles.d.ts.map +1 -1
  27. package/dist/dts/genesis/write-review/write-review.template.d.ts.map +1 -1
  28. package/dist/dts/genesis/write-tools.d.ts +6 -1
  29. package/dist/dts/genesis/write-tools.d.ts.map +1 -1
  30. package/dist/dts/main/main.template.d.ts +8 -0
  31. package/dist/dts/main/main.template.d.ts.map +1 -1
  32. package/dist/dts/state/debug-event-log.d.ts +1 -1
  33. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  34. package/dist/dts/types/ai-chat-widget.d.ts +7 -0
  35. package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
  36. package/dist/esm/components/chat-driver/chat-driver.js +39 -6
  37. package/dist/esm/components/chat-driver/interaction-controller.js +50 -4
  38. package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +17 -6
  39. package/dist/esm/genesis/config.js +108 -7
  40. package/dist/esm/genesis/consumes.js +8 -1
  41. package/dist/esm/genesis/index.js +1 -0
  42. package/dist/esm/genesis/register-genesis-assistant.js +7 -0
  43. package/dist/esm/genesis/review-model.js +115 -7
  44. package/dist/esm/genesis/write-review/write-review.js +80 -19
  45. package/dist/esm/genesis/write-review/write-review.styles.js +5 -2
  46. package/dist/esm/genesis/write-review/write-review.template.js +19 -2
  47. package/dist/esm/genesis/write-tools.js +49 -13
  48. package/dist/esm/main/main.template.js +19 -10
  49. package/dist/esm/state/debug-event-log.js +4 -0
  50. package/dist/genesis-consumes.cjs +8 -1
  51. package/dist/genesis-consumes.cjs.map +2 -2
  52. package/dist/genesis-consumes.mjs +8 -1
  53. package/dist/genesis-consumes.mjs.map +2 -2
  54. package/docs/genesis.md +60 -2
  55. package/package.json +18 -18
  56. package/scripts/smoke-genesis-consumes-node.mjs +1 -1
@@ -1754,211 +1754,6 @@
1754
1754
  }
1755
1755
  ]
1756
1756
  },
1757
- {
1758
- "kind": "javascript-module",
1759
- "path": "src/config/config.ts",
1760
- "declarations": [
1761
- {
1762
- "kind": "function",
1763
- "name": "defineAgent",
1764
- "description": "Identity helper that infers the narrowest possible type for an agent config,\npreserving string literal types (including `name`) without requiring `as const`.\n\nUse this when you need `typeof myAgent` to carry the literal `name` type —\nfor example, when wiring `ChatToolHandlers<typeof myAgent>`.\n\n```ts\nconst myAgent = defineAgent({ name: 'my_agent', ... });\ntype Handlers = ChatToolHandlers<typeof myAgent>;\n// requestSubAgent name param is now typed as 'my_agent'\n```"
1765
- }
1766
- ],
1767
- "exports": [
1768
- {
1769
- "kind": "js",
1770
- "name": "CachePolicy",
1771
- "declaration": {
1772
- "name": "CachePolicy",
1773
- "module": "src/config/config.ts"
1774
- }
1775
- },
1776
- {
1777
- "kind": "js",
1778
- "name": "ChatFallback",
1779
- "declaration": {
1780
- "name": "ChatFallback",
1781
- "module": "src/config/config.ts"
1782
- }
1783
- },
1784
- {
1785
- "kind": "js",
1786
- "name": "ChatInputDuringExecutionMode",
1787
- "declaration": {
1788
- "name": "ChatInputDuringExecutionMode",
1789
- "module": "src/config/config.ts"
1790
- }
1791
- },
1792
- {
1793
- "kind": "js",
1794
- "name": "ChatThinkingPolicy",
1795
- "declaration": {
1796
- "name": "ChatThinkingPolicy",
1797
- "module": "src/config/config.ts"
1798
- }
1799
- },
1800
- {
1801
- "kind": "js",
1802
- "name": "ChatToolChoice",
1803
- "declaration": {
1804
- "name": "ChatToolChoice",
1805
- "module": "src/config/config.ts"
1806
- }
1807
- },
1808
- {
1809
- "kind": "js",
1810
- "name": "defineAgent",
1811
- "declaration": {
1812
- "name": "defineAgent",
1813
- "module": "src/config/config.ts"
1814
- }
1815
- }
1816
- ]
1817
- },
1818
- {
1819
- "kind": "javascript-module",
1820
- "path": "src/config/define-stateful-agent.ts",
1821
- "declarations": [
1822
- {
1823
- "kind": "function",
1824
- "name": "restoreMachine",
1825
- "return": {
1826
- "type": {
1827
- "text": "void"
1828
- }
1829
- },
1830
- "parameters": [
1831
- {
1832
- "name": "machine",
1833
- "type": {
1834
- "text": "{ stop: () => void; start: (options?: { state?: unknown }) => void }"
1835
- },
1836
- "description": "the machine to restore (already constructed/started)."
1837
- },
1838
- {
1839
- "name": "restored",
1840
- "type": {
1841
- "text": "unknown"
1842
- },
1843
- "description": "the agent's serialized image (`ctx.restored` in `init`)."
1844
- },
1845
- {
1846
- "name": "key",
1847
- "default": "'machine'",
1848
- "description": "the property the machine occupies in the snapshot; defaults to\n`'machine'` to match the conventional `{ machine }` state bag."
1849
- }
1850
- ],
1851
- "description": "Restore a foundation-state-machine instance from a snapshot produced by the\ndefault serializer (or `machine.getPersistedSnapshot()`). Call inside a\nstateful agent's `init` to resume the machine in its exact prior place:\n\n```ts\ninit: ({ restored }) => {\n const machine = new MyMachine();\n restoreMachine(machine, restored); // resume, or no-op on a fresh start\n return { machine };\n}\n```\n\nNo-ops when there is nothing to restore (a fresh session), leaving the\nfreshly-constructed machine in its initial state."
1852
- },
1853
- {
1854
- "kind": "function",
1855
- "name": "defineStatefulAgent",
1856
- "return": {
1857
- "type": {
1858
- "text": "AgentConfig"
1859
- }
1860
- },
1861
- "parameters": [
1862
- {
1863
- "name": "opts",
1864
- "type": {
1865
- "text": "StatefulAgentInit<S>"
1866
- }
1867
- }
1868
- ],
1869
- "description": "Build an `AgentConfig` whose `systemPrompt`, `toolDefinitions`, and tool\nhandlers all close over a long-lived state object created on activation.\n\nThe framework wires the lifecycle: `init` on `onActivate`, `dispose` on\n`onDeactivate`. State is held inside the helper's closure — never exposed on\nthe resulting `AgentConfig` — so the redux serializer doesn't see it."
1870
- }
1871
- ],
1872
- "exports": [
1873
- {
1874
- "kind": "js",
1875
- "name": "restoreMachine",
1876
- "declaration": {
1877
- "name": "restoreMachine",
1878
- "module": "src/config/define-stateful-agent.ts"
1879
- }
1880
- },
1881
- {
1882
- "kind": "js",
1883
- "name": "defineStatefulAgent",
1884
- "declaration": {
1885
- "name": "defineStatefulAgent",
1886
- "module": "src/config/define-stateful-agent.ts"
1887
- }
1888
- }
1889
- ]
1890
- },
1891
- {
1892
- "kind": "javascript-module",
1893
- "path": "src/config/fallback-agents.ts",
1894
- "declarations": [
1895
- {
1896
- "kind": "variable",
1897
- "name": "friendlyFallbackAgent",
1898
- "type": {
1899
- "text": "FallbackAgentConfig"
1900
- },
1901
- "default": "{\n name: 'Assistant',\n fallback: true,\n systemPrompt: `You are a warm, friendly assistant. For general conversation like \"Hi\" or \"How are you\", you can have a friendly chat. For anything more complex, you cannot directly help, but you can explain what specialists are available. The available specialists are:\\n\\n{{agents}}\\n\\nPolitely let the user know what you can help with and invite them to rephrase their request if it is outside your scope.`,\n}",
1902
- "description": "A warm, conversational fallback agent. Acknowledges it can't help directly,\nexplains what the available specialists can do, and invites the user to retry.\n\nThe system prompt is generated at runtime by `OrchestratingDriver` from the\nspecialist list — no manual authoring required."
1903
- },
1904
- {
1905
- "kind": "variable",
1906
- "name": "strictFallbackAgent",
1907
- "type": {
1908
- "text": "FallbackAgentConfig"
1909
- },
1910
- "default": "{\n name: 'Assistant',\n fallback: true,\n systemPrompt: `You are a concise assistant. The user's request is outside your scope. The available specialists are: {{agents}}.\n\n{{unroutable}}\n\nAnswer in a single short sentence. Do not elaborate.`,\n}",
1911
- "description": "A brief, professional fallback agent. States what is available without\nelaboration. The `{{agents}}` placeholder is replaced at runtime by\n`OrchestratingDriver` with the generated specialist list.\n\nThe `{{unroutable}}` placeholder positions `UNROUTABLE_INSTRUCTION` — the framework's\ninstruction for a substantive request no specialist covers, which is otherwise APPENDED to a\nstring-form prompt. Positioned rather than appended for one reason: this preset's whole point is\nbrevity, and appended text would be the last thing the model reads. Putting the block above the\nbrevity rule leaves \"a single short sentence\" with the recency, so the two compose instead of\ncompeting. A prompt whose tone rules matter should do the same."
1912
- }
1913
- ],
1914
- "exports": [
1915
- {
1916
- "kind": "js",
1917
- "name": "friendlyFallbackAgent",
1918
- "declaration": {
1919
- "name": "friendlyFallbackAgent",
1920
- "module": "src/config/fallback-agents.ts"
1921
- }
1922
- },
1923
- {
1924
- "kind": "js",
1925
- "name": "strictFallbackAgent",
1926
- "declaration": {
1927
- "name": "strictFallbackAgent",
1928
- "module": "src/config/fallback-agents.ts"
1929
- }
1930
- }
1931
- ]
1932
- },
1933
- {
1934
- "kind": "javascript-module",
1935
- "path": "src/config/index.ts",
1936
- "declarations": [],
1937
- "exports": [
1938
- {
1939
- "kind": "js",
1940
- "name": "*",
1941
- "declaration": {
1942
- "name": "*",
1943
- "package": "./config"
1944
- }
1945
- },
1946
- {
1947
- "kind": "js",
1948
- "name": "*",
1949
- "declaration": {
1950
- "name": "*",
1951
- "package": "./fallback-agents"
1952
- }
1953
- }
1954
- ]
1955
- },
1956
- {
1957
- "kind": "javascript-module",
1958
- "path": "src/config/validate-providers.ts",
1959
- "declarations": [],
1960
- "exports": []
1961
- },
1962
1757
  {
1963
1758
  "kind": "javascript-module",
1964
1759
  "path": "src/genesis/calendar.ts",
@@ -2003,6 +1798,24 @@
2003
1798
  }
2004
1799
  ],
2005
1800
  "description": "The model-facing tool name for a resource. Deterministic and collision-free (resource names\nare unique), and trivially mapped back to the resource in a debug log. What the tool is FOR\nreaches the model through its description, not its name."
1801
+ },
1802
+ {
1803
+ "kind": "function",
1804
+ "name": "customCodeOf",
1805
+ "return": {
1806
+ "type": {
1807
+ "text": "GenesisCustomCodeCheck"
1808
+ }
1809
+ },
1810
+ "parameters": [
1811
+ {
1812
+ "name": "resource",
1813
+ "type": {
1814
+ "text": "GenesisAiResource"
1815
+ }
1816
+ }
1817
+ ],
1818
+ "description": "A resource's `customCode` as it is used: the one reader of the field."
2006
1819
  }
2007
1820
  ],
2008
1821
  "exports": [
@@ -2029,6 +1842,14 @@
2029
1842
  "name": "toolNameOf",
2030
1843
  "module": "src/genesis/config.ts"
2031
1844
  }
1845
+ },
1846
+ {
1847
+ "kind": "js",
1848
+ "name": "customCodeOf",
1849
+ "declaration": {
1850
+ "name": "customCodeOf",
1851
+ "module": "src/genesis/config.ts"
1852
+ }
2032
1853
  }
2033
1854
  ]
2034
1855
  },
@@ -2180,6 +2001,14 @@
2180
2001
  "module": "./register-genesis-assistant"
2181
2002
  }
2182
2003
  },
2004
+ {
2005
+ "kind": "js",
2006
+ "name": "customCodeOf",
2007
+ "declaration": {
2008
+ "name": "customCodeOf",
2009
+ "module": "./config"
2010
+ }
2011
+ },
2183
2012
  {
2184
2013
  "kind": "js",
2185
2014
  "name": "GENESIS_AI_CONSUMES",
@@ -2388,6 +2217,22 @@
2388
2217
  "module": "./types"
2389
2218
  }
2390
2219
  },
2220
+ {
2221
+ "kind": "js",
2222
+ "name": "GenesisCustomCode",
2223
+ "declaration": {
2224
+ "name": "GenesisCustomCode",
2225
+ "module": "./types"
2226
+ }
2227
+ },
2228
+ {
2229
+ "kind": "js",
2230
+ "name": "GenesisCustomCodeCheck",
2231
+ "declaration": {
2232
+ "name": "GenesisCustomCodeCheck",
2233
+ "module": "./types"
2234
+ }
2235
+ },
2391
2236
  {
2392
2237
  "kind": "js",
2393
2238
  "name": "GenesisEventOp",
@@ -2675,137 +2520,342 @@
2675
2520
  },
2676
2521
  {
2677
2522
  "kind": "javascript-module",
2678
- "path": "src/genesis/value-compare.ts",
2679
- "declarations": [],
2680
- "exports": []
2681
- },
2682
- {
2683
- "kind": "javascript-module",
2684
- "path": "src/genesis/write-commit.ts",
2685
- "declarations": [],
2686
- "exports": []
2687
- },
2688
- {
2689
- "kind": "javascript-module",
2690
- "path": "src/genesis/write-outcome.ts",
2691
- "declarations": [],
2692
- "exports": []
2693
- },
2694
- {
2695
- "kind": "javascript-module",
2696
- "path": "src/genesis/write-payload.ts",
2523
+ "path": "src/genesis/value-compare.ts",
2524
+ "declarations": [],
2525
+ "exports": []
2526
+ },
2527
+ {
2528
+ "kind": "javascript-module",
2529
+ "path": "src/genesis/write-commit.ts",
2530
+ "declarations": [],
2531
+ "exports": []
2532
+ },
2533
+ {
2534
+ "kind": "javascript-module",
2535
+ "path": "src/genesis/write-outcome.ts",
2536
+ "declarations": [],
2537
+ "exports": []
2538
+ },
2539
+ {
2540
+ "kind": "javascript-module",
2541
+ "path": "src/genesis/write-payload.ts",
2542
+ "declarations": [
2543
+ {
2544
+ "kind": "function",
2545
+ "name": "buildEventPayload",
2546
+ "return": {
2547
+ "type": {
2548
+ "text": "PayloadResult"
2549
+ }
2550
+ },
2551
+ "parameters": [
2552
+ {
2553
+ "name": "fields",
2554
+ "type": {
2555
+ "text": "readonly GenesisEventField[]"
2556
+ }
2557
+ },
2558
+ {
2559
+ "name": "row",
2560
+ "type": {
2561
+ "text": "unknown"
2562
+ }
2563
+ },
2564
+ {
2565
+ "name": "{ op, preImage }",
2566
+ "default": "{}",
2567
+ "type": {
2568
+ "text": "BuildPayloadOptions"
2569
+ }
2570
+ }
2571
+ ]
2572
+ }
2573
+ ],
2574
+ "exports": [
2575
+ {
2576
+ "kind": "js",
2577
+ "name": "buildEventPayload",
2578
+ "declaration": {
2579
+ "name": "buildEventPayload",
2580
+ "module": "src/genesis/write-payload.ts"
2581
+ }
2582
+ }
2583
+ ]
2584
+ },
2585
+ {
2586
+ "kind": "javascript-module",
2587
+ "path": "src/genesis/write-plan.ts",
2588
+ "declarations": [
2589
+ {
2590
+ "kind": "variable",
2591
+ "name": "MAX_WRITE_ROWS",
2592
+ "type": {
2593
+ "text": "number"
2594
+ },
2595
+ "default": "25",
2596
+ "description": "A batch a person can actually read before approving it."
2597
+ }
2598
+ ],
2599
+ "exports": [
2600
+ {
2601
+ "kind": "js",
2602
+ "name": "MAX_WRITE_ROWS",
2603
+ "declaration": {
2604
+ "name": "MAX_WRITE_ROWS",
2605
+ "module": "src/genesis/write-plan.ts"
2606
+ }
2607
+ }
2608
+ ]
2609
+ },
2610
+ {
2611
+ "kind": "javascript-module",
2612
+ "path": "src/genesis/write-tools.ts",
2613
+ "declarations": [
2614
+ {
2615
+ "kind": "function",
2616
+ "name": "createGenesisWriteTools",
2617
+ "return": {
2618
+ "type": {
2619
+ "text": "{\n toolDefinitions: () => Promise<ChatToolDefinition[]>;\n toolHandlers: ChatToolHandlers;\n /**\n * The events that can get a write tool, as far as the config can tell: an event refused for its\n * op or its rowSources entry, or a modify or delete with no row source, is not among them. Their\n * metadata, read when the tools are first listed, can still withhold one.\n */\n writableEvents: readonly string[];\n}"
2620
+ }
2621
+ },
2622
+ "parameters": [
2623
+ {
2624
+ "name": "resources",
2625
+ "type": {
2626
+ "text": "readonly GenesisAiResource[]"
2627
+ }
2628
+ },
2629
+ {
2630
+ "name": "options",
2631
+ "default": "{}",
2632
+ "type": {
2633
+ "text": "GenesisWriteToolsOptions"
2634
+ }
2635
+ }
2636
+ ],
2637
+ "description": "Builds the assistant's write tools from an app's event resources."
2638
+ }
2639
+ ],
2640
+ "exports": [
2641
+ {
2642
+ "kind": "js",
2643
+ "name": "createGenesisWriteTools",
2644
+ "declaration": {
2645
+ "name": "createGenesisWriteTools",
2646
+ "module": "src/genesis/write-tools.ts"
2647
+ }
2648
+ }
2649
+ ]
2650
+ },
2651
+ {
2652
+ "kind": "javascript-module",
2653
+ "path": "src/genesis/write-turn.ts",
2654
+ "declarations": [],
2655
+ "exports": []
2656
+ },
2657
+ {
2658
+ "kind": "javascript-module",
2659
+ "path": "src/config/config.ts",
2660
+ "declarations": [
2661
+ {
2662
+ "kind": "function",
2663
+ "name": "defineAgent",
2664
+ "description": "Identity helper that infers the narrowest possible type for an agent config,\npreserving string literal types (including `name`) without requiring `as const`.\n\nUse this when you need `typeof myAgent` to carry the literal `name` type —\nfor example, when wiring `ChatToolHandlers<typeof myAgent>`.\n\n```ts\nconst myAgent = defineAgent({ name: 'my_agent', ... });\ntype Handlers = ChatToolHandlers<typeof myAgent>;\n// requestSubAgent name param is now typed as 'my_agent'\n```"
2665
+ }
2666
+ ],
2667
+ "exports": [
2668
+ {
2669
+ "kind": "js",
2670
+ "name": "CachePolicy",
2671
+ "declaration": {
2672
+ "name": "CachePolicy",
2673
+ "module": "src/config/config.ts"
2674
+ }
2675
+ },
2676
+ {
2677
+ "kind": "js",
2678
+ "name": "ChatFallback",
2679
+ "declaration": {
2680
+ "name": "ChatFallback",
2681
+ "module": "src/config/config.ts"
2682
+ }
2683
+ },
2684
+ {
2685
+ "kind": "js",
2686
+ "name": "ChatInputDuringExecutionMode",
2687
+ "declaration": {
2688
+ "name": "ChatInputDuringExecutionMode",
2689
+ "module": "src/config/config.ts"
2690
+ }
2691
+ },
2692
+ {
2693
+ "kind": "js",
2694
+ "name": "ChatThinkingPolicy",
2695
+ "declaration": {
2696
+ "name": "ChatThinkingPolicy",
2697
+ "module": "src/config/config.ts"
2698
+ }
2699
+ },
2700
+ {
2701
+ "kind": "js",
2702
+ "name": "ChatToolChoice",
2703
+ "declaration": {
2704
+ "name": "ChatToolChoice",
2705
+ "module": "src/config/config.ts"
2706
+ }
2707
+ },
2708
+ {
2709
+ "kind": "js",
2710
+ "name": "defineAgent",
2711
+ "declaration": {
2712
+ "name": "defineAgent",
2713
+ "module": "src/config/config.ts"
2714
+ }
2715
+ }
2716
+ ]
2717
+ },
2718
+ {
2719
+ "kind": "javascript-module",
2720
+ "path": "src/config/define-stateful-agent.ts",
2697
2721
  "declarations": [
2698
2722
  {
2699
2723
  "kind": "function",
2700
- "name": "buildEventPayload",
2724
+ "name": "restoreMachine",
2701
2725
  "return": {
2702
2726
  "type": {
2703
- "text": "PayloadResult"
2727
+ "text": "void"
2704
2728
  }
2705
2729
  },
2706
2730
  "parameters": [
2707
2731
  {
2708
- "name": "fields",
2732
+ "name": "machine",
2709
2733
  "type": {
2710
- "text": "readonly GenesisEventField[]"
2711
- }
2734
+ "text": "{ stop: () => void; start: (options?: { state?: unknown }) => void }"
2735
+ },
2736
+ "description": "the machine to restore (already constructed/started)."
2712
2737
  },
2713
2738
  {
2714
- "name": "row",
2739
+ "name": "restored",
2715
2740
  "type": {
2716
2741
  "text": "unknown"
2717
- }
2742
+ },
2743
+ "description": "the agent's serialized image (`ctx.restored` in `init`)."
2718
2744
  },
2719
2745
  {
2720
- "name": "{ op, preImage }",
2721
- "default": "{}",
2746
+ "name": "key",
2747
+ "default": "'machine'",
2748
+ "description": "the property the machine occupies in the snapshot; defaults to\n`'machine'` to match the conventional `{ machine }` state bag."
2749
+ }
2750
+ ],
2751
+ "description": "Restore a foundation-state-machine instance from a snapshot produced by the\ndefault serializer (or `machine.getPersistedSnapshot()`). Call inside a\nstateful agent's `init` to resume the machine in its exact prior place:\n\n```ts\ninit: ({ restored }) => {\n const machine = new MyMachine();\n restoreMachine(machine, restored); // resume, or no-op on a fresh start\n return { machine };\n}\n```\n\nNo-ops when there is nothing to restore (a fresh session), leaving the\nfreshly-constructed machine in its initial state."
2752
+ },
2753
+ {
2754
+ "kind": "function",
2755
+ "name": "defineStatefulAgent",
2756
+ "return": {
2757
+ "type": {
2758
+ "text": "AgentConfig"
2759
+ }
2760
+ },
2761
+ "parameters": [
2762
+ {
2763
+ "name": "opts",
2722
2764
  "type": {
2723
- "text": "BuildPayloadOptions"
2765
+ "text": "StatefulAgentInit<S>"
2724
2766
  }
2725
2767
  }
2726
- ]
2768
+ ],
2769
+ "description": "Build an `AgentConfig` whose `systemPrompt`, `toolDefinitions`, and tool\nhandlers all close over a long-lived state object created on activation.\n\nThe framework wires the lifecycle: `init` on `onActivate`, `dispose` on\n`onDeactivate`. State is held inside the helper's closure — never exposed on\nthe resulting `AgentConfig` — so the redux serializer doesn't see it."
2727
2770
  }
2728
2771
  ],
2729
2772
  "exports": [
2730
2773
  {
2731
2774
  "kind": "js",
2732
- "name": "buildEventPayload",
2775
+ "name": "restoreMachine",
2733
2776
  "declaration": {
2734
- "name": "buildEventPayload",
2735
- "module": "src/genesis/write-payload.ts"
2777
+ "name": "restoreMachine",
2778
+ "module": "src/config/define-stateful-agent.ts"
2779
+ }
2780
+ },
2781
+ {
2782
+ "kind": "js",
2783
+ "name": "defineStatefulAgent",
2784
+ "declaration": {
2785
+ "name": "defineStatefulAgent",
2786
+ "module": "src/config/define-stateful-agent.ts"
2736
2787
  }
2737
2788
  }
2738
2789
  ]
2739
2790
  },
2740
2791
  {
2741
2792
  "kind": "javascript-module",
2742
- "path": "src/genesis/write-plan.ts",
2793
+ "path": "src/config/fallback-agents.ts",
2743
2794
  "declarations": [
2744
2795
  {
2745
2796
  "kind": "variable",
2746
- "name": "MAX_WRITE_ROWS",
2797
+ "name": "friendlyFallbackAgent",
2747
2798
  "type": {
2748
- "text": "number"
2799
+ "text": "FallbackAgentConfig"
2749
2800
  },
2750
- "default": "25",
2751
- "description": "A batch a person can actually read before approving it."
2801
+ "default": "{\n name: 'Assistant',\n fallback: true,\n systemPrompt: `You are a warm, friendly assistant. For general conversation like \"Hi\" or \"How are you\", you can have a friendly chat. For anything more complex, you cannot directly help, but you can explain what specialists are available. The available specialists are:\\n\\n{{agents}}\\n\\nPolitely let the user know what you can help with and invite them to rephrase their request if it is outside your scope.`,\n}",
2802
+ "description": "A warm, conversational fallback agent. Acknowledges it can't help directly,\nexplains what the available specialists can do, and invites the user to retry.\n\nThe system prompt is generated at runtime by `OrchestratingDriver` from the\nspecialist list — no manual authoring required."
2803
+ },
2804
+ {
2805
+ "kind": "variable",
2806
+ "name": "strictFallbackAgent",
2807
+ "type": {
2808
+ "text": "FallbackAgentConfig"
2809
+ },
2810
+ "default": "{\n name: 'Assistant',\n fallback: true,\n systemPrompt: `You are a concise assistant. The user's request is outside your scope. The available specialists are: {{agents}}.\n\n{{unroutable}}\n\nAnswer in a single short sentence. Do not elaborate.`,\n}",
2811
+ "description": "A brief, professional fallback agent. States what is available without\nelaboration. The `{{agents}}` placeholder is replaced at runtime by\n`OrchestratingDriver` with the generated specialist list.\n\nThe `{{unroutable}}` placeholder positions `UNROUTABLE_INSTRUCTION` — the framework's\ninstruction for a substantive request no specialist covers, which is otherwise APPENDED to a\nstring-form prompt. Positioned rather than appended for one reason: this preset's whole point is\nbrevity, and appended text would be the last thing the model reads. Putting the block above the\nbrevity rule leaves \"a single short sentence\" with the recency, so the two compose instead of\ncompeting. A prompt whose tone rules matter should do the same."
2752
2812
  }
2753
2813
  ],
2754
2814
  "exports": [
2755
2815
  {
2756
2816
  "kind": "js",
2757
- "name": "MAX_WRITE_ROWS",
2817
+ "name": "friendlyFallbackAgent",
2758
2818
  "declaration": {
2759
- "name": "MAX_WRITE_ROWS",
2760
- "module": "src/genesis/write-plan.ts"
2819
+ "name": "friendlyFallbackAgent",
2820
+ "module": "src/config/fallback-agents.ts"
2821
+ }
2822
+ },
2823
+ {
2824
+ "kind": "js",
2825
+ "name": "strictFallbackAgent",
2826
+ "declaration": {
2827
+ "name": "strictFallbackAgent",
2828
+ "module": "src/config/fallback-agents.ts"
2761
2829
  }
2762
2830
  }
2763
2831
  ]
2764
2832
  },
2765
2833
  {
2766
2834
  "kind": "javascript-module",
2767
- "path": "src/genesis/write-tools.ts",
2768
- "declarations": [
2769
- {
2770
- "kind": "function",
2771
- "name": "createGenesisWriteTools",
2772
- "return": {
2773
- "type": {
2774
- "text": "{\n toolDefinitions: () => Promise<ChatToolDefinition[]>;\n toolHandlers: ChatToolHandlers;\n /**\n * The events that can get a write tool, as far as the config can tell: an event refused for its\n * op or its rowSources entry, or a modify or delete with no row source, is not among them. Their\n * metadata, read when the tools are first listed, can still withhold one.\n */\n writableEvents: readonly string[];\n}"
2775
- }
2776
- },
2777
- "parameters": [
2778
- {
2779
- "name": "resources",
2780
- "type": {
2781
- "text": "readonly GenesisAiResource[]"
2782
- }
2783
- },
2784
- {
2785
- "name": "options",
2786
- "default": "{}",
2787
- "type": {
2788
- "text": "GenesisWriteToolsOptions"
2789
- }
2790
- }
2791
- ],
2792
- "description": "Builds the assistant's write tools from an app's event resources."
2793
- }
2794
- ],
2835
+ "path": "src/config/index.ts",
2836
+ "declarations": [],
2795
2837
  "exports": [
2796
2838
  {
2797
2839
  "kind": "js",
2798
- "name": "createGenesisWriteTools",
2840
+ "name": "*",
2799
2841
  "declaration": {
2800
- "name": "createGenesisWriteTools",
2801
- "module": "src/genesis/write-tools.ts"
2842
+ "name": "*",
2843
+ "package": "./config"
2844
+ }
2845
+ },
2846
+ {
2847
+ "kind": "js",
2848
+ "name": "*",
2849
+ "declaration": {
2850
+ "name": "*",
2851
+ "package": "./fallback-agents"
2802
2852
  }
2803
2853
  }
2804
2854
  ]
2805
2855
  },
2806
2856
  {
2807
2857
  "kind": "javascript-module",
2808
- "path": "src/genesis/write-turn.ts",
2858
+ "path": "src/config/validate-providers.ts",
2809
2859
  "declarations": [],
2810
2860
  "exports": []
2811
2861
  },
@@ -6685,7 +6735,7 @@
6685
6735
  "type": {
6686
6736
  "text": "Record<MetaEventType, MetaEventImportance>"
6687
6737
  },
6688
- "default": "{\n 'turn.error': 'high',\n 'tool.failed': 'high',\n 'subagent.failed': 'high',\n 'file.read-failed': 'high',\n 'suggestions.failed': 'high',\n 'context.threshold-crossed': 'high',\n 'context.compacted': 'high',\n 'persistence.restore-orphan': 'high',\n // A save that did not land is silent data loss in progress: the transcript on screen\n // is no longer backed by the store, and every later turn widens the gap. GENC-1511.\n 'persistence.save-failed': 'high',\n\n 'assistant.connected': 'normal',\n 'assistant.disconnected': 'normal',\n 'assistant.popout': 'normal',\n 'assistant.popin': 'normal',\n 'driver.created': 'normal',\n 'state.changed': 'normal',\n 'turn.start': 'normal',\n 'turn.end': 'normal',\n 'turn.retry': 'normal',\n 'tool.unresolved': 'normal',\n 'subagent.started': 'normal',\n 'subagent.completed': 'normal',\n // One per routing decision, with what the classifier answered and what the call cost. Same\n // level as the handoff it produces: you read them together to follow how a turn was routed.\n 'routing.decided': 'normal',\n 'agent.handoff': 'normal',\n 'agent.pinned': 'normal',\n 'agent.unpinned': 'normal',\n 'provider.selected': 'normal',\n 'interaction.requested': 'normal',\n 'interaction.resolved': 'normal',\n // Bookkeeping about an already-finished turn; interesting when reconciling a session total.\n 'interaction.external-cost': 'normal',\n // Spend that was billed but could NOT be recorded (the message was trimmed/condensed away, or\n // the value was not real spend). 'high': it is the one way the session total goes quietly\n // wrong, so it must stand out when reconciling.\n 'interaction.external-cost-dropped': 'high',\n 'external-diagnostics.folded': 'normal',\n 'session.cleared': 'normal',\n 'session.switched': 'low',\n 'session.switch-deferred': 'low',\n 'persistence.restored': 'normal',\n 'persistence.suppressed': 'normal',\n 'persistence.not-resumable': 'normal',\n\n 'driver.wired': 'low',\n 'driver.unwired': 'low',\n 'context.updated': 'low',\n 'context.condensed': 'low',\n 'panel.toggled': 'low',\n 'persistence.toggled': 'low',\n 'persistence.saved': 'low',\n 'attachment.added': 'low',\n}",
6738
+ "default": "{\n 'turn.error': 'high',\n 'tool.failed': 'high',\n 'subagent.failed': 'high',\n 'file.read-failed': 'high',\n 'suggestions.failed': 'high',\n 'context.threshold-crossed': 'high',\n 'context.compacted': 'high',\n 'persistence.restore-orphan': 'high',\n // A save that did not land is silent data loss in progress: the transcript on screen\n // is no longer backed by the store, and every later turn widens the gap. GENC-1511.\n 'persistence.save-failed': 'high',\n\n 'assistant.connected': 'normal',\n 'assistant.disconnected': 'normal',\n 'assistant.popout': 'normal',\n 'assistant.popin': 'normal',\n 'driver.created': 'normal',\n 'state.changed': 'normal',\n 'turn.start': 'normal',\n 'turn.end': 'normal',\n 'turn.retry': 'normal',\n 'tool.unresolved': 'normal',\n 'subagent.started': 'normal',\n 'subagent.completed': 'normal',\n // One per routing decision, with what the classifier answered and what the call cost. Same\n // level as the handoff it produces: you read them together to follow how a turn was routed.\n 'routing.decided': 'normal',\n 'agent.handoff': 'normal',\n 'agent.pinned': 'normal',\n 'agent.unpinned': 'normal',\n 'provider.selected': 'normal',\n 'interaction.requested': 'normal',\n 'interaction.resolved': 'normal',\n // Bookkeeping about an already-finished turn; interesting when reconciling a session total.\n 'interaction.external-cost': 'normal',\n // Spend that was billed but could NOT be recorded (the message was trimmed/condensed away, or\n // the value was not real spend). 'high': it is the one way the session total goes quietly\n // wrong, so it must stand out when reconciling.\n 'interaction.external-cost-dropped': 'high',\n // What came of an answer, recorded by the tool that asked (see recordInteractionOutcome).\n 'interaction.outcome': 'normal',\n // An outcome that could not be recorded: the widget goes on showing only the answer.\n 'interaction.outcome-dropped': 'high',\n 'external-diagnostics.folded': 'normal',\n 'session.cleared': 'normal',\n 'session.switched': 'low',\n 'session.switch-deferred': 'low',\n 'persistence.restored': 'normal',\n 'persistence.suppressed': 'normal',\n 'persistence.not-resumable': 'normal',\n\n 'driver.wired': 'low',\n 'driver.unwired': 'low',\n 'context.updated': 'low',\n 'context.condensed': 'low',\n 'panel.toggled': 'low',\n 'persistence.toggled': 'low',\n 'persistence.saved': 'low',\n 'attachment.added': 'low',\n}",
6689
6739
  "description": "Importance is intrinsic to the event *type*, not the instance, so it's\ndefined once here and stamped automatically by recordMetaEvent — call\nsites never pass it. The `Record` is exhaustive: adding a `MetaEventType`\nwithout a level here is a compile error.\n\n- `high` — failures and hard limits you almost always want to see.\n- `normal` — meaningful session flow you read to follow what happened.\n- `low` — frequent UI / bookkeeping noise, usually safe to skip."
6690
6740
  },
6691
6741
  {
@@ -12817,7 +12867,14 @@
12817
12867
  {
12818
12868
  "name": "fn",
12819
12869
  "type": {
12820
- "text": "<T>(componentName: string, data: any, options?: InteractionRequestOptions) => Promise<T>"
12870
+ "text": "InteractionRequester"
12871
+ }
12872
+ },
12873
+ {
12874
+ "name": "recordOutcome",
12875
+ "optional": true,
12876
+ "type": {
12877
+ "text": "(interactionId: string, outcome: unknown) => boolean"
12821
12878
  }
12822
12879
  }
12823
12880
  ],
@@ -12854,6 +12911,13 @@
12854
12911
  "text": "InteractionRequestOptions"
12855
12912
  },
12856
12913
  "description": "Optional per-call overrides, including\n`chatInputDuringExecution` to hide or disable the main chat input while\nthe widget is awaiting user input (reverts when the interaction resolves),\nand `presentation` to control whether the host wraps the widget in a chat\nbubble and/or shows the \"Assistant\" label."
12914
+ },
12915
+ {
12916
+ "name": "onOpened",
12917
+ "optional": true,
12918
+ "type": {
12919
+ "text": "(interactionId: string) => void"
12920
+ }
12857
12921
  }
12858
12922
  ],
12859
12923
  "description": "Request a custom UI interaction. Emits a new message with the interaction.\nTool handlers can call this to pause execution until the user completes the UI interaction.\n\nIf a host requester is wired (sub-agent case), the call delegates upward\nso the interaction lives on the parent — the main UI is only listening to\nthe root driver. Only one interaction may be in flight at any time on a\ngiven root: concurrent calls (e.g. two parallel sub-agents both spawning a\nwidget) throw. Parallel sub-agents are for parallel work, not for user\ninteraction, which is inherently sequential."
@@ -13531,11 +13595,20 @@
13531
13595
  "kind": "field",
13532
13596
  "name": "hostRequester",
13533
13597
  "type": {
13534
- "text": "<T>(\n componentName: string,\n data: any,\n options?: InteractionRequestOptions,\n ) => Promise<T> | undefined"
13598
+ "text": "InteractionRequester | undefined"
13535
13599
  },
13536
13600
  "privacy": "private",
13537
13601
  "description": "When set, `request` delegates to this callback instead of using this controller's own pending\nmap. Wired by `invokeSubAgent` so a sub-agent's widget renders in — and resolves through — the\nparent (ultimately the root) driver, where the main UI is listening."
13538
13602
  },
13603
+ {
13604
+ "kind": "field",
13605
+ "name": "hostOutcome",
13606
+ "type": {
13607
+ "text": "(interactionId: string, outcome: unknown) => boolean | undefined"
13608
+ },
13609
+ "privacy": "private",
13610
+ "description": "Wired with `hostRequester`: an outcome goes where its interaction went."
13611
+ },
13539
13612
  {
13540
13613
  "kind": "method",
13541
13614
  "name": "setHostRequester",
@@ -13548,7 +13621,14 @@
13548
13621
  {
13549
13622
  "name": "fn",
13550
13623
  "type": {
13551
- "text": "<T>(componentName: string, data: any, options?: InteractionRequestOptions) => Promise<T>"
13624
+ "text": "InteractionRequester"
13625
+ }
13626
+ },
13627
+ {
13628
+ "name": "recordOutcome",
13629
+ "optional": true,
13630
+ "type": {
13631
+ "text": "(interactionId: string, outcome: unknown) => boolean"
13552
13632
  }
13553
13633
  }
13554
13634
  ],
@@ -13581,9 +13661,16 @@
13581
13661
  "type": {
13582
13662
  "text": "InteractionRequestOptions"
13583
13663
  }
13664
+ },
13665
+ {
13666
+ "name": "onOpened",
13667
+ "optional": true,
13668
+ "type": {
13669
+ "text": "(interactionId: string) => void"
13670
+ }
13584
13671
  }
13585
13672
  ],
13586
- "description": "See `ChatDriver.requestInteraction`."
13673
+ "description": "See `ChatDriver.requestInteraction`. `onOpened` is told the id of the interaction this call\nopens, wherever it opens it, so the caller can later record its outcome and no other's."
13587
13674
  },
13588
13675
  {
13589
13676
  "kind": "method",
@@ -13633,6 +13720,30 @@
13633
13720
  ],
13634
13721
  "description": "See `ChatDriver.recordExternalCost`.\n\n**Why this exists separately from `resolve`.** A widget's spend reaches the session total only\nthrough `InteractionResult.costUsd`, which is read exactly once — `resolve` does its whole job\nagainst a live pending entry and then deletes it. That is correct for the resolution itself,\nbut it assumes a widget stops costing money when it resolves, and several deliberately do not:\na widget that resolves EARLY so the assistant stops waiting (options shown, a preview\nrendered) may stay interactive for minutes afterwards and do more paid work on the user's\nbehalf. Re-emitting `interaction-completed` does not help — with the interaction gone from the\nmap the call is a silent no-op — so that spend had nowhere to go and was simply missing from\nthe figure shown to the user.\n\nTouches only `externalCostUsd`: the recorded `interaction.resolved` payload is left exactly as\nthe resolution wrote it, because this is not a second resolution and must not read like one."
13635
13722
  },
13723
+ {
13724
+ "kind": "method",
13725
+ "name": "recordOutcome",
13726
+ "return": {
13727
+ "type": {
13728
+ "text": "boolean"
13729
+ }
13730
+ },
13731
+ "parameters": [
13732
+ {
13733
+ "name": "interactionId",
13734
+ "type": {
13735
+ "text": "string"
13736
+ }
13737
+ },
13738
+ {
13739
+ "name": "outcome",
13740
+ "type": {
13741
+ "text": "unknown"
13742
+ }
13743
+ }
13744
+ ],
13745
+ "description": "See `ChatDriver.recordInteractionOutcome`."
13746
+ },
13636
13747
  {
13637
13748
  "kind": "method",
13638
13749
  "name": "context",
@@ -14029,6 +14140,15 @@
14029
14140
  "default": "undefined",
14030
14141
  "description": "The resolved result once the interaction has completed. Forwarded to the rendered component. @internal"
14031
14142
  },
14143
+ {
14144
+ "kind": "field",
14145
+ "name": "outcome",
14146
+ "type": {
14147
+ "text": "unknown"
14148
+ },
14149
+ "default": "undefined",
14150
+ "description": "See `AiChatInteraction`'s resolved `outcome`: recorded after the answer, by the tool."
14151
+ },
14032
14152
  {
14033
14153
  "kind": "field",
14034
14154
  "name": "_resizeObserver",
@@ -14051,6 +14171,22 @@
14051
14171
  "kind": "method",
14052
14172
  "name": "resolvedChanged"
14053
14173
  },
14174
+ {
14175
+ "kind": "method",
14176
+ "name": "outcomeChanged",
14177
+ "description": "An outcome recorded after the answer reaches a widget already showing that answer."
14178
+ },
14179
+ {
14180
+ "kind": "method",
14181
+ "name": "resolvedInteraction",
14182
+ "privacy": "private",
14183
+ "return": {
14184
+ "type": {
14185
+ "text": "AiChatInteraction"
14186
+ }
14187
+ },
14188
+ "description": "The resolved descriptor, with the outcome when one has been recorded."
14189
+ },
14054
14190
  {
14055
14191
  "kind": "method",
14056
14192
  "name": "observeWidgetResize",
@@ -15534,7 +15670,7 @@
15534
15670
  {
15535
15671
  "kind": "variable",
15536
15672
  "name": "WriteReviewStyles",
15537
- "default": "css`\n :host {\n display: block;\n font: inherit;\n\n /* The diff tints — see the diff rules below for why they are backgrounds only. */\n --write-review-added: color-mix(in srgb, var(--success-fill-rest, #2da44e) 18%, transparent);\n --write-review-removed: color-mix(in srgb, var(--error-fill-rest, #cf222e) 18%, transparent);\n }\n\n /*\n * The review mounts inside the chat bubble's dialog content, which is overflow: hidden — so a\n * wide event's columns were CLIPPED rather than pushed off screen, with no scrollbar to say\n * anything was missing. A user approving values they cannot see is the failure this whole\n * component exists to prevent, so the table scrolls within itself.\n */\n .scroller {\n overflow-x: auto;\n max-width: 100%;\n }\n\n table {\n border-collapse: collapse;\n width: 100%;\n }\n\n th,\n td {\n border-bottom: calc(var(--stroke-width, 1) * 1px) solid var(--neutral-stroke-rest);\n padding: calc(var(--design-unit, 4) * 1px) calc(var(--design-unit, 4) * 2px);\n text-align: left;\n }\n\n /* A heading is a column name: kept on one line. */\n th {\n white-space: nowrap;\n }\n\n /*\n * A value is never clipped. Every character stays on screen.\n *\n * Clipping was the first bound, and the wrong one: 24ch with an ellipsis cut the END of every\n * cell, which in a changed cell is the NEW value, so the user approved a value they never saw.\n * No cell is safe to clip either. An insert has no pre-image, so none of its cells is\n * \"changed\", and every one of them is a value being written; a delete's cells are the record\n * being removed; and a title attribute holding the full text reaches nobody on a keyboard or a\n * touch screen.\n *\n * A SHORT value stays whole on one line, and the table scrolls. Wrapping every cell broke a\n * short value mid-token in a squeezed table — \"101.\" over \"2345\" — and the first line could\n * pass for the whole value.\n *\n * A LONG value (review-model marks it) wraps within a bound. With no bound at all, one long\n * value (a NOTE another user wrote) widened its column until the changed one sat out of view,\n * behind a scrollbar an overlay-scrollbar platform does not draw until you scroll.\n */\n td {\n white-space: nowrap;\n }\n\n td.long {\n white-space: normal;\n overflow-wrap: anywhere;\n\n /*\n * A floor as well as a ceiling. With only the ceiling, a squeezed table shrank a long value's\n * column to a sliver (a 100-character note became 22 lines of a few characters each) while\n * the one-line cells kept their width. The table scrolls instead.\n */\n min-width: 20ch;\n max-width: 40ch;\n }\n\n /*\n * The two marks this table carries — \"this field is changing\" and \"this field decides which\n * record disappears\" — were weight, colour and a strike-through only. None of that reaches\n * somebody using a screen reader, who is the one approver with no other way to tell, so each\n * mark has words as well.\n */\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n\n /*\n * A delete shows the whole record and sends its key alone, so the fields that actually decide\n * which record disappears are marked. Not colour alone — an underline carries to a user who\n * cannot distinguish it.\n */\n td.identifying {\n font-weight: 600;\n text-decoration: underline;\n }\n\n /*\n * The diff, the way a code review shows one: what goes is tinted as removed and struck through,\n * what comes in is tinted as added and bold. Only the BACKGROUND is tinted, at low alpha, from\n * the theme's own success and error tokens (with fallbacks, as foundation-forms does), and the\n * text keeps the normal foreground colour: coloured text on a coloured ground is where contrast\n * fails, dark mode first. The tint is never the only signal. Strike-through, weight, the visible\n * + and − marks and the spoken \"was\" and \"now\" all carry the same thing without colour.\n */\n\n /* The mark a user's eye needs: this field is being changed. */\n td.changed {\n font-weight: 600;\n }\n\n /* On its own line above the new value, so neither can push the other out of view. */\n td.changed .was {\n display: block;\n font-weight: 400;\n text-decoration: line-through;\n background: var(--write-review-removed);\n }\n\n td.changed .now {\n display: block;\n background: var(--write-review-added);\n }\n\n /* Room inside the tint, so the − and + do not sit on its edge. */\n td.changed .was,\n td.changed .now {\n padding-inline: calc(var(--design-unit, 4) * 1px);\n }\n\n /*\n * A row that will not be written is never tinted, not even inside a cell. For a refused row\n * review-model already gives it no changed cells, and this is the second guard. For a row the\n * resolved review did not approve, the − and + stay as the record of what was proposed, but\n * without the tint that says it will happen.\n */\n tr.refused td.changed .was,\n tr.refused td.changed .now,\n tr.unwritten td.changed .was,\n tr.unwritten td.changed .now {\n background: none;\n }\n\n /* A whole row coming in, or going. A refused row is neither, and keeps its muted look. */\n tr.added td {\n background: var(--write-review-added);\n }\n\n tr.removed td {\n background: var(--write-review-removed);\n }\n\n /*\n * A closed review's row that was not approved says so in words — without them, a denied modify\n * read in greyscale or by a screen reader exactly like an approved one.\n */\n .not-written {\n margin-inline-start: calc(var(--design-unit, 4) * 1.5px);\n font-size: var(--type-ramp-minus-1-font-size, 0.875em);\n color: var(--neutral-foreground-hint);\n }\n\n /* The empty placeholder: a style no row text can take, so a literal \"(blank)\" cannot pass for it. */\n .blank {\n font-style: italic;\n font-weight: 400;\n color: var(--neutral-foreground-hint);\n }\n\n .mark {\n font-weight: 600;\n padding-inline-end: calc(var(--design-unit, 4) * 1px);\n user-select: none;\n }\n\n /* The row's + or − sits beside its checkbox, not on the baseline under it (where − reads as _). */\n td.select {\n white-space: nowrap;\n }\n\n td.select rapid-checkbox,\n td.select .mark {\n vertical-align: middle;\n }\n\n /* A gap from the checkbox, so the mark reads as the row's sign rather than part of the box. */\n td.select .mark {\n margin-inline-start: calc(var(--design-unit, 4) * 1.5px);\n }\n\n /* The strike-through belongs to the value, not to its − mark. */\n td.changed .was .mark {\n display: inline-block;\n text-decoration: none;\n }\n\n tr.refused {\n color: var(--neutral-foreground-hint);\n }\n\n /* A refusal is a sentence, and it spans the table: it wraps rather than running off it. */\n .problems {\n color: var(--error-fill-rest, #c00);\n white-space: normal;\n }\n\n .actions {\n display: flex;\n gap: calc(var(--design-unit, 4) * 2px);\n margin-top: calc(var(--design-unit, 4) * 2px);\n }\n\n /* The change request takes the width the buttons leave it. */\n .change-request {\n flex: 1 1 24ch;\n }\n\n /* The outcome's live region is always there; while the review is open it takes no room. */\n .closed:empty {\n margin: 0;\n }\n\n /* The count sits at the foot of the field, beside it rather than in its way. */\n .remaining {\n align-self: flex-end;\n white-space: nowrap;\n font-size: var(--type-ramp-minus-1-font-size, 0.875em);\n color: var(--neutral-foreground-hint);\n }\n`"
15673
+ "default": "css`\n :host {\n display: block;\n font: inherit;\n\n /* The diff tints — see the diff rules below for why they are backgrounds only. */\n --write-review-added: color-mix(in srgb, var(--success-fill-rest, #2da44e) 18%, transparent);\n --write-review-removed: color-mix(in srgb, var(--error-fill-rest, #cf222e) 18%, transparent);\n }\n\n /*\n * The review mounts inside the chat bubble's dialog content, which is overflow: hidden — so a\n * wide event's columns were CLIPPED rather than pushed off screen, with no scrollbar to say\n * anything was missing. A user approving values they cannot see is the failure this whole\n * component exists to prevent, so the table scrolls within itself.\n */\n .scroller {\n overflow-x: auto;\n max-width: 100%;\n }\n\n table {\n border-collapse: collapse;\n width: 100%;\n }\n\n th,\n td {\n border-bottom: calc(var(--stroke-width, 1) * 1px) solid var(--neutral-stroke-rest);\n padding: calc(var(--design-unit, 4) * 1px) calc(var(--design-unit, 4) * 2px);\n text-align: left;\n }\n\n /* A heading is a column name: kept on one line. */\n th {\n white-space: nowrap;\n }\n\n /*\n * A value is never clipped. Every character stays on screen.\n *\n * Clipping was the first bound, and the wrong one: 24ch with an ellipsis cut the END of every\n * cell, which in a changed cell is the NEW value, so the user approved a value they never saw.\n * No cell is safe to clip either. An insert has no pre-image, so none of its cells is\n * \"changed\", and every one of them is a value being written; a delete's cells are the record\n * being removed; and a title attribute holding the full text reaches nobody on a keyboard or a\n * touch screen.\n *\n * A SHORT value stays whole on one line, and the table scrolls. Wrapping every cell broke a\n * short value mid-token in a squeezed table — \"101.\" over \"2345\" — and the first line could\n * pass for the whole value.\n *\n * A LONG value (review-model marks it) wraps within a bound. With no bound at all, one long\n * value (a NOTE another user wrote) widened its column until the changed one sat out of view,\n * behind a scrollbar an overlay-scrollbar platform does not draw until you scroll.\n */\n td {\n white-space: nowrap;\n }\n\n td.long {\n white-space: normal;\n overflow-wrap: anywhere;\n\n /*\n * A floor as well as a ceiling. With only the ceiling, a squeezed table shrank a long value's\n * column to a sliver (a 100-character note became 22 lines of a few characters each) while\n * the one-line cells kept their width. The table scrolls instead.\n */\n min-width: 20ch;\n max-width: 40ch;\n }\n\n /*\n * The two marks this table carries — \"this field is changing\" and \"this field decides which\n * record disappears\" — were weight, colour and a strike-through only. None of that reaches\n * somebody using a screen reader, who is the one approver with no other way to tell, so each\n * mark has words as well.\n */\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n\n /*\n * A delete shows the whole record and sends its key alone, so the fields that actually decide\n * which record disappears are marked. Not colour alone — an underline carries to a user who\n * cannot distinguish it.\n */\n td.identifying {\n font-weight: 600;\n text-decoration: underline;\n }\n\n /*\n * The diff, the way a code review shows one: what goes is tinted as removed and struck through,\n * what comes in is tinted as added and bold. Only the BACKGROUND is tinted, at low alpha, from\n * the theme's own success and error tokens (with fallbacks, as foundation-forms does), and the\n * text keeps the normal foreground colour: coloured text on a coloured ground is where contrast\n * fails, dark mode first. The tint is never the only signal. Strike-through, weight, the visible\n * + and − marks and the spoken \"was\" and \"now\" all carry the same thing without colour.\n */\n\n /* The mark a user's eye needs: this field is being changed. */\n td.changed {\n font-weight: 600;\n }\n\n /* On its own line above the new value, so neither can push the other out of view. */\n td.changed .was {\n display: block;\n font-weight: 400;\n text-decoration: line-through;\n background: var(--write-review-removed);\n }\n\n td.changed .now {\n display: block;\n background: var(--write-review-added);\n }\n\n /* Room inside the tint, so the − and + do not sit on its edge. */\n td.changed .was,\n td.changed .now {\n padding-inline: calc(var(--design-unit, 4) * 1px);\n }\n\n /*\n * A row that will not be written is never tinted, not even inside a cell. For a refused row\n * review-model already gives it no changed cells, and this is the second guard. For a row the\n * resolved review did not approve, the − and + stay as the record of what was proposed, but\n * without the tint that says it will happen.\n */\n tr.refused td.changed .was,\n tr.refused td.changed .now,\n tr.unwritten td.changed .was,\n tr.unwritten td.changed .now {\n background: none;\n }\n\n /* A whole row coming in, or going. A refused row is neither, and keeps its muted look. */\n tr.added td {\n background: var(--write-review-added);\n }\n\n tr.removed td {\n background: var(--write-review-removed);\n }\n\n /*\n * A closed review's row that was not approved says so in words — without them, a denied modify\n * read in greyscale or by a screen reader exactly like an approved one. An approved row says what\n * came of it the same way, once the write tool has recorded that (written, not written\n * because the user stopped, or its own reason).\n */\n .not-written,\n .fate {\n margin-inline-start: calc(var(--design-unit, 4) * 1.5px);\n font-size: var(--type-ramp-minus-1-font-size, 0.875em);\n color: var(--neutral-foreground-hint);\n }\n\n /* The empty placeholder: a style no row text can take, so a literal \"(blank)\" cannot pass for it. */\n .blank {\n font-style: italic;\n font-weight: 400;\n color: var(--neutral-foreground-hint);\n }\n\n .mark {\n font-weight: 600;\n padding-inline-end: calc(var(--design-unit, 4) * 1px);\n user-select: none;\n }\n\n /* The row's + or − sits beside its checkbox, not on the baseline under it (where − reads as _). */\n td.select {\n white-space: nowrap;\n }\n\n td.select rapid-checkbox,\n td.select .mark {\n vertical-align: middle;\n }\n\n /* A gap from the checkbox, so the mark reads as the row's sign rather than part of the box. */\n td.select .mark {\n margin-inline-start: calc(var(--design-unit, 4) * 1.5px);\n }\n\n /* The strike-through belongs to the value, not to its − mark. */\n td.changed .was .mark {\n display: inline-block;\n text-decoration: none;\n }\n\n tr.refused {\n color: var(--neutral-foreground-hint);\n }\n\n /* A refusal is a sentence, and it spans the table: it wraps rather than running off it. */\n .problems {\n color: var(--error-fill-rest, #c00);\n white-space: normal;\n }\n\n .actions {\n display: flex;\n gap: calc(var(--design-unit, 4) * 2px);\n margin-top: calc(var(--design-unit, 4) * 2px);\n }\n\n /* The change request takes the width the buttons leave it. */\n .change-request {\n flex: 1 1 24ch;\n }\n\n /* The outcome's live region is always there; while the review is open it takes no room. */\n .closed:empty {\n margin: 0;\n }\n\n /* The count sits at the foot of the field, beside it rather than in its way. */\n .remaining {\n align-self: flex-end;\n white-space: nowrap;\n font-size: var(--type-ramp-minus-1-font-size, 0.875em);\n color: var(--neutral-foreground-hint);\n }\n`"
15538
15674
  }
15539
15675
  ],
15540
15676
  "exports": [
@@ -15558,7 +15694,7 @@
15558
15694
  "type": {
15559
15695
  "text": "ViewTemplate<GenesisWriteReview>"
15560
15696
  },
15561
- "default": "html<GenesisWriteReview>`\n ${when(\n (x) => !!x.model,\n html<GenesisWriteReview>`\n <p>\n ${(x) => x.model?.op} ${(x) => x.model?.rows.length} row(s) in ${(x) => x.model?.resource}.\n Nothing is written until you choose rows and select Write.\n </p>\n <div class=\"scroller\">\n <table aria-label=\"Rows to be written to ${(x) => x.model?.resource}\">\n <thead>\n <tr>\n <th>\n <rapid-checkbox\n aria-label=\"Select all rows\"\n :checked=\"${(x) => x.allSelected}\"\n ?disabled=\"${(x) => x.settled || !x.model?.selectable.length}\"\n @change=\"${(x, c) => x.setAll(checkedOf(c.event))}\"\n ></rapid-checkbox>\n </th>\n ${repeat(\n (x) => x.model?.columns ?? [],\n html<ReviewColumn>`\n <th>${(c) => c.label}</th>\n `,\n )}\n </tr>\n </thead>\n <tbody>${repeat((x) => x.model?.rows ?? [], row)}</tbody>\n </table>\n </div>\n <div class=\"actions\">\n ${when(\n (x) => !x.asking,\n html<GenesisWriteReview>`\n <rapid-button\n appearance=\"accent\"\n ?disabled=\"${(x) => !x.writable}\"\n @click=\"${(x) => x.write()}\"\n >\n Write ${(x) => (x.rowsSelected ? `${x.rowsSelected} row(s)` : '')}\n </rapid-button>\n <rapid-button\n class=\"ask\"\n ?disabled=\"${(x) => x.settled}\"\n @click=\"${(x) => x.startAsking()}\"\n >\n Ask for changes\n </rapid-button>\n <rapid-button ?disabled=\"${(x) => x.settled}\" @click=\"${(x) => x.deny()}\">\n Deny\n </rapid-button>\n `,\n )}\n ${when(\n (x) => x.asking,\n html<GenesisWriteReview>`\n <rapid-text-area\n class=\"change-request\"\n :value=\"${(x) => x.changeText}\"\n ?readonly=\"${(x) => x.settled}\"\n maxlength=\"${() => MAX_FEEDBACK_CHARS}\"\n @input=\"${(x, c) => {\n x.setChangeText((c.event.target as HTMLTextAreaElement).value);\n return true;\n }}\"\n >\n What should change?\n </rapid-text-area>\n <span class=\"remaining\">${(x) => x.charactersLeft} characters left</span>\n <rapid-button\n class=\"send\"\n appearance=\"accent\"\n ?disabled=\"${(x) => !x.canSendChanges}\"\n @click=\"${(x) => x.sendChanges()}\"\n >\n Send\n </rapid-button>\n <rapid-button class=\"back\" ?disabled=\"${(x) => x.settled}\" @click=\"${(x) => x.back()}\">\n Back\n </rapid-button>\n `,\n )}\n </div>\n `,\n )}\n ${\n /* A live region, and there from the start: a screen reader announces a change to one it\n already knows, and a region added with its text already in it was not announced at all.\n Empty while the review is open; filled by sayOutcome, which also decides when. Focusable\n from script only, so focus can land on the outcome after an answer. */ ''\n }\n <p class=\"closed\" role=\"status\" tabindex=\"-1\">${(x) => x.announcement}</p>\n`"
15697
+ "default": "html<GenesisWriteReview>`\n ${when(\n (x) => !!x.model,\n html<GenesisWriteReview>`\n <p>\n ${(x) => x.model?.op} ${(x) => x.model?.rows.length} row(s) in ${(x) => x.model?.resource}.\n Nothing is written until you choose rows and select Write.\n </p>\n ${when(\n (x) => !!x.customCodeLine,\n html<GenesisWriteReview>`\n <p class=\"custom-code\" id=\"${CUSTOM_CODE_LINE_ID}\">${(x) => x.customCodeLine}</p>\n `,\n )}\n <div class=\"scroller\">\n <table\n aria-label=\"Rows to be written to ${(x) => x.model?.resource}\"\n aria-describedby=\"${(x) => (x.customCodeLine ? CUSTOM_CODE_LINE_ID : undefined)}\"\n >\n <thead>\n <tr>\n <th>\n <rapid-checkbox\n aria-label=\"Select all rows\"\n :checked=\"${(x) => x.allSelected}\"\n ?disabled=\"${(x) => x.settled || !x.model?.selectable.length}\"\n @change=\"${(x, c) => x.setAll(checkedOf(c.event))}\"\n ></rapid-checkbox>\n </th>\n ${repeat(\n (x) => x.model?.columns ?? [],\n html<ReviewColumn>`\n <th>${(c) => c.label}</th>\n `,\n )}\n </tr>\n </thead>\n <tbody>${repeat((x) => x.model?.rows ?? [], row)}</tbody>\n </table>\n </div>\n <div class=\"actions\">\n ${when(\n (x) => !x.asking,\n html<GenesisWriteReview>`\n <rapid-button\n appearance=\"accent\"\n ?disabled=\"${(x) => !x.writable}\"\n @click=\"${(x) => x.write()}\"\n >\n Write ${(x) => (x.rowsSelected ? `${x.rowsSelected} row(s)` : '')}\n </rapid-button>\n <rapid-button\n class=\"ask\"\n ?disabled=\"${(x) => x.settled}\"\n @click=\"${(x) => x.startAsking()}\"\n >\n Ask for changes\n </rapid-button>\n <rapid-button ?disabled=\"${(x) => x.settled}\" @click=\"${(x) => x.deny()}\">\n Deny\n </rapid-button>\n `,\n )}\n ${when(\n (x) => x.asking,\n html<GenesisWriteReview>`\n <rapid-text-area\n class=\"change-request\"\n :value=\"${(x) => x.changeText}\"\n ?readonly=\"${(x) => x.settled}\"\n maxlength=\"${() => MAX_FEEDBACK_CHARS}\"\n @input=\"${(x, c) => {\n x.setChangeText((c.event.target as HTMLTextAreaElement).value);\n return true;\n }}\"\n >\n What should change?\n </rapid-text-area>\n <span class=\"remaining\">${(x) => x.charactersLeft} characters left</span>\n <rapid-button\n class=\"send\"\n appearance=\"accent\"\n ?disabled=\"${(x) => !x.canSendChanges}\"\n @click=\"${(x) => x.sendChanges()}\"\n >\n Send\n </rapid-button>\n <rapid-button class=\"back\" ?disabled=\"${(x) => x.settled}\" @click=\"${(x) => x.back()}\">\n Back\n </rapid-button>\n `,\n )}\n </div>\n `,\n )}\n ${\n /* A live region, and there from the start: a screen reader announces a change to one it\n already knows, and a region added with its text already in it was not announced at all.\n Empty while the review is open; filled by sayOutcome, which also decides when. Focusable\n from script only, so focus can land on the outcome after an answer. */ ''\n }\n <p class=\"closed\" role=\"status\" tabindex=\"-1\">${(x) => x.announcement}</p>\n`"
15562
15698
  }
15563
15699
  ],
15564
15700
  "exports": [
@@ -15651,6 +15787,15 @@
15651
15787
  "privacy": "private",
15652
15788
  "description": "This element's own answer, until `sayOutcome` has said it."
15653
15789
  },
15790
+ {
15791
+ "kind": "field",
15792
+ "name": "heldAnswer",
15793
+ "type": {
15794
+ "text": "Answered | undefined"
15795
+ },
15796
+ "privacy": "private",
15797
+ "description": "The answer this element shows while its outcome is still to come, whose `focused` it keeps\ncurrent. The rebuild that brings the outcome gives focus back only if this one held it when\nit was removed: a user who has since moved to the chat input keeps their place."
15798
+ },
15654
15799
  {
15655
15800
  "kind": "field",
15656
15801
  "name": "model",
@@ -15668,6 +15813,15 @@
15668
15813
  },
15669
15814
  "readonly": true
15670
15815
  },
15816
+ {
15817
+ "kind": "field",
15818
+ "name": "customCodeLine",
15819
+ "type": {
15820
+ "text": "string"
15821
+ },
15822
+ "description": "What the review says about custom code the event runs, or `''` when it runs none. Read from\nthe model, which history keeps, so it is there whether the review is open, resolved or\nre-mounted. Not repeated in the closed summary: the resolved review still shows it, and the\nsummary's live region would announce it as though code had run.",
15823
+ "readonly": true
15824
+ },
15671
15825
  {
15672
15826
  "kind": "field",
15673
15827
  "name": "answered",
@@ -15696,6 +15850,33 @@
15696
15850
  "description": "The rows the user approved, once the review has resolved — empty for a rejection or a\ntimeout, and while it is still open.",
15697
15851
  "readonly": true
15698
15852
  },
15853
+ {
15854
+ "kind": "field",
15855
+ "name": "outcome",
15856
+ "type": {
15857
+ "text": "ReviewOutcome | undefined"
15858
+ },
15859
+ "description": "What came of the approved rows, once the write tool has recorded it: see `ReviewOutcome`.\nOnly for an approval — nothing else writes — and only in the shape the review can read.",
15860
+ "readonly": true
15861
+ },
15862
+ {
15863
+ "kind": "method",
15864
+ "name": "fateOf",
15865
+ "return": {
15866
+ "type": {
15867
+ "text": "ReviewOutcome['rows'][number] | undefined"
15868
+ }
15869
+ },
15870
+ "parameters": [
15871
+ {
15872
+ "name": "index",
15873
+ "type": {
15874
+ "text": "number"
15875
+ }
15876
+ }
15877
+ ],
15878
+ "description": "An approved row's recorded fate, when there is one."
15879
+ },
15699
15880
  {
15700
15881
  "kind": "field",
15701
15882
  "name": "closedSummary",