@aparte/core 1.5.0 → 1.6.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 (39) hide show
  1. package/dist/client/agent-runner.d.ts.map +1 -1
  2. package/dist/client/aparte-client.d.ts +6 -0
  3. package/dist/client/aparte-client.d.ts.map +1 -1
  4. package/dist/client/stream-adapter.d.ts +52 -2
  5. package/dist/client/stream-adapter.d.ts.map +1 -1
  6. package/dist/client/wire-history.d.ts +3 -2
  7. package/dist/client/wire-history.d.ts.map +1 -1
  8. package/dist/components/bubble/aparte-chat-bubble.d.ts +1 -1
  9. package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
  10. package/dist/components/viewport/aparte-chat-viewport.d.ts +5 -0
  11. package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
  12. package/dist/config/aparte-config.d.ts +69 -4
  13. package/dist/config/aparte-config.d.ts.map +1 -1
  14. package/dist/config/locale.d.ts +9 -0
  15. package/dist/config/locale.d.ts.map +1 -1
  16. package/dist/custom-elements.json +513 -9
  17. package/dist/{defer-hydration-lK-7XQXf.js → defer-hydration-W4yhnyfc.js} +406 -143
  18. package/dist/defer-hydration-W4yhnyfc.js.map +1 -0
  19. package/dist/index.css +1 -1
  20. package/dist/index.d.ts +6 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +84 -76
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.node.d.ts +6 -2
  25. package/dist/index.node.d.ts.map +1 -1
  26. package/dist/index.node.js +52 -47
  27. package/dist/index.node.js.map +1 -1
  28. package/dist/renderers/segments/tool-call.d.ts.map +1 -1
  29. package/dist/transport/agent-handler.d.ts.map +1 -1
  30. package/dist/types/index.d.ts +1 -1
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/tools.d.ts +40 -0
  33. package/dist/types/tools.d.ts.map +1 -1
  34. package/dist/utils/segment-list.d.ts +49 -0
  35. package/dist/utils/segment-list.d.ts.map +1 -0
  36. package/dist/utils/tool-line.d.ts +36 -9
  37. package/dist/utils/tool-line.d.ts.map +1 -1
  38. package/package.json +2 -2
  39. package/dist/defer-hydration-lK-7XQXf.js.map +0 -1
@@ -793,6 +793,14 @@
793
793
  "module": "./types/index.js"
794
794
  }
795
795
  },
796
+ {
797
+ "kind": "js",
798
+ "name": "AparteToolRun",
799
+ "declaration": {
800
+ "name": "AparteToolRun",
801
+ "module": "./types/index.js"
802
+ }
803
+ },
796
804
  {
797
805
  "kind": "js",
798
806
  "name": "AparteToolRenderer",
@@ -841,6 +849,14 @@
841
849
  "module": "./types/index.js"
842
850
  }
843
851
  },
852
+ {
853
+ "kind": "js",
854
+ "name": "AparteToolLine",
855
+ "declaration": {
856
+ "name": "AparteToolLine",
857
+ "module": "./types/index.js"
858
+ }
859
+ },
844
860
  {
845
861
  "kind": "js",
846
862
  "name": "AparteToolCallView",
@@ -2449,6 +2465,38 @@
2449
2465
  "module": "./client/stream-adapter.js"
2450
2466
  }
2451
2467
  },
2468
+ {
2469
+ "kind": "js",
2470
+ "name": "runSubAgent",
2471
+ "declaration": {
2472
+ "name": "runSubAgent",
2473
+ "module": "./client/stream-adapter.js"
2474
+ }
2475
+ },
2476
+ {
2477
+ "kind": "js",
2478
+ "name": "startSubAgent",
2479
+ "declaration": {
2480
+ "name": "startSubAgent",
2481
+ "module": "./client/stream-adapter.js"
2482
+ }
2483
+ },
2484
+ {
2485
+ "kind": "js",
2486
+ "name": "AparteRunEventContext",
2487
+ "declaration": {
2488
+ "name": "AparteRunEventContext",
2489
+ "module": "./config/aparte-config.js"
2490
+ }
2491
+ },
2492
+ {
2493
+ "kind": "js",
2494
+ "name": "AparteRunEventObserver",
2495
+ "declaration": {
2496
+ "name": "AparteRunEventObserver",
2497
+ "module": "./config/aparte-config.js"
2498
+ }
2499
+ },
2452
2500
  {
2453
2501
  "kind": "js",
2454
2502
  "name": "createAgentStreamRunner",
@@ -2657,6 +2705,38 @@
2657
2705
  "module": "./utils/segments.js"
2658
2706
  }
2659
2707
  },
2708
+ {
2709
+ "kind": "js",
2710
+ "name": "createSegmentList",
2711
+ "declaration": {
2712
+ "name": "createSegmentList",
2713
+ "module": "./utils/segment-list.js"
2714
+ }
2715
+ },
2716
+ {
2717
+ "kind": "js",
2718
+ "name": "AparteSegmentList",
2719
+ "declaration": {
2720
+ "name": "AparteSegmentList",
2721
+ "module": "./utils/segment-list.js"
2722
+ }
2723
+ },
2724
+ {
2725
+ "kind": "js",
2726
+ "name": "pluralize",
2727
+ "declaration": {
2728
+ "name": "pluralize",
2729
+ "module": "./utils/plural.js"
2730
+ }
2731
+ },
2732
+ {
2733
+ "kind": "js",
2734
+ "name": "formatDuration",
2735
+ "declaration": {
2736
+ "name": "formatDuration",
2737
+ "module": "./utils/format-duration.js"
2738
+ }
2739
+ },
2660
2740
  {
2661
2741
  "kind": "js",
2662
2742
  "name": "AparteHostHandlersConfig",
@@ -3675,6 +3755,14 @@
3675
3755
  "module": "./types/index.js"
3676
3756
  }
3677
3757
  },
3758
+ {
3759
+ "kind": "js",
3760
+ "name": "AparteToolRun",
3761
+ "declaration": {
3762
+ "name": "AparteToolRun",
3763
+ "module": "./types/index.js"
3764
+ }
3765
+ },
3678
3766
  {
3679
3767
  "kind": "js",
3680
3768
  "name": "AparteToolRenderer",
@@ -3723,6 +3811,14 @@
3723
3811
  "module": "./types/index.js"
3724
3812
  }
