@aparte/core 1.6.0 → 1.7.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 (53) hide show
  1. package/dist/client/stream-adapter.d.ts +20 -0
  2. package/dist/client/stream-adapter.d.ts.map +1 -1
  3. package/dist/client/wire-history.d.ts +2 -0
  4. package/dist/client/wire-history.d.ts.map +1 -1
  5. package/dist/components/bubble/aparte-chat-bubble.d.ts +14 -0
  6. package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
  7. package/dist/components/conversation-list/aparte-conversation-list.d.ts +46 -22
  8. package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
  9. package/dist/components/viewport/aparte-chat-viewport.d.ts +5 -0
  10. package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
  11. package/dist/config/aparte-config.d.ts +44 -1
  12. package/dist/config/aparte-config.d.ts.map +1 -1
  13. package/dist/config/bubble-shell-renderer.d.ts +3 -0
  14. package/dist/config/bubble-shell-renderer.d.ts.map +1 -1
  15. package/dist/config/index.d.ts +1 -1
  16. package/dist/config/index.d.ts.map +1 -1
  17. package/dist/custom-elements.json +721 -69
  18. package/dist/{defer-hydration-W4yhnyfc.js → defer-hydration-o5MFsc_Z.js} +423 -193
  19. package/dist/defer-hydration-o5MFsc_Z.js.map +1 -0
  20. package/dist/elicitation/panel.d.ts.map +1 -1
  21. package/dist/host/aparte-chat-host.d.ts +8 -0
  22. package/dist/host/aparte-chat-host.d.ts.map +1 -1
  23. package/dist/index.css +1 -1
  24. package/dist/index.d.ts +6 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +238 -179
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.node.d.ts +6 -2
  29. package/dist/index.node.d.ts.map +1 -1
  30. package/dist/index.node.js +52 -47
  31. package/dist/index.node.js.map +1 -1
  32. package/dist/kit-keyboard-BUSLQ5i4.js +434 -0
  33. package/dist/kit-keyboard-BUSLQ5i4.js.map +1 -0
  34. package/dist/renderers/segment-renderers.d.ts.map +1 -1
  35. package/dist/renderers/segments/activity.d.ts +5 -0
  36. package/dist/renderers/segments/activity.d.ts.map +1 -0
  37. package/dist/renderers/segments/tool-call.d.ts.map +1 -1
  38. package/dist/types/chat.d.ts +22 -0
  39. package/dist/types/chat.d.ts.map +1 -1
  40. package/dist/types/event-map.d.ts +4 -0
  41. package/dist/types/event-map.d.ts.map +1 -1
  42. package/dist/types/index.d.ts +2 -2
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/segments.d.ts +53 -1
  45. package/dist/types/segments.d.ts.map +1 -1
  46. package/dist/types/tools.d.ts +27 -1
  47. package/dist/types/tools.d.ts.map +1 -1
  48. package/dist/utils/menu.d.ts +90 -0
  49. package/dist/utils/menu.d.ts.map +1 -0
  50. package/dist/utils/tabs.d.ts +49 -0
  51. package/dist/utils/tabs.d.ts.map +1 -0
  52. package/package.json +2 -2
  53. package/dist/defer-hydration-W4yhnyfc.js.map +0 -1
@@ -313,6 +313,22 @@
313
313
  "module": "./types/index.js"
314
314
  }
315
315
  },
316
+ {
317
+ "kind": "js",
318
+ "name": "AparteActivitySegment",
319
+ "declaration": {
320
+ "name": "AparteActivitySegment",
321
+ "module": "./types/index.js"
322
+ }
323
+ },
324
+ {
325
+ "kind": "js",
326
+ "name": "AparteActivityRenderer",
327
+ "declaration": {
328
+ "name": "AparteActivityRenderer",
329
+ "module": "./types/index.js"
330
+ }
331
+ },
316
332
  {
317
333
  "kind": "js",
318
334
  "name": "AparteSegmentBase",
@@ -857,6 +873,14 @@
857
873
  "module": "./types/index.js"
858
874
  }
859
875
  },
876
+ {
877
+ "kind": "js",
878
+ "name": "AparteToolLineOpen",
879
+ "declaration": {
880
+ "name": "AparteToolLineOpen",
881
+ "module": "./types/index.js"
882
+ }
883
+ },
860
884
  {
861
885
  "kind": "js",
862
886
  "name": "AparteToolCallView",
@@ -2033,6 +2057,14 @@
2033
2057
  "module": "./config/index.js"
2034
2058
  }
2035
2059
  },
2060
+ {
2061
+ "kind": "js",
2062
+ "name": "onRenderersChange",
2063
+ "declaration": {
2064
+ "name": "onRenderersChange",
2065
+ "module": "./config/index.js"
2066
+ }
2067
+ },
2036
2068
  {
2037
2069
  "kind": "js",
2038
2070
  "name": "AparteConfigChangeEventDetail",
@@ -2665,6 +2697,70 @@
2665
2697
  "module": "./utils/place-floating.js"
2666
2698
  }
2667
2699
  },
2700
+ {
2701
+ "kind": "js",
2702
+ "name": "enhanceMenu",
2703
+ "declaration": {
2704
+ "name": "enhanceMenu",
2705
+ "module": "./utils/menu.js"
2706
+ }
2707
+ },
2708
+ {
2709
+ "kind": "js",
2710
+ "name": "enhanceContextMenu",
2711
+ "declaration": {
2712
+ "name": "enhanceContextMenu",
2713
+ "module": "./utils/menu.js"
2714
+ }
2715
+ },
2716
+ {
2717
+ "kind": "js",
2718
+ "name": "AparteMenuOptions",
2719
+ "declaration": {
2720
+ "name": "AparteMenuOptions",
2721
+ "module": "./utils/menu.js"
2722
+ }
2723
+ },
2724
+ {
2725
+ "kind": "js",
2726
+ "name": "AparteContextMenuOptions",
2727
+ "declaration": {
2728
+ "name": "AparteContextMenuOptions",
2729
+ "module": "./utils/menu.js"
2730
+ }
2731
+ },
2732
+ {
2733
+ "kind": "js",
2734
+ "name": "AparteMenuSelectDetail",
2735
+ "declaration": {
2736
+ "name": "AparteMenuSelectDetail",
2737
+ "module": "./utils/menu.js"
2738
+ }
2739
+ },
2740
+ {
2741
+ "kind": "js",
2742
+ "name": "enhanceTabs",
2743
+ "declaration": {
2744
+ "name": "enhanceTabs",
2745
+ "module": "./utils/tabs.js"
2746
+ }
2747
+ },
2748
+ {
2749
+ "kind": "js",
2750
+ "name": "AparteTabsOptions",
2751
+ "declaration": {
2752
+ "name": "AparteTabsOptions",
2753
+ "module": "./utils/tabs.js"
2754
+ }
2755
+ },
2756
+ {
2757
+ "kind": "js",
2758
+ "name": "AparteTabChangeDetail",
2759
+ "declaration": {
2760
+ "name": "AparteTabChangeDetail",
2761
+ "module": "./utils/tabs.js"
2762
+ }
2763
+ },
2668
2764
  {
2669
2765
  "kind": "js",
2670
2766
  "name": "uuid",
@@ -3275,6 +3371,22 @@
3275
3371
  "module": "./types/index.js"
3276
3372
  }
3277
3373
  },
3374
+ {
3375
+ "kind": "js",
3376
+ "name": "AparteActivitySegment",
3377
+ "declaration": {
3378
+ "name": "AparteActivitySegment",
3379
+ "module": "./types/index.js"
3380
+ }
3381
+ },
3382
+ {
3383
+ "kind": "js",
3384
+ "name": "AparteActivityRenderer",
3385
+ "declaration": {
3386
+ "name": "AparteActivityRenderer",
3387
+ "module": "./types/index.js"
3388
+ }
3389
+ },
3278
3390
  {
3279
3391
  "kind": "js",
3280
3392
  "name": "AparteSegmentBase",
@@ -3819,6 +3931,14 @@
3819
3931
  "module": "./types/index.js"
3820
3932
  }
3821
3933
  },
3934
+ {
3935
+ "kind": "js",
3936
+ "name": "AparteToolLineOpen",
3937
+ "declaration": {
3938
+ "name": "AparteToolLineOpen",
3939
+ "module": "./types/index.js"
3940
+ }
3941
+ },
3822
3942
  {
3823
3943
  "kind": "js",
3824
3944
  "name": "AparteToolCallView",
@@ -4811,6 +4931,14 @@
4811
4931
  "module": "./config/index.js"
4812
4932
  }
4813
4933
  },
4934
+ {
4935
+ "kind": "js",
4936
+ "name": "onRenderersChange",
4937
+ "declaration": {
4938
+ "name": "onRenderersChange",
4939
+ "module": "./config/index.js"
4940
+ }
4941
+ },
4814
4942
  {
4815
4943
  "kind": "js",
4816
4944
  "name": "AparteConfigChangeEventDetail",
@@ -5291,6 +5419,70 @@
5291
5419
  "module": "./utils/place-floating.js"
5292
5420
  }
5293
5421
  },
