kiari 0.1.0__py3-none-any.whl
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.
- kiari/README.md +31 -0
- kiari/__init__.py +46 -0
- kiari/__main__.py +9 -0
- kiari/cli/__init__.py +29 -0
- kiari/cli/_constants/common_option_groups.py +129 -0
- kiari/cli/_decorators/common_options.py +188 -0
- kiari/cli/_helpers/build_cli_args.py +70 -0
- kiari/cli/_helpers/render_bootstrap_message.py +37 -0
- kiari/cli/_helpers/run.py +18 -0
- kiari/cli/_helpers/setup_profile.py +24 -0
- kiari/cli/_i18n.py +197 -0
- kiari/cli/_schemas/cli_args.py +15 -0
- kiari/cli/_types/extra_args.py +3 -0
- kiari/cli/_types/save_mode.py +3 -0
- kiari/cli/_utils/graceful_shutdown.py +35 -0
- kiari/cli/admin/clear_cache/cli.py +101 -0
- kiari/cli/admin/cli.py +30 -0
- kiari/cli/admin/init/cli.py +75 -0
- kiari/cli/admin/wipe_data/cli.py +102 -0
- kiari/cli/batch/_constants/batch_option_group.py +11 -0
- kiari/cli/batch/_decorators/batch_options.py +22 -0
- kiari/cli/batch/_i18n.py +22 -0
- kiari/cli/batch/_operations/run_batch.py +28 -0
- kiari/cli/batch/batch_handler/__init__.py +25 -0
- kiari/cli/batch/batch_handler/_models/base_batch_handler.py +114 -0
- kiari/cli/batch/batch_handler/_schemas/batch_request.py +8 -0
- kiari/cli/batch/batch_handler/_schemas/batch_session.py +38 -0
- kiari/cli/batch/batch_handler/_services/batch_handler_registry.py +27 -0
- kiari/cli/batch/batch_handler/_settings.py +27 -0
- kiari/cli/batch/batch_handler/_types/batch_handler.py +24 -0
- kiari/cli/batch/batch_handler/_types/batch_handler_name.py +3 -0
- kiari/cli/batch/batch_handler/_types/batch_handler_specifier.py +12 -0
- kiari/cli/batch/cli.py +103 -0
- kiari/cli/cli.py +95 -0
- kiari/cli/console/_constants/console_option_group.py +20 -0
- kiari/cli/console/_decorators/console_options.py +65 -0
- kiari/cli/console/_i18n.py +43 -0
- kiari/cli/console/_operations/run_console.py +269 -0
- kiari/cli/console/_services/console_completer.py +80 -0
- kiari/cli/console/cli.py +105 -0
- kiari/cli/console/console_handler/__init__.py +25 -0
- kiari/cli/console/console_handler/_models/base_console_handler.py +214 -0
- kiari/cli/console/console_handler/_schemas/console_request.py +8 -0
- kiari/cli/console/console_handler/_schemas/console_session.py +69 -0
- kiari/cli/console/console_handler/_services/console_handler_registry.py +27 -0
- kiari/cli/console/console_handler/_settings.py +27 -0
- kiari/cli/console/console_handler/_types/console_handler.py +34 -0
- kiari/cli/console/console_handler/_types/console_handler_name.py +3 -0
- kiari/cli/console/console_handler/_types/console_handler_specifier.py +12 -0
- kiari/cli/console/console_renderer/__init__.py +8 -0
- kiari/cli/console/console_renderer/_helpers/render_console_hint.py +11 -0
- kiari/cli/console/console_renderer/_helpers/render_console_status.py +492 -0
- kiari/cli/console/console_state/__init__.py +3 -0
- kiari/cli/console/console_state/_types/console_state.py +3 -0
- kiari/cli/console/console_text/__init__.py +7 -0
- kiari/cli/console/console_text/_helpers/__init__.py +3 -0
- kiari/cli/console/console_text/_helpers/parse_console_text.py +71 -0
- kiari/cli/console/console_text/_schemas/__init__.py +3 -0
- kiari/cli/console/console_text/_schemas/console_text.py +8 -0
- kiari/cli/console/slash_command/__init__.py +20 -0
- kiari/cli/console/slash_command/_models/base_slash_command.py +49 -0
- kiari/cli/console/slash_command/_services/slash_command_registry.py +27 -0
- kiari/cli/console/slash_command/_settings.py +58 -0
- kiari/cli/console/slash_command/_types/slash_command.py +23 -0
- kiari/cli/console/slash_command/_types/slash_command_name.py +3 -0
- kiari/cli/console/slash_command/_types/slash_command_specifier.py +12 -0
- kiari/cli/console/slash_command_impl/attach/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/attach/_i18n.py +35 -0
- kiari/cli/console/slash_command_impl/attach/_models/attach_slash_command.py +183 -0
- kiari/cli/console/slash_command_impl/back/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/back/_i18n.py +17 -0
- kiari/cli/console/slash_command_impl/back/_models/back_slash_command.py +102 -0
- kiari/cli/console/slash_command_impl/chat_model/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/chat_model/_i18n.py +16 -0
- kiari/cli/console/slash_command_impl/chat_model/_models/chat_model_slash_command.py +106 -0
- kiari/cli/console/slash_command_impl/clear/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/clear/_i18n.py +14 -0
- kiari/cli/console/slash_command_impl/clear/_models/clear_slash_command.py +102 -0
- kiari/cli/console/slash_command_impl/copy/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/copy/_i18n.py +20 -0
- kiari/cli/console/slash_command_impl/copy/_models/copy_slash_command.py +117 -0
- kiari/cli/console/slash_command_impl/event/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/event/_i18n.py +42 -0
- kiari/cli/console/slash_command_impl/event/_models/event_slash_command.py +249 -0
- kiari/cli/console/slash_command_impl/file_info/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/file_info/_i18n.py +40 -0
- kiari/cli/console/slash_command_impl/file_info/_models/file_info_slash_command.py +290 -0
- kiari/cli/console/slash_command_impl/help/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/help/_i18n.py +9 -0
- kiari/cli/console/slash_command_impl/help/_models/help_slash_command.py +90 -0
- kiari/cli/console/slash_command_impl/metadata/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/metadata/_i18n.py +59 -0
- kiari/cli/console/slash_command_impl/metadata/_models/metadata_slash_command.py +267 -0
- kiari/cli/console/slash_command_impl/run/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/run/_i18n.py +27 -0
- kiari/cli/console/slash_command_impl/run/_models/run_slash_command.py +151 -0
- kiari/cli/console/slash_command_impl/show/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/show/_i18n.py +18 -0
- kiari/cli/console/slash_command_impl/show/_models/show_slash_command.py +105 -0
- kiari/cli/console/slash_command_impl/stt/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/stt/_i18n.py +13 -0
- kiari/cli/console/slash_command_impl/stt/_models/stt_slash_command.py +44 -0
- kiari/cli/console/slash_command_impl/tool/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/tool/_i18n.py +29 -0
- kiari/cli/console/slash_command_impl/tool/_models/tool_slash_command.py +250 -0
- kiari/cli/console/slash_command_impl/tool_choice/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/tool_choice/_i18n.py +17 -0
- kiari/cli/console/slash_command_impl/tool_choice/_models/tool_choice_slash_command.py +76 -0
- kiari/cli/console/slash_command_impl/tool_info/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/tool_info/_i18n.py +55 -0
- kiari/cli/console/slash_command_impl/tool_info/_models/tool_info_slash_command.py +360 -0
- kiari/cli/console/slash_command_impl/tts/__init__.py +3 -0
- kiari/cli/console/slash_command_impl/tts/_i18n.py +13 -0
- kiari/cli/console/slash_command_impl/tts/_models/tts_slash_command.py +44 -0
- kiari/cli/ext/_operations/run_ext.py +21 -0
- kiari/cli/ext/cli.py +96 -0
- kiari/cli/ext/extension_command/__init__.py +23 -0
- kiari/cli/ext/extension_command/_models/base_extension_command.py +29 -0
- kiari/cli/ext/extension_command/_schemas/extension_command_context.py +8 -0
- kiari/cli/ext/extension_command/_services/extension_command_registry.py +26 -0
- kiari/cli/ext/extension_command/_settings.py +20 -0
- kiari/cli/ext/extension_command/_types/extension_command.py +16 -0
- kiari/cli/ext/extension_command/_types/extension_command_name.py +3 -0
- kiari/cli/ext/extension_command/_types/extension_command_specifier.py +5 -0
- kiari/cli/fastapi/cli.py +8 -0
- kiari/cli/profile/cli.py +29 -0
- kiari/cli/profile/copy/cli.py +86 -0
- kiari/cli/profile/delete/cli.py +89 -0
- kiari/cli/profile/list/cli.py +252 -0
- kiari/cli/profile/new/cli.py +67 -0
- kiari/cli/profile/set/cli.py +68 -0
- kiari/cli/profile/use/cli.py +57 -0
- kiari/cli/schedule/_constants/schedule_option_group.py +11 -0
- kiari/cli/schedule/_decorators/schedule_options.py +18 -0
- kiari/cli/schedule/_operations/run_schedule.py +76 -0
- kiari/cli/schedule/cli.py +55 -0
- kiari/cli/schedule/schedule_handler/__init__.py +18 -0
- kiari/cli/schedule/schedule_handler/_models/base_schedule_handler.py +261 -0
- kiari/cli/schedule/schedule_handler/_schemas/schedule_session.py +72 -0
- kiari/cli/schedule/schedule_handler/_services/schedule_handler_registry.py +27 -0
- kiari/cli/schedule/schedule_handler/_settings.py +27 -0
- kiari/cli/schedule/schedule_handler/_types/schedule_handler.py +42 -0
- kiari/cli/schedule/schedule_handler/_types/schedule_handler_name.py +3 -0
- kiari/cli/schedule/schedule_handler/_types/schedule_handler_specifier.py +3 -0
- kiari/cli/schedule/scheduler/__init__.py +11 -0
- kiari/cli/schedule/scheduler/_helpers/create_scheduler.py +34 -0
- kiari/cli/schedule/scheduler/_schemas/scheduler.py +11 -0
- kiari/cli/schedule/scheduler/_types/schedule_type.py +3 -0
- kiari/cli/schedule/scheduler/_utils/parse_duration.py +13 -0
- kiari/cli/streamlit/cli.py +8 -0
- kiari/cli/watch/_constants/watch_option_group.py +11 -0
- kiari/cli/watch/_decorators/watch_options.py +18 -0
- kiari/cli/watch/_operations/run_watch.py +111 -0
- kiari/cli/watch/cli.py +46 -0
- kiari/cli/watch/watch_handler/__init__.py +18 -0
- kiari/cli/watch/watch_handler/_models/base_watch_handler.py +134 -0
- kiari/cli/watch/watch_handler/_schemas/watch_session.py +41 -0
- kiari/cli/watch/watch_handler/_services/watch_handler_registry.py +27 -0
- kiari/cli/watch/watch_handler/_settings.py +28 -0
- kiari/cli/watch/watch_handler/_types/watch_handler.py +25 -0
- kiari/cli/watch/watch_handler/_types/watch_handler_name.py +3 -0
- kiari/cli/watch/watch_handler/_types/watch_handler_specifier.py +5 -0
- kiari/core/__init__.py +0 -0
- kiari/core/editor/__init__.py +11 -0
- kiari/core/editor/_helpers/edit_text.py +64 -0
- kiari/core/editor/_helpers/edit_text_with_validation.py +68 -0
- kiari/core/editor/_i18n.py +8 -0
- kiari/core/editor/_schemas/validation_result.py +17 -0
- kiari/core/exchange_rate/__init__.py +9 -0
- kiari/core/exchange_rate/_exceptions/exchange_rate_not_loaded_error.py +2 -0
- kiari/core/exchange_rate/_services/exchange_rate_store.py +62 -0
- kiari/core/file_info_source/__init__.py +9 -0
- kiari/core/file_info_source/_helpers/resolve_file_info_specifiers.py +57 -0
- kiari/core/file_info_source/_types/file_info_source.py +24 -0
- kiari/core/file_resolver/__init__.py +7 -0
- kiari/core/file_resolver/_helpers/resolve_file_paths.py +73 -0
- kiari/core/file_resolver/_types/file_path_pattern.py +7 -0
- kiari/core/finalizer/__init__.py +23 -0
- kiari/core/finalizer/_helpers/run_finalizers.py +20 -0
- kiari/core/finalizer/_models/base_finalizer.py +29 -0
- kiari/core/finalizer/_services/finalizer_registry.py +26 -0
- kiari/core/finalizer/_settings.py +26 -0
- kiari/core/finalizer/_types/finalizer.py +10 -0
- kiari/core/finalizer/_types/finalizer_name.py +3 -0
- kiari/core/finalizer/_types/finalizer_specifier.py +13 -0
- kiari/core/github/__init__.py +22 -0
- kiari/core/github/_helpers/fetch_github_dir.py +128 -0
- kiari/core/github/_helpers/fetch_github_file.py +69 -0
- kiari/core/github/_helpers/verify_github_trust.py +123 -0
- kiari/core/github/_i18n.py +20 -0
- kiari/core/github/_models/github_path_spec.py +99 -0
- kiari/core/github/_services/github_trusted_source_store.py +25 -0
- kiari/core/github/_settings.py +17 -0
- kiari/core/github/_types/github_path_pattern.py +23 -0
- kiari/core/logging/__init__.py +12 -0
- kiari/core/logging/_helpers/setup_logger.py +24 -0
- kiari/core/logging/_models/rich_log_handler.py +60 -0
- kiari/core/logging/_types/log_level.py +3 -0
- kiari/core/paths/__init__.py +25 -0
- kiari/core/paths/_utils/get_config_file_path.py +7 -0
- kiari/core/paths/_utils/get_github_cache_dir_path.py +7 -0
- kiari/core/paths/_utils/get_github_trusted_sources_file_path.py +7 -0
- kiari/core/paths/_utils/get_profile_config_file_path.py +7 -0
- kiari/core/paths/_utils/get_profile_dir_path.py +7 -0
- kiari/core/paths/_utils/get_profile_run_spec_file_path.py +7 -0
- kiari/core/paths/_utils/get_profiles_dir_path.py +7 -0
- kiari/core/paths/_utils/get_profiles_file_path.py +7 -0
- kiari/core/paths/_utils/get_prompt_session_history_file_path.py +7 -0
- kiari/core/plugin/__init__.py +3 -0
- kiari/core/plugin/_helpers/load_plugin.py +61 -0
- kiari/core/plugin/_i18n.py +7 -0
- kiari/core/plugin/_settings.py +14 -0
- kiari/core/profile/__init__.py +16 -0
- kiari/core/profile/_schemas/profile.py +11 -0
- kiari/core/profile/_schemas/run_options.py +127 -0
- kiari/core/profile/_services/profile_store.py +243 -0
- kiari/core/profile/_types/profile_name.py +13 -0
- kiari/core/profile/_types/run_spec.py +3 -0
- kiari/core/rich/__init__.py +24 -0
- kiari/core/rich/_helpers/render_content.py +63 -0
- kiari/core/rich/_helpers/render_display_content.py +98 -0
- kiari/core/rich/_helpers/render_event.py +50 -0
- kiari/core/rich/_helpers/render_file_info.py +24 -0
- kiari/core/rich/_helpers/render_message.py +143 -0
- kiari/core/rich/_helpers/render_tool_call.py +30 -0
- kiari/core/rich/_services/console_registry.py +19 -0
- kiari/core/rich/_utils/join_renderables.py +34 -0
- kiari/core/rich/_utils/render_status_block.py +41 -0
- kiari/core/runtime/__init__.py +9 -0
- kiari/core/runtime/_helpers/create_agi_options.py +96 -0
- kiari/core/runtime/_helpers/setup_history.py +94 -0
- kiari/core/runtime/_helpers/setup_runtime.py +302 -0
- kiari/core/terminal/__init__.py +16 -0
- kiari/core/terminal/_helpers/has_interactive_tty.py +7 -0
- kiari/core/terminal/_helpers/stop_asyncio_on_enter.py +34 -0
- kiari/core/terminal/_helpers/stop_threading_on_enter.py +34 -0
- kiari/core/terminal/_services/prompt_session_registry.py +40 -0
- kiari/core/terminal/_utils/create_prompt_toolkit_io.py +19 -0
- kiari/fastapi/__init__.py +0 -0
- kiari/impl/batch_handler_impl/vanilla/__init__.py +3 -0
- kiari/impl/batch_handler_impl/vanilla/_models/vanilla_batch_handler.py +5 -0
- kiari/impl/chat_logger_impl/default/__init__.py +3 -0
- kiari/impl/chat_logger_impl/default/_models/default_chat_logger.py +205 -0
- kiari/impl/console_handler_impl/vanilla/__init__.py +3 -0
- kiari/impl/console_handler_impl/vanilla/_models/vanilla_console_handler.py +5 -0
- kiari/impl/cost_logger_impl/default/__init__.py +3 -0
- kiari/impl/cost_logger_impl/default/_models/default_cost_logger.py +63 -0
- kiari/impl/finalizer_impl/__init__.py +1 -0
- kiari/impl/finalizer_impl/chrome/__init__.py +3 -0
- kiari/impl/finalizer_impl/chrome/_models/chrome_finalizer.py +7 -0
- kiari/impl/finalizer_impl/null/__init__.py +3 -0
- kiari/impl/finalizer_impl/null/_models/null_finalizer.py +5 -0
- kiari/impl/finalizer_impl/subprocess/__init__.py +3 -0
- kiari/impl/finalizer_impl/subprocess/_models/subprocess_finalizer.py +7 -0
- kiari/impl/history_repository_impl/in_memory/__init__.py +3 -0
- kiari/impl/history_repository_impl/in_memory/_models/in_memory_history_repository.py +34 -0
- kiari/impl/history_repository_impl/local/__init__.py +13 -0
- kiari/impl/history_repository_impl/local/_helpers/create_local_history_repository.py +15 -0
- kiari/impl/history_repository_impl/local/_models/local_history_repository.py +42 -0
- kiari/impl/history_repository_impl/local/_settings.py +14 -0
- kiari/impl/history_repository_impl/null/__init__.py +3 -0
- kiari/impl/history_repository_impl/null/_models/null_history_repository.py +5 -0
- kiari/impl/schedule_handler_impl/__init__.py +1 -0
- kiari/impl/schedule_handler_impl/vanilla/__init__.py +3 -0
- kiari/impl/schedule_handler_impl/vanilla/_models/vanilla_schedule_handler.py +5 -0
- kiari/impl/tool_impl/__init__.py +0 -0
- kiari/impl/tool_impl/audio_file_view/__init__.py +3 -0
- kiari/impl/tool_impl/audio_file_view/_i18n.py +13 -0
- kiari/impl/tool_impl/audio_file_view/_models/audio_file_view.py +34 -0
- kiari/impl/tool_impl/audio_file_view/_schemas/audio_file_view_schema.py +33 -0
- kiari/impl/tool_impl/change_directory/__init__.py +3 -0
- kiari/impl/tool_impl/change_directory/_i18n.py +8 -0
- kiari/impl/tool_impl/change_directory/_models/change_directory.py +30 -0
- kiari/impl/tool_impl/change_directory/_schemas/change_directory_schema.py +9 -0
- kiari/impl/tool_impl/gui/__init__.py +3 -0
- kiari/impl/tool_impl/gui/_i18n.py +50 -0
- kiari/impl/tool_impl/gui/_models/gui.py +78 -0
- kiari/impl/tool_impl/gui/_operations/keyboard_hotkey.py +22 -0
- kiari/impl/tool_impl/gui/_operations/keyboard_press.py +22 -0
- kiari/impl/tool_impl/gui/_operations/keyboard_write.py +22 -0
- kiari/impl/tool_impl/gui/_operations/mouse_click.py +25 -0
- kiari/impl/tool_impl/gui/_operations/mouse_down.py +25 -0
- kiari/impl/tool_impl/gui/_operations/mouse_move.py +27 -0
- kiari/impl/tool_impl/gui/_operations/mouse_up.py +25 -0
- kiari/impl/tool_impl/gui/_operations/screenshot.py +15 -0
- kiari/impl/tool_impl/gui/_schemas/gui_schema.py +114 -0
- kiari/impl/tool_impl/gui/_types/action.py +12 -0
- kiari/impl/tool_impl/image_file_view/__init__.py +3 -0
- kiari/impl/tool_impl/image_file_view/_i18n.py +13 -0
- kiari/impl/tool_impl/image_file_view/_models/image_file_view.py +28 -0
- kiari/impl/tool_impl/image_file_view/_schemas/image_file_view_schema.py +14 -0
- kiari/impl/tool_impl/pdf_file_view/__init__.py +3 -0
- kiari/impl/tool_impl/pdf_file_view/_i18n.py +12 -0
- kiari/impl/tool_impl/pdf_file_view/_models/pdf_file_view.py +34 -0
- kiari/impl/tool_impl/pdf_file_view/_schemas/pdf_file_view_schema.py +33 -0
- kiari/impl/tool_impl/subprocess/__init__.py +3 -0
- kiari/impl/tool_impl/subprocess/_i18n.py +68 -0
- kiari/impl/tool_impl/subprocess/_models/subprocess.py +50 -0
- kiari/impl/tool_impl/subprocess/_operations/cancel.py +64 -0
- kiari/impl/tool_impl/subprocess/_operations/get_list.py +65 -0
- kiari/impl/tool_impl/subprocess/_operations/get_output.py +58 -0
- kiari/impl/tool_impl/subprocess/_operations/run.py +61 -0
- kiari/impl/tool_impl/subprocess/_operations/run_background.py +37 -0
- kiari/impl/tool_impl/subprocess/_schemas/subprocess_schema.py +145 -0
- kiari/impl/tool_impl/subprocess/_types/action.py +9 -0
- kiari/impl/tool_impl/subprocess/_utils/create_output_file.py +39 -0
- kiari/impl/tool_impl/text_file_edit/__init__.py +3 -0
- kiari/impl/tool_impl/text_file_edit/_i18n.py +49 -0
- kiari/impl/tool_impl/text_file_edit/_models/text_file_edit.py +42 -0
- kiari/impl/tool_impl/text_file_edit/_operations/create.py +33 -0
- kiari/impl/tool_impl/text_file_edit/_operations/line_replace.py +118 -0
- kiari/impl/tool_impl/text_file_edit/_operations/str_replace.py +72 -0
- kiari/impl/tool_impl/text_file_edit/_operations/update.py +36 -0
- kiari/impl/tool_impl/text_file_edit/_schemas/text_file_edit_schema.py +92 -0
- kiari/impl/tool_impl/text_file_edit/_types/action.py +8 -0
- kiari/impl/tool_impl/text_file_edit/_utils/build_result.py +46 -0
- kiari/impl/tool_impl/text_file_edit/_utils/replace_str.py +72 -0
- kiari/impl/tool_impl/text_file_edit/_utils/resolve_path.py +7 -0
- kiari/impl/tool_impl/text_file_edit/_utils/write_file.py +34 -0
- kiari/impl/tool_impl/text_file_view/__init__.py +3 -0
- kiari/impl/tool_impl/text_file_view/_i18n.py +14 -0
- kiari/impl/tool_impl/text_file_view/_models/text_file_view.py +81 -0
- kiari/impl/tool_impl/text_file_view/_schemas/text_file_view_schema.py +26 -0
- kiari/impl/tool_impl/video_file_view/__init__.py +3 -0
- kiari/impl/tool_impl/video_file_view/_i18n.py +13 -0
- kiari/impl/tool_impl/video_file_view/_models/video_file_view.py +34 -0
- kiari/impl/tool_impl/video_file_view/_schemas/video_file_view_schema.py +33 -0
- kiari/impl/tool_logger_impl/default/__init__.py +3 -0
- kiari/impl/tool_logger_impl/default/_models/default_tool_logger.py +104 -0
- kiari/impl/watch_handler_impl/__init__.py +1 -0
- kiari/impl/watch_handler_impl/slack/__init__.py +8 -0
- kiari/impl/watch_handler_impl/slack/_models/slack_watch_handler.py +259 -0
- kiari/impl/watch_handler_impl/slack/_settings.py +19 -0
- kiari/impl/watch_handler_impl/slack/_utils/convert_markdown_to_mrkdwn.py +23 -0
- kiari/impl/watch_handler_impl/slack/_utils/get_bot_token.py +34 -0
- kiari/impl/watch_handler_impl/vanilla/__init__.py +3 -0
- kiari/impl/watch_handler_impl/vanilla/_models/vanilla_watch_handler.py +5 -0
- kiari/impl/watcher_impl/__init__.py +1 -0
- kiari/impl/watcher_impl/file/__init__.py +18 -0
- kiari/impl/watcher_impl/file/_helpers/create_file_watcher.py +13 -0
- kiari/impl/watcher_impl/file/_models/file_watcher.py +88 -0
- kiari/impl/watcher_impl/file/_schemas/file_change.py +8 -0
- kiari/impl/watcher_impl/file/_schemas/file_watch_event.py +24 -0
- kiari/impl/watcher_impl/file/_schemas/file_watch_payload.py +10 -0
- kiari/impl/watcher_impl/file/_settings.py +37 -0
- kiari/impl/watcher_impl/file/_types/change_type.py +3 -0
- kiari/impl/watcher_impl/pubsub/__init__.py +14 -0
- kiari/impl/watcher_impl/pubsub/_helpers/create_pubsub_watcher.py +13 -0
- kiari/impl/watcher_impl/pubsub/_models/pubsub_watcher.py +99 -0
- kiari/impl/watcher_impl/pubsub/_schemas/pubsub_watch_event.py +48 -0
- kiari/impl/watcher_impl/pubsub/_schemas/pubsub_watch_payload.py +11 -0
- kiari/impl/watcher_impl/pubsub/_settings.py +18 -0
- kiari/impl/watcher_impl/rtdb/__init__.py +16 -0
- kiari/impl/watcher_impl/rtdb/_helpers/create_rtdb_watcher.py +13 -0
- kiari/impl/watcher_impl/rtdb/_models/rtdb_watcher.py +48 -0
- kiari/impl/watcher_impl/rtdb/_schemas/rtdb_watch_event.py +42 -0
- kiari/impl/watcher_impl/rtdb/_schemas/rtdb_watch_payload.py +10 -0
- kiari/impl/watcher_impl/rtdb/_services/file_token_cache.py +21 -0
- kiari/impl/watcher_impl/rtdb/_settings.py +17 -0
- kiari/impl/watcher_impl/slack/__init__.py +14 -0
- kiari/impl/watcher_impl/slack/_helpers/create_slack_watcher.py +13 -0
- kiari/impl/watcher_impl/slack/_models/slack_watcher.py +335 -0
- kiari/impl/watcher_impl/slack/_schemas/slack_watch_event.py +63 -0
- kiari/impl/watcher_impl/slack/_schemas/slack_watch_payload.py +13 -0
- kiari/impl/watcher_impl/slack/_settings.py +33 -0
- kiari/lib/audio_utils/__init__.py +24 -0
- kiari/lib/audio_utils/_utils/load_audio_samples.py +11 -0
- kiari/lib/audio_utils/_utils/play_audio.py +72 -0
- kiari/lib/chrome/__init__.py +44 -0
- kiari/lib/chrome/_helpers/get_chrome.py +15 -0
- kiari/lib/chrome/_helpers/terminate_chrome.py +15 -0
- kiari/lib/chrome/_models/chrome.py +201 -0
- kiari/lib/chrome/_settings.py +67 -0
- kiari/lib/chrome/_types/chrome_boot_state.py +9 -0
- kiari/lib/chrome/_utils/get_chrome_executable_path.py +14 -0
- kiari/lib/chrome/_utils/is_port_open.py +21 -0
- kiari/lib/chrome/_utils/kill_process.py +24 -0
- kiari/lib/cwd/__init__.py +7 -0
- kiari/lib/cwd/_helpers/create_cwd_manager.py +7 -0
- kiari/lib/cwd/_models/cwd_manager.py +77 -0
- kiari/lib/cwd/_schemas/cwd_state.py +7 -0
- kiari/lib/gui/__init__.py +19 -0
- kiari/lib/gui/_services/gui.py +34 -0
- kiari/lib/history_repository/__init__.py +20 -0
- kiari/lib/history_repository/_models/base_history_repository.py +51 -0
- kiari/lib/history_repository/_services/__init__.py +3 -0
- kiari/lib/history_repository/_services/history_repository_registry.py +27 -0
- kiari/lib/history_repository/_settings.py +29 -0
- kiari/lib/history_repository/_types/history_repository.py +15 -0
- kiari/lib/history_repository/_types/history_repository_name.py +3 -0
- kiari/lib/history_repository/_types/history_repository_specifier.py +12 -0
- kiari/lib/keyboard/__init__.py +31 -0
- kiari/lib/keyboard/_models/keyboard.py +64 -0
- kiari/lib/keyboard/_types/keyboard_key.py +101 -0
- kiari/lib/keyboard/_utils/normalize_key.py +10 -0
- kiari/lib/keyboard/_utils/normalize_keys.py +10 -0
- kiari/lib/monitor/__init__.py +51 -0
- kiari/lib/monitor/_constants/max_scaling_targets.py +16 -0
- kiari/lib/monitor/_models/monitor.py +70 -0
- kiari/lib/monitor/_operations/calc_physical_size.py +17 -0
- kiari/lib/monitor/_operations/calc_scale_factor.py +11 -0
- kiari/lib/monitor/_operations/calc_scale_ratio.py +30 -0
- kiari/lib/monitor/_operations/capture_monitor.py +37 -0
- kiari/lib/monitor/_operations/get_image.py +26 -0
- kiari/lib/monitor/_operations/get_offset_vector.py +15 -0
- kiari/lib/monitor/_operations/get_screenshot.py +21 -0
- kiari/lib/monitor/_schemas/monitor_snapshot.py +16 -0
- kiari/lib/monitor/_schemas/multiple_monitor_capture.py +34 -0
- kiari/lib/monitor/_schemas/point.py +8 -0
- kiari/lib/monitor/_schemas/rect.py +59 -0
- kiari/lib/monitor/_schemas/size.py +12 -0
- kiari/lib/monitor/_types/monitor_index.py +3 -0
- kiari/lib/monitor/_views/monitor_info.py +14 -0
- kiari/lib/mouse/__init__.py +29 -0
- kiari/lib/mouse/_models/mouse.py +50 -0
- kiari/lib/mouse/_types/mouse_button.py +3 -0
- kiari/lib/subprocess/__init__.py +32 -0
- kiari/lib/subprocess/_enums/subprocess_status.py +15 -0
- kiari/lib/subprocess/_helpers/get_subprocess_manager.py +13 -0
- kiari/lib/subprocess/_helpers/terminate_all_sessions.py +6 -0
- kiari/lib/subprocess/_models/subprocess_manager.py +179 -0
- kiari/lib/subprocess/_models/subprocess_session.py +162 -0
- kiari/lib/subprocess/_operations/cancel_subprocess.py +171 -0
- kiari/lib/subprocess/_operations/run_subprocess.py +158 -0
- kiari/lib/subprocess/_settings.py +27 -0
- kiari/lib/subprocess/_types/cancel_options.py +21 -0
- kiari/lib/subprocess/_types/run_id.py +3 -0
- kiari/lib/subprocess/_types/subprocess_event.py +7 -0
- kiari/lib/subprocess/_utils/clean_ansi.py +65 -0
- kiari/lib/subprocess/_views/background_event.py +10 -0
- kiari/lib/subprocess/_views/finish_event.py +13 -0
- kiari/lib/subprocess/_views/stream_event.py +11 -0
- kiari/lib/watcher/__init__.py +23 -0
- kiari/lib/watcher/_models/base_watcher.py +30 -0
- kiari/lib/watcher/_schemas/watch_event.py +16 -0
- kiari/lib/watcher/_services/watcher_registry.py +26 -0
- kiari/lib/watcher/_settings.py +27 -0
- kiari/lib/watcher/_types/watcher.py +13 -0
- kiari/lib/watcher/_types/watcher_name.py +3 -0
- kiari/lib/watcher/_types/watcher_specifier.py +12 -0
- kiari/py.typed +1 -0
- kiari/resources/__init__.py +0 -0
- kiari/resources/i18n/__init__.py +0 -0
- kiari/resources/i18n/en.yaml +0 -0
- kiari/resources/i18n/ja.yaml +0 -0
- kiari/streamlit/__init__.py +0 -0
- kiari-0.1.0.dist-info/METADATA +181 -0
- kiari-0.1.0.dist-info/RECORD +451 -0
- kiari-0.1.0.dist-info/WHEEL +4 -0
- kiari-0.1.0.dist-info/entry_points.txt +2 -0
- kiari-0.1.0.dist-info/licenses/LICENSE +21 -0
kiari/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## watch モード
|
|
2
|
+
|
|
3
|
+
```sh
|
|
4
|
+
# ファイルの変更を監視
|
|
5
|
+
kiari watch "file?paths=.&include_patterns=*.md"
|
|
6
|
+
|
|
7
|
+
# PubSub を監視
|
|
8
|
+
kiari ext pubsub create-topic --project-id kiarina --topic-id tmp
|
|
9
|
+
kiari ext pubsub create-subscription --project-id kiarina --topic-id tmp --subscription-id tmp
|
|
10
|
+
kiari watch "pubsub?project_id=kiarina&subscription_id=tmp"
|
|
11
|
+
kiari ext pubsub publish-message --project-id kiarina --topic-id tmp --attribute hoge=fuga "hello"
|
|
12
|
+
|
|
13
|
+
# Realtime Database を監視
|
|
14
|
+
DATABASE_URL=https://kiarina-python.firebaseio.com/
|
|
15
|
+
kiari watch "rtdb?database_url=$DATABASE_URL&path=/posts/kiarina"
|
|
16
|
+
# - 複数のパスを監視
|
|
17
|
+
kiari watch \
|
|
18
|
+
"rtdb?database_url=$DATABASE_URL&path=/posts/kiarina" \
|
|
19
|
+
"rtdb?database_url=$DATABASE_URL&path=/status/kiarina"
|
|
20
|
+
kiari ext rtdb set --database-url $DATABASE_URL --path /posts/kiarina '{"message":"hello"}'
|
|
21
|
+
kiari ext rtdb get --database-url $DATABASE_URL --path /posts/kiarina
|
|
22
|
+
kiari ext rtdb watch --database-url $DATABASE_URL --path /posts/kiarina
|
|
23
|
+
|
|
24
|
+
# Slack を監視
|
|
25
|
+
CHANNEL_ID=C077QKNDCUR
|
|
26
|
+
kiari watch "slack?"
|
|
27
|
+
kiari watch --watch-handler slack "slack?"
|
|
28
|
+
kiari ext slack post-message --channel $CHANNEL_ID "hello"
|
|
29
|
+
kiari ext -v slack get-channel-messages --channel $CHANNEL_ID --limit 1
|
|
30
|
+
kiari ext slack watch-channel --channel $CHANNEL_ID
|
|
31
|
+
```
|
kiari/__init__.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from importlib import import_module
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from kiarina.agi.agent import BaseAgent as Agent
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
# --------------------------------------------------
|
|
9
|
+
# kiarina_agi
|
|
10
|
+
# --------------------------------------------------
|
|
11
|
+
# kiarina.agi.agent
|
|
12
|
+
"Agent",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def __getattr__(name: str) -> object:
|
|
17
|
+
if name not in __all__: # pragma: no cover
|
|
18
|
+
raise AttributeError(f"module {__name__} has no attribute {name}")
|
|
19
|
+
|
|
20
|
+
# Map attribute names to their module paths
|
|
21
|
+
# Format: "name": "module_path" or "name": ("module_path", "attr_name")
|
|
22
|
+
# fmg: off
|
|
23
|
+
module_map: dict[str, str | tuple[str, str]] = {
|
|
24
|
+
# --------------------------------------------------
|
|
25
|
+
# kiarina_agi
|
|
26
|
+
# --------------------------------------------------
|
|
27
|
+
# kiarina.agi.agent
|
|
28
|
+
"Agent": ("kiarina.agi.agent", "BaseAgent"),
|
|
29
|
+
}
|
|
30
|
+
# fmt: on
|
|
31
|
+
|
|
32
|
+
module_info = module_map[name]
|
|
33
|
+
|
|
34
|
+
if isinstance(module_info, tuple):
|
|
35
|
+
# Tuple format: (module_path, attr_name)
|
|
36
|
+
module_path, attr_name = module_info
|
|
37
|
+
module = import_module(module_path)
|
|
38
|
+
attr = getattr(module, attr_name)
|
|
39
|
+
else:
|
|
40
|
+
# String format: module_path (attr_name is the same as name)
|
|
41
|
+
module_path = module_info
|
|
42
|
+
module = import_module(module_path)
|
|
43
|
+
attr = getattr(module, name)
|
|
44
|
+
|
|
45
|
+
globals()[name] = attr
|
|
46
|
+
return attr
|
kiari/__main__.py
ADDED
kiari/cli/__init__.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from ._constants.common_option_groups import COMMON_OPTION_GROUPS
|
|
2
|
+
from ._decorators.common_options import common_options
|
|
3
|
+
from ._helpers.build_cli_args import build_cli_args
|
|
4
|
+
from ._helpers.render_bootstrap_message import render_bootstrap_message
|
|
5
|
+
from ._helpers.run import run
|
|
6
|
+
from ._helpers.setup_profile import setup_profile
|
|
7
|
+
from ._schemas.cli_args import CLIArgs
|
|
8
|
+
from ._types.extra_args import ExtraArgs
|
|
9
|
+
from ._types.save_mode import SaveMode
|
|
10
|
+
from ._utils.graceful_shutdown import graceful_shutdown
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
# ._constants
|
|
14
|
+
"COMMON_OPTION_GROUPS",
|
|
15
|
+
# ._decorators
|
|
16
|
+
"common_options",
|
|
17
|
+
# ._helpers
|
|
18
|
+
"build_cli_args",
|
|
19
|
+
"render_bootstrap_message",
|
|
20
|
+
"run",
|
|
21
|
+
"setup_profile",
|
|
22
|
+
# ._schemas
|
|
23
|
+
"CLIArgs",
|
|
24
|
+
# ._types
|
|
25
|
+
"ExtraArgs",
|
|
26
|
+
"SaveMode",
|
|
27
|
+
# ._utils
|
|
28
|
+
"graceful_shutdown",
|
|
29
|
+
]
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from rich_click.utils import OptionGroupDict
|
|
2
|
+
|
|
3
|
+
COMMON_OPTION_GROUPS: list[OptionGroupDict] = [
|
|
4
|
+
{
|
|
5
|
+
"name": "History Repository",
|
|
6
|
+
"options": [
|
|
7
|
+
"--history-repository",
|
|
8
|
+
"--stateless",
|
|
9
|
+
"--no-load",
|
|
10
|
+
"--no-save",
|
|
11
|
+
"--allow-active-missing-tools",
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "History",
|
|
16
|
+
"options": [
|
|
17
|
+
"--event",
|
|
18
|
+
"--file-info",
|
|
19
|
+
"--tool-info",
|
|
20
|
+
"--default-tool-state",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "Agent",
|
|
25
|
+
"options": [
|
|
26
|
+
"--agent",
|
|
27
|
+
"--file-limits",
|
|
28
|
+
"--max-iterations",
|
|
29
|
+
"--until-end",
|
|
30
|
+
"--until-tool-call",
|
|
31
|
+
"--until-tool-run",
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "Tool",
|
|
36
|
+
"options": [
|
|
37
|
+
"--tool",
|
|
38
|
+
"--pre-hook",
|
|
39
|
+
"--post-hook",
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "Workflow",
|
|
44
|
+
"options": [
|
|
45
|
+
"--workflow",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "Prompt",
|
|
50
|
+
"options": [
|
|
51
|
+
"--prompt",
|
|
52
|
+
"--prompt-limits",
|
|
53
|
+
"--system-message",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "Chat",
|
|
58
|
+
"options": [
|
|
59
|
+
"--chat-model",
|
|
60
|
+
"--openai",
|
|
61
|
+
"--anthropic",
|
|
62
|
+
"--google",
|
|
63
|
+
"--tool-choice",
|
|
64
|
+
"--parallel-tool-calls",
|
|
65
|
+
"--streaming",
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "Cost Recorder",
|
|
70
|
+
"options": [
|
|
71
|
+
"--cost-recorder",
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "Observability",
|
|
76
|
+
"options": [
|
|
77
|
+
"--request-logger",
|
|
78
|
+
"--cost-logger",
|
|
79
|
+
"--chat-logger",
|
|
80
|
+
"--tool-logger",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "Run Context",
|
|
85
|
+
"options": [
|
|
86
|
+
"--organization-id",
|
|
87
|
+
"--user-id",
|
|
88
|
+
"--agent-id",
|
|
89
|
+
"--runner-id",
|
|
90
|
+
"--language",
|
|
91
|
+
"--time-zone",
|
|
92
|
+
"--currency",
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "GitHub",
|
|
97
|
+
"options": [
|
|
98
|
+
"--github-ignore-cache",
|
|
99
|
+
"--github-trusted-username",
|
|
100
|
+
"--github-skip-trust-verification",
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "Config",
|
|
105
|
+
"options": [
|
|
106
|
+
"--i18n-catalog",
|
|
107
|
+
"--config",
|
|
108
|
+
"--config-var",
|
|
109
|
+
"--plugin",
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "Profile",
|
|
114
|
+
"options": [
|
|
115
|
+
"--profile",
|
|
116
|
+
"--set-profile",
|
|
117
|
+
"--reset-profile",
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "Logging",
|
|
122
|
+
"options": [
|
|
123
|
+
"--logger-name",
|
|
124
|
+
"--log-level",
|
|
125
|
+
"--verbose",
|
|
126
|
+
"--quiet",
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
]
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import rich_click as click
|
|
6
|
+
from kiarina.i18n import get_i18n, get_system_language
|
|
7
|
+
|
|
8
|
+
from .._i18n import CLII18n
|
|
9
|
+
|
|
10
|
+
t = get_i18n(CLII18n, get_system_language())
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def common_options(func: Callable) -> Callable:
|
|
14
|
+
# fmt: off
|
|
15
|
+
# --------------------------------------------------
|
|
16
|
+
# History Repository
|
|
17
|
+
# --------------------------------------------------
|
|
18
|
+
@click.option("--history-repository", type=str, help=t.history_repository_help)
|
|
19
|
+
@click.option("--stateless", is_flag=True, is_eager=True, expose_value=False, callback=_set_stateless, help=t.stateless_help)
|
|
20
|
+
@click.option("--no-load", is_flag=True, default=None, help=t.no_load_help)
|
|
21
|
+
@click.option("--no-save", is_flag=True, default=None, help=t.no_save_help)
|
|
22
|
+
@click.option("--allow-active-missing-tools", is_flag=True, default=None, help=t.allow_active_missing_tools_help)
|
|
23
|
+
# --------------------------------------------------
|
|
24
|
+
# History
|
|
25
|
+
# --------------------------------------------------
|
|
26
|
+
@click.option("--event", "events", multiple=True, type=str, help=t.events_help)
|
|
27
|
+
@click.option("-f", "--file-info", "file_infos", multiple=True, type=str, help=t.file_infos_help)
|
|
28
|
+
@click.option("--tool-info", "tool_infos", multiple=True, type=str, help=t.tool_infos_help)
|
|
29
|
+
@click.option("--default-tool-state", type=click.Choice(["active", "inactive", "disabled"]), help=t.default_tool_state_help)
|
|
30
|
+
# --------------------------------------------------
|
|
31
|
+
# Agent
|
|
32
|
+
# --------------------------------------------------
|
|
33
|
+
@click.option("--agent", type=str, help=t.agent_help)
|
|
34
|
+
@click.option("--file-limits", type=str, help=t.file_limits_help)
|
|
35
|
+
@click.option("-n", "--max-iterations", type=int, help=t.max_iterations_help)
|
|
36
|
+
@click.option("--until-end/--no-until-end", is_flag=True, default=None, help=t.until_end_help)
|
|
37
|
+
@click.option("--until-tool-call", "until_tool_calls", multiple=True, type=str, help=t.until_tool_calls_help)
|
|
38
|
+
@click.option("--until-tool-run", "until_tool_runs", multiple=True, type=str, help=t.until_tool_runs_help)
|
|
39
|
+
# --------------------------------------------------
|
|
40
|
+
# Tool
|
|
41
|
+
# --------------------------------------------------
|
|
42
|
+
@click.option("-t", "--tool", "tools", multiple=True, type=str, help=t.tools_help)
|
|
43
|
+
@click.option("--pre-hook", "pre_hooks", multiple=True, type=str, help=t.pre_hooks_help)
|
|
44
|
+
@click.option("--post-hook", "post_hooks", multiple=True, type=str, help=t.post_hooks_help)
|
|
45
|
+
# --------------------------------------------------
|
|
46
|
+
# Workflow
|
|
47
|
+
# --------------------------------------------------
|
|
48
|
+
@click.option("--workflow", type=str, help=t.workflow_help)
|
|
49
|
+
# --------------------------------------------------
|
|
50
|
+
# Prompt
|
|
51
|
+
# --------------------------------------------------
|
|
52
|
+
@click.option("--prompt", type=str, help=t.prompt_help)
|
|
53
|
+
@click.option("--prompt-limits", type=str, help=t.prompt_limits_help)
|
|
54
|
+
@click.option("--system-message", "system_messages", multiple=True, type=str, help=t.system_messages_help)
|
|
55
|
+
# --------------------------------------------------
|
|
56
|
+
# Chat
|
|
57
|
+
# --------------------------------------------------
|
|
58
|
+
@click.option("--chat-model", type=str, help=t.chat_model_help)
|
|
59
|
+
@click.option("--openai", is_flag=True, default=None, is_eager=True, expose_value=False, callback=_set_openai, help=t.openai_help)
|
|
60
|
+
@click.option("--anthropic", is_flag=True, default=None, is_eager=True, expose_value=False, callback=_set_anthropic, help=t.anthropic_help)
|
|
61
|
+
@click.option("--google", is_flag=True, default=None, is_eager=True, expose_value=False, callback=_set_google, help=t.google_help)
|
|
62
|
+
@click.option("--tool-choice", type=str, help=t.tool_choice_help)
|
|
63
|
+
@click.option("--parallel-tool-calls/--no-parallel-tool-calls", default=None, help=t.parallel_tool_calls_help)
|
|
64
|
+
@click.option("--streaming/--no-streaming", default=None, help=t.streaming_help)
|
|
65
|
+
# --------------------------------------------------
|
|
66
|
+
# Cost Recorder
|
|
67
|
+
# --------------------------------------------------
|
|
68
|
+
@click.option("--cost-recorder", type=str, help=t.cost_recorder_help)
|
|
69
|
+
# --------------------------------------------------
|
|
70
|
+
# Observability
|
|
71
|
+
# --------------------------------------------------
|
|
72
|
+
@click.option("--request-logger", type=str, help=t.request_logger_help)
|
|
73
|
+
@click.option("--cost-logger", type=str, help=t.cost_logger_help)
|
|
74
|
+
@click.option("--chat-logger", type=str, help=t.chat_logger_help)
|
|
75
|
+
@click.option("--tool-logger", type=str, help=t.tool_logger_help)
|
|
76
|
+
# --------------------------------------------------
|
|
77
|
+
# Run Context
|
|
78
|
+
# --------------------------------------------------
|
|
79
|
+
@click.option("--organization-id", type=str, help=t.organization_id_help)
|
|
80
|
+
@click.option("--user-id", type=str, help=t.user_id_help)
|
|
81
|
+
@click.option("--agent-id", type=str, help=t.agent_id_help)
|
|
82
|
+
@click.option("--runner-id", type=str, help=t.node_id_help)
|
|
83
|
+
@click.option("--language", type=str, help=t.language_help)
|
|
84
|
+
@click.option("--time-zone", type=str, help=t.time_zone_help)
|
|
85
|
+
@click.option("--currency", type=str, help=t.currency_help)
|
|
86
|
+
# --------------------------------------------------
|
|
87
|
+
# GitHub
|
|
88
|
+
# --------------------------------------------------
|
|
89
|
+
@click.option("--github-ignore-cache", is_flag=True, default=None, help=t.github_ignore_cache_help)
|
|
90
|
+
@click.option("--github-trusted-username", "github_trusted_usernames", multiple=True, type=str, help=t.github_trusted_username_help)
|
|
91
|
+
@click.option("--github-skip-trust-verification", is_flag=True, default=None, help=t.github_skip_trust_verification_help)
|
|
92
|
+
@functools.wraps(func)
|
|
93
|
+
# --------------------------------------------------
|
|
94
|
+
# Config
|
|
95
|
+
# --------------------------------------------------
|
|
96
|
+
@click.option("--i18n-catalog", "i18n_catalogs", multiple=True, type=str, help=t.i18n_catalog_help)
|
|
97
|
+
@click.option("--config", "configs", multiple=True, type=str, help=t.config_file_help)
|
|
98
|
+
@click.option("-c", "--config-var", "config_vars", multiple=True, type=str, help=t.config_var_help)
|
|
99
|
+
@click.option("--plugin", "plugins", multiple=True, type=str, help=t.plugin_help)
|
|
100
|
+
# --------------------------------------------------
|
|
101
|
+
# Logging
|
|
102
|
+
# --------------------------------------------------
|
|
103
|
+
@click.option("--logger-name", "logger_names", multiple=True, type=str, help=t.logger_name_help)
|
|
104
|
+
@click.option("--log-level", type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]), default=None, help=t.log_level_help)
|
|
105
|
+
@click.option("-v", "--verbose", is_flag=True, default=None, callback=_set_verbose, help=t.verbose_help)
|
|
106
|
+
@click.option("-q", "--quiet", is_flag=True, default=None, callback=_set_quiet, help=t.quiet_help)
|
|
107
|
+
# --------------------------------------------------
|
|
108
|
+
# Profile
|
|
109
|
+
# --------------------------------------------------
|
|
110
|
+
@click.option("-p", "--profile", "profile_name", type=str, default=None, help=t.profile_help)
|
|
111
|
+
@click.option("--set", "--set-profile", is_flag=True, is_eager=True, expose_value=False, callback=_set_profile, help=t.set_profile_help)
|
|
112
|
+
@click.option("--reset", "--reset-profile", is_flag=True, is_eager=True, expose_value=False, callback=_reset_profile, help=t.reset_profile_help)
|
|
113
|
+
# --------------------------------------------------
|
|
114
|
+
# CLI
|
|
115
|
+
# --------------------------------------------------
|
|
116
|
+
@click.option("-x", "--exec", "exec_file", type=str, help=t.exec_file_help)
|
|
117
|
+
@click.option("--finalizer", "finalizers", multiple=True, type=str, help=t.finalizers_help)
|
|
118
|
+
@functools.wraps(func)
|
|
119
|
+
# fmt: on
|
|
120
|
+
def wrapper(*args, **kwargs):
|
|
121
|
+
return func(*args, **kwargs)
|
|
122
|
+
|
|
123
|
+
return wrapper
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _set_profile(ctx: click.Context, _: click.Parameter, value: Any) -> Any:
|
|
127
|
+
if not value:
|
|
128
|
+
return value
|
|
129
|
+
|
|
130
|
+
ctx.params["save_mode"] = "set"
|
|
131
|
+
return value
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _reset_profile(ctx: click.Context, _: click.Parameter, value: Any) -> Any:
|
|
135
|
+
if not value:
|
|
136
|
+
return value
|
|
137
|
+
|
|
138
|
+
ctx.params["save_mode"] = "reset"
|
|
139
|
+
return value
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _set_stateless(ctx: click.Context, _: click.Parameter, value: Any) -> Any:
|
|
143
|
+
if not value:
|
|
144
|
+
return value
|
|
145
|
+
|
|
146
|
+
ctx.params["no_load"] = True
|
|
147
|
+
ctx.params["no_save"] = True
|
|
148
|
+
return value
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def _set_openai(ctx: click.Context, _: click.Parameter, value: Any) -> Any:
|
|
152
|
+
if not value:
|
|
153
|
+
return value
|
|
154
|
+
|
|
155
|
+
ctx.params["chat_model"] = "openai"
|
|
156
|
+
return value
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _set_anthropic(ctx: click.Context, _: click.Parameter, value: Any) -> Any:
|
|
160
|
+
if not value:
|
|
161
|
+
return value
|
|
162
|
+
|
|
163
|
+
ctx.params["chat_model"] = "anthropic"
|
|
164
|
+
return value
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _set_google(ctx: click.Context, _: click.Parameter, value: Any) -> Any:
|
|
168
|
+
if not value:
|
|
169
|
+
return value
|
|
170
|
+
|
|
171
|
+
ctx.params["chat_model"] = "google"
|
|
172
|
+
return value
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _set_verbose(ctx: click.Context, _: click.Parameter, value: Any) -> Any:
|
|
176
|
+
if not value:
|
|
177
|
+
return value
|
|
178
|
+
|
|
179
|
+
ctx.params["log_level"] = "DEBUG"
|
|
180
|
+
return value
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _set_quiet(ctx: click.Context, _: click.Parameter, value: Any) -> Any:
|
|
184
|
+
if not value:
|
|
185
|
+
return value
|
|
186
|
+
|
|
187
|
+
ctx.params["log_level"] = "WARNING"
|
|
188
|
+
return value
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from kiari.core.profile import ProfileName
|
|
4
|
+
|
|
5
|
+
from .._schemas.cli_args import CLIArgs
|
|
6
|
+
from .._types.save_mode import SaveMode
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def build_cli_args(
|
|
10
|
+
exec_file: str | None = None,
|
|
11
|
+
profile_name: ProfileName | None = None,
|
|
12
|
+
save_mode: SaveMode | None = None,
|
|
13
|
+
extra_args_keys: list[str] | None = None,
|
|
14
|
+
markdown_content_key: str | None = None,
|
|
15
|
+
**kwargs: Any,
|
|
16
|
+
) -> CLIArgs:
|
|
17
|
+
run_spec = _normalize_kwargs(kwargs)
|
|
18
|
+
|
|
19
|
+
extra_args = {}
|
|
20
|
+
|
|
21
|
+
if exec_file:
|
|
22
|
+
file_args: dict[str, Any] | None = None
|
|
23
|
+
|
|
24
|
+
if exec_file.endswith(".json"):
|
|
25
|
+
from kiarina.utils.file import read_json_dict
|
|
26
|
+
|
|
27
|
+
file_args = read_json_dict(exec_file)
|
|
28
|
+
|
|
29
|
+
elif exec_file.endswith(".yaml") or exec_file.endswith(".yml"):
|
|
30
|
+
from kiarina.utils.file import read_yaml_dict
|
|
31
|
+
|
|
32
|
+
file_args = read_yaml_dict(exec_file)
|
|
33
|
+
|
|
34
|
+
elif exec_file.endswith(".md") or exec_file.endswith(".markdown"):
|
|
35
|
+
from kiarina.utils.file import read_markdown
|
|
36
|
+
|
|
37
|
+
if markdown_content := read_markdown(exec_file):
|
|
38
|
+
file_args = markdown_content.metadata
|
|
39
|
+
|
|
40
|
+
if markdown_content_key:
|
|
41
|
+
extra_args[markdown_content_key] = markdown_content.content
|
|
42
|
+
|
|
43
|
+
else: # pragma: no cover
|
|
44
|
+
raise ValueError(f"Unsupported file type: {exec_file}")
|
|
45
|
+
|
|
46
|
+
if file_args is None:
|
|
47
|
+
raise FileNotFoundError(f"File not found: {exec_file}")
|
|
48
|
+
|
|
49
|
+
run_spec = {**file_args, **run_spec}
|
|
50
|
+
|
|
51
|
+
if extra_args_keys:
|
|
52
|
+
for key in extra_args_keys:
|
|
53
|
+
if key in run_spec:
|
|
54
|
+
extra_args[key] = run_spec.pop(key)
|
|
55
|
+
|
|
56
|
+
return CLIArgs(
|
|
57
|
+
exec_file=exec_file,
|
|
58
|
+
profile_name=profile_name,
|
|
59
|
+
save_mode=save_mode,
|
|
60
|
+
run_spec=run_spec,
|
|
61
|
+
extra_args=extra_args,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _normalize_kwargs(kwargs: dict[str, Any]) -> dict[str, Any]:
|
|
66
|
+
return {
|
|
67
|
+
k: v if not isinstance(v, tuple) else list(v)
|
|
68
|
+
for k, v in kwargs.items()
|
|
69
|
+
if v is not None and (not isinstance(v, tuple) or len(v) > 0)
|
|
70
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from kiarina.agi.console_utils import divider, section_header
|
|
2
|
+
from rich.console import Group, RenderableType
|
|
3
|
+
from rich.text import Text
|
|
4
|
+
|
|
5
|
+
from kiari.core.profile import ProfileName, RunOptions, RunSpec
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def render_bootstrap_message(
|
|
9
|
+
exec_file: str | None,
|
|
10
|
+
profile_name: ProfileName,
|
|
11
|
+
run_spec: RunSpec,
|
|
12
|
+
run_options: RunOptions,
|
|
13
|
+
) -> RenderableType | None:
|
|
14
|
+
if run_options.log_level not in ("DEBUG", "INFO"):
|
|
15
|
+
return None
|
|
16
|
+
|
|
17
|
+
style = "black"
|
|
18
|
+
|
|
19
|
+
renderables: list[RenderableType] = [
|
|
20
|
+
Text("kiari version 1.0.0", style=style),
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
if exec_file:
|
|
24
|
+
renderables.append(Text(f"+ exec: {exec_file}", style=style))
|
|
25
|
+
|
|
26
|
+
renderables.append(Text(f"+ profile: {profile_name}", style=style))
|
|
27
|
+
renderables.append(Text(section_header("RUN OPTIONS"), style=style))
|
|
28
|
+
|
|
29
|
+
if run_spec:
|
|
30
|
+
for k, v in run_spec.items():
|
|
31
|
+
renderables.append(Text(f"{k}: {v}", style=style))
|
|
32
|
+
else:
|
|
33
|
+
renderables.append(Text("No run options specified", style=style))
|
|
34
|
+
|
|
35
|
+
renderables.append(Text(divider(), style=style))
|
|
36
|
+
|
|
37
|
+
return Group(*renderables)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from kiari.core.finalizer import run_finalizers
|
|
5
|
+
from kiari.core.profile import ProfileName, RunOptions
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def run(
|
|
9
|
+
runner: Callable,
|
|
10
|
+
profile_name: ProfileName,
|
|
11
|
+
run_options: RunOptions,
|
|
12
|
+
*args: Any,
|
|
13
|
+
**kwargs: Any,
|
|
14
|
+
) -> None:
|
|
15
|
+
try:
|
|
16
|
+
await runner(profile_name, run_options, *args, **kwargs)
|
|
17
|
+
finally:
|
|
18
|
+
await run_finalizers(run_options.finalizers)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from kiari.core.profile import ProfileName, RunOptions, RunSpec, profile_store
|
|
2
|
+
|
|
3
|
+
from .._types.save_mode import SaveMode
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def setup_profile(
|
|
7
|
+
profile_name: ProfileName | None,
|
|
8
|
+
save_mode: SaveMode | None,
|
|
9
|
+
run_spec: RunSpec,
|
|
10
|
+
) -> tuple[ProfileName, RunSpec, RunOptions]:
|
|
11
|
+
if not profile_name:
|
|
12
|
+
profile_name = profile_store.get_current()
|
|
13
|
+
|
|
14
|
+
if save_mode != "reset":
|
|
15
|
+
run_spec = {
|
|
16
|
+
**profile_store.load_run_spec(profile_name),
|
|
17
|
+
**run_spec,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if save_mode in ("set", "reset"):
|
|
21
|
+
profile_store.save_run_spec(profile_name, run_spec)
|
|
22
|
+
|
|
23
|
+
run_options = RunOptions.model_validate(run_spec)
|
|
24
|
+
return profile_name, run_spec, run_options
|