3725
3813
  },
3814
+ {
3815
+ "kind": "js",
3816
+ "name": "AparteToolLine",
3817
+ "declaration": {
3818
+ "name": "AparteToolLine",
3819
+ "module": "./types/index.js"
3820
+ }
3821
+ },
3726
3822
  {
3727
3823
  "kind": "js",
3728
3824
  "name": "AparteToolCallView",
@@ -5235,6 +5331,38 @@
5235
5331
  "module": "./utils/segments.js"
5236
5332
  }
5237
5333
  },
5334
+ {
5335
+ "kind": "js",
5336
+ "name": "createSegmentList",
5337
+ "declaration": {
5338
+ "name": "createSegmentList",
5339
+ "module": "./utils/segment-list.js"
5340
+ }
5341
+ },
5342
+ {
5343
+ "kind": "js",
5344
+ "name": "AparteSegmentList",
5345
+ "declaration": {
5346
+ "name": "AparteSegmentList",
5347
+ "module": "./utils/segment-list.js"
5348
+ }
5349
+ },
5350
+ {
5351
+ "kind": "js",
5352
+ "name": "pluralize",
5353
+ "declaration": {
5354
+ "name": "pluralize",
5355
+ "module": "./utils/plural.js"
5356
+ }
5357
+ },
5358
+ {
5359
+ "kind": "js",
5360
+ "name": "formatDuration",
5361
+ "declaration": {
5362
+ "name": "formatDuration",
5363
+ "module": "./utils/format-duration.js"
5364
+ }
5365
+ },
5238
5366
  {
5239
5367
  "kind": "js",
5240
5368
  "name": "AparteHostHandlersConfig",
@@ -5291,6 +5419,38 @@
5291
5419
  "module": "./client/stream-adapter.js"
5292
5420
  }
5293
5421
  },
5422
+ {
5423
+ "kind": "js",
5424
+ "name": "runSubAgent",
5425
+ "declaration": {
5426
+ "name": "runSubAgent",
5427
+ "module": "./client/stream-adapter.js"
5428
+ }
5429
+ },
5430
+ {
5431
+ "kind": "js",
5432
+ "name": "startSubAgent",
5433
+ "declaration": {
5434
+ "name": "startSubAgent",
5435
+ "module": "./client/stream-adapter.js"
5436
+ }
5437
+ },
5438
+ {
5439
+ "kind": "js",
5440
+ "name": "AparteRunEventContext",
5441
+ "declaration": {
5442
+ "name": "AparteRunEventContext",
5443
+ "module": "./config/aparte-config.js"
5444
+ }
5445
+ },
5446
+ {
5447
+ "kind": "js",
5448
+ "name": "AparteRunEventObserver",
5449
+ "declaration": {
5450
+ "name": "AparteRunEventObserver",
5451
+ "module": "./config/aparte-config.js"
5452
+ }
5453
+ },
5294
5454
  {
5295
5455
  "kind": "js",
5296
5456
  "name": "createAgentStreamRunner",
@@ -5939,7 +6099,7 @@
5939
6099
  {
5940
6100
  "name": "event",
5941
6101
  "type": {
5942
- "text": "{ id: string; name: string; input: Record<string, unknown> }"
6102
+ "text": "{ id: string; name: string; input: Record<string, unknown>; agent?: { id: string; name?: string } }"
5943
6103
  }
5944
6104
  },
5945
6105
  {
@@ -6068,6 +6228,14 @@
6068
6228
  "default": "new Set<string>()",
6069
6229
  "description": "Replies a turn is running into right now, a pause it waits on included: a second\nload of their conversation must not start them again (`resumeDeferred`)."
6070
6230
  },
6231
+ {
6232
+ "kind": "field",
6233
+ "name": "_agentNames",
6234
+ "privacy": "private",
6235
+ "readonly": true,
6236
+ "default": "new Map<string, Map<string, string>>()",
6237
+ "description": "The name of each sub-agent of a turn in flight, by reply then `agentId`, as its\n`agent-start` gave it: what a paused run's question says about who asks. A pending\ncall carries only an `agentId`. Lives as long as the turn, never on the message."
6238
+ },
6071
6239
  {
6072
6240
  "kind": "method",
6073
6241
  "name": "_toolsForCurrentModel",
@@ -6649,6 +6817,12 @@
6649
6817
  "text": "AparteChatTargetElement"
6650
6818
  }
6651
6819
  },
