@artooi/agents-web-components 0.0.0-stage → 0.1.1
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 +77 -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,291 @@
|
|
|
1
|
+
import { randomUUID } from "@ag-ui/client";
|
|
2
|
+
import {
|
|
3
|
+
type ClientConversationStore,
|
|
4
|
+
SessionStorageStore,
|
|
5
|
+
type WriteFailureReport,
|
|
6
|
+
writeStoredItem,
|
|
7
|
+
} from "./conversation_store.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Storage namespaces already spoken for in this document.
|
|
11
|
+
*
|
|
12
|
+
* Per document rather than per origin, and released on disconnect, because the
|
|
13
|
+
* question it answers is "is another element on this page using these keys right
|
|
14
|
+
* now" — not "has anything ever used them". A registry that never released would
|
|
15
|
+
* turn every remount, and every framework re-render that moves the node, into a
|
|
16
|
+
* false collision that costs the element its own conversation.
|
|
17
|
+
*
|
|
18
|
+
* Module-level on purpose, and the one piece of shared mutable state the
|
|
19
|
+
* repository's `CLAUDE.md` exempts from its rule against it: the question is
|
|
20
|
+
* about the *other* live elements, which no instance field can answer. See the
|
|
21
|
+
* three conditions recorded there before adding anything beside it.
|
|
22
|
+
*/
|
|
23
|
+
const CLAIMED_NAMESPACES = new Set<string>();
|
|
24
|
+
|
|
25
|
+
/** What the storage scope needs from the element that owns it. */
|
|
26
|
+
export interface StorageScopeHost {
|
|
27
|
+
/** The element's `id`, the namespace it prefers. */
|
|
28
|
+
readonly id: () => string;
|
|
29
|
+
/** The element's `endpoint`, the namespace it falls back to. */
|
|
30
|
+
readonly endpoint: () => string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Which storage keys are this element's: the namespace it claims in the
|
|
35
|
+
* document, the key a layout preference is stored under, and the built-in
|
|
36
|
+
* conversation store scoped to it.
|
|
37
|
+
*
|
|
38
|
+
* Owned one-to-one by an `<ag-ui-chat>`. The one thing it shares is the record
|
|
39
|
+
* of claimed namespaces above, which is what keeps two elements apart.
|
|
40
|
+
*/
|
|
41
|
+
export class StorageScope {
|
|
42
|
+
readonly #host: StorageScopeHost;
|
|
43
|
+
// Per-instance suffix for the origin-scoped storage keys (collapsed / theme /
|
|
44
|
+
// size), so two instances on one origin don't clobber each other. Empty ⇒ the
|
|
45
|
+
// root keys, for an element with nothing to key on. Resolved on connect; the
|
|
46
|
+
// conversation adds `user-key` on top of it, see conversationNamespace.
|
|
47
|
+
#storageNs = "";
|
|
48
|
+
// The entry this element put in CLAIMED_NAMESPACES, to take back out on
|
|
49
|
+
// disconnect. `null` when it claimed nothing (no id, no endpoint, or it lost
|
|
50
|
+
// the claim to an element that mounted first).
|
|
51
|
+
#claimedNs: string | null = null;
|
|
52
|
+
// The fallback namespace minted when the preferred one was already claimed,
|
|
53
|
+
// with the preferred value it was minted for — so the element keeps it across
|
|
54
|
+
// remounts, but re-resolves if the host answers the warning with an `id`.
|
|
55
|
+
#generatedNs = "";
|
|
56
|
+
#generatedFor = "";
|
|
57
|
+
// The `sessionStorage`-backed store this scope handed out, which the element
|
|
58
|
+
// may therefore re-scope on a principal change -- while it is still the store
|
|
59
|
+
// in use, which rescopeStore asks, since a host can assign its own at any
|
|
60
|
+
// time. `null` until connecting has met the built-in store at all. A store of
|
|
61
|
+
// the host's own kind is never held here: the element does not know its
|
|
62
|
+
// keying and must not guess at it.
|
|
63
|
+
#builtinStore: SessionStorageStore | null = null;
|
|
64
|
+
readonly #writeFailure: WriteFailureReport = { reported: false };
|
|
65
|
+
|
|
66
|
+
constructor(host: StorageScopeHost) {
|
|
67
|
+
this.#host = host;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Resolve the per-instance storage namespace, before any key is read or
|
|
72
|
+
* written, so this instance doesn't share collapsed/theme/thread state with
|
|
73
|
+
* another on the same origin.
|
|
74
|
+
*/
|
|
75
|
+
claim(): void {
|
|
76
|
+
this.#storageNs = this.#claimNamespace();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Give the namespace back. A disconnect is not necessarily a farewell — a
|
|
81
|
+
* DOM move and a framework re-render both look like one — and an element
|
|
82
|
+
* that could not reclaim its own namespace on the way back in would lose its
|
|
83
|
+
* conversation to a false collision.
|
|
84
|
+
*/
|
|
85
|
+
release(): void {
|
|
86
|
+
if (this.#claimedNs !== null) {
|
|
87
|
+
CLAIMED_NAMESPACES.delete(this.#claimedNs);
|
|
88
|
+
this.#claimedNs = null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The conversation store's namespace: this element's, scoped to the principal
|
|
94
|
+
* `key` names.
|
|
95
|
+
*
|
|
96
|
+
* Only the conversation is principal-scoped. The panel's own collapsed / size
|
|
97
|
+
* / theme preferences stay on the element's own namespace, because they are
|
|
98
|
+
* this element's UI state rather than anyone's data — they carry no word of
|
|
99
|
+
* what was said — and because they are read once while connecting, so
|
|
100
|
+
* re-scoping them under a live element would rearrange the panel around a
|
|
101
|
+
* user who had only just signed in.
|
|
102
|
+
*/
|
|
103
|
+
conversationNamespace(key: string): string {
|
|
104
|
+
return key === "" ? this.#storageNs : `${this.#storageNs}#${key}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Namespace the built-in default store, and hand back the store to use. A
|
|
109
|
+
* host-injected store is used verbatim; the built-in one is remembered
|
|
110
|
+
* either way, because it is the element's own store and a later `user-key`
|
|
111
|
+
* change may move it to another namespace.
|
|
112
|
+
*/
|
|
113
|
+
scopeStore(store: ClientConversationStore, key: string): ClientConversationStore {
|
|
114
|
+
if (!(store instanceof SessionStorageStore)) {
|
|
115
|
+
return store;
|
|
116
|
+
}
|
|
117
|
+
const namespace = this.conversationNamespace(key);
|
|
118
|
+
this.#builtinStore = namespace === "" ? store : new SessionStorageStore(namespace);
|
|
119
|
+
return this.#builtinStore;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Rebuild the built-in store under `namespace`, or `null` when `current` --
|
|
124
|
+
* the store the element is using now, unwrapped from any remote it wrapped
|
|
125
|
+
* it in -- is not the one this scope handed out.
|
|
126
|
+
*
|
|
127
|
+
* Asked of the store in use rather than of what connecting remembered,
|
|
128
|
+
* because the two part company the moment a host assigns a store of its own
|
|
129
|
+
* to a connected element. Remembering was enough to tell a host's store from
|
|
130
|
+
* the built-in one at connect; after it, the built-in one was still
|
|
131
|
+
* remembered, so a key change replaced the host's store with a fresh
|
|
132
|
+
* `sessionStorage` one -- and a host that had chosen to keep message bodies
|
|
133
|
+
* off the client found every one of them cached in the tab again. A store
|
|
134
|
+
* the element did not make holds its data somewhere the element cannot see,
|
|
135
|
+
* and has to scope itself.
|
|
136
|
+
*/
|
|
137
|
+
rescopeStore(current: ClientConversationStore, namespace: string): SessionStorageStore | null {
|
|
138
|
+
if (current !== this.#builtinStore) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
this.#builtinStore = new SessionStorageStore(namespace);
|
|
142
|
+
return this.#builtinStore;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** This instance's namespaced form of an origin-scoped storage key. */
|
|
146
|
+
key(base: string): string {
|
|
147
|
+
return this.#storageNs === "" ? base : `${base}:${this.#storageNs}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Read a namespaced origin-scoped value. */
|
|
151
|
+
readScopedItem(base: string): string | null {
|
|
152
|
+
return sessionStorage.getItem(this.key(base));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Read a layout preference: where the widget sits, how big it is, which
|
|
157
|
+
* theme it wears.
|
|
158
|
+
*
|
|
159
|
+
* These live in `localStorage` rather than beside the transcript, because a
|
|
160
|
+
* layout preference is not a conversation. The transcript is deliberately
|
|
161
|
+
* per-tab -- two tabs are two conversations, and closing the tab ends it --
|
|
162
|
+
* and everything else inherited that scoping without earning it. A user who
|
|
163
|
+
* dragged the panel clear of their own UI did it again in the next tab, and
|
|
164
|
+
* again after every restart.
|
|
165
|
+
*
|
|
166
|
+
* Whether the widget is *currently open* stays per-tab with the transcript.
|
|
167
|
+
* It is a statement about this tab rather than a preference: carrying it
|
|
168
|
+
* across would pop the panel open on every new tab because it was opened
|
|
169
|
+
* once, somewhere else.
|
|
170
|
+
*
|
|
171
|
+
* Falls back to the per-tab copy, which is all a browser that denies
|
|
172
|
+
* `localStorage` has.
|
|
173
|
+
*/
|
|
174
|
+
readPreference(base: string): string | null {
|
|
175
|
+
try {
|
|
176
|
+
const stored = localStorage.getItem(this.key(base));
|
|
177
|
+
if (stored !== null) {
|
|
178
|
+
return stored;
|
|
179
|
+
}
|
|
180
|
+
} catch {
|
|
181
|
+
// Fall through to the per-tab copy below.
|
|
182
|
+
}
|
|
183
|
+
return this.readScopedItem(base);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Persist a layout preference as durably as this browser allows: to
|
|
188
|
+
* `localStorage` so it outlives the tab, and to the per-tab store as well.
|
|
189
|
+
*
|
|
190
|
+
* The second write is not redundancy for its own sake. A privacy mode can
|
|
191
|
+
* deny `localStorage` while allowing `sessionStorage`, and losing the
|
|
192
|
+
* durable copy should degrade to the per-tab behaviour this replaced rather
|
|
193
|
+
* than to no persistence at all. The read above prefers the durable copy, so
|
|
194
|
+
* a tab that has both cannot be shadowed by its own stale one.
|
|
195
|
+
*
|
|
196
|
+
* Neither write is worth an exception. A refused per-tab write warns once
|
|
197
|
+
* per scope rather than once per write, because the size path writes on
|
|
198
|
+
* every step.
|
|
199
|
+
*/
|
|
200
|
+
writePreference(base: string, value: string): void {
|
|
201
|
+
const key = this.key(base);
|
|
202
|
+
try {
|
|
203
|
+
localStorage.setItem(key, value);
|
|
204
|
+
} catch {
|
|
205
|
+
// Quota, or a store that denies writes.
|
|
206
|
+
}
|
|
207
|
+
writeStoredItem(key, value, this.#writeFailure);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Write a per-tab value under this scope's key, sharing its one refused-write warning. */
|
|
211
|
+
writeSession(base: string, value: string): void {
|
|
212
|
+
writeStoredItem(this.key(base), value, this.#writeFailure);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Drop a layout preference from both stores.
|
|
217
|
+
*
|
|
218
|
+
* The mirror of {@link writePreference}, and it has to clear both for the
|
|
219
|
+
* same reason that writes both: leaving either copy behind means the value
|
|
220
|
+
* comes back on the next read.
|
|
221
|
+
*/
|
|
222
|
+
clearPreference(base: string): void {
|
|
223
|
+
const key = this.key(base);
|
|
224
|
+
try {
|
|
225
|
+
localStorage.removeItem(key);
|
|
226
|
+
} catch {
|
|
227
|
+
// A store that denies access; the per-tab copy below still goes.
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
sessionStorage.removeItem(key);
|
|
231
|
+
} catch {
|
|
232
|
+
// Nothing left to do: the value was never persisted in the first place.
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Claim this element's storage namespace: its `id`, else its `endpoint`.
|
|
238
|
+
*
|
|
239
|
+
* The endpoint fallback exists so a lone widget restores its conversation
|
|
240
|
+
* across reloads with nothing asked of the page author. It stops working the
|
|
241
|
+
* moment there are two of them — a docked support panel and an inline page
|
|
242
|
+
* assistant against one agent mount, neither carrying an `id`, which nothing
|
|
243
|
+
* requires — because both resolve to the same string and then share a thread
|
|
244
|
+
* pointer, a drawer index and every message key. Whichever mounts second
|
|
245
|
+
* adopts the first's active thread and rehydrates its transcript into its own
|
|
246
|
+
* panel: one conversation's content inside another, on the same page.
|
|
247
|
+
*
|
|
248
|
+
* So the namespace is claimed by the first element to mount under it, and a
|
|
249
|
+
* second is given one of its own plus a warning naming the fix. The first
|
|
250
|
+
* element keeps the endpoint namespace, which is what leaves the ordinary
|
|
251
|
+
* single-element case exactly as it was.
|
|
252
|
+
*
|
|
253
|
+
* The generated namespace is random rather than derived from mount order.
|
|
254
|
+
* That costs the second element its history across reloads — the warning says
|
|
255
|
+
* so, and an `id` fixes it — which is the honest trade against an order-based
|
|
256
|
+
* name that would silently hand a stored conversation to whichever element
|
|
257
|
+
* happened to mount second on the next load.
|
|
258
|
+
*/
|
|
259
|
+
#claimNamespace(): string {
|
|
260
|
+
const id = this.#host.id();
|
|
261
|
+
const preferred = id !== "" ? id : this.#host.endpoint();
|
|
262
|
+
// Nothing to key on, so the root keys: an element with neither an id nor
|
|
263
|
+
// an endpoint cannot send anything, so what it would claim is an empty
|
|
264
|
+
// conversation.
|
|
265
|
+
if (preferred === "") {
|
|
266
|
+
return "";
|
|
267
|
+
}
|
|
268
|
+
// Already lost this claim once. Keep the fallback rather than drifting back
|
|
269
|
+
// onto a namespace the other element may since have released, which would
|
|
270
|
+
// swap this panel's conversation for that one's.
|
|
271
|
+
if (this.#generatedFor === preferred) {
|
|
272
|
+
return this.#generatedNs;
|
|
273
|
+
}
|
|
274
|
+
if (!CLAIMED_NAMESPACES.has(preferred)) {
|
|
275
|
+
CLAIMED_NAMESPACES.add(preferred);
|
|
276
|
+
this.#claimedNs = preferred;
|
|
277
|
+
return preferred;
|
|
278
|
+
}
|
|
279
|
+
this.#generatedFor = preferred;
|
|
280
|
+
this.#generatedNs = `${preferred}~${randomUUID()}`;
|
|
281
|
+
console.warn(
|
|
282
|
+
`<ag-ui-chat>: another element on this page already stores its ` +
|
|
283
|
+
`conversation under "${preferred}", so this one has been given a ` +
|
|
284
|
+
"throwaway namespace of its own — the two would otherwise share a " +
|
|
285
|
+
"thread pointer, a history drawer and every message. Give each " +
|
|
286
|
+
"<ag-ui-chat> its own id to keep them apart and let this one restore " +
|
|
287
|
+
"its conversation across reloads.",
|
|
288
|
+
);
|
|
289
|
+
return this.#generatedNs;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TOOL_CALL_STATUS, TOOL_OUTCOME } from "../constants.js";
|
|
2
|
+
import type { SettledStatus } from "../ui/progress/tool_call_card.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* How a tool call ended, in the wire's own words. See {@link TOOL_OUTCOME}.
|
|
6
|
+
*
|
|
7
|
+
* Absent is the fourth case and the common one: a server that has never heard
|
|
8
|
+
* of the field says nothing, and nothing means success.
|
|
9
|
+
*/
|
|
10
|
+
export type ToolOutcome = (typeof TOOL_OUTCOME)[keyof typeof TOOL_OUTCOME];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The card status a wire outcome settles into.
|
|
14
|
+
*
|
|
15
|
+
* Takes `unknown` rather than {@link ToolOutcome} on purpose: both callers read
|
|
16
|
+
* this off a boundary the type system does not police -- a key in an AG-UI
|
|
17
|
+
* event's `metadata`, which the protocol declares open and does not validate,
|
|
18
|
+
* and a JSON blob out of the conversation store -- so the narrowing belongs
|
|
19
|
+
* here, once, instead of at each of them.
|
|
20
|
+
*
|
|
21
|
+
* **Everything unrecognised maps to `DONE`.** Not because unknown values are
|
|
22
|
+
* expected to be successes, but because the alternative is worse in the
|
|
23
|
+
* direction that matters: a card claiming a call failed when it did not is a
|
|
24
|
+
* lie the user acts on, while a card claiming success has at least the result
|
|
25
|
+
* text under it for them to read. A future release may add words, and forward
|
|
26
|
+
* compatibility is the point of the open field.
|
|
27
|
+
*/
|
|
28
|
+
export function toolStatusFromOutcome(outcome: unknown): SettledStatus {
|
|
29
|
+
if (outcome === TOOL_OUTCOME.FAILED) {
|
|
30
|
+
return TOOL_CALL_STATUS.ERROR;
|
|
31
|
+
}
|
|
32
|
+
if (outcome === TOOL_OUTCOME.DENIED) {
|
|
33
|
+
return TOOL_CALL_STATUS.DECLINED;
|
|
34
|
+
}
|
|
35
|
+
if (outcome === TOOL_OUTCOME.INTERRUPTED) {
|
|
36
|
+
return TOOL_CALL_STATUS.INTERRUPTED;
|
|
37
|
+
}
|
|
38
|
+
return TOOL_CALL_STATUS.DONE;
|
|
39
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { withCredentials } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The composer's voice-transcription contract: take a recorded audio `Blob` and
|
|
5
|
+
* resolve to the transcript text. The built-in handler is
|
|
6
|
+
* {@link transcribeAudio}; a host swaps in its own (a Web Speech adapter, a
|
|
7
|
+
* direct-to-provider call) via `AgUiChat.transcribeHandler` without touching
|
|
8
|
+
* the mic button.
|
|
9
|
+
*/
|
|
10
|
+
export type TranscribeHandler = (audio: Blob) => Promise<string>;
|
|
11
|
+
|
|
12
|
+
/** Options for {@link transcribeAudio}. */
|
|
13
|
+
export interface TranscribeOptions {
|
|
14
|
+
/** The transcription endpoint (`data-transcribe-url`). */
|
|
15
|
+
readonly url: string;
|
|
16
|
+
/** Extra HTTP headers (CSRF / auth), read fresh per request. */
|
|
17
|
+
readonly headers?: Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Cookie policy, as `fetch`'s own `credentials` mode. Unset leaves the
|
|
20
|
+
* browser default (`same-origin`), which sends no cookies to an endpoint on
|
|
21
|
+
* another origin; a cookie-authenticated cross-origin deployment needs
|
|
22
|
+
* `"include"`.
|
|
23
|
+
*/
|
|
24
|
+
readonly credentials?: RequestCredentials;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* POST a recorded clip to the transcription endpoint and resolve to its text.
|
|
29
|
+
*
|
|
30
|
+
* The clip goes as multipart under the `audio` field with the element's
|
|
31
|
+
* `headers`, mirroring {@link uploadAttachment}, and the server replies
|
|
32
|
+
* `{ "text": "<transcript>" }`. A non-2xx response or a network error rejects
|
|
33
|
+
* so the mic button can surface the failure.
|
|
34
|
+
*/
|
|
35
|
+
export async function transcribeAudio(audio: Blob, options: TranscribeOptions): Promise<string> {
|
|
36
|
+
const form = new FormData();
|
|
37
|
+
// The extension is cosmetic: the server reads the blob's content type.
|
|
38
|
+
form.append("audio", audio, "recording.webm");
|
|
39
|
+
|
|
40
|
+
const response = await fetch(
|
|
41
|
+
options.url,
|
|
42
|
+
withCredentials(
|
|
43
|
+
{
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { ...(options.headers ?? {}) },
|
|
46
|
+
body: form,
|
|
47
|
+
},
|
|
48
|
+
options.credentials,
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
throw new Error(await errorMessage(response));
|
|
53
|
+
}
|
|
54
|
+
const body: unknown = await response.json();
|
|
55
|
+
if (
|
|
56
|
+
typeof body === "object" &&
|
|
57
|
+
body !== null &&
|
|
58
|
+
typeof (body as { text?: unknown }).text === "string"
|
|
59
|
+
) {
|
|
60
|
+
return (body as { text: string }).text;
|
|
61
|
+
}
|
|
62
|
+
throw new Error("transcription returned an unreadable response");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** A human-readable message from a non-2xx transcription response. */
|
|
66
|
+
async function errorMessage(response: Response): Promise<string> {
|
|
67
|
+
try {
|
|
68
|
+
const body = (await response.json()) as { error?: unknown };
|
|
69
|
+
if (typeof body.error === "string") {
|
|
70
|
+
return body.error;
|
|
71
|
+
}
|
|
72
|
+
} catch {
|
|
73
|
+
// Non-JSON error body — fall through to the status code.
|
|
74
|
+
}
|
|
75
|
+
return `transcription failed (${response.status})`;
|
|
76
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { AttachmentRef } from "./attachment.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The composer's upload contract: take a `File`, report `0..1` progress, and
|
|
5
|
+
* resolve to a durable {@link AttachmentRef}. The built-in handler is
|
|
6
|
+
* {@link uploadAttachment}; a host swaps in its own (a `tus-js-client` or
|
|
7
|
+
* direct-to-S3 adapter) via `AgUiChat.uploadHandler` without touching the tray,
|
|
8
|
+
* the chips, or the AG-UI wire, refs being transport-agnostic.
|
|
9
|
+
*
|
|
10
|
+
* The optional `signal` fires when the tray removes a chip or the element is
|
|
11
|
+
* torn down; a handler that honours it should abort its own transport, so a
|
|
12
|
+
* cancelled upload doesn't orphan a server-side file.
|
|
13
|
+
*/
|
|
14
|
+
export type UploadHandler = (
|
|
15
|
+
file: File,
|
|
16
|
+
onProgress: (fraction: number) => void,
|
|
17
|
+
signal?: AbortSignal,
|
|
18
|
+
) => Promise<AttachmentRef>;
|
|
19
|
+
|
|
20
|
+
/** Options for {@link uploadAttachment}. */
|
|
21
|
+
export interface UploadOptions {
|
|
22
|
+
/** The attachments endpoint (`data-attachments-url`). */
|
|
23
|
+
readonly url: string;
|
|
24
|
+
/** Extra HTTP headers (CSRF / auth), read fresh per upload. */
|
|
25
|
+
readonly headers?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Cookie policy, spelled as `fetch`'s `credentials` mode for consistency with
|
|
28
|
+
* the other endpoints, but carried by `XMLHttpRequest`'s two-state
|
|
29
|
+
* `withCredentials`: `"include"` sets it and every other value leaves it off,
|
|
30
|
+
* matching `"same-origin"`. `"omit"` therefore cannot be honoured for a
|
|
31
|
+
* same-origin upload, XHR always sending cookies there; use a custom
|
|
32
|
+
* {@link UploadHandler} if that matters.
|
|
33
|
+
*/
|
|
34
|
+
readonly credentials?: RequestCredentials;
|
|
35
|
+
/** Progress callback, `0..1`, fired as the body uploads. */
|
|
36
|
+
readonly onProgress?: (fraction: number) => void;
|
|
37
|
+
/** Abort signal to cancel the in-flight upload. */
|
|
38
|
+
readonly signal?: AbortSignal | undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Upload one file to the attachments endpoint and resolve to its durable
|
|
43
|
+
* {@link AttachmentRef}.
|
|
44
|
+
*
|
|
45
|
+
* Uses `XMLHttpRequest` rather than `fetch` for real upload-progress events.
|
|
46
|
+
* The file goes as multipart under the `file` field with the element's
|
|
47
|
+
* `headers`, so CSRF / auth ride along; a non-2xx response or a network/abort
|
|
48
|
+
* error rejects, letting the tray show an error chip.
|
|
49
|
+
*/
|
|
50
|
+
export function uploadAttachment(file: File, options: UploadOptions): Promise<AttachmentRef> {
|
|
51
|
+
return new Promise<AttachmentRef>((resolve, reject) => {
|
|
52
|
+
const form = new FormData();
|
|
53
|
+
form.append("file", file);
|
|
54
|
+
|
|
55
|
+
const xhr = new XMLHttpRequest();
|
|
56
|
+
xhr.open("POST", options.url);
|
|
57
|
+
// Cross-origin cookies ride only when asked for, as at the fetch sites.
|
|
58
|
+
// Without this an upload to another subdomain goes anonymous and 401s while
|
|
59
|
+
// the run itself succeeds.
|
|
60
|
+
xhr.withCredentials = options.credentials === "include";
|
|
61
|
+
for (const [key, value] of Object.entries(options.headers ?? {})) {
|
|
62
|
+
xhr.setRequestHeader(key, value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const onProgress = options.onProgress;
|
|
66
|
+
if (onProgress !== undefined) {
|
|
67
|
+
xhr.upload.addEventListener("progress", (event) => {
|
|
68
|
+
if (event.lengthComputable) {
|
|
69
|
+
onProgress(event.total === 0 ? 0 : event.loaded / event.total);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
xhr.addEventListener("load", () => {
|
|
75
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
76
|
+
try {
|
|
77
|
+
resolve(parseRef(JSON.parse(xhr.responseText)));
|
|
78
|
+
} catch {
|
|
79
|
+
reject(new Error("upload returned an unreadable response"));
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
reject(new Error(errorMessage(xhr)));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
xhr.addEventListener("error", () => reject(new Error("upload failed")));
|
|
86
|
+
xhr.addEventListener("abort", () => reject(new Error("upload cancelled")));
|
|
87
|
+
|
|
88
|
+
const signal = options.signal;
|
|
89
|
+
if (signal !== undefined) {
|
|
90
|
+
signal.addEventListener("abort", () => xhr.abort());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
xhr.send(form);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Validate + narrow the server's `201` body into an {@link AttachmentRef}. */
|
|
98
|
+
function parseRef(body: unknown): AttachmentRef {
|
|
99
|
+
if (typeof body !== "object" || body === null) {
|
|
100
|
+
throw new Error("not an object");
|
|
101
|
+
}
|
|
102
|
+
const o = body as Record<string, unknown>;
|
|
103
|
+
const id = o["id"];
|
|
104
|
+
const name = o["name"];
|
|
105
|
+
const mime = o["mime"];
|
|
106
|
+
const size = o["size"];
|
|
107
|
+
const url = o["url"];
|
|
108
|
+
if (
|
|
109
|
+
typeof id !== "string" ||
|
|
110
|
+
typeof name !== "string" ||
|
|
111
|
+
typeof mime !== "string" ||
|
|
112
|
+
typeof size !== "number"
|
|
113
|
+
) {
|
|
114
|
+
throw new Error("missing fields");
|
|
115
|
+
}
|
|
116
|
+
return typeof url === "string" ? { id, name, mime, size, url } : { id, name, mime, size };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** A human-readable message from a non-2xx upload response. */
|
|
120
|
+
function errorMessage(xhr: XMLHttpRequest): string {
|
|
121
|
+
try {
|
|
122
|
+
const body = JSON.parse(xhr.responseText) as { error?: unknown };
|
|
123
|
+
if (typeof body.error === "string") {
|
|
124
|
+
return body.error;
|
|
125
|
+
}
|
|
126
|
+
} catch {
|
|
127
|
+
// Non-JSON error body — fall through to the status text.
|
|
128
|
+
}
|
|
129
|
+
return `upload failed (${xhr.status})`;
|
|
130
|
+
}
|