5422
+ {
5423
+ "kind": "js",
5424
+ "name": "enhanceMenu",
5425
+ "declaration": {
5426
+ "name": "enhanceMenu",
5427
+ "module": "./utils/menu.js"
5428
+ }
5429
+ },
5430
+ {
5431
+ "kind": "js",
5432
+ "name": "enhanceContextMenu",
5433
+ "declaration": {
5434
+ "name": "enhanceContextMenu",
5435
+ "module": "./utils/menu.js"
5436
+ }
5437
+ },
5438
+ {
5439
+ "kind": "js",
5440
+ "name": "AparteMenuOptions",
5441
+ "declaration": {
5442
+ "name": "AparteMenuOptions",
5443
+ "module": "./utils/menu.js"
5444
+ }
5445
+ },
5446
+ {
5447
+ "kind": "js",
5448
+ "name": "AparteContextMenuOptions",
5449
+ "declaration": {
5450
+ "name": "AparteContextMenuOptions",
5451
+ "module": "./utils/menu.js"
5452
+ }
5453
+ },
5454
+ {
5455
+ "kind": "js",
5456
+ "name": "AparteMenuSelectDetail",
5457
+ "declaration": {
5458
+ "name": "AparteMenuSelectDetail",
5459
+ "module": "./utils/menu.js"
5460
+ }
5461
+ },
5462
+ {
5463
+ "kind": "js",
5464
+ "name": "enhanceTabs",
5465
+ "declaration": {
5466
+ "name": "enhanceTabs",
5467
+ "module": "./utils/tabs.js"
5468
+ }
5469
+ },
5470
+ {
5471
+ "kind": "js",
5472
+ "name": "AparteTabsOptions",
5473
+ "declaration": {
5474
+ "name": "AparteTabsOptions",
5475
+ "module": "./utils/tabs.js"
5476
+ }
5477
+ },
5478
+ {
5479
+ "kind": "js",
5480
+ "name": "AparteTabChangeDetail",
5481
+ "declaration": {
5482
+ "name": "AparteTabChangeDetail",
5483
+ "module": "./utils/tabs.js"
5484
+ }
5485
+ },
5294
5486
  {
5295
5487
  "kind": "js",
5296
5488
  "name": "uuid",
@@ -7225,6 +7417,11 @@
7225
7417
  ],
7226
7418
  "description": "Build the event → DOM adapter for one streamed message. Returns a synchronous\nAparteStreamRunEmitter to hand to `runStreamAgent` as its `emitter`.\nReproduces the inline loop's `targetElement.*` call sequence exactly (validated\nby the engine parity test against the real loop)."
7227
7419
  },
7420
+ {
7421
+ "kind": "variable",
7422
+ "name": "id",
7423
+ "default": "`tool-${toolCallId}`"
7424
+ },
7228
7425
  {
7229
7426
  "kind": "function",
7230
7427
  "name": "readableToAsyncIterable",
@@ -7443,7 +7640,7 @@
7443
7640
  }
7444
7641
  }
7445
7642
  ],
7446
- "description": "Segments → the text a model can read back.\n\nFences and the language tag are kept. Without them the model re-reads its own\ncode as prose — which is how it starts explaining a snippet it believes it\nwrote in English.\n\nA type core does not know — a registered block grammar's (an artifact, a\ncitation, a file), a consumer's custom segment — follows one rule: its\n`content` if it has one, else its `fallback`, else nothing. Dropping such a\nsegment would make a document the model had just produced invisible on the very\nnext turn, so it could not be asked to change the thing it had built. An artifact\nis a plugin's type like any other and follows this rule. Such a segment may also say\nwhat goes around its content (`wire`): the tag a grammar read it from, with the id the\nmodel needs to name it again.\n\n`thinking` and `tool_call` stay out on purpose — the first is the model's own\nscratchpad, and most APIs neither want it back nor bill for it kindly; the\nsecond is not text: `wireMessages` sends a reply's calls as the assistant's\n`toolCalls` and the `tool` messages answering them (`wireTurns`)."
7643
+ "description": "Segments → the text a model can read back.\n\nFences and the language tag are kept. Without them the model re-reads its own\ncode as prose — which is how it starts explaining a snippet it believes it\nwrote in English.\n\nA type core does not know — a registered block grammar's (an artifact, a\ncitation, a file), a consumer's custom segment — follows one rule: its\n`content` if it has one, else its `fallback`, else nothing. Dropping such a\nsegment would make a document the model had just produced invisible on the very\nnext turn, so it could not be asked to change the thing it had built. An artifact\nis a plugin's type like any other and follows this rule. Such a segment may also say\nwhat goes around its content (`wire`): the tag a grammar read it from, with the id the\nmodel needs to name it again.\n\n`activity` stays out too: it is progress shown to a person, and its content the agent's data.\n\n`thinking` and `tool_call` stay out on purpose — the first is the model's own\nscratchpad, and most APIs neither want it back nor bill for it kindly; the\nsecond is not text: `wireMessages` sends a reply's calls as the assistant's\n`toolCalls` and the `tool` messages answering them (`wireTurns`)."
7447
7644
  },
7448
7645
  {
7449
7646
  "kind": "function",
@@ -8016,7 +8213,8 @@
8016
8213
  "text": "(cfg: AparteConfig) => void"
8017
8214
  }
8018
8215
  }
8019
- ]
8216
+ ],
8217
+ "description": "Hear when a segment, tool or activity renderer is registered, overridden or taken off, with\nthe config it changed on — once per config per microtask, however many changed. Returns the\nfunction that stops listening.\n\nFor a row loop written outside `<aparte-chat-bubble>` (a sub-agent's conversation, a panel\nthat draws segments): the bubble redraws the rows whose renderer changed, and a loop of\nyour own does the same from here. Not called for any other change of the config."
8020
8218
  },
8021
8219
  {
8022
8220
  "kind": "function",
@@ -8405,6 +8603,13 @@
8405
8603
  "privacy": "private",
8406
8604
  "default": "new ToolTable<AparteToolDisplay>()"
8407
8605
  },
8606
+ {
8607
+ "kind": "field",
8608
+ "name": "_activityRenderers",
8609
+ "privacy": "private",
8610
+ "default": "new Map<string, AparteActivityRenderer>()",
8611
+ "description": "By activity type — see registerActivityRenderer."
8612
+ },
8408
8613
  {
8409
8614
  "kind": "field",
8410
8615
  "name": "_toolLineProvider",
@@ -10065,6 +10270,51 @@
10065
10270
  ],
10066
10271
  "description": "Unregister the renderer registered under this matcher. Calls on screen it drew go back to core's row."
10067
10272
  },
10273
+ {
10274
+ "kind": "method",
10275
+ "name": "registerActivityRenderer",
10276
+ "return": {
10277
+ "type": {
10278
+ "text": "() => void"
10279
+ }
10280
+ },
10281
+ "parameters": [
10282
+ {
10283
+ "name": "activityType",
10284
+ "type": {
10285
+ "text": "string"
10286
+ }
10287
+ },
10288
+ {
10289
+ "name": "renderer",
10290
+ "type": {
10291
+ "text": "AparteActivityRenderer"
10292
+ }
10293
+ }
10294
+ ],
10295
+ "description": "Draw one type of agent activity — the structured progress an agent reports while it\nworks (\"3 of 5 sources read\"), which reaches the reply as an `activity` segment and is\nupdated in place each time the agent sends it again. Returns the function that takes\nthis renderer off again (it changes nothing once another one has replaced it).\n\nAn activity with no renderer for its type is kept on the message and draws nothing:\nno row, no room, no orphan header on a turn that holds nothing else. It is never sent\nto the model either way. Activities already on screen follow a registration.",
10296
+ "examples": [
10297
+ "const off = aparteGlobalConfig.registerActivityRenderer('search-progress', {\n render: (segment) => {\n const el = document.createElement('p');\n const { read, of } = segment.content as { read: number; of: number };\n el.textContent = `${read} of ${of} sources read`;\n return el;\n },\n update: (el, segment) => {\n const { read, of } = segment.content as { read: number; of: number };\n el.textContent = `${read} of ${of} sources read`;\n },\n});"
10298
+ ]
10299
+ },
10300
+ {
10301
+ "kind": "method",
10302
+ "name": "getActivityRenderer",
10303
+ "return": {
10304
+ "type": {
10305
+ "text": "AparteActivityRenderer | undefined"
10306
+ }
10307
+ },
10308
+ "parameters": [
10309
+ {
10310
+ "name": "activityType",
10311
+ "type": {
10312
+ "text": "string"
10313
+ }
10314
+ }
10315
+ ],
10316
+ "description": "The renderer registered for an activity type, or undefined."
10317
+ },
10068
10318
  {
10069
10319
  "kind": "method",
10070
10320
  "name": "getToolRenderer",
@@ -11445,6 +11695,14 @@
11445
11695
  "module": "./aparte-config.js"
11446
11696
  }
11447
11697
  },
11698
+ {
11699
+ "kind": "js",
11700
+ "name": "onRenderersChange",
11701
+ "declaration": {
11702
+ "name": "onRenderersChange",
11703
+ "module": "./aparte-config.js"
11704
+ }
11705
+ },
11448
11706
  {
11449
11707
  "kind": "js",
11450
11708
  "name": "resolveConfig",
@@ -14546,6 +14804,16 @@
14546
14804
  "default": "null",
14547
14805
  "description": "Id of the assistant message currently streaming (null when idle)."
14548
14806
  },