6820
+ {
6821
+ "name": "messageId",
6822
+ "type": {
6823
+ "text": "string"
6824
+ }
6825
+ },
6652
6826
  {
6653
6827
  "name": "pending",
6654
6828
  "type": {
@@ -6698,7 +6872,7 @@
6698
6872
  {
6699
6873
  "name": "call",
6700
6874
  "type": {
6701
- "text": "AparteToolCall"
6875
+ "text": "AparteToolCall & Pick<Parameters<StreamApprovalResolver>[0], 'agent'>"
6702
6876
  }
6703
6877
  },
6704
6878
  {
@@ -7015,6 +7189,24 @@
7015
7189
  "default": "engineToolRefusal",
7016
7190
  "description": "What a refused tool call tells the model, and who refused it — engine's `toolRefusal`,\nunder core's roof. `reason` is the sentence the model reads (the refuser's own, else\nthe person's words quoted, else \"Tool execution was rejected by the user.\"); `by` and\n`instruction` are what a row shows the person.\n\nFor a runner that answers an agent the loop does not run (an AG-UI agent, a server):\nit writes the sentence the loop writes, so the model reads one refusal however it ran."
7017
7191
  },
7192
+ {
7193
+ "kind": "variable",
7194
+ "name": "runSubAgent",
7195
+ "type": {
7196
+ "text": "typeof engineRunSubAgent"
7197
+ },
7198
+ "default": "engineRunSubAgent",
7199
+ "description": "Run a sub-agent from inside a tool handler — engine's `runSubAgent`, under core's roof.\n`run` is the handler's `context.run`, `signal` its second argument; `request` is the\nsub-agent's own conversation. Its events reach the page as the sub-agent's: kept out of\nthe reply, and handed to the observers of AparteConfig.observeRunEvents.\n\nResolves `{ status, text }` and never rejects for a sub-agent that failed, so the tool\ndecides what the model reads. A handler called without a run (a browser tool answering\na paused server run) has nothing to open one from, and rejects with a clear error."
7200
+ },
7201
+ {
7202
+ "kind": "variable",
7203
+ "name": "startSubAgent",
7204
+ "type": {
7205
+ "text": "typeof engineStartSubAgent"
7206
+ },
7207
+ "default": "engineStartSubAgent",
7208
+ "description": "Start a sub-agent in the background, from inside a tool handler — engine's `startSubAgent`.\nThe handler answers at once and the model goes on, writing and calling tools, while the\nsub-agent works on its own line; the reply does not end before it is back. Once the model\nhas nothing more to say, the loop waits for the sub-agents still at work, tells the model\nhow each ended, and asks it again. A Stop, a pause of the run, the turn limit or a crash\nstop it."
7209
+ },
7018
7210
  {
7019
7211
  "kind": "function",
7020
7212
  "name": "createStreamAdapter",
@@ -7067,6 +7259,22 @@
7067
7259
  "module": "src/client/stream-adapter.ts"
7068
7260
  }
7069
7261
  },
7262
+ {
7263
+ "kind": "js",
7264
+ "name": "runSubAgent",
7265
+ "declaration": {
7266
+ "name": "runSubAgent",
7267
+ "module": "src/client/stream-adapter.ts"
7268
+ }
7269
+ },
7270
+ {
7271
+ "kind": "js",
7272
+ "name": "startSubAgent",
7273
+ "declaration": {
7274
+ "name": "startSubAgent",
7275
+ "module": "src/client/stream-adapter.ts"
7276
+ }
7277
+ },
7070
7278
  {
7071
7279
  "kind": "js",
7072
7280
  "name": "createStreamAdapter",
@@ -7195,7 +7403,7 @@
7195
7403
  "name": "options",
7196
7404
  "default": "{}",
7197
7405
  "type": {
7198
- "text": "{\n /**\n * Leave this message's paused calls unanswered: the request that RESUMES them\n * sends the envelope with those calls open, for the server to answer them.\n */\n openDeferred?: boolean;\n }"
7406
+ "text": "{\n /**\n * Leave this message's paused calls unanswered — and its calls still running: the\n * request that RESUMES them sends the envelope with those calls open, for the\n * server to answer them.\n */\n openDeferred?: boolean;\n }"
7199
7407
  }
7200
7408
  }
7201
7409
  ],
@@ -8197,6 +8405,16 @@
8197
8405
  "privacy": "private",
8198
8406
  "default": "new ToolTable<AparteToolDisplay>()"
8199
8407
  },
8408
+ {
8409
+ "kind": "field",
8410
+ "name": "_toolLineProvider",
8411
+ "type": {
8412
+ "text": "((segment: AparteToolCallSegment) => AparteToolLine | undefined) | null"
8413
+ },
8414
+ "privacy": "private",
8415
+ "default": "null",
8416
+ "description": "What a plugin says about a call, read after the app's display — see setToolLineProvider."
8417
+ },
8200
8418
  {
8201
8419
  "kind": "field",
8202
8420
  "name": "_streamBlocks",
@@ -8216,6 +8434,16 @@
8216
8434
  "privacy": "private",
8217
8435
  "default": "new Map()"
8218
8436
  },
8437
+ {
8438
+ "kind": "field",
8439
+ "name": "_runEventObservers",
8440
+ "type": {
8441
+ "text": "Array<{ fn: AparteRunEventObserver }>"
8442
+ },
8443
+ "privacy": "private",
8444
+ "default": "[]",
8445
+ "description": "One entry per registration, so each remover takes back its own — see observeRunEvents."
8446
+ },
8219
8447
  {
8220
8448
  "kind": "field",
8221
8449
  "name": "_hostHandlers",
@@ -9958,6 +10186,37 @@
9958
10186
  ],
9959
10187
  "description": "Whether a tool's calls draw nothing: its display says `hidden`, and no renderer is\nregistered for it MORE specifically. A `'*'` hide therefore leaves a tool with its\nown renderer drawn (a plugin's receipt), while a hide as specific as the renderer\nwins — the app said so for that tool. A hidden call stays in the message, in storage\nand in the model's history; only its row is empty."
9960
10188
  },
10189
+ {
10190
+ "kind": "method",
10191
+ "name": "setToolLineProvider",
10192
+ "return": {
10193
+ "type": {
10194
+ "text": "void"
10195
+ }
10196
+ },
10197
+ "parameters": [
10198
+ {
10199
+ "name": "provider",
10200
+ "type": {
10201
+ "text": "((segment: AparteToolCallSegment) => AparteToolLine | undefined) | null"
10202
+ }
10203
+ }
10204
+ ],
10205
+ "description": "Say more about a call than its display does: what ran it, what it is doing now, a\nshort note after its state. For a plugin that knows a call from the inside — a\nsub-agent's line is the line of the call that opened it.\n\nOne provider per config; `null` removes it. It is consulted AFTER the app's display,\nfield by field, so the app always wins: `label` and `target` are read when the display\ngives none, `details` when the display has no `details` key. `activity`, a second\nline under the name, and `note` show in every state they are given: give `activity` for\nthe call's whole life, or never, or the row changes height. A function, called whenever the\nrow is drawn, updated or relabelled — never text stored on the segment — so its words\nfollow a language switch. One that throws, or returns nothing, leaves the default\nline. A chat with a config of its own and no provider reads aparteGlobalConfig's.",
10206
+ "examples": [
10207
+ "aparteGlobalConfig.setToolLineProvider((segment) =>\n segment.toolCall.name === 'delegate' ? { activity: 'Reading the parser', note: '3 tools' } : undefined);"
10208
+ ]
10209
+ },
10210
+ {
10211
+ "kind": "method",
10212
+ "name": "getToolLineProvider",
10213
+ "return": {
10214
+ "type": {
10215
+ "text": "((segment: AparteToolCallSegment) => AparteToolLine | undefined) | null"
10216
+ }
10217
+ },
10218
+ "description": "The tool-line provider this config reads: its own, else the page's."
10219
+ },
9961
10220
  {
9962
10221
  "kind": "method",
9963
10222
  "name": "_dropToolDisplayField",
@@ -10158,6 +10417,37 @@
10158
10417
  },
