@sentry/junior 0.314.0 → 0.316.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{channel-access-BOL29BG3.js → adapter-context-Bref7aPI.js} +42 -3
- package/dist/{admin-BXGAySz0.js → admin-QYiDMnsu.js} +1 -1
- package/dist/agent-runner-Cr5Fhjf-.js +23870 -0
- package/dist/{agent-update-delivery-CZ5M8RDa.js → agent-update-delivery-BY13DPSD.js} +46 -9
- package/dist/api/schema.d.ts +9549 -2
- package/dist/api/schema.js +4 -6
- package/dist/api.d.ts +2 -3
- package/dist/api.js +747 -293
- package/dist/{app-D7tKnw9a.d.ts → app-BhvzRD__.d.ts} +314 -29
- package/dist/app.d.ts +1 -1
- package/dist/app.js +268 -58
- package/dist/change-record-Bqsa5ZXE.d.ts +175 -0
- package/dist/chat-core-engine-3dtlMku3.js +123 -0
- package/dist/cli/chat.d.ts +4 -1
- package/dist/cli/chat.js +39 -21
- package/dist/cli/check.js +4 -4
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +3 -4
- package/dist/cli/run.d.ts +1 -1
- package/dist/cli/run.js +1 -1
- package/dist/cli/snapshot-create.js +2 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +46 -74
- package/dist/{continue-in-slack-fnmD2Ifb.js → continue-in-slack-DbQUFe_F.js} +3 -5
- package/dist/{conversation-feed-DdFQuQDR.js → conversation-feed-B84pMjHo.js} +28 -3
- package/dist/{conversation-turn-DScuDYmN.js → conversation-turn-DzEpTIaf.js} +152 -199
- package/dist/{create-CrNt4Ewu.js → create-DUJBXr6E.js} +4 -4
- package/dist/{credential-sync-CtqsGjj1.js → credential-sync-JH_K9Adg.js} +10 -15
- package/dist/db-BpxcYXfD.d.ts +2 -0
- package/dist/{credentialed-dWRA3-oJ.js → db-DhzvUY23.js} +21830 -9264
- package/dist/deployment-BhvrhQeh.js +51 -0
- package/dist/engine-context-C9Nal48K.js +1814 -0
- package/dist/{html-B8rBt7F4.js → html-B_12WjKT.js} +2 -5
- package/dist/instrumentation.js +2 -2
- package/dist/job-runner-DO8nslyY.js +1139 -0
- package/dist/{lineage-EULJkGO1.js → lineage-D3AZAJVe.js} +1 -1
- package/dist/{list-C5400AlJ.js → list-B0zsb5Cp.js} +307 -146
- package/dist/{markers-DUP8aBOp.js → list-mkB_GU8R.js} +96 -124
- package/dist/local-server-CpnGhYml.js +276 -0
- package/dist/{conversation-privacy-DtZhI91r.js → logging-B8KEJegM.js} +2 -231
- package/dist/{media-FYM-Bl3H.js → media-BebquhET.js} +684 -37
- package/dist/{message-DuDelZFr.js → message-B5fKDYzz.js} +18 -16
- package/dist/{model-input-0osF3pBS.js → model-input-CuMWy37l.js} +3 -3
- package/dist/nitro.d.ts +7 -1
- package/dist/nitro.js +48 -293
- package/dist/{oauth-callback-server-DX2fQ7Nq.js → oauth-callback-server-B3Vvlydo.js} +2 -2
- package/dist/{oauth-relay-PwPMdZJv.js → oauth-relay-6ERrGPbA.js} +1 -1
- package/dist/{package-discovery-DD9vencX.js → package-discovery-BI6T_RkD.js} +50 -1
- package/dist/people-CUtFApfL.js +81 -0
- package/dist/proxy-path-BTmXDjfx.js +203 -0
- package/dist/{resolve-D8CPJcNK.js → resolve-D5JVvv6A.js} +229 -4
- package/dist/{result-D090hxr5.js → result-CS_7mo8a.js} +95 -144
- package/dist/{runner-BU7fgrm-.js → runner-BzAES5W3.js} +7 -7
- package/dist/{sandbox-egress-signals-BUmVrsoG.js → sandbox-egress-signals-Dwhk2Q5F.js} +1 -1
- package/dist/{schema-7gW9vBpJ.js → schema-z5-wA6N4.js} +132 -15
- package/dist/{service-account-plA-uzIB.js → service-account-D6AsAtc1.js} +1 -3
- package/dist/{mailbox-turn-DL3Lvsm0.js → session-stop-DponjDUZ.js} +3259 -3793
- package/dist/{skills-CIosT6bS.js → skills-DgJ9GBPR.js} +4 -4
- package/dist/{slack-conversation-unfurl-CBgZqth6.js → slack-conversation-unfurl-Dq71EkhM.js} +6 -8
- package/dist/{spawn-DRjdzh3R.js → spawn-BJWpdwhQ.js} +4 -5
- package/dist/start-conversation-B-LIqqNi.js +162 -0
- package/dist/system-prompt-table-iIgpmslr.js +1171 -0
- package/dist/{task-runner-C-pXsgHM.js → task-runner-BJae4JwE.js} +83 -17
- package/dist/{thread-context-CDX4dSZd.js → thread-context-fiMNylbg.js} +5 -6
- package/dist/topic-CRYYBYp-.js +7 -0
- package/dist/transcript-CCi7323k.js +410 -0
- package/dist/turn-session-routing-D15orfwy.js +1309 -0
- package/dist/{turn-wake-Bzq1Efrm.js → turn-wake-BjDW7x-5.js} +5 -7
- package/dist/{validation-bTq88sya.js → validation-D5WmmmhX.js} +1 -1
- package/dist/{version-DGUa1dZK.js → version-CBQoanXb.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/virtual-module-BeKA_EII.js +12 -0
- package/dist/{worker-AkZg7Dg1.js → worker-Cyb4kF17.js} +3 -5
- package/migrations/20260711145847_initial/snapshot.json +2103 -0
- package/migrations/20260711145900_conversation_metrics/snapshot.json +135 -0
- package/migrations/20260712153649_conversation_message_search/snapshot.json +50 -0
- package/migrations/20260713040256_peaceful_scalphunter/snapshot.json +42 -0
- package/migrations/20260715174202_useful_magus/snapshot.json +42 -0
- package/migrations/20260715174203_conversation_events/snapshot.json +539 -0
- package/migrations/20260723042835_drop_legacy_conversation_messages/snapshot.json +9 -0
- package/migrations/20260723050612_thick_sugar_man/snapshot.json +120 -0
- package/migrations/20260727223822_sticky_rage/snapshot.json +274 -0
- package/migrations/20260728033158_slippery_harrier/snapshot.json +191 -0
- package/migrations/20260728040836_native_conversation_history/snapshot.json +9 -0
- package/migrations/20260728204900_sour_golden_guardian/snapshot.json +124 -0
- package/migrations/20260730233332_structured_conversation_events/snapshot.json +9 -0
- package/migrations/20260731164038_conversation_session_source/snapshot.json +42 -0
- package/migrations/20260801230336_source_visibility/snapshot.json +9 -0
- package/migrations/20260802023731_magical_ezekiel_stane/snapshot.json +266 -0
- package/migrations/20260804015843_neat_the_anarchist/snapshot.json +714 -0
- package/migrations/20260804165952_drop_paused_scheduled_tasks/snapshot.json +9 -0
- package/migrations/20260804225613_curvy_excalibur/snapshot.json +223 -0
- package/migrations/20260805174033_lowly_valkyrie/snapshot.json +344 -0
- package/migrations/20260805200301_restrict_task_execution_kinds/snapshot.json +36 -0
- package/migrations/20260806030729_first_warhawk/snapshot.json +690 -0
- package/migrations/20260807185200_task_execution_status/snapshot.json +92 -0
- package/migrations/20260808014743_task_title_columns/snapshot.json +68 -0
- package/migrations/20260809220421_misty_typhoid_mary/snapshot.json +191 -0
- package/migrations/20260811193709_mcp_credential_subject/snapshot.json +9 -0
- package/migrations/20260812032924_conversation_event_actor_and_participants/snapshot.json +393 -0
- package/migrations/20260812172418_attachment_storage/snapshot.json +341 -0
- package/migrations/20260813230732_artifacts/snapshot.json +349 -0
- package/migrations/20260814062905_dizzy_barracuda/snapshot.json +342 -0
- package/migrations/20260814231353_drop_workspace_repo_primary/snapshot.json +55 -0
- package/migrations/20260815030100_wild_phantom_reporter/snapshot.json +135 -0
- package/migrations/20260817082233_workspace_snapshots_table/snapshot.json +625 -0
- package/migrations/20260818160339_workspace_snapshot_active_build/snapshot.json +62 -0
- package/migrations/20260821180755_strong_randall/snapshot.json +42 -0
- package/migrations/20260823030308_workspace_snapshot_size_bytes/snapshot.json +62 -0
- package/migrations/20260824190313_complex_rage/snapshot.json +690 -0
- package/migrations/20260827233711_conversation_location/snapshot.json +42 -0
- package/migrations/20260901224306_event_task_status/snapshot.json +100 -0
- package/migrations/20260904153232_attachment_provider/snapshot.json +234 -0
- package/migrations/20260909111415_conversation_briefs/snapshot.json +364 -0
- package/migrations/20260910144928_automation_outcomes_backfill/snapshot.json +9 -0
- package/migrations/20260911184346_conversation_metrics/snapshot.json +226 -0
- package/migrations/20260921140842_scheduled_automation_channel_destinations/snapshot.json +9 -0
- package/migrations/20260922221709_event_automation_channel_destinations/snapshot.json +9 -0
- package/migrations/20261001113455_conversation_forks/snapshot.json +120 -0
- package/migrations/20261005161844_automation_versions/snapshot.json +150 -0
- package/migrations/20261006152043_user_timezone/snapshot.json +37 -0
- package/migrations/20261008200858_user_admin/snapshot.json +37 -0
- package/migrations/20261009145407_event_automation_status_reason/snapshot.json +42 -0
- package/migrations/20261013160816_agent_invocation_parent_mailbox/snapshot.json +93 -0
- package/migrations/20261013215020_agent_invocation_parent_tool_call/snapshot.json +42 -0
- package/migrations/20261014011138_agent_invocation_title/snapshot.json +42 -0
- package/migrations/20261014211942_conversation_stopped_at/snapshot.json +42 -0
- package/migrations/20261015012820_flowery_rage/snapshot.json +42 -0
- package/migrations/20261017000924_automations/snapshot.json +790 -0
- package/migrations/20261017134736_automation_runs/snapshot.json +474 -0
- package/migrations/20261017170250_drop_legacy_automation_tables/snapshot.json +397 -0
- package/migrations/20261018134754_automation_creator_identity/snapshot.json +130 -0
- package/migrations/20261023071954_automation_run_version/snapshot.json +79 -0
- package/migrations/20261025233137_identity_signed_in_at/snapshot.json +42 -0
- package/migrations/20261027234315_workspace_vcpus/snapshot.json +37 -0
- package/migrations/20261028124242_plugin_report_index/snapshot.json +68 -0
- package/migrations/20261028154230_agent_invocation_type/snapshot.json +42 -0
- package/migrations/20261030021803_any_resource_event_triggers/snapshot.json +42 -0
- package/migrations/20261030234309_user_customization/snapshot.json +37 -0
- package/migrations/20261031020656_review_items/snapshot.json +1078 -0
- package/migrations/20261031024151_review_item_dedupe_tenant/snapshot.json +62 -0
- package/migrations/20261031024246_review_item_slack_cards/snapshot.json +159 -0
- package/migrations/20261031155308_system_identity/snapshot.json +9 -0
- package/migrations/20261101193952_review_item_foreign_keys/snapshot.json +108 -0
- package/migrations/20261102172751_review_item_turn/snapshot.json +42 -0
- package/migrations/20261102221411_conversation_read_positions/snapshot.json +190 -0
- package/migrations/20261104085028_conversation_quick_question/snapshot.json +42 -0
- package/migrations/20261104145136_conversation_participant_pins/snapshot.json +42 -0
- package/migrations/20261104164429_conversation_detail_version/snapshot.json +42 -0
- package/migrations/20261104172055_conversation_auto_archive/snapshot.json +206 -0
- package/migrations/20261105005443_drop_agent_invocation_model_profile/snapshot.json +30 -0
- package/migrations/20261105043807_plugin_conversation_index/snapshot.json +76 -0
- package/migrations/20261105051837_conversation_event_author_index/snapshot.json +70 -0
- package/migrations/20261105182854_conversation_event_latest_message_indexes/snapshot.json +136 -0
- package/migrations/20261106011443_conversation_pin_position/snapshot.json +42 -0
- package/migrations/20261106095004_push_notifications/snapshot.json +308 -0
- package/migrations/20261106162740_conversation_kind/snapshot.json +88 -0
- package/migrations/20261107002001_read_position_backfill/snapshot.json +9 -0
- package/migrations/20261107025209_child_archived_at/snapshot.json +42 -0
- package/migrations/20261107035735_shared_archive/snapshot.json +67 -0
- package/migrations/20261107215055_child_location/snapshot.json +9 -0
- package/migrations/20261108191927_conversation_unsubscribe/snapshot.json +42 -0
- package/migrations/20261109021618_conversation_paused_status/snapshot.json +9 -0
- package/migrations/20261109111553_guardian_review_time_index/snapshot.json +54 -0
- package/migrations/20261109173130_conversation_participant_unsubscribed_index/snapshot.json +62 -0
- package/migrations/20261109182006_turn_metric_actor/snapshot.json +128 -0
- package/migrations/20261109202836_participant_root_actor_backfill/snapshot.json +9 -0
- package/migrations/20261109232640_conversation_delivery_paused_at/snapshot.json +42 -0
- package/migrations/20261110120937_web_linked_slack_identity_repair/snapshot.json +9 -0
- package/migrations/20261110175824_automation_task_kind/snapshot.json +145 -0
- package/migrations/20261110210242_conversation_kind_automation/snapshot.json +55 -0
- package/migrations/20261110222632_review_item_plugin_actions/snapshot.json +37 -0
- package/migrations/20261110225157_conversation_last_message_at/snapshot.json +42 -0
- package/migrations/20261111013351_automation_task_kind_repair/snapshot.json +9 -0
- package/migrations/20261111163126_drop_legacy_columns/snapshot.json +9 -0
- package/migrations/20261111170150_code_change_last_activity/snapshot.json +42 -0
- package/migrations/20261111191441_agent_invocation_fork/snapshot.json +42 -0
- package/migrations/20261112142841_code_change_draft/snapshot.json +37 -0
- package/migrations/20261112202901_attachment_uploads/snapshot.json +255 -0
- package/migrations/20261112220407_conversation_agent_config/snapshot.json +42 -0
- package/migrations/20261113081247_attachment_deferred_download/snapshot.json +52 -0
- package/migrations/20261113225551_conversation_embeddings/snapshot.json +203 -0
- package/migrations/20261114213238_user_preferences/snapshot.json +37 -0
- package/migrations/20261114222527_code_change_repository_state_index/snapshot.json +70 -0
- package/migrations/20261115172605_attachment_kinds/snapshot.json +244 -0
- package/migrations/20261115173004_attachment_url_fill/snapshot.json +9 -0
- package/migrations/20261115180216_attachment_url_index/snapshot.json +62 -0
- package/migrations/20261116103700_plan_items/snapshot.json +420 -0
- package/migrations/20261117100100_automation_creator_slack_index/snapshot.json +62 -0
- package/migrations/20261117132522_conversation_event_search/snapshot.json +396 -0
- package/migrations/20261117164007_automation_last_run/snapshot.json +108 -0
- package/migrations/20261117164047_automation_last_run_index/snapshot.json +54 -0
- package/migrations/20261117210444_money_micro_usd/snapshot.json +68 -0
- package/migrations/20261117210505_conversation_cost_micro_usd/snapshot.json +9 -0
- package/migrations/20261118081416_people_list_metric_index/snapshot.json +86 -0
- package/migrations/20261118095216_automation_rollout_repair/snapshot.json +9 -0
- package/migrations/20261118143948_cache_warming_history_reset/snapshot.json +9 -0
- package/migrations/20261119040651_artifact_visibility/snapshot.json +132 -0
- package/migrations/20261119040715_artifact_public_sha_index/snapshot.json +9 -0
- package/migrations/20261119052706_artifact_drop_public/snapshot.json +71 -0
- package/migrations/20261119053831_artifact_path/snapshot.json +114 -0
- package/migrations/20261119053844_artifact_path_index/snapshot.json +9 -0
- package/migrations/20261119091949_review_item_answered_index/snapshot.json +70 -0
- package/migrations/20261119100029_review_item_status_index/snapshot.json +54 -0
- package/migrations/20261119165607_brief_outcome_status/snapshot.json +42 -0
- package/migrations/20261119165622_brief_outcome_status_backfill/snapshot.json +9 -0
- package/migrations/20261119213716_brief_created_at_index/snapshot.json +62 -0
- package/migrations/20261119222456_slack_person_search_index/snapshot.json +50 -0
- package/migrations/20261119225522_code_change_size/snapshot.json +104 -0
- package/migrations/20261119232253_merge_conflict_notice_dismiss/snapshot.json +9 -0
- package/migrations/20261119235649_inbox_snoozes/snapshot.json +605 -0
- package/migrations/20261120093118_code_change_search_index/snapshot.json +89 -0
- package/migrations/20261120093452_review_item_owner/snapshot.json +314 -0
- package/migrations/20261120185654_review_item_owner_index/snapshot.json +62 -0
- package/migrations/20261120185754_memory_core_adoption/snapshot.json +1184 -0
- package/migrations/20261120185854_memory_core_indexes/snapshot.json +70 -0
- package/migrations/20261120235226_todos/snapshot.json +473 -0
- package/migrations/20261121082316_inbox_items/snapshot.json +2026 -0
- package/migrations/20261121175651_todo_changed_by_agent/snapshot.json +42 -0
- package/migrations/20261121183527_inbox_item_subject_title_parts/snapshot.json +42 -0
- package/migrations/20261121194143_inbox_snooze_wake_reason/snapshot.json +42 -0
- package/migrations/20261121222400_authorization_request_index/snapshot.json +62 -0
- package/migrations/20261121225908_conversation_metadata/snapshot.json +184 -0
- package/migrations/20261121225910_conversation_metadata_fill/snapshot.json +9 -0
- package/migrations/20261121225913_conversation_search_index/snapshot.json +50 -0
- package/migrations/20261122022900_inbox_item_legacy_automation_keys/snapshot.json +9 -0
- package/migrations/20261122024454_artifact_expiry/snapshot.json +37 -0
- package/migrations/20261122024455_artifact_permanent_sha_index/snapshot.json +62 -0
- package/migrations/20261122024457_artifact_drop_public_sha_index/snapshot.json +37 -0
- package/migrations/20261122024458_conversation_kind_lead/snapshot.json +55 -0
- package/migrations/20261122024459_conversation_lead_actor_index/snapshot.json +54 -0
- package/migrations/20261122071549_keep_legacy_archive_columns/snapshot.json +49 -0
- package/migrations/20261122191400_conversation_embeddings_fk_validate/snapshot.json +9 -0
- package/migrations/20261122204325_money_micro_usd_repair/snapshot.json +9 -0
- package/migrations/20261122204326_agent_config_backfill/snapshot.json +143 -0
- package/migrations/20261122221456_inbox_item_deliveries/snapshot.json +301 -0
- package/migrations/20261123155735_pg_trgm/snapshot.json +9 -0
- package/migrations/20261123155739_search_indexes/snapshot.json +167 -0
- package/migrations/20261123172647_drop_legacy_archive_columns/snapshot.json +9 -0
- package/migrations/20261123192506_memory_prefix_index/snapshot.json +69 -0
- package/migrations/20261123201740_todo_search_indexes/snapshot.json +89 -0
- package/migrations/20261123211505_todo_inbox_items/snapshot.json +38 -0
- package/migrations/20261123214917_drop_code_urls/snapshot.json +44 -0
- package/migrations/20261123224000_code_change_conversations_index/migration.sql +1 -0
- package/migrations/20261123224000_code_change_conversations_index/snapshot.json +54 -0
- package/migrations/20261124122023_drop_code_change_sizes/migration.sql +4 -0
- package/migrations/20261124122023_drop_code_change_sizes/snapshot.json +82 -0
- package/migrations/20261124142958_conversation_root_lookup_index/migration.sql +1 -0
- package/migrations/20261124142958_conversation_root_lookup_index/snapshot.json +62 -0
- package/migrations/20261124183352_legacy_brief_metadata_fill/migration.sql +26 -0
- package/migrations/20261124183352_legacy_brief_metadata_fill/snapshot.json +114 -0
- package/migrations/20261124202143_drizzle_v1_baseline/migration.sql +5 -0
- package/migrations/20261124202143_drizzle_v1_baseline/snapshot.json +2012 -0
- package/migrations/20261124221751_spaces/migration.sql +22 -0
- package/migrations/20261124221751_spaces/snapshot.json +436 -0
- package/migrations/20261124230319_conversation_metrics_utc_day_stats/migration.sql +11 -0
- package/migrations/20261124230319_conversation_metrics_utc_day_stats/snapshot.json +9 -0
- package/migrations/20261124234024_space_conversations/migration.sql +5 -0
- package/migrations/20261124234024_space_conversations/snapshot.json +103 -0
- package/migrations/20261124234026_space_conversations_index/migration.sql +1 -0
- package/migrations/20261124234026_space_conversations_index/snapshot.json +62 -0
- package/migrations/20261125012448_drop_lead_actor_index/migration.sql +3 -0
- package/migrations/20261125012448_drop_lead_actor_index/snapshot.json +36 -0
- package/migrations/20261125012452_space_lead_index/migration.sql +1 -0
- package/migrations/20261125012452_space_lead_index/snapshot.json +54 -0
- package/migrations/20261125043821_space_configurations/migration.sql +11 -0
- package/migrations/20261125043821_space_configurations/snapshot.json +194 -0
- package/migrations/20261125064854_agent_update_done_status/migration.sql +9 -0
- package/migrations/20261125064854_agent_update_done_status/snapshot.json +9 -0
- package/migrations/20261125073321_turn_engine_tables/migration.sql +75 -0
- package/migrations/20261125073321_turn_engine_tables/snapshot.json +1497 -0
- package/migrations/20261125073339_turn_inbox_one_source/migration.sql +5 -0
- package/migrations/20261125073339_turn_inbox_one_source/snapshot.json +9 -0
- package/migrations/20261125124506_versions_notify/migration.sql +27 -0
- package/migrations/20261125124506_versions_notify/snapshot.json +9 -0
- package/migrations/20261125140339_turn_group_key/migration.sql +14 -0
- package/migrations/20261125140339_turn_group_key/snapshot.json +75 -0
- package/migrations/20261125140343_turn_group_key_not_null/migration.sql +4 -0
- package/migrations/20261125140343_turn_group_key_not_null/snapshot.json +29 -0
- package/migrations/20261125142845_code_change_requesters/migration.sql +1 -0
- package/migrations/20261125142845_code_change_requesters/snapshot.json +42 -0
- package/migrations/20261125142846_code_change_requesters_index/migration.sql +1 -0
- package/migrations/20261125142846_code_change_requesters_index/snapshot.json +54 -0
- package/migrations/20261125143903_space_visibility/migration.sql +1 -0
- package/migrations/20261125143903_space_visibility/snapshot.json +37 -0
- package/migrations/20261125154848_merge_leaves/migration.sql +2 -0
- package/migrations/20261125154848_merge_leaves/snapshot.json +14 -0
- package/migrations/20261125171254_conversation_visibility/migration.sql +4 -0
- package/migrations/20261125171254_conversation_visibility/snapshot.json +67 -0
- package/migrations/20261125171257_conversation_visibility_backfill/migration.sql +25 -0
- package/migrations/20261125171257_conversation_visibility_backfill/snapshot.json +9 -0
- package/migrations/20261125213232_drop_versions_notify/migration.sql +19 -0
- package/migrations/20261125213232_drop_versions_notify/snapshot.json +9 -0
- package/migrations/20261125225138_conversation_kind_root_thread/migration.sql +23 -0
- package/migrations/20261125225138_conversation_kind_root_thread/snapshot.json +55 -0
- package/migrations/20261125225142_conversation_kind_root_thread_backfill/migration.sql +7 -0
- package/migrations/20261125225142_conversation_kind_root_thread_backfill/snapshot.json +9 -0
- package/migrations/20261126000151_conversation_event_message_role_seq_index/migration.sql +1 -0
- package/migrations/20261126000151_conversation_event_message_role_seq_index/snapshot.json +69 -0
- package/migrations/20261126012917_merge_leaves/migration.sql +2 -0
- package/migrations/20261126012917_merge_leaves/snapshot.json +12 -0
- package/package.json +13 -12
- package/skills/design-automation-skill/SKILL.md +1 -1
- package/skills/jr-rpc/SKILL.md +3 -5
- package/dist/adapter-JARQvoLw.js +0 -258
- package/dist/adapter-context-B4BrJZuS.js +0 -43
- package/dist/agent-runner-qZU5TR8i.js +0 -11974
- package/dist/agent-update-cS7Z9mnG.js +0 -26
- package/dist/background-compaction-queue-C_uIBUvS.js +0 -145
- package/dist/callback-C8SdXCwr.js +0 -68
- package/dist/catalog-runtime-BLKtnUL3.js +0 -6
- package/dist/config-BIfHKNXN.js +0 -2336
- package/dist/db-BTmLKZrp.js +0 -5804
- package/dist/db-DcmzbA55.d.ts +0 -274
- package/dist/history-CneKY7_V.js +0 -595
- package/dist/install-OtFboxOM.js +0 -228
- package/dist/proxy-path-BHYoKZdq.js +0 -15
- package/dist/registry-D6kS6xYH.js +0 -3024
- package/dist/rule-DAxQY-1h.js +0 -20
- package/dist/schema-BB6E0wyV.d.ts +0 -9472
- package/dist/start-conversation-a4NXH4X9.js +0 -752
- package/dist/store-BuhF1QDm.js +0 -490
- package/dist/task-queue-CrRjFzOh.js +0 -79
- package/dist/turn-session-routing-CZTRU8IY.js +0 -116
- package/dist/vercel-queue-nL0Hq3hr.js +0 -234
- package/dist/warmup-CCOuIwAS.js +0 -12759
- package/migrations/meta/0000_snapshot.json +0 -946
- package/migrations/meta/0001_snapshot.json +0 -972
- package/migrations/meta/0002_snapshot.json +0 -987
- package/migrations/meta/0003_snapshot.json +0 -1035
- package/migrations/meta/0004_snapshot.json +0 -1041
- package/migrations/meta/0005_snapshot.json +0 -948
- package/migrations/meta/0006_snapshot.json +0 -948
- package/migrations/meta/0007_snapshot.json +0 -1013
- package/migrations/meta/0008_snapshot.json +0 -1076
- package/migrations/meta/0009_snapshot.json +0 -1146
- package/migrations/meta/0010_snapshot.json +0 -1190
- package/migrations/meta/0011_snapshot.json +0 -1195
- package/migrations/meta/0012_snapshot.json +0 -1244
- package/migrations/meta/0013_snapshot.json +0 -1250
- package/migrations/meta/0014_snapshot.json +0 -1201
- package/migrations/meta/0015_snapshot.json +0 -1360
- package/migrations/meta/0016_snapshot.json +0 -1617
- package/migrations/meta/0017_snapshot.json +0 -1666
- package/migrations/meta/0018_snapshot.json +0 -1756
- package/migrations/meta/0019_snapshot.json +0 -1904
- package/migrations/meta/0020_snapshot.json +0 -1848
- package/migrations/meta/0021_snapshot.json +0 -2176
- package/migrations/meta/0022_snapshot.json +0 -2186
- package/migrations/meta/0023_snapshot.json +0 -2198
- package/migrations/meta/0024_snapshot.json +0 -2275
- package/migrations/meta/0025_snapshot.json +0 -2275
- package/migrations/meta/0026_snapshot.json +0 -2424
- package/migrations/meta/0027_snapshot.json +0 -2554
- package/migrations/meta/0028_snapshot.json +0 -2685
- package/migrations/meta/0029_snapshot.json +0 -2709
- package/migrations/meta/0030_snapshot.json +0 -2799
- package/migrations/meta/0031_snapshot.json +0 -2823
- package/migrations/meta/0032_snapshot.json +0 -2892
- package/migrations/meta/0033_snapshot.json +0 -2914
- package/migrations/meta/0034_snapshot.json +0 -3038
- package/migrations/meta/0035_snapshot.json +0 -3048
- package/migrations/meta/0036_snapshot.json +0 -3186
- package/migrations/meta/0037_snapshot.json +0 -3192
- package/migrations/meta/0038_snapshot.json +0 -3323
- package/migrations/meta/0039_snapshot.json +0 -3368
- package/migrations/meta/0040_snapshot.json +0 -3516
- package/migrations/meta/0041_snapshot.json +0 -3516
- package/migrations/meta/0042_snapshot.json +0 -3610
- package/migrations/meta/0043_snapshot.json +0 -3610
- package/migrations/meta/0044_snapshot.json +0 -3473
- package/migrations/meta/0045_snapshot.json +0 -3503
- package/migrations/meta/0046_snapshot.json +0 -3707
- package/migrations/meta/0047_snapshot.json +0 -3713
- package/migrations/meta/0048_snapshot.json +0 -3720
- package/migrations/meta/0049_snapshot.json +0 -3581
- package/migrations/meta/0050_snapshot.json +0 -3753
- package/migrations/meta/0051_snapshot.json +0 -3759
- package/migrations/meta/0052_snapshot.json +0 -3765
- package/migrations/meta/0053_snapshot.json +0 -3771
- package/migrations/meta/0054_snapshot.json +0 -3777
- package/migrations/meta/0055_snapshot.json +0 -3948
- package/migrations/meta/0056_snapshot.json +0 -4280
- package/migrations/meta/0057_snapshot.json +0 -3618
- package/migrations/meta/0058_snapshot.json +0 -3598
- package/migrations/meta/0059_snapshot.json +0 -3619
- package/migrations/meta/0060_snapshot.json +0 -3465
- package/migrations/meta/0061_snapshot.json +0 -3471
- package/migrations/meta/0062_snapshot.json +0 -3499
- package/migrations/meta/0063_snapshot.json +0 -3505
- package/migrations/meta/0064_snapshot.json +0 -3505
- package/migrations/meta/0065_snapshot.json +0 -3511
- package/migrations/meta/0066_snapshot.json +0 -4099
- package/migrations/meta/0067_snapshot.json +0 -3921
- package/migrations/meta/0068_snapshot.json +0 -4176
- package/migrations/meta/0069_snapshot.json +0 -3979
- package/migrations/meta/0070_snapshot.json +0 -3997
- package/migrations/meta/0071_snapshot.json +0 -4003
- package/migrations/meta/0072_snapshot.json +0 -4064
- package/migrations/meta/0073_snapshot.json +0 -4070
- package/migrations/meta/0074_snapshot.json +0 -4076
- package/migrations/meta/0075_snapshot.json +0 -4083
- package/migrations/meta/0076_snapshot.json +0 -4147
- package/migrations/meta/0077_snapshot.json +0 -4141
- package/migrations/meta/0078_snapshot.json +0 -4175
- package/migrations/meta/0079_snapshot.json +0 -4203
- package/migrations/meta/0080_snapshot.json +0 -4265
- package/migrations/meta/0081_snapshot.json +0 -4271
- package/migrations/meta/0082_snapshot.json +0 -4373
- package/migrations/meta/0083_snapshot.json +0 -4388
- package/migrations/meta/0084_snapshot.json +0 -4388
- package/migrations/meta/0085_snapshot.json +0 -4394
- package/migrations/meta/0086_snapshot.json +0 -4366
- package/migrations/meta/0087_snapshot.json +0 -4366
- package/migrations/meta/0088_snapshot.json +0 -4372
- package/migrations/meta/0089_snapshot.json +0 -4372
- package/migrations/meta/0090_snapshot.json +0 -4388
- package/migrations/meta/0091_snapshot.json +0 -4410
- package/migrations/meta/0092_snapshot.json +0 -4446
- package/migrations/meta/0093_snapshot.json +0 -4446
- package/migrations/meta/0094_snapshot.json +0 -4452
- package/migrations/meta/0095_snapshot.json +0 -4452
- package/migrations/meta/0096_snapshot.json +0 -4490
- package/migrations/meta/0097_snapshot.json +0 -4490
- package/migrations/meta/0098_snapshot.json +0 -4490
- package/migrations/meta/0099_snapshot.json +0 -4496
- package/migrations/meta/0100_snapshot.json +0 -4496
- package/migrations/meta/0101_snapshot.json +0 -4496
- package/migrations/meta/0102_snapshot.json +0 -4502
- package/migrations/meta/0103_snapshot.json +0 -4509
- package/migrations/meta/0104_snapshot.json +0 -4516
- package/migrations/meta/0105_snapshot.json +0 -4611
- package/migrations/meta/0106_snapshot.json +0 -4617
- package/migrations/meta/0107_snapshot.json +0 -4617
- package/migrations/meta/0108_snapshot.json +0 -4688
- package/migrations/meta/0109_snapshot.json +0 -4925
- package/migrations/meta/0110_snapshot.json +0 -4952
- package/migrations/meta/0111_snapshot.json +0 -5011
- package/migrations/meta/0112_snapshot.json +0 -5011
- package/migrations/meta/0113_snapshot.json +0 -5033
- package/migrations/meta/0114_snapshot.json +0 -5203
- package/migrations/meta/0115_snapshot.json +0 -5225
- package/migrations/meta/0116_snapshot.json +0 -5388
- package/migrations/meta/0117_snapshot.json +0 -5413
- package/migrations/meta/0118_snapshot.json +0 -5428
- package/migrations/meta/0119_snapshot.json +0 -5441
- package/migrations/meta/0120_snapshot.json +0 -5441
- package/migrations/meta/0121_snapshot.json +0 -5481
- package/migrations/meta/0122_snapshot.json +0 -5481
- package/migrations/meta/0123_snapshot.json +0 -5481
- package/migrations/meta/0124_snapshot.json +0 -5516
- package/migrations/meta/0125_snapshot.json +0 -5516
- package/migrations/meta/0126_snapshot.json +0 -5488
- package/migrations/meta/0127_snapshot.json +0 -5519
- package/migrations/meta/0128_snapshot.json +0 -5519
- package/migrations/meta/0129_snapshot.json +0 -5547
- package/migrations/meta/0130_snapshot.json +0 -5563
- package/migrations/meta/0131_snapshot.json +0 -5569
- package/migrations/meta/0132_snapshot.json +0 -5569
- package/migrations/meta/0133_snapshot.json +0 -5590
- package/migrations/meta/0134_snapshot.json +0 -5606
- package/migrations/meta/0135_snapshot.json +0 -5624
- package/migrations/meta/0136_snapshot.json +0 -5624
- package/migrations/meta/0137_snapshot.json +0 -5864
- package/migrations/meta/0138_snapshot.json +0 -5894
- package/migrations/meta/0139_snapshot.json +0 -5898
- package/migrations/meta/0140_snapshot.json +0 -5919
- package/migrations/meta/0141_snapshot.json +0 -6429
- package/migrations/meta/0142_snapshot.json +0 -6457
- package/migrations/meta/0143_snapshot.json +0 -6434
- package/migrations/meta/0144_snapshot.json +0 -6434
- package/migrations/meta/0145_snapshot.json +0 -6440
- package/migrations/meta/0146_snapshot.json +0 -6446
- package/migrations/meta/0147_snapshot.json +0 -6452
- package/migrations/meta/0148_snapshot.json +0 -6474
- package/migrations/meta/0149_snapshot.json +0 -6490
- package/migrations/meta/0150_snapshot.json +0 -6490
- package/migrations/meta/0151_snapshot.json +0 -6505
- package/migrations/meta/0152_snapshot.json +0 -6505
- package/migrations/meta/0153_snapshot.json +0 -6511
- package/migrations/meta/0154_snapshot.json +0 -6533
- package/migrations/meta/0155_snapshot.json +0 -6511
- package/migrations/meta/0156_snapshot.json +0 -6511
- package/migrations/meta/0157_snapshot.json +0 -6527
- package/migrations/meta/0158_snapshot.json +0 -6515
- package/migrations/meta/0159_snapshot.json +0 -6515
- package/migrations/meta/0160_snapshot.json +0 -6515
- package/migrations/meta/0161_snapshot.json +0 -6278
- package/migrations/meta/0162_snapshot.json +0 -6404
- package/migrations/meta/0163_snapshot.json +0 -6404
- package/migrations/meta/0164_snapshot.json +0 -6466
- package/migrations/meta/0165_snapshot.json +0 -6466
- package/migrations/meta/0166_snapshot.json +0 -6494
- package/migrations/meta/0167_snapshot.json +0 -6525
- package/migrations/meta/0168_snapshot.json +0 -6525
- package/migrations/meta/0169_snapshot.json +0 -6513
- package/migrations/meta/_journal.json +0 -1196
- /package/migrations/{0000_initial.sql → 20260711145847_initial/migration.sql} +0 -0
- /package/migrations/{0001_conversation_metrics.sql → 20260711145900_conversation_metrics/migration.sql} +0 -0
- /package/migrations/{0002_conversation_message_search.sql → 20260712153649_conversation_message_search/migration.sql} +0 -0
- /package/migrations/{0003_peaceful_scalphunter.sql → 20260713040256_peaceful_scalphunter/migration.sql} +0 -0
- /package/migrations/{0004_useful_magus.sql → 20260715174202_useful_magus/migration.sql} +0 -0
- /package/migrations/{0005_conversation_events.sql → 20260715174203_conversation_events/migration.sql} +0 -0
- /package/migrations/{0006_drop_legacy_conversation_messages.sql → 20260723042835_drop_legacy_conversation_messages/migration.sql} +0 -0
- /package/migrations/{0007_thick_sugar_man.sql → 20260723050612_thick_sugar_man/migration.sql} +0 -0
- /package/migrations/{0008_sticky_rage.sql → 20260727223822_sticky_rage/migration.sql} +0 -0
- /package/migrations/{0009_slippery_harrier.sql → 20260728033158_slippery_harrier/migration.sql} +0 -0
- /package/migrations/{0010_native_conversation_history.sql → 20260728040836_native_conversation_history/migration.sql} +0 -0
- /package/migrations/{0011_sour_golden_guardian.sql → 20260728204900_sour_golden_guardian/migration.sql} +0 -0
- /package/migrations/{0012_structured_conversation_events.sql → 20260730233332_structured_conversation_events/migration.sql} +0 -0
- /package/migrations/{0013_conversation_session_source.sql → 20260731164038_conversation_session_source/migration.sql} +0 -0
- /package/migrations/{0014_source_visibility.sql → 20260801230336_source_visibility/migration.sql} +0 -0
- /package/migrations/{0015_magical_ezekiel_stane.sql → 20260802023731_magical_ezekiel_stane/migration.sql} +0 -0
- /package/migrations/{0016_neat_the_anarchist.sql → 20260804015843_neat_the_anarchist/migration.sql} +0 -0
- /package/migrations/{0017_drop_paused_scheduled_tasks.sql → 20260804165952_drop_paused_scheduled_tasks/migration.sql} +0 -0
- /package/migrations/{0018_curvy_excalibur.sql → 20260804225613_curvy_excalibur/migration.sql} +0 -0
- /package/migrations/{0019_lowly_valkyrie.sql → 20260805174033_lowly_valkyrie/migration.sql} +0 -0
- /package/migrations/{0020_restrict_task_execution_kinds.sql → 20260805200301_restrict_task_execution_kinds/migration.sql} +0 -0
- /package/migrations/{0021_first_warhawk.sql → 20260806030729_first_warhawk/migration.sql} +0 -0
- /package/migrations/{0022_task_execution_status.sql → 20260807185200_task_execution_status/migration.sql} +0 -0
- /package/migrations/{0023_task_title_columns.sql → 20260808014743_task_title_columns/migration.sql} +0 -0
- /package/migrations/{0024_misty_typhoid_mary.sql → 20260809220421_misty_typhoid_mary/migration.sql} +0 -0
- /package/migrations/{0025_mcp_credential_subject.sql → 20260811193709_mcp_credential_subject/migration.sql} +0 -0
- /package/migrations/{0026_conversation_event_actor_and_participants.sql → 20260812032924_conversation_event_actor_and_participants/migration.sql} +0 -0
- /package/migrations/{0027_attachment_storage.sql → 20260812172418_attachment_storage/migration.sql} +0 -0
- /package/migrations/{0028_artifacts.sql → 20260813230732_artifacts/migration.sql} +0 -0
- /package/migrations/{0029_dizzy_barracuda.sql → 20260814062905_dizzy_barracuda/migration.sql} +0 -0
- /package/migrations/{0030_drop_workspace_repo_primary.sql → 20260814231353_drop_workspace_repo_primary/migration.sql} +0 -0
- /package/migrations/{0031_wild_phantom_reporter.sql → 20260815030100_wild_phantom_reporter/migration.sql} +0 -0
- /package/migrations/{0032_workspace_snapshots_table.sql → 20260817082233_workspace_snapshots_table/migration.sql} +0 -0
- /package/migrations/{0033_workspace_snapshot_active_build.sql → 20260818160339_workspace_snapshot_active_build/migration.sql} +0 -0
- /package/migrations/{0034_strong_randall.sql → 20260821180755_strong_randall/migration.sql} +0 -0
- /package/migrations/{0035_workspace_snapshot_size_bytes.sql → 20260823030308_workspace_snapshot_size_bytes/migration.sql} +0 -0
- /package/migrations/{0036_complex_rage.sql → 20260824190313_complex_rage/migration.sql} +0 -0
- /package/migrations/{0037_conversation_location.sql → 20260827233711_conversation_location/migration.sql} +0 -0
- /package/migrations/{0038_event_task_status.sql → 20260901224306_event_task_status/migration.sql} +0 -0
- /package/migrations/{0039_attachment_provider.sql → 20260904153232_attachment_provider/migration.sql} +0 -0
- /package/migrations/{0040_conversation_briefs.sql → 20260909111415_conversation_briefs/migration.sql} +0 -0
- /package/migrations/{0041_automation_outcomes_backfill.sql → 20260910144928_automation_outcomes_backfill/migration.sql} +0 -0
- /package/migrations/{0042_conversation_metrics.sql → 20260911184346_conversation_metrics/migration.sql} +0 -0
- /package/migrations/{0043_scheduled_automation_channel_destinations.sql → 20260921140842_scheduled_automation_channel_destinations/migration.sql} +0 -0
- /package/migrations/{0044_event_automation_channel_destinations.sql → 20260922221709_event_automation_channel_destinations/migration.sql} +0 -0
- /package/migrations/{0045_conversation_forks.sql → 20261001113455_conversation_forks/migration.sql} +0 -0
- /package/migrations/{0046_automation_versions.sql → 20261005161844_automation_versions/migration.sql} +0 -0
- /package/migrations/{0047_user_timezone.sql → 20261006152043_user_timezone/migration.sql} +0 -0
- /package/migrations/{0048_user_admin.sql → 20261008200858_user_admin/migration.sql} +0 -0
- /package/migrations/{0049_event_automation_status_reason.sql → 20261009145407_event_automation_status_reason/migration.sql} +0 -0
- /package/migrations/{0050_agent_invocation_parent_mailbox.sql → 20261013160816_agent_invocation_parent_mailbox/migration.sql} +0 -0
- /package/migrations/{0051_agent_invocation_parent_tool_call.sql → 20261013215020_agent_invocation_parent_tool_call/migration.sql} +0 -0
- /package/migrations/{0052_agent_invocation_title.sql → 20261014011138_agent_invocation_title/migration.sql} +0 -0
- /package/migrations/{0053_conversation_stopped_at.sql → 20261014211942_conversation_stopped_at/migration.sql} +0 -0
- /package/migrations/{0054_flowery_rage.sql → 20261015012820_flowery_rage/migration.sql} +0 -0
- /package/migrations/{0055_automations.sql → 20261017000924_automations/migration.sql} +0 -0
- /package/migrations/{0056_automation_runs.sql → 20261017134736_automation_runs/migration.sql} +0 -0
- /package/migrations/{0057_drop_legacy_automation_tables.sql → 20261017170250_drop_legacy_automation_tables/migration.sql} +0 -0
- /package/migrations/{0058_automation_creator_identity.sql → 20261018134754_automation_creator_identity/migration.sql} +0 -0
- /package/migrations/{0059_automation_run_version.sql → 20261023071954_automation_run_version/migration.sql} +0 -0
- /package/migrations/{0060_identity_signed_in_at.sql → 20261025233137_identity_signed_in_at/migration.sql} +0 -0
- /package/migrations/{0061_workspace_vcpus.sql → 20261027234315_workspace_vcpus/migration.sql} +0 -0
- /package/migrations/{0062_plugin_report_index.sql → 20261028124242_plugin_report_index/migration.sql} +0 -0
- /package/migrations/{0063_agent_invocation_type.sql → 20261028154230_agent_invocation_type/migration.sql} +0 -0
- /package/migrations/{0064_any_resource_event_triggers.sql → 20261030021803_any_resource_event_triggers/migration.sql} +0 -0
- /package/migrations/{0065_user_customization.sql → 20261030234309_user_customization/migration.sql} +0 -0
- /package/migrations/{0066_review_items.sql → 20261031020656_review_items/migration.sql} +0 -0
- /package/migrations/{0067_review_item_dedupe_tenant.sql → 20261031024151_review_item_dedupe_tenant/migration.sql} +0 -0
- /package/migrations/{0068_review_item_slack_cards.sql → 20261031024246_review_item_slack_cards/migration.sql} +0 -0
- /package/migrations/{0069_system_identity.sql → 20261031155308_system_identity/migration.sql} +0 -0
- /package/migrations/{0070_review_item_foreign_keys.sql → 20261101193952_review_item_foreign_keys/migration.sql} +0 -0
- /package/migrations/{0071_review_item_turn.sql → 20261102172751_review_item_turn/migration.sql} +0 -0
- /package/migrations/{0072_conversation_read_positions.sql → 20261102221411_conversation_read_positions/migration.sql} +0 -0
- /package/migrations/{0073_conversation_quick_question.sql → 20261104085028_conversation_quick_question/migration.sql} +0 -0
- /package/migrations/{0074_conversation_participant_pins.sql → 20261104145136_conversation_participant_pins/migration.sql} +0 -0
- /package/migrations/{0075_conversation_detail_version.sql → 20261104164429_conversation_detail_version/migration.sql} +0 -0
- /package/migrations/{0076_conversation_auto_archive.sql → 20261104172055_conversation_auto_archive/migration.sql} +0 -0
- /package/migrations/{0077_drop_agent_invocation_model_profile.sql → 20261105005443_drop_agent_invocation_model_profile/migration.sql} +0 -0
- /package/migrations/{0078_plugin_conversation_index.sql → 20261105043807_plugin_conversation_index/migration.sql} +0 -0
- /package/migrations/{0079_conversation_event_author_index.sql → 20261105051837_conversation_event_author_index/migration.sql} +0 -0
- /package/migrations/{0080_conversation_event_latest_message_indexes.sql → 20261105182854_conversation_event_latest_message_indexes/migration.sql} +0 -0
- /package/migrations/{0081_conversation_pin_position.sql → 20261106011443_conversation_pin_position/migration.sql} +0 -0
- /package/migrations/{0082_push_notifications.sql → 20261106095004_push_notifications/migration.sql} +0 -0
- /package/migrations/{0083_conversation_kind.sql → 20261106162740_conversation_kind/migration.sql} +0 -0
- /package/migrations/{0084_read_position_backfill.sql → 20261107002001_read_position_backfill/migration.sql} +0 -0
- /package/migrations/{0085_child_archived_at.sql → 20261107025209_child_archived_at/migration.sql} +0 -0
- /package/migrations/{0086_shared_archive.sql → 20261107035735_shared_archive/migration.sql} +0 -0
- /package/migrations/{0087_child_location.sql → 20261107215055_child_location/migration.sql} +0 -0
- /package/migrations/{0088_conversation_unsubscribe.sql → 20261108191927_conversation_unsubscribe/migration.sql} +0 -0
- /package/migrations/{0089_conversation_paused_status.sql → 20261109021618_conversation_paused_status/migration.sql} +0 -0
- /package/migrations/{0090_guardian_review_time_index.sql → 20261109111553_guardian_review_time_index/migration.sql} +0 -0
- /package/migrations/{0091_conversation_participant_unsubscribed_index.sql → 20261109173130_conversation_participant_unsubscribed_index/migration.sql} +0 -0
- /package/migrations/{0092_turn_metric_actor.sql → 20261109182006_turn_metric_actor/migration.sql} +0 -0
- /package/migrations/{0093_participant_root_actor_backfill.sql → 20261109202836_participant_root_actor_backfill/migration.sql} +0 -0
- /package/migrations/{0094_conversation_delivery_paused_at.sql → 20261109232640_conversation_delivery_paused_at/migration.sql} +0 -0
- /package/migrations/{0095_web_linked_slack_identity_repair.sql → 20261110120937_web_linked_slack_identity_repair/migration.sql} +0 -0
- /package/migrations/{0096_automation_task_kind.sql → 20261110175824_automation_task_kind/migration.sql} +0 -0
- /package/migrations/{0097_conversation_kind_automation.sql → 20261110210242_conversation_kind_automation/migration.sql} +0 -0
- /package/migrations/{0098_review_item_plugin_actions.sql → 20261110222632_review_item_plugin_actions/migration.sql} +0 -0
- /package/migrations/{0099_conversation_last_message_at.sql → 20261110225157_conversation_last_message_at/migration.sql} +0 -0
- /package/migrations/{0100_automation_task_kind_repair.sql → 20261111013351_automation_task_kind_repair/migration.sql} +0 -0
- /package/migrations/{0101_drop_legacy_columns.sql → 20261111163126_drop_legacy_columns/migration.sql} +0 -0
- /package/migrations/{0102_code_change_last_activity.sql → 20261111170150_code_change_last_activity/migration.sql} +0 -0
- /package/migrations/{0103_agent_invocation_fork.sql → 20261111191441_agent_invocation_fork/migration.sql} +0 -0
- /package/migrations/{0104_code_change_draft.sql → 20261112142841_code_change_draft/migration.sql} +0 -0
- /package/migrations/{0105_attachment_uploads.sql → 20261112202901_attachment_uploads/migration.sql} +0 -0
- /package/migrations/{0106_conversation_agent_config.sql → 20261112220407_conversation_agent_config/migration.sql} +0 -0
- /package/migrations/{0107_attachment_deferred_download.sql → 20261113081247_attachment_deferred_download/migration.sql} +0 -0
- /package/migrations/{0108_conversation_embeddings.sql → 20261113225551_conversation_embeddings/migration.sql} +0 -0
- /package/migrations/{0109_user_preferences.sql → 20261114213238_user_preferences/migration.sql} +0 -0
- /package/migrations/{0110_code_change_repository_state_index.sql → 20261114222527_code_change_repository_state_index/migration.sql} +0 -0
- /package/migrations/{0111_attachment_kinds.sql → 20261115172605_attachment_kinds/migration.sql} +0 -0
- /package/migrations/{0112_attachment_url_fill.sql → 20261115173004_attachment_url_fill/migration.sql} +0 -0
- /package/migrations/{0113_attachment_url_index.sql → 20261115180216_attachment_url_index/migration.sql} +0 -0
- /package/migrations/{0114_plan_items.sql → 20261116103700_plan_items/migration.sql} +0 -0
- /package/migrations/{0115_automation_creator_slack_index.sql → 20261117100100_automation_creator_slack_index/migration.sql} +0 -0
- /package/migrations/{0116_conversation_event_search.sql → 20261117132522_conversation_event_search/migration.sql} +0 -0
- /package/migrations/{0117_automation_last_run.sql → 20261117164007_automation_last_run/migration.sql} +0 -0
- /package/migrations/{0118_automation_last_run_index.sql → 20261117164047_automation_last_run_index/migration.sql} +0 -0
- /package/migrations/{0119_money_micro_usd.sql → 20261117210444_money_micro_usd/migration.sql} +0 -0
- /package/migrations/{0120_conversation_cost_micro_usd.sql → 20261117210505_conversation_cost_micro_usd/migration.sql} +0 -0
- /package/migrations/{0121_people_list_metric_index.sql → 20261118081416_people_list_metric_index/migration.sql} +0 -0
- /package/migrations/{0122_automation_rollout_repair.sql → 20261118095216_automation_rollout_repair/migration.sql} +0 -0
- /package/migrations/{0123_cache_warming_history_reset.sql → 20261118143948_cache_warming_history_reset/migration.sql} +0 -0
- /package/migrations/{0124_artifact_visibility.sql → 20261119040651_artifact_visibility/migration.sql} +0 -0
- /package/migrations/{0125_artifact_public_sha_index.sql → 20261119040715_artifact_public_sha_index/migration.sql} +0 -0
- /package/migrations/{0126_artifact_drop_public.sql → 20261119052706_artifact_drop_public/migration.sql} +0 -0
- /package/migrations/{0127_artifact_path.sql → 20261119053831_artifact_path/migration.sql} +0 -0
- /package/migrations/{0128_artifact_path_index.sql → 20261119053844_artifact_path_index/migration.sql} +0 -0
- /package/migrations/{0129_review_item_answered_index.sql → 20261119091949_review_item_answered_index/migration.sql} +0 -0
- /package/migrations/{0130_review_item_status_index.sql → 20261119100029_review_item_status_index/migration.sql} +0 -0
- /package/migrations/{0131_brief_outcome_status.sql → 20261119165607_brief_outcome_status/migration.sql} +0 -0
- /package/migrations/{0132_brief_outcome_status_backfill.sql → 20261119165622_brief_outcome_status_backfill/migration.sql} +0 -0
- /package/migrations/{0133_brief_created_at_index.sql → 20261119213716_brief_created_at_index/migration.sql} +0 -0
- /package/migrations/{0134_slack_person_search_index.sql → 20261119222456_slack_person_search_index/migration.sql} +0 -0
- /package/migrations/{0135_code_change_size.sql → 20261119225522_code_change_size/migration.sql} +0 -0
- /package/migrations/{0136_merge_conflict_notice_dismiss.sql → 20261119232253_merge_conflict_notice_dismiss/migration.sql} +0 -0
- /package/migrations/{0137_inbox_snoozes.sql → 20261119235649_inbox_snoozes/migration.sql} +0 -0
- /package/migrations/{0138_code_change_search_index.sql → 20261120093118_code_change_search_index/migration.sql} +0 -0
- /package/migrations/{0139_review_item_owner.sql → 20261120093452_review_item_owner/migration.sql} +0 -0
- /package/migrations/{0140_review_item_owner_index.sql → 20261120185654_review_item_owner_index/migration.sql} +0 -0
- /package/migrations/{0141_memory_core_adoption.sql → 20261120185754_memory_core_adoption/migration.sql} +0 -0
- /package/migrations/{0142_memory_core_indexes.sql → 20261120185854_memory_core_indexes/migration.sql} +0 -0
- /package/migrations/{0143_todos.sql → 20261120235226_todos/migration.sql} +0 -0
- /package/migrations/{0144_inbox_items.sql → 20261121082316_inbox_items/migration.sql} +0 -0
- /package/migrations/{0145_todo_changed_by_agent.sql → 20261121175651_todo_changed_by_agent/migration.sql} +0 -0
- /package/migrations/{0146_inbox_item_subject_title_parts.sql → 20261121183527_inbox_item_subject_title_parts/migration.sql} +0 -0
- /package/migrations/{0147_inbox_snooze_wake_reason.sql → 20261121194143_inbox_snooze_wake_reason/migration.sql} +0 -0
- /package/migrations/{0148_authorization_request_index.sql → 20261121222400_authorization_request_index/migration.sql} +0 -0
- /package/migrations/{0149_conversation_metadata.sql → 20261121225908_conversation_metadata/migration.sql} +0 -0
- /package/migrations/{0150_conversation_metadata_fill.sql → 20261121225910_conversation_metadata_fill/migration.sql} +0 -0
- /package/migrations/{0151_conversation_search_index.sql → 20261121225913_conversation_search_index/migration.sql} +0 -0
- /package/migrations/{0152_inbox_item_legacy_automation_keys.sql → 20261122022900_inbox_item_legacy_automation_keys/migration.sql} +0 -0
- /package/migrations/{0153_artifact_expiry.sql → 20261122024454_artifact_expiry/migration.sql} +0 -0
- /package/migrations/{0154_artifact_permanent_sha_index.sql → 20261122024455_artifact_permanent_sha_index/migration.sql} +0 -0
- /package/migrations/{0155_artifact_drop_public_sha_index.sql → 20261122024457_artifact_drop_public_sha_index/migration.sql} +0 -0
- /package/migrations/{0156_conversation_kind_lead.sql → 20261122024458_conversation_kind_lead/migration.sql} +0 -0
- /package/migrations/{0157_conversation_lead_actor_index.sql → 20261122024459_conversation_lead_actor_index/migration.sql} +0 -0
- /package/migrations/{0158_keep_legacy_archive_columns.sql → 20261122071549_keep_legacy_archive_columns/migration.sql} +0 -0
- /package/migrations/{0159_conversation_embeddings_fk_validate.sql → 20261122191400_conversation_embeddings_fk_validate/migration.sql} +0 -0
- /package/migrations/{0160_money_micro_usd_repair.sql → 20261122204325_money_micro_usd_repair/migration.sql} +0 -0
- /package/migrations/{0161_agent_config_backfill.sql → 20261122204326_agent_config_backfill/migration.sql} +0 -0
- /package/migrations/{0162_inbox_item_deliveries.sql → 20261122221456_inbox_item_deliveries/migration.sql} +0 -0
- /package/migrations/{0163_pg_trgm.sql → 20261123155735_pg_trgm/migration.sql} +0 -0
- /package/migrations/{0164_search_indexes.sql → 20261123155739_search_indexes/migration.sql} +0 -0
- /package/migrations/{0165_drop_legacy_archive_columns.sql → 20261123172647_drop_legacy_archive_columns/migration.sql} +0 -0
- /package/migrations/{0166_memory_prefix_index.sql → 20261123192506_memory_prefix_index/migration.sql} +0 -0
- /package/migrations/{0167_todo_search_indexes.sql → 20261123201740_todo_search_indexes/migration.sql} +0 -0
- /package/migrations/{0168_todo_inbox_items.sql → 20261123211505_todo_inbox_items/migration.sql} +0 -0
- /package/migrations/{0169_drop_code_urls.sql → 20261123214917_drop_code_urls/migration.sql} +0 -0
package/dist/api.js
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { C as
|
|
5
|
-
import {
|
|
6
|
-
import { A as
|
|
7
|
-
import {
|
|
8
|
-
import { C as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { a as listChildAgents } from "./markers-DUP8aBOp.js";
|
|
16
|
-
import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-fnmD2Ifb.js";
|
|
17
|
-
import { i as readLiveAttachment } from "./store-BuhF1QDm.js";
|
|
1
|
+
import { $ as getPlugins, $c as updateViewerDisplayName, $i as getVercelConversationWorkQueue, $u as cancelWatch, Aa as createPluginCache, Ac as inboxItemTodo, Ap as getAttachmentStorage, At as memoryDb, Au as slackPersonPredicate, Cc as canUserReadInboxItem, Cf as parseSlackChannelId, Ci as createPluginEmbedder, Cl as createConversationAccessReader, Cs as conversationStatusSql, Ds as conversationKindFromRow, Dt as contentVersion, Du as juniorSpaceMembers, Eo as getDashboardSettingsLink, Et as REVALIDATED_READ_PATHS, Fl as rootVisibleToViewer, Fr as getServiceAccountStatus, Ft as prefixMatch, Gc as findUserByEmail, Gn as create, I as escapeSlackMrkdwnText, Ic as itemNeedsUser, In as listWorkspaces, It as prefixRank, Iu as getEventCatalog, Jl as todoFuzzyTitle, Js as ownerConversationId, Kn as hash, L as formatSlackLink, Ll as isPublicConversation, Ln as listWorkspacesByRepository, Lt as rankSearchMatches, Mn as createWorkspace, Mt as parseTypedQuery, Mu as juniorUsers, N as loadConversationSlackTenantIds, Nc as isInboxItemForEveryone, Nn as deleteWorkspace, Nr as disconnectServiceAccount, Nt as fuzzyMatch, Nu as juniorDestinations, Oc as inboxItemReaderForUser, Ol as readableSlackTeamId, Ot as contentVersionHeaders, Pc as isOnlyAssignee, Pf as botConfig, Pn as getWorkspace, Pr as finishServiceAccountSignIn, Pt as fuzzyRank, Ql as inboxItemSearchDocument, Rn as updateWorkspace, Rr as serviceAccountPlugins, Rt as scoredSearchMatches, Ss as conversationIsActiveSql, St as isPausedBySlack, Tf as parseSlackTeamId, Tl as readConversationAccessFromSql, To as getDashboardPersonLink, Tu as juniorConversations, Ud as eventWatchUnavailable, Vs as getInboxItem, Ws as inboxItemsNeedingUserVersionQuery, Xc as readViewerAvatarUrl, Yl as todoSearchDocument, Yo as AutomationConflictError, Ys as searchInboxItems, Yu as isAgentResourceType, Zc as resolveViewerUser, Zl as inboxItemFuzzyTitle, _l as readCachedUserByEmail, _t as listPushSubscriptions, a as getDb, ac as clearInboxWakeReasons, au as juniorAutomations, bo as getDashboardConversationLink, bs as conversationRangeColumns, bt as savePushSubscription, bu as juniorCodeChanges, cc as inboxItemSnoozedBy, cd as listWatches, cp as withLock, cu as juniorAgentBindings, dc as settleInboxSnoozes, dt as readWebPushConfig, ep as readEnabledProviders, et as getRegistrations, eu as juniorInboxItemConversations, fc as snoozeInboxItems, ft as sendPushNotificationToUser, gs as microUsdToUsd, gt as deletePushSubscription, gu as juniorApiTokens, hs as microUsdSql, ht as resolveNotificationTimezone, hu as juniorConversationEvents, i as getConversationStore, ii as webActorUserIds, il as readUserAvatarUrls, ip as createCache, iu as automationSearchDocument, jc as inboxItemVisibleTo, jr as pluginCatalogRuntime, jt as searchTypedMemories, ju as slackPersonSearchDocument, kc as inboxItemReaderForUserInConversation, kt as revalidateContent, ku as juniorIdentities, la as createPluginAnnotations, lt as apiRoutePrefix, mc as unsnoozeInboxRow, mu as juniorConversationMetrics, nf as getStateAdapter, no as postSlackMessage, np as saveEnabledProviders, nu as juniorInboxItems, o as getSqlExecutor, of as credentialContextForActor, ou as juniorAutomationRuns, pc as snoozeTimerTrigger, ql as juniorTodos, rl as readAvatarFetch, rp as cacheKeyPrefix, ru as automationFuzzyTitle, sc as inboxItemInRow, ss as readAutomationTitlesByConversationId, tl as identityAvatarUrl, tp as readServedProviders, ua as listConversationAnnotations, uc as readViewerInboxSnoozes, uu as juniorConversationParticipants, vs as usdToMicroUsdUnbiased, vt as readNotificationSchedule, vu as codeChangeSearchDocument, wc as inboxItemForUser, wr as createUserTokenStore, ws as conversationTurnFailedSql, xc as canAnswerInboxItem, xi as workspaceRepoCheckoutPath, xs as conversationUsageCostExpr, xu as juniorCodeRepositories, yc as canActOnInboxItem, yi as SANDBOX_RUNTIME, ys as conversationAggregateColumns, yt as saveNotificationSchedule, yu as codeRepositorySearchDocument, zd as automationEventCatalog, zi as completeText, zn as WorkspaceValidationError, zr as startServiceAccountSignIn, zs as countInboxItemsNeedingUserBySubject } from "./db-DhzvUY23.js";
|
|
2
|
+
import { E as withSpan, N as normalizeIdentityEmail, _ as runBestEffort, h as logWarn, m as logInfo, p as logException, y as setSentryUser } from "./logging-B8KEJegM.js";
|
|
3
|
+
import { A as pauseConversationDelivery, Dt as emptyResponse, Gt as readViewerAutomationExecutions, Ht as ViewerTaskNotFoundError, It as activateViewerAutomationVersion, Jt as readViewerAutomationVersions, Kt as readViewerAutomationRuns, Lt as changeViewerAutomationLifecycle, M as AttachmentDownloadError, N as readAttachmentContent, O as canPauseConversationDelivery, Ot as jsonResponse, P as previewOriginBelongsTo, Rt as deleteViewerTask, Ut as collectionRowTitle, Vt as updateViewerAutomation, Yt as readViewerAutomations, Zt as AutomationEditError, cn as savingsTotals, dn as breakerStates, dt as reportConversationRead, fn as closeBreaker, ht as listOwnedWatches, j as resumeConversationDelivery, kt as throwApiError, ln as addStats, nn as SAVINGS_NAMESPACE, p as createInboxItemShow, pn as connectedState, qt as readViewerAutomationSummary, tn as viewerAutomationCollection, un as readStats, wt as inviteToConversation, yt as setSpaceArchive, zt as readViewerAutomationEdit } from "./agent-runner-Cr5Fhjf-.js";
|
|
4
|
+
import { A as automationVersionActivateSchema, At as spaceSchema, B as conversationAttachmentParamsSchema, C as automationRunListSchema, D as automationSchedulePreviewSchema, Dt as spaceListSchema, E as automationScheduleIntentSchema, Et as spaceListQuerySchema, Fn as automationTaskText, Ht as MAX_ATTACHMENT_BYTES, I as CONVERSATION_DETAIL_VERSION_HEADER, J as conversationParamsSchema, K as conversationEventPageSchema, L as CONVERSATION_VERSION_HEADER, M as automationVersionParamsSchema, Mt as updateSpaceBodySchema, O as automationSummarySchema, Ot as spaceParamsSchema, Pt as conversationReadPositionSchema, S as automationParamsSchema, Tt as createSpaceBodySchema, U as conversationDetailQuerySchema, V as conversationAttachmentQuerySchema, W as conversationDetailReportSchema, _ as automationLifecycleSchema, b as automationListQuerySchema, d as automationEditSchema, en as ScheduleIntentError, f as automationEventCatalogSchema, j as automationVersionListSchema, k as automationUpdateSchema, l as apiErrorSchema, mn as isOpenTodoStatus, n as INPUT_IMAGE_TYPES, p as automationExecutionListSchema, q as conversationEventsQuerySchema, r as detectImageMediaType, s as notificationScheduleSchema, t as INLINE_VIDEO_TYPES, tn as compileScheduleIntent, u as automationEditErrorSchema, wt as archiveSpaceBodySchema, y as automationListPageSchema } from "./media-BebquhET.js";
|
|
5
|
+
import { $ as userSearchQuerySchema, A as cacheHealthQuerySchema, At as connectionListSchema, B as serviceAccountParamsSchema, C as inboxSnoozeResourceQuerySchema, Cn as createConversationMessageBodySchema, Ct as activityHours$2, D as inboxSnoozeWakesClearSchema, Dt as pushSubscriptionBodySchema, E as inboxSnoozeSubjectSchema, Et as notificationSettingsSchema, F as cacheWarmingSavingsRefillResponseSchema, G as createPersonalTokenBodySchema, Gt as codeRepositoryReportSchema, H as startServiceAccountSignInResponseSchema, Ht as codePersonReportSchema, I as cacheWarmingSavingsReportSchema, Jt as personCodeQuerySchema, K as createdPersonalTokenSchema, L as closeCacheWarmingBreakerResponseSchema, Lt as codeChangeSearchQuerySchema, M as cacheWarmingBreakerListSchema, N as cacheWarmingBreakerParamsSchema, Nt as disconnectConnectionResponseSchema, O as gatewayProvidersSchema, Ot as pushSubscriptionDeleteBodySchema, P as cacheWarmingSavingsQuerySchema, Pt as startConnectionResponseSchema, Qt as todoStatusBodySchema, R as disconnectServiceAccountResponseSchema, Rt as codeChangeSearchReportSchema, S as inboxSnoozeCreateSchema, Sn as createConversationBodySchema, St as activityDays$1, T as inboxSnoozeSchema, Tn as forkConversationResponseSchema, U as searchQuerySchema, Ut as codeRepositoryParamsSchema, Vt as codeOverviewReportSchema, W as searchReportSchema, Wt as codeRepositoryQuerySchema, X as revokePersonalTokenResponseSchema, Xt as conversationTodosReportSchema, Y as personalTokenParamsSchema, Yt as conversationTodoSchema, Zt as todoParamsSchema, _ as inboxItemListSchema, _n as conversationCatchUpSchema, _t as spaceConfigurationSchema, a as statsReportSchema, an as continueConversationInSlackResponseSchema, at as avatarParamsSchema, b as inboxItemWaitingConversationsSchema, bn as createAttachmentUploadBodySchema, bt as locationDirectoryReportSchema, c as workspaceBodySchema, cn as attachObjectLinkResponseSchema, ct as peopleSearchReportSchema, dn as conversationStatsReportSchema, dt as personalSpendReportSchema, en as conversationWatchesReportSchema, et as userSearchReportSchema, f as workspaceSchema, ft as addSpaceMemberBodySchema, g as inboxItemListQuerySchema, gn as conversationCatchUpBodySchema, h as inboxItemCountSchema, hn as conversationDeliveryResponseSchema, ht as leadSchema, in as continueConversationInSlackBodySchema, it as actorProfileReportSchema, j as cacheHealthReportSchema, jt as connectionParamsSchema, k as updateGatewayProvidersBodySchema, kt as testNotificationResponseSchema, l as workspaceListSchema, ln as objectLinksQuerySchema, lt as personCardReportSchema, m as inboxItemCountQuerySchema, mn as conversationDeliveryBodySchema, n as versionsQuerySchema, p as inboxItemActionSchema, pn as conversationOutlineSchema, pt as spaceMemberListSchema, q as personalTokenListSchema, r as versionsSchema, rn as conversationChildAgentsReportSchema, rt as actorDirectoryReportSchema, s as deleteWorkspaceResponseSchema, sn as attachObjectLinkBodySchema, st as peopleSearchQuerySchema, tn as watchParamsSchema, u as workspaceParamsSchema, un as objectLinksReportSchema, ut as personParamsSchema, v as inboxItemParamsSchema, vn as attachmentUploadParamsSchema, w as inboxSnoozeResourceSchema, wn as forkConversationBodySchema, wt as activitySixHours$1, xn as acceptedConversationMessageSchema, xt as locationParamsSchema, y as inboxItemSchema, yn as attachmentUploadSchema, yt as locationDetailReportSchema, z as serviceAccountListSchema } from "./schema-z5-wA6N4.js";
|
|
6
|
+
import { A as conversationUnchangedDetailWithMailboxSchema, B as runtimeInfoReportSchema, M as steerConversationPendingMessagesResponseSchema, N as healthReportSchema, P as pluginOperationalReportFeedSchema, T as conversationDetailWithMailboxReportSchema, U as skillReportsSchema, V as skillDetailReportSchema, _ as reorderPinnedConversationsBodySchema, a as conversationInviteResponseSchema, i as conversationInviteBodySchema, j as steerConversationPendingMessagesBodySchema, k as conversationPendingMessagesReportSchema, n as conversationFeedSchema, t as conversationFeedQuerySchema, v as reorderPinnedConversationsResponseSchema, z as pluginsSchema } from "./conversation-feed-B84pMjHo.js";
|
|
7
|
+
import { Dt as listTodos, Ir as createPluginEgress, Mn as addConversationNote, Ot as setTodoStatusByUser, Pn as isExperimentalFeatureEnabled, St as saveUserCustomization, an as steerWebPendingMessages, gn as isAllowedDomain, kt as pushConversationInboxItemsNow, vn as parseEmail, xt as readUserCustomization } from "./session-stop-DponjDUZ.js";
|
|
8
|
+
import { C as joinSpace, D as readSpace, E as listSpaces, M as readLiveAttachment, O as updateSpace, S as createSpace, T as listSpaceMembers, _ as AttachmentUploadError, a as getSpaceLead, h as webActorFromUser, l as acceptsWebMessages, s as readSpaceLead, w as leaveSpace, x as writeAttachmentUpload, y as createAttachmentUpload } from "./turn-session-routing-D15orfwy.js";
|
|
9
|
+
import { $t as createViewerMcp, A as setConversationAutoArchiveOperation, C as archiveConversationOperation, Ct as readObjectLinkTypes, D as leaveConversationOperation, Dt as guardedFetch, Et as viewerCanViewPluginLink, F as apiOperationHandler, M as setConversationSubscriptionOperation, Mt as getProductionSlackAdapter, N as stopConversationOperation, O as pinConversationOperation, P as reorderPinnedConversations, Q as actOnInboxItem, Qt as readFirstHumanMessageTexts, St as readLinkObjectType, T as cancelQueuedMessagesOperation, Tt as resolveObjectLinks, X as resolveMentions, Y as requireConversationPendingMessages, Yt as resolvePersonLink, Z as InboxItemActionError, Zt as conversationSummaryFromStoredConversation, _ as readConversationEvents, _t as startSavingsRefill, a as listWaitingConversations, at as DEFAULT_USER_SETTINGS, b as requireWebMessageConversation, bt as readHealthReport, c as readConversationDetail, d as childAgentTotalsReport, en as IMAGE_WIDTHS, et as readInboxItemForUser, f as readConversationTreeMetricsFromSql, g as keepQuickQuestionForViewer, h as forkConversationForViewer, ht as readSavingsRefill, i as encodePageCursor, j as setConversationSpaceOperation, k as renameConversationOperation, l as readConversationTreeStates, m as readConversationDetailEtag, mt as scheduleInboxSnoozeTimer, n as readConversationFeed, o as listedConversation, ot as readUserSettings, p as conversationVersionsQuery, r as decodePageCursor, s as notLeadConversation, st as updateUserSettings, t as conversationFeedVersionQuery, tn as decodeImageId, u as readConversationAuxiliaryCostsFromSql, v as appendConversationMessageForViewer, w as archiveDoneConversationsOperation, wt as resolveObjectLinkNow, xt as OBJECT_LINK_TTL_MS, y as createConversationForViewer } from "./list-B0zsb5Cp.js";
|
|
10
|
+
import { a as transcriptEntriesFromReportEvents, c as linkedCodeProviders, f as readConversationLastEventSeq, l as readConversationEventPage, m as reportParentAgentInput, o as codeChangeUrl, s as codeRepositoryUrl } from "./task-runner-BJae4JwE.js";
|
|
11
|
+
import { t as runWithSlackInstallation } from "./adapter-context-Bref7aPI.js";
|
|
12
|
+
import { n as listChildAgents } from "./list-mkB_GU8R.js";
|
|
13
|
+
import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-DbQUFe_F.js";
|
|
14
|
+
import { o as readSlackAttachmentSource } from "./start-conversation-B-LIqqNi.js";
|
|
18
15
|
import { u as sentry_exports } from "./sentry-CPbZjomA.js";
|
|
19
|
-
import { K as credentialContextForActor, M as webActorUserIds, a as finishServiceAccountSignIn, i as disconnectServiceAccount, l as serviceAccountPlugins, o as getServiceAccountStatus, u as startServiceAccountSignIn } from "./registry-D6kS6xYH.js";
|
|
20
|
-
import { i as getStateAdapter } from "./adapter-JARQvoLw.js";
|
|
21
16
|
import { a as fillUtcSixHours, c as trailingUtcDayWindow, d as utcHourKey, i as fillUtcHours, l as trailingUtcHourWindow, n as HOUR_MS$3, o as startOfUtcHour, r as fillUtcDays, s as sumUtcHoursIntoSixHours, t as DAY_MS$3, u as trailingUtcSixHourWindow } from "./reporting-window-C4dbzDiR.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
17
|
+
import { a as isConnectableProvider, c as startConnection, i as disconnectConnection, o as listConnections, t as escapeHtml, u as htmlCallbackResponse } from "./html-B_12WjKT.js";
|
|
18
|
+
import { G as mapBounded, I as createPluginLogger } from "./transcript-CCi7323k.js";
|
|
19
|
+
import { D as listSpaceConfiguration } from "./job-runner-DO8nslyY.js";
|
|
25
20
|
import { n as userCustomizationSchema } from "./user-customization-B27StpVQ.js";
|
|
26
|
-
import {
|
|
27
|
-
import { t as getCachedSnapshot } from "./resolve-D8CPJcNK.js";
|
|
28
|
-
import { t as getVercelConversationWorkQueue } from "./vercel-queue-nL0Hq3hr.js";
|
|
21
|
+
import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-D5JVvv6A.js";
|
|
29
22
|
import { Hono } from "hono";
|
|
30
23
|
import * as z from "zod";
|
|
31
24
|
import path from "node:path";
|
|
@@ -661,7 +654,7 @@ async function readConversationOutline(conversationId, options = {}) {
|
|
|
661
654
|
}
|
|
662
655
|
/**
|
|
663
656
|
* Read the cut text of one role's messages in seq order. The
|
|
664
|
-
* `
|
|
657
|
+
* `message_role_seq_idx` index reads only these messages, in that order.
|
|
665
658
|
*/
|
|
666
659
|
function readMessages(conversationId, role, ...filters) {
|
|
667
660
|
return getDb().select({
|
|
@@ -703,13 +696,12 @@ async function steerConversationPendingMessagesForViewer(viewer, conversationId,
|
|
|
703
696
|
}
|
|
704
697
|
// src/api/cached-report.ts
|
|
705
698
|
const CACHE_NAMESPACE = "core";
|
|
706
|
-
const
|
|
707
|
-
const KEEP_MS = 36e5;
|
|
708
|
-
const RELOAD_WAIT_MS = 1e4;
|
|
699
|
+
const RELOAD_WAIT_MS = 3e4;
|
|
709
700
|
/**
|
|
710
701
|
* Create a reader for one report that is the same for every viewer. A cached
|
|
711
|
-
* report is served
|
|
712
|
-
* starts a background refresh.
|
|
702
|
+
* report is served until `keepMs` after its read. After `freshMs`, a request
|
|
703
|
+
* also starts a background refresh. With no cached report, one request reads
|
|
704
|
+
* it and the others wait for that read.
|
|
713
705
|
*/
|
|
714
706
|
function createCachedReport(source) {
|
|
715
707
|
const cachedSchema = z.object({
|
|
@@ -717,9 +709,9 @@ function createCachedReport(source) {
|
|
|
717
709
|
report: source.schema
|
|
718
710
|
}).strict();
|
|
719
711
|
const load = async () => ({
|
|
720
|
-
ttlMs:
|
|
712
|
+
ttlMs: source.keepMs,
|
|
721
713
|
value: {
|
|
722
|
-
refreshAtMs: Date.now() +
|
|
714
|
+
refreshAtMs: Date.now() + source.freshMs,
|
|
723
715
|
report: source.schema.parse(await source.read())
|
|
724
716
|
}
|
|
725
717
|
});
|
|
@@ -744,16 +736,11 @@ function createCachedReport(source) {
|
|
|
744
736
|
}, { "cache.key": [source.key] });
|
|
745
737
|
return ({ waitUntil }) => withSpan(source.key, "cache.get", {}, async (setSpanAttributes) => {
|
|
746
738
|
const state = getStateAdapter();
|
|
747
|
-
|
|
748
|
-
const
|
|
749
|
-
hit = false;
|
|
750
|
-
return load();
|
|
751
|
-
};
|
|
752
|
-
const parsed = cachedSchema.safeParse(await createCache(state, CACHE_NAMESPACE).getOrLoad(source.key, loadOnMiss));
|
|
739
|
+
const parsed = cachedSchema.safeParse(await createCache(state, CACHE_NAMESPACE).get(source.key));
|
|
740
|
+
const hit = parsed.success;
|
|
753
741
|
let cached;
|
|
754
742
|
if (parsed.success) cached = parsed.data;
|
|
755
743
|
else {
|
|
756
|
-
hit = false;
|
|
757
744
|
const reloaded = await reload(state, () => true, RELOAD_WAIT_MS);
|
|
758
745
|
cached = reloaded.acquired ? reloaded.value : (await load()).value;
|
|
759
746
|
}
|
|
@@ -763,7 +750,7 @@ function createCachedReport(source) {
|
|
|
763
750
|
"cache.hit": hit,
|
|
764
751
|
"cache.item_size": Buffer.byteLength(JSON.stringify(cached)),
|
|
765
752
|
"app.cache.stale": stale,
|
|
766
|
-
"app.cache.age_ms": now - (cached.refreshAtMs -
|
|
753
|
+
"app.cache.age_ms": now - (cached.refreshAtMs - source.freshMs)
|
|
767
754
|
});
|
|
768
755
|
if (stale) waitUntil(() => refresh(state));
|
|
769
756
|
return cached.report;
|
|
@@ -840,6 +827,235 @@ async function readConversationMetricBuckets(db, options) {
|
|
|
840
827
|
value: sql`sum(${juniorConversationMetrics.value})::double precision`
|
|
841
828
|
}).from(juniorConversationMetrics).where(and(gte(juniorConversationMetrics.occurredAt, options.start), lte(juniorConversationMetrics.occurredAt, options.end))).groupBy(date, juniorConversationMetrics.metric).orderBy(asc(date), asc(juniorConversationMetrics.metric));
|
|
842
829
|
}
|
|
830
|
+
const metrics$2 = juniorConversationMetrics;
|
|
831
|
+
/** Sum the values of one metric among grouped metric rows. */
|
|
832
|
+
function metricSum(metric) {
|
|
833
|
+
return sql`sum(${metrics$2.value}) FILTER (WHERE ${metrics$2.metric} = ${metric})`;
|
|
834
|
+
}
|
|
835
|
+
/** Sum the spend of Turn metric rows read straight from their table. */
|
|
836
|
+
const turnMetricColumns = { costMicroUsd: microUsdSql(metricSum("cost_micro_usd")) };
|
|
837
|
+
/** Root Conversation of a person's Turn, for status, location, and surface. */
|
|
838
|
+
const turnRoot = alias(juniorConversations, "person_turn_root");
|
|
839
|
+
/** Root of a Conversation row: itself when it has no root. */
|
|
840
|
+
const conversationRootId = sql`coalesce(
|
|
841
|
+
${juniorConversations.rootConversationId},
|
|
842
|
+
${juniorConversations.conversationId}
|
|
843
|
+
)`;
|
|
844
|
+
/**
|
|
845
|
+
* Read one row per verified person and root Conversation where they ran a
|
|
846
|
+
* Turn, over all time: the Turn range and the duration and token totals.
|
|
847
|
+
*
|
|
848
|
+
* The person and metric filters apply to the metric rows, and the rows are
|
|
849
|
+
* grouped before any join. Every Run writes a `duration_ms` row, so these
|
|
850
|
+
* two metrics mark every Turn.
|
|
851
|
+
*/
|
|
852
|
+
function personRoots(email) {
|
|
853
|
+
const verifiedIdentities = getDb().select({ id: juniorIdentities.id }).from(juniorIdentities).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(verifiedActorWhere(email));
|
|
854
|
+
const conversations = getDb().select({
|
|
855
|
+
identityId: sql`${metrics$2.actorIdentityId}`.as("turn_identity_id"),
|
|
856
|
+
conversationId: sql`${metrics$2.conversationId}`.as("turn_conversation_id"),
|
|
857
|
+
firstAt: sql`min(${metrics$2.occurredAt})`.as("turn_first_at"),
|
|
858
|
+
lastAt: sql`max(${metrics$2.occurredAt})`.as("turn_last_at"),
|
|
859
|
+
durationMs: metricSum("duration_ms").as("turn_duration_ms"),
|
|
860
|
+
tokens: metricSum("total_tokens").as("turn_tokens")
|
|
861
|
+
}).from(metrics$2).where(and(inArray(metrics$2.actorIdentityId, verifiedIdentities), inArray(metrics$2.metric, ["duration_ms", "total_tokens"]))).groupBy(metrics$2.actorIdentityId, metrics$2.conversationId).as("person_conversation_turns");
|
|
862
|
+
return getDb().select({
|
|
863
|
+
userId: sql`${juniorIdentities.userId}`.as("root_user_id"),
|
|
864
|
+
rootConversationId: conversationRootId.as("person_root_id"),
|
|
865
|
+
firstAt: sql`min(${conversations.firstAt})`.as("root_first_at"),
|
|
866
|
+
lastAt: sql`max(${conversations.lastAt})`.as("root_last_at"),
|
|
867
|
+
durationMs: sql`sum(${conversations.durationMs})`.as("root_duration_ms"),
|
|
868
|
+
tokens: sql`sum(${conversations.tokens})`.as("root_tokens"),
|
|
869
|
+
slackUserId: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END)`.as("root_slack_user_id"),
|
|
870
|
+
slackUserName: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END)`.as("root_slack_user_name")
|
|
871
|
+
}).from(conversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, conversations.identityId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, conversations.conversationId)).groupBy(juniorIdentities.userId, conversationRootId).as("person_roots");
|
|
872
|
+
}
|
|
873
|
+
/** Join a person's roots to the root Conversation rows. */
|
|
874
|
+
function personRootJoin(roots) {
|
|
875
|
+
return eq(turnRoot.conversationId, roots.rootConversationId);
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Aggregate rows from {@link personRoots} joined to {@link turnRoot}. A
|
|
879
|
+
* Conversation counts once for each person who ran a Turn in it, and child
|
|
880
|
+
* Conversation Turns count for the root. Each row is one root of one person,
|
|
881
|
+
* so plain counts need no DISTINCT. Active and failed read the root's current
|
|
882
|
+
* status.
|
|
883
|
+
*/
|
|
884
|
+
function rootAggregateColumns(roots) {
|
|
885
|
+
return {
|
|
886
|
+
active: sql`(count(*) FILTER (WHERE ${conversationIsActiveSql(turnRoot)}))::integer`,
|
|
887
|
+
conversations: sql`count(*)::integer`,
|
|
888
|
+
durationMs: sql`COALESCE(sum(${roots.durationMs}), 0)::double precision`,
|
|
889
|
+
failed: sql`(count(*) FILTER (WHERE ${turnRoot.stoppedAt} IS NULL AND ${conversationTurnFailedSql(turnRoot)}))::integer`,
|
|
890
|
+
tokens: sql`sum(${roots.tokens})::double precision`
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Count the UTC days on which the grouped person ran a Turn. A correlated
|
|
895
|
+
* subquery runs once per person through the actor index, so a bad row
|
|
896
|
+
* estimate cannot make Postgres repeat it once per root.
|
|
897
|
+
*/
|
|
898
|
+
function personActiveDays() {
|
|
899
|
+
const days = getDb().selectDistinct({ day: sql`(${metrics$2.occurredAt} AT TIME ZONE 'UTC')::date`.as("turn_day") }).from(metrics$2).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics$2.actorIdentityId)).where(and(eq(juniorIdentities.userId, juniorUsers.id), eq(juniorIdentities.kind, "user"), eq(juniorIdentities.emailVerified, true))).as("person_turn_days");
|
|
900
|
+
return sql`(${getDb().select({ days: sql`count(*)` }).from(days)})::integer`;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Select the identity, Turn range, and totals of one person from roots
|
|
904
|
+
* grouped by person and joined to {@link juniorUsers}.
|
|
905
|
+
*/
|
|
906
|
+
function personTotalColumns(roots) {
|
|
907
|
+
return {
|
|
908
|
+
...rootAggregateColumns(roots),
|
|
909
|
+
activeDays: personActiveDays(),
|
|
910
|
+
email: sql`${juniorUsers.primaryEmailNormalized}`,
|
|
911
|
+
firstSeenAt: sql`min(${roots.firstAt})`.mapWith(metrics$2.occurredAt),
|
|
912
|
+
fullName: juniorUsers.displayName,
|
|
913
|
+
lastSeenAt: sql`max(${roots.lastAt})`.mapWith(metrics$2.occurredAt),
|
|
914
|
+
slackUserId: sql`max(${roots.slackUserId})`,
|
|
915
|
+
slackUserName: sql`max(${roots.slackUserName})`
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
/** Normalize emails before matching people API rows. */
|
|
919
|
+
function normalizeEmail$1(email) {
|
|
920
|
+
return email?.trim().toLowerCase() || void 0;
|
|
921
|
+
}
|
|
922
|
+
/** Build a zeroed totals object for people API aggregations. */
|
|
923
|
+
function emptyTotals() {
|
|
924
|
+
return {
|
|
925
|
+
active: 0,
|
|
926
|
+
activeDays: 0,
|
|
927
|
+
conversations: 0,
|
|
928
|
+
durationMs: 0,
|
|
929
|
+
failed: 0
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
/** Build a zeroed activity day for the people profile window. */
|
|
933
|
+
function emptyActivityDay(date) {
|
|
934
|
+
return {
|
|
935
|
+
active: 0,
|
|
936
|
+
conversations: 0,
|
|
937
|
+
date,
|
|
938
|
+
durationMs: 0,
|
|
939
|
+
failed: 0
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
/** Fill the fixed people profile activity window from sparse day totals. */
|
|
943
|
+
function activityDays(days, nowMs) {
|
|
944
|
+
return fillUtcDays({
|
|
945
|
+
count: 365,
|
|
946
|
+
empty: emptyActivityDay,
|
|
947
|
+
nowMs,
|
|
948
|
+
rows: days
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Fill the trailing 7-day people activity hour window from known hour totals.
|
|
953
|
+
* 24h charts use the last 24 points. 7d charts sum hours into 6-hour buckets.
|
|
954
|
+
*/
|
|
955
|
+
function activityHours$1(hours, nowMs) {
|
|
956
|
+
return fillUtcHours({
|
|
957
|
+
count: 168,
|
|
958
|
+
empty: emptyActivityDay,
|
|
959
|
+
nowMs,
|
|
960
|
+
rows: hours
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Fill trailing 6-hour people activity buckets from hour keys or hour rows.
|
|
965
|
+
* Hour keys must be summed into 6-hour keys first.
|
|
966
|
+
*/
|
|
967
|
+
function activitySixHours(hours, nowMs) {
|
|
968
|
+
const series = hours instanceof Map ? activityHours$1(hours, nowMs) : [...hours];
|
|
969
|
+
return sumUtcHoursIntoSixHours({
|
|
970
|
+
empty: emptyActivityDay,
|
|
971
|
+
hours: series,
|
|
972
|
+
nowMs
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
/** Return deterministic stats rows for people API responses. */
|
|
976
|
+
function statsItems(map) {
|
|
977
|
+
return [...map.values()].sort((left, right) => right.conversations - left.conversations || right.durationMs - left.durationMs || left.label.localeCompare(right.label));
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Build the verified person actor predicate shared by People aggregate and
|
|
981
|
+
* recent-row queries.
|
|
982
|
+
*
|
|
983
|
+
* Any provider counts, so Slack and dashboard (web) Conversations roll up to
|
|
984
|
+
* the same person. System identities never count.
|
|
985
|
+
*/
|
|
986
|
+
function verifiedActorWhere(email) {
|
|
987
|
+
const normalizedEmail = normalizeEmail$1(email);
|
|
988
|
+
return and(eq(juniorIdentities.kind, "user"), eq(juniorIdentities.emailVerified, true), sql`${juniorUsers.primaryEmailNormalized} IS NOT NULL`, normalizedEmail ? eq(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0);
|
|
989
|
+
}
|
|
990
|
+
/** Read the Conversations where a person ran a Turn, by their last Turn. */
|
|
991
|
+
async function recentActorRows(email) {
|
|
992
|
+
const lastTurns = getDb().select({
|
|
993
|
+
conversationId: sql`${metrics$2.conversationId}`.as("turn_conversation_id"),
|
|
994
|
+
lastTurnAt: sql`max(${metrics$2.occurredAt})`.as("last_turn_at")
|
|
995
|
+
}).from(metrics$2).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics$2.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(verifiedActorWhere(email), eq(metrics$2.metric, "duration_ms"))).groupBy(metrics$2.conversationId).as("person_last_turns");
|
|
996
|
+
return getDb().select({
|
|
997
|
+
channelName: juniorConversations.channelName,
|
|
998
|
+
conversationId: juniorConversations.conversationId,
|
|
999
|
+
createdAt: juniorConversations.createdAt,
|
|
1000
|
+
destinationId: juniorDestinations.id,
|
|
1001
|
+
durationMs: juniorConversations.durationMs,
|
|
1002
|
+
email: juniorUsers.primaryEmailNormalized,
|
|
1003
|
+
executionStatus: juniorConversations.executionStatus,
|
|
1004
|
+
executionUpdatedAt: juniorConversations.executionUpdatedAt,
|
|
1005
|
+
fullName: juniorUsers.displayName,
|
|
1006
|
+
kind: juniorConversations.kind,
|
|
1007
|
+
parentConversationId: juniorConversations.parentConversationId,
|
|
1008
|
+
archivedAt: juniorConversations.archivedAt,
|
|
1009
|
+
handle: sql`CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END`,
|
|
1010
|
+
lastActivityAt: juniorConversations.lastActivityAt,
|
|
1011
|
+
providerSubjectId: sql`CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END`,
|
|
1012
|
+
source: juniorConversations.source,
|
|
1013
|
+
status: conversationStatusSql(juniorConversations),
|
|
1014
|
+
title: juniorConversations.title,
|
|
1015
|
+
updatedAt: juniorConversations.updatedAt,
|
|
1016
|
+
usage: juniorConversations.usage
|
|
1017
|
+
}).from(lastTurns).innerJoin(juniorConversations, eq(juniorConversations.conversationId, lastTurns.conversationId)).leftJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(juniorDestinations, eq(juniorDestinations.id, juniorConversations.destinationId)).where(notLeadConversation()).orderBy(desc(lastTurns.lastTurnAt), asc(juniorConversations.conversationId)).limit(25);
|
|
1018
|
+
}
|
|
1019
|
+
// src/api/conversations/person-spend-days.ts
|
|
1020
|
+
const metrics$1 = juniorConversationMetrics;
|
|
1021
|
+
/**
|
|
1022
|
+
* Read model spend per UTC day, split between verified people and Turns with
|
|
1023
|
+
* no verified person, with the count of active people and the median spend
|
|
1024
|
+
* of one person. A person is one Junior user, so their Slack and web
|
|
1025
|
+
* Identities count once. Every Run writes a `duration_ms` row, so a person
|
|
1026
|
+
* with a Turn but no cost row counts with zero spend.
|
|
1027
|
+
*
|
|
1028
|
+
* Metric rows are grouped by day and Identity before any join, so the joins
|
|
1029
|
+
* read one row per Identity and day.
|
|
1030
|
+
*/
|
|
1031
|
+
async function readPersonSpendDays(db, options) {
|
|
1032
|
+
const day = sql`date_trunc('day', ${metrics$1.occurredAt} at time zone 'UTC')`;
|
|
1033
|
+
const identityDays = db.select({
|
|
1034
|
+
date: day.as("identity_day_date"),
|
|
1035
|
+
identityId: sql`${metrics$1.actorIdentityId}`.as("identity_day_identity_id"),
|
|
1036
|
+
costMicroUsd: sql`coalesce(sum(${metrics$1.value}) FILTER (
|
|
1037
|
+
WHERE ${metrics$1.metric} = 'cost_micro_usd'
|
|
1038
|
+
), 0)`.as("identity_day_micro_usd")
|
|
1039
|
+
}).from(metrics$1).where(and(inArray(metrics$1.metric, ["duration_ms", "cost_micro_usd"]), gte(metrics$1.occurredAt, options.start), lte(metrics$1.occurredAt, options.end))).groupBy(day, metrics$1.actorIdentityId).as("person_identity_days");
|
|
1040
|
+
const identityPeople = db.select({
|
|
1041
|
+
date: sql`${identityDays.date}`.as("identity_person_date"),
|
|
1042
|
+
userId: sql`CASE WHEN ${verifiedActorWhere()} THEN ${juniorUsers.id} END`.as("identity_person_user_id"),
|
|
1043
|
+
costMicroUsd: sql`${identityDays.costMicroUsd}`.as("identity_person_micro_usd")
|
|
1044
|
+
}).from(identityDays).leftJoin(juniorIdentities, eq(juniorIdentities.id, identityDays.identityId)).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).as("person_identity_people");
|
|
1045
|
+
const personDays = db.select({
|
|
1046
|
+
date: sql`${identityPeople.date}`.as("person_day_date"),
|
|
1047
|
+
userId: sql`${identityPeople.userId}`.as("person_day_user_id"),
|
|
1048
|
+
costMicroUsd: sql`sum(${identityPeople.costMicroUsd})`.as("person_day_micro_usd")
|
|
1049
|
+
}).from(identityPeople).groupBy(identityPeople.date, identityPeople.userId).as("person_days");
|
|
1050
|
+
const person = sql`${personDays.userId} IS NOT NULL`;
|
|
1051
|
+
return await db.select({
|
|
1052
|
+
date: sql`to_char(${personDays.date}, 'YYYY-MM-DD')`,
|
|
1053
|
+
medianPersonCostMicroUsd: sql`(percentile_cont(0.5) WITHIN GROUP (ORDER BY ${personDays.costMicroUsd}) FILTER (WHERE ${person}))::double precision`,
|
|
1054
|
+
people: sql`(count(*) FILTER (WHERE ${person}))::integer`,
|
|
1055
|
+
personCostMicroUsd: sql`coalesce(sum(${personDays.costMicroUsd}) FILTER (WHERE ${person}), 0)::double precision`,
|
|
1056
|
+
unattributedCostMicroUsd: sql`coalesce(sum(${personDays.costMicroUsd}) FILTER (WHERE NOT ${person}), 0)::double precision`
|
|
1057
|
+
}).from(personDays).groupBy(personDays.date);
|
|
1058
|
+
}
|
|
843
1059
|
// src/api/conversations/outcome-buckets.ts
|
|
844
1060
|
const changes = juniorCodeChanges;
|
|
845
1061
|
const linked$1 = alias(juniorConversations, "linked");
|
|
@@ -947,6 +1163,7 @@ async function readWindowMerges(db, options) {
|
|
|
947
1163
|
}] : []);
|
|
948
1164
|
}
|
|
949
1165
|
// src/api/conversations/stats.query.ts
|
|
1166
|
+
const WINDOW_DAYS$1 = 90;
|
|
950
1167
|
function addUsd(current, next) {
|
|
951
1168
|
return Math.round(((current ?? 0) + next) * 0xe8d4a51000) / 0xe8d4a51000;
|
|
952
1169
|
}
|
|
@@ -1119,6 +1336,23 @@ function guardianStats(dayRows, hourRows, endMs) {
|
|
|
1119
1336
|
...costUsd !== void 0 ? { costUsd } : void 0
|
|
1120
1337
|
};
|
|
1121
1338
|
}
|
|
1339
|
+
function personSpendDay(row) {
|
|
1340
|
+
return {
|
|
1341
|
+
date: row.date,
|
|
1342
|
+
people: row.people,
|
|
1343
|
+
personCostUsd: microUsdToUsd(row.personCostMicroUsd),
|
|
1344
|
+
unattributedCostUsd: microUsdToUsd(row.unattributedCostMicroUsd),
|
|
1345
|
+
...row.medianPersonCostMicroUsd !== null ? { medianPersonCostUsd: microUsdToUsd(row.medianPersonCostMicroUsd) } : void 0
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
function emptyPersonSpendDay(date) {
|
|
1349
|
+
return {
|
|
1350
|
+
date,
|
|
1351
|
+
people: 0,
|
|
1352
|
+
personCostUsd: 0,
|
|
1353
|
+
unattributedCostUsd: 0
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1122
1356
|
/** Sum hour rows into UTC day rows, one per day and `key`. */
|
|
1123
1357
|
function sumHoursIntoDays(hours, add, key = () => "") {
|
|
1124
1358
|
const days = /* @__PURE__ */ new Map();
|
|
@@ -1135,7 +1369,7 @@ function sumHoursIntoDays(hours, add, key = () => "") {
|
|
|
1135
1369
|
return [...days.values()];
|
|
1136
1370
|
}
|
|
1137
1371
|
/** Count the window roots that have a tree, per UTC hour of last activity. */
|
|
1138
|
-
function activityHours
|
|
1372
|
+
function activityHours(roots) {
|
|
1139
1373
|
const hours = /* @__PURE__ */ new Map();
|
|
1140
1374
|
for (const root of roots) {
|
|
1141
1375
|
if (root.treeConversations === 0) continue;
|
|
@@ -1154,7 +1388,7 @@ async function readConversationStatsFromSql() {
|
|
|
1154
1388
|
const nowMs = Date.now();
|
|
1155
1389
|
const { end, start } = statsWindow(nowMs);
|
|
1156
1390
|
const db = getDb();
|
|
1157
|
-
const [windowRoots, metrics, merges, guardian] = await Promise.all([
|
|
1391
|
+
const [windowRoots, metrics, merges, guardian, personSpend] = await Promise.all([
|
|
1158
1392
|
readWindowRoots(db, {
|
|
1159
1393
|
start,
|
|
1160
1394
|
end
|
|
@@ -1170,9 +1404,13 @@ async function readConversationStatsFromSql() {
|
|
|
1170
1404
|
readGuardianHours(db, getStateAdapter(), {
|
|
1171
1405
|
start,
|
|
1172
1406
|
end
|
|
1407
|
+
}),
|
|
1408
|
+
readPersonSpendDays(db, {
|
|
1409
|
+
start,
|
|
1410
|
+
end
|
|
1173
1411
|
})
|
|
1174
1412
|
]);
|
|
1175
|
-
const activity = activityHours
|
|
1413
|
+
const activity = activityHours(windowRoots);
|
|
1176
1414
|
const outcomes = outcomeBuckets({ merges });
|
|
1177
1415
|
const hours = metricHours(applyMetricBuckets(activity, metrics, outcomes), nowMs);
|
|
1178
1416
|
return {
|
|
@@ -1194,6 +1432,12 @@ async function readConversationStatsFromSql() {
|
|
|
1194
1432
|
})), nowMs),
|
|
1195
1433
|
metricHours: hours,
|
|
1196
1434
|
metricSixHours: sumMetricHoursIntoSixHours(hours, nowMs),
|
|
1435
|
+
personSpendDays: fillUtcDays({
|
|
1436
|
+
count: WINDOW_DAYS$1,
|
|
1437
|
+
empty: emptyPersonSpendDay,
|
|
1438
|
+
nowMs,
|
|
1439
|
+
rows: new Map(personSpend.map((row) => [row.date, personSpendDay(row)]))
|
|
1440
|
+
}),
|
|
1197
1441
|
source: "conversation_index",
|
|
1198
1442
|
windowEnd: end.toISOString(),
|
|
1199
1443
|
windowStart: start.toISOString()
|
|
@@ -1202,6 +1446,8 @@ async function readConversationStatsFromSql() {
|
|
|
1202
1446
|
// src/api/conversations/stats.ts
|
|
1203
1447
|
/** Load aggregate conversation stats from durable SQL records. */
|
|
1204
1448
|
const readConversationStats = createCachedReport({
|
|
1449
|
+
freshMs: 3e5,
|
|
1450
|
+
keepMs: 36e5,
|
|
1205
1451
|
key: "conversation-stats",
|
|
1206
1452
|
read: readConversationStatsFromSql,
|
|
1207
1453
|
refreshFailedEvent: "conversation_stats.refresh.failed",
|
|
@@ -1330,7 +1576,7 @@ function createConversationRoutes(options) {
|
|
|
1330
1576
|
const app = new Hono();
|
|
1331
1577
|
const messageBodyLimit = bodyLimit({ maxSize: 262144 });
|
|
1332
1578
|
app.get("/", validateRequest("query", conversationFeedQuerySchema, "Invalid query parameters."), async (context) => {
|
|
1333
|
-
const { actorEmail, codeRepositoryId, cursor, include, q, status } = context.req.valid("query");
|
|
1579
|
+
const { actorEmail, codeRepositoryId, cursor, include, q, spaceId, status } = context.req.valid("query");
|
|
1334
1580
|
const viewer = context.get("viewer");
|
|
1335
1581
|
let waitingRows = 0;
|
|
1336
1582
|
const feed = await readConversationFeed({
|
|
@@ -1342,6 +1588,7 @@ function createConversationRoutes(options) {
|
|
|
1342
1588
|
waitingRows = count;
|
|
1343
1589
|
},
|
|
1344
1590
|
...q ? { q } : void 0,
|
|
1591
|
+
...spaceId ? { spaceId } : void 0,
|
|
1345
1592
|
status,
|
|
1346
1593
|
...viewer ? { viewer } : void 0
|
|
1347
1594
|
});
|
|
@@ -1385,8 +1632,10 @@ function createConversationRoutes(options) {
|
|
|
1385
1632
|
app.post("/:conversationId/forks", requireViewer, bodyLimit({ maxSize: 32768 }), validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", forkConversationBodySchema, "Invalid request body."), async (context) => jsonResponse(forkConversationResponseSchema, await forkConversationForViewer(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
|
|
1386
1633
|
app.post("/:conversationId/quick-question/keep", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), async (context) => jsonResponse(forkConversationResponseSchema, await keepQuickQuestionForViewer(context.get("viewer"), context.req.valid("param").conversationId)));
|
|
1387
1634
|
app.patch("/:conversationId/archive", requireViewer, apiOperationHandler(archiveConversationOperation, options));
|
|
1635
|
+
app.put("/:conversationId/space", requireViewer, apiOperationHandler(setConversationSpaceOperation, options));
|
|
1388
1636
|
app.patch("/:conversationId/pin", requireViewer, apiOperationHandler(pinConversationOperation, options));
|
|
1389
1637
|
app.patch("/:conversationId/delivery", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationDeliveryBodySchema, "Invalid request body."), async (context) => jsonResponse(conversationDeliveryResponseSchema, await setConversationDeliveryForViewer(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
|
|
1638
|
+
app.post("/:conversationId/leave", requireViewer, apiOperationHandler(leaveConversationOperation, options));
|
|
1390
1639
|
app.patch("/:conversationId/subscription", requireViewer, apiOperationHandler(setConversationSubscriptionOperation, options));
|
|
1391
1640
|
app.post("/:conversationId/invites", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationInviteBodySchema, "Invalid request body."), async (context) => jsonResponse(conversationInviteResponseSchema, await inviteToConversation(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
|
|
1392
1641
|
app.patch("/:conversationId/title", requireViewer, apiOperationHandler(renameConversationOperation, options));
|
|
@@ -1521,6 +1770,55 @@ function createConversationRoutes(options) {
|
|
|
1521
1770
|
});
|
|
1522
1771
|
return app;
|
|
1523
1772
|
}
|
|
1773
|
+
// src/api/code/stacks.ts
|
|
1774
|
+
/**
|
|
1775
|
+
* Read the stack of each code change: the Automation that ran its first
|
|
1776
|
+
* Conversation's root, or else that root. The first Conversation is the
|
|
1777
|
+
* earliest created one, since `conversation_ids` is sorted by id. A change
|
|
1778
|
+
* whose root the viewer may not read has no stack, so its title stays
|
|
1779
|
+
* hidden.
|
|
1780
|
+
*/
|
|
1781
|
+
async function readCodeChangeStacks(db, changes, viewer) {
|
|
1782
|
+
const linkedIds = [...new Set(changes.flatMap((change) => change.conversationIds))];
|
|
1783
|
+
const createdAt = new Map((linkedIds.length === 0 ? [] : await db.select({
|
|
1784
|
+
conversationId: juniorConversations.conversationId,
|
|
1785
|
+
createdAt: juniorConversations.createdAt
|
|
1786
|
+
}).from(juniorConversations).where(inArray(juniorConversations.conversationId, linkedIds))).map((row) => [row.conversationId, row.createdAt.getTime()]));
|
|
1787
|
+
const firstIds = new Map(changes.flatMap((change) => {
|
|
1788
|
+
const [first] = change.conversationIds.filter((id) => createdAt.has(id)).sort((a, b) => createdAt.get(a) - createdAt.get(b) || a.localeCompare(b));
|
|
1789
|
+
return first ? [[change.id, first]] : [];
|
|
1790
|
+
}));
|
|
1791
|
+
const access = await readConversationAccessFromSql(db, [...new Set(firstIds.values())], viewer);
|
|
1792
|
+
const rootIds = [...new Set([...access.values()].flatMap((entry) => entry.canViewPrivateContent && entry.rootConversationId ? [entry.rootConversationId] : []))];
|
|
1793
|
+
const roots = rootIds.length === 0 ? [] : await db.select({
|
|
1794
|
+
automationId: juniorAutomations.id,
|
|
1795
|
+
automationKind: juniorAutomations.kind,
|
|
1796
|
+
automationTask: sql`${juniorAutomations.record}->'task'`,
|
|
1797
|
+
automationTitle: juniorAutomations.title,
|
|
1798
|
+
conversationId: juniorConversations.conversationId,
|
|
1799
|
+
title: juniorConversations.title
|
|
1800
|
+
}).from(juniorConversations).leftJoin(juniorAutomationRuns, eq(juniorAutomationRuns.conversationId, juniorConversations.conversationId)).leftJoin(juniorAutomations, eq(juniorAutomations.id, juniorAutomationRuns.automationId)).where(inArray(juniorConversations.conversationId, rootIds));
|
|
1801
|
+
const stackOfRoot = new Map(roots.map((root) => [root.conversationId, root.automationId && root.automationKind ? {
|
|
1802
|
+
id: root.automationId,
|
|
1803
|
+
kind: "automation",
|
|
1804
|
+
title: collectionRowTitle({
|
|
1805
|
+
kind: root.automationKind,
|
|
1806
|
+
task: root.automationTask,
|
|
1807
|
+
title: root.automationTitle
|
|
1808
|
+
})
|
|
1809
|
+
} : {
|
|
1810
|
+
id: root.conversationId,
|
|
1811
|
+
kind: "conversation",
|
|
1812
|
+
...root.title ? { title: root.title } : void 0
|
|
1813
|
+
}]));
|
|
1814
|
+
const stacks = /* @__PURE__ */ new Map();
|
|
1815
|
+
for (const [changeId, conversationId] of firstIds) {
|
|
1816
|
+
const entry = access.get(conversationId);
|
|
1817
|
+
const stack = entry?.canViewPrivateContent && entry.rootConversationId ? stackOfRoot.get(entry.rootConversationId) : void 0;
|
|
1818
|
+
if (stack) stacks.set(changeId, stack);
|
|
1819
|
+
}
|
|
1820
|
+
return stacks;
|
|
1821
|
+
}
|
|
1524
1822
|
// src/api/code/overview.ts
|
|
1525
1823
|
const DAY_MS$2 = 864e5;
|
|
1526
1824
|
const WINDOW_DAYS = 30;
|
|
@@ -1600,9 +1898,13 @@ async function readTreeCosts(conversationIds) {
|
|
|
1600
1898
|
};
|
|
1601
1899
|
}
|
|
1602
1900
|
/**
|
|
1603
|
-
* True when any linked conversation actor belongs to the subject user
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1901
|
+
* True when any linked conversation actor belongs to the subject user, or
|
|
1902
|
+
* the code change credits one of the user's Identities as requester. A
|
|
1903
|
+
* Thread or an Automation run that someone else started can open a change
|
|
1904
|
+
* for the user, so the requester half finds the changes the actor half
|
|
1905
|
+
* misses. The first subquery starts from the user's Conversations, so
|
|
1906
|
+
* Postgres hash-joins them with the linked ids instead of one lookup per
|
|
1907
|
+
* code change. The second uses the requester GIN index.
|
|
1606
1908
|
*/
|
|
1607
1909
|
function ownedByUserSql(userId) {
|
|
1608
1910
|
return sql`${juniorCodeChanges.id} IN (
|
|
@@ -1616,6 +1918,12 @@ function ownedByUserSql(userId) {
|
|
|
1616
1918
|
) AS linked
|
|
1617
1919
|
ON linked.conversation_id = conversations.conversation_id
|
|
1618
1920
|
WHERE identities.user_id = ${userId}
|
|
1921
|
+
UNION ALL
|
|
1922
|
+
SELECT requested.id
|
|
1923
|
+
FROM junior_identities AS identities
|
|
1924
|
+
INNER JOIN junior_code_changes AS requested
|
|
1925
|
+
ON requested.requester_identity_ids @> ARRAY[identities.id]
|
|
1926
|
+
WHERE identities.user_id = ${userId}
|
|
1619
1927
|
)`;
|
|
1620
1928
|
}
|
|
1621
1929
|
/** Limit code changes to one person's conversations or one repository. */
|
|
@@ -1691,11 +1999,7 @@ async function readCodeWindows(args) {
|
|
|
1691
1999
|
}
|
|
1692
2000
|
/** Columns read for one code change report row. */
|
|
1693
2001
|
const codeChangeReportColumns = {
|
|
1694
|
-
additions: juniorCodeChanges.additions,
|
|
1695
|
-
changedFiles: juniorCodeChanges.changedFiles,
|
|
1696
2002
|
closedAt: juniorCodeChanges.closedAt,
|
|
1697
|
-
deletions: juniorCodeChanges.deletions,
|
|
1698
|
-
draft: juniorCodeChanges.draft,
|
|
1699
2003
|
id: juniorCodeChanges.id,
|
|
1700
2004
|
lastActivityAt: juniorCodeChanges.lastActivityAt,
|
|
1701
2005
|
mergedAt: juniorCodeChanges.mergedAt,
|
|
@@ -1707,14 +2011,9 @@ const codeChangeReportColumns = {
|
|
|
1707
2011
|
title: juniorCodeChanges.title
|
|
1708
2012
|
};
|
|
1709
2013
|
/** Convert one code change row to its report shape. */
|
|
1710
|
-
function codeChangeReport(
|
|
1711
|
-
const size = {};
|
|
1712
|
-
if (additions !== null) size.additions = additions;
|
|
1713
|
-
if (deletions !== null) size.deletions = deletions;
|
|
1714
|
-
if (changedFiles !== null) size.changedFiles = changedFiles;
|
|
2014
|
+
function codeChangeReport(change) {
|
|
1715
2015
|
return {
|
|
1716
2016
|
...change,
|
|
1717
|
-
...Object.keys(size).length > 0 ? { size } : void 0,
|
|
1718
2017
|
closedAt: change.closedAt?.toISOString(),
|
|
1719
2018
|
lastActivityAt: change.lastActivityAt?.toISOString(),
|
|
1720
2019
|
mergedAt: change.mergedAt?.toISOString(),
|
|
@@ -1792,8 +2091,8 @@ function afterPersonCodeCursor(cursor) {
|
|
|
1792
2091
|
return or(completed, sql`${idleSince} > ${since}`, and(sql`${idleSince} = ${since}`, laterInGroup));
|
|
1793
2092
|
}
|
|
1794
2093
|
/**
|
|
1795
|
-
* Read person-scoped code activity and recent code changes linked
|
|
1796
|
-
*
|
|
2094
|
+
* Read person-scoped code activity and recent code changes: the ones linked
|
|
2095
|
+
* to the person's Conversations, and the ones that credit them as requester.
|
|
1797
2096
|
*/
|
|
1798
2097
|
async function readPersonCodeOverview(args) {
|
|
1799
2098
|
const nowMs = args.nowMs ?? Date.now();
|
|
@@ -1804,14 +2103,25 @@ async function readPersonCodeOverview(args) {
|
|
|
1804
2103
|
userId: args.userId
|
|
1805
2104
|
}), db.select({
|
|
1806
2105
|
change: codeChangeReportColumns,
|
|
2106
|
+
conversationIds: juniorCodeChanges.conversationIds,
|
|
1807
2107
|
updatedAt: juniorCodeChanges.updatedAt
|
|
1808
2108
|
}).from(juniorCodeChanges).innerJoin(juniorCodeRepositories, eq(juniorCodeChanges.repositoryId, juniorCodeRepositories.id)).where(and(changeScopeFilter({ userId: args.userId }), after ? afterPersonCodeCursor(after) : void 0)).orderBy(desc(sql`${juniorCodeChanges.state} = 'open'`), asc(sql`CASE WHEN ${juniorCodeChanges.state} = 'open' THEN ${idleSince} END`), desc(juniorCodeChanges.updatedAt), asc(juniorCodeChanges.id)).limit(PERSON_CHANGE_LIMIT)]);
|
|
2109
|
+
const stacks = await readCodeChangeStacks(db, changes.map((row) => ({
|
|
2110
|
+
conversationIds: row.conversationIds,
|
|
2111
|
+
id: row.change.id
|
|
2112
|
+
})), args.viewer);
|
|
1809
2113
|
const last = changes.at(-1);
|
|
1810
2114
|
return {
|
|
1811
2115
|
activityDays: windows.activityDays,
|
|
1812
2116
|
activityHours: windows.activityHours,
|
|
1813
2117
|
activitySixHours: windows.activitySixHours,
|
|
1814
|
-
changes: changes.map((row) =>
|
|
2118
|
+
changes: changes.map((row) => {
|
|
2119
|
+
const stack = stacks.get(row.change.id);
|
|
2120
|
+
return {
|
|
2121
|
+
...codeChangeReport(row.change),
|
|
2122
|
+
...stack ? { stack } : void 0
|
|
2123
|
+
};
|
|
2124
|
+
}),
|
|
1815
2125
|
generatedAt: windows.windowEnd.toISOString(),
|
|
1816
2126
|
nextCursor: last && changes.length === PERSON_CHANGE_LIMIT ? encodePageCursor(personCodeCursorSchema, {
|
|
1817
2127
|
id: last.change.id,
|
|
@@ -1891,8 +2201,8 @@ async function readCodeRepository(repositoryId, options = {}) {
|
|
|
1891
2201
|
// src/api/code/search.query.ts
|
|
1892
2202
|
const CODE_CHANGE_SEARCH_LIMIT = 8;
|
|
1893
2203
|
const CODE_CHANGE_SEARCH_TERMS = 4;
|
|
1894
|
-
const
|
|
1895
|
-
const
|
|
2204
|
+
const CODE_CHANGE_SEARCH_TIMEOUT_MS = 3e3;
|
|
2205
|
+
const matched = alias(juniorCodeChanges, "matched");
|
|
1896
2206
|
const linked = alias(juniorConversations, "linked_conversation");
|
|
1897
2207
|
/**
|
|
1898
2208
|
* Find code changes for the composer `#` menu, newest activity first. A
|
|
@@ -1911,16 +2221,20 @@ async function readCodeChangeSearchFromSql(query, viewerUserId) {
|
|
|
1911
2221
|
const anyTerm = terms.map((term) => `${term}:*`).join(" | ");
|
|
1912
2222
|
const db = getDb();
|
|
1913
2223
|
const changeDocument = codeChangeSearchDocument(juniorCodeChanges);
|
|
1914
|
-
const
|
|
1915
|
-
const
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
2224
|
+
const repositoryDocument = codeRepositorySearchDocument(juniorCodeRepositories);
|
|
2225
|
+
const textMatch = (condition) => db.select({ id: matched.id }).from(matched).innerJoin(juniorCodeRepositories, eq(juniorCodeRepositories.id, matched.repositoryId)).where(and(condition, terms.length > 1 ? sql`(${codeChangeSearchDocument(matched)} || ${repositoryDocument}) @@ to_tsquery('simple', ${everyTerm})` : void 0));
|
|
2226
|
+
const matches = number ? and(sql`${changeDocument} @@ to_tsquery('simple', ${everyTerm})`, sql`${juniorCodeChanges.number}::text like ${`${number}%`}`) : inArray(juniorCodeChanges.id, union(textMatch(sql`${codeChangeSearchDocument(matched)} @@ to_tsquery('simple', ${anyTerm})`), textMatch(sql`${repositoryDocument} @@ to_tsquery('simple', ${anyTerm})`)));
|
|
2227
|
+
const visible = exists(db.select({ conversationId: juniorConversations.conversationId }).from(linked).innerJoin(juniorConversations, eq(juniorConversations.conversationId, sql`coalesce(${linked.rootConversationId}, ${linked.conversationId})`)).where(and(sql`${linked.conversationId} = any(${juniorCodeChanges.conversationIds})`, listedConversation(), rootVisibleToViewer(viewerUserId))));
|
|
2228
|
+
return (await db.transaction(async (tx) => {
|
|
2229
|
+
await tx.execute(sql`SELECT set_config('statement_timeout', ${String(CODE_CHANGE_SEARCH_TIMEOUT_MS)}, true)`);
|
|
2230
|
+
return await tx.select({
|
|
2231
|
+
number: juniorCodeChanges.number,
|
|
2232
|
+
provider: juniorCodeChanges.provider,
|
|
2233
|
+
repository: juniorCodeRepositories.name,
|
|
2234
|
+
state: juniorCodeChanges.state,
|
|
2235
|
+
title: juniorCodeChanges.title
|
|
2236
|
+
}).from(juniorCodeChanges).innerJoin(juniorCodeRepositories, eq(juniorCodeRepositories.id, juniorCodeChanges.repositoryId)).where(and(matches, inArray(juniorCodeChanges.provider, providers), visible)).orderBy(...number ? [desc(sql`${juniorCodeChanges.number}::text = ${number}`)] : [], desc(sql`coalesce(${juniorCodeChanges.lastActivityAt}, ${juniorCodeChanges.openedAt})`), asc(juniorCodeChanges.id)).limit(CODE_CHANGE_SEARCH_LIMIT);
|
|
2237
|
+
})).flatMap(({ provider, ...row }) => {
|
|
1924
2238
|
const url = codeChangeUrl({
|
|
1925
2239
|
...row,
|
|
1926
2240
|
provider
|
|
@@ -2122,8 +2436,8 @@ function summaryFromRow(row, options = {}) {
|
|
|
2122
2436
|
});
|
|
2123
2437
|
}
|
|
2124
2438
|
// src/api/locations/query.ts
|
|
2125
|
-
const RECENT_LIMIT
|
|
2126
|
-
const ACTIVITY_DAYS
|
|
2439
|
+
const RECENT_LIMIT = 25;
|
|
2440
|
+
const ACTIVITY_DAYS = 90;
|
|
2127
2441
|
/**
|
|
2128
2442
|
* Location id for every public Conversation with a `local` destination. Each
|
|
2129
2443
|
* such Conversation has its own destination row, so they report as one
|
|
@@ -2169,7 +2483,7 @@ function topLevelWhere() {
|
|
|
2169
2483
|
return isNull(juniorConversations.parentConversationId);
|
|
2170
2484
|
}
|
|
2171
2485
|
function publicLocationWhere(locationId) {
|
|
2172
|
-
return and(topLevelWhere(), locationId === DASHBOARD_LOCATION_ID ? eq(juniorDestinations.provider, "local") : and(eq(juniorDestinations.id, locationId), ne(juniorDestinations.provider, "local")),
|
|
2486
|
+
return and(topLevelWhere(), locationId === DASHBOARD_LOCATION_ID ? eq(juniorDestinations.provider, "local") : and(eq(juniorDestinations.id, locationId), ne(juniorDestinations.provider, "local")), isPublicConversation(juniorConversations));
|
|
2173
2487
|
}
|
|
2174
2488
|
function locationColumns() {
|
|
2175
2489
|
return {
|
|
@@ -2178,7 +2492,8 @@ function locationColumns() {
|
|
|
2178
2492
|
destinationKind: juniorDestinations.kind,
|
|
2179
2493
|
destinationProvider: juniorDestinations.provider,
|
|
2180
2494
|
destinationProviderId: juniorDestinations.providerDestinationId,
|
|
2181
|
-
destinationVisibility: juniorDestinations.visibility
|
|
2495
|
+
destinationVisibility: juniorDestinations.visibility,
|
|
2496
|
+
rootVisibility: juniorConversations.visibility
|
|
2182
2497
|
};
|
|
2183
2498
|
}
|
|
2184
2499
|
function locationGroupBy() {
|
|
@@ -2188,12 +2503,16 @@ function locationGroupBy() {
|
|
|
2188
2503
|
juniorDestinations.kind,
|
|
2189
2504
|
juniorDestinations.provider,
|
|
2190
2505
|
juniorDestinations.providerDestinationId,
|
|
2191
|
-
juniorDestinations.visibility
|
|
2506
|
+
juniorDestinations.visibility,
|
|
2507
|
+
juniorConversations.visibility
|
|
2192
2508
|
];
|
|
2193
2509
|
}
|
|
2194
|
-
/**
|
|
2510
|
+
/**
|
|
2511
|
+
* Admit only public roots at complete persisted-public destinations as named
|
|
2512
|
+
* locations.
|
|
2513
|
+
*/
|
|
2195
2514
|
function locationFromAggregate(row) {
|
|
2196
|
-
if (row.destinationVisibility !== "public" || !row.destinationId || !row.destinationProvider || !row.destinationProviderId || !row.destinationKind) return;
|
|
2515
|
+
if (row.rootVisibility !== "public" || row.destinationVisibility !== "public" || !row.destinationId || !row.destinationProvider || !row.destinationProviderId || !row.destinationKind) return;
|
|
2197
2516
|
const dashboard = row.destinationProvider === "local";
|
|
2198
2517
|
const location = {
|
|
2199
2518
|
...emptyMetrics(),
|
|
@@ -2245,15 +2564,15 @@ async function directoryActivityRows(db, start, hourStart) {
|
|
|
2245
2564
|
)`;
|
|
2246
2565
|
const select = {
|
|
2247
2566
|
conversations: sql`COUNT(*)::integer`,
|
|
2248
|
-
visibility:
|
|
2567
|
+
visibility: juniorConversations.visibility
|
|
2249
2568
|
};
|
|
2250
2569
|
const [dayRows, hourRows] = await Promise.all([db.select({
|
|
2251
2570
|
...select,
|
|
2252
2571
|
date: day
|
|
2253
|
-
}).from(juniorConversations).
|
|
2572
|
+
}).from(juniorConversations).where(and(topLevelWhere(), gte(juniorConversations.lastActivityAt, start))).groupBy(day, juniorConversations.visibility), db.select({
|
|
2254
2573
|
...select,
|
|
2255
2574
|
date: hour
|
|
2256
|
-
}).from(juniorConversations).
|
|
2575
|
+
}).from(juniorConversations).where(and(topLevelWhere(), gte(juniorConversations.lastActivityAt, hourStart))).groupBy(hour, juniorConversations.visibility)]);
|
|
2257
2576
|
return {
|
|
2258
2577
|
dayRows,
|
|
2259
2578
|
hourRows
|
|
@@ -2278,7 +2597,7 @@ function accumulateLocationActivity(rows) {
|
|
|
2278
2597
|
}
|
|
2279
2598
|
function directoryActivityDays$1(rows, nowMs) {
|
|
2280
2599
|
return fillUtcDays({
|
|
2281
|
-
count: ACTIVITY_DAYS
|
|
2600
|
+
count: ACTIVITY_DAYS,
|
|
2282
2601
|
empty: emptyLocationActivityDay,
|
|
2283
2602
|
nowMs,
|
|
2284
2603
|
rows: accumulateLocationActivity(rows)
|
|
@@ -2308,7 +2627,7 @@ function directoryActivitySixHours$1(rows, nowMs) {
|
|
|
2308
2627
|
/** Load public locations plus one complete privacy-safe aggregate for non-public activity. */
|
|
2309
2628
|
async function readLocationDirectoryFromSql() {
|
|
2310
2629
|
const nowMs = Date.now();
|
|
2311
|
-
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS
|
|
2630
|
+
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS);
|
|
2312
2631
|
const hourWindow = trailingUtcHourWindow(nowMs, 168);
|
|
2313
2632
|
const [rows, activity] = await Promise.all([directoryRows(getDb()), directoryActivityRows(getDb(), start, hourWindow.start)]);
|
|
2314
2633
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -2362,12 +2681,12 @@ async function recentLocationRows(db, locationId) {
|
|
|
2362
2681
|
title: juniorConversations.title,
|
|
2363
2682
|
updatedAt: juniorConversations.updatedAt,
|
|
2364
2683
|
usage: juniorConversations.usage
|
|
2365
|
-
}).from(juniorConversations).innerJoin(juniorDestinations, eq(juniorDestinations.id, juniorConversations.destinationId)).leftJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(publicLocationWhere(locationId)).orderBy(desc(juniorConversations.lastActivityAt), asc(juniorConversations.conversationId)).limit(RECENT_LIMIT
|
|
2684
|
+
}).from(juniorConversations).innerJoin(juniorDestinations, eq(juniorDestinations.id, juniorConversations.destinationId)).leftJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(publicLocationWhere(locationId)).orderBy(desc(juniorConversations.lastActivityAt), asc(juniorConversations.conversationId)).limit(RECENT_LIMIT);
|
|
2366
2685
|
}
|
|
2367
2686
|
/** Load one public location's complete activity while bounding only recent conversations. */
|
|
2368
2687
|
async function readLocationDetailFromSql(locationId, options = {}) {
|
|
2369
2688
|
const nowMs = Date.now();
|
|
2370
|
-
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS
|
|
2689
|
+
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS);
|
|
2371
2690
|
const hourWindow = trailingUtcHourWindow(nowMs, 168);
|
|
2372
2691
|
const where = publicLocationWhere(locationId);
|
|
2373
2692
|
const activityDate = sql`TO_CHAR(
|
|
@@ -2443,7 +2762,7 @@ async function readLocationDetailFromSql(locationId, options = {}) {
|
|
|
2443
2762
|
addMetrics(item, row);
|
|
2444
2763
|
actors.push(item);
|
|
2445
2764
|
}
|
|
2446
|
-
const activity = activityDays$1(days, nowMs, ACTIVITY_DAYS
|
|
2765
|
+
const activity = activityDays$1(days, nowMs, ACTIVITY_DAYS);
|
|
2447
2766
|
const hourlyActivity = activityHours$2(hours, nowMs);
|
|
2448
2767
|
const recentConversationIds = recentRows.map((row) => row.conversationId);
|
|
2449
2768
|
const [accessByConversation, metricsByRoot, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
|
|
@@ -2637,211 +2956,225 @@ function createImageRoutes() {
|
|
|
2637
2956
|
});
|
|
2638
2957
|
return app;
|
|
2639
2958
|
}
|
|
2640
|
-
// src/api/
|
|
2641
|
-
/**
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
lastSeq,
|
|
2652
|
-
watchedConversationIds
|
|
2653
|
-
}, { headers: { "cache-control": "private, no-store" } });
|
|
2654
|
-
});
|
|
2655
|
-
return app;
|
|
2656
|
-
}
|
|
2657
|
-
const metrics$1 = juniorConversationMetrics;
|
|
2658
|
-
/** Sum the values of one metric among grouped metric rows. */
|
|
2659
|
-
function metricSum(metric) {
|
|
2660
|
-
return sql`sum(${metrics$1.value}) FILTER (WHERE ${metrics$1.metric} = ${metric})`;
|
|
2959
|
+
// src/api/spaces/access.ts
|
|
2960
|
+
/** Validate the `:spaceId` route parameter. */
|
|
2961
|
+
const spaceParamsValidator = validateRequest("param", spaceParamsSchema, "Invalid route parameters.");
|
|
2962
|
+
/** Write one Space as the API reports it. */
|
|
2963
|
+
function spaceReport(space) {
|
|
2964
|
+
return {
|
|
2965
|
+
...space,
|
|
2966
|
+
createdAt: space.createdAt.toISOString(),
|
|
2967
|
+
updatedAt: space.updatedAt.toISOString(),
|
|
2968
|
+
archivedAt: space.archivedAt?.toISOString() ?? null
|
|
2969
|
+
};
|
|
2661
2970
|
}
|
|
2662
|
-
/** Sum the spend of Turn metric rows read straight from their table. */
|
|
2663
|
-
const turnMetricColumns = { costMicroUsd: microUsdSql(metricSum("cost_micro_usd")) };
|
|
2664
|
-
/** Root Conversation of a person's Turn, for status, location, and surface. */
|
|
2665
|
-
const turnRoot = alias(juniorConversations, "person_turn_root");
|
|
2666
|
-
/** Root of a Conversation row: itself when it has no root. */
|
|
2667
|
-
const conversationRootId = sql`coalesce(
|
|
2668
|
-
${juniorConversations.rootConversationId},
|
|
2669
|
-
${juniorConversations.conversationId}
|
|
2670
|
-
)`;
|
|
2671
2971
|
/**
|
|
2672
|
-
*
|
|
2673
|
-
*
|
|
2674
|
-
*
|
|
2675
|
-
* The person and metric filters apply to the metric rows, and the rows are
|
|
2676
|
-
* grouped before any join. Every Run writes a `duration_ms` row, so these
|
|
2677
|
-
* two metrics mark every Turn.
|
|
2972
|
+
* Return the Space that the viewer reads, or a 404. A private Space is a 404
|
|
2973
|
+
* to a person who is not a member, so the error does not show it exists.
|
|
2678
2974
|
*/
|
|
2679
|
-
function
|
|
2680
|
-
const
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
conversationId: sql`${metrics$1.conversationId}`.as("turn_conversation_id"),
|
|
2684
|
-
firstAt: sql`min(${metrics$1.occurredAt})`.as("turn_first_at"),
|
|
2685
|
-
lastAt: sql`max(${metrics$1.occurredAt})`.as("turn_last_at"),
|
|
2686
|
-
durationMs: metricSum("duration_ms").as("turn_duration_ms"),
|
|
2687
|
-
tokens: metricSum("total_tokens").as("turn_tokens")
|
|
2688
|
-
}).from(metrics$1).where(and(inArray(metrics$1.actorIdentityId, verifiedIdentities), inArray(metrics$1.metric, ["duration_ms", "total_tokens"]))).groupBy(metrics$1.actorIdentityId, metrics$1.conversationId).as("person_conversation_turns");
|
|
2689
|
-
return getDb().select({
|
|
2690
|
-
userId: sql`${juniorIdentities.userId}`.as("root_user_id"),
|
|
2691
|
-
rootConversationId: conversationRootId.as("person_root_id"),
|
|
2692
|
-
firstAt: sql`min(${conversations.firstAt})`.as("root_first_at"),
|
|
2693
|
-
lastAt: sql`max(${conversations.lastAt})`.as("root_last_at"),
|
|
2694
|
-
durationMs: sql`sum(${conversations.durationMs})`.as("root_duration_ms"),
|
|
2695
|
-
tokens: sql`sum(${conversations.tokens})`.as("root_tokens"),
|
|
2696
|
-
slackUserId: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END)`.as("root_slack_user_id"),
|
|
2697
|
-
slackUserName: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END)`.as("root_slack_user_name")
|
|
2698
|
-
}).from(conversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, conversations.identityId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, conversations.conversationId)).groupBy(juniorIdentities.userId, conversationRootId).as("person_roots");
|
|
2699
|
-
}
|
|
2700
|
-
/** Join a person's roots to the root Conversation rows. */
|
|
2701
|
-
function personRootJoin(roots) {
|
|
2702
|
-
return eq(turnRoot.conversationId, roots.rootConversationId);
|
|
2975
|
+
async function requireSpace(viewerUserId, spaceId) {
|
|
2976
|
+
const space = await readSpace(viewerUserId, spaceId);
|
|
2977
|
+
if (!space) throwApiError(404, "Space was not found.");
|
|
2978
|
+
return space;
|
|
2703
2979
|
}
|
|
2704
2980
|
/**
|
|
2705
|
-
*
|
|
2706
|
-
*
|
|
2707
|
-
* Conversation Turns count for the root. Each row is one root of one person,
|
|
2708
|
-
* so plain counts need no DISTINCT. Active and failed read the root's current
|
|
2709
|
-
* status.
|
|
2981
|
+
* Return the Space that the viewer changes. Anyone can read a public Space,
|
|
2982
|
+
* but only members change a Space.
|
|
2710
2983
|
*/
|
|
2711
|
-
function
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2984
|
+
async function requireMemberSpace(viewerUserId, spaceId) {
|
|
2985
|
+
const space = await requireSpace(viewerUserId, spaceId);
|
|
2986
|
+
if (!space.viewerIsMember) throwApiError(403, "Join the Space to change it.");
|
|
2987
|
+
return space;
|
|
2988
|
+
}
|
|
2989
|
+
/** Respond with the Space as the viewer sees it now. */
|
|
2990
|
+
async function spaceResponse(viewerUserId, spaceId, init) {
|
|
2991
|
+
return jsonResponse(spaceSchema, spaceReport(await requireSpace(viewerUserId, spaceId)), init);
|
|
2992
|
+
}
|
|
2993
|
+
// src/api/spaces/archive.ts
|
|
2994
|
+
/** Create the route that archives or restores a Space with its Conversations. */
|
|
2995
|
+
function createSpaceArchiveRoutes(options) {
|
|
2996
|
+
const app = new Hono();
|
|
2997
|
+
app.patch("/:spaceId/archive", requireViewer, spaceParamsValidator, validateRequest("json", archiveSpaceBodySchema, "Invalid request body."), async (context) => {
|
|
2998
|
+
const viewerUserId = context.get("viewer").id;
|
|
2999
|
+
const { spaceId } = context.req.valid("param");
|
|
3000
|
+
await requireMemberSpace(viewerUserId, spaceId);
|
|
3001
|
+
await setSpaceArchive({
|
|
3002
|
+
archived: context.req.valid("json").archived,
|
|
3003
|
+
queue: options.queue,
|
|
3004
|
+
spaceId
|
|
3005
|
+
});
|
|
3006
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
3007
|
+
});
|
|
3008
|
+
return app;
|
|
2719
3009
|
}
|
|
3010
|
+
// src/api/spaces/configuration.ts
|
|
2720
3011
|
/**
|
|
2721
|
-
*
|
|
2722
|
-
*
|
|
2723
|
-
*
|
|
3012
|
+
* Create the route that reads a Space's configuration. Anyone who reads the
|
|
3013
|
+
* Space reads it. Junior changes it with its `setConfiguration` tool,
|
|
3014
|
+
* when a member asks.
|
|
2724
3015
|
*/
|
|
2725
|
-
function
|
|
2726
|
-
const
|
|
2727
|
-
|
|
3016
|
+
function createSpaceConfigurationRoutes() {
|
|
3017
|
+
const app = new Hono();
|
|
3018
|
+
app.get("/:spaceId/configuration", requireViewer, spaceParamsValidator, async (context) => {
|
|
3019
|
+
const { spaceId } = context.req.valid("param");
|
|
3020
|
+
await requireSpace(context.get("viewer").id, spaceId);
|
|
3021
|
+
const entries = await listSpaceConfiguration(spaceId);
|
|
3022
|
+
return jsonResponse(spaceConfigurationSchema, { entries: entries.map((entry) => ({
|
|
3023
|
+
...entry,
|
|
3024
|
+
updatedAt: entry.updatedAt.toISOString()
|
|
3025
|
+
})) });
|
|
3026
|
+
});
|
|
3027
|
+
return app;
|
|
2728
3028
|
}
|
|
3029
|
+
// src/api/spaces/lead.ts
|
|
2729
3030
|
/**
|
|
2730
|
-
*
|
|
2731
|
-
*
|
|
3031
|
+
* Create the route that finds a Space's Lead. A member's first read creates
|
|
3032
|
+
* it. Anyone who reads the Space reads its Lead, which is public like the
|
|
3033
|
+
* Space.
|
|
2732
3034
|
*/
|
|
2733
|
-
function
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
}
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
return {
|
|
2752
|
-
active: 0,
|
|
2753
|
-
activeDays: 0,
|
|
2754
|
-
conversations: 0,
|
|
2755
|
-
durationMs: 0,
|
|
2756
|
-
failed: 0
|
|
2757
|
-
};
|
|
2758
|
-
}
|
|
2759
|
-
/** Build a zeroed activity day for the people profile window. */
|
|
2760
|
-
function emptyActivityDay(date) {
|
|
2761
|
-
return {
|
|
2762
|
-
active: 0,
|
|
2763
|
-
conversations: 0,
|
|
2764
|
-
date,
|
|
2765
|
-
durationMs: 0,
|
|
2766
|
-
failed: 0
|
|
2767
|
-
};
|
|
2768
|
-
}
|
|
2769
|
-
/** Fill the fixed people profile activity window from sparse day totals. */
|
|
2770
|
-
function activityDays(days, nowMs) {
|
|
2771
|
-
return fillUtcDays({
|
|
2772
|
-
count: 365,
|
|
2773
|
-
empty: emptyActivityDay,
|
|
2774
|
-
nowMs,
|
|
2775
|
-
rows: days
|
|
3035
|
+
function createSpaceLeadRoutes() {
|
|
3036
|
+
const app = new Hono();
|
|
3037
|
+
app.get("/:spaceId/lead", requireViewer, spaceParamsValidator, async (context) => {
|
|
3038
|
+
const viewer = context.get("viewer");
|
|
3039
|
+
const space = await requireSpace(viewer.id, context.req.valid("param").spaceId);
|
|
3040
|
+
const lead = space.viewerIsMember ? await getSpaceLead({
|
|
3041
|
+
member: viewer,
|
|
3042
|
+
space
|
|
3043
|
+
}) : await readSpaceLead(space.id);
|
|
3044
|
+
if (!lead) throwApiError(404, "This Space has no Lead yet.");
|
|
3045
|
+
const lastSeq = await readConversationLastEventSeq(getSqlExecutor(), lead.conversationId);
|
|
3046
|
+
const watches = await listWatches({ conversationId: lead.conversationId });
|
|
3047
|
+
const watchedConversationIds = [...new Set(watches.filter((watch) => watch.namespace === "junior" && isAgentResourceType(watch.resourceType)).map((watch) => watch.identifier))];
|
|
3048
|
+
return jsonResponse(leadSchema, {
|
|
3049
|
+
conversationId: lead.conversationId,
|
|
3050
|
+
lastSeq,
|
|
3051
|
+
watchedConversationIds
|
|
3052
|
+
}, { headers: { "cache-control": "private, no-store" } });
|
|
2776
3053
|
});
|
|
3054
|
+
return app;
|
|
2777
3055
|
}
|
|
3056
|
+
// src/api/spaces/members.ts
|
|
2778
3057
|
/**
|
|
2779
|
-
*
|
|
2780
|
-
*
|
|
3058
|
+
* Create the routes that list a Space's members, add a member, and join or
|
|
3059
|
+
* leave it.
|
|
2781
3060
|
*/
|
|
2782
|
-
function
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
3061
|
+
function createSpaceMemberRoutes() {
|
|
3062
|
+
const app = new Hono();
|
|
3063
|
+
app.get("/:spaceId/members", requireViewer, spaceParamsValidator, async (context) => {
|
|
3064
|
+
const { spaceId } = context.req.valid("param");
|
|
3065
|
+
await requireSpace(context.get("viewer").id, spaceId);
|
|
3066
|
+
const members = await listSpaceMembers(spaceId);
|
|
3067
|
+
return jsonResponse(spaceMemberListSchema, { members: members.map((member) => ({
|
|
3068
|
+
...member,
|
|
3069
|
+
joinedAt: member.joinedAt.toISOString()
|
|
3070
|
+
})) });
|
|
3071
|
+
});
|
|
3072
|
+
app.post("/:spaceId/members", requireViewer, spaceParamsValidator, validateRequest("json", addSpaceMemberBodySchema, "Invalid request body."), async (context) => {
|
|
3073
|
+
const viewerUserId = context.get("viewer").id;
|
|
3074
|
+
const { spaceId } = context.req.valid("param");
|
|
3075
|
+
await requireMemberSpace(viewerUserId, spaceId);
|
|
3076
|
+
const email = normalizeIdentityEmail(context.req.valid("json").email);
|
|
3077
|
+
const person = email ? await readCachedUserByEmail(getDb(), email) : void 0;
|
|
3078
|
+
if (!person) throwApiError(404, "No person has that email.");
|
|
3079
|
+
await joinSpace(spaceId, person.user.id);
|
|
3080
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
3081
|
+
});
|
|
3082
|
+
app.put("/:spaceId/members/me", requireViewer, spaceParamsValidator, async (context) => {
|
|
3083
|
+
const viewerUserId = context.get("viewer").id;
|
|
3084
|
+
const { spaceId } = context.req.valid("param");
|
|
3085
|
+
await requireSpace(viewerUserId, spaceId);
|
|
3086
|
+
await joinSpace(spaceId, viewerUserId);
|
|
3087
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
3088
|
+
});
|
|
3089
|
+
app.delete("/:spaceId/members/me", requireViewer, spaceParamsValidator, async (context) => {
|
|
3090
|
+
const viewerUserId = context.get("viewer").id;
|
|
3091
|
+
const { spaceId } = context.req.valid("param");
|
|
3092
|
+
const space = await requireSpace(viewerUserId, spaceId);
|
|
3093
|
+
if (await leaveSpace(spaceId, viewerUserId) === "last_member") throwApiError(409, "The last member can't leave a private Space.");
|
|
3094
|
+
if (space.visibility === "private") return jsonResponse(spaceSchema, {
|
|
3095
|
+
...spaceReport(space),
|
|
3096
|
+
memberCount: space.memberCount - 1,
|
|
3097
|
+
viewerIsMember: false
|
|
3098
|
+
});
|
|
3099
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
2788
3100
|
});
|
|
3101
|
+
return app;
|
|
2789
3102
|
}
|
|
3103
|
+
// src/api/spaces/state.ts
|
|
2790
3104
|
/**
|
|
2791
|
-
*
|
|
2792
|
-
*
|
|
3105
|
+
* The most Conversations of the listed Spaces that one read rolls up, newest
|
|
3106
|
+
* activity first. The Lead archives finished work, so a Space has few
|
|
3107
|
+
* Conversations that are not archived. Past this, the oldest ones count for
|
|
3108
|
+
* nothing.
|
|
2793
3109
|
*/
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
});
|
|
2801
|
-
}
|
|
2802
|
-
/** Return deterministic stats rows for people API responses. */
|
|
2803
|
-
function statsItems(map) {
|
|
2804
|
-
return [...map.values()].sort((left, right) => right.conversations - left.conversations || right.durationMs - left.durationMs || left.label.localeCompare(right.label));
|
|
2805
|
-
}
|
|
3110
|
+
const SPACE_STATE_CONVERSATION_LIMIT = 200;
|
|
3111
|
+
const TREE_STATE_ORDER = [
|
|
3112
|
+
"needs_you",
|
|
3113
|
+
"working",
|
|
3114
|
+
"done"
|
|
3115
|
+
];
|
|
2806
3116
|
/**
|
|
2807
|
-
*
|
|
2808
|
-
*
|
|
2809
|
-
*
|
|
2810
|
-
*
|
|
2811
|
-
* the
|
|
3117
|
+
* Roll up the tree state of every Conversation in each Space that the viewer
|
|
3118
|
+
* can read and that is not archived, the Lead included. Each Space gets an
|
|
3119
|
+
* entry, and a Space with none of them reads `done`. `treeState` is the
|
|
3120
|
+
* first that applies over them, as for one Conversation. `latestTurnFailed`
|
|
3121
|
+
* is set when the latest Turn of one of them failed.
|
|
2812
3122
|
*/
|
|
2813
|
-
function
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
}
|
|
2817
|
-
/** Read the Conversations where a person ran a Turn, by their last Turn. */
|
|
2818
|
-
async function recentActorRows(email) {
|
|
2819
|
-
const lastTurns = getDb().select({
|
|
2820
|
-
conversationId: sql`${metrics$1.conversationId}`.as("turn_conversation_id"),
|
|
2821
|
-
lastTurnAt: sql`max(${metrics$1.occurredAt})`.as("last_turn_at")
|
|
2822
|
-
}).from(metrics$1).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics$1.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(verifiedActorWhere(email), eq(metrics$1.metric, "duration_ms"))).groupBy(metrics$1.conversationId).as("person_last_turns");
|
|
2823
|
-
return getDb().select({
|
|
2824
|
-
channelName: juniorConversations.channelName,
|
|
3123
|
+
async function readSpaceStates(db, spaceIds, viewerUserId) {
|
|
3124
|
+
if (spaceIds.length === 0) return /* @__PURE__ */ new Map();
|
|
3125
|
+
const roots = await db.select({
|
|
2825
3126
|
conversationId: juniorConversations.conversationId,
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
3127
|
+
spaceId: juniorConversations.spaceId,
|
|
3128
|
+
latestTurnFailed: conversationTurnFailedSql(juniorConversations)
|
|
3129
|
+
}).from(juniorConversations).where(and(inArray(juniorConversations.spaceId, [...spaceIds]), isNull(juniorConversations.parentConversationId), isNull(juniorConversations.archivedAt), isNull(juniorConversations.quickQuestionAt), rootVisibleToViewer(viewerUserId))).orderBy(desc(juniorConversations.lastActivityAt)).limit(SPACE_STATE_CONVERSATION_LIMIT);
|
|
3130
|
+
const trees = await readConversationTreeStates(db, roots.map((root) => root.conversationId), viewerUserId);
|
|
3131
|
+
const states = new Map(spaceIds.map((spaceId) => [spaceId, {
|
|
3132
|
+
latestTurnFailed: false,
|
|
3133
|
+
treeState: "done"
|
|
3134
|
+
}]));
|
|
3135
|
+
for (const root of roots) {
|
|
3136
|
+
const current = root.spaceId ? states.get(root.spaceId) : void 0;
|
|
3137
|
+
if (!current) continue;
|
|
3138
|
+
const treeState = trees.get(root.conversationId)?.treeState ?? "done";
|
|
3139
|
+
if (root.latestTurnFailed) current.latestTurnFailed = true;
|
|
3140
|
+
if (TREE_STATE_ORDER.indexOf(treeState) < TREE_STATE_ORDER.indexOf(current.treeState)) current.treeState = treeState;
|
|
3141
|
+
}
|
|
3142
|
+
return states;
|
|
3143
|
+
}
|
|
3144
|
+
// src/api/spaces/space.ts
|
|
3145
|
+
/** Create the routes that list, create, read, and change Spaces. */
|
|
3146
|
+
function createSpaceRoutes() {
|
|
3147
|
+
const app = new Hono();
|
|
3148
|
+
app.get("/", requireViewer, validateRequest("query", spaceListQuerySchema, "Invalid query parameters."), async (context) => {
|
|
3149
|
+
const viewerUserId = context.get("viewer").id;
|
|
3150
|
+
const spaces = await listSpaces(viewerUserId, context.req.valid("query"));
|
|
3151
|
+
const states = await readSpaceStates(getDb(), spaces.map((space) => space.id), viewerUserId);
|
|
3152
|
+
return jsonResponse(spaceListSchema, { spaces: spaces.map((space) => ({
|
|
3153
|
+
...spaceReport(space),
|
|
3154
|
+
...states.get(space.id)
|
|
3155
|
+
})) });
|
|
3156
|
+
});
|
|
3157
|
+
app.post("/", requireViewer, validateRequest("json", createSpaceBodySchema, "Invalid request body."), async (context) => {
|
|
3158
|
+
const body = context.req.valid("json");
|
|
3159
|
+
const space = await createSpace({
|
|
3160
|
+
creatorUserId: context.get("viewer").id,
|
|
3161
|
+
name: body.name,
|
|
3162
|
+
description: body.description ?? null,
|
|
3163
|
+
visibility: body.visibility
|
|
3164
|
+
});
|
|
3165
|
+
return jsonResponse(spaceSchema, spaceReport(space), { status: 201 });
|
|
3166
|
+
});
|
|
3167
|
+
app.get("/:spaceId", requireViewer, spaceParamsValidator, async (context) => spaceResponse(context.get("viewer").id, context.req.valid("param").spaceId));
|
|
3168
|
+
app.patch("/:spaceId", requireViewer, spaceParamsValidator, validateRequest("json", updateSpaceBodySchema, "Invalid request body."), async (context) => {
|
|
3169
|
+
const viewerUserId = context.get("viewer").id;
|
|
3170
|
+
const { spaceId } = context.req.valid("param");
|
|
3171
|
+
const { visibility, ...changes } = context.req.valid("json");
|
|
3172
|
+
if (visibility !== void 0) throwApiError(400, "A Space's visibility is set when it is created. Create a new Space for a different audience.");
|
|
3173
|
+
await requireMemberSpace(viewerUserId, spaceId);
|
|
3174
|
+
await updateSpace(spaceId, changes);
|
|
3175
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
3176
|
+
});
|
|
3177
|
+
return app;
|
|
2845
3178
|
}
|
|
2846
3179
|
// src/api/people/card.ts
|
|
2847
3180
|
const RECENT_DAYS = 30;
|
|
@@ -2945,7 +3278,7 @@ async function readPersonCard(email, viewer) {
|
|
|
2945
3278
|
}
|
|
2946
3279
|
// src/api/people/code.ts
|
|
2947
3280
|
/** Read person-scoped native code activity for one People profile. */
|
|
2948
|
-
async function readPeopleCode(email, cursor) {
|
|
3281
|
+
async function readPeopleCode(email, cursor, viewer) {
|
|
2949
3282
|
const subject = await findUserByEmail(email);
|
|
2950
3283
|
if (!subject) {
|
|
2951
3284
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2966,7 +3299,8 @@ async function readPeopleCode(email, cursor) {
|
|
|
2966
3299
|
}
|
|
2967
3300
|
return await readPersonCodeOverview({
|
|
2968
3301
|
cursor,
|
|
2969
|
-
userId: subject.id
|
|
3302
|
+
userId: subject.id,
|
|
3303
|
+
viewer
|
|
2970
3304
|
});
|
|
2971
3305
|
}
|
|
2972
3306
|
// src/api/people/list.query.ts
|
|
@@ -3070,8 +3404,10 @@ function rangeWindow(spend, conversations) {
|
|
|
3070
3404
|
}
|
|
3071
3405
|
/**
|
|
3072
3406
|
* Count active people and root Conversations in each bucket of each series,
|
|
3073
|
-
* from one read of the Turns since `since`. The
|
|
3074
|
-
*
|
|
3407
|
+
* from one read of the Turns since `since`. The Turns are grouped by bucket,
|
|
3408
|
+
* Identity, and Conversation before any join, so the joins and the counts
|
|
3409
|
+
* read a few rows for each Conversation, not one for each Turn. Six-hour
|
|
3410
|
+
* buckets roll up hour buckets.
|
|
3075
3411
|
*
|
|
3076
3412
|
* Each count is a hashed `DISTINCT` of (bucket, person) or (bucket, root)
|
|
3077
3413
|
* pairs, which costs less than sorting for `COUNT(DISTINCT)`.
|
|
@@ -3079,11 +3415,16 @@ function rangeWindow(spend, conversations) {
|
|
|
3079
3415
|
function activityRows(since, read) {
|
|
3080
3416
|
const utc = sql`(${metrics.occurredAt} AT TIME ZONE 'UTC')`;
|
|
3081
3417
|
const readBucket = sql`date_trunc(${sql.raw(`'${read}'`)}, ${utc})`;
|
|
3418
|
+
const bucketTurns = getDb().select({
|
|
3419
|
+
bucket: readBucket.as("turn_bucket"),
|
|
3420
|
+
identityId: sql`${metrics.actorIdentityId}`.as("turn_identity_id"),
|
|
3421
|
+
conversationId: sql`${metrics.conversationId}`.as("turn_conversation_id")
|
|
3422
|
+
}).from(metrics).where(and(eq(metrics.metric, "duration_ms"), gte(metrics.occurredAt, since))).groupBy(readBucket, metrics.actorIdentityId, metrics.conversationId).as("activity_bucket_turns");
|
|
3082
3423
|
const turns = getDb().$with("activity_turns").as(getDb().select({
|
|
3083
|
-
bucket:
|
|
3424
|
+
bucket: sql`${bucketTurns.bucket}`.as("activity_bucket"),
|
|
3084
3425
|
userId: sql`${juniorUsers.id}`.as("activity_user_id"),
|
|
3085
3426
|
rootConversationId: conversationRootId.as("activity_root_id")
|
|
3086
|
-
}).from(
|
|
3427
|
+
}).from(bucketTurns).innerJoin(juniorIdentities, eq(juniorIdentities.id, bucketTurns.identityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, bucketTurns.conversationId)).where(verifiedActorWhere()).groupBy(bucketTurns.bucket, juniorUsers.id, conversationRootId));
|
|
3087
3428
|
const unitCounts = (unit) => {
|
|
3088
3429
|
const bucket = unit === "six_hour" ? sql`date_trunc('day', ${turns.bucket}) + FLOOR(EXTRACT(HOUR FROM ${turns.bucket}) / 6) * INTERVAL '6 hours'` : sql`${turns.bucket}`;
|
|
3089
3430
|
const pairs = (kind, id) => getDb().selectDistinct({
|
|
@@ -3225,6 +3566,8 @@ async function readPeopleListFromSql() {
|
|
|
3225
3566
|
* gets the same list, so one cached copy serves them all.
|
|
3226
3567
|
*/
|
|
3227
3568
|
const readPeopleList = createCachedReport({
|
|
3569
|
+
freshMs: 9e5,
|
|
3570
|
+
keepMs: 6048e5,
|
|
3228
3571
|
key: "people-list",
|
|
3229
3572
|
read: readPeopleListFromSql,
|
|
3230
3573
|
refreshFailedEvent: "people_list.refresh.failed",
|
|
@@ -3240,7 +3583,7 @@ async function readPeoplePluginReports(args) {
|
|
|
3240
3583
|
reports: [],
|
|
3241
3584
|
source: "plugins"
|
|
3242
3585
|
});
|
|
3243
|
-
const { getPluginProfileReports } = await import("./
|
|
3586
|
+
const { getPluginProfileReports } = await import("./db-DhzvUY23.js").then((n) => n.W);
|
|
3244
3587
|
return pluginOperationalReportFeedSchema.parse({
|
|
3245
3588
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3246
3589
|
reports: await getPluginProfileReports({
|
|
@@ -3259,7 +3602,7 @@ function emptyProfile(email, nowMs) {
|
|
|
3259
3602
|
start.setUTCDate(start.getUTCDate() - 364);
|
|
3260
3603
|
return {
|
|
3261
3604
|
activityDays: activityDays(/* @__PURE__ */ new Map(), nowMs),
|
|
3262
|
-
activityHours: activityHours(/* @__PURE__ */ new Map(), nowMs),
|
|
3605
|
+
activityHours: activityHours$1(/* @__PURE__ */ new Map(), nowMs),
|
|
3263
3606
|
activitySixHours: activitySixHours(/* @__PURE__ */ new Map(), nowMs),
|
|
3264
3607
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3265
3608
|
locations: [],
|
|
@@ -3304,7 +3647,7 @@ function channelExpression(table) {
|
|
|
3304
3647
|
}
|
|
3305
3648
|
function locationLabel(row) {
|
|
3306
3649
|
if (row.surface !== "slack") return surfaceLabel(row.surface);
|
|
3307
|
-
if (row.
|
|
3650
|
+
if (row.visibility !== "public") return "Private Conversation";
|
|
3308
3651
|
return slackLocationLabel({
|
|
3309
3652
|
channel: row.channel || void 0,
|
|
3310
3653
|
channelName: row.channelName ?? void 0
|
|
@@ -3360,7 +3703,7 @@ function rootBucketRows(args) {
|
|
|
3360
3703
|
date: sql`TO_CHAR(${buckets.bucket}, ${sql.raw(`'${format}'`)})`,
|
|
3361
3704
|
durationMs: sql`COALESCE(sum(${buckets.durationMs}), 0)::double precision`,
|
|
3362
3705
|
failed: sql`(count(*) FILTER (
|
|
3363
|
-
WHERE ${buckets.isLastTurn} AND ${
|
|
3706
|
+
WHERE ${buckets.isLastTurn} AND ${turnRoot.stoppedAt} IS NULL AND ${conversationTurnFailedSql(turnRoot)}
|
|
3364
3707
|
))::integer`,
|
|
3365
3708
|
tokens: sql`sum(${buckets.tokens})::double precision`
|
|
3366
3709
|
}).from(buckets).innerJoin(turnRoot, eq(turnRoot.conversationId, buckets.rootConversationId)).where(sql`${buckets.bucket} >= (${args.since.toISOString()}::timestamptz AT TIME ZONE 'UTC')`).groupBy(buckets.bucket);
|
|
@@ -3394,10 +3737,10 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
3394
3737
|
getDb().select({
|
|
3395
3738
|
channel,
|
|
3396
3739
|
channelName: turnRoot.channelName,
|
|
3397
|
-
destinationVisibility: juniorDestinations.visibility,
|
|
3398
3740
|
surface,
|
|
3741
|
+
visibility: turnRoot.visibility,
|
|
3399
3742
|
...aggregate
|
|
3400
|
-
}).from(roots).innerJoin(turnRoot, personRootJoin(roots)).
|
|
3743
|
+
}).from(roots).innerJoin(turnRoot, personRootJoin(roots)).groupBy(channel, turnRoot.channelName, turnRoot.visibility, surface),
|
|
3401
3744
|
getDb().select({
|
|
3402
3745
|
surface,
|
|
3403
3746
|
...aggregate
|
|
@@ -3427,7 +3770,7 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
3427
3770
|
]);
|
|
3428
3771
|
return {
|
|
3429
3772
|
activityDays: activityDays(days, nowMs),
|
|
3430
|
-
activityHours: activityHours(hours, nowMs),
|
|
3773
|
+
activityHours: activityHours$1(hours, nowMs),
|
|
3431
3774
|
activitySixHours: activitySixHours(hours, nowMs),
|
|
3432
3775
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3433
3776
|
locations: statsItems(locations),
|
|
@@ -3573,6 +3916,110 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
|
|
|
3573
3916
|
windowStart: thirtyDayStart.toISOString()
|
|
3574
3917
|
};
|
|
3575
3918
|
}
|
|
3919
|
+
// src/api/people/user-search.query.ts
|
|
3920
|
+
const USER_SEARCH_TERMS = 4;
|
|
3921
|
+
/**
|
|
3922
|
+
* Split typed text into lowercase search terms. A leading `@` of a Slack
|
|
3923
|
+
* handle is not part of it.
|
|
3924
|
+
*/
|
|
3925
|
+
function userSearchTerms(query) {
|
|
3926
|
+
return query.toLowerCase().split(/\s+/).map((term) => term.replace(/^@+/, "")).filter(Boolean).slice(0, USER_SEARCH_TERMS);
|
|
3927
|
+
}
|
|
3928
|
+
/**
|
|
3929
|
+
* Find Users whose name, Slack name, Slack handle, or primary email holds
|
|
3930
|
+
* each word of the query. An exact match of a whole field ranks first, then
|
|
3931
|
+
* a field or a word of the name that starts with the query, then any other
|
|
3932
|
+
* match. Ties sort by name, then email, then User id, so the order is
|
|
3933
|
+
* stable. Users are people: Slack bots and service accounts have none.
|
|
3934
|
+
*/
|
|
3935
|
+
async function readUserSearchFromSql(args) {
|
|
3936
|
+
const terms = userSearchTerms(args.query);
|
|
3937
|
+
if (terms.length === 0) return [];
|
|
3938
|
+
const whole = terms.join(" ");
|
|
3939
|
+
const { target } = args;
|
|
3940
|
+
const db = getDb();
|
|
3941
|
+
const slack = alias(juniorIdentities, "user_search_slack");
|
|
3942
|
+
const slackJoin = and(eq(slack.userId, juniorUsers.id), slackPersonPredicate(slack), target.kind === "conversation" && target.slackTeamId ? eq(slack.providerTenantId, target.slackTeamId) : void 0);
|
|
3943
|
+
const name = sql`lower(coalesce(${juniorUsers.displayName}, ${slack.displayName}, ''))`;
|
|
3944
|
+
const handle = sql`lower(coalesce(${slack.handle}, ''))`;
|
|
3945
|
+
const email = juniorUsers.primaryEmailNormalized;
|
|
3946
|
+
const document = sql`(${name} || ' ' || lower(coalesce(${slack.displayName}, '')) || ' ' || ${handle} || ' ' || ${email})`;
|
|
3947
|
+
const exact = sql`(${name} = ${whole} or ${handle} = ${whole} or ${email} = ${whole} or split_part(${email}, '@', 1) = ${whole})`;
|
|
3948
|
+
const prefix = sql`(starts_with(${name}, ${whole}) or starts_with(${handle}, ${whole}) or starts_with(${email}, ${whole}) or strpos(' ' || ${name}, ' ' || ${whole}) > 0)`;
|
|
3949
|
+
const rank = sql`case when ${exact} then 0 when ${prefix} then 1 else 2 end`;
|
|
3950
|
+
const base = db.selectDistinctOn([juniorUsers.id], {
|
|
3951
|
+
email: juniorUsers.primaryEmail,
|
|
3952
|
+
emailNormalized: email,
|
|
3953
|
+
fullName: sql`coalesce(${juniorUsers.displayName}, ${slack.displayName})`.as("full_name"),
|
|
3954
|
+
rank: rank.as("rank"),
|
|
3955
|
+
slackUserId: slack.providerSubjectId,
|
|
3956
|
+
slackUserName: slack.handle,
|
|
3957
|
+
sortName: name.as("sort_name"),
|
|
3958
|
+
userId: juniorUsers.id
|
|
3959
|
+
}).from(juniorUsers);
|
|
3960
|
+
const matches = (target.kind === "conversation" ? base.innerJoin(slack, slackJoin) : base.leftJoin(slack, slackJoin)).where(and(...terms.map((term) => sql`strpos(${document}, ${term}) > 0`))).orderBy(juniorUsers.id, asc(rank), asc(slack.id)).as("user_search_matches");
|
|
3961
|
+
const rows = await db.select({
|
|
3962
|
+
email: matches.email,
|
|
3963
|
+
fullName: matches.fullName,
|
|
3964
|
+
isMember: memberSql(db, target, matches.userId).as("is_member"),
|
|
3965
|
+
slackUserId: matches.slackUserId,
|
|
3966
|
+
slackUserName: matches.slackUserName,
|
|
3967
|
+
userId: matches.userId
|
|
3968
|
+
}).from(matches).orderBy(asc(matches.rank), asc(matches.sortName), asc(matches.emailNormalized), asc(matches.userId)).limit(args.limit);
|
|
3969
|
+
const avatars = await readUserAvatarUrls(db, rows.map((row) => row.userId));
|
|
3970
|
+
return rows.map((row) => {
|
|
3971
|
+
const fullName = row.fullName?.trim();
|
|
3972
|
+
const avatarUrl = avatars.get(row.userId);
|
|
3973
|
+
return {
|
|
3974
|
+
email: row.email,
|
|
3975
|
+
userId: row.userId,
|
|
3976
|
+
...fullName ? { fullName } : void 0,
|
|
3977
|
+
...row.slackUserName ? { slackUserName: row.slackUserName } : void 0,
|
|
3978
|
+
...target.kind === "conversation" && row.slackUserId ? { slackUserId: row.slackUserId } : void 0,
|
|
3979
|
+
...avatarUrl ? { avatarUrl } : void 0,
|
|
3980
|
+
...row.isMember ? { isMember: true } : void 0
|
|
3981
|
+
};
|
|
3982
|
+
});
|
|
3983
|
+
}
|
|
3984
|
+
/** SQL: the User is already a Member of the Space or a Participant. */
|
|
3985
|
+
function memberSql(db, target, userId) {
|
|
3986
|
+
if (target.kind === "space") return sql`${exists(db.select({ userId: juniorSpaceMembers.userId }).from(juniorSpaceMembers).where(and(eq(juniorSpaceMembers.spaceId, target.spaceId), eq(juniorSpaceMembers.userId, userId))))}`;
|
|
3987
|
+
const participants = juniorConversationParticipants;
|
|
3988
|
+
return sql`${exists(db.select({ userId: participants.userId }).from(participants).where(and(eq(participants.rootConversationId, target.rootConversationId), eq(participants.userId, userId))))}`;
|
|
3989
|
+
}
|
|
3990
|
+
// src/api/people/user-search.ts
|
|
3991
|
+
/**
|
|
3992
|
+
* Find Users to add to a Space or a Conversation. The viewer must be able
|
|
3993
|
+
* to read it, so who is a member does not leak; otherwise it looks
|
|
3994
|
+
* missing. The Users are those of this install, which is the tenant of
|
|
3995
|
+
* every Space and dashboard Conversation. A Conversation in a Slack
|
|
3996
|
+
* workspace narrows them to that workspace. Whether the viewer may add
|
|
3997
|
+
* them stays with the route that adds them.
|
|
3998
|
+
*/
|
|
3999
|
+
async function searchUsersForViewer(viewer, query) {
|
|
4000
|
+
return await readUserSearchFromSql({
|
|
4001
|
+
limit: query.limit,
|
|
4002
|
+
query: query.q,
|
|
4003
|
+
target: await readUserSearchTarget(viewer, query)
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
async function readUserSearchTarget(viewer, query) {
|
|
4007
|
+
if (query.spaceId) {
|
|
4008
|
+
await requireSpace(viewer.id, query.spaceId);
|
|
4009
|
+
return {
|
|
4010
|
+
kind: "space",
|
|
4011
|
+
spaceId: query.spaceId
|
|
4012
|
+
};
|
|
4013
|
+
}
|
|
4014
|
+
const conversationId = query.conversationId;
|
|
4015
|
+
const access = (await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId);
|
|
4016
|
+
if (!access?.canViewPrivateContent || !access.rootConversationId) throwApiError(404, "Conversation not found.");
|
|
4017
|
+
return {
|
|
4018
|
+
kind: "conversation",
|
|
4019
|
+
rootConversationId: access.rootConversationId,
|
|
4020
|
+
slackTeamId: readableSlackTeamId(access)
|
|
4021
|
+
};
|
|
4022
|
+
}
|
|
3576
4023
|
// src/api/people/routes.ts
|
|
3577
4024
|
/** Create the HTTP routes owned by the People API. */
|
|
3578
4025
|
function createPeopleRoutes(options) {
|
|
@@ -3596,6 +4043,7 @@ function createPeopleRoutes(options) {
|
|
|
3596
4043
|
const slackTeamId = conversationId ? readableSlackTeamId((await readConversationAccessFromSql(getDb(), [conversationId], context.get("viewer"))).get(conversationId)) : void 0;
|
|
3597
4044
|
return jsonResponse(peopleSearchReportSchema, { people: await readPeopleSearchFromSql(q, slackTeamId) });
|
|
3598
4045
|
});
|
|
4046
|
+
app.get("/user-search", requireViewer, validateRequest("query", userSearchQuerySchema, "Invalid search query."), async (context) => jsonResponse(userSearchReportSchema, { users: await searchUsersForViewer(context.get("viewer"), context.req.valid("query")) }));
|
|
3599
4047
|
app.get("/:email/plugin-reports", requireViewer, validateRequest("param", personParamsSchema, "Invalid route parameters."), async (context) => {
|
|
3600
4048
|
const { email } = context.req.valid("param");
|
|
3601
4049
|
const viewer = context.get("viewer");
|
|
@@ -3611,7 +4059,7 @@ function createPeopleRoutes(options) {
|
|
|
3611
4059
|
app.get("/:email/code", validateRequest("param", personParamsSchema, "Invalid route parameters."), validateRequest("query", personCodeQuerySchema, "Invalid code query."), async (context) => {
|
|
3612
4060
|
const { email } = context.req.valid("param");
|
|
3613
4061
|
const { cursor } = context.req.valid("query");
|
|
3614
|
-
return jsonResponse(codePersonReportSchema, await readPeopleCode(email, cursor));
|
|
4062
|
+
return jsonResponse(codePersonReportSchema, await readPeopleCode(email, cursor, context.get("viewer")));
|
|
3615
4063
|
});
|
|
3616
4064
|
app.get("/:email", validateRequest("param", personParamsSchema, "Invalid route parameters."), async (context) => {
|
|
3617
4065
|
const { email } = context.req.valid("param");
|
|
@@ -3899,7 +4347,7 @@ async function searchTodosForViewer(viewer, query, limit) {
|
|
|
3899
4347
|
const candidates = db.select({
|
|
3900
4348
|
conversationId: todos.conversationId,
|
|
3901
4349
|
id: todos.id
|
|
3902
|
-
}).from(todos).innerJoin(conversation, eq(conversation.conversationId, todos.conversationId)).innerJoin(juniorConversations, and(eq(juniorConversations.conversationId, conversation.rootConversationId), eq(juniorConversations.rootConversationId, juniorConversations.conversationId), isNull(juniorConversations.parentConversationId))).
|
|
4350
|
+
}).from(todos).innerJoin(conversation, eq(conversation.conversationId, todos.conversationId)).innerJoin(juniorConversations, and(eq(juniorConversations.conversationId, conversation.rootConversationId), eq(juniorConversations.rootConversationId, juniorConversations.conversationId), isNull(juniorConversations.parentConversationId))).where(and(or(prefixMatch(todoSearchDocument(todos), query), fuzzyMatch(todoFuzzyTitle(todos), query)), or(isNotNull(conversation.parentConversationId), eq(conversation.rootConversationId, conversation.conversationId)), rootVisibleToViewer(viewer.id))).orderBy(desc(todos.updatedAt), desc(todos.conversationId), desc(todos.id)).limit(200).as("todo_candidates");
|
|
3903
4351
|
const todo = alias(juniorTodos, "todo");
|
|
3904
4352
|
const document = todoSearchDocument(todo);
|
|
3905
4353
|
const title = todoFuzzyTitle(todo);
|
|
@@ -5130,10 +5578,11 @@ function inboxItemPayload(item, viewer, roots, mentions, related, wake) {
|
|
|
5130
5578
|
const todo = inboxItemTodo(item);
|
|
5131
5579
|
return {
|
|
5132
5580
|
...root ? { addedByLabel: root.label } : void 0,
|
|
5133
|
-
assignedToEveryone: item
|
|
5581
|
+
assignedToEveryone: isInboxItemForEveryone(item),
|
|
5134
5582
|
assignees: item.assignees,
|
|
5135
5583
|
body: item.body,
|
|
5136
5584
|
canAct: canActOnInboxItem(item, viewer.id),
|
|
5585
|
+
canAnswer: canAnswerInboxItem(item, viewer.id),
|
|
5137
5586
|
canTake: canActOnInboxItem(item, viewer.id) && !isOnlyAssignee(item, viewer.id),
|
|
5138
5587
|
conversationIds: item.conversationIds,
|
|
5139
5588
|
createdAt: item.createdAt.toISOString(),
|
|
@@ -5153,6 +5602,7 @@ function inboxItemPayload(item, viewer, roots, mentions, related, wake) {
|
|
|
5153
5602
|
...item.closedBy ? { closedBy: item.closedBy } : void 0,
|
|
5154
5603
|
...mentions.length > 0 ? { mentions: [...mentions] } : void 0,
|
|
5155
5604
|
...related && (related.items.length > 0 || related.conversationIds.length > 0) ? { related } : void 0,
|
|
5605
|
+
...item.dedupeKey.startsWith("reply:") ? { replyNotice: true } : void 0,
|
|
5156
5606
|
...item.request ? { request: item.request } : void 0,
|
|
5157
5607
|
...item.subject ? { subject: subjectPayload(item.subject) } : void 0,
|
|
5158
5608
|
...todo ? { todoId: todo.id } : void 0,
|
|
@@ -5516,7 +5966,7 @@ function readDescriptionText(home) {
|
|
|
5516
5966
|
}
|
|
5517
5967
|
/** Read discovered skills for runtime diagnostics and the Automation editor. */
|
|
5518
5968
|
async function readSkillReports() {
|
|
5519
|
-
const { discoverSkills } = await import("./skills-
|
|
5969
|
+
const { discoverSkills } = await import("./skills-DgJ9GBPR.js").then((n) => n.s);
|
|
5520
5970
|
const skills = await discoverSkills();
|
|
5521
5971
|
return skillReportsSchema.parse(skills.map((skill) => ({
|
|
5522
5972
|
name: skill.name,
|
|
@@ -5530,7 +5980,7 @@ async function readSkillReports() {
|
|
|
5530
5980
|
* what the skill tells Junior. Returns null when no skill has that name.
|
|
5531
5981
|
*/
|
|
5532
5982
|
async function readSkillDetailReport(name) {
|
|
5533
|
-
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-
|
|
5983
|
+
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-DgJ9GBPR.js").then((n) => n.s);
|
|
5534
5984
|
const skill = findSkillByName(name, await discoverSkills());
|
|
5535
5985
|
if (!skill) return null;
|
|
5536
5986
|
const parsed = parseSkillFile(await fs.readFile(path.join(skill.skillPath, "SKILL.md"), "utf8"), skill.name);
|
|
@@ -5545,7 +5995,7 @@ async function readSkillDetailReport(name) {
|
|
|
5545
5995
|
}
|
|
5546
5996
|
/** Read safe configured plugin metadata for authenticated runtime diagnostics. */
|
|
5547
5997
|
async function readPlugins() {
|
|
5548
|
-
const { pluginCatalogRuntime } = await import("./
|
|
5998
|
+
const { pluginCatalogRuntime } = await import("./db-DhzvUY23.js").then((n) => n.Ar);
|
|
5549
5999
|
return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
5550
6000
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
5551
6001
|
description: plugin.manifest.description,
|
|
@@ -5556,8 +6006,8 @@ async function readPlugins() {
|
|
|
5556
6006
|
/** Read authenticated runtime discovery data. */
|
|
5557
6007
|
async function readRuntimeInfoReport() {
|
|
5558
6008
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
5559
|
-
import("./package-discovery-
|
|
5560
|
-
import("./
|
|
6009
|
+
import("./package-discovery-BI6T_RkD.js").then((n) => n.r),
|
|
6010
|
+
import("./db-DhzvUY23.js").then((n) => n.Ar),
|
|
5561
6011
|
readPlugins(),
|
|
5562
6012
|
readSkillReports()
|
|
5563
6013
|
]);
|
|
@@ -5574,7 +6024,7 @@ async function readRuntimeInfoReport() {
|
|
|
5574
6024
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
5575
6025
|
async function readPluginOperationalReportFeed() {
|
|
5576
6026
|
const nowMs = Date.now();
|
|
5577
|
-
const { getPluginOperationalReports } = await import("./
|
|
6027
|
+
const { getPluginOperationalReports } = await import("./db-DhzvUY23.js").then((n) => n.W);
|
|
5578
6028
|
return pluginOperationalReportFeedSchema.parse({
|
|
5579
6029
|
source: "plugins",
|
|
5580
6030
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -5618,11 +6068,15 @@ function createJuniorApi(options = {}) {
|
|
|
5618
6068
|
app.route("/api/cache-warming", createCacheWarmingRoutes());
|
|
5619
6069
|
app.route("/api/gateway-providers", createGatewayProviderRoutes());
|
|
5620
6070
|
app.route("/api/images", createImageRoutes());
|
|
5621
|
-
app.route("/api/lead", createLeadRoutes());
|
|
5622
6071
|
app.route("/api/objects", createObjectRoutes());
|
|
5623
6072
|
app.route("/api/people", createPeopleRoutes({ waitUntil: waitUntil$1 }));
|
|
5624
6073
|
app.route("/api/locations", createLocationRoutes());
|
|
5625
6074
|
app.route("/api/search", createSearchRoutes());
|
|
6075
|
+
app.route("/api/spaces", createSpaceRoutes());
|
|
6076
|
+
app.route("/api/spaces", createSpaceArchiveRoutes({ queue }));
|
|
6077
|
+
app.route("/api/spaces", createSpaceMemberRoutes());
|
|
6078
|
+
app.route("/api/spaces", createSpaceConfigurationRoutes());
|
|
6079
|
+
app.route("/api/spaces", createSpaceLeadRoutes());
|
|
5626
6080
|
app.route("/api/user-pages", createUserPageRoutes());
|
|
5627
6081
|
app.route("/api/user-customization", createUserCustomizationRoutes());
|
|
5628
6082
|
app.route("/api/automations", createAutomationRoutes());
|