14807
+ {
14808
+ "kind": "field",
14809
+ "name": "_step",
14810
+ "type": {
14811
+ "text": "{ messageId: string; name: string } | null"
14812
+ },
14813
+ "privacy": "private",
14814
+ "default": "null",
14815
+ "description": "The step the streaming reply is on: kept until its bubble is painted, never in the list."
14816
+ },
14549
14817
  {
14550
14818
  "kind": "field",
14551
14819
  "name": "_renderedIds",
@@ -14877,6 +15145,30 @@
14877
15145
  ],
14878
15146
  "description": "Atomic partial update of a message by id."
14879
15147
  },
15148
+ {
15149
+ "kind": "method",
15150
+ "name": "setStep",
15151
+ "return": {
15152
+ "type": {
15153
+ "text": "void"
15154
+ }
15155
+ },
15156
+ "parameters": [
15157
+ {
15158
+ "name": "messageId",
15159
+ "type": {
15160
+ "text": "string"
15161
+ }
15162
+ },
15163
+ {
15164
+ "name": "name",
15165
+ "type": {
15166
+ "text": "string | null"
15167
+ }
15168
+ }
15169
+ ],
15170
+ "description": "Say the step the agent is on in the reply's waiting indicator, or `null` for none. Live\nonly: never written into the message list. Kept for a bubble the framework has not\npainted yet, and given to it when it is."
15171
+ },
14880
15172
  {
14881
15173
  "kind": "method",
14882
15174
  "name": "updateLastMessage",
@@ -20346,6 +20638,22 @@
20346
20638
  "module": "./segments.js"
20347
20639
  }
20348
20640
  },
20641
+ {
20642
+ "kind": "js",
20643
+ "name": "AparteActivitySegment",
20644
+ "declaration": {
20645
+ "name": "AparteActivitySegment",
20646
+ "module": "./segments.js"
20647
+ }
20648
+ },
20649
+ {
20650
+ "kind": "js",
20651
+ "name": "AparteActivityRenderer",
20652
+ "declaration": {
20653
+ "name": "AparteActivityRenderer",
20654
+ "module": "./segments.js"
20655
+ }
20656
+ },
20349
20657
  {
20350
20658
  "kind": "js",
20351
20659
  "name": "AparteSegmentType",
@@ -20666,6 +20974,14 @@
20666
20974
  "module": "./tools.js"
20667
20975
  }
20668
20976
  },
20977
+ {
20978
+ "kind": "js",
20979
+ "name": "AparteToolLineOpen",
20980
+ "declaration": {
20981
+ "name": "AparteToolLineOpen",
20982
+ "module": "./tools.js"
20983
+ }
20984
+ },
20669
20985
  {
20670
20986
  "kind": "js",
20671
20987
  "name": "AparteToolCallView",
@@ -21631,6 +21947,171 @@
21631
21947
  }
21632
21948
  ]
21633
21949
  },
21950
+ {
21951
+ "kind": "javascript-module",
21952
+ "path": "src/utils/menu.ts",
21953
+ "declarations": [
21954
+ {
21955
+ "kind": "function",
21956
+ "name": "usableIn",
21957
+ "return": {
21958
+ "type": {
21959
+ "text": "boolean"
21960
+ }
21961
+ },
21962
+ "parameters": [
21963
+ {
21964
+ "name": "el",
21965
+ "type": {
21966
+ "text": "HTMLElement"
21967
+ }
21968
+ },
21969
+ {
21970
+ "name": "root",
21971
+ "type": {
21972
+ "text": "HTMLElement"
21973
+ }
21974
+ }
21975
+ ],
21976
+ "description": "An item a reader can reach: not `disabled`, not `aria-disabled`, not hidden."
21977
+ },
21978
+ {
21979
+ "kind": "function",
21980
+ "name": "onPress",
21981
+ "return": {
21982
+ "type": {
21983
+ "text": "void"
21984
+ }
21985
+ },
21986
+ "parameters": [
21987
+ {
21988
+ "name": "e",
21989
+ "type": {
21990
+ "text": "Event"
21991
+ }
21992
+ }
21993
+ ]
21994
+ },
21995
+ {
21996
+ "kind": "function",
21997
+ "name": "onRelease",
21998
+ "return": {
21999
+ "type": {
22000
+ "text": "void"
22001
+ }
22002
+ }
22003
+ },
22004
+ {
22005
+ "kind": "function",
22006
+ "name": "onScroll",
22007
+ "return": {
22008
+ "type": {
22009
+ "text": "void"
22010
+ }
22011
+ },
22012
+ "parameters": [
22013
+ {
22014
+ "name": "e",
22015
+ "type": {
22016
+ "text": "Event"
22017
+ }
22018
+ }
22019
+ ]
22020
+ },
22021
+ {
22022
+ "kind": "function",
22023
+ "name": "enhanceMenu",
22024
+ "return": {
22025
+ "type": {
22026
+ "text": "() => void"
22027
+ }
22028
+ },
22029
+ "parameters": [
22030
+ {
22031
+ "name": "trigger",
22032
+ "type": {
22033
+ "text": "HTMLElement"
22034
+ }
22035
+ },
22036
+ {
22037
+ "name": "menu",
22038
+ "type": {
22039
+ "text": "HTMLElement"
22040
+ }
22041
+ },
22042
+ {
22043
+ "name": "options",
22044
+ "default": "{}",
22045
+ "type": {
22046
+ "text": "AparteMenuOptions"
22047
+ }
22048
+ }
22049
+ ],
22050
+ "description": "Drives a menu drawn with the kit (`.aparte-menu`, `role=\"menuitem\"` items) from the button\nthat opens it, the way the WAI-ARIA menu button pattern asks, and returns the function that\nstops it.\n\nThe button opens it on a click (so Enter and Space, which click a button), ArrowDown (on the\nfirst item) and ArrowUp (on the last). Inside, the arrows move and wrap round, Home and End\njump to the ends, and a letter moves to the next item that starts with it; an item that is\n`disabled`, `aria-disabled=\"true\"` or hidden is passed over. Escape closes it and puts the\nfocus back on the button; Tab closes it and moves on from the button. A press outside, the\nfocus leaving or a resize close it, and so does a scroll that moves the button (the page, a\nlist it is in) — not one beside it, such as a reply streaming in. One menu is open at a time.\n\nChoosing an item fires `aparte-menu-select` on the menu with `{ item }`, then closes it and\nputs the focus back. A `menuitemcheckbox` or `menuitemradio` is not ticked for you: set its\n`aria-checked` in that listener. `preventDefault()` on the event keeps the menu open.\n\nThe menu is shown and hidden with `hidden`, and placed with `placeFloating` against the\nbutton, fixed to the window. To open or close it from code, call `trigger.click()`.\n\nTouches no DOM until it is called, so it can be imported on a server."
22051
+ },
22052
+ {
22053
+ "kind": "function",
22054
+ "name": "enhanceContextMenu",
22055
+ "return": {
22056
+ "type": {
22057
+ "text": "() => void"
22058
+ }
22059
+ },
22060
+ "parameters": [
22061
+ {
22062
+ "name": "region",
22063
+ "type": {
22064
+ "text": "HTMLElement"
22065
+ }
22066
+ },
22067
+ {
22068
+ "name": "menu",
22069
+ "type": {
22070
+ "text": "HTMLElement"
22071
+ }
22072
+ },
22073
+ {
22074
+ "name": "options",
22075
+ "default": "{}",
22076
+ "type": {
22077
+ "text": "AparteContextMenuOptions"
22078
+ }
22079
+ }
22080
+ ],
22081
+ "description": "The same menu as `enhanceMenu`, opened by a right click, Shift+F10 or the Menu key inside\n`region` — at the pointer for a click, under the focused element for a key — and returns\nthe function that stops it. One menu serves the whole region: `onOpen(target)` says which\nelement it was asked about, so the menu can be filled for that row.\n\nInside, it behaves as `enhanceMenu`'s does: the same keys, the same `aparte-menu-select`,\nthe same ways to close. Escape puts the focus back on the element that had it."
22082
+ },
22083
+ {
22084
+ "kind": "variable",
22085
+ "name": "back"
22086
+ }
22087
+ ],
22088
+ "exports": [
22089
+ {
22090
+ "kind": "js",
22091
+ "name": "usableIn",
22092
+ "declaration": {
22093
+ "name": "usableIn",
22094
+ "module": "src/utils/menu.ts"
22095
+ }
22096
+ },
22097
+ {
22098
+ "kind": "js",
22099
+ "name": "enhanceMenu",
22100
+ "declaration": {
22101
+ "name": "enhanceMenu",
22102
+ "module": "src/utils/menu.ts"
22103
+ }
22104
+ },
22105
+ {
22106
+ "kind": "js",
22107
+ "name": "enhanceContextMenu",
22108
+ "declaration": {
22109
+ "name": "enhanceContextMenu",
22110
+ "module": "src/utils/menu.ts"
22111
+ }
22112
+ }
22113
+ ]
22114
+ },
21634
22115
  {
21635
22116
  "kind": "javascript-module",
21636
22117
  "path": "src/utils/ndjson.ts",
@@ -22261,6 +22742,47 @@
22261
22742
  }