10159
10418
  "description": "The registered block grammars, in registration order."
10160
10419
  },
10420
+ {
10421
+ "kind": "method",
10422
+ "name": "observeRunEvents",
10423
+ "return": {
10424
+ "type": {
10425
+ "text": "() => void"
10426
+ }
10427
+ },
10428
+ "parameters": [
10429
+ {
10430
+ "name": "observer",
10431
+ "type": {
10432
+ "text": "AparteRunEventObserver"
10433
+ }
10434
+ }
10435
+ ],
10436
+ "description": "Hear every event of a reply's run, before the reply handles it — including the\nevents of its sub-agents, which the reply never draws: an event that carries an\n`agentId`, and `agent-start` / `agent-end`, are kept out of the reply whether anyone\nobserves them or not. This is how a plugin draws a sub-agent's conversation.\n\nA chat hears the observers of its own config first, then those of\naparteGlobalConfig, the way a segment renderer is found: one registered once on\nthe page reaches a chat that carries a config of its own. An observer that throws is\nreported once per reply, and the reply goes on. Returns the function that removes it.",
10437
+ "examples": [
10438
+ "const stop = aparteGlobalConfig.observeRunEvents((event, { messageId }) => {\n if (event.type === 'agent-start') console.info(`${messageId}: ${event.name} started`);\n});"
10439
+ ]
10440
+ },
10441
+ {
10442
+ "kind": "method",
10443
+ "name": "getRunEventObservers",
10444
+ "return": {
10445
+ "type": {
10446
+ "text": "AparteRunEventObserver[]"
10447
+ }
10448
+ },
10449
+ "description": "The observers registered on this config, in registration order (read by the stream adapter)."
10450
+ },
10161
10451
  {
10162
10452
  "kind": "method",
10163
10453
  "name": "setConversationManager",
@@ -10323,7 +10613,7 @@
10323
10613
  "text": "void"
10324
10614
  }
10325
10615
  },
10326
- "description": "Put the configuration back to its defaults: the providers and the selected model,\nthe tools with their renderers and summaries, the renderers and render hooks, the\nMarkdown and highlight providers, the code-language renderers, the sanitizer, the system prompt, the locale, icons,\navatars, actions and host handlers, the conversation manager, the question presenters\nand their queue. Three things stay: the transport, the key sources added with\nAparteConfig.registerKeyProvider| registerKeyProvider() (an `AparteClient`'s\n`keyResolver` among them), and the AparteConfig.subscribe| subscribe() listeners."
10616
+ "description": "Put the configuration back to its defaults: the providers and the selected model,\nthe tools with their renderers and summaries, the tool-line provider, the renderers and render hooks, the\nMarkdown and highlight providers, the code-language renderers, the sanitizer, the system prompt, the locale, icons,\navatars, actions and host handlers, the conversation manager, the question presenters\nand their queue, the run-event observers. Three things stay: the transport, the key sources added with\nAparteConfig.registerKeyProvider| registerKeyProvider() (an `AparteClient`'s\n`keyResolver` among them), and the AparteConfig.subscribe| subscribe() listeners."
10327
10617
  },
