@artooi/agents-web-components 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +68 -0
- package/LICENSE +21 -0
- package/README.md +4397 -2
- package/dist/agents-web-components.bundle.js +5708 -0
- package/dist/agents-web-components.bundle.js.map +7 -0
- package/dist/bundle.d.ts +3 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/chat.d.ts +3 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +16373 -0
- package/dist/chat.js.map +7 -0
- package/dist/chunk-ARNLFGCC.js +7715 -0
- package/dist/chunk-ARNLFGCC.js.map +7 -0
- package/dist/constants.d.ts +575 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core/activity_registration.d.ts +19 -0
- package/dist/core/activity_registration.d.ts.map +1 -0
- package/dist/core/activity_registry.d.ts +46 -0
- package/dist/core/activity_registry.d.ts.map +1 -0
- package/dist/core/activity_renderer.d.ts +20 -0
- package/dist/core/activity_renderer.d.ts.map +1 -0
- package/dist/core/ag_ui_chat.d.ts +836 -0
- package/dist/core/ag_ui_chat.d.ts.map +1 -0
- package/dist/core/agui_client.d.ts +370 -0
- package/dist/core/agui_client.d.ts.map +1 -0
- package/dist/core/attachment.d.ts +42 -0
- package/dist/core/attachment.d.ts.map +1 -0
- package/dist/core/chat_registry.d.ts +23 -0
- package/dist/core/chat_registry.d.ts.map +1 -0
- package/dist/core/client_seed.d.ts +27 -0
- package/dist/core/client_seed.d.ts.map +1 -0
- package/dist/core/conversation_store.d.ts +195 -0
- package/dist/core/conversation_store.d.ts.map +1 -0
- package/dist/core/create_http_agent.d.ts +57 -0
- package/dist/core/create_http_agent.d.ts.map +1 -0
- package/dist/core/define_chat.d.ts +13 -0
- package/dist/core/define_chat.d.ts.map +1 -0
- package/dist/core/events/attachments_detail.d.ts +9 -0
- package/dist/core/events/attachments_detail.d.ts.map +1 -0
- package/dist/core/events/bar_height_detail.d.ts +6 -0
- package/dist/core/events/bar_height_detail.d.ts.map +1 -0
- package/dist/core/events/custom_agent_detail.d.ts +8 -0
- package/dist/core/events/custom_agent_detail.d.ts.map +1 -0
- package/dist/core/events/dock_width_detail.d.ts +8 -0
- package/dist/core/events/dock_width_detail.d.ts.map +1 -0
- package/dist/core/events/feedback_detail.d.ts +28 -0
- package/dist/core/events/feedback_detail.d.ts.map +1 -0
- package/dist/core/events/invalidate_detail.d.ts +16 -0
- package/dist/core/events/invalidate_detail.d.ts.map +1 -0
- package/dist/core/events/maximize_detail.d.ts +5 -0
- package/dist/core/events/maximize_detail.d.ts.map +1 -0
- package/dist/core/events/run_finished_detail.d.ts +36 -0
- package/dist/core/events/run_finished_detail.d.ts.map +1 -0
- package/dist/core/events/state_detail.d.ts +5 -0
- package/dist/core/events/state_detail.d.ts.map +1 -0
- package/dist/core/events/submit_detail.d.ts +8 -0
- package/dist/core/events/submit_detail.d.ts.map +1 -0
- package/dist/core/events/thread_detail.d.ts +27 -0
- package/dist/core/events/thread_detail.d.ts.map +1 -0
- package/dist/core/events/thread_title_detail.d.ts +8 -0
- package/dist/core/events/thread_title_detail.d.ts.map +1 -0
- package/dist/core/events/toggle_detail.d.ts +5 -0
- package/dist/core/events/toggle_detail.d.ts.map +1 -0
- package/dist/core/events/tool_run.d.ts +11 -0
- package/dist/core/events/tool_run.d.ts.map +1 -0
- package/dist/core/events/unread_detail.d.ts +11 -0
- package/dist/core/events/unread_detail.d.ts.map +1 -0
- package/dist/core/message_role.d.ts +4 -0
- package/dist/core/message_role.d.ts.map +1 -0
- package/dist/core/read_flag.d.ts +11 -0
- package/dist/core/read_flag.d.ts.map +1 -0
- package/dist/core/read_json_attribute.d.ts +15 -0
- package/dist/core/read_json_attribute.d.ts.map +1 -0
- package/dist/core/read_max_tool_rounds.d.ts +9 -0
- package/dist/core/read_max_tool_rounds.d.ts.map +1 -0
- package/dist/core/remote_conversation_store.d.ts +71 -0
- package/dist/core/remote_conversation_store.d.ts.map +1 -0
- package/dist/core/run_handlers.d.ts +85 -0
- package/dist/core/run_handlers.d.ts.map +1 -0
- package/dist/core/run_index.d.ts +58 -0
- package/dist/core/run_index.d.ts.map +1 -0
- package/dist/core/storage_scope.d.ts +118 -0
- package/dist/core/storage_scope.d.ts.map +1 -0
- package/dist/core/tool_outcome.d.ts +27 -0
- package/dist/core/tool_outcome.d.ts.map +1 -0
- package/dist/core/transcribe_audio.d.ts +32 -0
- package/dist/core/transcribe_audio.d.ts.map +1 -0
- package/dist/core/upload_attachment.d.ts +44 -0
- package/dist/core/upload_attachment.d.ts.map +1 -0
- package/dist/core/utils.d.ts +117 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/dom/animations.d.ts +122 -0
- package/dist/dom/animations.d.ts.map +1 -0
- package/dist/dom/dom_driver.d.ts +28 -0
- package/dist/dom/dom_driver.d.ts.map +1 -0
- package/dist/dom/highlight_overlay.d.ts +39 -0
- package/dist/dom/highlight_overlay.d.ts.map +1 -0
- package/dist/dom/native_setter.d.ts +5 -0
- package/dist/dom/native_setter.d.ts.map +1 -0
- package/dist/dom/ring_color.d.ts +16 -0
- package/dist/dom/ring_color.d.ts.map +1 -0
- package/dist/dom/utils.d.ts +3 -0
- package/dist/dom/utils.d.ts.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +223 -0
- package/dist/index.js.map +7 -0
- package/dist/skills/fill_template.d.ts +16 -0
- package/dist/skills/fill_template.d.ts.map +1 -0
- package/dist/skills/parse_skills.d.ts +8 -0
- package/dist/skills/parse_skills.d.ts.map +1 -0
- package/dist/skills/skill.d.ts +33 -0
- package/dist/skills/skill.d.ts.map +1 -0
- package/dist/skills/skill_catalog.d.ts +69 -0
- package/dist/skills/skill_catalog.d.ts.map +1 -0
- package/dist/skills/skill_name_from.d.ts +12 -0
- package/dist/skills/skill_name_from.d.ts.map +1 -0
- package/dist/tools/chat_surface_tools.d.ts +77 -0
- package/dist/tools/chat_surface_tools.d.ts.map +1 -0
- package/dist/tools/client_tool_registry.d.ts +58 -0
- package/dist/tools/client_tool_registry.d.ts.map +1 -0
- package/dist/tools/is_destructive.d.ts +14 -0
- package/dist/tools/is_destructive.d.ts.map +1 -0
- package/dist/tools/is_navigates.d.ts +9 -0
- package/dist/tools/is_navigates.d.ts.map +1 -0
- package/dist/tools/page_action_tools.d.ts +30 -0
- package/dist/tools/page_action_tools.d.ts.map +1 -0
- package/dist/tools/page_map.d.ts +16 -0
- package/dist/tools/page_map.d.ts.map +1 -0
- package/dist/tools/page_state.d.ts +27 -0
- package/dist/tools/page_state.d.ts.map +1 -0
- package/dist/tools/parse_tool_catalog.d.ts +21 -0
- package/dist/tools/parse_tool_catalog.d.ts.map +1 -0
- package/dist/tools/route_map.d.ts +37 -0
- package/dist/tools/route_map.d.ts.map +1 -0
- package/dist/tools/tool_catalog.d.ts +86 -0
- package/dist/tools/tool_catalog.d.ts.map +1 -0
- package/dist/tools/tool_dispatch.d.ts +82 -0
- package/dist/tools/tool_dispatch.d.ts.map +1 -0
- package/dist/ui/charts/chart_block.d.ts +57 -0
- package/dist/ui/charts/chart_block.d.ts.map +1 -0
- package/dist/ui/charts/chart_spec_from.d.ts +12 -0
- package/dist/ui/charts/chart_spec_from.d.ts.map +1 -0
- package/dist/ui/charts/chart_styles.d.ts +2 -0
- package/dist/ui/charts/chart_styles.d.ts.map +1 -0
- package/dist/ui/charts/chart_tool.d.ts +15 -0
- package/dist/ui/charts/chart_tool.d.ts.map +1 -0
- package/dist/ui/composer/attachment_styles.d.ts +2 -0
- package/dist/ui/composer/attachment_styles.d.ts.map +1 -0
- package/dist/ui/composer/attachment_tray.d.ts +53 -0
- package/dist/ui/composer/attachment_tray.d.ts.map +1 -0
- package/dist/ui/composer/auto_grow.d.ts +10 -0
- package/dist/ui/composer/auto_grow.d.ts.map +1 -0
- package/dist/ui/composer/build_composer.d.ts +32 -0
- package/dist/ui/composer/build_composer.d.ts.map +1 -0
- package/dist/ui/composer/composer_attachments.d.ts +57 -0
- package/dist/ui/composer/composer_attachments.d.ts.map +1 -0
- package/dist/ui/composer/composer_styles.d.ts +2 -0
- package/dist/ui/composer/composer_styles.d.ts.map +1 -0
- package/dist/ui/composer/composer_voice.d.ts +48 -0
- package/dist/ui/composer/composer_voice.d.ts.map +1 -0
- package/dist/ui/composer/skill_styles.d.ts +2 -0
- package/dist/ui/composer/skill_styles.d.ts.map +1 -0
- package/dist/ui/composer/skills_menu.d.ts +34 -0
- package/dist/ui/composer/skills_menu.d.ts.map +1 -0
- package/dist/ui/composer/voice_input.d.ts +46 -0
- package/dist/ui/composer/voice_input.d.ts.map +1 -0
- package/dist/ui/excerpts/attach_copy_buttons.d.ts +13 -0
- package/dist/ui/excerpts/attach_copy_buttons.d.ts.map +1 -0
- package/dist/ui/excerpts/copy_payload.d.ts +30 -0
- package/dist/ui/excerpts/copy_payload.d.ts.map +1 -0
- package/dist/ui/excerpts/page_quote_offer.d.ts +33 -0
- package/dist/ui/excerpts/page_quote_offer.d.ts.map +1 -0
- package/dist/ui/excerpts/place_offer.d.ts +9 -0
- package/dist/ui/excerpts/place_offer.d.ts.map +1 -0
- package/dist/ui/excerpts/quote_selection.d.ts +66 -0
- package/dist/ui/excerpts/quote_selection.d.ts.map +1 -0
- package/dist/ui/excerpts/transcript_quote_offer.d.ts +57 -0
- package/dist/ui/excerpts/transcript_quote_offer.d.ts.map +1 -0
- package/dist/ui/fill_ui_string.d.ts +32 -0
- package/dist/ui/fill_ui_string.d.ts.map +1 -0
- package/dist/ui/history/checkpoint_menu.d.ts +41 -0
- package/dist/ui/history/checkpoint_menu.d.ts.map +1 -0
- package/dist/ui/history/conversation_history.d.ts +317 -0
- package/dist/ui/history/conversation_history.d.ts.map +1 -0
- package/dist/ui/history/history_styles.d.ts +2 -0
- package/dist/ui/history/history_styles.d.ts.map +1 -0
- package/dist/ui/history/relative_time.d.ts +23 -0
- package/dist/ui/history/relative_time.d.ts.map +1 -0
- package/dist/ui/history/thread_drawer.d.ts +64 -0
- package/dist/ui/history/thread_drawer.d.ts.map +1 -0
- package/dist/ui/history/utils.d.ts +2 -0
- package/dist/ui/history/utils.d.ts.map +1 -0
- package/dist/ui/interrupts/approval_card.d.ts +64 -0
- package/dist/ui/interrupts/approval_card.d.ts.map +1 -0
- package/dist/ui/interrupts/approval_styles.d.ts +2 -0
- package/dist/ui/interrupts/approval_styles.d.ts.map +1 -0
- package/dist/ui/interrupts/confirmation_card.d.ts +51 -0
- package/dist/ui/interrupts/confirmation_card.d.ts.map +1 -0
- package/dist/ui/interrupts/confirmation_styles.d.ts +2 -0
- package/dist/ui/interrupts/confirmation_styles.d.ts.map +1 -0
- package/dist/ui/interrupts/pending_decision.d.ts +22 -0
- package/dist/ui/interrupts/pending_decision.d.ts.map +1 -0
- package/dist/ui/interrupts/question_card.d.ts +49 -0
- package/dist/ui/interrupts/question_card.d.ts.map +1 -0
- package/dist/ui/interrupts/question_styles.d.ts +2 -0
- package/dist/ui/interrupts/question_styles.d.ts.map +1 -0
- package/dist/ui/place/place.d.ts +17 -0
- package/dist/ui/place/place.d.ts.map +1 -0
- package/dist/ui/place/place_chip.d.ts +26 -0
- package/dist/ui/place/place_chip.d.ts.map +1 -0
- package/dist/ui/place/place_from_route.d.ts +9 -0
- package/dist/ui/place/place_from_route.d.ts.map +1 -0
- package/dist/ui/place/place_styles.d.ts +2 -0
- package/dist/ui/place/place_styles.d.ts.map +1 -0
- package/dist/ui/placement/clamp_launcher.d.ts +20 -0
- package/dist/ui/placement/clamp_launcher.d.ts.map +1 -0
- package/dist/ui/placement/clamp_panel.d.ts +13 -0
- package/dist/ui/placement/clamp_panel.d.ts.map +1 -0
- package/dist/ui/placement/collapse_styles.d.ts +2 -0
- package/dist/ui/placement/collapse_styles.d.ts.map +1 -0
- package/dist/ui/placement/dock_styles.d.ts +2 -0
- package/dist/ui/placement/dock_styles.d.ts.map +1 -0
- package/dist/ui/placement/embedded_styles.d.ts +2 -0
- package/dist/ui/placement/embedded_styles.d.ts.map +1 -0
- package/dist/ui/placement/launcher_drag.d.ts +49 -0
- package/dist/ui/placement/launcher_drag.d.ts.map +1 -0
- package/dist/ui/placement/launcher_placement.d.ts +77 -0
- package/dist/ui/placement/launcher_placement.d.ts.map +1 -0
- package/dist/ui/placement/launcher_styles.d.ts +2 -0
- package/dist/ui/placement/launcher_styles.d.ts.map +1 -0
- package/dist/ui/placement/page_styles.d.ts +2 -0
- package/dist/ui/placement/page_styles.d.ts.map +1 -0
- package/dist/ui/placement/panel_drag.d.ts +40 -0
- package/dist/ui/placement/panel_drag.d.ts.map +1 -0
- package/dist/ui/placement/panel_placement.d.ts +173 -0
- package/dist/ui/placement/panel_placement.d.ts.map +1 -0
- package/dist/ui/placement/place_widget.d.ts +31 -0
- package/dist/ui/placement/place_widget.d.ts.map +1 -0
- package/dist/ui/placement/preset_styles.d.ts +2 -0
- package/dist/ui/placement/preset_styles.d.ts.map +1 -0
- package/dist/ui/placement/resize_handle.d.ts +78 -0
- package/dist/ui/placement/resize_handle.d.ts.map +1 -0
- package/dist/ui/placement/resize_styles.d.ts +2 -0
- package/dist/ui/placement/resize_styles.d.ts.map +1 -0
- package/dist/ui/placement/sidebar_styles.d.ts +2 -0
- package/dist/ui/placement/sidebar_styles.d.ts.map +1 -0
- package/dist/ui/placement/small_viewport_styles.d.ts +2 -0
- package/dist/ui/placement/small_viewport_styles.d.ts.map +1 -0
- package/dist/ui/placement/surface_for.d.ts +93 -0
- package/dist/ui/placement/surface_for.d.ts.map +1 -0
- package/dist/ui/progress/prettify_tool_name.d.ts +11 -0
- package/dist/ui/progress/prettify_tool_name.d.ts.map +1 -0
- package/dist/ui/progress/run_announcer.d.ts +41 -0
- package/dist/ui/progress/run_announcer.d.ts.map +1 -0
- package/dist/ui/progress/run_notice.d.ts +21 -0
- package/dist/ui/progress/run_notice.d.ts.map +1 -0
- package/dist/ui/progress/run_notice_styles.d.ts +2 -0
- package/dist/ui/progress/run_notice_styles.d.ts.map +1 -0
- package/dist/ui/progress/subagent_panel.d.ts +101 -0
- package/dist/ui/progress/subagent_panel.d.ts.map +1 -0
- package/dist/ui/progress/subagent_progress.d.ts +57 -0
- package/dist/ui/progress/subagent_progress.d.ts.map +1 -0
- package/dist/ui/progress/subagent_update.d.ts +28 -0
- package/dist/ui/progress/subagent_update.d.ts.map +1 -0
- package/dist/ui/progress/thoughts_block.d.ts +57 -0
- package/dist/ui/progress/thoughts_block.d.ts.map +1 -0
- package/dist/ui/progress/thoughts_styles.d.ts +2 -0
- package/dist/ui/progress/thoughts_styles.d.ts.map +1 -0
- package/dist/ui/progress/tool_call_card.d.ts +167 -0
- package/dist/ui/progress/tool_call_card.d.ts.map +1 -0
- package/dist/ui/progress/tool_group_styles.d.ts +2 -0
- package/dist/ui/progress/tool_group_styles.d.ts.map +1 -0
- package/dist/ui/progress/tool_step_group.d.ts +50 -0
- package/dist/ui/progress/tool_step_group.d.ts.map +1 -0
- package/dist/ui/progress/tool_step_styles.d.ts +2 -0
- package/dist/ui/progress/tool_step_styles.d.ts.map +1 -0
- package/dist/ui/shell/adopt_styles.d.ts +28 -0
- package/dist/ui/shell/adopt_styles.d.ts.map +1 -0
- package/dist/ui/shell/build_header.d.ts +45 -0
- package/dist/ui/shell/build_header.d.ts.map +1 -0
- package/dist/ui/shell/build_launcher.d.ts +33 -0
- package/dist/ui/shell/build_launcher.d.ts.map +1 -0
- package/dist/ui/shell/collapse_glyph.d.ts +14 -0
- package/dist/ui/shell/collapse_glyph.d.ts.map +1 -0
- package/dist/ui/shell/frame_styles.d.ts +2 -0
- package/dist/ui/shell/frame_styles.d.ts.map +1 -0
- package/dist/ui/shell/glyph_slot.d.ts +7 -0
- package/dist/ui/shell/glyph_slot.d.ts.map +1 -0
- package/dist/ui/shell/header_button.d.ts +11 -0
- package/dist/ui/shell/header_button.d.ts.map +1 -0
- package/dist/ui/shell/icon_element.d.ts +12 -0
- package/dist/ui/shell/icon_element.d.ts.map +1 -0
- package/dist/ui/shell/is_unread_badge_enabled.d.ts +10 -0
- package/dist/ui/shell/is_unread_badge_enabled.d.ts.map +1 -0
- package/dist/ui/shell/read_launcher_icon_url.d.ts +8 -0
- package/dist/ui/shell/read_launcher_icon_url.d.ts.map +1 -0
- package/dist/ui/shell/theme_styles.d.ts +2 -0
- package/dist/ui/shell/theme_styles.d.ts.map +1 -0
- package/dist/ui/shell/token_styles.d.ts +2 -0
- package/dist/ui/shell/token_styles.d.ts.map +1 -0
- package/dist/ui/styles.d.ts +2 -0
- package/dist/ui/styles.d.ts.map +1 -0
- package/dist/ui/themes/classic_styles.d.ts +2 -0
- package/dist/ui/themes/classic_styles.d.ts.map +1 -0
- package/dist/ui/themes/classic_tokens.d.ts +2 -0
- package/dist/ui/themes/classic_tokens.d.ts.map +1 -0
- package/dist/ui/themes/code_tokens.d.ts +2 -0
- package/dist/ui/themes/code_tokens.d.ts.map +1 -0
- package/dist/ui/themes/ledger_styles.d.ts +2 -0
- package/dist/ui/themes/ledger_styles.d.ts.map +1 -0
- package/dist/ui/themes/ledger_tokens.d.ts +2 -0
- package/dist/ui/themes/ledger_tokens.d.ts.map +1 -0
- package/dist/ui/themes/modern_styles.d.ts +2 -0
- package/dist/ui/themes/modern_styles.d.ts.map +1 -0
- package/dist/ui/themes/quiet_styles.d.ts +2 -0
- package/dist/ui/themes/quiet_styles.d.ts.map +1 -0
- package/dist/ui/themes/scheme_styles.d.ts +2 -0
- package/dist/ui/themes/scheme_styles.d.ts.map +1 -0
- package/dist/ui/themes/soft_styles.d.ts +2 -0
- package/dist/ui/themes/soft_styles.d.ts.map +1 -0
- package/dist/ui/themes/soft_tokens.d.ts +2 -0
- package/dist/ui/themes/soft_tokens.d.ts.map +1 -0
- package/dist/ui/themes/theme_hosts.d.ts +15 -0
- package/dist/ui/themes/theme_hosts.d.ts.map +1 -0
- package/dist/ui/transcript/answer_actions.d.ts +50 -0
- package/dist/ui/transcript/answer_actions.d.ts.map +1 -0
- package/dist/ui/transcript/answer_stream.d.ts +56 -0
- package/dist/ui/transcript/answer_stream.d.ts.map +1 -0
- package/dist/ui/transcript/attachment_chip_styles.d.ts +2 -0
- package/dist/ui/transcript/attachment_chip_styles.d.ts.map +1 -0
- package/dist/ui/transcript/attachment_chips.d.ts +21 -0
- package/dist/ui/transcript/attachment_chips.d.ts.map +1 -0
- package/dist/ui/transcript/build_transcript.d.ts +21 -0
- package/dist/ui/transcript/build_transcript.d.ts.map +1 -0
- package/dist/ui/transcript/greeting_styles.d.ts +2 -0
- package/dist/ui/transcript/greeting_styles.d.ts.map +1 -0
- package/dist/ui/transcript/groups_tool_steps.d.ts +13 -0
- package/dist/ui/transcript/groups_tool_steps.d.ts.map +1 -0
- package/dist/ui/transcript/message_action_styles.d.ts +2 -0
- package/dist/ui/transcript/message_action_styles.d.ts.map +1 -0
- package/dist/ui/transcript/message_actions.d.ts +74 -0
- package/dist/ui/transcript/message_actions.d.ts.map +1 -0
- package/dist/ui/transcript/message_styles.d.ts +2 -0
- package/dist/ui/transcript/message_styles.d.ts.map +1 -0
- package/dist/ui/transcript/render_markdown.d.ts +40 -0
- package/dist/ui/transcript/render_markdown.d.ts.map +1 -0
- package/dist/ui/transcript/render_or_warn.d.ts +16 -0
- package/dist/ui/transcript/render_or_warn.d.ts.map +1 -0
- package/dist/ui/transcript/reveal_words.d.ts +8 -0
- package/dist/ui/transcript/reveal_words.d.ts.map +1 -0
- package/dist/ui/transcript/starter_chips.d.ts +21 -0
- package/dist/ui/transcript/starter_chips.d.ts.map +1 -0
- package/dist/ui/transcript/stick_to_bottom.d.ts +55 -0
- package/dist/ui/transcript/stick_to_bottom.d.ts.map +1 -0
- package/dist/ui/transcript/suggestion_chips.d.ts +29 -0
- package/dist/ui/transcript/suggestion_chips.d.ts.map +1 -0
- package/dist/ui/transcript/transcript.d.ts +196 -0
- package/dist/ui/transcript/transcript.d.ts.map +1 -0
- package/dist/ui/transcript/transcript_styles.d.ts +2 -0
- package/dist/ui/transcript/transcript_styles.d.ts.map +1 -0
- package/dist/ui/ui_strings.d.ts +352 -0
- package/dist/ui/ui_strings.d.ts.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +86 -3
- package/src/bundle.ts +2 -0
- package/src/chat.ts +2 -0
- package/src/constants.ts +650 -0
- package/src/core/activity_registration.ts +19 -0
- package/src/core/activity_registry.ts +133 -0
- package/src/core/activity_renderer.ts +19 -0
- package/src/core/ag_ui_chat.ts +3966 -0
- package/src/core/agui_client.ts +1028 -0
- package/src/core/attachment.ts +62 -0
- package/src/core/chat_registry.ts +53 -0
- package/src/core/client_seed.ts +27 -0
- package/src/core/conversation_store.ts +478 -0
- package/src/core/create_http_agent.ts +97 -0
- package/src/core/define_chat.ts +25 -0
- package/src/core/events/attachments_detail.ts +9 -0
- package/src/core/events/bar_height_detail.ts +5 -0
- package/src/core/events/custom_agent_detail.ts +7 -0
- package/src/core/events/dock_width_detail.ts +7 -0
- package/src/core/events/feedback_detail.ts +27 -0
- package/src/core/events/invalidate_detail.ts +15 -0
- package/src/core/events/maximize_detail.ts +4 -0
- package/src/core/events/run_finished_detail.ts +36 -0
- package/src/core/events/state_detail.ts +4 -0
- package/src/core/events/submit_detail.ts +8 -0
- package/src/core/events/thread_detail.ts +26 -0
- package/src/core/events/thread_title_detail.ts +7 -0
- package/src/core/events/toggle_detail.ts +4 -0
- package/src/core/events/tool_run.ts +10 -0
- package/src/core/events/unread_detail.ts +10 -0
- package/src/core/message_role.ts +4 -0
- package/src/core/read_flag.ts +13 -0
- package/src/core/read_json_attribute.ts +30 -0
- package/src/core/read_max_tool_rounds.ts +13 -0
- package/src/core/remote_conversation_store.ts +279 -0
- package/src/core/run_handlers.ts +524 -0
- package/src/core/run_index.ts +114 -0
- package/src/core/storage_scope.ts +291 -0
- package/src/core/tool_outcome.ts +39 -0
- package/src/core/transcribe_audio.ts +76 -0
- package/src/core/upload_attachment.ts +130 -0
- package/src/core/utils.ts +230 -0
- package/src/dom/animations.ts +341 -0
- package/src/dom/dom_driver.ts +91 -0
- package/src/dom/highlight_overlay.ts +204 -0
- package/src/dom/native_setter.ts +40 -0
- package/src/dom/ring_color.ts +206 -0
- package/src/dom/utils.ts +5 -0
- package/src/index.ts +220 -0
- package/src/skills/fill_template.ts +31 -0
- package/src/skills/parse_skills.ts +31 -0
- package/src/skills/skill.ts +32 -0
- package/src/skills/skill_catalog.ts +172 -0
- package/src/skills/skill_name_from.ts +19 -0
- package/src/tools/chat_surface_tools.ts +183 -0
- package/src/tools/client_tool_registry.ts +80 -0
- package/src/tools/is_destructive.ts +17 -0
- package/src/tools/is_navigates.ts +12 -0
- package/src/tools/page_action_tools.ts +123 -0
- package/src/tools/page_map.ts +26 -0
- package/src/tools/page_state.ts +57 -0
- package/src/tools/parse_tool_catalog.ts +41 -0
- package/src/tools/route_map.ts +132 -0
- package/src/tools/tool_catalog.ts +334 -0
- package/src/tools/tool_dispatch.ts +453 -0
- package/src/ui/charts/chart_block.ts +519 -0
- package/src/ui/charts/chart_spec_from.ts +125 -0
- package/src/ui/charts/chart_styles.ts +63 -0
- package/src/ui/charts/chart_tool.ts +72 -0
- package/src/ui/composer/attachment_styles.ts +71 -0
- package/src/ui/composer/attachment_tray.ts +295 -0
- package/src/ui/composer/auto_grow.ts +12 -0
- package/src/ui/composer/build_composer.ts +114 -0
- package/src/ui/composer/composer_attachments.ts +324 -0
- package/src/ui/composer/composer_styles.ts +177 -0
- package/src/ui/composer/composer_voice.ts +93 -0
- package/src/ui/composer/skill_styles.ts +120 -0
- package/src/ui/composer/skills_menu.ts +188 -0
- package/src/ui/composer/voice_input.ts +282 -0
- package/src/ui/excerpts/attach_copy_buttons.ts +73 -0
- package/src/ui/excerpts/copy_payload.ts +156 -0
- package/src/ui/excerpts/page_quote_offer.ts +203 -0
- package/src/ui/excerpts/place_offer.ts +24 -0
- package/src/ui/excerpts/quote_selection.ts +345 -0
- package/src/ui/excerpts/transcript_quote_offer.ts +175 -0
- package/src/ui/fill_ui_string.ts +41 -0
- package/src/ui/history/checkpoint_menu.ts +300 -0
- package/src/ui/history/conversation_history.ts +1169 -0
- package/src/ui/history/history_styles.ts +492 -0
- package/src/ui/history/relative_time.ts +50 -0
- package/src/ui/history/thread_drawer.ts +471 -0
- package/src/ui/history/utils.ts +11 -0
- package/src/ui/interrupts/approval_card.ts +202 -0
- package/src/ui/interrupts/approval_styles.ts +52 -0
- package/src/ui/interrupts/confirmation_card.ts +138 -0
- package/src/ui/interrupts/confirmation_styles.ts +114 -0
- package/src/ui/interrupts/pending_decision.ts +33 -0
- package/src/ui/interrupts/question_card.ts +213 -0
- package/src/ui/interrupts/question_styles.ts +73 -0
- package/src/ui/place/place.ts +16 -0
- package/src/ui/place/place_chip.ts +146 -0
- package/src/ui/place/place_from_route.ts +27 -0
- package/src/ui/place/place_styles.ts +108 -0
- package/src/ui/placement/clamp_launcher.ts +38 -0
- package/src/ui/placement/clamp_panel.ts +30 -0
- package/src/ui/placement/collapse_styles.ts +472 -0
- package/src/ui/placement/dock_styles.ts +116 -0
- package/src/ui/placement/embedded_styles.ts +14 -0
- package/src/ui/placement/launcher_drag.ts +206 -0
- package/src/ui/placement/launcher_placement.ts +133 -0
- package/src/ui/placement/launcher_styles.ts +189 -0
- package/src/ui/placement/page_styles.ts +47 -0
- package/src/ui/placement/panel_drag.ts +138 -0
- package/src/ui/placement/panel_placement.ts +1975 -0
- package/src/ui/placement/place_widget.ts +64 -0
- package/src/ui/placement/preset_styles.ts +49 -0
- package/src/ui/placement/resize_handle.ts +229 -0
- package/src/ui/placement/resize_styles.ts +201 -0
- package/src/ui/placement/sidebar_styles.ts +113 -0
- package/src/ui/placement/small_viewport_styles.ts +70 -0
- package/src/ui/placement/surface_for.ts +183 -0
- package/src/ui/progress/prettify_tool_name.ts +16 -0
- package/src/ui/progress/run_announcer.ts +67 -0
- package/src/ui/progress/run_notice.ts +61 -0
- package/src/ui/progress/run_notice_styles.ts +52 -0
- package/src/ui/progress/subagent_panel.ts +227 -0
- package/src/ui/progress/subagent_progress.ts +200 -0
- package/src/ui/progress/subagent_update.ts +89 -0
- package/src/ui/progress/thoughts_block.ts +165 -0
- package/src/ui/progress/thoughts_styles.ts +74 -0
- package/src/ui/progress/tool_call_card.ts +429 -0
- package/src/ui/progress/tool_group_styles.ts +313 -0
- package/src/ui/progress/tool_step_group.ts +317 -0
- package/src/ui/progress/tool_step_styles.ts +486 -0
- package/src/ui/shell/adopt_styles.ts +34 -0
- package/src/ui/shell/build_header.ts +121 -0
- package/src/ui/shell/build_launcher.ts +79 -0
- package/src/ui/shell/collapse_glyph.ts +42 -0
- package/src/ui/shell/frame_styles.ts +147 -0
- package/src/ui/shell/glyph_slot.ts +12 -0
- package/src/ui/shell/header_button.ts +22 -0
- package/src/ui/shell/icon_element.ts +33 -0
- package/src/ui/shell/is_unread_badge_enabled.ts +11 -0
- package/src/ui/shell/read_launcher_icon_url.ts +9 -0
- package/src/ui/shell/theme_styles.ts +11 -0
- package/src/ui/shell/token_styles.ts +480 -0
- package/src/ui/styles.ts +110 -0
- package/src/ui/themes/classic_styles.ts +32 -0
- package/src/ui/themes/classic_tokens.ts +51 -0
- package/src/ui/themes/code_tokens.ts +21 -0
- package/src/ui/themes/ledger_styles.ts +169 -0
- package/src/ui/themes/ledger_tokens.ts +33 -0
- package/src/ui/themes/modern_styles.ts +80 -0
- package/src/ui/themes/quiet_styles.ts +118 -0
- package/src/ui/themes/scheme_styles.ts +26 -0
- package/src/ui/themes/soft_styles.ts +149 -0
- package/src/ui/themes/soft_tokens.ts +29 -0
- package/src/ui/themes/theme_hosts.ts +14 -0
- package/src/ui/transcript/answer_actions.ts +165 -0
- package/src/ui/transcript/answer_stream.ts +123 -0
- package/src/ui/transcript/attachment_chip_styles.ts +116 -0
- package/src/ui/transcript/attachment_chips.ts +82 -0
- package/src/ui/transcript/build_transcript.ts +67 -0
- package/src/ui/transcript/greeting_styles.ts +171 -0
- package/src/ui/transcript/groups_tool_steps.ts +16 -0
- package/src/ui/transcript/message_action_styles.ts +155 -0
- package/src/ui/transcript/message_actions.ts +234 -0
- package/src/ui/transcript/message_styles.ts +262 -0
- package/src/ui/transcript/render_markdown.ts +181 -0
- package/src/ui/transcript/render_or_warn.ts +22 -0
- package/src/ui/transcript/reveal_words.ts +41 -0
- package/src/ui/transcript/starter_chips.ts +42 -0
- package/src/ui/transcript/stick_to_bottom.ts +126 -0
- package/src/ui/transcript/suggestion_chips.ts +73 -0
- package/src/ui/transcript/transcript.ts +555 -0
- package/src/ui/transcript/transcript_styles.ts +153 -0
- package/src/ui/ui_strings.ts +550 -0
- package/src/version.ts +1 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import type { Tool } from "@ag-ui/core";
|
|
2
|
+
import { READ_PAGE_TOOL, X_SUMMARY_KEY } from "../constants.js";
|
|
3
|
+
import { commaTokens } from "../core/utils.js";
|
|
4
|
+
import type { PendingDecision } from "../ui/interrupts/pending_decision.js";
|
|
5
|
+
import {
|
|
6
|
+
type QuestionRenderer,
|
|
7
|
+
type QuestionRequest,
|
|
8
|
+
requestQuestion,
|
|
9
|
+
} from "../ui/interrupts/question_card.js";
|
|
10
|
+
import type { UiStrings } from "../ui/ui_strings.js";
|
|
11
|
+
import { type ChatSurface, createChatSurfaceTools } from "./chat_surface_tools.js";
|
|
12
|
+
import { type ClientTool, ClientToolRegistry } from "./client_tool_registry.js";
|
|
13
|
+
import { createPageActionTools, PAGE_ACTIONS } from "./page_action_tools.js";
|
|
14
|
+
import type { PageMap } from "./page_map.js";
|
|
15
|
+
import { createPageStateTools, type PageState } from "./page_state.js";
|
|
16
|
+
import { parseToolCatalog, type ToolCatalogEntry } from "./parse_tool_catalog.js";
|
|
17
|
+
import { createRouteTools, type RouteMap } from "./route_map.js";
|
|
18
|
+
|
|
19
|
+
/** What the tool catalog needs from the element that owns it. */
|
|
20
|
+
export interface ToolCatalogHost {
|
|
21
|
+
/** The custom element: its tool attributes, and the surface the chat tools drive. */
|
|
22
|
+
readonly element: HTMLElement & ChatSurface;
|
|
23
|
+
/** The element's `routeMap`, read per call. */
|
|
24
|
+
readonly routeMap: () => RouteMap;
|
|
25
|
+
/** The element's `navigate`, read per call. */
|
|
26
|
+
readonly navigate: () => ((path: string) => void) | null;
|
|
27
|
+
/** The element's `getPageMap`, read per call. */
|
|
28
|
+
readonly getPageMap: () => (() => PageMap) | null;
|
|
29
|
+
/** Whether the user withheld the place, which withholds the page with it. */
|
|
30
|
+
readonly pageWithheld: () => boolean;
|
|
31
|
+
/** The element's `resolvePageTarget`, called per target. */
|
|
32
|
+
readonly resolvePageTarget: (target: string) => HTMLElement | null;
|
|
33
|
+
/** The element's `getTools`, which a host may have replaced. */
|
|
34
|
+
readonly getTools: () => Tool[];
|
|
35
|
+
/** The element's `askUser` flag. */
|
|
36
|
+
readonly askUser: () => boolean;
|
|
37
|
+
/** The element's `askUserRenderer`. */
|
|
38
|
+
readonly askUserRenderer: () => QuestionRenderer | null;
|
|
39
|
+
/** The decision a run is suspended on, which a Stop abandons. */
|
|
40
|
+
readonly decision: PendingDecision;
|
|
41
|
+
/**
|
|
42
|
+
* Mark the card of ``callId`` as asking the user, or no longer. The call id is
|
|
43
|
+
* absent for a handler run outside a tool call, which has no card to mark.
|
|
44
|
+
*/
|
|
45
|
+
readonly setAsking: (callId: string | undefined, asking: boolean) => void;
|
|
46
|
+
/** The current answer group, opening one if none is open. */
|
|
47
|
+
readonly ensureGroup: () => HTMLDivElement;
|
|
48
|
+
/** The resolved string table. */
|
|
49
|
+
readonly strings: () => UiStrings;
|
|
50
|
+
/** Remove the pending indicator if shown. */
|
|
51
|
+
readonly hidePending: () => void;
|
|
52
|
+
/** Update the empty state after the transcript changed. */
|
|
53
|
+
readonly updateEmptyState: () => void;
|
|
54
|
+
/** Keep the transcript at its foot, if the reader is there. */
|
|
55
|
+
readonly follow: () => void;
|
|
56
|
+
/** The fetch options every request the element makes carries. */
|
|
57
|
+
readonly fetchInit: (url: string) => RequestInit | undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The frontend tools the agent is offered: the host's registered tools, the
|
|
62
|
+
* built-in ones the element's configuration switches on, what the current round
|
|
63
|
+
* advertised, and the server's catalog of labels for the tools it runs itself.
|
|
64
|
+
*
|
|
65
|
+
* Owned one-to-one by an `<ag-ui-chat>`, and holding no state outside the
|
|
66
|
+
* instance.
|
|
67
|
+
*/
|
|
68
|
+
export class ToolCatalog {
|
|
69
|
+
readonly #host: ToolCatalogHost;
|
|
70
|
+
/** The `data-tools-url` catalog by tool name: the base layer behind `toolSummaries`, filled once on connect. */
|
|
71
|
+
#toolCatalog: Record<string, ToolCatalogEntry> = {};
|
|
72
|
+
/**
|
|
73
|
+
* The tool names the current round handed the agent, snapshotted as the catalog went out.
|
|
74
|
+
*
|
|
75
|
+
* The registry is mount-wide but `getTools` is per-run, so a call naming a tool this run
|
|
76
|
+
* withheld must not reach a handler that is merely still registered. Not re-asked at
|
|
77
|
+
* dispatch: the provider is a function and may answer differently. Empty until the first
|
|
78
|
+
* round advertises, which always precedes the calls that round produces.
|
|
79
|
+
*/
|
|
80
|
+
#advertisedTools: ReadonlySet<string> = new Set();
|
|
81
|
+
readonly #toolRegistry = new ClientToolRegistry();
|
|
82
|
+
|
|
83
|
+
constructor(host: ToolCatalogHost) {
|
|
84
|
+
this.#host = host;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The registration behind `AgUiChat.registerTool`, whose doc is the contract. */
|
|
88
|
+
register(tool: ClientTool): void {
|
|
89
|
+
this.#toolRegistry.register(tool);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The binding behind `AgUiChat.registerPageState`, whose doc is the contract. */
|
|
93
|
+
registerPageState(binding: PageState): void {
|
|
94
|
+
for (const tool of createPageStateTools(binding)) {
|
|
95
|
+
this.#toolRegistry.register(tool);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Whether a tool of this name is registered, built-ins aside. */
|
|
100
|
+
has(name: string): boolean {
|
|
101
|
+
return this.#toolRegistry.has(name);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The catalog behind the default `AgUiChat.getTools`, whose doc is the contract. */
|
|
105
|
+
defaultTools(): Tool[] {
|
|
106
|
+
return [
|
|
107
|
+
...this.#builtinTools().map((t) => ({
|
|
108
|
+
name: t.name,
|
|
109
|
+
description: t.description,
|
|
110
|
+
parameters: t.parameters,
|
|
111
|
+
})),
|
|
112
|
+
...this.#toolRegistry.tools(),
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The catalog for the round about to start, remembering what it offered.
|
|
118
|
+
*
|
|
119
|
+
* Every path to a frontend tool goes through here first — the client asks
|
|
120
|
+
* for `RunAgentInput.tools` at the top of each round — so this is the one
|
|
121
|
+
* place that can know what the agent was actually told about.
|
|
122
|
+
*/
|
|
123
|
+
advertise(): Tool[] {
|
|
124
|
+
const tools = this.#host.getTools();
|
|
125
|
+
this.#advertisedTools = new Set(tools.map((tool) => tool.name));
|
|
126
|
+
return tools;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Whether the current round offered a tool of this name. */
|
|
130
|
+
wasAdvertised(name: string): boolean {
|
|
131
|
+
return this.#advertisedTools.has(name);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Resolve a tool by name: built-in tools first, then the registry. */
|
|
135
|
+
resolve(name: string): ClientTool | null {
|
|
136
|
+
const builtin = this.#builtinTools().find((t) => t.name === name);
|
|
137
|
+
if (builtin !== undefined) {
|
|
138
|
+
return builtin;
|
|
139
|
+
}
|
|
140
|
+
return this.#toolRegistry.has(name) ? this.#toolRegistry.get(name) : null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The server catalog's label for a tool, if it sent one. */
|
|
144
|
+
summary(name: string): string | undefined {
|
|
145
|
+
return this.#toolCatalog[name]?.summary;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Fetch the server tool-label catalog from `data-tools-url`, if set. */
|
|
149
|
+
async fetchCatalog(): Promise<void> {
|
|
150
|
+
const url = this.#host.element.getAttribute("data-tools-url");
|
|
151
|
+
if (url === null) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const response = await fetch(url, this.#host.fetchInit(url));
|
|
156
|
+
this.#toolCatalog = parseToolCatalog(await response.json());
|
|
157
|
+
} catch {
|
|
158
|
+
// Network/parse failure: cards fall back to toolSummaries / raw names.
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The built-in `route.*` tools, present only when a route map is set. */
|
|
163
|
+
#routeTools(): ClientTool[] {
|
|
164
|
+
if (this.#host.routeMap().length === 0) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
return createRouteTools(
|
|
168
|
+
() => this.#host.routeMap(),
|
|
169
|
+
() => this.#host.navigate(),
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The built-in `read_page` tool, present only when a `getPageMap`
|
|
175
|
+
* provider is set and the user has not withheld the place. A *pull* the
|
|
176
|
+
* agent can call mid-turn to see the page after it has acted (the
|
|
177
|
+
* auto-injected context is a send-time snapshot).
|
|
178
|
+
*/
|
|
179
|
+
#pageTools(): ClientTool[] {
|
|
180
|
+
const getPageMap = this.#host.getPageMap();
|
|
181
|
+
if (getPageMap === null || this.#host.pageWithheld()) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
return [
|
|
185
|
+
{
|
|
186
|
+
name: READ_PAGE_TOOL,
|
|
187
|
+
description:
|
|
188
|
+
"Read the current page's structure (fields, buttons, route). Call after " +
|
|
189
|
+
"acting to observe the result within the same turn.",
|
|
190
|
+
parameters: {
|
|
191
|
+
type: "object",
|
|
192
|
+
properties: {},
|
|
193
|
+
required: [],
|
|
194
|
+
[X_SUMMARY_KEY]: "Read the page",
|
|
195
|
+
},
|
|
196
|
+
handler: () => getPageMap(),
|
|
197
|
+
},
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Opt-in page-action tools (`scroll_to` / `drag_and_drop`), enabled per token
|
|
203
|
+
* via the `data-page-actions` attribute (e.g. `"scroll,drag"`). Targets resolve
|
|
204
|
+
* through `resolvePageTarget` so a host controls the agent's interaction
|
|
205
|
+
* surface; absent attribute ⇒ no tools registered.
|
|
206
|
+
*/
|
|
207
|
+
#pageActionTools(): ClientTool[] {
|
|
208
|
+
const attr = this.#host.element.getAttribute("data-page-actions");
|
|
209
|
+
if (attr === null) {
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
const enabled = new Set(commaTokens(attr));
|
|
213
|
+
return [
|
|
214
|
+
...createPageActionTools(enabled, (target) => this.#host.resolvePageTarget(target)),
|
|
215
|
+
...(enabled.has(PAGE_ACTIONS.CHAT) ? createChatSurfaceTools(this.#host.element) : []),
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** All built-in (route + page + page-action + ask_user) frontend tools. */
|
|
220
|
+
#builtinTools(): ClientTool[] {
|
|
221
|
+
return [
|
|
222
|
+
...this.#routeTools(),
|
|
223
|
+
...this.#pageTools(),
|
|
224
|
+
...this.#pageActionTools(),
|
|
225
|
+
...this.#askUserTool(),
|
|
226
|
+
];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The built-in `ask_user` frontend tool, or `[]` when `askUser` is off.
|
|
231
|
+
*
|
|
232
|
+
* The agent calls it, the client executes it locally through the normal
|
|
233
|
+
* frontend-tool path by rendering a {@link requestQuestion} card, and the
|
|
234
|
+
* answer flows back as the tool result. No new protocol.
|
|
235
|
+
*/
|
|
236
|
+
#askUserTool(): ClientTool[] {
|
|
237
|
+
if (!this.#host.askUser()) {
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
return [
|
|
241
|
+
{
|
|
242
|
+
name: "ask_user",
|
|
243
|
+
description:
|
|
244
|
+
"Ask the user a question and wait for their answer. Provide `options` for a " +
|
|
245
|
+
"multiple-choice prompt; set `allow_custom` to also accept a free-text answer.",
|
|
246
|
+
parameters: {
|
|
247
|
+
type: "object",
|
|
248
|
+
properties: {
|
|
249
|
+
question: { type: "string", description: "The question to ask the user." },
|
|
250
|
+
options: {
|
|
251
|
+
type: "array",
|
|
252
|
+
items: { type: "string" },
|
|
253
|
+
description: "Preset choices offered as radio buttons.",
|
|
254
|
+
},
|
|
255
|
+
allow_custom: {
|
|
256
|
+
type: "boolean",
|
|
257
|
+
description: "Allow a free-text answer in addition to any options.",
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
required: ["question"],
|
|
261
|
+
},
|
|
262
|
+
handler: (args, callId) => this.#askUser(args, callId),
|
|
263
|
+
},
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** Render the `ask_user` question card and resolve with the user's answer. */
|
|
268
|
+
async #askUser(args: Record<string, unknown>, callId: string | undefined): Promise<string> {
|
|
269
|
+
const question = typeof args["question"] === "string" ? args["question"] : "";
|
|
270
|
+
const request: QuestionRequest = { question };
|
|
271
|
+
const rawOptions = args["options"];
|
|
272
|
+
if (Array.isArray(rawOptions)) {
|
|
273
|
+
request.options = rawOptions.filter((option): option is string => typeof option === "string");
|
|
274
|
+
}
|
|
275
|
+
if (args["allow_custom"] === true) {
|
|
276
|
+
request.allowCustom = true;
|
|
277
|
+
}
|
|
278
|
+
// A Stop aborts the signal, resolving the card with an empty answer.
|
|
279
|
+
const signal = this.#host.decision.open();
|
|
280
|
+
this.#host.hidePending();
|
|
281
|
+
const builtIn = (): Promise<string> =>
|
|
282
|
+
requestQuestion(this.#host.ensureGroup(), request, {
|
|
283
|
+
signal,
|
|
284
|
+
strings: this.#host.strings(),
|
|
285
|
+
});
|
|
286
|
+
const renderer = this.#host.askUserRenderer();
|
|
287
|
+
let answer: string;
|
|
288
|
+
// Asking until answered, stopped or failed, so the step row does not read as running.
|
|
289
|
+
this.#host.setAsking(callId, true);
|
|
290
|
+
try {
|
|
291
|
+
if (renderer === null) {
|
|
292
|
+
answer = await builtIn();
|
|
293
|
+
} else {
|
|
294
|
+
// Called on the element, as `this.askUserRenderer(...)` always was.
|
|
295
|
+
// Awaited here, not in a helper, to keep the microtask count of an answering renderer.
|
|
296
|
+
try {
|
|
297
|
+
answer = await renderer.call(this.#host.element, request, { signal });
|
|
298
|
+
} catch (error) {
|
|
299
|
+
answer = await this.#afterRendererFailed(error, signal, callId, builtIn);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} finally {
|
|
303
|
+
this.#host.setAsking(callId, false);
|
|
304
|
+
}
|
|
305
|
+
this.#host.decision.close();
|
|
306
|
+
this.#host.updateEmptyState();
|
|
307
|
+
this.#host.follow();
|
|
308
|
+
return answer;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Answer an `ask_user` call whose host renderer failed: the built-in card asks instead.
|
|
313
|
+
*
|
|
314
|
+
* A renderer is presentation, not policy, so its failure must neither reach the agent as
|
|
315
|
+
* the tool result nor leave the pending decision open. A rejection after a Stop is the
|
|
316
|
+
* signal working: it resolves empty and says nothing.
|
|
317
|
+
*/
|
|
318
|
+
#afterRendererFailed(
|
|
319
|
+
error: unknown,
|
|
320
|
+
signal: AbortSignal,
|
|
321
|
+
callId: string | undefined,
|
|
322
|
+
builtIn: () => Promise<string>,
|
|
323
|
+
): Promise<string> {
|
|
324
|
+
if (signal.aborted) {
|
|
325
|
+
return Promise.resolve("");
|
|
326
|
+
}
|
|
327
|
+
// Named by call id: the model can ask the same question twice in a turn.
|
|
328
|
+
console.warn(
|
|
329
|
+
`ag-ui-chat: askUserRenderer failed for tool call ${callId}, so the built-in question card asks instead`,
|
|
330
|
+
error,
|
|
331
|
+
);
|
|
332
|
+
return builtIn();
|
|
333
|
+
}
|
|
334
|
+
}
|