22262
22743
  ]
22263
22744
  },
22745
+ {
22746
+ "kind": "javascript-module",
22747
+ "path": "src/utils/tabs.ts",
22748
+ "declarations": [
22749
+ {
22750
+ "kind": "function",
22751
+ "name": "enhanceTabs",
22752
+ "return": {
22753
+ "type": {
22754
+ "text": "() => void"
22755
+ }
22756
+ },
22757
+ "parameters": [
22758
+ {
22759
+ "name": "tablist",
22760
+ "type": {
22761
+ "text": "HTMLElement"
22762
+ }
22763
+ },
22764
+ {
22765
+ "name": "options",
22766
+ "default": "{}",
22767
+ "type": {
22768
+ "text": "AparteTabsOptions"
22769
+ }
22770
+ }
22771
+ ],
22772
+ "description": "Drives a row of tabs drawn with the kit (`role=\"tablist\"`, `role=\"tab\"` buttons with\n`aria-controls`), the way the WAI-ARIA tabs pattern asks, and returns the function that\nstops it.\n\nThe row is one tab stop: the selected tab has `tabindex=\"0\"`, the others `-1`. ArrowRight\nand ArrowLeft move to the next and the previous tab and wrap round — the other way round in\na right-to-left row — or ArrowDown and ArrowUp when the list says\n`aria-orientation=\"vertical\"`. Home and End go to the ends. A tab that is `disabled`,\n`aria-disabled=\"true\"` or hidden is passed over. A click selects too.\n\nSelecting sets `aria-selected`, moves the tab stop, shows the panel the tab's\n`aria-controls` names and puts `hidden` on the others. `aparte-tab-change` fires on the\ntablist just before, with `{ tab, panel, previous }`; `preventDefault()` keeps the current\ntab. To select a tab from code, call its `click()`.\n\nWith nothing marked `aria-selected=\"true\"`, the first tab that can be used is selected.\nTouches no DOM until it is called, so it can be imported on a server."
22773
+ }
22774
+ ],
22775
+ "exports": [
22776
+ {
22777
+ "kind": "js",
22778
+ "name": "enhanceTabs",
22779
+ "declaration": {
22780
+ "name": "enhanceTabs",
22781
+ "module": "src/utils/tabs.ts"
22782
+ }
22783
+ }
22784
+ ]
22785
+ },
22264
22786
  {
22265
22787
  "kind": "javascript-module",
22266
22788
  "path": "src/utils/tool-input.ts",
@@ -22958,6 +23480,16 @@
22958
23480
  "privacy": "private",
22959
23481
  "default": "null"
22960
23482
  },
23483
+ {
23484
+ "kind": "field",
23485
+ "name": "_step",
23486
+ "type": {
23487
+ "text": "string | null"
23488
+ },
23489
+ "privacy": "private",
23490
+ "default": "null",
23491
+ "description": "The step the agent is on while this reply waits: live only, never part of the message."
23492
+ },
22961
23493
  {
22962
23494
  "kind": "field",
22963
23495
  "name": "_finishReason",
@@ -23221,6 +23753,25 @@
23221
23753
  ],
23222
23754
  "description": "The tool renderer in effect for a call: none for a hidden call or another segment."
23223
23755
  },
23756
+ {
23757
+ "kind": "method",
23758
+ "name": "_innerRendererFor",
23759
+ "privacy": "private",
23760
+ "return": {
23761
+ "type": {
23762
+ "text": "AparteToolRenderer | AparteActivityRenderer | null"
23763
+ }
23764
+ },
23765
+ "parameters": [
23766
+ {
23767
+ "name": "segment",
23768
+ "type": {
23769
+ "text": "AparteSegment"
23770
+ }
23771
+ }
23772
+ ],
23773
+ "description": "The tool or activity renderer in effect for a segment, when core's own renderer for its type is what draws it."
23774
+ },
23224
23775
  {
23225
23776
  "kind": "method",
23226
23777
  "name": "_install",
@@ -23783,6 +24334,24 @@
23783
24334
  ],
23784
24335
  "description": "Set token usage + timing for this message (assistant only).\n\nThis is the *precondition* for the info (\"i\") action, not the trigger: the\nbutton appears only if the app also declared it wants it —\n`aparteGlobalConfig.setBubbleActions({ info: true })` — because the stats popover it\nopens (`aparte-message-info`) is the app's, and core has none. Without usage\nthere is nothing to show, so the button never renders either way."
23785
24336
  },