10328
10618
  {
10329
10619
  "kind": "method",
@@ -11503,7 +11793,7 @@
11503
11793
  "type": {
11504
11794
  "text": "AparteLocale"
11505
11795
  },
11506
- "default": "{ inputPlaceholder: \"Type a message...\", sendButton: \"Send\", copy: \"Copy\", copied: \"Copied!\", retry: \"Retry\", thinking: \"Thinking\", elicitationOther: \"Other…\", elicitationOtherPlaceholder: \"Type your answer…\", elicitationOtherLabel: \"Custom answer\", submitButton: \"Submit\", stopButton: \"Stop\", elicitationRecommended: \"Recommended\", elicitationSkip: \"Skip\", elicitationHide: \"Hide for now\", elicitationWaiting: \"Waiting for your answer\", elicitationYes: \"Yes\", elicitationNo: \"No\", elicitationAnswerLabel: \"Your answer\", approvalInstructionPlaceholder: \"Or tell it what to do instead…\", approvalAsk: \"Allow {tool}?\", approvalWaiting: \"Waiting\", scrollToBottom: \"Scroll to bottom\", suggestionsLabel: \"Suggested prompts\", contextLabel: \"Context window\", contextSystem: \"System prompt\", contextTools: \"Tools\", contextSummary: \"Summary\", contextMessages: \"Messages\", contextOther: \"Other\", contextFree: \"Free\", contextTotal: \"Total\", contextReclaim: \"Compacting now would free ~{n} tokens\", contextCompactNow: \"Compact now\", checkpointCount: \"{n} messages summarised for the model\", checkpointCountOne: \"1 message summarised for the model\", checkpointLegacy: \"Earlier messages were summarised\", checkpointGroup: \"Context summary\", checkpointShow: \"Show summary\", checkpointHide: \"Hide summary\", checkpointRestore: \"Restore\", checkpointRestoreConfirm: \"Send the original messages to the model again?\", checkpointPending: \"Summarising the context…\", checkpointFailed: \"Couldn't summarise the context\", toolRunning: \"Running\", toolCompleted: \"Done\", toolRejected: \"Rejected\", toolStopped: \"Stopped\", toolFailed: \"Failed\", toolInput: \"Input\", toolOutput: \"Output\", toolRejectedSaid: \"You said: “{instruction}”\", toolRefusedByPolicy: \"Refused by policy\", toolNotRunAfterRefusal: \"Not run: an earlier call was refused\", toolTimedOut: \"Timed out\", toolUnavailable: \"Not available here\", toolNoApprover: \"No one could approve it\", toolTurnLimit: \"Turn limit reached\", maxTurnsReached: \"Stopped after {n} turns to avoid an endless loop.\", sourcesCount: \"{n} sources\", sourcesOne: \"1 source\", sourcesCard: \"Sources\", sourcePrevious: \"Previous source\", sourceNext: \"Next source\", sourcePosition: \"Source {i} of {n}\", opensInNewTab: \"(opens in a new tab)\", imageLoad: \"Load the image from {host}\", imageLoadNamed: \"Load the image “{alt}” from {host}\", questionDeclined: \"You declined to answer.\", artifactNotCreated: \"Not created\", thoughtFor: \"Thought for {duration}\", thought: \"Thought\", turnWorking: \"Working…\", turnWorked: \"Worked {duration}\", turnUsed: \"Used {tools}\", turnTools: \"one:{n} tool|other:{n} tools\", feedbackReasonTitle: 'What went wrong?', feedbackReasonDismiss: 'Not now', triggersLoading: 'Loading…', triggersEmpty: 'No results', triggersError: 'This list could not be loaded', triggersRetry: 'Try again', triggersBack: 'Back', triggersCommandNew: 'Start a new conversation', triggersCommandStop: 'Stop the reply', triggersCommandRetry: 'Answer again', triggersCommandCopy: 'Copy the last reply', triggersCommandCompact: 'Summarise the earlier messages', triggersCompactNothing: 'There is nothing to compact yet', triggersCompactBusy: 'Wait for the reply to finish', triggersCompactNoWindow: 'This model does not say how much it can read', triggersCompactFailed: 'The summary could not be written', triggersCommandModel: 'Change the model', triggersCommandApproval: 'Change the approval mode', approvalOptionsLabel: \"Your decision\", approvalArgsLabel: \"Arguments\", actionUpload: \"Attach file\", removeAttachment: \"Remove {name}\", messageFrom: \"Message from {name}\", selectSearchPlaceholder: \"Search…\", selectSearchLabel: \"Search options\", loading: \"Loading…\", download: \"Download\", openArtifact: \"Open\", closeArtifact: \"Close\", artifactVersion: \"Version {n} of {total}\", previousVersion: \"Previous version\", nextVersion: \"Next version\", modelContextWindow: \"{n} context\", previewPending: \"Press Preview to run this artifact.\", sandboxError: \"The sandbox failed during generation.\", sandboxErrorHint: \"Common cause: the model produced invalid code (undefined variable, wrong argument type). Retry the request — the model may produce different code.\", preview: \"Preview\", code: \"Code\", generating: \"Generating…\", rebuildingPreview: \"Rebuilding preview…\", typing: \"Typing\", responseCutOff: \"Cut off at the model's length limit.\", error: \"Error\", errorUnreachable: \"The assistant can’t be reached right now. Try again in a moment.\", errorTimeout: \"The answer took too long. Try again in a moment.\", errorRefused: \"The assistant isn’t allowed to answer right now.\", errorRateLimited: \"Too many requests right now. Try again in a moment.\", errorTooLong: \"This conversation is too long for the model. Start a new one.\", errorFailed: \"The assistant couldn’t answer. Try again in a moment.\", errorNoAnswer: \"The assistant couldn’t answer this request.\", running: \"Running...\", run: \"Run\", file: \"File\", modelSelectorPlaceholder: \"Select a model...\", approvalModeLabel: \"Approval mode\", roleNameUser: \"You\", roleNameAssistant: \"Assistant\", yourMessage: \"Your message\", assistantResponse: \"Assistant response\", messageActions: \"Message actions\", edit: \"Edit message\", editConfirm: \"Send\", editCancel: \"Cancel\", feedbackPositive: \"Good response\", feedbackNegative: \"Bad response\", previousResponse: \"Previous response\", nextResponse: \"Next response\", approveTool: \"Approve\", rejectTool: \"Reject\", messageInfo: \"Details\", newChat: \"New Chat\", loadingConversations: \"Loading conversations\", conversationSearchEmpty: \"No conversation matches\", conversationList: \"Conversations\", loadingConversation: \"Loading the conversation\", deleteConversation: \"Delete\", archiveConversation: \"Archive\", unarchiveConversation: \"Unarchive\", conversationActions: \"Conversation actions\", conversationRunning: \"Answering\", conversationWaiting: \"Waiting for you\", renameConversation: \"Rename\", conversationTitle: \"Conversation title\", pinConversation: \"Pin\", unpinConversation: \"Unpin\", deleteConversationConfirm: \"Delete “{title}”?\", cancel: \"Cancel\", conversationGroupPinned: \"Pinned\", conversationGroupToday: \"Today\", conversationGroupYesterday: \"Yesterday\", conversationGroupWeek: \"Previous 7 days\", conversationGroupMonth: \"Previous 30 days\", scrollRailLabel: \"Conversation outline\", sidebarLabel: \"Conversations\", splitHandleLabel: \"Resize the panes\", launcherOpen: \"Open the chat\", launcherClose: \"Close the chat\", launcherHeading: \"Chat\", launcherMaximize: \"Expand the chat\", launcherRestore: \"Shrink the chat\", transcript: \"Transcript\" }",
11796
+ "default": "{ inputPlaceholder: \"Type a message...\", sendButton: \"Send\", copy: \"Copy\", copied: \"Copied!\", retry: \"Retry\", thinking: \"Thinking\", elicitationOther: \"Other…\", elicitationOtherPlaceholder: \"Type your answer…\", elicitationOtherLabel: \"Custom answer\", submitButton: \"Submit\", stopButton: \"Stop\", elicitationRecommended: \"Recommended\", elicitationSkip: \"Skip\", elicitationHide: \"Hide for now\", elicitationWaiting: \"Waiting for your answer\", elicitationYes: \"Yes\", elicitationNo: \"No\", elicitationAnswerLabel: \"Your answer\", approvalInstructionPlaceholder: \"Or tell it what to do instead…\", approvalAsk: \"Allow {tool}?\", approvalAskBy: \"Allow {tool} for {agent}?\", approvalWaiting: \"Waiting\", scrollToBottom: \"Scroll to bottom\", suggestionsLabel: \"Suggested prompts\", contextLabel: \"Context window\", contextSystem: \"System prompt\", contextTools: \"Tools\", contextSummary: \"Summary\", contextMessages: \"Messages\", contextOther: \"Other\", contextFree: \"Free\", contextTotal: \"Total\", contextReclaim: \"Compacting now would free ~{n} tokens\", contextCompactNow: \"Compact now\", checkpointCount: \"{n} messages summarised for the model\", checkpointCountOne: \"1 message summarised for the model\", checkpointLegacy: \"Earlier messages were summarised\", checkpointGroup: \"Context summary\", checkpointShow: \"Show summary\", checkpointHide: \"Hide summary\", checkpointRestore: \"Restore\", checkpointRestoreConfirm: \"Send the original messages to the model again?\", checkpointPending: \"Summarising the context…\", checkpointFailed: \"Couldn't summarise the context\", toolRunning: \"Running\", toolCompleted: \"Done\", toolRejected: \"Rejected\", toolStopped: \"Stopped\", toolFailed: \"Failed\", toolInput: \"Input\", toolOutput: \"Output\", toolRejectedSaid: \"You said: “{instruction}”\", toolRefusedByPolicy: \"Refused by policy\", toolNotRunAfterRefusal: \"Not run: an earlier call was refused\", toolTimedOut: \"Timed out\", toolUnavailable: \"Not available here\", toolNoApprover: \"No one could approve it\", toolTurnLimit: \"Turn limit reached\", maxTurnsReached: \"Stopped after {n} turns to avoid an endless loop.\", sourcesCount: \"{n} sources\", sourcesOne: \"1 source\", sourcesCard: \"Sources\", sourcePrevious: \"Previous source\", sourceNext: \"Next source\", sourcePosition: \"Source {i} of {n}\", opensInNewTab: \"(opens in a new tab)\", imageLoad: \"Load the image from {host}\", imageLoadNamed: \"Load the image “{alt}” from {host}\", questionDeclined: \"You declined to answer.\", artifactNotCreated: \"Not created\", thoughtFor: \"Thought for {duration}\", thought: \"Thought\", turnWorking: \"Working…\", turnWorked: \"Worked {duration}\", turnUsed: \"Used {tools}\", turnTools: \"one:{n} tool|other:{n} tools\", feedbackReasonTitle: 'What went wrong?', feedbackReasonDismiss: 'Not now', triggersLoading: 'Loading…', triggersEmpty: 'No results', triggersError: 'This list could not be loaded', triggersRetry: 'Try again', triggersBack: 'Back', triggersCommandNew: 'Start a new conversation', triggersCommandStop: 'Stop the reply', triggersCommandRetry: 'Answer again', triggersCommandCopy: 'Copy the last reply', triggersCommandCompact: 'Summarise the earlier messages', triggersCompactNothing: 'There is nothing to compact yet', triggersCompactBusy: 'Wait for the reply to finish', triggersCompactNoWindow: 'This model does not say how much it can read', triggersCompactFailed: 'The summary could not be written', triggersCommandModel: 'Change the model', triggersCommandApproval: 'Change the approval mode', approvalOptionsLabel: \"Your decision\", approvalArgsLabel: \"Arguments\", actionUpload: \"Attach file\", removeAttachment: \"Remove {name}\", messageFrom: \"Message from {name}\", selectSearchPlaceholder: \"Search…\", selectSearchLabel: \"Search options\", loading: \"Loading…\", download: \"Download\", openArtifact: \"Open\", closeArtifact: \"Close\", artifactVersion: \"Version {n} of {total}\", previousVersion: \"Previous version\", nextVersion: \"Next version\", modelContextWindow: \"{n} context\", previewPending: \"Press Preview to run this artifact.\", sandboxError: \"The sandbox failed during generation.\", sandboxErrorHint: \"Common cause: the model produced invalid code (undefined variable, wrong argument type). Retry the request — the model may produce different code.\", preview: \"Preview\", code: \"Code\", generating: \"Generating…\", rebuildingPreview: \"Rebuilding preview…\", typing: \"Typing\", responseCutOff: \"Cut off at the model's length limit.\", error: \"Error\", errorUnreachable: \"The assistant can’t be reached right now. Try again in a moment.\", errorTimeout: \"The answer took too long. Try again in a moment.\", errorRefused: \"The assistant isn’t allowed to answer right now.\", errorRateLimited: \"Too many requests right now. Try again in a moment.\", errorTooLong: \"This conversation is too long for the model. Start a new one.\", errorFailed: \"The assistant couldn’t answer. Try again in a moment.\", errorNoAnswer: \"The assistant couldn’t answer this request.\", running: \"Running...\", run: \"Run\", file: \"File\", modelSelectorPlaceholder: \"Select a model...\", approvalModeLabel: \"Approval mode\", roleNameUser: \"You\", roleNameAssistant: \"Assistant\", yourMessage: \"Your message\", assistantResponse: \"Assistant response\", messageActions: \"Message actions\", edit: \"Edit message\", editConfirm: \"Send\", editCancel: \"Cancel\", feedbackPositive: \"Good response\", feedbackNegative: \"Bad response\", previousResponse: \"Previous response\", nextResponse: \"Next response\", approveTool: \"Approve\", rejectTool: \"Reject\", messageInfo: \"Details\", newChat: \"New Chat\", loadingConversations: \"Loading conversations\", conversationSearchEmpty: \"No conversation matches\", conversationList: \"Conversations\", loadingConversation: \"Loading the conversation\", deleteConversation: \"Delete\", archiveConversation: \"Archive\", unarchiveConversation: \"Unarchive\", conversationActions: \"Conversation actions\", conversationRunning: \"Answering\", conversationWaiting: \"Waiting for you\", renameConversation: \"Rename\", conversationTitle: \"Conversation title\", pinConversation: \"Pin\", unpinConversation: \"Unpin\", deleteConversationConfirm: \"Delete “{title}”?\", cancel: \"Cancel\", conversationGroupPinned: \"Pinned\", conversationGroupToday: \"Today\", conversationGroupYesterday: \"Yesterday\", conversationGroupWeek: \"Previous 7 days\", conversationGroupMonth: \"Previous 30 days\", scrollRailLabel: \"Conversation outline\", sidebarLabel: \"Conversations\", splitHandleLabel: \"Resize the panes\", launcherOpen: \"Open the chat\", launcherClose: \"Close the chat\", launcherHeading: \"Chat\", launcherMaximize: \"Expand the chat\", launcherRestore: \"Shrink the chat\", transcript: \"Transcript\" }",
11507
11797
  "description": "Default English Locale (Zero-dependency)\nHardcoded to ensure the core works out-of-the-box."
11508
11798
  }
