collavre 0.25.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -10
- data/app/assets/images/collavre/kollavy.png +0 -0
- data/app/assets/images/collavre/kollavy.svg +9 -0
- data/app/assets/stylesheets/collavre/actiontext.css +24 -165
- data/app/assets/stylesheets/collavre/activity_logs.css +23 -12
- data/app/assets/stylesheets/collavre/agent_connections.css +196 -0
- data/app/assets/stylesheets/collavre/agent_gateways.css +153 -0
- data/app/assets/stylesheets/collavre/attachment_card.css +34 -0
- data/app/assets/stylesheets/collavre/comments_popup.css +512 -87
- data/app/assets/stylesheets/collavre/creatives.css +827 -126
- data/app/assets/stylesheets/collavre/dark_mode.css +0 -20
- data/app/assets/stylesheets/collavre/design_tokens.css +79 -0
- data/app/assets/stylesheets/collavre/desktop_setup.css +0 -5
- data/app/assets/stylesheets/collavre/image_lightbox.css +12 -0
- data/app/assets/stylesheets/collavre/landing.css +23 -104
- data/app/assets/stylesheets/collavre/llm_usages.css +67 -0
- data/app/assets/stylesheets/collavre/mention_menu.css +18 -0
- data/app/assets/stylesheets/collavre/modal_dialog.css +66 -3
- data/app/assets/stylesheets/collavre/notice_bar.css +465 -0
- data/app/assets/stylesheets/collavre/org_chart.css +0 -4
- data/app/assets/stylesheets/collavre/popup.css +15 -18
- data/app/assets/stylesheets/collavre/search_popup.css +0 -34
- data/app/assets/stylesheets/collavre/slide_view.css +221 -4
- data/app/assets/stylesheets/collavre/workflow_editor.css +101 -0
- data/app/assets/stylesheets/collavre/workspace.css +13 -10
- data/app/channels/collavre/agent_channel.rb +48 -23
- data/app/components/collavre/command_menu_component.html.erb +5 -0
- data/app/components/collavre/command_menu_component.rb +8 -0
- data/app/components/collavre/comment_user_menu_component.html.erb +61 -0
- data/app/components/collavre/comment_user_menu_component.rb +14 -0
- data/app/components/collavre/cron_badge_component.html.erb +80 -0
- data/app/components/collavre/cron_badge_component.rb +50 -0
- data/app/controllers/collavre/admin/orchestration_controller.rb +59 -32
- data/app/controllers/collavre/admin/settings_controller.rb +77 -8
- data/app/controllers/collavre/agent_connections_controller.rb +9 -21
- data/app/controllers/collavre/agent_models_controller.rb +55 -0
- data/app/controllers/collavre/agent_provisioning_controller.rb +31 -22
- data/app/controllers/collavre/api/v1/agents_controller.rb +47 -163
- data/app/controllers/collavre/api/v1/task_suspensions_controller.rb +60 -0
- data/app/controllers/collavre/attachments_controller.rb +12 -12
- data/app/controllers/collavre/comments/activity_logs_controller.rb +2 -0
- data/app/controllers/collavre/comments/reactions_controller.rb +10 -12
- data/app/controllers/collavre/comments/resends_controller.rb +21 -0
- data/app/controllers/collavre/comments/versions_controller.rb +24 -21
- data/app/controllers/collavre/comments_controller.rb +61 -10
- data/app/controllers/collavre/concerns/creative_history_trackable.rb +31 -0
- data/app/controllers/collavre/concerns/tree_manageable.rb +4 -0
- data/app/controllers/collavre/creative_change_sets_controller.rb +112 -0
- data/app/controllers/collavre/creative_imports_controller.rb +9 -1
- data/app/controllers/collavre/creative_invitations_controller.rb +2 -11
- data/app/controllers/collavre/creative_shares_controller.rb +7 -15
- data/app/controllers/collavre/creatives/attachments_controller.rb +16 -4
- data/app/controllers/collavre/creatives/file_drops_controller.rb +35 -0
- data/app/controllers/collavre/creatives/ppt_previews_controller.rb +66 -0
- data/app/controllers/collavre/creatives_controller.rb +49 -272
- data/app/controllers/collavre/crons_controller.rb +48 -0
- data/app/controllers/collavre/desktop_gateway_registrations_controller.rb +2 -19
- data/app/controllers/collavre/desktop_setup_controller.rb +2 -19
- data/app/controllers/collavre/desktop_sidecar_health_controller.rb +2 -14
- data/app/controllers/collavre/google_auth_controller.rb +3 -4
- data/app/controllers/collavre/inline_agent_logins_controller.rb +79 -0
- data/app/controllers/collavre/llm_usages_controller.rb +51 -0
- data/app/controllers/collavre/onboarding_replays_controller.rb +10 -0
- data/app/controllers/collavre/public_assets_controller.rb +48 -4
- data/app/controllers/collavre/seo_controller.rb +83 -0
- data/app/controllers/collavre/sessions_controller.rb +5 -9
- data/app/controllers/collavre/topics_controller.rb +17 -32
- data/app/controllers/collavre/user_creative_preferences_controller.rb +26 -59
- data/app/controllers/collavre/user_notices_controller.rb +64 -0
- data/app/controllers/collavre/user_themes_controller.rb +11 -7
- data/app/controllers/collavre/users_controller.rb +1 -0
- data/app/controllers/concerns/collavre/active_storage_access.rb +127 -0
- data/app/controllers/concerns/collavre/api/claude_channel_prompts.rb +209 -0
- data/app/controllers/concerns/collavre/blob_access_control.rb +57 -0
- data/app/controllers/concerns/collavre/comments/approval_actions.rb +24 -22
- data/app/controllers/concerns/collavre/comments/approval_gate_actions.rb +29 -0
- data/app/controllers/concerns/collavre/comments/batch_operations.rb +1 -1
- data/app/controllers/concerns/collavre/comments/comment_scoping.rb +4 -2
- data/app/controllers/concerns/collavre/comments/history_topic_guard.rb +22 -0
- data/app/controllers/concerns/collavre/creative_destroyable.rb +41 -0
- data/app/controllers/concerns/collavre/creative_permission_guard.rb +6 -0
- data/app/controllers/concerns/collavre/creative_type_editable.rb +76 -0
- data/app/controllers/concerns/collavre/loopback_request.rb +32 -0
- data/app/controllers/concerns/collavre/origin_verification.rb +29 -0
- data/app/controllers/concerns/collavre/permission_update_response.rb +23 -0
- data/app/controllers/concerns/collavre/proxy_error_response.rb +14 -0
- data/app/controllers/concerns/collavre/public_creative_page.rb +52 -0
- data/app/controllers/concerns/collavre/public_creative_redirectable.rb +31 -0
- data/app/controllers/concerns/collavre/successful_authentication.rb +12 -0
- data/app/controllers/concerns/collavre/svg_streaming.rb +39 -0
- data/app/controllers/concerns/collavre/topics/reserved_topic_guard.rb +52 -0
- data/app/controllers/concerns/collavre/user_creative_preferences_controller/persistence.rb +98 -0
- data/app/controllers/concerns/collavre/users_controller/admin_operations.rb +38 -12
- data/app/controllers/concerns/collavre/users_controller/ai_profile_access.rb +25 -0
- data/app/controllers/concerns/collavre/users_controller/ai_user_management.rb +80 -40
- data/app/controllers/concerns/collavre/users_controller/contact_management.rb +31 -18
- data/app/controllers/concerns/collavre/users_controller/profile_and_settings.rb +15 -1
- data/app/controllers/concerns/collavre/users_controller/registration.rb +7 -11
- data/app/controllers/concerns/collavre/workflow_editable.rb +112 -0
- data/app/errors/collavre/approval_gate_pending_error.rb +12 -0
- data/app/errors/collavre/approval_pending_error.rb +5 -2
- data/app/errors/collavre/screening_pending_error.rb +17 -0
- data/app/errors/collavre/task_suspended_error.rb +11 -0
- data/app/helpers/collavre/activity_logs_helper.rb +26 -0
- data/app/helpers/collavre/application_helper.rb +10 -44
- data/app/helpers/collavre/creative_move_helper.rb +15 -0
- data/app/helpers/collavre/creatives_helper.rb +117 -65
- data/app/helpers/collavre/navigation_helper.rb +122 -0
- data/app/helpers/collavre/public_assets_helper.rb +14 -0
- data/app/helpers/collavre/public_creatives_helper.rb +44 -0
- data/app/javascript/__tests__/slide_view.test.js +30 -0
- data/app/javascript/collavre.js +3 -0
- data/app/javascript/collavre_pdf_viewer.js +3 -0
- data/app/javascript/collavre_pdf_worker.js +1 -0
- data/app/javascript/comments/__tests__/user_menu.test.js +137 -0
- data/app/javascript/comments/user_menu.js +205 -0
- data/app/javascript/components/EmojiPicker.js +90 -0
- data/app/javascript/components/HeadingButtons.js +45 -0
- data/app/javascript/components/HistoryButtons.jsx +26 -0
- data/app/javascript/components/ImageResizer.jsx +11 -30
- data/app/javascript/components/InlineLexicalEditor.jsx +19 -77
- data/app/javascript/components/__tests__/EmojiPicker.test.js +127 -0
- data/app/javascript/components/__tests__/HeadingButtons.test.js +111 -0
- data/app/javascript/components/__tests__/creative_tree_row_document_view.test.js +814 -0
- data/app/javascript/components/__tests__/creative_tree_row_progress_toggle.test.js +72 -2
- data/app/javascript/components/__tests__/document_row_swipe.test.js +206 -0
- data/app/javascript/components/creative_header_progress.js +24 -0
- data/app/javascript/components/creative_tree_row.js +39 -82
- data/app/javascript/components/creative_tree_row_document_view.js +251 -0
- data/app/javascript/components/document_row_swipe.js +107 -0
- data/app/javascript/components/plugins/__tests__/creative_links_plugin.test.js +59 -0
- data/app/javascript/components/plugins/__tests__/image_upload_plugin.test.js +107 -0
- data/app/javascript/components/plugins/creative_links_plugin.js +24 -0
- data/app/javascript/components/plugins/image_upload_plugin.jsx +24 -28
- data/app/javascript/components/plugins/markdown_shortcuts_plugin.jsx +5 -2
- data/app/javascript/controllers/__tests__/agent_connection_controller.test.js +433 -3
- data/app/javascript/controllers/__tests__/agent_vendor_controller.test.js +94 -0
- data/app/javascript/controllers/__tests__/comment_agent_model_controller.test.js +148 -0
- data/app/javascript/controllers/__tests__/comment_approval_controls.test.js +45 -0
- data/app/javascript/controllers/__tests__/comment_user_menu_controller.test.js +285 -0
- data/app/javascript/controllers/__tests__/comment_version_controller.test.js +51 -0
- data/app/javascript/controllers/__tests__/controller_csrf_requests.test.js +137 -0
- data/app/javascript/controllers/__tests__/creative_history_controller.test.js +123 -0
- data/app/javascript/controllers/__tests__/creative_history_detail_controller.test.js +104 -0
- data/app/javascript/controllers/__tests__/creative_history_undo_controller.test.js +55 -0
- data/app/javascript/controllers/__tests__/creative_image_lightbox_controller.test.js +583 -0
- data/app/javascript/controllers/__tests__/creative_move_controller.test.js +713 -0
- data/app/javascript/controllers/__tests__/cron_badge_controller.test.js +436 -0
- data/app/javascript/controllers/__tests__/document_preview_controller.test.js +33 -0
- data/app/javascript/controllers/__tests__/entity_list_controller.test.js +270 -0
- data/app/javascript/controllers/__tests__/expansion_controller.test.js +235 -0
- data/app/javascript/controllers/__tests__/index.test.js +6 -0
- data/app/javascript/controllers/__tests__/inline_creative_picker_controller.test.js +232 -0
- data/app/javascript/controllers/__tests__/link_creative_controller.test.js +101 -0
- data/app/javascript/controllers/__tests__/notice_bar_controller.test.js +1076 -0
- data/app/javascript/controllers/__tests__/popup_menu_controller.test.js +267 -0
- data/app/javascript/controllers/__tests__/search_popup_controller.test.js +46 -32
- data/app/javascript/controllers/__tests__/share_modal_public_link.test.js +113 -0
- data/app/javascript/controllers/__tests__/share_user_search_controller.test.js +17 -0
- data/app/javascript/controllers/__tests__/tabs_controller.test.js +137 -0
- data/app/javascript/controllers/__tests__/tool_category_controller.test.js +116 -0
- data/app/javascript/controllers/__tests__/topic_list_controller.test.js +14 -0
- data/app/javascript/controllers/__tests__/workspace_tree_controller.test.js +757 -22
- data/app/javascript/controllers/agent_auth_controller.js +245 -0
- data/app/javascript/controllers/agent_connection_controller.js +29 -189
- data/app/javascript/controllers/agent_vendor_controller.js +47 -1
- data/app/javascript/controllers/comment_agent_model_controller.js +87 -0
- data/app/javascript/controllers/comment_controller.js +34 -77
- data/app/javascript/controllers/comment_image_lightbox_controller.js +15 -0
- data/app/javascript/controllers/comment_user_menu_controller.js +122 -0
- data/app/javascript/controllers/comment_version_controller.js +10 -8
- data/app/javascript/controllers/comments/__tests__/comment_form_request.test.js +72 -0
- data/app/javascript/controllers/comments/__tests__/comment_list_response.test.js +30 -0
- data/app/javascript/controllers/comments/__tests__/comment_read_tracker.test.js +71 -0
- data/app/javascript/controllers/comments/__tests__/contexts_controller_context_list.test.js +466 -0
- data/app/javascript/controllers/comments/__tests__/contexts_controller_dnd.test.js +484 -0
- data/app/javascript/controllers/comments/__tests__/creative_quote_review_controller.test.js +111 -0
- data/app/javascript/controllers/comments/__tests__/drop_trigger_controller.test.js +48 -0
- data/app/javascript/controllers/comments/__tests__/feature_cards_controller.test.js +2 -2
- data/app/javascript/controllers/comments/__tests__/form_controller_double_submit.test.js +38 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_draft.test.js +202 -17
- data/app/javascript/controllers/comments/__tests__/form_controller_review.test.js +375 -0
- data/app/javascript/controllers/comments/__tests__/form_controller_stashed_draft.test.js +4 -4
- data/app/javascript/controllers/comments/__tests__/form_controller_stashed_draft_creative_switch.test.js +2 -2
- data/app/javascript/controllers/comments/__tests__/form_draft_manager.test.js +154 -0
- data/app/javascript/controllers/comments/__tests__/inline_login_preservation.test.js +23 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_approval_gate.test.js +51 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_batch_delete.test.js +97 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_dnd.test.js +26 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_docked.test.js +54 -1
- data/app/javascript/controllers/comments/__tests__/list_controller_load_result.test.js +56 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_loading.test.js +43 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_prev_message.test.js +202 -1
- data/app/javascript/controllers/comments/__tests__/list_controller_read_pointer.test.js +12 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_resend.test.js +69 -0
- data/app/javascript/controllers/comments/__tests__/list_controller_resume_pagination.test.js +191 -0
- data/app/javascript/controllers/comments/__tests__/loading_controller.test.js +83 -0
- data/app/javascript/controllers/comments/__tests__/mention_menu_controller.test.js +59 -0
- data/app/javascript/controllers/comments/__tests__/popup_controller.test.js +318 -4
- data/app/javascript/controllers/comments/__tests__/popup_exit_target.test.js +118 -0
- data/app/javascript/controllers/comments/__tests__/popup_focus.test.js +72 -0
- data/app/javascript/controllers/comments/__tests__/popup_fullscreen.test.js +320 -0
- data/app/javascript/controllers/comments/__tests__/popup_initial_url.test.js +103 -0
- data/app/javascript/controllers/comments/__tests__/popup_resume_resync.test.js +154 -0
- data/app/javascript/controllers/comments/__tests__/presence_controller.test.js +58 -0
- data/app/javascript/controllers/comments/__tests__/presence_controller_agent_online.test.js +244 -0
- data/app/javascript/controllers/comments/__tests__/presence_controller_participant_list.test.js +570 -0
- data/app/javascript/controllers/comments/__tests__/resend_action.test.js +137 -0
- data/app/javascript/controllers/comments/__tests__/review_quotes_store.test.js +27 -0
- data/app/javascript/controllers/comments/__tests__/run_options_controller.test.js +248 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_archived.test.js +45 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_creation_container.test.js +165 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_delete.test.js +231 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_dnd.test.js +120 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_scroll.test.js +17 -0
- data/app/javascript/controllers/comments/__tests__/topics_controller_selection_race.test.js +274 -2
- data/app/javascript/controllers/comments/__tests__/topics_controller_topic_list.test.js +4 -4
- data/app/javascript/controllers/comments/approval_request_options.js +12 -0
- data/app/javascript/controllers/comments/comment_form_request.js +26 -0
- data/app/javascript/controllers/comments/comment_list_response.js +20 -0
- data/app/javascript/controllers/comments/comment_read_tracker.js +143 -0
- data/app/javascript/controllers/comments/contexts_controller.js +338 -226
- data/app/javascript/controllers/comments/creative_chat_navigation.js +50 -0
- data/app/javascript/controllers/comments/creative_quote_review_controller.js +30 -0
- data/app/javascript/controllers/comments/drop_trigger_controller.js +2 -7
- data/app/javascript/controllers/comments/feature_cards_controller.js +1 -1
- data/app/javascript/controllers/comments/form_controller.js +128 -706
- data/app/javascript/controllers/comments/form_draft_manager.js +269 -0
- data/app/javascript/controllers/comments/form_draft_migration.js +142 -0
- data/app/javascript/controllers/comments/form_draft_persistence.js +228 -0
- data/app/javascript/controllers/comments/inline_login_preservation.js +18 -0
- data/app/javascript/controllers/comments/list_controller.js +105 -273
- data/app/javascript/controllers/comments/loading_controller.js +48 -0
- data/app/javascript/controllers/comments/mention_menu_controller.js +1 -24
- data/app/javascript/controllers/comments/optimistic_removal.js +15 -0
- data/app/javascript/controllers/comments/pagination_state.js +20 -0
- data/app/javascript/controllers/comments/popup_controller.js +74 -510
- data/app/javascript/controllers/comments/popup_creative_progress.js +51 -0
- data/app/javascript/controllers/comments/popup_exit_target.js +92 -0
- data/app/javascript/controllers/comments/popup_focus.js +5 -0
- data/app/javascript/controllers/comments/popup_fullscreen.js +335 -0
- data/app/javascript/controllers/comments/popup_resume_resync.js +28 -0
- data/app/javascript/controllers/comments/popup_url_open.js +22 -0
- data/app/javascript/controllers/comments/presence_controller.js +295 -142
- data/app/javascript/controllers/comments/previous_message_navigation.js +154 -0
- data/app/javascript/controllers/comments/resend_action.js +63 -0
- data/app/javascript/controllers/comments/review_quotes_store.js +11 -8
- data/app/javascript/controllers/comments/run_options_controller.js +145 -0
- data/app/javascript/controllers/comments/topics/last_topic_save.js +124 -0
- data/app/javascript/controllers/comments/topics/reserved_topic_deletion.js +25 -0
- data/app/javascript/controllers/comments/topics/save_order_state.js +127 -0
- data/app/javascript/controllers/comments/topics/selection_restore_state.js +42 -0
- data/app/javascript/controllers/comments/topics/self_echo_state.js +24 -0
- data/app/javascript/controllers/comments/topics_controller.js +336 -478
- data/app/javascript/controllers/creative_history_controller.js +57 -0
- data/app/javascript/controllers/creative_history_detail_controller.js +41 -0
- data/app/javascript/controllers/creative_history_undo_controller.js +19 -0
- data/app/javascript/controllers/creative_image_lightbox_controller.js +114 -0
- data/app/javascript/controllers/creative_move_controller.js +202 -0
- data/app/javascript/controllers/creatives/__tests__/document_selection_controller.test.js +241 -0
- data/app/javascript/controllers/creatives/__tests__/document_view_controller.test.js +173 -0
- data/app/javascript/controllers/creatives/__tests__/drag_drop_controller.test.js +74 -0
- data/app/javascript/controllers/creatives/__tests__/import_controller.test.js +48 -0
- data/app/javascript/controllers/creatives/__tests__/select_mode_controller.test.js +111 -0
- data/app/javascript/controllers/creatives/__tests__/tree_controller.test.js +605 -2
- data/app/javascript/controllers/creatives/__tests__/workflow_rule_controller.test.js +322 -0
- data/app/javascript/controllers/creatives/document_selection_controller.js +77 -0
- data/app/javascript/controllers/creatives/document_view_controller.js +82 -0
- data/app/javascript/controllers/creatives/drag_drop_controller.js +13 -19
- data/app/javascript/controllers/creatives/expansion_controller.js +21 -19
- data/app/javascript/controllers/creatives/import_controller.js +1 -1
- data/app/javascript/controllers/creatives/select_mode_controller.js +31 -4
- data/app/javascript/controllers/creatives/tree_controller.js +128 -36
- data/app/javascript/controllers/creatives/workflow_rule_controller.js +96 -0
- data/app/javascript/controllers/creatives/workflow_rule_form.js +183 -0
- data/app/javascript/controllers/cron_badge_controller.js +187 -0
- data/app/javascript/controllers/document_preview_controller.js +16 -0
- data/app/javascript/controllers/entity_list_controller.js +147 -0
- data/app/javascript/controllers/gateway_check_controller.js +3 -5
- data/app/javascript/controllers/image_lightbox_controller.js +29 -70
- data/app/javascript/controllers/image_lightbox_values.js +13 -0
- data/app/javascript/controllers/index.js +85 -11
- data/app/javascript/controllers/inline_creative_picker_controller.js +110 -0
- data/app/javascript/controllers/link_creative_controller.js +14 -11
- data/app/javascript/controllers/notice_bar_controller.js +364 -0
- data/app/javascript/controllers/org_chart_controller.js +2 -23
- data/app/javascript/controllers/popup_menu_controller.js +128 -45
- data/app/javascript/controllers/search_popup_controller.js +12 -8
- data/app/javascript/controllers/searchable_list_controller.js +30 -0
- data/app/javascript/controllers/share_modal_controller.js +18 -56
- data/app/javascript/controllers/share_user_search_controller.js +1 -11
- data/app/javascript/controllers/tabs_controller.js +5 -1
- data/app/javascript/controllers/tool_category_controller.js +39 -0
- data/app/javascript/controllers/topic_list_controller.js +5 -31
- data/app/javascript/controllers/topic_search_controller.js +2 -4
- data/app/javascript/controllers/workspace_tree_controller.js +194 -53
- data/app/javascript/creatives/__tests__/row_progress.test.js +155 -0
- data/app/javascript/creatives/__tests__/tree_reload_events.test.js +101 -0
- data/app/javascript/creatives/__tests__/tree_renderer.test.js +116 -1
- data/app/javascript/creatives/__tests__/tree_view_state.test.js +277 -0
- data/app/javascript/creatives/branch_expansion.js +39 -0
- data/app/javascript/creatives/drag_drop/__tests__/command_integration.test.js +194 -0
- data/app/javascript/creatives/drag_drop/__tests__/creative_tree_drop.test.js +964 -0
- data/app/javascript/creatives/drag_drop/__tests__/event_handlers_data.test.js +329 -0
- data/app/javascript/creatives/drag_drop/__tests__/file_drop.test.js +99 -0
- data/app/javascript/creatives/drag_drop/__tests__/hover_expand.test.js +134 -0
- data/app/javascript/creatives/drag_drop/__tests__/indicator.test.js +36 -0
- data/app/javascript/creatives/drag_drop/__tests__/move_command.test.js +471 -0
- data/app/javascript/creatives/drag_drop/__tests__/move_command_dom_recovery.test.js +346 -0
- data/app/javascript/creatives/drag_drop/__tests__/move_command_queued_saves.test.js +201 -0
- data/app/javascript/creatives/drag_drop/__tests__/move_feedback.test.js +79 -0
- data/app/javascript/creatives/drag_drop/__tests__/source_window_bundle.test.js +141 -0
- data/app/javascript/creatives/drag_drop/__tests__/state.test.js +36 -0
- data/app/javascript/creatives/drag_drop/__tests__/touch_tree_integration.test.js +209 -0
- data/app/javascript/creatives/drag_drop/__tests__/workspace_tree_adapter.test.js +517 -0
- data/app/javascript/creatives/drag_drop/__tests__/workspace_tree_dom.test.js +105 -0
- data/app/javascript/creatives/drag_drop/dom.js +9 -0
- data/app/javascript/creatives/drag_drop/event_handlers.js +279 -431
- data/app/javascript/creatives/drag_drop/file_drop.js +60 -0
- data/app/javascript/creatives/drag_drop/indicator.js +2 -1
- data/app/javascript/creatives/drag_drop/move_command.js +297 -0
- data/app/javascript/creatives/drag_drop/move_feedback.js +22 -0
- data/app/javascript/creatives/drag_drop/operations.js +73 -0
- data/app/javascript/creatives/drag_drop/state.js +10 -1
- data/app/javascript/creatives/drag_drop/workspace_tree_adapter.js +161 -0
- data/app/javascript/creatives/drag_drop/workspace_tree_dom.js +52 -0
- data/app/javascript/creatives/row_progress.js +96 -0
- data/app/javascript/creatives/tree_reload_events.js +42 -0
- data/app/javascript/creatives/tree_renderer.js +70 -21
- data/app/javascript/creatives/tree_view_state.js +87 -0
- data/app/javascript/lib/__tests__/creative_quote.test.js +343 -0
- data/app/javascript/lib/__tests__/creative_title.test.js +15 -0
- data/app/javascript/lib/__tests__/entity_list_popup.test.js +47 -0
- data/app/javascript/lib/__tests__/html_escape.test.js +29 -0
- data/app/javascript/lib/__tests__/permission_update.test.js +38 -0
- data/app/javascript/lib/__tests__/popup_toggle_guard.test.js +82 -0
- data/app/javascript/lib/__tests__/ppt_background.test.js +86 -0
- data/app/javascript/lib/__tests__/ppt_connector.test.js +80 -0
- data/app/javascript/lib/__tests__/ppt_formatting.test.js +246 -0
- data/app/javascript/lib/__tests__/ppt_media.test.js +86 -0
- data/app/javascript/lib/__tests__/quote_selection_popup.test.js +100 -0
- data/app/javascript/lib/__tests__/touch_drag_tap.test.js +31 -0
- data/app/javascript/lib/__tests__/touch_drag_targets.test.js +293 -0
- data/app/javascript/lib/__tests__/turbo_stream_actions.test.js +29 -1
- data/app/javascript/lib/__tests__/workspace_scroll_restoration.test.js +310 -0
- data/app/javascript/lib/__tests__/workspace_tree_removal.test.js +108 -0
- data/app/javascript/lib/api/__tests__/creatives.test.js +27 -1
- data/app/javascript/lib/api/__tests__/drag_drop.test.js +136 -0
- data/app/javascript/lib/api/__tests__/expansion_intent.test.js +75 -0
- data/app/javascript/lib/api/__tests__/expansion_save_queue.test.js +110 -0
- data/app/javascript/lib/api/__tests__/queue_manager.test.js +237 -0
- data/app/javascript/lib/api/__tests__/queue_reconciliation.test.js +57 -0
- data/app/javascript/lib/api/__tests__/queue_recovery.test.js +28 -0
- data/app/javascript/lib/api/creatives.js +5 -2
- data/app/javascript/lib/api/drag_drop.js +25 -1
- data/app/javascript/lib/api/expansion_intent.js +28 -0
- data/app/javascript/lib/api/expansion_save_queue.js +51 -0
- data/app/javascript/lib/api/queue_completion.js +30 -0
- data/app/javascript/lib/api/queue_manager.js +34 -50
- data/app/javascript/lib/api/queue_reconciliation.js +44 -0
- data/app/javascript/lib/api/queue_recovery.js +24 -0
- data/app/javascript/lib/common_popup.js +7 -7
- data/app/javascript/lib/creative_quote.js +135 -0
- data/app/javascript/lib/creative_title.js +9 -0
- data/app/javascript/lib/creative_tree_invalidation.js +4 -0
- data/app/javascript/lib/dnd/__tests__/bundle_image.test.js +32 -0
- data/app/javascript/lib/dnd/__tests__/envelope.test.js +262 -0
- data/app/javascript/lib/dnd/__tests__/hit_test.test.js +69 -0
- data/app/javascript/lib/dnd/__tests__/preview.test.js +22 -0
- data/app/javascript/lib/dnd/__tests__/registry.test.js +797 -0
- data/app/javascript/lib/dnd/__tests__/session.test.js +213 -0
- data/app/javascript/lib/dnd/__tests__/session_without_window.test.js +15 -0
- data/app/javascript/lib/dnd/__tests__/touch_bridge.test.js +532 -0
- data/app/javascript/lib/dnd/creative_label.js +21 -0
- data/app/javascript/lib/dnd/envelope.js +194 -0
- data/app/javascript/lib/dnd/hit_test.js +42 -0
- data/app/javascript/lib/dnd/preview.js +10 -0
- data/app/javascript/lib/dnd/registry.js +315 -0
- data/app/javascript/lib/dnd/session.js +152 -0
- data/app/javascript/lib/dnd/touch_bridge.js +184 -0
- data/app/javascript/lib/editor/__tests__/code_languages.test.js +1 -5
- data/app/javascript/lib/editor/code_languages.js +0 -1
- data/app/javascript/lib/entity_list_popup.js +45 -0
- data/app/javascript/lib/html_escape.js +12 -0
- data/app/javascript/lib/image_lightbox_pan.js +31 -0
- data/app/javascript/lib/lexical/__tests__/attachment_payload.test.js +12 -189
- data/app/javascript/lib/lexical/__tests__/creative_link_drop.test.js +414 -0
- data/app/javascript/lib/lexical/__tests__/creative_link_node.test.js +50 -0
- data/app/javascript/lib/lexical/__tests__/file_drop.test.js +288 -0
- data/app/javascript/lib/lexical/attachment_node.jsx +21 -42
- data/app/javascript/lib/lexical/attachment_payload.js +0 -274
- data/app/javascript/lib/lexical/attachment_presentation.js +57 -0
- data/app/javascript/lib/lexical/creative_link_drop.js +98 -0
- data/app/javascript/lib/lexical/creative_link_node.js +30 -4
- data/app/javascript/lib/lexical/file_drop.js +106 -0
- data/app/javascript/lib/lexical/ppt_attachment.js +26 -0
- data/app/javascript/lib/lexical/upload_anchor_node.js +16 -0
- data/app/javascript/lib/lexical/upload_nodes.js +6 -0
- data/app/javascript/lib/media_loading.js +25 -0
- data/app/javascript/lib/permission_update.js +21 -0
- data/app/javascript/lib/popup_toggle_guard.js +56 -0
- data/app/javascript/lib/ppt_background.js +48 -0
- data/app/javascript/lib/ppt_chart.js +59 -0
- data/app/javascript/lib/ppt_connector.js +63 -0
- data/app/javascript/lib/ppt_formatting.js +138 -0
- data/app/javascript/lib/ppt_media.js +61 -0
- data/app/javascript/lib/quote_selection_popup.js +67 -0
- data/app/javascript/lib/responsive_images.js +0 -12
- data/app/javascript/lib/search_combobox.js +61 -0
- data/app/javascript/lib/share_modal_links.js +35 -0
- data/app/javascript/lib/touch_drag.js +119 -37
- data/app/javascript/lib/turbo_stream_actions.js +19 -1
- data/app/javascript/lib/utils/__tests__/attachment_rendering.test.js +189 -0
- data/app/javascript/lib/utils/__tests__/creative_link_navigation.test.js +301 -0
- data/app/javascript/lib/utils/__tests__/filter_navigation.test.js +16 -0
- data/app/javascript/lib/utils/__tests__/focus.test.js +144 -0
- data/app/javascript/lib/utils/__tests__/mermaid_math.test.js +24 -0
- data/app/javascript/lib/utils/__tests__/sanitize_description.test.js +10 -0
- data/app/javascript/lib/utils/creative_link_navigation.js +64 -0
- data/app/javascript/lib/utils/filter_navigation.js +16 -2
- data/app/javascript/lib/utils/focus.js +36 -0
- data/app/javascript/lib/utils/markdown.js +0 -4
- data/app/javascript/lib/utils/sanitize_description.js +12 -4
- data/app/javascript/lib/utils/workspace_chat_navigation.js +25 -0
- data/app/javascript/lib/viewport_region.js +20 -0
- data/app/javascript/lib/workspace_scroll_restoration.js +134 -0
- data/app/javascript/lib/workspace_tree_removal.js +91 -0
- data/app/javascript/lib/workspace_tree_visibility.js +25 -0
- data/app/javascript/modules/__tests__/background_creative_create.test.js +114 -0
- data/app/javascript/modules/__tests__/command_args_form.test.js +96 -0
- data/app/javascript/modules/__tests__/command_menu_details.test.js +199 -0
- data/app/javascript/modules/__tests__/creative_inline_dataset.test.js +35 -0
- data/app/javascript/modules/__tests__/creative_inline_payload.test.js +35 -0
- data/app/javascript/modules/__tests__/creative_row_editor_background_create.test.js +2147 -0
- data/app/javascript/modules/__tests__/creative_row_editor_empty_state_recovery.test.js +15 -320
- data/app/javascript/modules/__tests__/creative_row_editor_empty_state_removal.test.js +122 -0
- data/app/javascript/modules/__tests__/creative_row_editor_instant_reveal.test.js +186 -0
- data/app/javascript/modules/__tests__/creative_row_editor_save_paths.test.js +1132 -0
- data/app/javascript/modules/__tests__/creative_save_state.test.js +165 -0
- data/app/javascript/modules/__tests__/creative_type_editor.test.js +203 -0
- data/app/javascript/modules/__tests__/failed_creative_save.test.js +65 -0
- data/app/javascript/modules/__tests__/html_content_empty.test.js +11 -0
- data/app/javascript/modules/__tests__/integration_wizard.test.js +139 -0
- data/app/javascript/modules/__tests__/mention_menu.test.js +190 -0
- data/app/javascript/modules/__tests__/notice_bar_motion.test.js +132 -0
- data/app/javascript/modules/__tests__/notice_bar_sheet.test.js +108 -0
- data/app/javascript/modules/__tests__/notice_bar_spotlight.test.js +109 -0
- data/app/javascript/modules/__tests__/notice_bar_storage.test.js +31 -0
- data/app/javascript/modules/__tests__/notice_bar_toasts.test.js +71 -0
- data/app/javascript/modules/__tests__/notice_bar_view.test.js +89 -0
- data/app/javascript/modules/__tests__/pdf_assets.test.js +26 -0
- data/app/javascript/modules/__tests__/pdf_document.test.js +231 -0
- data/app/javascript/modules/__tests__/persisted_creative_tree.test.js +48 -0
- data/app/javascript/modules/__tests__/ppt_viewer.test.js +219 -0
- data/app/javascript/modules/__tests__/queued_creative_row.test.js +206 -0
- data/app/javascript/modules/__tests__/recovered_creative_position.test.js +57 -0
- data/app/javascript/modules/__tests__/slide_view_attachments.test.js +71 -0
- data/app/javascript/modules/__tests__/support/inline_editor_dom.js +24 -0
- data/app/javascript/modules/__tests__/viewer_navigation.test.js +42 -0
- data/app/javascript/modules/background_creative_create.js +326 -0
- data/app/javascript/modules/command_args_form.js +32 -30
- data/app/javascript/modules/command_menu.js +91 -17
- data/app/javascript/modules/creative_inline_dataset.js +34 -0
- data/app/javascript/modules/creative_inline_payload.js +10 -14
- data/app/javascript/modules/creative_removal.js +39 -0
- data/app/javascript/modules/creative_row_editor.js +383 -402
- data/app/javascript/modules/creative_save_state.js +141 -0
- data/app/javascript/modules/creative_type_editor.js +139 -0
- data/app/javascript/modules/failed_creative_save.js +42 -0
- data/app/javascript/modules/html_content_empty.js +5 -3
- data/app/javascript/modules/integration_wizard.js +68 -19
- data/app/javascript/modules/keep_goal_text.js +4 -0
- data/app/javascript/modules/lexical_inline_editor.jsx +9 -2
- data/app/javascript/modules/mention_menu.js +34 -22
- data/app/javascript/modules/notice_bar/__tests__/refresh.test.js +177 -0
- data/app/javascript/modules/notice_bar/motion.js +59 -0
- data/app/javascript/modules/notice_bar/refresh.js +53 -0
- data/app/javascript/modules/notice_bar/sheet.js +102 -0
- data/app/javascript/modules/notice_bar/spotlight.js +78 -0
- data/app/javascript/modules/notice_bar/storage.js +14 -0
- data/app/javascript/modules/notice_bar/toasts.js +49 -0
- data/app/javascript/modules/notice_bar/view.js +101 -0
- data/app/javascript/modules/pdf_document.js +65 -0
- data/app/javascript/modules/pending_creative_sync.js +23 -0
- data/app/javascript/modules/persisted_creative_tree.js +39 -0
- data/app/javascript/modules/ppt_viewer.js +76 -0
- data/app/javascript/modules/queued_creative_row.js +128 -0
- data/app/javascript/modules/recovered_creative_position.js +52 -0
- data/app/javascript/modules/slide_view.js +9 -3
- data/app/javascript/modules/viewer_navigation.js +16 -0
- data/app/javascript/slide_view.js +9 -0
- data/app/jobs/collavre/agent_provisioning_sync_job.rb +79 -0
- data/app/jobs/collavre/ai_agent_job.rb +181 -160
- data/app/jobs/collavre/approval_continuation_job.rb +102 -0
- data/app/jobs/collavre/approval_gate_resume_job.rb +22 -0
- data/app/jobs/collavre/async_approval_resume_job.rb +20 -0
- data/app/jobs/collavre/async_approval_sweep_job.rb +44 -0
- data/app/jobs/collavre/batch_destroy_comments_job.rb +17 -0
- data/app/jobs/collavre/cancel_offline_delegated_tasks_job.rb +35 -82
- data/app/jobs/collavre/cdn_invalidation_job.rb +62 -0
- data/app/jobs/collavre/claude_approval_resume_job.rb +15 -0
- data/app/jobs/collavre/comment_push_delivery_sweep_job.rb +9 -1
- data/app/jobs/collavre/compress_job.rb +3 -27
- data/app/jobs/collavre/creative_broadcast_job.rb +13 -16
- data/app/jobs/collavre/creative_history_notice_job.rb +40 -0
- data/app/jobs/collavre/creative_history_prune_job.rb +86 -0
- data/app/jobs/collavre/creative_tree_invalidation_job.rb +33 -0
- data/app/jobs/collavre/cron_action_job.rb +24 -7
- data/app/jobs/collavre/cron_scheduler_job.rb +44 -3
- data/app/jobs/collavre/drop_trigger_job.rb +35 -30
- data/app/jobs/collavre/endpoint_health_probe_job.rb +23 -0
- data/app/jobs/collavre/endpoint_health_sweep_job.rb +22 -0
- data/app/jobs/collavre/gateway_health_probe_job.rb +33 -0
- data/app/jobs/collavre/gateway_health_sweep_job.rb +22 -0
- data/app/jobs/collavre/inline_agent_replay_job.rb +32 -0
- data/app/jobs/collavre/keep_loop_reconcile_job.rb +57 -0
- data/app/jobs/collavre/merge_comments_job.rb +6 -30
- data/app/jobs/collavre/offline_task_sweep_job.rb +44 -0
- data/app/jobs/collavre/permission_cache_job.rb +19 -10
- data/app/jobs/collavre/purge_unreferenced_blob_job.rb +19 -0
- data/app/jobs/collavre/push_notification_job.rb +4 -3
- data/app/jobs/collavre/recover_interrupted_tasks_job.rb +79 -0
- data/app/jobs/collavre/resume_suspended_tasks_job.rb +29 -0
- data/app/jobs/collavre/solid_queue_worker_watchdog_job.rb +108 -0
- data/app/jobs/collavre/trigger_loop_check_job.rb +104 -105
- data/app/jobs/collavre/trigger_loop_verify_job.rb +51 -82
- data/app/jobs/collavre/workflow_outbox_job.rb +10 -0
- data/app/jobs/collavre/workflow_push_job.rb +11 -0
- data/app/jobs/collavre/workflow_sweep_job.rb +11 -0
- data/app/jobs/concerns/collavre/comment_serializable.rb +3 -1
- data/app/jobs/concerns/collavre/dispatch_admission.rb +95 -0
- data/app/jobs/concerns/collavre/trigger_loop_helpers.rb +178 -13
- data/app/models/collavre/agent_gateway.rb +76 -0
- data/app/models/collavre/agent_workspace.rb +42 -7
- data/app/models/collavre/blob_access_flag.rb +24 -0
- data/app/models/collavre/channel.rb +17 -0
- data/app/models/collavre/comment/approvable.rb +14 -1
- data/app/models/collavre/comment/approval_gate.rb +98 -0
- data/app/models/collavre/comment/batch_destruction.rb +173 -0
- data/app/models/collavre/comment/broadcastable.rb +18 -0
- data/app/models/collavre/comment/bulk_follow_up_jobs.rb +29 -0
- data/app/models/collavre/comment/claude_channel_permission.rb +59 -5
- data/app/models/collavre/comment/creative_quote.rb +55 -0
- data/app/models/collavre/comment/image_cdn_eviction.rb +36 -0
- data/app/models/collavre/comment/notifiable.rb +7 -6
- data/app/models/collavre/comment/suspension_notice.rb +20 -0
- data/app/models/collavre/comment/topic_membership.rb +21 -1
- data/app/models/collavre/comment/trigger_loop_resume.rb +77 -0
- data/app/models/collavre/comment.rb +30 -106
- data/app/models/collavre/comment_notification_delivery.rb +19 -8
- data/app/models/collavre/comment_version.rb +4 -0
- data/app/models/collavre/creative/ai_write_policy.rb +26 -0
- data/app/models/collavre/creative/contextual.rb +153 -0
- data/app/models/collavre/creative/describable.rb +34 -25
- data/app/models/collavre/creative/history_trackable.rb +104 -0
- data/app/models/collavre/creative/linkable.rb +21 -1
- data/app/models/collavre/creative/permissible.rb +12 -20
- data/app/models/collavre/creative/publishable.rb +65 -0
- data/app/models/collavre/creative/type_selectable.rb +25 -0
- data/app/models/collavre/creative.rb +26 -110
- data/app/models/collavre/creative_change.rb +55 -0
- data/app/models/collavre/creative_change_set.rb +71 -0
- data/app/models/collavre/creative_share.rb +19 -0
- data/app/models/collavre/current.rb +8 -1
- data/app/models/collavre/llm_model.rb +1 -0
- data/app/models/collavre/llm_usage/requester.rb +9 -0
- data/app/models/collavre/llm_usage.rb +33 -0
- data/app/models/collavre/mcp_tool.rb +25 -3
- data/app/models/collavre/orchestrator_policy.rb +25 -29
- data/app/models/collavre/preview_channel.rb +1 -15
- data/app/models/collavre/retired_task_execution.rb +9 -0
- data/app/models/collavre/system_setting.rb +60 -8
- data/app/models/collavre/task/approval_gate_cleanup.rb +23 -0
- data/app/models/collavre/task/async_approval.rb +30 -0
- data/app/models/collavre/task.rb +76 -30
- data/app/models/collavre/task_merged_instruction.rb +6 -0
- data/app/models/collavre/tool_usage/requester.rb +9 -0
- data/app/models/collavre/tool_usage.rb +69 -0
- data/app/models/collavre/topic.rb +41 -3
- data/app/models/collavre/user/ai_capabilities.rb +38 -0
- data/app/models/collavre/user.rb +28 -24
- data/app/models/collavre/user_creative_preference.rb +25 -1
- data/app/models/collavre/user_notice.rb +64 -0
- data/app/models/collavre/workflow/chain.rb +27 -0
- data/app/models/collavre/workflow/execution.rb +28 -0
- data/app/models/collavre/workflow/outbox.rb +43 -0
- data/app/models/collavre/workflow/receipt.rb +26 -0
- data/app/models/concerns/collavre/agent_liveness.rb +95 -0
- data/app/models/concerns/collavre/agent_run_options.rb +45 -0
- data/app/models/concerns/collavre/ai_agent_resolvable.rb +30 -7
- data/app/models/concerns/collavre/comment/dispatch_revocation.rb +99 -0
- data/app/models/concerns/collavre/comment/keep_loop.rb +166 -0
- data/app/models/concerns/collavre/creation_events.rb +25 -0
- data/app/models/concerns/collavre/creative/trigger_loop.rb +57 -0
- data/app/models/concerns/collavre/creative_history_topic.rb +34 -0
- data/app/models/concerns/collavre/creative_reserved_topics.rb +25 -0
- data/app/models/concerns/collavre/has_inbox_creative.rb +9 -1
- data/app/models/concerns/collavre/system_agent_identity.rb +13 -0
- data/app/models/concerns/collavre/task/replay_loop_completion.rb +78 -0
- data/app/models/concerns/collavre/task/trigger_loop_completion.rb +126 -0
- data/app/models/concerns/collavre/task/usage_attribution_tracking.rb +28 -0
- data/app/models/concerns/collavre/task/workflow_completion.rb +59 -0
- data/app/services/collavre/agent_health/endpoint_request.rb +64 -0
- data/app/services/collavre/agent_health/openai_endpoint_checker.rb +77 -0
- data/app/services/collavre/agent_health/probe.rb +47 -0
- data/app/services/collavre/agent_health.rb +43 -0
- data/app/services/collavre/agent_session_abort.rb +2 -2
- data/app/services/collavre/agent_tool_permission.rb +43 -0
- data/app/services/collavre/ai_agent/a2a_dispatcher.rb +22 -4
- data/app/services/collavre/ai_agent/agent_lifecycle_manager.rb +16 -1
- data/app/services/collavre/ai_agent/approval_conversation.rb +60 -0
- data/app/services/collavre/ai_agent/approval_gate_handler.rb +37 -0
- data/app/services/collavre/ai_agent/approval_handler.rb +8 -1
- data/app/services/collavre/ai_agent/budgeted_tree_renderer.rb +80 -0
- data/app/services/collavre/ai_agent/chat_history_window.rb +87 -0
- data/app/services/collavre/ai_agent/claude_channel_adapter.rb +60 -9
- data/app/services/collavre/ai_agent/creative_quote_context.rb +66 -0
- data/app/services/collavre/ai_agent/history_notice.rb +94 -0
- data/app/services/collavre/ai_agent/message_builder.rb +160 -113
- data/app/services/collavre/ai_agent/prompt_budget.rb +142 -0
- data/app/services/collavre/ai_agent/referenced_creative_renderer.rb +101 -0
- data/app/services/collavre/ai_agent/reply_placeholder.rb +28 -0
- data/app/services/collavre/ai_agent/response_finalizer.rb +15 -1
- data/app/services/collavre/ai_agent/review_handler.rb +17 -17
- data/app/services/collavre/ai_agent/screening_approval_handler.rb +26 -0
- data/app/services/collavre/ai_agent/session_context_resolver.rb +6 -1
- data/app/services/collavre/ai_agent/task_claim_service.rb +55 -3
- data/app/services/collavre/ai_agent/task_reply_service.rb +30 -7
- data/app/services/collavre/ai_agent/task_workspace_user.rb +20 -0
- data/app/services/collavre/ai_agent/turn_screening.rb +132 -0
- data/app/services/collavre/ai_agent/workspace_authentication.rb +74 -0
- data/app/services/collavre/ai_agent_service.rb +49 -74
- data/app/services/collavre/ai_approval_summary.rb +51 -0
- data/app/services/collavre/ai_client/approval_gate.rb +90 -0
- data/app/services/collavre/ai_client/cli_tool_events.rb +100 -0
- data/app/services/collavre/ai_client/decision.rb +101 -0
- data/app/services/collavre/ai_client/error_handling.rb +67 -0
- data/app/services/collavre/ai_client/provider_context.rb +69 -0
- data/app/services/collavre/ai_client.rb +58 -209
- data/app/services/collavre/ai_usage_tracking.rb +93 -0
- data/app/services/collavre/auto_theme_generator.rb +5 -8
- data/app/services/collavre/blob_access.rb +166 -0
- data/app/services/collavre/cdn_invalidation.rb +67 -0
- data/app/services/collavre/claude_approval_handoff.rb +28 -0
- data/app/services/collavre/cli_proxy/adapter_engine.rb +27 -0
- data/app/services/collavre/cli_proxy/client.rb +56 -13
- data/app/services/collavre/cli_proxy/engine_unauthenticated_error.rb +31 -0
- data/app/services/collavre/cli_proxy/health_probe.rb +137 -0
- data/app/services/collavre/cli_proxy/inline_login.rb +239 -0
- data/app/services/collavre/cli_proxy/inline_replay_admission.rb +57 -0
- data/app/services/collavre/cli_proxy/replay_claims.rb +48 -0
- data/app/services/collavre/cli_proxy/replay_routing.rb +43 -0
- data/app/services/collavre/cli_proxy/replay_workspace.rb +53 -0
- data/app/services/collavre/cli_proxy/run_options.rb +90 -0
- data/app/services/collavre/command_menu_service.rb +18 -4
- data/app/services/collavre/comment_move_service.rb +5 -1
- data/app/services/collavre/comment_resend_service/cleanup.rb +20 -0
- data/app/services/collavre/comment_resend_service.rb +125 -0
- data/app/services/collavre/comment_snapshot_restore_service.rb +16 -10
- data/app/services/collavre/comments/action_executor.rb +15 -25
- data/app/services/collavre/comments/approval_gate_decision.rb +54 -0
- data/app/services/collavre/comments/approved_tool_invocation.rb +37 -0
- data/app/services/collavre/comments/async_approval_decision.rb +41 -0
- data/app/services/collavre/comments/command_processor.rb +14 -0
- data/app/services/collavre/comments/creative_quote_rejection_notice.rb +37 -0
- data/app/services/collavre/comments/creative_quote_review.rb +54 -0
- data/app/services/collavre/comments/keep_command.rb +80 -0
- data/app/services/collavre/comments/list_response.rb +30 -2
- data/app/services/collavre/comments/topic_command.rb +6 -27
- data/app/services/collavre/creatives/agent_turn_history.rb +15 -0
- data/app/services/collavre/creatives/ai_write_policy.rb +36 -0
- data/app/services/collavre/creatives/change_set_apply_service.rb +309 -0
- data/app/services/collavre/creatives/change_set_diff.rb +216 -0
- data/app/services/collavre/creatives/change_set_restore_service.rb +20 -0
- data/app/services/collavre/creatives/change_set_revert_service.rb +21 -0
- data/app/services/collavre/creatives/change_set_visibility.rb +108 -0
- data/app/services/collavre/creatives/children_index.rb +19 -8
- data/app/services/collavre/creatives/create_service.rb +3 -1
- data/app/services/collavre/creatives/creation_revert_policy.rb +35 -0
- data/app/services/collavre/creatives/creative_quote_turn.rb +96 -0
- data/app/services/collavre/creatives/description_image_dimensions.rb +50 -0
- data/app/services/collavre/creatives/destroy_service.rb +18 -2
- data/app/services/collavre/creatives/draft_change_set_applicator.rb +121 -0
- data/app/services/collavre/creatives/draft_change_set_capture.rb +206 -0
- data/app/services/collavre/creatives/draft_change_set_reject_service.rb +45 -0
- data/app/services/collavre/creatives/draft_conflict_dependency_pruner.rb +110 -0
- data/app/services/collavre/creatives/draft_link_authorization.rb +61 -0
- data/app/services/collavre/creatives/draft_link_progress_reconciliation.rb +36 -0
- data/app/services/collavre/creatives/drop_trigger_missing_agent_notifier.rb +31 -0
- data/app/services/collavre/creatives/expansion_save_order.rb +70 -0
- data/app/services/collavre/creatives/file_drop_service.rb +49 -0
- data/app/services/collavre/creatives/filter_pipeline.rb +7 -4
- data/app/services/collavre/creatives/filter_state.rb +25 -0
- data/app/services/collavre/creatives/filters/base_filter.rb +3 -2
- data/app/services/collavre/creatives/filters/cron_filter.rb +19 -0
- data/app/services/collavre/creatives/filters/reaction_filter.rb +17 -0
- data/app/services/collavre/creatives/historical_snapshot_authorization.rb +108 -0
- data/app/services/collavre/creatives/history.rb +302 -0
- data/app/services/collavre/creatives/history_page.rb +61 -0
- data/app/services/collavre/creatives/importer.rb +19 -5
- data/app/services/collavre/creatives/index_query.rb +6 -12
- data/app/services/collavre/creatives/keep_agent_scope.rb +29 -0
- data/app/services/collavre/creatives/origin_chain_preloader.rb +23 -0
- data/app/services/collavre/creatives/permission_cache_builder.rb +72 -42
- data/app/services/collavre/creatives/permission_checker.rb +51 -4
- data/app/services/collavre/creatives/permission_filter.rb +14 -1
- data/app/services/collavre/creatives/progress_propagation_targets.rb +36 -0
- data/app/services/collavre/creatives/propagated_change_authorization.rb +142 -0
- data/app/services/collavre/creatives/reorderer.rb +128 -49
- data/app/services/collavre/creatives/snapshot_assignment.rb +25 -0
- data/app/services/collavre/creatives/snapshot_comparison.rb +14 -0
- data/app/services/collavre/creatives/tree_builder.rb +40 -13
- data/app/services/collavre/creatives/tree_formatter.rb +1 -1
- data/app/services/collavre/creatives/trigger_action_command.rb +222 -0
- data/app/services/collavre/creatives/type_transition.rb +58 -0
- data/app/services/collavre/creatives/workspace_expansion_candidates.rb +24 -0
- data/app/services/collavre/creatives/workspace_expansion_order.rb +58 -0
- data/app/services/collavre/creatives/workspace_expansion_presence.rb +38 -0
- data/app/services/collavre/creatives/workspace_tree_builder.rb +19 -11
- data/app/services/collavre/crons/change_broadcaster.rb +35 -0
- data/app/services/collavre/crons/recurring_task_arguments.rb +10 -2
- data/app/services/collavre/crons/recurring_task_index.rb +78 -0
- data/app/services/collavre/decision_questions.rb +125 -0
- data/app/services/collavre/http_client.rb +42 -6
- data/app/services/collavre/inbox_reply_service.rb +1 -0
- data/app/services/collavre/keep_loop.rb +84 -0
- data/app/services/collavre/kollavy/access_scope.rb +84 -0
- data/app/services/collavre/kollavy/identity.rb +25 -0
- data/app/services/collavre/kollavy.rb +153 -0
- data/app/services/collavre/llm_usage/attribution.rb +99 -0
- data/app/services/collavre/llm_usage/history_omission.rb +30 -0
- data/app/services/collavre/llm_usage/recorder.rb +59 -0
- data/app/services/collavre/llm_usage/report.rb +116 -0
- data/app/services/collavre/llm_usage/token_normalizer.rb +54 -0
- data/app/services/collavre/markdown_converter.rb +45 -41
- data/app/services/collavre/mcp_service.rb +61 -35
- data/app/services/collavre/mcp_tool_access.rb +40 -0
- data/app/services/collavre/mcp_tool_categories.rb +57 -0
- data/app/services/collavre/mcp_tool_registrar.rb +217 -0
- data/app/services/collavre/mcp_tool_registry.rb +38 -0
- data/app/services/collavre/mention_parser.rb +48 -14
- data/app/services/collavre/notices/feed.rb +127 -0
- data/app/services/collavre/notices/onboarding_replay.rb +17 -0
- data/app/services/collavre/notices/refresh_deadline.rb +15 -0
- data/app/services/collavre/notices/tracker.rb +68 -0
- data/app/services/collavre/openai_endpoint.rb +24 -0
- data/app/services/collavre/orchestration/agent_context_builder.rb +3 -1
- data/app/services/collavre/orchestration/agent_orchestrator.rb +100 -451
- data/app/services/collavre/orchestration/agent_recovery_trigger.rb +16 -0
- data/app/services/collavre/orchestration/arbiter.rb +15 -8
- data/app/services/collavre/orchestration/deferred_trigger_scope.rb +12 -1
- data/app/services/collavre/orchestration/delivery_record.rb +31 -83
- data/app/services/collavre/orchestration/dispatch_records.rb +52 -0
- data/app/services/collavre/orchestration/execution_fence.rb +97 -0
- data/app/services/collavre/orchestration/job_enqueue.rb +150 -0
- data/app/services/collavre/orchestration/keep_dispatch_admission.rb +76 -0
- data/app/services/collavre/orchestration/keep_dispatch_restoration.rb +57 -0
- data/app/services/collavre/orchestration/keep_loop_ownership.rb +152 -0
- data/app/services/collavre/orchestration/keep_queued_dispatches.rb +73 -0
- data/app/services/collavre/orchestration/loop_breaker.rb +10 -5
- data/app/services/collavre/orchestration/matcher.rb +123 -50
- data/app/services/collavre/orchestration/offline_task_grace.rb +50 -0
- data/app/services/collavre/orchestration/policy_resolver.rb +58 -7
- data/app/services/collavre/orchestration/resource_tracker.rb +4 -1
- data/app/services/collavre/orchestration/restored_dispatch_admission.rb +103 -0
- data/app/services/collavre/orchestration/restored_dispatch_context.rb +15 -0
- data/app/services/collavre/orchestration/resume_context.rb +90 -0
- data/app/services/collavre/orchestration/scheduler.rb +9 -2
- data/app/services/collavre/orchestration/selection.rb +40 -7
- data/app/services/collavre/orchestration/solid_queue_retry_recovery.rb +54 -0
- data/app/services/collavre/orchestration/task_coalescer.rb +52 -22
- data/app/services/collavre/orchestration/task_resumer.rb +408 -0
- data/app/services/collavre/orchestration/waiting_notice_manager.rb +289 -0
- data/app/services/collavre/orchestration/workflow_dispatch.rb +47 -0
- data/app/services/collavre/orchestration/workflow_routing.rb +96 -0
- data/app/services/collavre/ppt_archive.rb +123 -0
- data/app/services/collavre/ppt_backgrounds.rb +97 -0
- data/app/services/collavre/ppt_colors.rb +104 -0
- data/app/services/collavre/ppt_connectors.rb +33 -0
- data/app/services/collavre/ppt_diagrams.rb +50 -0
- data/app/services/collavre/ppt_formatting.rb +134 -0
- data/app/services/collavre/ppt_geometry.rb +92 -0
- data/app/services/collavre/ppt_importer.rb +45 -64
- data/app/services/collavre/ppt_inheritance.rb +122 -0
- data/app/services/collavre/ppt_inline_media.rb +19 -0
- data/app/services/collavre/ppt_media.rb +49 -0
- data/app/services/collavre/ppt_numbering.rb +63 -0
- data/app/services/collavre/ppt_paragraphs.rb +52 -0
- data/app/services/collavre/ppt_preview.rb +12 -0
- data/app/services/collavre/ppt_renderer.rb +259 -0
- data/app/services/collavre/ppt_shape_fills.rb +35 -0
- data/app/services/collavre/ppt_shape_styles.rb +81 -0
- data/app/services/collavre/ppt_tables.rb +35 -0
- data/app/services/collavre/public_asset_allowlist.rb +41 -0
- data/app/services/collavre/quota/agent_execution.rb +31 -0
- data/app/services/collavre/quota/exceeded_error.rb +48 -0
- data/app/services/collavre/quota/notice.rb +15 -0
- data/app/services/collavre/quota/pending_dispatch.rb +35 -0
- data/app/services/collavre/quota/probe.rb +44 -0
- data/app/services/collavre/quota/recovery.rb +97 -0
- data/app/services/collavre/quota/retry_time.rb +65 -0
- data/app/services/collavre/ruby_llm_interaction_logger.rb +17 -7
- data/app/services/collavre/screening/gate.rb +47 -0
- data/app/services/collavre/screening/input.rb +30 -0
- data/app/services/collavre/screening/scope.rb +34 -0
- data/app/services/collavre/screening/screener.rb +57 -0
- data/app/services/collavre/screening/screener_resolver.rb +23 -0
- data/app/services/collavre/screening/turn_guard.rb +196 -0
- data/app/services/collavre/screening/verdict.rb +30 -0
- data/app/services/collavre/screening.rb +65 -0
- data/app/services/collavre/source_browser.rb +186 -0
- data/app/services/collavre/system_events/context_builder.rb +53 -12
- data/app/services/collavre/system_events/dispatcher.rb +26 -17
- data/app/services/collavre/system_events/vocabulary.rb +4 -1
- data/app/services/collavre/task_execution_time.rb +33 -0
- data/app/services/collavre/tool_approval_policy.rb +42 -0
- data/app/services/collavre/tool_description.rb +35 -0
- data/app/services/collavre/tool_usage/approved_invocation.rb +28 -0
- data/app/services/collavre/tool_usage/cli_proxy_recorder.rb +100 -0
- data/app/services/collavre/tool_usage/mcp_call.rb +52 -0
- data/app/services/collavre/tool_usage/recorder.rb +34 -0
- data/app/services/collavre/tool_usage/report.rb +38 -0
- data/app/services/collavre/tools/approval_request_service.rb +54 -0
- data/app/services/collavre/tools/async_approval_request.rb +58 -0
- data/app/services/collavre/tools/creative_attach_files_service.rb +10 -2
- data/app/services/collavre/tools/creative_batch_service.rb +90 -10
- data/app/services/collavre/tools/creative_create_service.rb +33 -4
- data/app/services/collavre/tools/creative_import_service.rb +26 -3
- data/app/services/collavre/tools/creative_link_service.rb +75 -0
- data/app/services/collavre/tools/creative_list_attachments_service.rb +2 -2
- data/app/services/collavre/tools/creative_remove_attachment_service.rb +30 -5
- data/app/services/collavre/tools/creative_reorder_service.rb +111 -0
- data/app/services/collavre/tools/creative_retrieval_service.rb +27 -21
- data/app/services/collavre/tools/creative_unlink_service.rb +60 -0
- data/app/services/collavre/tools/creative_update_service.rb +88 -81
- data/app/services/collavre/tools/cron_cancel_service.rb +3 -17
- data/app/services/collavre/tools/cron_create_service.rb +91 -36
- data/app/services/collavre/tools/cron_list_service.rb +2 -2
- data/app/services/collavre/tools/cron_update_service.rb +5 -19
- data/app/services/collavre/tools/keep_service.rb +42 -0
- data/app/services/collavre/tools/source_list_service.rb +25 -0
- data/app/services/collavre/tools/source_read_service.rb +26 -0
- data/app/services/collavre/tools/source_search_service.rb +25 -0
- data/app/services/collavre/tools/source_tool_support.rb +39 -0
- data/app/services/collavre/tools/task_descendants.rb +32 -0
- data/app/services/collavre/tools/task_lineage.rb +46 -0
- data/app/services/collavre/tools/task_status_service.rb +61 -0
- data/app/services/collavre/tools/task_tracking.rb +67 -0
- data/app/services/collavre/tools/topic_authorizer.rb +2 -2
- data/app/services/collavre/tools/topic_message_create_service.rb +35 -17
- data/app/services/collavre/tools/topic_move_service.rb +3 -4
- data/app/services/collavre/tools/topic_tasks_service.rb +42 -0
- data/app/services/collavre/tools/topic_update_service.rb +1 -1
- data/app/services/collavre/topic_branch_service.rb +1 -0
- data/app/services/collavre/topics/active_topic_snapshot.rb +30 -0
- data/app/services/collavre/topics/agent_resolver.rb +7 -1
- data/app/services/collavre/topics/cron_badge_decorator.rb +32 -0
- data/app/services/collavre/topics/last_topic_preference_payload.rb +1 -0
- data/app/services/collavre/topics/message_page.rb +1 -1
- data/app/services/collavre/topics/orphaned_cron_notifier.rb +33 -14
- data/app/services/collavre/topics/pin_rejection.rb +16 -2
- data/app/services/collavre/topics/reserved_name.rb +6 -0
- data/app/services/collavre/topics/serializer.rb +10 -3
- data/app/services/collavre/topics/topic_move.rb +21 -2
- data/app/services/collavre/trigger_loop_config.rb +15 -0
- data/app/services/collavre/workflow/admission.rb +109 -0
- data/app/services/collavre/workflow/child_context.rb +35 -0
- data/app/services/collavre/workflow/conditions.rb +79 -0
- data/app/services/collavre/workflow/context_preloader.rb +48 -0
- data/app/services/collavre/workflow/continuation.rb +16 -0
- data/app/services/collavre/workflow/dispatch_identity.rb +25 -0
- data/app/services/collavre/workflow/dispatch_outcome.rb +9 -0
- data/app/services/collavre/workflow/editor.rb +79 -0
- data/app/services/collavre/workflow/envelope_validation.rb +18 -0
- data/app/services/collavre/workflow/fallback_delivery.rb +59 -0
- data/app/services/collavre/workflow/fixed_anchor.rb +32 -0
- data/app/services/collavre/workflow/human_handoff.rb +39 -0
- data/app/services/collavre/workflow/inbox_notice.rb +56 -0
- data/app/services/collavre/workflow/invocation.rb +60 -0
- data/app/services/collavre/workflow/materialization.rb +41 -0
- data/app/services/collavre/workflow/publication.rb +55 -0
- data/app/services/collavre/workflow/push_delivery.rb +97 -0
- data/app/services/collavre/workflow/recovery.rb +62 -0
- data/app/services/collavre/workflow/resolver.rb +83 -0
- data/app/services/collavre/workflow/rule.rb +189 -0
- data/app/services/collavre/workflow/safety.rb +61 -0
- data/app/services/collavre/workflow/settlement.rb +60 -0
- data/app/services/collavre/workflow/source_message.rb +39 -0
- data/app/services/collavre/workflow/task_admission.rb +114 -0
- data/app/views/collavre/admin/settings/_system_tab.html.erb +49 -11
- data/app/views/collavre/agent_connections/show.html.erb +76 -69
- data/app/views/collavre/agent_gateways/_form.html.erb +69 -55
- data/app/views/collavre/agent_gateways/edit.html.erb +4 -2
- data/app/views/collavre/agent_gateways/index.html.erb +48 -51
- data/app/views/collavre/agent_gateways/new.html.erb +4 -2
- data/app/views/collavre/agent_models/_editor.html.erb +20 -0
- data/app/views/collavre/comments/_activity_log_details.html.erb +10 -4
- data/app/views/collavre/comments/_agent_run_options.html.erb +12 -0
- data/app/views/collavre/comments/_approval_gate.html.erb +8 -0
- data/app/views/collavre/comments/_comment.html.erb +45 -8
- data/app/views/collavre/comments/_comments_popup.html.erb +81 -12
- data/app/views/collavre/comments/_creative_quote_review.html.erb +29 -0
- data/app/views/collavre/comments/_feature_card.html.erb +1 -1
- data/app/views/collavre/comments/_loading.html.erb +7 -0
- data/app/views/collavre/comments/_reaction_buttons.html.erb +7 -0
- data/app/views/collavre/comments/_reaction_picker.html.erb +1 -8
- data/app/views/collavre/comments/_run_options.html.erb +4 -0
- data/app/views/collavre/comments/_thinking_icon.html.erb +7 -0
- data/app/views/collavre/creative_change_sets/_detail.html.erb +88 -0
- data/app/views/collavre/creative_change_sets/_list.html.erb +40 -0
- data/app/views/collavre/creative_change_sets/_undo_toast.html.erb +22 -0
- data/app/views/collavre/creatives/_import_upload_zone.html.erb +1 -1
- data/app/views/collavre/creatives/_inline_edit_form.html.erb +14 -2
- data/app/views/collavre/creatives/_public_meta.html.erb +16 -0
- data/app/views/collavre/creatives/_share_modal.html.erb +9 -0
- data/app/views/collavre/creatives/_type_selector.html.erb +15 -0
- data/app/views/collavre/creatives/_workflow_panel.html.erb +71 -0
- data/app/views/collavre/creatives/_workspace_tree.html.erb +4 -1
- data/app/views/collavre/creatives/edit.html.erb +7 -4
- data/app/views/collavre/creatives/index.html.erb +74 -11
- data/app/views/collavre/creatives/ppt_previews/_markdown_document.html.erb +17 -0
- data/app/views/collavre/creatives/ppt_previews/show.html.erb +38 -0
- data/app/views/collavre/creatives/show.html.erb +1 -1
- data/app/views/collavre/features/index.html.erb +4 -4
- data/app/views/collavre/inline_agent_logins/show.html.erb +31 -0
- data/app/views/collavre/llm_usages/_metrics.html.erb +13 -0
- data/app/views/collavre/llm_usages/index.html.erb +88 -0
- data/app/views/collavre/notices/_payload.html.erb +5 -0
- data/app/views/collavre/notices/_zone.html.erb +20 -0
- data/app/views/collavre/seo/sitemap.xml.builder +8 -0
- data/app/views/collavre/seo/sitemap_index.xml.builder +8 -0
- data/app/views/collavre/shared/_creative_move_modal.html.erb +59 -0
- data/app/views/collavre/shared/_link_creative_modal.html.erb +2 -0
- data/app/views/collavre/shared/navigation/_help_button.html.erb +21 -2
- data/app/views/collavre/shared/navigation/_search_form.html.erb +14 -1
- data/app/views/collavre/users/_llm_fields.html.erb +26 -31
- data/app/views/collavre/users/_model_picker.html.erb +36 -0
- data/app/views/collavre/users/_tool_details.html.erb +7 -0
- data/app/views/collavre/users/_tool_selection.html.erb +51 -0
- data/app/views/collavre/users/edit_ai.html.erb +29 -24
- data/app/views/collavre/users/index.html.erb +96 -80
- data/app/views/collavre/users/new_ai.html.erb +4 -22
- data/app/views/collavre/users/show.html.erb +12 -29
- data/app/views/layouts/collavre/landing.html.erb +14 -0
- data/app/views/layouts/collavre/slide.html.erb +4 -1
- data/config/initializers/active_storage_access.rb +34 -0
- data/config/initializers/agent_health.rb +7 -0
- data/config/initializers/kollavy_feature_card.rb +11 -0
- data/config/initializers/mcp_discovery_access.rb +17 -0
- data/config/initializers/mcp_tool_usage.rb +17 -0
- data/config/initializers/meta_tool_access.rb +35 -0
- data/config/initializers/rate_limits.rb +4 -0
- data/config/initializers/ruby_llm_openai_cli_events.rb +43 -0
- data/config/initializers/ruby_llm_openai_reasoning_content.rb +8 -7
- data/config/initializers/screening_integration_settings.rb +5 -0
- data/config/initializers/task_recovery.rb +30 -0
- data/config/locales/admin.en.yml +19 -3
- data/config/locales/admin.ko.yml +19 -3
- data/config/locales/agent_gateway.en.yml +6 -2
- data/config/locales/agent_gateway.ko.yml +6 -2
- data/config/locales/ai_agent.en.yml +11 -0
- data/config/locales/ai_agent.ko.yml +11 -0
- data/config/locales/approval_gate.en.yml +11 -0
- data/config/locales/approval_gate.ko.yml +11 -0
- data/config/locales/claude_channel.en.yml +1 -0
- data/config/locales/claude_channel.ko.yml +1 -0
- data/config/locales/comments.en.yml +80 -18
- data/config/locales/comments.ko.yml +80 -18
- data/config/locales/contacts.en.yml +0 -5
- data/config/locales/contacts.ko.yml +0 -5
- data/config/locales/contexts.en.yml +6 -0
- data/config/locales/contexts.ko.yml +6 -0
- data/config/locales/creative_history.en.yml +62 -0
- data/config/locales/creative_history.ko.yml +56 -0
- data/config/locales/creative_types.en.yml +19 -0
- data/config/locales/creative_types.ko.yml +19 -0
- data/config/locales/creatives.en.yml +19 -51
- data/config/locales/creatives.ko.yml +17 -44
- data/config/locales/crons.en.yml +16 -0
- data/config/locales/crons.ko.yml +16 -0
- data/config/locales/dnd.en.yml +26 -0
- data/config/locales/dnd.ko.yml +26 -0
- data/config/locales/drop_trigger.en.yml +5 -16
- data/config/locales/drop_trigger.ko.yml +5 -16
- data/config/locales/features.en.yml +15 -0
- data/config/locales/features.ko.yml +15 -0
- data/config/locales/file_drop.en.yml +5 -0
- data/config/locales/file_drop.ko.yml +5 -0
- data/config/locales/inline_agent_login.en.yml +20 -0
- data/config/locales/inline_agent_login.ko.yml +16 -0
- data/config/locales/integrations.en.yml +0 -1
- data/config/locales/integrations.ko.yml +0 -1
- data/config/locales/keep.en.yml +18 -0
- data/config/locales/keep.ko.yml +18 -0
- data/config/locales/kollavy.en.yml +4 -0
- data/config/locales/kollavy.ko.yml +4 -0
- data/config/locales/landing.en.yml +2 -6
- data/config/locales/landing.ko.yml +2 -6
- data/config/locales/llm_usages.en.yml +45 -0
- data/config/locales/llm_usages.ko.yml +45 -0
- data/config/locales/mcp_tools.en.yml +6 -0
- data/config/locales/mcp_tools.ko.yml +6 -0
- data/config/locales/notices.en.yml +52 -0
- data/config/locales/notices.ko.yml +52 -0
- data/config/locales/orchestration.en.yml +34 -2
- data/config/locales/orchestration.ko.yml +34 -2
- data/config/locales/ppt_viewer.en.yml +18 -0
- data/config/locales/ppt_viewer.ko.yml +18 -0
- data/config/locales/public_creatives.en.yml +6 -0
- data/config/locales/public_creatives.ko.yml +6 -0
- data/config/locales/quota.en.yml +5 -0
- data/config/locales/quota.ko.yml +5 -0
- data/config/locales/screening.en.yml +22 -0
- data/config/locales/screening.ko.yml +22 -0
- data/config/locales/search_popup.en.yml +2 -3
- data/config/locales/search_popup.ko.yml +2 -3
- data/config/locales/task_tracking.en.yml +13 -0
- data/config/locales/task_tracking.ko.yml +13 -0
- data/config/locales/tool_categories.en.yml +14 -0
- data/config/locales/tool_categories.ko.yml +14 -0
- data/config/locales/tool_descriptions.en.yml +163 -0
- data/config/locales/tool_descriptions.ko.yml +163 -0
- data/config/locales/tools.en.yml +26 -0
- data/config/locales/tools.ko.yml +26 -0
- data/config/locales/users.en.yml +19 -23
- data/config/locales/users.ko.yml +19 -22
- data/config/locales/workflow_editor.en.yml +62 -0
- data/config/locales/workflow_editor.ko.yml +62 -0
- data/config/locales/workflow_runtime.en.yml +19 -0
- data/config/locales/workflow_runtime.ko.yml +19 -0
- data/config/routes/account_settings.rb +4 -0
- data/config/routes/agent_api.rb +6 -0
- data/config/routes/agent_connections.rb +24 -0
- data/config/routes/attachments.rb +2 -0
- data/config/routes/comment_actions.rb +10 -0
- data/config/routes/creative_attachments.rb +2 -0
- data/config/routes/creative_contexts.rb +8 -0
- data/config/routes/creative_history.rb +4 -0
- data/config/routes/creative_preferences.rb +3 -0
- data/config/routes/notices.rb +16 -0
- data/config/routes/public_creatives.rb +12 -0
- data/config/routes.rb +13 -42
- data/db/migrate/20251204161133_set_default_routing_expression_for_ai_agents.rb +10 -3
- data/db/migrate/20260903070800_add_joined_at_order_index_to_users.rb +23 -0
- data/db/migrate/20260903180000_create_creative_change_history.rb +47 -0
- data/db/migrate/20260903190000_add_system_kind_to_topics.rb +8 -0
- data/db/migrate/20260908000000_add_last_topic_all_messages_to_user_creative_preferences.rb +5 -0
- data/db/migrate/20260910000000_add_health_to_agent_gateways.rb +10 -0
- data/db/migrate/20260911000000_add_endpoint_health_to_users.rb +9 -0
- data/db/migrate/20260911020000_normalize_user_names_to_single_line.rb +32 -0
- data/db/migrate/20260913000000_create_workflow_executions.rb +64 -0
- data/db/migrate/20260913000002_add_ordinary_delivery_to_workflow_outboxes.rb +7 -0
- data/db/migrate/20260913000100_add_reserved_to_workflow_executions.rb +7 -0
- data/db/migrate/20260914063000_add_justify_creative_descriptions_to_users.rb +5 -0
- data/db/migrate/20260922000000_create_llm_usages.rb +44 -0
- data/db/migrate/20260922000001_add_expansion_save_sequences_to_users.rb +5 -0
- data/db/migrate/20260922000002_deduplicate_root_creative_preferences.rb +37 -0
- data/db/migrate/20260922000003_add_agent_quota_recovery.rb +7 -0
- data/db/migrate/20260922000004_add_agent_quota_probe.rb +6 -0
- data/db/migrate/20260922000005_add_suspension_to_tasks.rb +12 -0
- data/db/migrate/20260922010000_create_retired_task_executions.rb +11 -0
- data/db/migrate/20260922113000_add_emoji_comment_index_to_comment_reactions.rb +17 -0
- data/db/migrate/20260922120000_create_tool_usages.rb +37 -0
- data/db/migrate/20260923000000_link_tool_usages_to_agent_workspaces.rb +44 -0
- data/db/migrate/20260924000000_add_agent_run_options.rb +7 -0
- data/db/migrate/20260924010000_add_run_options_to_comment_versions.rb +5 -0
- data/db/migrate/20260924060000_add_async_approval_recovery_to_comments.rb +24 -0
- data/db/migrate/20260924070000_add_async_approval_task_to_comments.rb +22 -0
- data/db/migrate/20260929000000_create_user_notices.rb +14 -0
- data/db/migrate/20260929010000_add_system_agent_to_users.rb +5 -0
- data/db/migrate/20260929120000_add_actor_lookup_index_to_creative_change_sets.rb +19 -0
- data/db/migrate/20261008000000_add_public_id_to_creatives.rb +6 -0
- data/db/migrate/20261008010000_backfill_public_creative_ids.rb +26 -0
- data/db/migrate/20261012000000_create_blob_access_flags.rb +17 -0
- data/db/migrate/20261012000001_publish_landing_public_assets.rb +16 -0
- data/db/migrate/20261014000000_backfill_implicit_main_cron_topics.rb +38 -0
- data/db/migrate/20261016000000_add_trigger_comment_id_to_tasks.rb +21 -0
- data/db/migrate/20261016000001_index_task_event_causation.rb +20 -0
- data/db/migrate/20261016000002_index_task_merged_instructions.rb +25 -0
- data/db/migrate/20261019000000_add_quoted_creative_to_comments.rb +10 -0
- data/db/migrate/20261028000000_add_deleting_at_to_comments.rb +5 -0
- data/db/seeds.rb +3 -19
- data/lib/collavre/bulk_job_enqueue.rb +145 -0
- data/lib/collavre/engine.rb +11 -6
- data/lib/collavre/feature_card_registry.rb +8 -2
- data/lib/collavre/notice_registry.rb +179 -0
- data/lib/collavre/onboarding_notices.rb +107 -0
- data/lib/collavre/profile_preferences.rb +17 -0
- data/lib/collavre/stylesheets_helper.rb +72 -0
- data/lib/collavre/version.rb +1 -1
- data/lib/collavre.rb +12 -0
- data/lib/generators/collavre/install/install_generator.rb +50 -8
- data/lib/generators/collavre/install/templates/build.cjs.tt +1 -0
- data/lib/tasks/public_assets.rake +24 -0
- data/skills/collavre/SKILL.md +42 -0
- data/skills/collavre/references/tool-authoring.md +121 -0
- data/skills/collavre/references/tool-reference.md +98 -0
- data/skills/collavre/scripts/collavre +30 -11
- metadata +774 -7
- data/config/locales/notifications.en.yml +0 -8
- data/config/locales/notifications.ko.yml +0 -8
- /data/app/javascript/{utils/drag_bundle_image.js → lib/dnd/bundle_image.js} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
# Measures the latest completed attempt, excluding queue time and earlier retries.
|
|
5
|
+
# Missing completion events are not estimated, including historical delegations.
|
|
6
|
+
class TaskExecutionTime
|
|
7
|
+
def self.seconds(task)
|
|
8
|
+
return unless task.done?
|
|
9
|
+
|
|
10
|
+
events = execution_events(task)
|
|
11
|
+
return unless events.first&.first == "completion"
|
|
12
|
+
|
|
13
|
+
# Each start marks a new attempt, even when the preceding attempt has no terminal event.
|
|
14
|
+
started = events.find { |type, _time| type == "start" }
|
|
15
|
+
return unless started
|
|
16
|
+
|
|
17
|
+
events.first.last - started.last
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.execution_events(task)
|
|
21
|
+
actions = task.task_actions
|
|
22
|
+
unless actions.loaded?
|
|
23
|
+
return actions.where(action_type: %w[start completion])
|
|
24
|
+
.order(created_at: :desc, id: :desc).pluck(:action_type, :created_at)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
actions.select { |action| action.action_type.in?(%w[start completion]) }
|
|
28
|
+
.sort_by { |action| [ action.created_at, action.id ] }.reverse
|
|
29
|
+
.map { |action| [ action.action_type, action.created_at ] }
|
|
30
|
+
end
|
|
31
|
+
private_class_method :execution_events
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
# Whether a tool call must wait for human approval: a dynamic McpTool or a
|
|
5
|
+
# system tool may require it globally, and an agent may require it for its
|
|
6
|
+
# own calls via agent_conf `approval: { tools: [...] }` — so one agent can
|
|
7
|
+
# gate its write tools without changing them for every other agent.
|
|
8
|
+
class ToolApprovalPolicy
|
|
9
|
+
# Check every executable wrapper without changing the call persisted for
|
|
10
|
+
# approval and conversation replay. Discovery never executes its target.
|
|
11
|
+
def self.required_for_call?(tool_call, agent: nil)
|
|
12
|
+
name, arguments = tool_call.name, tool_call.arguments
|
|
13
|
+
loop do
|
|
14
|
+
return true if required?(name, agent: agent)
|
|
15
|
+
return false unless name == "meta_tool" && arguments.is_a?(Hash)
|
|
16
|
+
|
|
17
|
+
args = arguments.stringify_keys
|
|
18
|
+
return false unless %w[run call].include?(args["action"])
|
|
19
|
+
|
|
20
|
+
name, arguments = args["tool_name"], args["arguments"]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.required?(tool_name, agent: nil)
|
|
25
|
+
McpTool.find_by(name: tool_name)&.requires_approval? ||
|
|
26
|
+
system_tool_requires_approval?(tool_name) ||
|
|
27
|
+
agent_requires_approval?(agent, tool_name)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.agent_requires_approval?(agent, tool_name)
|
|
31
|
+
return false unless agent
|
|
32
|
+
|
|
33
|
+
Array(agent.parsed_agent_conf.dig("approval", "tools")).map(&:to_s).include?(tool_name.to_s)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.system_tool_requires_approval?(tool_name)
|
|
37
|
+
klass = ToolMeta.registry.find { |service| service.tool_metadata[:name] == tool_name }
|
|
38
|
+
klass.respond_to?(:requires_approval?) && klass.requires_approval?
|
|
39
|
+
end
|
|
40
|
+
private_class_method :system_tool_requires_approval?
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Collavre
|
|
2
|
+
# Human-facing text for an MCP tool: a one-line summary for lists and the
|
|
3
|
+
# slash-command menu, plus longer details revealed behind "more".
|
|
4
|
+
#
|
|
5
|
+
# The tool_description declared on the service stays English and is written
|
|
6
|
+
# for the LLM. People read the localized copy under
|
|
7
|
+
# collavre.tool_descriptions.<tool_name>; engines add keys for their own
|
|
8
|
+
# tools. Tools without translations (user-defined Ruby tools) fall back to
|
|
9
|
+
# splitting their declared description: the first sentence is the summary.
|
|
10
|
+
module ToolDescription
|
|
11
|
+
SENTENCE_END = /(?<=[.!?。])\s+/
|
|
12
|
+
|
|
13
|
+
module_function
|
|
14
|
+
|
|
15
|
+
def for(name, description)
|
|
16
|
+
key = name.to_s
|
|
17
|
+
localized = key.match?(/\A\w+\z/) && I18n.t("collavre.tool_descriptions.#{key}", default: nil)
|
|
18
|
+
return localized_parts(localized) if localized.is_a?(Hash) && localized[:summary].present?
|
|
19
|
+
|
|
20
|
+
split(description)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def localized_parts(localized)
|
|
24
|
+
{ summary: localized[:summary].to_s, details: localized[:details].presence&.to_s }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def split(description)
|
|
28
|
+
text = description.to_s.strip
|
|
29
|
+
first_paragraph, rest = text.split(/\n\s*\n/, 2)
|
|
30
|
+
summary, more = first_paragraph.to_s.squish.split(SENTENCE_END, 2)
|
|
31
|
+
details = [ more, rest&.strip ].compact_blank.join("\n\n")
|
|
32
|
+
{ summary: summary.to_s, details: details.presence }
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
class ToolUsage
|
|
5
|
+
# Approval replay bypasses the agent tool callbacks; account at execution instead.
|
|
6
|
+
class ApprovedInvocation
|
|
7
|
+
def self.call(task, tool_name)
|
|
8
|
+
started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
9
|
+
succeeded = false
|
|
10
|
+
result = yield
|
|
11
|
+
succeeded = !ToolUsage.failed_result?(result)
|
|
12
|
+
result
|
|
13
|
+
ensure
|
|
14
|
+
record(task, tool_name, succeeded, started_at)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.record(task, tool_name, succeeded, started_at)
|
|
18
|
+
Recorder.new(context: { task: task }, source: "internal").record(
|
|
19
|
+
tool_name: tool_name, succeeded: succeeded, duration_ms: ToolUsage.elapsed_ms(started_at),
|
|
20
|
+
call_id: task.pending_tool_call&.dig("tool_call_id")
|
|
21
|
+
)
|
|
22
|
+
rescue StandardError => e
|
|
23
|
+
Rails.logger.error("Failed to persist approved tool usage: #{e.class}: #{e.message}")
|
|
24
|
+
end
|
|
25
|
+
private_class_method :record
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
class ToolUsage
|
|
5
|
+
# Turns the x_cli_events of one cli-openai-proxy run into tool_usages rows.
|
|
6
|
+
#
|
|
7
|
+
# - Only a "result" event is recorded: it carries the outcome. A call that
|
|
8
|
+
# never gets a result (the run was cut off) records nothing.
|
|
9
|
+
# - The event id is the call_id, so a result reported twice records once.
|
|
10
|
+
# - duration_ms is the gap between the call and result events arriving here.
|
|
11
|
+
# Streaming delivers them as the CLI runs the tool; a non-streaming
|
|
12
|
+
# response delivers them together, so it passes timed: false and the
|
|
13
|
+
# duration stays nil.
|
|
14
|
+
# - Collavre MCP tools the CLI calls are recorded here too, whatever alias the
|
|
15
|
+
# workspace registered the server under. /mcp has already recorded the call
|
|
16
|
+
# tagged with the workspace and a digest of its arguments, so a recorded
|
|
17
|
+
# result replaces the /mcp row of this run with the same tool and
|
|
18
|
+
# arguments, and each call is counted once. Another run sharing the
|
|
19
|
+
# workspace can't take that row unless it made the identical call. A call
|
|
20
|
+
# whose result never arrives keeps its /mcp row; a call that never reached
|
|
21
|
+
# /mcp replaces nothing. Only when the proxy clipped the input (over 4KB)
|
|
22
|
+
# does the result fall back to the oldest row of that tool. See McpCall.
|
|
23
|
+
class CliProxyRecorder
|
|
24
|
+
SOURCE = "cli_proxy"
|
|
25
|
+
# "mcp__<alias>__<tool>" (Claude) and "<alias>.<tool>" (Codex)
|
|
26
|
+
MCP_TOOL_NAME = /\A(?:mcp__.+__|[^.]+\.)(?<tool>[^.]+)\z/
|
|
27
|
+
|
|
28
|
+
def initialize(context:, execution_id:, agent_workspace: nil, since: nil)
|
|
29
|
+
@recorder = Recorder.new(context: context, source: SOURCE, execution_id: execution_id)
|
|
30
|
+
@agent_workspace_id = agent_workspace&.id
|
|
31
|
+
@since = since
|
|
32
|
+
@started = {}
|
|
33
|
+
@inputs = {}
|
|
34
|
+
@recorded = Set.new
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def execution_id
|
|
38
|
+
@recorder.execution_id
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def observe(event, timed: true)
|
|
42
|
+
event = event.to_h.stringify_keys
|
|
43
|
+
id = event["id"].to_s
|
|
44
|
+
case event["phase"]
|
|
45
|
+
when "call" then observe_call(event, id, timed)
|
|
46
|
+
when "result" then record_result(event, id)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
def observe_call(event, id, timed)
|
|
53
|
+
return if id.blank?
|
|
54
|
+
|
|
55
|
+
@inputs[id] = event["input"]
|
|
56
|
+
@started[id] ||= monotonic_now if timed
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def record_result(event, id)
|
|
60
|
+
started = @started.delete(id)
|
|
61
|
+
input = @inputs.delete(id)
|
|
62
|
+
return if id.present? && !@recorded.add?(id)
|
|
63
|
+
|
|
64
|
+
name = event["name"].presence || "tool"
|
|
65
|
+
succeeded = succeeded?(event)
|
|
66
|
+
row = @recorder.record(
|
|
67
|
+
tool_name: name, succeeded: succeeded,
|
|
68
|
+
duration_ms: started && ((monotonic_now - started) * 1000).round, call_id: id.presence
|
|
69
|
+
)
|
|
70
|
+
replace_mcp_row(name, input, succeeded) if row
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Rows of identical calls (same workspace, tool and arguments) carry the
|
|
74
|
+
# same attribution, so taking another run's row keeps the counts right.
|
|
75
|
+
# Preferring one with the same outcome keeps the failure counts right too.
|
|
76
|
+
def replace_mcp_row(name, input, succeeded)
|
|
77
|
+
tool = MCP_TOOL_NAME.match(name)&.[](:tool)
|
|
78
|
+
return unless tool && @agent_workspace_id && @since
|
|
79
|
+
|
|
80
|
+
rows = ToolUsage.where(source: McpCall::SOURCE, agent_workspace_id: @agent_workspace_id, tool_name: tool)
|
|
81
|
+
.where(occurred_at: @since..).order(:occurred_at, :id)
|
|
82
|
+
digest = ToolUsage.arguments_digest(input)
|
|
83
|
+
return rows.first&.destroy unless digest
|
|
84
|
+
|
|
85
|
+
rows = rows.where(arguments_digest: digest)
|
|
86
|
+
(rows.find_by(succeeded: succeeded) || rows.first)&.destroy
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def succeeded?(event)
|
|
90
|
+
return event["ok"] == true unless event["ok"].nil?
|
|
91
|
+
|
|
92
|
+
event["exitCode"].nil? || event["exitCode"].to_i.zero?
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def monotonic_now
|
|
96
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
class ToolUsage
|
|
5
|
+
# Records a tool call an external client made through /mcp. In-process agents
|
|
6
|
+
# run the RubyLLM tool classes and never reach FastMcp tools, so these calls
|
|
7
|
+
# are not also counted by the agent's internal tool hook.
|
|
8
|
+
#
|
|
9
|
+
# A call made with a cli-openai-proxy workspace callback token is tagged with
|
|
10
|
+
# its workspace and a digest of its arguments. When the proxy's matching
|
|
11
|
+
# x_cli_events result arrives, the
|
|
12
|
+
# cli_proxy row (which carries the agent and the LLM execution) replaces it;
|
|
13
|
+
# if the stream breaks first, this row still counts the call.
|
|
14
|
+
# See CliProxyRecorder.
|
|
15
|
+
module McpCall
|
|
16
|
+
SOURCE = "mcp"
|
|
17
|
+
|
|
18
|
+
# The block returns FastMcp's [result, metadata] pair.
|
|
19
|
+
def self.track(tool_name, arguments = nil)
|
|
20
|
+
started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
21
|
+
succeeded = false
|
|
22
|
+
pair = yield
|
|
23
|
+
succeeded = !ToolUsage.failed_result?(pair.first)
|
|
24
|
+
pair
|
|
25
|
+
ensure
|
|
26
|
+
record(tool_name, arguments, succeeded, ToolUsage.elapsed_ms(started_at))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# McpOauthMiddleware sets Current.user to the token owner. An agent token
|
|
30
|
+
# attributes the call to that agent; a human token to that person. A
|
|
31
|
+
# workspace callback token belongs to the workspace user (or the agent, for
|
|
32
|
+
# a shared workspace), but the call is the workspace agent's, so the agent
|
|
33
|
+
# and its owner are taken from the workspace and the token owner stays the
|
|
34
|
+
# requester.
|
|
35
|
+
def self.record(tool_name, arguments, succeeded, duration_ms)
|
|
36
|
+
workspace = Current.mcp_agent_workspace
|
|
37
|
+
Recorder.new(context: context(Current.user, workspace), source: SOURCE, agent_workspace: workspace).record(
|
|
38
|
+
tool_name: tool_name, succeeded: succeeded, duration_ms: duration_ms,
|
|
39
|
+
arguments_digest: workspace && ToolUsage.arguments_digest(arguments)
|
|
40
|
+
)
|
|
41
|
+
rescue StandardError => e
|
|
42
|
+
Rails.logger.error("Failed to persist MCP tool usage: #{e.class}: #{e.message}")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.context(user, workspace)
|
|
46
|
+
return { agent: workspace.agent, requester: user } if workspace
|
|
47
|
+
user&.ai_user? ? { user: user } : { requester: user }
|
|
48
|
+
end
|
|
49
|
+
private_class_method :record, :context
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
class ToolUsage
|
|
5
|
+
# Records tool calls of one execution. Attribution is snapshotted once, the same
|
|
6
|
+
# way LlmUsage::Recorder does, so both tables share execution_id and identity.
|
|
7
|
+
class Recorder
|
|
8
|
+
attr_reader :execution_id
|
|
9
|
+
|
|
10
|
+
def initialize(context:, source:, execution_id: nil, agent_workspace: nil)
|
|
11
|
+
@identity = LlmUsage::Attribution.snapshot(context).merge(agent_id: LlmUsage::Attribution.agent(context)&.id)
|
|
12
|
+
@identity[:agent_workspace_id] = agent_workspace.id if agent_workspace
|
|
13
|
+
@source = source
|
|
14
|
+
@execution_id = execution_id || SecureRandom.uuid
|
|
15
|
+
@sequence = 0
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# call_id makes the event idempotent when the same call is reported twice.
|
|
19
|
+
def record(tool_name:, succeeded: true, duration_ms: nil, call_id: nil, arguments_digest: nil, occurred_at: Time.current)
|
|
20
|
+
@sequence += 1
|
|
21
|
+
ToolUsage.create!(
|
|
22
|
+
@identity.merge(
|
|
23
|
+
event_key: "#{execution_id}:#{@source}:#{call_id.presence || "seq-#{@sequence}"}",
|
|
24
|
+
execution_id: execution_id, source: @source, tool_name: tool_name.to_s,
|
|
25
|
+
succeeded: succeeded, duration_ms: duration_ms, arguments_digest: arguments_digest,
|
|
26
|
+
occurred_at: occurred_at
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
rescue ActiveRecord::RecordNotUnique
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
class ToolUsage
|
|
5
|
+
# Per-tool-name totals over the token report's date range and identity filters.
|
|
6
|
+
class Report
|
|
7
|
+
FILTERS = %w[owner_id requester_id agent_id].freeze
|
|
8
|
+
|
|
9
|
+
def initialize(user:, range:, params: {})
|
|
10
|
+
@user = user
|
|
11
|
+
@range = range
|
|
12
|
+
@params = params.to_h.stringify_keys
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def rows
|
|
16
|
+
relation.group(:tool_name).pluck(
|
|
17
|
+
:tool_name, Arel.sql("COUNT(*)"), Arel.sql("SUM(CASE WHEN succeeded THEN 0 ELSE 1 END)"), Arel.sql("AVG(duration_ms)")
|
|
18
|
+
).map do |tool_name, calls, failures, average|
|
|
19
|
+
{ tool_name: tool_name, calls: calls, failures: failures.to_i, average_duration_ms: average&.to_f&.round }
|
|
20
|
+
end.sort_by { |row| [ -row[:calls], row[:tool_name] ] }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def relation
|
|
26
|
+
scope = ToolUsage.visible_to(@user).where(occurred_at: @range)
|
|
27
|
+
FILTERS.each do |key|
|
|
28
|
+
next if @params[key].blank?
|
|
29
|
+
|
|
30
|
+
scope = key == "requester_id" ? scope.merge(ToolUsage.requested_by(@params[key])) : scope.where(key => @params[key])
|
|
31
|
+
end
|
|
32
|
+
# Only agent tool calls belong to a model, through the execution they share.
|
|
33
|
+
scope = scope.where(execution_id: LlmUsage.where(model: @params["model"]).select(:execution_id)) if @params["model"].present?
|
|
34
|
+
scope
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
module Tools
|
|
5
|
+
class ApprovalRequestService
|
|
6
|
+
extend T::Sig
|
|
7
|
+
extend ToolMeta
|
|
8
|
+
|
|
9
|
+
tool_name "approval_request"
|
|
10
|
+
tool_description "Pause the current native Collavre agent turn for a human decision. " \
|
|
11
|
+
"Provide a concrete question and optionally a human approver ID (defaults to the triggering comment author). " \
|
|
12
|
+
"The original call receives approved or denied, reason, and decided_by after the person responds. " \
|
|
13
|
+
"Denial is a normal result; reconsider the plan instead of performing the denied action. No automatic expiration. " \
|
|
14
|
+
"For Codex CLI turns, pass task_id from the prompt: returns pending; end the turn and wait for a decision message. " \
|
|
15
|
+
"Available through native agent tools or meta_tool run; unassociated external MCP sessions are not supported " \
|
|
16
|
+
"(a Claude Channel session asks through its own plugin's approval_request tool instead)."
|
|
17
|
+
tool_param :question, description: "The concrete question for the human approver. Markdown supported."
|
|
18
|
+
tool_param :approver_user_id, description: "Human approver with access to this creative.", required: false
|
|
19
|
+
|
|
20
|
+
tool_param :task_id, description: "Current Codex CLI task ID supplied by Collavre in the prompt.", required: false
|
|
21
|
+
|
|
22
|
+
def self.requires_approval?
|
|
23
|
+
false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
sig { params(question: String, approver_user_id: T.nilable(Integer), task_id: T.nilable(Integer)).returns(T::Hash[Symbol, T.untyped]) }
|
|
27
|
+
def call(question:, approver_user_id: nil, task_id: nil)
|
|
28
|
+
if Current.agent_turn.nil? && task_id
|
|
29
|
+
return AsyncApprovalRequest.new.call(task_id: task_id, question: question, approver_user_id: approver_user_id)
|
|
30
|
+
end
|
|
31
|
+
self.class.approver!(Current.agent_turn&.dig(:task), question, approver_user_id)
|
|
32
|
+
# Valid native calls are intercepted before execution. Other callers
|
|
33
|
+
# have no resumable conversation, even if they carry an agent context.
|
|
34
|
+
{ error: I18n.t("collavre.approval_gate.native_required") }
|
|
35
|
+
rescue ArgumentError, PermissionDeniedError => e
|
|
36
|
+
{ error: e.message }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.approver!(task, question, approver_user_id)
|
|
40
|
+
raise ArgumentError, I18n.t("collavre.approval_gate.question_required") if question.blank?
|
|
41
|
+
raise ArgumentError, I18n.t("collavre.approval_gate.native_required") unless task&.running?
|
|
42
|
+
|
|
43
|
+
id = approver_user_id || task.trigger_event_payload&.dig("comment", "user_id")
|
|
44
|
+
approver = User.find_by(id: id)
|
|
45
|
+
creative = task.creative&.effective_origin
|
|
46
|
+
unless approver && !approver.ai_user? && creative &&
|
|
47
|
+
(creative.user == approver || creative.has_permission?(approver, :read))
|
|
48
|
+
raise ArgumentError, I18n.t("collavre.approval_gate.invalid_approver")
|
|
49
|
+
end
|
|
50
|
+
approver
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Collavre
|
|
4
|
+
module Tools
|
|
5
|
+
class AsyncApprovalRequest
|
|
6
|
+
def call(task_id:, question:, approver_user_id: nil)
|
|
7
|
+
task = Task.find_by(id: task_id)
|
|
8
|
+
task&.with_lock do
|
|
9
|
+
authorize!(task)
|
|
10
|
+
approver_id = approver_user_id || AiAgent::TaskWorkspaceUser.resolve(task)&.id || 0
|
|
11
|
+
approver = ApprovalRequestService.approver!(task, question, approver_id)
|
|
12
|
+
gate = task.async_approval_gates.first || create_gate(task, question, approver)
|
|
13
|
+
return { status: "pending", request_id: gate.approval_gate_action["request_id"],
|
|
14
|
+
question: gate.content, instruction: I18n.t("collavre.approval_gate.async_pending") }
|
|
15
|
+
end
|
|
16
|
+
raise ArgumentError, I18n.t("collavre.approval_gate.invalid_task")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def authorize!(task)
|
|
22
|
+
caller = Current.user
|
|
23
|
+
unless caller && task.running? && task.agent.cli_proxy_agent? &&
|
|
24
|
+
authorized_caller?(task, caller) &&
|
|
25
|
+
Topic.exists?(id: task.topic_id, creative_id: task.creative_id)
|
|
26
|
+
raise ArgumentError, I18n.t("collavre.approval_gate.invalid_task")
|
|
27
|
+
end
|
|
28
|
+
# The gate is raised on the agent's behalf, so its tool selection applies
|
|
29
|
+
# even when the CLI authenticates with its creator's token.
|
|
30
|
+
AgentToolPermission.authorize_call!("approval_request", agent: task.agent)
|
|
31
|
+
TopicAuthorizer.authorize_creative!(task.creative, :feedback, user: caller)
|
|
32
|
+
TopicAuthorizer.authorize_creative!(task.creative, :feedback, user: task.agent)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def authorized_caller?(task, caller)
|
|
36
|
+
workspace = Current.mcp_agent_workspace
|
|
37
|
+
return task.agent == caller || task.agent.created_by_id == caller.id unless workspace
|
|
38
|
+
|
|
39
|
+
workspace.agent_id == task.agent_id && (workspace.user || workspace.agent) == caller &&
|
|
40
|
+
(workspace.user_id.nil? || workspace_principal(task) == caller)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def workspace_principal(task)
|
|
44
|
+
principal = AiAgent::TaskWorkspaceUser.resolve(task)
|
|
45
|
+
return principal if task.trigger_event_payload&.key?("workspace_user_id")
|
|
46
|
+
|
|
47
|
+
principal || task.agent.creator
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def create_gate(task, question, approver)
|
|
51
|
+
Comment.create!(creative: task.creative, topic_id: task.topic_id, user: task.agent,
|
|
52
|
+
approver: approver, content: question, private: false, async_approval_task_id: task.id,
|
|
53
|
+
action: { action: "approval_gate", mode: "async", task_id: task.id,
|
|
54
|
+
request_id: SecureRandom.uuid }.to_json)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -8,7 +8,7 @@ module Tools
|
|
|
8
8
|
include Collavre::PublicAssetsHelper
|
|
9
9
|
|
|
10
10
|
tool_name "creative_attach_files_service"
|
|
11
|
-
tool_description "Attach inline, agent-generated TEXT content (markdown, html, svg, plain text) to a Creative. The content is stored as an ActiveStorage blob, embedded into the Creative's description, and
|
|
11
|
+
tool_description "Attach inline, agent-generated TEXT content (markdown, html, svg, plain text) to a Creative. The content is stored as an ActiveStorage blob, embedded into the Creative's description, and a download URL is returned. Anyone may fetch it only while they can read the Creative: publicly shared attachments get a CDN-cached /public-assets URL, others an app-host URL authorized per request (session or bearer token).\n\nUse this for content the agent produced as text (notes, generated markdown/html/svg).\n\nFor BINARY files already on disk (png, mp4, pdf), use the CLI `collavre attach --creative <id> --file <path>` instead — it uploads the raw bytes over a bearer multipart HTTP endpoint without base64 bloat.\n\nRequires :write permission on the target Creative. A Creative with inherited ai_write_policy=review stores a draft in History for approval."
|
|
12
12
|
|
|
13
13
|
tool_param :creative_id, description: "ID of the Creative to attach content to.", required: true
|
|
14
14
|
tool_param :files, description: "Array of objects: { filename, content, content_type? }. `content` is the literal UTF-8 text to store (e.g. markdown/html/svg source). `content_type` is inferred from the filename when omitted.", required: true
|
|
@@ -30,6 +30,14 @@ module Tools
|
|
|
30
30
|
# later in the array never leaves an orphaned blob from an earlier one.
|
|
31
31
|
return { error: "Each file requires a filename" } if files.any? { |f| f["filename"].to_s.blank? }
|
|
32
32
|
|
|
33
|
+
Creatives::AiWritePolicy.capture(
|
|
34
|
+
creatives: [ creative, creative.effective_origin ], anchor: Creatives::AiWritePolicy.agent_anchor || creative
|
|
35
|
+
) { attach_files(creative, files) }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def attach_files(creative, files)
|
|
33
41
|
blobs = files.map do |f|
|
|
34
42
|
name = f["filename"].to_s
|
|
35
43
|
content = f["content"].to_s
|
|
@@ -52,7 +60,7 @@ module Tools
|
|
|
52
60
|
filename: b.filename.to_s,
|
|
53
61
|
content_type: b.content_type,
|
|
54
62
|
byte_size: b.byte_size,
|
|
55
|
-
url:
|
|
63
|
+
url: attachment_access_url(b)
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
}
|
|
@@ -10,17 +10,18 @@ module Collavre
|
|
|
10
10
|
tool_name "creative_batch_service"
|
|
11
11
|
tool_description "Execute multiple Creative operations (create, update, delete) in a single batch call. " \
|
|
12
12
|
"All operations run inside a transaction — if any operation fails, the entire batch is rolled back.\n\n" \
|
|
13
|
-
"
|
|
13
|
+
"Delete operations archive Creatives so they remain recoverable from History.\n\n" \
|
|
14
|
+
"A Creative with inherited ai_write_policy=review stores a draft in History for approval instead of applying immediately.\n\n" \
|
|
14
15
|
"Each operation is a hash with an 'action' key ('create', 'update', or 'delete') plus action-specific fields."
|
|
15
16
|
|
|
16
17
|
def self.requires_approval?
|
|
17
|
-
|
|
18
|
+
false
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
tool_param :operations, description: "Array of operation objects. Each object must have an 'action' key.\n\n" \
|
|
21
22
|
"For 'create': { action: 'create', parent_id: <int>, description: <markdown string>, progress: <float>, after_id: <int>, before_id: <int> }\n" \
|
|
22
23
|
"For 'update': { action: 'update', id: <int>, description: <markdown string>, progress: 1.0, parent_id: <int> } — progress only accepts 1.0 (complete) and only on leaf Creatives\n" \
|
|
23
|
-
"For 'delete': { action: 'delete', id: <int> }\n\n" \
|
|
24
|
+
"For 'delete': { action: 'delete', id: <int> } — archives the Creative and its propagated family\n\n" \
|
|
24
25
|
"The 'description' field is written as Markdown (GitHub-Flavored).\n" \
|
|
25
26
|
"Fields other than 'action' and 'id'/'parent_id' are optional.", required: true
|
|
26
27
|
|
|
@@ -37,6 +38,15 @@ module Collavre
|
|
|
37
38
|
def call(operations:)
|
|
38
39
|
raise "Current.user is required" unless Current.user
|
|
39
40
|
|
|
41
|
+
Creatives::AiWritePolicy.capture(
|
|
42
|
+
creatives: review_targets(operations),
|
|
43
|
+
anchor: Creatives::AiWritePolicy.agent_anchor
|
|
44
|
+
) { perform_operations(operations) }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def perform_operations(operations)
|
|
40
50
|
results = []
|
|
41
51
|
|
|
42
52
|
ApplicationRecord.transaction do
|
|
@@ -66,7 +76,81 @@ module Collavre
|
|
|
66
76
|
{ success: false, error: "Operation #{failed[:index]} (#{failed[:action]}) failed: #{failed[:error]}", results: e.results }
|
|
67
77
|
end
|
|
68
78
|
|
|
69
|
-
|
|
79
|
+
def review_targets(operations)
|
|
80
|
+
ids = operations.flat_map do |operation|
|
|
81
|
+
operation = operation.stringify_keys
|
|
82
|
+
[ operation["id"], operation["parent_id"], operation["before_id"], operation["after_id"] ]
|
|
83
|
+
end.compact.map(&:to_i).select(&:positive?)
|
|
84
|
+
creatives = Creative.where(id: ids).to_a
|
|
85
|
+
delete_ids = operations.filter_map do |operation|
|
|
86
|
+
operation = operation.stringify_keys
|
|
87
|
+
operation["id"].to_i if operation["action"] == "delete"
|
|
88
|
+
end.to_set
|
|
89
|
+
archive_targets = creatives.select { |creative| delete_ids.include?(creative.id) }
|
|
90
|
+
.flat_map { |creative| creative.archive_family.to_a }
|
|
91
|
+
archive_targets.concat(moved_families_before_delete(operations, creatives))
|
|
92
|
+
progress_targets = propagation_targets(progress_sources(operations, creatives))
|
|
93
|
+
archive_progress_targets = propagation_targets(archive_targets)
|
|
94
|
+
structural_progress_sources = structural_progress_sources(operations, creatives)
|
|
95
|
+
structural_progress_targets = propagation_targets(structural_progress_sources)
|
|
96
|
+
[
|
|
97
|
+
*creatives, *archive_targets, *progress_targets, *archive_progress_targets,
|
|
98
|
+
*structural_progress_sources, *structural_progress_targets, *reorder_targets(operations)
|
|
99
|
+
]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def progress_sources(operations, creatives)
|
|
103
|
+
progress_ids = operations.filter_map do |operation|
|
|
104
|
+
operation = operation.stringify_keys
|
|
105
|
+
operation["id"].to_i if operation["action"] == "update" && operation["progress"].present?
|
|
106
|
+
end.to_set
|
|
107
|
+
creatives.select { |creative| progress_ids.include?(creative.id) }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def propagation_targets(creatives)
|
|
111
|
+
creatives.flat_map { |creative| Creatives::ProgressPropagationTargets.new(creative.effective_origin).call }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def structural_progress_sources(operations, creatives)
|
|
115
|
+
records = creatives.index_by(&:id)
|
|
116
|
+
operations.flat_map do |operation|
|
|
117
|
+
operation = operation.stringify_keys
|
|
118
|
+
case operation["action"]
|
|
119
|
+
when "create"
|
|
120
|
+
records[operation["parent_id"].to_i]
|
|
121
|
+
when "update"
|
|
122
|
+
move_progress_sources(operation, records)
|
|
123
|
+
end
|
|
124
|
+
end.compact
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def move_progress_sources(operation, records)
|
|
128
|
+
return [] unless operation["parent_id"].present? && operation["parent_id"].to_i.positive?
|
|
129
|
+
|
|
130
|
+
[ records[operation["id"].to_i]&.parent, records[operation["parent_id"].to_i] ].compact
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def moved_families_before_delete(operations, creatives)
|
|
134
|
+
records = creatives.index_by(&:id)
|
|
135
|
+
delete_indexes = operations.each_index.select { |index| operations[index].stringify_keys["action"] == "delete" }
|
|
136
|
+
operations.each_with_index.flat_map do |operation, index|
|
|
137
|
+
operation = operation.stringify_keys
|
|
138
|
+
next [] unless operation["action"] == "update" && delete_indexes.any? { |delete_index| delete_index > index }
|
|
139
|
+
next [] unless operation["parent_id"].present? && operation["parent_id"].to_i.positive?
|
|
140
|
+
|
|
141
|
+
records[operation["id"].to_i]&.archive_family&.to_a || []
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def reorder_targets(operations)
|
|
146
|
+
operations.flat_map do |operation|
|
|
147
|
+
operation = operation.stringify_keys
|
|
148
|
+
next [] unless operation["action"] == "create" && (operation["before_id"].present? || operation["after_id"].present?)
|
|
149
|
+
|
|
150
|
+
parent_id = operation["parent_id"].to_i
|
|
151
|
+
parent_id.positive? ? Creative.where(parent_id: parent_id).to_a : Creative.roots.to_a
|
|
152
|
+
end
|
|
153
|
+
end
|
|
70
154
|
|
|
71
155
|
def execute_create(op)
|
|
72
156
|
service = CreativeCreateService.new
|
|
@@ -100,12 +184,8 @@ module Collavre
|
|
|
100
184
|
return { error: "Creative not found", id: id } unless creative
|
|
101
185
|
return { error: "No write permission on this Creative", id: id } unless creative.has_permission?(Current.user, :write)
|
|
102
186
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
user: Current.user
|
|
106
|
-
).call
|
|
107
|
-
return { error: "Failed to destroy creative", id: id } unless result
|
|
108
|
-
{ success: true, id: id, deleted: true }
|
|
187
|
+
creative.archive!
|
|
188
|
+
{ success: true, id: id, archived: true }
|
|
109
189
|
end
|
|
110
190
|
end
|
|
111
191
|
end
|