24337
+ {
24338
+ "kind": "method",
24339
+ "name": "setStep",
24340
+ "return": {
24341
+ "type": {
24342
+ "text": "void"
24343
+ }
24344
+ },
24345
+ "parameters": [
24346
+ {
24347
+ "name": "name",
24348
+ "type": {
24349
+ "text": "string | null"
24350
+ }
24351
+ }
24352
+ ],
24353
+ "description": "Say the step the agent is on (\"Reading the parser\") while this reply waits, or `null`\nwhen it is on none. The client calls it as the run announces steps.\n\nLive only: the words show beside the waiting dots while the reply has nothing to show\n(or between two calls), and are what a screen reader hears in place of \"Typing\". They\nare never one of the message's segments, never saved and never sent to the model, and\nthey go with the reply's end even when nobody closed the step."
24354
+ },
23786
24355
  {
23787
24356
  "kind": "method",
23788
24357
  "name": "setFinishReason",
@@ -28979,7 +29548,7 @@
28979
29548
  "declarations": [
28980
29549
  {
28981
29550
  "kind": "class",
28982
- "description": "Conversation-history sidebar — a framework-agnostic web component. The host sets\nthe `conversations` JS property and the `active-id` attribute; this renders the\nrows and fires the user's intent. Acting on it is the host's, unless `manage` hands\nthe row menu's writes to the registered conversation manager.\n\nA row is two real buttons: the title, which selects, and a `⋯` that opens the row's\nmenu — rename, pin or unpin, archive or unarchive, delete. Every item fires an event\nand stops; the one exception is delete, which asks first, inline in the menu,\nbecause it is the one action the host cannot undo. Rename swaps the title for an\ninput: Enter or leaving the field commits, Escape cancels, and an unchanged or\nemptied title fires nothing. The rows are grouped by date — Pinned, Today,\nYesterday, Previous 7 days, Previous 30 days, then one heading per month — as soon\nas any item carries `updatedAt`; set `flat` to render them flat.\n\nChildren are not a composition point: `_render()` assigns `innerHTML` from the\n`conversations` array, so any light-DOM child a host writes inside the element is\ndiscarded the next time the list renders — and switching this element's locale is\nenough to trigger one. Compose around the element, not inside it: it renders rows\nand nothing else, with no header, no new-conversation button and no search field.\n\nWhat it is not: a store. Selecting, renaming, pinning, archiving and deleting all\nleave the array untouched — the events carry an id (and, for rename, the title) and\nstop. Set `manage` and the menu's write gestures are carried out on the conversation\nmanager you registered, so you do not write those six listeners; the\nevent still goes out first and `preventDefault()` takes the gesture back. The array\nis still not this element's: the manager's own change is what re-renders it.\nA row's text comes from the array, so it changes when the host assigns\n`conversations` again; the exception is an empty title, which falls back to the\nlocale's new-chat label and therefore follows a locale switch. An archived item is\nstill rendered (it gains `aparte-conv-item--archived`); filtering archived\nconversations out of the list is the host's decision, not this element's. The\nasymmetry between the two inputs is deliberate: `active-id` is an attribute because\nmoving the selection patches the rendered rows in place, while `conversations` is a\nJS property because it is structured data an attribute cannot carry, and setting it\nre-renders the whole list.",
29551
+ "description": "Conversation-history sidebar — a framework-agnostic web component. The host sets\nthe `conversations` JS property and the `active-id` attribute; this renders the\nrows and fires the user's intent. Acting on it is the host's, unless `manage` hands\nthe row menu's writes to the registered conversation manager.\n\nA row is two real buttons: the title, which selects, and a `⋯` that opens the row's\nmenu — rename, pin or unpin, archive or unarchive, delete. A right click on a row,\nShift+F10 or the Menu key opens the same menu there. Every item fires an event\nand stops; the one exception is delete, which asks first, inline in the menu,\nbecause it is the one action the host cannot undo. Rename swaps the title for an\ninput: Enter or leaving the field commits, Escape cancels, and an unchanged or\nemptied title fires nothing. The rows are grouped by date — Pinned, Today,\nYesterday, Previous 7 days, Previous 30 days, then one heading per month — as soon\nas any item carries `updatedAt`; set `flat` to render them flat.\n\nChildren are not a composition point: `_render()` assigns `innerHTML` from the\n`conversations` array, so any light-DOM child a host writes inside the element is\ndiscarded the next time the list renders — and switching this element's locale is\nenough to trigger one. Compose around the element, not inside it: it renders rows\nand nothing else, with no header, no new-conversation button and no search field.\n\nWhat it is not: a store. Selecting, renaming, pinning, archiving and deleting all\nleave the array untouched — the events carry an id (and, for rename, the title) and\nstop. Set `manage` and the menu's write gestures are carried out on the conversation\nmanager you registered, so you do not write those six listeners; the\nevent still goes out first and `preventDefault()` takes the gesture back. The array\nis still not this element's: the manager's own change is what re-renders it.\nA row's text comes from the array, so it changes when the host assigns\n`conversations` again; the exception is an empty title, which falls back to the\nlocale's new-chat label and therefore follows a locale switch. An archived item is\nstill rendered (it gains `aparte-conv-item--archived`); filtering archived\nconversations out of the list is the host's decision, not this element's. The\nasymmetry between the two inputs is deliberate: `active-id` is an attribute because\nmoving the selection patches the rendered rows in place, while `conversations` is a\nJS property because it is structured data an attribute cannot carry, and setting it\nre-renders the whole list.",
28983
29552
  "name": "AparteConversationList",
28984
29553
  "cssProperties": [
28985
29554
  {
@@ -29059,12 +29628,23 @@
29059
29628
  },
29060
29629
  {
29061
29630
  "kind": "field",
29062
- "name": "_open",
29631
+ "name": "_menus",
29063
29632
  "type": {
29064
- "text": "OpenMenu | null"
29633
+ "text": "Array<() => void>"
29065
29634
  },
29066
29635
  "privacy": "private",
29067
- "default": "null"
29636
+ "default": "[]",
29637
+ "description": "What stops the menus of the rows on screen: one `enhanceMenu` per `⋯`, and the\ncontext menu over the whole list. A render replaces the rows, so it releases them\nall and wires the new ones."
29638
+ },
29639
+ {
29640
+ "kind": "field",
29641
+ "name": "_contextMenu",
29642
+ "type": {
29643
+ "text": "HTMLElement | null"
29644
+ },
29645
+ "privacy": "private",
29646
+ "default": "null",
29647
+ "description": "The context menu's element: one for the list, filled for the row it was asked about."
29068
29648
  },
29069
29649
  {
29070
29650
  "kind": "field",
@@ -29415,40 +29995,27 @@
29415
29995
  },
29416
29996
  {
29417
29997
  "kind": "method",
29418
- "name": "_openMenu",
29998
+ "name": "_newMenu",
29419
29999
  "privacy": "private",
29420
30000
  "return": {
29421
30001
  "type": {
29422
- "text": "void"
30002
+ "text": "HTMLElement"
29423
30003
  }
29424
30004
  },
29425
- "parameters": [
29426
- {
29427
- "name": "row",
29428
- "type": {
29429
- "text": "HTMLElement"
29430
- }
29431
- },
29432
- {
29433
- "name": "button",
29434
- "type": {
29435
- "text": "HTMLElement"
29436
- }
29437
- }
29438
- ]
30005
+ "description": "A row menu's element, empty: `_fillMenu` gives it its items as it opens."
29439
30006
  },
29440
30007
  {
29441
30008
  "kind": "method",
29442
- "name": "_placeMenu",
30009
+ "name": "_fillMenu",
29443
30010
  "privacy": "private",
29444
30011
  "return": {
29445
30012
  "type": {
29446
- "text": "void"
30013
+ "text": "boolean"
29447
30014
  }
29448
30015
  },
29449
30016
  "parameters": [
29450
30017
  {
29451
- "name": "button",
30018
+ "name": "row",
29452
30019
  "type": {
29453
30020
  "text": "HTMLElement"
29454
30021
  }
@@ -29460,53 +30027,60 @@
29460
30027
  }
29461
30028
  }
29462
30029
  ],
29463
- "description": "Fixed, below the button's end edge, flipped above it when the viewport ends\nfirst. Fixed rather than absolute because a sidebar scrolls: an absolute menu on\nthe last rows would be clipped by the list's own overflow. No anchoring library —\nthe menu closes on any scroll or resize, which is what makes the arithmetic\nsafe to do once."
30030
+ "description": "Fills `menu` for the row's conversation and puts it in the row, as it opens; it leaves\nthe row when it closes, so a list with no menu open holds none. `enhanceMenu` places it\nfixed to the window, because a sidebar scrolls and an absolute menu on the last rows\nwould be clipped by the list's own overflow. False — stay closed — when the\nconversation is gone."
29464
30031
  },
29465
30032
  {
29466
30033
  "kind": "method",
29467
- "name": "_closeMenu",
30034
+ "name": "_wireMenus",
29468
30035
  "privacy": "private",
29469
30036
  "return": {
29470
30037
  "type": {
29471
30038
  "text": "void"
29472
30039
  }
29473
30040
  },
29474
- "parameters": [
29475
- {
29476
- "name": "returnFocus",
29477
- "default": "false"
29478
- }
29479
- ]
30041
+ "description": "The keyboard, the closing and the placing are `enhanceMenu`'s, the same code the kit\ngives a host for its own menus: each row's `⋯` drives its own menu, and a right\nclick, Shift+F10 or the Menu key on a row opens one shared menu there\n(`enhanceContextMenu`). Both fill as they open."
29480
30042
  },
29481
30043
  {
29482
- "kind": "field",
29483
- "name": "_pressInMenu",
29484
- "type": {
29485
- "text": "boolean"
29486
- },
30044
+ "kind": "method",
30045
+ "name": "_releaseMenus",
29487
30046
  "privacy": "private",
29488
- "default": "false",
29489
- "description": "A pointer is down inside the open menu. WebKit does not move the focus to a\nbutton on mousedown: the element that held it is blurred instead — `focusout`\nwith no `relatedTarget` — before the click reaches the item. `_onFocusOut` used\nto read that as the focus leaving the menu and close it on the press, so with a\nmouse no item could be chosen at all. Held from the press to its release."
29490
- },
29491
- {
29492
- "kind": "field",
29493
- "name": "_onDocumentPointerUp",
29494
- "privacy": "private"
29495
- },
29496
- {
29497
- "kind": "field",
29498
- "name": "_onDocumentPointerDown",
29499
- "privacy": "private"
30047
+ "return": {
30048
+ "type": {
30049
+ "text": "void"
30050
+ }
30051
+ },
30052
+ "description": "Closes whichever menu is open, without moving the focus, and stops them all."
29500
30053
  },
29501
30054
  {
29502
- "kind": "field",
29503
- "name": "_onWindowScroll",
29504
- "privacy": "private"
30055
+ "kind": "method",
30056
+ "name": "_placeQuestion",
30057
+ "privacy": "private",
30058
+ "return": {
30059
+ "type": {
30060
+ "text": "void"
30061
+ }
30062
+ },
30063
+ "parameters": [
30064
+ {
30065
+ "name": "menu",
30066
+ "type": {
30067
+ "text": "HTMLElement"
30068
+ }
30069
+ },
30070
+ {
30071
+ "name": "id",
30072
+ "type": {
30073
+ "text": "string"
30074
+ }
30075
+ }
30076
+ ],
30077
+ "description": "Placed again once the question has taken the items' place, since it is not their\nsize: the `⋯` menu against its button, the context menu on the corner it opened at."
29505
30078
  },
29506
30079
  {
29507
30080
  "kind": "field",
29508
- "name": "_onFocusOut",
29509
- "privacy": "private"
30081
+ "name": "_onMenuSelect",
30082
+ "privacy": "private",
30083
+ "description": "An item chosen in a row's menu: `enhanceMenu` asks before it closes. Delete keeps it\nopen, since the question takes the items' place. The event stops here: the menu is\nthis element's own, and what the list tells the page is `aparte-conversation-*`."
29510
30084
  },
29511
30085
  {
29512
30086
  "kind": "method",
@@ -29548,22 +30122,19 @@
29548
30122
  "type": {
29549
30123
  "text": "string"
29550
30124
  }
30125
+ },
30126
+ {
30127
+ "name": "menu",
30128
+ "type": {
30129
+ "text": "HTMLElement"
30130
+ }
29551
30131
  }
29552
- ]
29553
- },
29554
- {
29555
- "kind": "method",
29556
- "name": "_menuFocusables",
29557
- "privacy": "private",
29558
- "return": {
29559
- "type": {
29560
- "text": "HTMLElement[]"
29561
- }
29562
- }
30132
+ ],
30133
+ "description": "What the item does, once the menu has done its part: by now it has closed and put the\nfocus back on the `⋯` (or the row) — except for delete, kept open to ask."
29563
30134
  },
29564
30135
  {
29565
30136
  "kind": "method",
29566
- "name": "_onMenuKeydown",
30137
+ "name": "_onQuestionKeydown",
29567
30138
  "privacy": "private",
29568
30139
  "return": {
29569
30140
  "type": {
@@ -29576,8 +30147,15 @@
29576
30147
  "type": {
29577
30148
  "text": "KeyboardEvent"
29578
30149
  }
30150
+ },
30151
+ {
30152
+ "name": "menu",
30153
+ "type": {
30154
+ "text": "HTMLElement"
30155
+ }
29579
30156
  }
29580
- ]
30157
+ ],
30158
+ "description": "The delete question's own keys: the arrows, Home and End between its two answers.\nA menu holds no item while it asks, so the menu's own arrows have nothing to move\nto; Escape and Tab are still the menu's, and close it."
29581
30159
  },