11509
11799
  ],
@@ -20312,6 +20602,14 @@
20312
20602
  "module": "./tools.js"
20313
20603
  }
20314
20604
  },
20605
+ {
20606
+ "kind": "js",
20607
+ "name": "AparteToolRun",
20608
+ "declaration": {
20609
+ "name": "AparteToolRun",
20610
+ "module": "./tools.js"
20611
+ }
20612
+ },
20315
20613
  {
20316
20614
  "kind": "js",
20317
20615
  "name": "AparteToolRenderer",
@@ -20360,6 +20658,14 @@
20360
20658
  "module": "./tools.js"
20361
20659
  }
20362
20660
  },
20661
+ {
20662
+ "kind": "js",
20663
+ "name": "AparteToolLine",
20664
+ "declaration": {
20665
+ "name": "AparteToolLine",
20666
+ "module": "./tools.js"
20667
+ }
20668
+ },
20363
20669
  {
20364
20670
  "kind": "js",
20365
20671
  "name": "AparteToolCallView",
@@ -21528,6 +21834,40 @@
21528
21834
  }
21529
21835
  ]
21530
21836
  },
21837
+ {
21838
+ "kind": "javascript-module",
21839
+ "path": "src/utils/segment-list.ts",
21840
+ "declarations": [
21841
+ {
21842
+ "kind": "function",
21843
+ "name": "createSegmentList",
21844
+ "return": {
21845
+ "type": {
21846
+ "text": "AparteSegmentList"
21847
+ }
21848
+ },
21849
+ "parameters": [
21850
+ {
21851
+ "name": "opts",
21852
+ "type": {
21853
+ "text": "{\n messageId: string;\n segments?: readonly AparteSegment[];\n config?: AparteConfig;\n}"
21854
+ }
21855
+ }
21856
+ ],
21857
+ "description": "A segment list a stream adapter can write into, stamped like a message's.\n\n`messageId` is the id stamped on each segment — the message the list belongs to. With a\n`config`, a segment joining the list takes that config's segment defaults\n(`setSegmentDefaults`), as it would in a chat. `segments` is a list saved earlier, adopted.\n\n`addSegment` and `updateSegment` are the writes; `updateMessage` and `setUsage` do nothing\n(there is no message here), and `dispatchEvent` dispatches nothing: the events of the run\nare the caller's to hear, with `observeRunEvents`."
21858
+ }
21859
+ ],
21860
+ "exports": [
21861
+ {
21862
+ "kind": "js",
21863
+ "name": "createSegmentList",
21864
+ "declaration": {
21865
+ "name": "createSegmentList",
21866
+ "module": "src/utils/segment-list.ts"
21867
+ }
21868
+ }
21869
+ ]
21870
+ },
21531
21871
  {
21532
21872
  "kind": "javascript-module",
21533
21873
  "path": "src/utils/segments.ts",
@@ -21966,6 +22306,30 @@
21966
22306
  "kind": "javascript-module",
21967
22307
  "path": "src/utils/tool-line.ts",
21968
22308
  "declarations": [
22309
+ {
22310
+ "kind": "function",
22311
+ "name": "toolLineOf",
22312
+ "return": {
22313
+ "type": {
22314
+ "text": "AparteToolLine | undefined"
22315
+ }
22316
+ },
22317
+ "parameters": [
22318
+ {
22319
+ "name": "segment",
22320
+ "type": {
22321
+ "text": "AparteToolCallSegment"
22322
+ }
22323
+ },
22324
+ {
22325
+ "name": "config",
22326
+ "type": {
22327
+ "text": "AparteConfig"
22328
+ }
22329
+ }
22330
+ ],
22331
+ "description": "What the config's tool-line provider says about this call (`setToolLineProvider`), or\n`undefined` when there is none, it says nothing, or it throws — the default line then.\nCalled at every draw, update and relabel, never stored: its words follow the locale."
22332
+ },
21969
22333
  {
21970
22334
  "kind": "function",
21971
22335
  "name": "toolNameOf",
@@ -21986,9 +22350,16 @@
21986
22350
  "type": {
21987
22351
  "text": "AparteConfig"
21988
22352
  }
22353
+ },
22354
+ {
22355
+ "name": "line",
22356
+ "default": "toolLineOf(segment, config)",
22357
+ "type": {
22358
+ "text": "AparteToolLine | undefined"
22359
+ }
21989
22360
  }
21990
22361
  ],
21991
- "description": "The name a call goes by: the label its display declares (`registerToolDisplay`), else\nthe identifier — the app's wire format, which core never turns into words on its own.\nA label that throws or says nothing costs the call its label, not its render."
22362
+ "description": "The name a call goes by: the label its display declares (`registerToolDisplay`), else the\nlabel the tool-line provider gives, else the identifier — the app's wire format, which\ncore never turns into words on its own. A label that throws or says nothing costs the\ncall its label, not its render.\n\n`line` is the provider's answer when the caller already asked for it (the row asks once\nper draw); left out, it is asked here."
21992
22363
  },