29582
30160
  {
29583
30161
  "kind": "method",
@@ -34977,6 +35555,30 @@
34977
35555
  ],
34978
35556
  "description": "Persist token usage on a message and propagate to the live bubble, which is\nwhat allows the info (\"i\") action to render — provided the app declared it\nwith `aparteGlobalConfig.setBubbleActions({ info: true })`; it is off by default,\nsince the popover it opens belongs to the app."
34979
35557
  },
35558
+ {
35559
+ "kind": "method",
35560
+ "name": "setStep",
35561
+ "return": {
35562
+ "type": {
35563
+ "text": "void"
35564
+ }
35565
+ },
35566
+ "parameters": [
35567
+ {
35568
+ "name": "messageId",
35569
+ "type": {
35570
+ "text": "string"
35571
+ }
35572
+ },
35573
+ {
35574
+ "name": "name",
35575
+ "type": {
35576
+ "text": "string | null"
35577
+ }
35578
+ }
35579
+ ],
35580
+ "description": "Say the step the agent is on (\"Reading the parser\") in the reply's waiting indicator,\nor `null` for none. Live only: handed to the bubble, never written on the message."
35581
+ },
34980
35582
  {
34981
35583
  "kind": "method",
34982
35584
  "name": "completeMessage",
@@ -37138,6 +37740,56 @@
37138
37740
  }
37139
37741
  ]
37140
37742
  },