21993
22364
  {
21994
22365
  "kind": "function",
@@ -22010,12 +22381,100 @@
22010
22381
  "type": {
22011
22382
  "text": "AparteConfig"
22012
22383
  }
22384
+ },
22385
+ {
22386
+ "name": "line",
22387
+ "default": "toolLineOf(segment, config)",
22388
+ "type": {
22389
+ "text": "AparteToolLine | undefined"
22390
+ }
22013
22391
  }
22014
22392
  ],
22015
- "description": "What a call targets, from the summary its display declares — `''` when there is none,\nor when it throws: a summary reads model-chosen input, and a bad one must cost the call\nits one line, not the bubble its render."
22393
+ "description": "What a call targets, from the summary its display declares, else the target the\ntool-line provider gives — `''` when neither says anything, or when the summary throws:\na summary reads model-chosen input, and a bad one must cost the call its one line, not\nthe bubble its render."
22394
+ },
22395
+ {
22396
+ "kind": "function",
22397
+ "name": "toolTargetPartsOf",
22398
+ "return": {
22399
+ "type": {
22400
+ "text": "{ text: string; isWords: boolean }"
22401
+ }
22402
+ },
22403
+ "parameters": [
22404
+ {
22405
+ "name": "segment",
22406
+ "type": {
22407
+ "text": "AparteToolCallSegment"
22408
+ }
22409
+ },
22410
+ {
22411
+ "name": "config",
22412
+ "type": {
22413
+ "text": "AparteConfig"
22414
+ }
22415
+ },
22416
+ {
22417
+ "name": "line",
22418
+ "default": "toolLineOf(segment, config)",
22419
+ "type": {
22420
+ "text": "AparteToolLine | undefined"
22421
+ }
22422
+ }
22423
+ ],
22424
+ "description": "The target and where it came from: `isWords` when the tool-line provider gave it (a\nsentence for a person — a sub-agent's task), not the app's summary, which is read off the\narguments (a path, a command) and keeps the code face on an agent's row."
22425
+ },
22426
+ {
22427
+ "kind": "function",
22428
+ "name": "toolActivityOf",
22429
+ "return": {
22430
+ "type": {
22431
+ "text": "string"
22432
+ }
22433
+ },
22434
+ "parameters": [
22435
+ {
22436
+ "name": "_segment",
22437
+ "type": {
22438
+ "text": "AparteToolCallSegment"
22439
+ }
22440
+ },
22441
+ {
22442
+ "name": "line",
22443
+ "type": {
22444
+ "text": "AparteToolLine | undefined"
22445
+ }
22446
+ }
22447
+ ],
22448
+ "description": "The row's second line, from the tool-line provider, in every state it gives one: what the\ncall is doing now, and once it is over what it did. Core says nothing there on its own."
22449
+ },
22450
+ {
22451
+ "kind": "function",
22452
+ "name": "toolLineNoteOf",
22453
+ "return": {
22454
+ "type": {
22455
+ "text": "string"
22456
+ }
22457
+ },
22458
+ "parameters": [
22459
+ {
22460
+ "name": "line",
22461
+ "type": {
22462
+ "text": "AparteToolLine | undefined"
22463
+ }
22464
+ }
22465
+ ],
22466
+ "description": "The provider's trailing note, in every state."
22016
22467
  }