37743
+ {
37744
+ "kind": "javascript-module",
37745
+ "path": "src/renderers/segments/activity.ts",
37746
+ "declarations": [
37747
+ {
37748
+ "kind": "function",
37749
+ "name": "activityRendererThatDrew",
37750
+ "return": {
37751
+ "type": {
37752
+ "text": "AparteActivityRenderer | null"
37753
+ }
37754
+ },
37755
+ "parameters": [
37756
+ {
37757
+ "name": "element",
37758
+ "type": {
37759
+ "text": "Element"
37760
+ }
37761
+ }
37762
+ ],
37763
+ "description": "Which activity renderer is behind `element`, or null. Internal to core."
37764
+ },
37765
+ {
37766
+ "kind": "variable",
37767
+ "name": "activityRenderer",
37768
+ "type": {
37769
+ "text": "AparteSegmentRenderer<AparteActivitySegment>"
37770
+ },
37771
+ "default": "{ type: 'activity', render: (segment) => { const custom = rendererOf(segment); if (!custom) return placeholder(segment); const out = custom.render(segment); if (out instanceof HTMLElement) { drawnBy.set(out, custom); behind.set(out, custom); return out; } return out.trim() ? out : placeholder(segment); }, setup: (element, segment) => { const custom = rendererOf(segment); if (!custom) return; behind.set(element, custom); if (isPlaceholder(element)) return; drawnBy.set(element, custom); custom.setup?.(element, segment); }, /** * The agent sent it again. The renderer that drew it patches it, when it can and is still * the one registered; otherwise it is drawn again here, and the bubble follows the element. */ update: (element, segment) => { const custom = rendererOf(segment); const drawn = drawnBy.get(element) ?? null; if (drawn && drawn === custom && drawn.update) { drawn.update(element, segment); return; } if (!custom && !drawn && isPlaceholder(element)) { element.setAttribute('data-activity-type', segment.activityType); return; } const out = activityRenderer.render(segment); let rebuilt: HTMLElement | null; if (typeof out === 'string') { const tpl = document.createElement('template'); tpl.innerHTML = out.trim(); rebuilt = tpl.content.firstElementChild as HTMLElement | null; } else { rebuilt = out; } if (!rebuilt) return; if (!rebuilt.hasAttribute('data-segment-id')) rebuilt.setAttribute('data-segment-id', segment.id); activityRenderer.cleanup?.(element, segment); element.replaceWith(rebuilt); activityRenderer.setup?.(rebuilt, segment); }, relabel: (element, segment) => { drawnBy.get(element)?.relabel?.(element, segment); }, /** The element leaves for good: the renderer that drew it cleans up. A cleanup that throws is reported, nothing more. */ cleanup: (element, segment) => { behind.delete(element); const custom = drawnBy.get(element); if (!custom) return; drawnBy.delete(element); try { custom.cleanup?.(element, segment); } catch (err) { console.error('[aparte] an activity renderer\\'s cleanup threw', err); } }, }"
37772
+ }
37773
+ ],
37774
+ "exports": [
37775
+ {
37776
+ "kind": "js",
37777
+ "name": "activityRendererThatDrew",
37778
+ "declaration": {
37779
+ "name": "activityRendererThatDrew",
37780
+ "module": "src/renderers/segments/activity.ts"
37781
+ }
37782
+ },
37783
+ {
37784
+ "kind": "js",
37785
+ "name": "activityRenderer",
37786
+ "declaration": {
37787
+ "name": "activityRenderer",
37788
+ "module": "src/renderers/segments/activity.ts"
37789
+ }
37790
+ }
37791
+ ]
37792
+ },
37141
37793
  {
37142
37794
  "kind": "javascript-module",
37143
37795
  "path": "src/renderers/segments/code.ts",
@@ -37262,7 +37914,7 @@
37262
37914
  "type": {
37263
37915
  "text": "AparteSegmentRenderer<AparteToolCallSegment>"
37264
37916
  },
37265
- "default": "{ type: 'tool_call', render: (segment) => { const name = segment.toolCall?.name ?? 'tool'; /* * A tool waiting for a person is a STATE of the pill now, not a control. * * The Approve / Reject buttons were here, and they were the only decision * surface in the whole library that lived in the transcript. They are at the * composer now, which is where every other request for the user already went — * so this is the ANCHOR: the thing you scroll to, and the thing the panel is * about. Nothing clickable, no role, no tab stop, no pointer (ratified decision * #8: an undeclared affordance is not half-rendered either). * * It also fixes a defect by construction rather than by guarding: a segment * restored from storage used to repaint live buttons wired to a listener that * had gone with the page. * * And removing the branch un-shadows a seam that was said to be missing. It ran * BEFORE the per-tool renderer lookup below, so `registerToolRenderer` could * never draw anything while a tool awaited approval. The lookup is now first, * and a tool renders its own surface at every status. */ if (contextConfig().isToolHidden(name)) return placeholderMarkup(segment); const customRenderer = contextConfig().getToolRenderer(name); if (customRenderer) { // Its stylesheet, here as well as on the live path: this is what runs when a // stored conversation is re-rendered, and nothing replays `tool-start` for // history. Idempotent, keyed by renderer. injectToolRendererStyles(name, customRenderer); // Drawing nothing hides the call, the same element as a display's `hidden` // — it used to bring back the default row here while the live path dropped // the call, so a reload showed what the live chat had hidden. const out = customRenderer.render(segment); if (out instanceof HTMLElement) { drawnBy.set(out, customRenderer); behind.set(out, customRenderer); } return out || placeholderMarkup(segment); } const line = toolLineOf(segment, contextConfig()); return drawDefault(segment, behindOf(segment, line), line); }, /** * The pill's glyphs, and the label it wears while a person is deciding. * * The two highest-stakes strings in the library — the approval labels — are no * longer here: they are on the panel, which relabels itself. This still matters * though, because the request the pill describes stays open for as long as * somebody takes to decide, which is exactly long enough for a language switch. * * No child node is added or removed, per the relabel contract. */ relabel: (element, segment) => { if (isPlaceholder(element)) return; const cfg = contextConfig(); // A registered renderer owns its markup, so none of the selectors below exist // in it; its own `relabel` — when it declares one — is the only thing that can // re-read the locale for it. const custom = drawerOf(element, cfg.getToolRenderer(segment.toolCall?.name) ?? null); if (custom) { custom.relabel?.(element, segment); return; } // The provider is asked again: its words are in the reader's language too. const line = toolLineOf(segment, cfg); const icon = element.querySelector('.aparte-tool-icon'); if (icon) icon.innerHTML = iconOf(segment); setName(element, segment, line); setTarget(element, segment, line); setActivity(element, segment, line); setNote(element, segment, line); // The part labels are locale text too; the parts themselves stay (relabel adds none). const inputLabel = element.querySelector('[data-part=\"input\"] .aparte-tool-part-label'); if (inputLabel) inputLabel.textContent = cfg.t('toolInput'); element.querySelector('[data-part=\"input\"] .aparte-tool-part-body')?.setAttribute('aria-label', cfg.t('toolInput')); const outcome = outcomeOf(segment); const outputLabel = element.querySelector('[data-part=\"output\"] .aparte-tool-part-label'); if (outputLabel && outcome) outputLabel.textContent = cfg.t(outcome.key); if (outcome) element.querySelector('[data-part=\"output\"] .aparte-tool-part-body')?.setAttribute('aria-label', cfg.t(outcome.key)); for (const button of element.querySelectorAll<HTMLElement>('.aparte-tool-copy')) relabelCopyButton(button); // An app's detail may hold words in the reader's language too: its function is // asked again, and what it draws now is written into the nodes already there. const appDetail = appDetailOf(element); if (appDetail) { const behind = behindOf(segment, line); if (behind.kind === 'body') relabelBody(appDetail, behind.body); } // Through `stateBadge`, which is the whole point of it existing. // // This used to rebuild the badge by hand as the ICON ALONE, so any config change // — `setLocale`, `setIconProvider`, `registerTool`, `reset()`, anything that // calls `_notify()` — permanently deleted the localized state word that // `stateBadge` renders beside it. \"✓ Done\" became \"✓\", and `pending`'s \"Running\" // became empty. Four of five statuses regressed; only `awaiting-approval` // survived, because a second line below re-wrote it. // // Which is exactly what `stateBadge`'s own docblock says it prevents: \"One // function so `render` and `update` cannot disagree\". `relabel` was never folded // in. It is now, so there is no third spelling of the badge to keep in step — // and the approval-waiting special case goes with it, since `stateBadge` already // returns the localized `approvalWaiting` for that status. const statusEl = element.querySelector('.aparte-tool-state'); if (statusEl) statusEl.innerHTML = stateBadge(segment); setQuiet(element, segment); }, /** * Patch in place. NEVER re-render, and never touch `open`. * * Without an `update` the bubble replaces the element wholesale — and a tool call * changes status several times per turn, so a disclosure the reader opened would * slam shut under them every time. The same rule the reasoning block has, for the * same reason: `collapsed` is honoured only when an update explicitly carries it. * * The one case that cannot be patched is a change of ELEMENT: a call that had * neither arguments nor a result rendered as a plain pill, and gaining a result * makes it a `<details>`. That falls back to a rebuild, which costs nothing because * there was no disclosure to lose. */ update: (element, segment) => { const status = segment.status ?? 'pending'; const hidden = contextConfig().isToolHidden(segment.toolCall?.name ?? 'tool'); // A hidden call stays hidden: its placeholder only follows the status. if (hidden && isPlaceholder(element)) { element.setAttribute('data-status', status); return; } /* * Three cases this cannot patch, and each rebuilds instead. * * A registered tool renderer owns the WHOLE markup, so none of the selectors * below exist in it — patching would fail silently and that segment would * simply stop updating. Before this file had an `update` at all, the bubble * rebuilt on every change, which re-invoked their render; a rebuild keeps that * behaviour exactly. * * And a change of ELEMENT: a call with neither arguments nor a result renders * as a plain pill, and gaining either makes it a `<details>`. Nothing is lost * there — there was no disclosure to keep open. * * And a change of what is BEHIND the line, the app's detail for core's parts or * the other way: patched, the parts would be written around the app's markup. * That happens when a display gains or drops `details` while a turn is still * streaming, before the bubble redraws. */ // The renderer that DREW this row, and the one in effect now. They differ when one // was registered or dropped since; the row is then rebuilt by the current one. const custom = hidden ? null : (contextConfig().getToolRenderer(segment.toolCall?.name) ?? null); const drawn = isPlaceholder(element) ? null : drawerOf(element, custom); // A registered renderer that declares `update` owns the patch — a mounted // preview or an opened disclosure in its markup survives the change. One // that does not is rebuilt, as it always was. // Never on a placeholder: it is not the renderer's markup, and a call it drew as // nothing may draw something now — a rebuild asks it. if (drawn && drawn === custom && drawn.update && !isPlaceholder(element)) { drawn.update(element, segment); return; } const rebuild = (out: HTMLElement | string): void => { // A `<template>`, not the bubble's own converter: this file is a renderer // and must not import from the component that consumes it. const tpl = document.createElement('template'); tpl.innerHTML = typeof out === 'string' ? out.trim() : ''; const rebuilt = (typeof out === 'string' ? tpl.content.firstElementChild : out) as HTMLElement | null; if (rebuilt) { // The bubble stamps a renderer's root on its own render; this path must too, // or the next update misses the row and the whole bubble is drawn again. if (!rebuilt.hasAttribute('data-segment-id')) rebuilt.setAttribute('data-segment-id', segment.id); // This row is replaced HERE, not by the bubble: what drew it cleans up first // (the bubble follows the new element and cleans that one up when it goes). toolCallRenderer.cleanup?.(element, segment); element.replaceWith(rebuilt); toolCallRenderer.setup?.(rebuilt, segment); } }; if (custom || drawn || hidden || isPlaceholder(element)) { rebuild(toolCallRenderer.render(segment)); return; } // Asked here, past the hide and the renderer, so an app's `details` is never asked // for a call it cannot draw — and once: a rebuild draws with this same answer. const line = toolLineOf(segment, contextConfig()); const behind = behindOf(segment, line); const input = behind.kind === 'parts' ? describeInput(segment) : ''; const outcome = behind.kind === 'parts' ? outcomeOf(segment) : null; const wantsDetail = behind.kind === 'body' || !!input || !!outcome; const holdsAppDetail = !!appDetailOf(element); if (wantsDetail !== (element.tagName === 'DETAILS') || (wantsDetail && (behind.kind === 'body') !== holdsAppDetail)) { rebuild(drawDefault(segment, behind, line)); return; } element.setAttribute('data-status', status); const badge = element.querySelector('.aparte-tool-state'); if (badge) badge.innerHTML = stateBadge(segment); setQuiet(element, segment); setName(element, segment, line); setTarget(element, segment, line); setActivity(element, segment, line); setNote(element, segment, line); if (behind.kind === 'body') { setBody(element, behind.body); return; } setPart(element, 'input', input, 'toolInput'); setPart(element, 'output', outcome?.text ?? '', outcome?.key ?? 'toolOutput'); highlightParts(element); }, setup: (element, segment) => { // Set up right after `render`, so the renderer in effect now is the one behind the // row: remembered for its updates, its relabels and its cleanup. const hidden = contextConfig().isToolHidden(segment.toolCall?.name ?? 'tool'); const customRenderer = hidden ? undefined : contextConfig().getToolRenderer(segment.toolCall?.name); if (customRenderer) behind.set(element, customRenderer); if (isPlaceholder(element)) return; // The one control of ours is each part's copy button. The approval buttons that // used to be wired here dispatched `aparte-tool-decision`; the decision is // answered at the composer now, and the transcript holds no decision control. wireParts(element); highlightParts(element); if (customRenderer) drawnBy.set(element, customRenderer); customRenderer?.setup?.(element, segment); }, /** * The row leaves for good: the registered renderer that drew it, if any, cleans up. A * cleanup that throws is reported and goes no further: the row is replaced or removed * all the same, and the stream that caused it is not interrupted. */ cleanup: (element, segment) => { behind.delete(element); const custom = drawnBy.get(element); if (!custom) return; drawnBy.delete(element); try { custom.cleanup?.(element, segment); } catch (err) { console.error('[aparte] a tool renderer\\'s cleanup threw', err); } }, // CSS lives in styles/segment/ — see that folder for why a // built-in's rules belong there. `getStyles` stays for a CONSUMER's renderer, which // has no other way onto the page. getStyles: () => '' }"
37917
+ "default": "{ type: 'tool_call', render: (segment) => { const name = segment.toolCall?.name ?? 'tool'; /* * A tool waiting for a person is a STATE of the pill now, not a control. * * The Approve / Reject buttons were here, and they were the only decision * surface in the whole library that lived in the transcript. They are at the * composer now, which is where every other request for the user already went — * so this is the ANCHOR: the thing you scroll to, and the thing the panel is * about. Nothing clickable, no role, no tab stop, no pointer (ratified decision * #8: an undeclared affordance is not half-rendered either). * * It also fixes a defect by construction rather than by guarding: a segment * restored from storage used to repaint live buttons wired to a listener that * had gone with the page. * * And removing the branch un-shadows a seam that was said to be missing. It ran * BEFORE the per-tool renderer lookup below, so `registerToolRenderer` could * never draw anything while a tool awaited approval. The lookup is now first, * and a tool renders its own surface at every status. */ if (contextConfig().isToolHidden(name)) return placeholderMarkup(segment); const customRenderer = contextConfig().getToolRenderer(name); if (customRenderer) { // Its stylesheet, here as well as on the live path: this is what runs when a // stored conversation is re-rendered, and nothing replays `tool-start` for // history. Idempotent, keyed by renderer. injectToolRendererStyles(name, customRenderer); // Drawing nothing hides the call, the same element as a display's `hidden` // — it used to bring back the default row here while the live path dropped // the call, so a reload showed what the live chat had hidden. const out = customRenderer.render(segment); if (out instanceof HTMLElement) { drawnBy.set(out, customRenderer); behind.set(out, customRenderer); } return out || placeholderMarkup(segment); } const line = toolLineOf(segment, contextConfig()); return drawDefault(segment, behindOf(segment, line), line); }, /** * The pill's glyphs, and the label it wears while a person is deciding. * * The two highest-stakes strings in the library — the approval labels — are no * longer here: they are on the panel, which relabels itself. This still matters * though, because the request the pill describes stays open for as long as * somebody takes to decide, which is exactly long enough for a language switch. * * No child node is added or removed, per the relabel contract. */ relabel: (element, segment) => { if (isPlaceholder(element)) return; const cfg = contextConfig(); // A registered renderer owns its markup, so none of the selectors below exist // in it; its own `relabel` — when it declares one — is the only thing that can // re-read the locale for it. const custom = drawerOf(element, cfg.getToolRenderer(segment.toolCall?.name) ?? null); if (custom) { custom.relabel?.(element, segment); return; } // The provider is asked again: its words are in the reader's language too. const line = toolLineOf(segment, cfg); const icon = element.querySelector('.aparte-tool-icon'); if (icon) icon.innerHTML = iconOf(segment); setName(element, segment, line); setTarget(element, segment, line); setActivity(element, segment, line); setNote(element, segment, line); setOpen(element, line, false); // The part labels are locale text too; the parts themselves stay (relabel adds none). const inputLabel = element.querySelector('[data-part=\"input\"] .aparte-tool-part-label'); if (inputLabel) inputLabel.textContent = cfg.t('toolInput'); element.querySelector('[data-part=\"input\"] .aparte-tool-part-body')?.setAttribute('aria-label', cfg.t('toolInput')); const outcome = outcomeOf(segment); const outputLabel = element.querySelector('[data-part=\"output\"] .aparte-tool-part-label'); if (outputLabel && outcome) outputLabel.textContent = cfg.t(outcome.key); if (outcome) element.querySelector('[data-part=\"output\"] .aparte-tool-part-body')?.setAttribute('aria-label', cfg.t(outcome.key)); for (const button of element.querySelectorAll<HTMLElement>('.aparte-tool-copy')) relabelCopyButton(button); // An app's detail may hold words in the reader's language too: its function is // asked again, and what it draws now is written into the nodes already there. const appDetail = appDetailOf(element); if (appDetail) { const behind = behindOf(segment, line, element); if (behind.kind === 'body') relabelBody(appDetail, behind.body); } // Through `stateBadge`, which is the whole point of it existing. // // This used to rebuild the badge by hand as the ICON ALONE, so any config change // — `setLocale`, `setIconProvider`, `registerTool`, `reset()`, anything that // calls `_notify()` — permanently deleted the localized state word that // `stateBadge` renders beside it. \"✓ Done\" became \"✓\", and `pending`'s \"Running\" // became empty. Four of five statuses regressed; only `awaiting-approval` // survived, because a second line below re-wrote it. // // Which is exactly what `stateBadge`'s own docblock says it prevents: \"One // function so `render` and `update` cannot disagree\". `relabel` was never folded // in. It is now, so there is no third spelling of the badge to keep in step — // and the approval-waiting special case goes with it, since `stateBadge` already // returns the localized `approvalWaiting` for that status. const statusEl = element.querySelector('.aparte-tool-state'); if (statusEl) statusEl.innerHTML = stateBadge(segment); setQuiet(element, segment); }, /** * Patch in place. NEVER re-render, and never touch `open`. * * Without an `update` the bubble replaces the element wholesale — and a tool call * changes status several times per turn, so a disclosure the reader opened would * slam shut under them every time. The same rule the reasoning block has, for the * same reason: `collapsed` is honoured only when an update explicitly carries it. * * The one case that cannot be patched is a change of ELEMENT: a call that had * neither arguments nor a result rendered as a plain pill, and gaining a result * makes it a `<details>`. That falls back to a rebuild, which costs nothing because * there was no disclosure to lose. */ update: (element, segment) => { const status = segment.status ?? 'pending'; const hidden = contextConfig().isToolHidden(segment.toolCall?.name ?? 'tool'); // A hidden call stays hidden: its placeholder only follows the status. if (hidden && isPlaceholder(element)) { element.setAttribute('data-status', status); return; } /* * Three cases this cannot patch, and each rebuilds instead. * * A registered tool renderer owns the WHOLE markup, so none of the selectors * below exist in it — patching would fail silently and that segment would * simply stop updating. Before this file had an `update` at all, the bubble * rebuilt on every change, which re-invoked their render; a rebuild keeps that * behaviour exactly. * * And a change of ELEMENT: a call with neither arguments nor a result renders * as a plain pill, and gaining either makes it a `<details>`. Nothing is lost * there — there was no disclosure to keep open. * * And a change of what is BEHIND the line, the app's detail for core's parts or * the other way: patched, the parts would be written around the app's markup. * That happens when a display gains or drops `details` while a turn is still * streaming, before the bubble redraws. */ // The renderer that DREW this row, and the one in effect now. They differ when one // was registered or dropped since; the row is then rebuilt by the current one. const custom = hidden ? null : (contextConfig().getToolRenderer(segment.toolCall?.name) ?? null); const drawn = isPlaceholder(element) ? null : drawerOf(element, custom); // A registered renderer that declares `update` owns the patch — a mounted // preview or an opened disclosure in its markup survives the change. One // that does not is rebuilt, as it always was. // Never on a placeholder: it is not the renderer's markup, and a call it drew as // nothing may draw something now — a rebuild asks it. if (drawn && drawn === custom && drawn.update && !isPlaceholder(element)) { drawn.update(element, segment); return; } const rebuild = (out: HTMLElement | string): HTMLElement | null => { // A `<template>`, not the bubble's own converter: this file is a renderer // and must not import from the component that consumes it. const tpl = document.createElement('template'); tpl.innerHTML = typeof out === 'string' ? out.trim() : ''; const rebuilt = (typeof out === 'string' ? tpl.content.firstElementChild : out) as HTMLElement | null; if (rebuilt) { // The bubble stamps a renderer's root on its own render; this path must too, // or the next update misses the row and the whole bubble is drawn again. if (!rebuilt.hasAttribute('data-segment-id')) rebuilt.setAttribute('data-segment-id', segment.id); // This row is replaced HERE, not by the bubble: what drew it cleans up first // (the bubble follows the new element and cleans that one up when it goes). toolCallRenderer.cleanup?.(element, segment); element.replaceWith(rebuilt); toolCallRenderer.setup?.(rebuilt, segment); } return rebuilt; }; if (custom || drawn || hidden || isPlaceholder(element)) { rebuild(toolCallRenderer.render(segment)); return; } // Asked here, past the hide and the renderer, so an app's `details` is never asked // for a call it cannot draw — and once: a rebuild draws with this same answer. const line = toolLineOf(segment, contextConfig()); const behind = behindOf(segment, line, element); const input = behind.kind === 'parts' ? describeInput(segment) : ''; const outcome = behind.kind === 'parts' ? outcomeOf(segment) : null; const wantsDetail = behind.kind === 'body' || !!input || !!outcome; const holdsAppDetail = !!appDetailOf(element); const disclosure = disclosureOf(element); // A row with a detail and an Open button wraps its disclosure (see `drawDefault`): the // button coming or going is a change of shape too. What the reader opened is kept. const wrapped = !!disclosure && disclosure !== element; if (wantsDetail !== !!disclosure || (wantsDetail && (behind.kind === 'body') !== holdsAppDetail) || (wantsDetail && wrapped !== !!openOf(line))) { const wasOpen = disclosure?.open; const now = rebuild(drawDefault(segment, behind, line)); const next = now && wasOpen !== undefined ? disclosureOf(now) : null; if (next && wasOpen !== undefined) next.open = wasOpen; return; } element.setAttribute('data-status', status); const badge = element.querySelector('.aparte-tool-state'); if (badge) badge.innerHTML = stateBadge(segment); setQuiet(element, segment); setName(element, segment, line); setTarget(element, segment, line); setActivity(element, segment, line); setNote(element, segment, line); setOpen(element, line, true); if (behind.kind === 'body') { setBody(element, behind.body); return; } setPart(element, 'input', input, 'toolInput'); setPart(element, 'output', outcome?.text ?? '', outcome?.key ?? 'toolOutput'); highlightParts(element); }, setup: (element, segment) => { // Set up right after `render`, so the renderer in effect now is the one behind the // row: remembered for its updates, its relabels and its cleanup. const hidden = contextConfig().isToolHidden(segment.toolCall?.name ?? 'tool'); const customRenderer = hidden ? undefined : contextConfig().getToolRenderer(segment.toolCall?.name); if (customRenderer) behind.set(element, customRenderer); if (isPlaceholder(element)) return; // A line that opens elsewhere: its button, from the provider's answer of this draw. if (!customRenderer) { setOpen(element, toolLineOf(segment, contextConfig()), false); wireOpen(element); } // The other control of ours is each part's copy button. The approval buttons that // used to be wired here dispatched `aparte-tool-decision`; the decision is // answered at the composer now, and the transcript holds no decision control. wireParts(element); highlightParts(element); if (customRenderer) drawnBy.set(element, customRenderer); customRenderer?.setup?.(element, segment); }, /** * The row leaves for good: the registered renderer that drew it, if any, cleans up. A * cleanup that throws is reported and goes no further: the row is replaced or removed * all the same, and the stream that caused it is not interrupted. */ cleanup: (element, segment) => { behind.delete(element); const custom = drawnBy.get(element); if (!custom) return; drawnBy.delete(element); try { custom.cleanup?.(element, segment); } catch (err) { console.error('[aparte] a tool renderer\\'s cleanup threw', err); } }, // CSS lives in styles/segment/ — see that folder for why a // built-in's rules belong there. `getStyles` stays for a CONSUMER's renderer, which // has no other way onto the page. getStyles: () => '' }"
37266
37918
  }
37267
37919
  ],
37268
37920
  "exports": [