22017
22468
  ],
22018
22469
  "exports": [
22470
+ {
22471
+ "kind": "js",
22472
+ "name": "toolLineOf",
22473
+ "declaration": {
22474
+ "name": "toolLineOf",
22475
+ "module": "src/utils/tool-line.ts"
22476
+ }
22477
+ },
22019
22478
  {
22020
22479
  "kind": "js",
22021
22480
  "name": "toolNameOf",
@@ -22031,6 +22490,30 @@
22031
22490
  "name": "toolTargetOf",
22032
22491
  "module": "src/utils/tool-line.ts"
22033
22492
  }
22493
+ },
22494
+ {
22495
+ "kind": "js",
22496
+ "name": "toolTargetPartsOf",
22497
+ "declaration": {
22498
+ "name": "toolTargetPartsOf",
22499
+ "module": "src/utils/tool-line.ts"
22500
+ }
22501
+ },
22502
+ {
22503
+ "kind": "js",
22504
+ "name": "toolActivityOf",
22505
+ "declaration": {
22506
+ "name": "toolActivityOf",
22507
+ "module": "src/utils/tool-line.ts"
22508
+ }
22509
+ },
22510
+ {
22511
+ "kind": "js",
22512
+ "name": "toolLineNoteOf",
22513
+ "declaration": {
22514
+ "name": "toolLineNoteOf",
22515
+ "module": "src/utils/tool-line.ts"
22516
+ }
22034
22517
  }
22035
22518
  ]
22036
22519
  },
@@ -23616,7 +24099,7 @@
23616
24099
  }
23617
24100
  }
23618
24101
  ],
23619
- "description": "What a call goes by on screen: the label the app gave it, else its identifier."
24102
+ "description": "What a call goes by on screen — the name its row shows, through the same function."
23620
24103
  },
23621
24104
  {
23622
24105
  "kind": "method",
@@ -35199,6 +35682,27 @@
35199
35682
  }
35200
35683
  }
35201
35684
  },
35685
+ {
35686
+ "kind": "method",
35687
+ "name": "_fitsOnceCentred",
35688
+ "privacy": "private",
35689
+ "return": {
35690
+ "type": {
35691
+ "text": "boolean"
35692
+ }
35693
+ },
35694
+ "description": "The transcript will fit once the room the centring spacer under the composer still\nholds (`center-empty`, or a wrapper's auto-centre) is back. That room is 0 once the\nslide is over, and outside those layouts."
35695
+ },
35696
+ {
35697
+ "kind": "method",
35698
+ "name": "_centringRoom",
35699
+ "privacy": "private",
35700
+ "return": {
35701
+ "type": {
35702
+ "text": "number"
35703
+ }
35704
+ }
35705
+ },
35202
35706
  {
35203
35707
  "kind": "method",
35204
35708
  "name": "_gliding",
@@ -36758,7 +37262,7 @@
36758
37262
  "type": {
36759
37263
  "text": "AparteSegmentRenderer<AparteToolCallSegment>"
36760
37264
  },
36761
- "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); } return drawDefault(segment, behindOf(segment)); }, /** * 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; } const icon = element.querySelector('.aparte-tool-icon'); if (icon) icon.innerHTML = iconOf(segment); setName(element, segment); setTarget(element, segment); setNote(element, segment); // 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); 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 behind = behindOf(segment); 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)); 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); setTarget(element, segment); setNote(element, segment); 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: () => '' }"
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: () => '' }"
36762
37266
  }
36763
37267
  ],
36764
37268
  "exports": [