@sentry/junior 0.313.0 → 0.315.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-mt7K6dPh.js → adapter-context-BlSGE44V.js} +46 -7
- package/dist/{admin-Cyhb4TwZ.js → admin-5jUYY46p.js} +1 -1
- package/dist/agent-runner-C7GNLRB6.js +23438 -0
- package/dist/agent-update-delivery-BNEYQsAf.js +149 -0
- package/dist/api/schema.d.ts +9500 -2
- package/dist/api/schema.js +5 -7
- package/dist/api.d.ts +2 -3
- package/dist/api.js +1172 -371
- package/dist/{app-DA8-hCMj.d.ts → app-D_bAXRDe.d.ts} +312 -48
- package/dist/app.d.ts +2 -2
- package/dist/app.js +305 -184
- package/dist/change-record-Bqsa5ZXE.d.ts +175 -0
- package/dist/chat-core-engine-CxkwRpn9.js +123 -0
- package/dist/child-message--2G3Ft26.js +19 -0
- package/dist/cli/chat.d.ts +4 -1
- package/dist/cli/chat.js +40 -25
- package/dist/cli/check.js +4 -4
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +4 -5
- 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 +68 -97
- package/dist/{continue-in-slack-CxyFzdlF.js → continue-in-slack-BGKjIdFp.js} +3 -7
- package/dist/{conversation-feed-BEXLD3Me.js → conversation-feed-Sl8lKKmR.js} +22 -2
- package/dist/{conversation-turn-B35eu0uz.js → conversation-turn-BoLK9i6g.js} +514 -83
- package/dist/create-BOycVH9h.js +213 -0
- package/dist/{credential-sync-DWTOEQrm.js → credential-sync-Mn4OdkEh.js} +10 -18
- package/dist/db-BpxcYXfD.d.ts +2 -0
- package/dist/{credentialed-Dyv8b-lu.js → db-DXTOYRzR.js} +22220 -9334
- package/dist/deployment-CG3TchWh.js +51 -0
- package/dist/direct-url-BYgYfuIy.js +22 -0
- package/dist/engine-context-dyWlfNdD.js +1817 -0
- package/dist/{html-DidUcRhI.js → html-CfXEwl_h.js} +2 -7
- package/dist/instrumentation.js +3 -3
- package/dist/job-runner-CySgpi9v.js +1131 -0
- package/dist/{lineage-BXplQAVH.js → lineage-tRTOcrsL.js} +1 -2
- package/dist/{list-DyIyReSV.js → list-DXBz8SYL.js} +610 -173
- package/dist/local-server-CpnGhYml.js +276 -0
- package/dist/{logging-DNt-qOIO.js → logging-czs0nqLC.js} +2 -45
- package/dist/{turn-membership-DTR3SaKD.js → mailbox-turn-79Nv1JXv.js} +4153 -559
- package/dist/markers-CE0HMXWT.js +67 -0
- package/dist/{media-B0pZJ0bG.js → media-Cr9pGkzr.js} +701 -41
- package/dist/{message-Z5YKC-Af.js → message-BTox2Cmb.js} +25 -36
- package/dist/{model-input-BhPJYdSV.js → model-input-IRGa98V7.js} +3 -3
- package/dist/nitro.d.ts +8 -4
- package/dist/nitro.js +106 -24
- package/dist/{oauth-callback-server-ByvDdcdY.js → oauth-callback-server-NXK7AlBp.js} +2 -2
- package/dist/{oauth-relay-D-kK0yoN.js → oauth-relay-6NBPSpFE.js} +1 -1
- package/dist/{package-discovery-DD9vencX.js → package-discovery-BI6T_RkD.js} +50 -1
- package/dist/parent-result-Dg6P6roR.js +323 -0
- package/dist/people-Cegp1Iwq.js +81 -0
- package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
- package/dist/{conversation-privacy-BrMiDN61.js → proxy-path-Dc-0jXGi.js} +16 -2
- package/dist/{resolve-CWtBNSKP.js → resolve-BUFkmxkT.js} +229 -4
- package/dist/result-DfATzX77.js +337 -0
- package/dist/{runner-CsZ_VRxp.js → runner-CmKP3inb.js} +7 -8
- package/dist/{sandbox-egress-signals-FbCk1FkN.js → sandbox-egress-signals-DYo5BsM7.js} +1 -1
- package/dist/{schema-DojR2uCL.js → schema-DrBMdPmv.js} +197 -20
- package/dist/{service-account-CDYb9hfX.js → service-account-CxTX7nnR.js} +4 -5
- package/dist/{skills-B0jP4whm.js → skills-BlHUDj7k.js} +4 -4
- package/dist/{slack-conversation-unfurl-D26t9kBC.js → slack-conversation-unfurl-Dhe3lB1U.js} +6 -10
- package/dist/{spawn-BjljgExZ.js → spawn-CfvlFdfz.js} +8 -17
- package/dist/start-conversation-Uh8Sk1EF.js +162 -0
- package/dist/system-prompt-table-CDCYVwqN.js +1169 -0
- package/dist/{task-runner--Ke8KSMf.js → task-runner-DcdQJd9e.js} +163 -55
- package/dist/{thread-context-B8exINEe.js → thread-context-DF5uDcWN.js} +7 -9
- package/dist/topic-CRYYBYp-.js +7 -0
- package/dist/transcript-BHhJVY0P.js +410 -0
- package/dist/turn-session-routing-GtetHsdO.js +1309 -0
- package/dist/turn-wake-um5Ubd4m.js +152 -0
- package/dist/user-customization-B27StpVQ.js +9 -0
- package/dist/{validation-Ce0qbMlT.js → validation-CJyuOPD2.js} +1 -1
- package/dist/{version-DFh4n9nr.js → version-Bhe7RPIe.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/virtual-module-BeKA_EII.js +12 -0
- package/dist/{worker-CDg9Lbpg.js → worker-D8PRgUqr.js} +3 -6
- 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/migration.sql +99 -0
- package/migrations/20261122204325_money_micro_usd_repair/snapshot.json +9 -0
- package/migrations/20261122204326_agent_config_backfill/migration.sql +34 -0
- package/migrations/20261122204326_agent_config_backfill/snapshot.json +143 -0
- package/migrations/20261122221456_inbox_item_deliveries/migration.sql +15 -0
- package/migrations/20261122221456_inbox_item_deliveries/snapshot.json +301 -0
- package/migrations/20261123155735_pg_trgm/migration.sql +2 -0
- package/migrations/20261123155735_pg_trgm/snapshot.json +9 -0
- package/migrations/20261123155739_search_indexes/migration.sql +4 -0
- package/migrations/20261123155739_search_indexes/snapshot.json +167 -0
- package/migrations/20261123172647_drop_legacy_archive_columns/migration.sql +4 -0
- package/migrations/20261123172647_drop_legacy_archive_columns/snapshot.json +9 -0
- package/migrations/20261123192506_memory_prefix_index/migration.sql +1 -0
- package/migrations/20261123192506_memory_prefix_index/snapshot.json +69 -0
- package/migrations/20261123201740_todo_search_indexes/migration.sql +2 -0
- package/migrations/20261123201740_todo_search_indexes/snapshot.json +89 -0
- package/migrations/20261123211505_todo_inbox_items/migration.sql +4 -0
- package/migrations/20261123211505_todo_inbox_items/snapshot.json +38 -0
- package/migrations/20261123214917_drop_code_urls/migration.sql +2 -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/package.json +17 -25
- package/skills/design-automation-skill/SKILL.md +3 -4
- package/dist/actor-BsBdxDXQ.js +0 -208
- package/dist/adapter-CYAvJzZS.js +0 -259
- package/dist/adapter-context-CVsHoVSf.js +0 -43
- package/dist/agent-runner-B5y9MsT-.js +0 -11295
- package/dist/background-compaction-queue-iZXadLV3.js +0 -206
- package/dist/catalog-runtime-kkE3hvCX.js +0 -6
- package/dist/config-CWbwKj0j.js +0 -2331
- package/dist/db-DYGcXYl3.d.ts +0 -274
- package/dist/db-PwSRzWWn.js +0 -3607
- package/dist/executor-CgWyWfYz.js +0 -1858
- package/dist/fan-out-Cod-yEHG.js +0 -10
- package/dist/history-CYstOMKX.js +0 -577
- package/dist/ingest-B0AggUEC.js +0 -7931
- package/dist/install-2urLLXNt.js +0 -228
- package/dist/proxy-path-BHYoKZdq.js +0 -15
- package/dist/registry-POH4bZC4.js +0 -1686
- package/dist/request-deadline-BUiRYQYj.js +0 -24
- package/dist/rule-DAxQY-1h.js +0 -20
- package/dist/schema-DBf18QPS.d.ts +0 -9339
- package/dist/service-account-o15pZWcJ.js +0 -931
- package/dist/start-conversation-DbVujrwO.js +0 -755
- package/dist/state-BTawTCme.js +0 -161
- package/dist/statuses-BKwqCPhj.js +0 -69
- package/dist/store-CjXrp-Up.js +0 -492
- package/dist/task-queue-Cwlatjz3.js +0 -90
- package/dist/vercel-queue-q4z8w5QO.js +0 -349
- package/dist/warmup-D5hzqTcp.js +0 -12257
- 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/_journal.json +0 -1126
- /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/dist/api.js
CHANGED
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { E 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 juniorConversationMetrics, F as codeChangeSearchDocument, G as slackPersonSearchDocument, H as juniorConversations, I as codeRepositorySearchDocument, K as juniorUsers, L as juniorCodeChanges, M as juniorConversationEvents, N as juniorApiTokens, R as juniorCodeRepositories, U as juniorIdentities, W as slackPersonPredicate, b as juniorAgentBindings, h as juniorInboxItems, p as juniorInboxItemConversations, q as juniorDestinations, x as juniorAgentInvocations } from "./executor-CgWyWfYz.js";
|
|
16
|
-
import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-CxyFzdlF.js";
|
|
17
|
-
import { f as parseSlackTeamId, u as parseSlackChannelId } from "./actor-BsBdxDXQ.js";
|
|
18
|
-
import { i as readLiveAttachment } from "./store-CjXrp-Up.js";
|
|
1
|
+
import { $ as getPlugins, $c as readViewerAvatarUrl, $f as cacheKeyPrefix, $i as getVercelConversationWorkQueue, $l as automationSearchDocument, Aa as createPluginCache, Af as botConfig, Ar as pluginCatalogRuntime, At as memoryDb, Cr as createUserTokenStore, Cs as conversationStatusSql, Dc as inboxItemForUser, Ds as conversationKindFromRow, Dt as contentVersion, Du as juniorUsers, Ec as canUserReadInboxItem, El as readConversationAccessFromSql, Eo as getDashboardSettingsLink, Et as REVALIDATED_READ_PATHS, Eu as slackPersonSearchDocument, Fd as automationEventCatalog, Fn as listWorkspaces, Ft as prefixMatch, Gn as hash, Hl as juniorTodos, I as escapeSlackMrkdwnText, Ic as isInboxItemForEveryone, Il as rootVisibleToViewer, In as listWorkspacesByRepository, It as prefixRank, Jc as findUserByEmail, Js as ownerConversationId, Kl as inboxItemFuzzyTitle, L as formatSlackLink, Lc as isOnlyAssignee, Ln as updateWorkspace, Lr as serviceAccountPlugins, Lt as rankSearchMatches, Mc as inboxItemReaderForUserInConversation, Mn as deleteWorkspace, Mr as disconnectServiceAccount, Mt as parseTypedQuery, N as loadConversationSlackTenantIds, Nc as inboxItemTodo, Nn as getWorkspace, Nr as finishServiceAccountSignIn, Nt as fuzzyMatch, Ot as contentVersionHeaders, Ou as juniorDestinations, Pc as inboxItemVisibleTo, Pr as getServiceAccountStatus, Pt as fuzzyRank, Qd as getStateAdapter, Qf as saveEnabledProviders, Ql as automationFuzzyTitle, Rn as WorkspaceValidationError, Rr as startServiceAccountSignIn, Rt as scoredSearchMatches, Sc as canActOnInboxItem, Si as createPluginEmbedder, Ss as conversationIsActiveSql, St as isPausedBySlack, Tl as createConversationAccessReader, To as getDashboardPersonLink, Tu as slackPersonPredicate, Ul as todoFuzzyTitle, Vs as getInboxItem, Wl as todoSearchDocument, Wn as create, Ws as inboxItemsNeedingUserVersionQuery, Wu as isAgentResourceType, Xf as readEnabledProviders, Yl as juniorInboxItemConversations, Yo as AutomationConflictError, Ys as searchInboxItems, Yu as cancelWatch, Zf as readServedProviders, Zl as juniorInboxItems, _t as listPushSubscriptions, a as getDb, ac as clearInboxWakeReasons, bi as workspaceRepoCheckoutPath, bl as readCachedUserByEmail, bo as getDashboardConversationLink, bs as conversationRangeColumns, bt as savePushSubscription, bu as juniorConversations, cc as inboxItemSnoozedBy, dc as settleInboxSnoozes, dt as readWebPushConfig, du as juniorApiTokens, el as resolveViewerUser, ep as createCache, et as getRegistrations, eu as juniorAutomations, fc as snoozeInboxItems, ft as sendPushNotificationToUser, gs as microUsdToUsd, gt as deletePushSubscription, gu as juniorCodeRepositories, hs as microUsdSql, ht as resolveNotificationTimezone, hu as juniorCodeChanges, i as getConversationStore, id as listWatches, il as identityAvatarUrl, ip as withLock, jc as inboxItemReaderForUser, jf as getChatConfig, jn as createWorkspace, jt as searchTypedMemories, ju as getEventCatalog, kl as readableSlackTeamId, kt as revalidateContent, la as createPluginAnnotations, lt as apiRoutePrefix, lu as juniorConversationMetrics, mc as unsnoozeInboxRow, mu as codeRepositorySearchDocument, nf as credentialContextForActor, nl as updateViewerDisplayName, no as postSlackMessage, o as getSqlExecutor, ol as readAvatarFetch, pc as snoozeTimerTrigger, pu as codeChangeSearchDocument, ql as inboxItemSearchDocument, ri as webActorUserIds, ru as juniorAgentBindings, sc as inboxItemInRow, sl as readUserAvatarUrls, ss as readAutomationTitlesByConversationId, tu as juniorAutomationRuns, ua as listConversationAnnotations, uc as readViewerInboxSnoozes, uu as juniorConversationEvents, vi as SANDBOX_RUNTIME, vs as usdToMicroUsdUnbiased, vt as readNotificationSchedule, wc as canAnswerInboxItem, wp as getAttachmentStorage, ws as conversationTurnFailedSql, wu as juniorIdentities, xf as parseSlackTeamId, xs as conversationUsageCostExpr, yf as parseSlackChannelId, ys as conversationAggregateColumns, yt as saveNotificationSchedule, zc as itemNeedsUser, zd as eventWatchUnavailable, zi as completeText, zs as countInboxItemsNeedingUserBySubject } from "./db-DXTOYRzR.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-czs0nqLC.js";
|
|
3
|
+
import { A as pauseConversationDelivery, Bt as readViewerAutomationExecutions, Ct as jsonResponse, Ht as readViewerAutomationSummary, It as updateViewerAutomation, Kt as AutomationEditError, Lt as ViewerTaskNotFoundError, M as AttachmentDownloadError, Mt as changeViewerAutomationLifecycle, N as readAttachmentContent, Nt as deleteViewerTask, O as canPauseConversationDelivery, P as previewOriginBelongsTo, Pt as readViewerAutomationEdit, Rt as collectionRowTitle, St as emptyResponse, Ut as readViewerAutomationVersions, Vt as readViewerAutomationRuns, Wt as readViewerAutomations, Xt as viewerAutomationCollection, Zt as SAVINGS_NAMESPACE, an as readStats, bt as inviteToConversation, cn as connectedState, in as addStats, j as resumeConversationDelivery, jt as activateViewerAutomationVersion, mt as reportConversationRead, on as breakerStates, p as createInboxItemShow, rn as savingsTotals, sn as closeBreaker, vt as listOwnedWatches, wt as throwApiError } from "./agent-runner-C7GNLRB6.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-Cr9pGkzr.js";
|
|
5
|
+
import { A as gatewayProvidersSchema, At as disconnectConnectionResponseSchema, B as disconnectServiceAccountResponseSchema, Bt as codeRepositoryParamsSchema, Ct as notificationSettingsSchema, D as inboxSnoozeSchema, Dt as connectionListSchema, E as inboxSnoozeResourceSchema, Et as testNotificationResponseSchema, F as cacheWarmingBreakerParamsSchema, Ft as codeChangeSearchReportSchema, G as searchQuerySchema, Gt as personCodeQuerySchema, H as serviceAccountParamsSchema, Ht as codeRepositoryReportSchema, I as cacheWarmingSavingsQuerySchema, J as createdPersonalTokenSchema, Jt as todoParamsSchema, K as searchReportSchema, Kt as conversationTodoSchema, L as cacheWarmingSavingsRefillResponseSchema, M as cacheHealthQuerySchema, N as cacheHealthReportSchema, O as inboxSnoozeSubjectSchema, Ot as connectionParamsSchema, P as cacheWarmingBreakerListSchema, Pt as codeChangeSearchQuerySchema, Q as revokePersonalTokenResponseSchema, Qt as watchParamsSchema, R as cacheWarmingSavingsReportSchema, Rt as codeOverviewReportSchema, S as inboxItemWaitingConversationsSchema, Sn as forkConversationResponseSchema, T as inboxSnoozeResourceQuerySchema, Tt as pushSubscriptionDeleteBodySchema, V as serviceAccountListSchema, Vt as codeRepositoryQuerySchema, W as startServiceAccountSignInResponseSchema, Y as personalTokenListSchema, Yt as todoStatusBodySchema, Z as personalTokenParamsSchema, Zt as conversationWatchesReportSchema, _ as inboxItemCountSchema, _n as createAttachmentUploadBodySchema, _t as locationDirectoryReportSchema, a as versionsSchema, an as attachObjectLinkResponseSchema, at as peopleSearchReportSchema, b as inboxItemParamsSchema, bn as createConversationMessageBodySchema, bt as activityHours$2, cn as conversationStatsReportSchema, ct as personalSpendReportSchema, d as workspaceListSchema, dn as conversationDeliveryBodySchema, en as conversationChildAgentsReportSchema, et as actorDirectoryReportSchema, f as workspaceParamsSchema, fn as conversationDeliveryResponseSchema, ft as leadSchema, g as inboxItemCountQuerySchema, gn as attachmentUploadSchema, gt as locationDetailReportSchema, h as inboxItemActionSchema, hn as attachmentUploadParamsSchema, i as versionsQuerySchema, in as attachObjectLinkBodySchema, it as peopleSearchQuerySchema, j as updateGatewayProvidersBodySchema, jt as startConnectionResponseSchema, k as inboxSnoozeWakesClearSchema, l as deleteWorkspaceResponseSchema, lt as addSpaceMemberBodySchema, m as workspaceSchema, mn as conversationCatchUpSchema, mt as spaceConfigurationSchema, n as VERSIONS_STREAM_HEADER, nn as continueConversationInSlackResponseSchema, nt as avatarParamsSchema, on as objectLinksQuerySchema, ot as personCardReportSchema, pn as conversationCatchUpBodySchema, q as createPersonalTokenBodySchema, qt as conversationTodosReportSchema, r as VERSIONS_STREAM_KEEPALIVE_EVENT, s as statsReportSchema, sn as objectLinksReportSchema, st as personParamsSchema, tn as continueConversationInSlackBodySchema, tt as actorProfileReportSchema, u as workspaceBodySchema, un as conversationOutlineSchema, ut as spaceMemberListSchema, v as inboxItemListQuerySchema, vn as acceptedConversationMessageSchema, vt as locationParamsSchema, w as inboxSnoozeCreateSchema, wt as pushSubscriptionBodySchema, x as inboxItemSchema, xn as forkConversationBodySchema, xt as activitySixHours$1, y as inboxItemListSchema, yn as createConversationBodySchema, yt as activityDays$1, z as closeCacheWarmingBreakerResponseSchema, zt as codePersonReportSchema } from "./schema-DrBMdPmv.js";
|
|
6
|
+
import { A as steerConversationPendingMessagesBodySchema, B as skillDetailReportSchema, H as skillReportsSchema, M as healthReportSchema, N as pluginOperationalReportFeedSchema, O as conversationPendingMessagesReportSchema, R as pluginsSchema, _ as reorderPinnedConversationsResponseSchema, a as conversationInviteResponseSchema, g as reorderPinnedConversationsBodySchema, i as conversationInviteBodySchema, j as steerConversationPendingMessagesResponseSchema, k as conversationUnchangedDetailWithMailboxSchema, n as conversationFeedSchema, t as conversationFeedQuerySchema, w as conversationDetailWithMailboxReportSchema, z as runtimeInfoReportSchema } from "./conversation-feed-Sl8lKKmR.js";
|
|
7
|
+
import { Ht as listTodos, In as isExperimentalFeatureEnabled, It as readUserCustomization, Lt as saveUserCustomization, Rr as createPluginEgress, Ut as setTodoStatusByUser, V as parseEmail, Wt as pushConversationInboxItemsNow, bn as steerWebPendingMessages, kn as addConversationNote, z as isAllowedDomain } from "./mailbox-turn-79Nv1JXv.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-GtetHsdO.js";
|
|
9
|
+
import { $ as readInboxItemForUser, $t as createViewerMcp, A as setConversationSubscriptionOperation, C as archiveDoneConversationsOperation, Ct as resolveObjectLinkNow, D as renameConversationOperation, E as pinConversationOperation, Et as guardedFetch, J as requireConversationPendingMessages, Jt as resolvePersonLink, M as setSpaceArchive, N as reorderPinnedConversations, O as setConversationAutoArchiveOperation, P as apiOperationHandler, Qt as readFirstHumanMessageTexts, S as archiveConversationOperation, St as readObjectLinkTypes, Tt as viewerCanViewPluginLink, X as InboxItemActionError, Y as resolveMentions, Yt as conversationRecordJoins, Z as actOnInboxItem, Zt as conversationSummaryFromStoredConversation, _ as appendConversationMessageForViewer, a as listWaitingConversations, at as readUserSettings, bt as OBJECT_LINK_TTL_MS, c as readConversationDetail, d as readConversationTreeMetricsFromSql, en as IMAGE_WIDTHS, f as conversationVersionsQuery, g as readConversationEvents, gt as startSavingsRefill, h as keepQuickQuestionForViewer, i as encodePageCursor, it as DEFAULT_USER_SETTINGS, j as stopConversationOperation, jt as getProductionSlackAdapter, k as setConversationSpaceOperation, l as readConversationAuxiliaryCostsFromSql, m as forkConversationForViewer, mt as readSavingsRefill, n as readConversationFeed, o as listedConversation, ot as updateUserSettings, p as readConversationDetailEtag, pt as scheduleInboxSnoozeTimer, r as decodePageCursor, s as notLeadConversation, t as conversationFeedVersionQuery, tn as decodeImageId, u as childAgentTotalsReport, v as createConversationForViewer, w as cancelQueuedMessagesOperation, wt as resolveObjectLinks, xt as readLinkObjectType, y as requireWebMessageConversation, yt as readHealthReport } from "./list-DXBz8SYL.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-DcdQJd9e.js";
|
|
11
|
+
import { t as runWithSlackInstallation } from "./adapter-context-BlSGE44V.js";
|
|
12
|
+
import { o as listChildAgents } from "./parent-result-Dg6P6roR.js";
|
|
13
|
+
import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-BGKjIdFp.js";
|
|
14
|
+
import { o as readSlackAttachmentSource } from "./start-conversation-Uh8Sk1EF.js";
|
|
19
15
|
import { u as sentry_exports } from "./sentry-CPbZjomA.js";
|
|
20
|
-
import { i as webActorUserIds } from "./state-BTawTCme.js";
|
|
21
|
-
import { H as steerWebPendingMessages, Lt as createPluginEgress } from "./turn-membership-DTR3SaKD.js";
|
|
22
|
-
import { i as getStateAdapter } from "./adapter-CYAvJzZS.js";
|
|
23
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";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import { o as getSandboxResources } from "./install-2urLLXNt.js";
|
|
31
|
-
import { t as getCachedSnapshot } from "./resolve-CWtBNSKP.js";
|
|
32
|
-
import { t as getVercelConversationWorkQueue } from "./vercel-queue-q4z8w5QO.js";
|
|
17
|
+
import { a as isConnectableProvider, c as startConnection, i as disconnectConnection, o as listConnections, t as escapeHtml, u as htmlCallbackResponse } from "./html-CfXEwl_h.js";
|
|
18
|
+
import { G as mapBounded, I as createPluginLogger } from "./transcript-BHhJVY0P.js";
|
|
19
|
+
import { D as listSpaceConfiguration } from "./job-runner-CySgpi9v.js";
|
|
20
|
+
import { n as userCustomizationSchema } from "./user-customization-B27StpVQ.js";
|
|
21
|
+
import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-BUFkmxkT.js";
|
|
22
|
+
import { t as readDirectDatabaseUrl } from "./direct-url-BYgYfuIy.js";
|
|
33
23
|
import { Hono } from "hono";
|
|
34
24
|
import * as z from "zod";
|
|
35
25
|
import path from "node:path";
|
|
@@ -39,6 +29,8 @@ import { and, asc, count as count$1, desc, eq, exists, gt, gte, inArray, isNotNu
|
|
|
39
29
|
import { alias, union } from "drizzle-orm/pg-core";
|
|
40
30
|
import fs from "node:fs/promises";
|
|
41
31
|
import { readFileSync } from "node:fs";
|
|
32
|
+
import { Client } from "@neondatabase/serverless";
|
|
33
|
+
import pg from "pg";
|
|
42
34
|
import { HTTPException } from "hono/http-exception";
|
|
43
35
|
import { bodyLimit } from "hono/body-limit";
|
|
44
36
|
import { waitUntil } from "@vercel/functions";
|
|
@@ -263,7 +255,8 @@ async function postSlackDetachNotice(args) {
|
|
|
263
255
|
/**
|
|
264
256
|
* Detach a root from its Location, or attach it again. Only a participant
|
|
265
257
|
* can change it, the same as rename. A mention in the Location attaches it
|
|
266
|
-
* again too. Each detach tells the Slack thread once.
|
|
258
|
+
* again too. Each detach tells the Slack thread once. Each change pushes
|
|
259
|
+
* the open items of the Conversation without the Slack card wait.
|
|
267
260
|
*/
|
|
268
261
|
async function setConversationDeliveryForViewer(viewer, conversationId, body) {
|
|
269
262
|
const conversation = (await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant ? await getConversationStore().get({ conversationId }) : void 0;
|
|
@@ -281,39 +274,10 @@ async function setConversationDeliveryForViewer(viewer, conversationId, body) {
|
|
|
281
274
|
location
|
|
282
275
|
})
|
|
283
276
|
}), "conversation.detach_notice.failed", { "app.conversation.id": conversationId });
|
|
284
|
-
|
|
277
|
+
if (detached) await pushConversationInboxItemsNow(conversationId);
|
|
278
|
+
} else if (await resumeConversationDelivery(conversationId)) await pushConversationInboxItemsNow(conversationId);
|
|
285
279
|
return { paused: body.paused };
|
|
286
280
|
}
|
|
287
|
-
// src/chat/conversations/sql/title.ts
|
|
288
|
-
/**
|
|
289
|
-
* Replace one Conversation's title. Returns the stored title, or undefined
|
|
290
|
-
* when the Conversation does not exist.
|
|
291
|
-
*
|
|
292
|
-
* recordActivity reads the title and writes it back under the mutation lock,
|
|
293
|
-
* so this write takes the same lock. A concurrent Turn cannot restore the old
|
|
294
|
-
* title.
|
|
295
|
-
*/
|
|
296
|
-
async function setConversationTitle(executor, conversationId, title) {
|
|
297
|
-
return await withConversationMutationLock(executor, conversationId, async () => {
|
|
298
|
-
const [row] = await executor.db().update(juniorConversations).set({
|
|
299
|
-
detailVersion: nextDetailVersion,
|
|
300
|
-
title
|
|
301
|
-
}).where(eq(juniorConversations.conversationId, conversationId)).returning({ title: juniorConversations.title });
|
|
302
|
-
return row?.title ?? void 0;
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
// src/api/conversations/rename.ts
|
|
306
|
-
/**
|
|
307
|
-
* Rename one conversation. The title is shared, so only a participant can
|
|
308
|
-
* change it, the same as pin and archive. Automatic titles are set once, so a
|
|
309
|
-
* later Turn keeps this title.
|
|
310
|
-
*/
|
|
311
|
-
async function renameConversation(viewer, conversationId, body) {
|
|
312
|
-
if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
|
|
313
|
-
const title = await setConversationTitle(getSqlExecutor(), conversationId, body.title);
|
|
314
|
-
if (!title) throwApiError(404, "Conversation not found.");
|
|
315
|
-
return { title };
|
|
316
|
-
}
|
|
317
281
|
// src/api/conversations/child-agents.ts
|
|
318
282
|
/**
|
|
319
283
|
* Load the direct child agents of one Conversation, or throw a standard API
|
|
@@ -672,7 +636,7 @@ async function readConversationOutline(conversationId, options = {}) {
|
|
|
672
636
|
seq: row.seq,
|
|
673
637
|
text,
|
|
674
638
|
...row.authorIdentityId && row.authorIdentityId !== "system" ? { actorIdentityId: row.authorIdentityId } : void 0,
|
|
675
|
-
...row
|
|
639
|
+
...reportParentAgentInput(row)
|
|
676
640
|
}];
|
|
677
641
|
});
|
|
678
642
|
let itemIndex = -1;
|
|
@@ -699,7 +663,9 @@ function readMessages(conversationId, role, ...filters) {
|
|
|
699
663
|
return getDb().select({
|
|
700
664
|
agentInvocationId: sql`${payload}->'meta'->>'agentInvocationId'`,
|
|
701
665
|
authorIdentityId: sql`coalesce(${payload}->>'authorIdentityId', ${juniorConversationEvents.actorIdentityId})`,
|
|
666
|
+
authorUserId: sql`${payload}->'meta'->'author'->>'userId'`,
|
|
702
667
|
createdAt: juniorConversationEvents.createdAt,
|
|
668
|
+
messageId: sql`${payload}->>'messageId'`,
|
|
703
669
|
seq: juniorConversationEvents.seq,
|
|
704
670
|
text: sql`coalesce(left(${payload}->>'text', ${200}), '')`
|
|
705
671
|
}).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), sql`${juniorConversationEvents.type} = 'message'`, sql`${payload}->>'role' = ${role}`, ...filters)).orderBy(asc(juniorConversationEvents.seq));
|
|
@@ -733,13 +699,12 @@ async function steerConversationPendingMessagesForViewer(viewer, conversationId,
|
|
|
733
699
|
}
|
|
734
700
|
// src/api/cached-report.ts
|
|
735
701
|
const CACHE_NAMESPACE = "core";
|
|
736
|
-
const
|
|
737
|
-
const KEEP_MS = 36e5;
|
|
738
|
-
const RELOAD_WAIT_MS = 1e4;
|
|
702
|
+
const RELOAD_WAIT_MS = 3e4;
|
|
739
703
|
/**
|
|
740
704
|
* Create a reader for one report that is the same for every viewer. A cached
|
|
741
|
-
* report is served
|
|
742
|
-
* starts a background refresh.
|
|
705
|
+
* report is served until `keepMs` after its read. After `freshMs`, a request
|
|
706
|
+
* also starts a background refresh. With no cached report, one request reads
|
|
707
|
+
* it and the others wait for that read.
|
|
743
708
|
*/
|
|
744
709
|
function createCachedReport(source) {
|
|
745
710
|
const cachedSchema = z.object({
|
|
@@ -747,9 +712,9 @@ function createCachedReport(source) {
|
|
|
747
712
|
report: source.schema
|
|
748
713
|
}).strict();
|
|
749
714
|
const load = async () => ({
|
|
750
|
-
ttlMs:
|
|
715
|
+
ttlMs: source.keepMs,
|
|
751
716
|
value: {
|
|
752
|
-
refreshAtMs: Date.now() +
|
|
717
|
+
refreshAtMs: Date.now() + source.freshMs,
|
|
753
718
|
report: source.schema.parse(await source.read())
|
|
754
719
|
}
|
|
755
720
|
});
|
|
@@ -774,16 +739,11 @@ function createCachedReport(source) {
|
|
|
774
739
|
}, { "cache.key": [source.key] });
|
|
775
740
|
return ({ waitUntil }) => withSpan(source.key, "cache.get", {}, async (setSpanAttributes) => {
|
|
776
741
|
const state = getStateAdapter();
|
|
777
|
-
|
|
778
|
-
const
|
|
779
|
-
hit = false;
|
|
780
|
-
return load();
|
|
781
|
-
};
|
|
782
|
-
const parsed = cachedSchema.safeParse(await createCache(state, CACHE_NAMESPACE).getOrLoad(source.key, loadOnMiss));
|
|
742
|
+
const parsed = cachedSchema.safeParse(await createCache(state, CACHE_NAMESPACE).get(source.key));
|
|
743
|
+
const hit = parsed.success;
|
|
783
744
|
let cached;
|
|
784
745
|
if (parsed.success) cached = parsed.data;
|
|
785
746
|
else {
|
|
786
|
-
hit = false;
|
|
787
747
|
const reloaded = await reload(state, () => true, RELOAD_WAIT_MS);
|
|
788
748
|
cached = reloaded.acquired ? reloaded.value : (await load()).value;
|
|
789
749
|
}
|
|
@@ -793,7 +753,7 @@ function createCachedReport(source) {
|
|
|
793
753
|
"cache.hit": hit,
|
|
794
754
|
"cache.item_size": Buffer.byteLength(JSON.stringify(cached)),
|
|
795
755
|
"app.cache.stale": stale,
|
|
796
|
-
"app.cache.age_ms": now - (cached.refreshAtMs -
|
|
756
|
+
"app.cache.age_ms": now - (cached.refreshAtMs - source.freshMs)
|
|
797
757
|
});
|
|
798
758
|
if (stale) waitUntil(() => refresh(state));
|
|
799
759
|
return cached.report;
|
|
@@ -870,6 +830,235 @@ async function readConversationMetricBuckets(db, options) {
|
|
|
870
830
|
value: sql`sum(${juniorConversationMetrics.value})::double precision`
|
|
871
831
|
}).from(juniorConversationMetrics).where(and(gte(juniorConversationMetrics.occurredAt, options.start), lte(juniorConversationMetrics.occurredAt, options.end))).groupBy(date, juniorConversationMetrics.metric).orderBy(asc(date), asc(juniorConversationMetrics.metric));
|
|
872
832
|
}
|
|
833
|
+
const metrics$2 = juniorConversationMetrics;
|
|
834
|
+
/** Sum the values of one metric among grouped metric rows. */
|
|
835
|
+
function metricSum(metric) {
|
|
836
|
+
return sql`sum(${metrics$2.value}) FILTER (WHERE ${metrics$2.metric} = ${metric})`;
|
|
837
|
+
}
|
|
838
|
+
/** Sum the spend of Turn metric rows read straight from their table. */
|
|
839
|
+
const turnMetricColumns = { costMicroUsd: microUsdSql(metricSum("cost_micro_usd")) };
|
|
840
|
+
/** Root Conversation of a person's Turn, for status, location, and surface. */
|
|
841
|
+
const turnRoot = alias(juniorConversations, "person_turn_root");
|
|
842
|
+
/** Root of a Conversation row: itself when it has no root. */
|
|
843
|
+
const conversationRootId = sql`coalesce(
|
|
844
|
+
${juniorConversations.rootConversationId},
|
|
845
|
+
${juniorConversations.conversationId}
|
|
846
|
+
)`;
|
|
847
|
+
/**
|
|
848
|
+
* Read one row per verified person and root Conversation where they ran a
|
|
849
|
+
* Turn, over all time: the Turn range and the duration and token totals.
|
|
850
|
+
*
|
|
851
|
+
* The person and metric filters apply to the metric rows, and the rows are
|
|
852
|
+
* grouped before any join. Every Run writes a `duration_ms` row, so these
|
|
853
|
+
* two metrics mark every Turn.
|
|
854
|
+
*/
|
|
855
|
+
function personRoots(email) {
|
|
856
|
+
const verifiedIdentities = getDb().select({ id: juniorIdentities.id }).from(juniorIdentities).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(verifiedActorWhere(email));
|
|
857
|
+
const conversations = getDb().select({
|
|
858
|
+
identityId: sql`${metrics$2.actorIdentityId}`.as("turn_identity_id"),
|
|
859
|
+
conversationId: sql`${metrics$2.conversationId}`.as("turn_conversation_id"),
|
|
860
|
+
firstAt: sql`min(${metrics$2.occurredAt})`.as("turn_first_at"),
|
|
861
|
+
lastAt: sql`max(${metrics$2.occurredAt})`.as("turn_last_at"),
|
|
862
|
+
durationMs: metricSum("duration_ms").as("turn_duration_ms"),
|
|
863
|
+
tokens: metricSum("total_tokens").as("turn_tokens")
|
|
864
|
+
}).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");
|
|
865
|
+
return getDb().select({
|
|
866
|
+
userId: sql`${juniorIdentities.userId}`.as("root_user_id"),
|
|
867
|
+
rootConversationId: conversationRootId.as("person_root_id"),
|
|
868
|
+
firstAt: sql`min(${conversations.firstAt})`.as("root_first_at"),
|
|
869
|
+
lastAt: sql`max(${conversations.lastAt})`.as("root_last_at"),
|
|
870
|
+
durationMs: sql`sum(${conversations.durationMs})`.as("root_duration_ms"),
|
|
871
|
+
tokens: sql`sum(${conversations.tokens})`.as("root_tokens"),
|
|
872
|
+
slackUserId: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END)`.as("root_slack_user_id"),
|
|
873
|
+
slackUserName: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END)`.as("root_slack_user_name")
|
|
874
|
+
}).from(conversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, conversations.identityId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, conversations.conversationId)).groupBy(juniorIdentities.userId, conversationRootId).as("person_roots");
|
|
875
|
+
}
|
|
876
|
+
/** Join a person's roots to the root Conversation rows. */
|
|
877
|
+
function personRootJoin(roots) {
|
|
878
|
+
return eq(turnRoot.conversationId, roots.rootConversationId);
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Aggregate rows from {@link personRoots} joined to {@link turnRoot}. A
|
|
882
|
+
* Conversation counts once for each person who ran a Turn in it, and child
|
|
883
|
+
* Conversation Turns count for the root. Each row is one root of one person,
|
|
884
|
+
* so plain counts need no DISTINCT. Active and failed read the root's current
|
|
885
|
+
* status.
|
|
886
|
+
*/
|
|
887
|
+
function rootAggregateColumns(roots) {
|
|
888
|
+
return {
|
|
889
|
+
active: sql`(count(*) FILTER (WHERE ${conversationIsActiveSql(turnRoot)}))::integer`,
|
|
890
|
+
conversations: sql`count(*)::integer`,
|
|
891
|
+
durationMs: sql`COALESCE(sum(${roots.durationMs}), 0)::double precision`,
|
|
892
|
+
failed: sql`(count(*) FILTER (WHERE ${conversationTurnFailedSql(turnRoot)} AND ${turnRoot.stoppedAt} IS NULL))::integer`,
|
|
893
|
+
tokens: sql`sum(${roots.tokens})::double precision`
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Count the UTC days on which the grouped person ran a Turn. A correlated
|
|
898
|
+
* subquery runs once per person through the actor index, so a bad row
|
|
899
|
+
* estimate cannot make Postgres repeat it once per root.
|
|
900
|
+
*/
|
|
901
|
+
function personActiveDays() {
|
|
902
|
+
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");
|
|
903
|
+
return sql`(${getDb().select({ days: sql`count(*)` }).from(days)})::integer`;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Select the identity, Turn range, and totals of one person from roots
|
|
907
|
+
* grouped by person and joined to {@link juniorUsers}.
|
|
908
|
+
*/
|
|
909
|
+
function personTotalColumns(roots) {
|
|
910
|
+
return {
|
|
911
|
+
...rootAggregateColumns(roots),
|
|
912
|
+
activeDays: personActiveDays(),
|
|
913
|
+
email: sql`${juniorUsers.primaryEmailNormalized}`,
|
|
914
|
+
firstSeenAt: sql`min(${roots.firstAt})`.mapWith(metrics$2.occurredAt),
|
|
915
|
+
fullName: juniorUsers.displayName,
|
|
916
|
+
lastSeenAt: sql`max(${roots.lastAt})`.mapWith(metrics$2.occurredAt),
|
|
917
|
+
slackUserId: sql`max(${roots.slackUserId})`,
|
|
918
|
+
slackUserName: sql`max(${roots.slackUserName})`
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
/** Normalize emails before matching people API rows. */
|
|
922
|
+
function normalizeEmail$1(email) {
|
|
923
|
+
return email?.trim().toLowerCase() || void 0;
|
|
924
|
+
}
|
|
925
|
+
/** Build a zeroed totals object for people API aggregations. */
|
|
926
|
+
function emptyTotals() {
|
|
927
|
+
return {
|
|
928
|
+
active: 0,
|
|
929
|
+
activeDays: 0,
|
|
930
|
+
conversations: 0,
|
|
931
|
+
durationMs: 0,
|
|
932
|
+
failed: 0
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
/** Build a zeroed activity day for the people profile window. */
|
|
936
|
+
function emptyActivityDay(date) {
|
|
937
|
+
return {
|
|
938
|
+
active: 0,
|
|
939
|
+
conversations: 0,
|
|
940
|
+
date,
|
|
941
|
+
durationMs: 0,
|
|
942
|
+
failed: 0
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
/** Fill the fixed people profile activity window from sparse day totals. */
|
|
946
|
+
function activityDays(days, nowMs) {
|
|
947
|
+
return fillUtcDays({
|
|
948
|
+
count: 365,
|
|
949
|
+
empty: emptyActivityDay,
|
|
950
|
+
nowMs,
|
|
951
|
+
rows: days
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Fill the trailing 7-day people activity hour window from known hour totals.
|
|
956
|
+
* 24h charts use the last 24 points. 7d charts sum hours into 6-hour buckets.
|
|
957
|
+
*/
|
|
958
|
+
function activityHours$1(hours, nowMs) {
|
|
959
|
+
return fillUtcHours({
|
|
960
|
+
count: 168,
|
|
961
|
+
empty: emptyActivityDay,
|
|
962
|
+
nowMs,
|
|
963
|
+
rows: hours
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Fill trailing 6-hour people activity buckets from hour keys or hour rows.
|
|
968
|
+
* Hour keys must be summed into 6-hour keys first.
|
|
969
|
+
*/
|
|
970
|
+
function activitySixHours(hours, nowMs) {
|
|
971
|
+
const series = hours instanceof Map ? activityHours$1(hours, nowMs) : [...hours];
|
|
972
|
+
return sumUtcHoursIntoSixHours({
|
|
973
|
+
empty: emptyActivityDay,
|
|
974
|
+
hours: series,
|
|
975
|
+
nowMs
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
/** Return deterministic stats rows for people API responses. */
|
|
979
|
+
function statsItems(map) {
|
|
980
|
+
return [...map.values()].sort((left, right) => right.conversations - left.conversations || right.durationMs - left.durationMs || left.label.localeCompare(right.label));
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Build the verified person actor predicate shared by People aggregate and
|
|
984
|
+
* recent-row queries.
|
|
985
|
+
*
|
|
986
|
+
* Any provider counts, so Slack and dashboard (web) Conversations roll up to
|
|
987
|
+
* the same person. System identities never count.
|
|
988
|
+
*/
|
|
989
|
+
function verifiedActorWhere(email) {
|
|
990
|
+
const normalizedEmail = normalizeEmail$1(email);
|
|
991
|
+
return and(eq(juniorIdentities.kind, "user"), eq(juniorIdentities.emailVerified, true), sql`${juniorUsers.primaryEmailNormalized} IS NOT NULL`, normalizedEmail ? eq(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0);
|
|
992
|
+
}
|
|
993
|
+
/** Read the Conversations where a person ran a Turn, by their last Turn. */
|
|
994
|
+
async function recentActorRows(email) {
|
|
995
|
+
const lastTurns = getDb().select({
|
|
996
|
+
conversationId: sql`${metrics$2.conversationId}`.as("turn_conversation_id"),
|
|
997
|
+
lastTurnAt: sql`max(${metrics$2.occurredAt})`.as("last_turn_at")
|
|
998
|
+
}).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");
|
|
999
|
+
return getDb().select({
|
|
1000
|
+
channelName: juniorConversations.channelName,
|
|
1001
|
+
conversationId: juniorConversations.conversationId,
|
|
1002
|
+
createdAt: juniorConversations.createdAt,
|
|
1003
|
+
destinationId: juniorDestinations.id,
|
|
1004
|
+
durationMs: juniorConversations.durationMs,
|
|
1005
|
+
email: juniorUsers.primaryEmailNormalized,
|
|
1006
|
+
executionStatus: juniorConversations.executionStatus,
|
|
1007
|
+
executionUpdatedAt: juniorConversations.executionUpdatedAt,
|
|
1008
|
+
fullName: juniorUsers.displayName,
|
|
1009
|
+
kind: juniorConversations.kind,
|
|
1010
|
+
parentConversationId: juniorConversations.parentConversationId,
|
|
1011
|
+
archivedAt: juniorConversations.archivedAt,
|
|
1012
|
+
handle: sql`CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END`,
|
|
1013
|
+
lastActivityAt: juniorConversations.lastActivityAt,
|
|
1014
|
+
providerSubjectId: sql`CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END`,
|
|
1015
|
+
source: juniorConversations.source,
|
|
1016
|
+
status: conversationStatusSql(juniorConversations),
|
|
1017
|
+
title: juniorConversations.title,
|
|
1018
|
+
updatedAt: juniorConversations.updatedAt,
|
|
1019
|
+
usage: juniorConversations.usage
|
|
1020
|
+
}).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);
|
|
1021
|
+
}
|
|
1022
|
+
// src/api/conversations/person-spend-days.ts
|
|
1023
|
+
const metrics$1 = juniorConversationMetrics;
|
|
1024
|
+
/**
|
|
1025
|
+
* Read model spend per UTC day, split between verified people and Turns with
|
|
1026
|
+
* no verified person, with the count of active people and the median spend
|
|
1027
|
+
* of one person. A person is one Junior user, so their Slack and web
|
|
1028
|
+
* Identities count once. Every Run writes a `duration_ms` row, so a person
|
|
1029
|
+
* with a Turn but no cost row counts with zero spend.
|
|
1030
|
+
*
|
|
1031
|
+
* Metric rows are grouped by day and Identity before any join, so the joins
|
|
1032
|
+
* read one row per Identity and day.
|
|
1033
|
+
*/
|
|
1034
|
+
async function readPersonSpendDays(db, options) {
|
|
1035
|
+
const day = sql`date_trunc('day', ${metrics$1.occurredAt} at time zone 'UTC')`;
|
|
1036
|
+
const identityDays = db.select({
|
|
1037
|
+
date: day.as("identity_day_date"),
|
|
1038
|
+
identityId: sql`${metrics$1.actorIdentityId}`.as("identity_day_identity_id"),
|
|
1039
|
+
costMicroUsd: sql`coalesce(sum(${metrics$1.value}) FILTER (
|
|
1040
|
+
WHERE ${metrics$1.metric} = 'cost_micro_usd'
|
|
1041
|
+
), 0)`.as("identity_day_micro_usd")
|
|
1042
|
+
}).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");
|
|
1043
|
+
const identityPeople = db.select({
|
|
1044
|
+
date: sql`${identityDays.date}`.as("identity_person_date"),
|
|
1045
|
+
userId: sql`CASE WHEN ${verifiedActorWhere()} THEN ${juniorUsers.id} END`.as("identity_person_user_id"),
|
|
1046
|
+
costMicroUsd: sql`${identityDays.costMicroUsd}`.as("identity_person_micro_usd")
|
|
1047
|
+
}).from(identityDays).leftJoin(juniorIdentities, eq(juniorIdentities.id, identityDays.identityId)).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).as("person_identity_people");
|
|
1048
|
+
const personDays = db.select({
|
|
1049
|
+
date: sql`${identityPeople.date}`.as("person_day_date"),
|
|
1050
|
+
userId: sql`${identityPeople.userId}`.as("person_day_user_id"),
|
|
1051
|
+
costMicroUsd: sql`sum(${identityPeople.costMicroUsd})`.as("person_day_micro_usd")
|
|
1052
|
+
}).from(identityPeople).groupBy(identityPeople.date, identityPeople.userId).as("person_days");
|
|
1053
|
+
const person = sql`${personDays.userId} IS NOT NULL`;
|
|
1054
|
+
return await db.select({
|
|
1055
|
+
date: sql`to_char(${personDays.date}, 'YYYY-MM-DD')`,
|
|
1056
|
+
medianPersonCostMicroUsd: sql`(percentile_cont(0.5) WITHIN GROUP (ORDER BY ${personDays.costMicroUsd}) FILTER (WHERE ${person}))::double precision`,
|
|
1057
|
+
people: sql`(count(*) FILTER (WHERE ${person}))::integer`,
|
|
1058
|
+
personCostMicroUsd: sql`coalesce(sum(${personDays.costMicroUsd}) FILTER (WHERE ${person}), 0)::double precision`,
|
|
1059
|
+
unattributedCostMicroUsd: sql`coalesce(sum(${personDays.costMicroUsd}) FILTER (WHERE NOT ${person}), 0)::double precision`
|
|
1060
|
+
}).from(personDays).groupBy(personDays.date);
|
|
1061
|
+
}
|
|
873
1062
|
// src/api/conversations/outcome-buckets.ts
|
|
874
1063
|
const changes = juniorCodeChanges;
|
|
875
1064
|
const linked$1 = alias(juniorConversations, "linked");
|
|
@@ -977,6 +1166,7 @@ async function readWindowMerges(db, options) {
|
|
|
977
1166
|
}] : []);
|
|
978
1167
|
}
|
|
979
1168
|
// src/api/conversations/stats.query.ts
|
|
1169
|
+
const WINDOW_DAYS$1 = 90;
|
|
980
1170
|
function addUsd(current, next) {
|
|
981
1171
|
return Math.round(((current ?? 0) + next) * 0xe8d4a51000) / 0xe8d4a51000;
|
|
982
1172
|
}
|
|
@@ -1149,6 +1339,23 @@ function guardianStats(dayRows, hourRows, endMs) {
|
|
|
1149
1339
|
...costUsd !== void 0 ? { costUsd } : void 0
|
|
1150
1340
|
};
|
|
1151
1341
|
}
|
|
1342
|
+
function personSpendDay(row) {
|
|
1343
|
+
return {
|
|
1344
|
+
date: row.date,
|
|
1345
|
+
people: row.people,
|
|
1346
|
+
personCostUsd: microUsdToUsd(row.personCostMicroUsd),
|
|
1347
|
+
unattributedCostUsd: microUsdToUsd(row.unattributedCostMicroUsd),
|
|
1348
|
+
...row.medianPersonCostMicroUsd !== null ? { medianPersonCostUsd: microUsdToUsd(row.medianPersonCostMicroUsd) } : void 0
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
function emptyPersonSpendDay(date) {
|
|
1352
|
+
return {
|
|
1353
|
+
date,
|
|
1354
|
+
people: 0,
|
|
1355
|
+
personCostUsd: 0,
|
|
1356
|
+
unattributedCostUsd: 0
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1152
1359
|
/** Sum hour rows into UTC day rows, one per day and `key`. */
|
|
1153
1360
|
function sumHoursIntoDays(hours, add, key = () => "") {
|
|
1154
1361
|
const days = /* @__PURE__ */ new Map();
|
|
@@ -1165,7 +1372,7 @@ function sumHoursIntoDays(hours, add, key = () => "") {
|
|
|
1165
1372
|
return [...days.values()];
|
|
1166
1373
|
}
|
|
1167
1374
|
/** Count the window roots that have a tree, per UTC hour of last activity. */
|
|
1168
|
-
function activityHours
|
|
1375
|
+
function activityHours(roots) {
|
|
1169
1376
|
const hours = /* @__PURE__ */ new Map();
|
|
1170
1377
|
for (const root of roots) {
|
|
1171
1378
|
if (root.treeConversations === 0) continue;
|
|
@@ -1184,7 +1391,7 @@ async function readConversationStatsFromSql() {
|
|
|
1184
1391
|
const nowMs = Date.now();
|
|
1185
1392
|
const { end, start } = statsWindow(nowMs);
|
|
1186
1393
|
const db = getDb();
|
|
1187
|
-
const [windowRoots, metrics, merges, guardian] = await Promise.all([
|
|
1394
|
+
const [windowRoots, metrics, merges, guardian, personSpend] = await Promise.all([
|
|
1188
1395
|
readWindowRoots(db, {
|
|
1189
1396
|
start,
|
|
1190
1397
|
end
|
|
@@ -1200,9 +1407,13 @@ async function readConversationStatsFromSql() {
|
|
|
1200
1407
|
readGuardianHours(db, getStateAdapter(), {
|
|
1201
1408
|
start,
|
|
1202
1409
|
end
|
|
1410
|
+
}),
|
|
1411
|
+
readPersonSpendDays(db, {
|
|
1412
|
+
start,
|
|
1413
|
+
end
|
|
1203
1414
|
})
|
|
1204
1415
|
]);
|
|
1205
|
-
const activity = activityHours
|
|
1416
|
+
const activity = activityHours(windowRoots);
|
|
1206
1417
|
const outcomes = outcomeBuckets({ merges });
|
|
1207
1418
|
const hours = metricHours(applyMetricBuckets(activity, metrics, outcomes), nowMs);
|
|
1208
1419
|
return {
|
|
@@ -1224,6 +1435,12 @@ async function readConversationStatsFromSql() {
|
|
|
1224
1435
|
})), nowMs),
|
|
1225
1436
|
metricHours: hours,
|
|
1226
1437
|
metricSixHours: sumMetricHoursIntoSixHours(hours, nowMs),
|
|
1438
|
+
personSpendDays: fillUtcDays({
|
|
1439
|
+
count: WINDOW_DAYS$1,
|
|
1440
|
+
empty: emptyPersonSpendDay,
|
|
1441
|
+
nowMs,
|
|
1442
|
+
rows: new Map(personSpend.map((row) => [row.date, personSpendDay(row)]))
|
|
1443
|
+
}),
|
|
1227
1444
|
source: "conversation_index",
|
|
1228
1445
|
windowEnd: end.toISOString(),
|
|
1229
1446
|
windowStart: start.toISOString()
|
|
@@ -1232,6 +1449,8 @@ async function readConversationStatsFromSql() {
|
|
|
1232
1449
|
// src/api/conversations/stats.ts
|
|
1233
1450
|
/** Load aggregate conversation stats from durable SQL records. */
|
|
1234
1451
|
const readConversationStats = createCachedReport({
|
|
1452
|
+
freshMs: 3e5,
|
|
1453
|
+
keepMs: 36e5,
|
|
1235
1454
|
key: "conversation-stats",
|
|
1236
1455
|
read: readConversationStatsFromSql,
|
|
1237
1456
|
refreshFailedEvent: "conversation_stats.refresh.failed",
|
|
@@ -1360,7 +1579,7 @@ function createConversationRoutes(options) {
|
|
|
1360
1579
|
const app = new Hono();
|
|
1361
1580
|
const messageBodyLimit = bodyLimit({ maxSize: 262144 });
|
|
1362
1581
|
app.get("/", validateRequest("query", conversationFeedQuerySchema, "Invalid query parameters."), async (context) => {
|
|
1363
|
-
const { actorEmail, codeRepositoryId, cursor, include, q, status } = context.req.valid("query");
|
|
1582
|
+
const { actorEmail, codeRepositoryId, cursor, include, q, spaceId, status } = context.req.valid("query");
|
|
1364
1583
|
const viewer = context.get("viewer");
|
|
1365
1584
|
let waitingRows = 0;
|
|
1366
1585
|
const feed = await readConversationFeed({
|
|
@@ -1372,6 +1591,7 @@ function createConversationRoutes(options) {
|
|
|
1372
1591
|
waitingRows = count;
|
|
1373
1592
|
},
|
|
1374
1593
|
...q ? { q } : void 0,
|
|
1594
|
+
...spaceId ? { spaceId } : void 0,
|
|
1375
1595
|
status,
|
|
1376
1596
|
...viewer ? { viewer } : void 0
|
|
1377
1597
|
});
|
|
@@ -1415,11 +1635,12 @@ function createConversationRoutes(options) {
|
|
|
1415
1635
|
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"))));
|
|
1416
1636
|
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)));
|
|
1417
1637
|
app.patch("/:conversationId/archive", requireViewer, apiOperationHandler(archiveConversationOperation, options));
|
|
1638
|
+
app.put("/:conversationId/space", requireViewer, apiOperationHandler(setConversationSpaceOperation, options));
|
|
1418
1639
|
app.patch("/:conversationId/pin", requireViewer, apiOperationHandler(pinConversationOperation, options));
|
|
1419
1640
|
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"))));
|
|
1420
1641
|
app.patch("/:conversationId/subscription", requireViewer, apiOperationHandler(setConversationSubscriptionOperation, options));
|
|
1421
1642
|
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"))));
|
|
1422
|
-
app.patch("/:conversationId/title", requireViewer,
|
|
1643
|
+
app.patch("/:conversationId/title", requireViewer, apiOperationHandler(renameConversationOperation, options));
|
|
1423
1644
|
app.post("/:conversationId/annotations", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", attachObjectLinkBodySchema, "Invalid request body."), async (context) => jsonResponse(attachObjectLinkResponseSchema, await attachObjectLink(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json").url)));
|
|
1424
1645
|
app.put("/:conversationId/read-position", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationReadPositionSchema, "Invalid request body."), async (context) => {
|
|
1425
1646
|
const viewer = context.get("viewer");
|
|
@@ -1551,6 +1772,55 @@ function createConversationRoutes(options) {
|
|
|
1551
1772
|
});
|
|
1552
1773
|
return app;
|
|
1553
1774
|
}
|
|
1775
|
+
// src/api/code/stacks.ts
|
|
1776
|
+
/**
|
|
1777
|
+
* Read the stack of each code change: the Automation that ran its first
|
|
1778
|
+
* Conversation's root, or else that root. The first Conversation is the
|
|
1779
|
+
* earliest created one, since `conversation_ids` is sorted by id. A change
|
|
1780
|
+
* whose root the viewer may not read has no stack, so its title stays
|
|
1781
|
+
* hidden.
|
|
1782
|
+
*/
|
|
1783
|
+
async function readCodeChangeStacks(db, changes, viewer) {
|
|
1784
|
+
const linkedIds = [...new Set(changes.flatMap((change) => change.conversationIds))];
|
|
1785
|
+
const createdAt = new Map((linkedIds.length === 0 ? [] : await db.select({
|
|
1786
|
+
conversationId: juniorConversations.conversationId,
|
|
1787
|
+
createdAt: juniorConversations.createdAt
|
|
1788
|
+
}).from(juniorConversations).where(inArray(juniorConversations.conversationId, linkedIds))).map((row) => [row.conversationId, row.createdAt.getTime()]));
|
|
1789
|
+
const firstIds = new Map(changes.flatMap((change) => {
|
|
1790
|
+
const [first] = change.conversationIds.filter((id) => createdAt.has(id)).sort((a, b) => createdAt.get(a) - createdAt.get(b) || a.localeCompare(b));
|
|
1791
|
+
return first ? [[change.id, first]] : [];
|
|
1792
|
+
}));
|
|
1793
|
+
const access = await readConversationAccessFromSql(db, [...new Set(firstIds.values())], viewer);
|
|
1794
|
+
const rootIds = [...new Set([...access.values()].flatMap((entry) => entry.canViewPrivateContent && entry.rootConversationId ? [entry.rootConversationId] : []))];
|
|
1795
|
+
const roots = rootIds.length === 0 ? [] : await db.select({
|
|
1796
|
+
automationId: juniorAutomations.id,
|
|
1797
|
+
automationKind: juniorAutomations.kind,
|
|
1798
|
+
automationTask: sql`${juniorAutomations.record}->'task'`,
|
|
1799
|
+
automationTitle: juniorAutomations.title,
|
|
1800
|
+
conversationId: juniorConversations.conversationId,
|
|
1801
|
+
title: juniorConversations.title
|
|
1802
|
+
}).from(juniorConversations).leftJoin(juniorAutomationRuns, eq(juniorAutomationRuns.conversationId, juniorConversations.conversationId)).leftJoin(juniorAutomations, eq(juniorAutomations.id, juniorAutomationRuns.automationId)).where(inArray(juniorConversations.conversationId, rootIds));
|
|
1803
|
+
const stackOfRoot = new Map(roots.map((root) => [root.conversationId, root.automationId && root.automationKind ? {
|
|
1804
|
+
id: root.automationId,
|
|
1805
|
+
kind: "automation",
|
|
1806
|
+
title: collectionRowTitle({
|
|
1807
|
+
kind: root.automationKind,
|
|
1808
|
+
task: root.automationTask,
|
|
1809
|
+
title: root.automationTitle
|
|
1810
|
+
})
|
|
1811
|
+
} : {
|
|
1812
|
+
id: root.conversationId,
|
|
1813
|
+
kind: "conversation",
|
|
1814
|
+
...root.title ? { title: root.title } : void 0
|
|
1815
|
+
}]));
|
|
1816
|
+
const stacks = /* @__PURE__ */ new Map();
|
|
1817
|
+
for (const [changeId, conversationId] of firstIds) {
|
|
1818
|
+
const entry = access.get(conversationId);
|
|
1819
|
+
const stack = entry?.canViewPrivateContent && entry.rootConversationId ? stackOfRoot.get(entry.rootConversationId) : void 0;
|
|
1820
|
+
if (stack) stacks.set(changeId, stack);
|
|
1821
|
+
}
|
|
1822
|
+
return stacks;
|
|
1823
|
+
}
|
|
1554
1824
|
// src/api/code/overview.ts
|
|
1555
1825
|
const DAY_MS$2 = 864e5;
|
|
1556
1826
|
const WINDOW_DAYS = 30;
|
|
@@ -1630,9 +1900,13 @@ async function readTreeCosts(conversationIds) {
|
|
|
1630
1900
|
};
|
|
1631
1901
|
}
|
|
1632
1902
|
/**
|
|
1633
|
-
* True when any linked conversation actor belongs to the subject user
|
|
1634
|
-
*
|
|
1635
|
-
*
|
|
1903
|
+
* True when any linked conversation actor belongs to the subject user, or
|
|
1904
|
+
* the code change credits one of the user's Identities as requester. A
|
|
1905
|
+
* Thread or an Automation run that someone else started can open a change
|
|
1906
|
+
* for the user, so the requester half finds the changes the actor half
|
|
1907
|
+
* misses. The first subquery starts from the user's Conversations, so
|
|
1908
|
+
* Postgres hash-joins them with the linked ids instead of one lookup per
|
|
1909
|
+
* code change. The second uses the requester GIN index.
|
|
1636
1910
|
*/
|
|
1637
1911
|
function ownedByUserSql(userId) {
|
|
1638
1912
|
return sql`${juniorCodeChanges.id} IN (
|
|
@@ -1646,6 +1920,12 @@ function ownedByUserSql(userId) {
|
|
|
1646
1920
|
) AS linked
|
|
1647
1921
|
ON linked.conversation_id = conversations.conversation_id
|
|
1648
1922
|
WHERE identities.user_id = ${userId}
|
|
1923
|
+
UNION ALL
|
|
1924
|
+
SELECT requested.id
|
|
1925
|
+
FROM junior_identities AS identities
|
|
1926
|
+
INNER JOIN junior_code_changes AS requested
|
|
1927
|
+
ON requested.requester_identity_ids @> ARRAY[identities.id]
|
|
1928
|
+
WHERE identities.user_id = ${userId}
|
|
1649
1929
|
)`;
|
|
1650
1930
|
}
|
|
1651
1931
|
/** Limit code changes to one person's conversations or one repository. */
|
|
@@ -1721,11 +2001,7 @@ async function readCodeWindows(args) {
|
|
|
1721
2001
|
}
|
|
1722
2002
|
/** Columns read for one code change report row. */
|
|
1723
2003
|
const codeChangeReportColumns = {
|
|
1724
|
-
additions: juniorCodeChanges.additions,
|
|
1725
|
-
changedFiles: juniorCodeChanges.changedFiles,
|
|
1726
2004
|
closedAt: juniorCodeChanges.closedAt,
|
|
1727
|
-
deletions: juniorCodeChanges.deletions,
|
|
1728
|
-
draft: juniorCodeChanges.draft,
|
|
1729
2005
|
id: juniorCodeChanges.id,
|
|
1730
2006
|
lastActivityAt: juniorCodeChanges.lastActivityAt,
|
|
1731
2007
|
mergedAt: juniorCodeChanges.mergedAt,
|
|
@@ -1734,24 +2010,18 @@ const codeChangeReportColumns = {
|
|
|
1734
2010
|
provider: juniorCodeChanges.provider,
|
|
1735
2011
|
repository: juniorCodeRepositories.name,
|
|
1736
2012
|
state: juniorCodeChanges.state,
|
|
1737
|
-
title: juniorCodeChanges.title
|
|
1738
|
-
url: juniorCodeChanges.url
|
|
2013
|
+
title: juniorCodeChanges.title
|
|
1739
2014
|
};
|
|
1740
2015
|
/** Convert one code change row to its report shape. */
|
|
1741
|
-
function codeChangeReport(
|
|
1742
|
-
const size = {};
|
|
1743
|
-
if (additions !== null) size.additions = additions;
|
|
1744
|
-
if (deletions !== null) size.deletions = deletions;
|
|
1745
|
-
if (changedFiles !== null) size.changedFiles = changedFiles;
|
|
2016
|
+
function codeChangeReport(change) {
|
|
1746
2017
|
return {
|
|
1747
2018
|
...change,
|
|
1748
|
-
...Object.keys(size).length > 0 ? { size } : void 0,
|
|
1749
2019
|
closedAt: change.closedAt?.toISOString(),
|
|
1750
2020
|
lastActivityAt: change.lastActivityAt?.toISOString(),
|
|
1751
2021
|
mergedAt: change.mergedAt?.toISOString(),
|
|
1752
2022
|
openedAt: change.openedAt.toISOString(),
|
|
1753
2023
|
title: change.title ?? void 0,
|
|
1754
|
-
url: change
|
|
2024
|
+
url: codeChangeUrl(change)
|
|
1755
2025
|
};
|
|
1756
2026
|
}
|
|
1757
2027
|
/** Read code activity created by Junior across installed code plugins. */
|
|
@@ -1771,8 +2041,7 @@ async function readCodeOverview(nowMs = Date.now()) {
|
|
|
1771
2041
|
merged,
|
|
1772
2042
|
name: repositories.name,
|
|
1773
2043
|
open: sql`count(*) filter (where ${changes.state} = 'open')`.mapWith(Number),
|
|
1774
|
-
provider: repositories.provider
|
|
1775
|
-
url: repositories.url
|
|
2044
|
+
provider: repositories.provider
|
|
1776
2045
|
}).from(repositories).innerJoin(changes, eq(changes.repositoryId, repositories.id)).where(recent).groupBy(repositories.id).orderBy(desc(merged), desc(created), asc(repositories.name)).limit(25), db.select(codeChangeReportColumns).from(changes).innerJoin(repositories, eq(changes.repositoryId, repositories.id)).where(recent).orderBy(desc(changes.updatedAt)).limit(25)]);
|
|
1777
2046
|
const repositoryChanges = repositoryRows.length ? await db.select({
|
|
1778
2047
|
conversationIds: changes.conversationIds,
|
|
@@ -1797,7 +2066,7 @@ async function readCodeOverview(nowMs = Date.now()) {
|
|
|
1797
2066
|
...repository,
|
|
1798
2067
|
medianCostUsd: median(repositoryCosts.get(repository.id) ?? []),
|
|
1799
2068
|
mergeRate: mergeRate(repository.merged, repository.closed),
|
|
1800
|
-
url: repository
|
|
2069
|
+
url: codeRepositoryUrl(repository)
|
|
1801
2070
|
})),
|
|
1802
2071
|
summary: windows.summary,
|
|
1803
2072
|
windowEnd: windows.windowEnd.toISOString(),
|
|
@@ -1824,8 +2093,8 @@ function afterPersonCodeCursor(cursor) {
|
|
|
1824
2093
|
return or(completed, sql`${idleSince} > ${since}`, and(sql`${idleSince} = ${since}`, laterInGroup));
|
|
1825
2094
|
}
|
|
1826
2095
|
/**
|
|
1827
|
-
* Read person-scoped code activity and recent code changes linked
|
|
1828
|
-
*
|
|
2096
|
+
* Read person-scoped code activity and recent code changes: the ones linked
|
|
2097
|
+
* to the person's Conversations, and the ones that credit them as requester.
|
|
1829
2098
|
*/
|
|
1830
2099
|
async function readPersonCodeOverview(args) {
|
|
1831
2100
|
const nowMs = args.nowMs ?? Date.now();
|
|
@@ -1836,14 +2105,25 @@ async function readPersonCodeOverview(args) {
|
|
|
1836
2105
|
userId: args.userId
|
|
1837
2106
|
}), db.select({
|
|
1838
2107
|
change: codeChangeReportColumns,
|
|
2108
|
+
conversationIds: juniorCodeChanges.conversationIds,
|
|
1839
2109
|
updatedAt: juniorCodeChanges.updatedAt
|
|
1840
2110
|
}).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)]);
|
|
2111
|
+
const stacks = await readCodeChangeStacks(db, changes.map((row) => ({
|
|
2112
|
+
conversationIds: row.conversationIds,
|
|
2113
|
+
id: row.change.id
|
|
2114
|
+
})), args.viewer);
|
|
1841
2115
|
const last = changes.at(-1);
|
|
1842
2116
|
return {
|
|
1843
2117
|
activityDays: windows.activityDays,
|
|
1844
2118
|
activityHours: windows.activityHours,
|
|
1845
2119
|
activitySixHours: windows.activitySixHours,
|
|
1846
|
-
changes: changes.map((row) =>
|
|
2120
|
+
changes: changes.map((row) => {
|
|
2121
|
+
const stack = stacks.get(row.change.id);
|
|
2122
|
+
return {
|
|
2123
|
+
...codeChangeReport(row.change),
|
|
2124
|
+
...stack ? { stack } : void 0
|
|
2125
|
+
};
|
|
2126
|
+
}),
|
|
1847
2127
|
generatedAt: windows.windowEnd.toISOString(),
|
|
1848
2128
|
nextCursor: last && changes.length === PERSON_CHANGE_LIMIT ? encodePageCursor(personCodeCursorSchema, {
|
|
1849
2129
|
id: last.change.id,
|
|
@@ -1884,8 +2164,7 @@ async function readCodeRepository(repositoryId, options = {}) {
|
|
|
1884
2164
|
merged: countState("merged"),
|
|
1885
2165
|
name: juniorCodeRepositories.name,
|
|
1886
2166
|
open: countState("open"),
|
|
1887
|
-
provider: juniorCodeRepositories.provider
|
|
1888
|
-
url: juniorCodeRepositories.url
|
|
2167
|
+
provider: juniorCodeRepositories.provider
|
|
1889
2168
|
}).from(juniorCodeRepositories).leftJoin(juniorCodeChanges, eq(juniorCodeChanges.repositoryId, juniorCodeRepositories.id)).where(eq(juniorCodeRepositories.id, repositoryId)).groupBy(juniorCodeRepositories.id);
|
|
1890
2169
|
if (!row) return void 0;
|
|
1891
2170
|
const { closed, merged, open, ...repository } = row;
|
|
@@ -1913,7 +2192,7 @@ async function readCodeRepository(repositoryId, options = {}) {
|
|
|
1913
2192
|
generatedAt: windows.windowEnd.toISOString(),
|
|
1914
2193
|
repository: {
|
|
1915
2194
|
...repository,
|
|
1916
|
-
url: repository
|
|
2195
|
+
url: codeRepositoryUrl(repository)
|
|
1917
2196
|
},
|
|
1918
2197
|
summary: windows.summary,
|
|
1919
2198
|
windowEnd: windows.windowEnd.toISOString(),
|
|
@@ -1924,8 +2203,8 @@ async function readCodeRepository(repositoryId, options = {}) {
|
|
|
1924
2203
|
// src/api/code/search.query.ts
|
|
1925
2204
|
const CODE_CHANGE_SEARCH_LIMIT = 8;
|
|
1926
2205
|
const CODE_CHANGE_SEARCH_TERMS = 4;
|
|
1927
|
-
const
|
|
1928
|
-
const
|
|
2206
|
+
const CODE_CHANGE_SEARCH_TIMEOUT_MS = 3e3;
|
|
2207
|
+
const matched = alias(juniorCodeChanges, "matched");
|
|
1929
2208
|
const linked = alias(juniorConversations, "linked_conversation");
|
|
1930
2209
|
/**
|
|
1931
2210
|
* Find code changes for the composer `#` menu, newest activity first. A
|
|
@@ -1938,24 +2217,35 @@ const linked = alias(juniorConversations, "linked_conversation");
|
|
|
1938
2217
|
async function readCodeChangeSearchFromSql(query, viewerUserId) {
|
|
1939
2218
|
const number = /^#?(\d+)$/.exec(query.trim())?.[1];
|
|
1940
2219
|
const terms = number ? [number] : (query.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? []).slice(0, CODE_CHANGE_SEARCH_TERMS);
|
|
1941
|
-
|
|
2220
|
+
const providers = linkedCodeProviders();
|
|
2221
|
+
if (terms.length === 0 || providers.length === 0) return [];
|
|
1942
2222
|
const everyTerm = terms.map((term) => `${term}:*`).join(" & ");
|
|
1943
2223
|
const anyTerm = terms.map((term) => `${term}:*`).join(" | ");
|
|
1944
2224
|
const db = getDb();
|
|
1945
2225
|
const changeDocument = codeChangeSearchDocument(juniorCodeChanges);
|
|
1946
|
-
const
|
|
1947
|
-
const
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
2226
|
+
const repositoryDocument = codeRepositorySearchDocument(juniorCodeRepositories);
|
|
2227
|
+
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));
|
|
2228
|
+
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})`)));
|
|
2229
|
+
const visible = exists(db.select({ conversationId: juniorConversations.conversationId }).from(linked).innerJoin(juniorConversations, eq(juniorConversations.conversationId, sql`coalesce(${linked.rootConversationId}, ${linked.conversationId})`)).leftJoin(juniorDestinations, conversationRecordJoins.location).where(and(sql`${linked.conversationId} = any(${juniorCodeChanges.conversationIds})`, listedConversation(), rootVisibleToViewer(viewerUserId))));
|
|
2230
|
+
return (await db.transaction(async (tx) => {
|
|
2231
|
+
await tx.execute(sql`SELECT set_config('statement_timeout', ${String(CODE_CHANGE_SEARCH_TIMEOUT_MS)}, true)`);
|
|
2232
|
+
return await tx.select({
|
|
2233
|
+
number: juniorCodeChanges.number,
|
|
2234
|
+
provider: juniorCodeChanges.provider,
|
|
2235
|
+
repository: juniorCodeRepositories.name,
|
|
2236
|
+
state: juniorCodeChanges.state,
|
|
2237
|
+
title: juniorCodeChanges.title
|
|
2238
|
+
}).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);
|
|
2239
|
+
})).flatMap(({ provider, ...row }) => {
|
|
2240
|
+
const url = codeChangeUrl({
|
|
2241
|
+
...row,
|
|
2242
|
+
provider
|
|
2243
|
+
});
|
|
2244
|
+
return url ? [{
|
|
2245
|
+
...row,
|
|
2246
|
+
url
|
|
2247
|
+
}] : [];
|
|
2248
|
+
});
|
|
1959
2249
|
}
|
|
1960
2250
|
// src/api/code/routes.ts
|
|
1961
2251
|
/** Create the code analytics API. */
|
|
@@ -2148,8 +2438,8 @@ function summaryFromRow(row, options = {}) {
|
|
|
2148
2438
|
});
|
|
2149
2439
|
}
|
|
2150
2440
|
// src/api/locations/query.ts
|
|
2151
|
-
const RECENT_LIMIT
|
|
2152
|
-
const ACTIVITY_DAYS
|
|
2441
|
+
const RECENT_LIMIT = 25;
|
|
2442
|
+
const ACTIVITY_DAYS = 90;
|
|
2153
2443
|
/**
|
|
2154
2444
|
* Location id for every public Conversation with a `local` destination. Each
|
|
2155
2445
|
* such Conversation has its own destination row, so they report as one
|
|
@@ -2304,7 +2594,7 @@ function accumulateLocationActivity(rows) {
|
|
|
2304
2594
|
}
|
|
2305
2595
|
function directoryActivityDays$1(rows, nowMs) {
|
|
2306
2596
|
return fillUtcDays({
|
|
2307
|
-
count: ACTIVITY_DAYS
|
|
2597
|
+
count: ACTIVITY_DAYS,
|
|
2308
2598
|
empty: emptyLocationActivityDay,
|
|
2309
2599
|
nowMs,
|
|
2310
2600
|
rows: accumulateLocationActivity(rows)
|
|
@@ -2334,7 +2624,7 @@ function directoryActivitySixHours$1(rows, nowMs) {
|
|
|
2334
2624
|
/** Load public locations plus one complete privacy-safe aggregate for non-public activity. */
|
|
2335
2625
|
async function readLocationDirectoryFromSql() {
|
|
2336
2626
|
const nowMs = Date.now();
|
|
2337
|
-
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS
|
|
2627
|
+
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS);
|
|
2338
2628
|
const hourWindow = trailingUtcHourWindow(nowMs, 168);
|
|
2339
2629
|
const [rows, activity] = await Promise.all([directoryRows(getDb()), directoryActivityRows(getDb(), start, hourWindow.start)]);
|
|
2340
2630
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -2388,12 +2678,12 @@ async function recentLocationRows(db, locationId) {
|
|
|
2388
2678
|
title: juniorConversations.title,
|
|
2389
2679
|
updatedAt: juniorConversations.updatedAt,
|
|
2390
2680
|
usage: juniorConversations.usage
|
|
2391
|
-
}).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
|
|
2681
|
+
}).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);
|
|
2392
2682
|
}
|
|
2393
2683
|
/** Load one public location's complete activity while bounding only recent conversations. */
|
|
2394
2684
|
async function readLocationDetailFromSql(locationId, options = {}) {
|
|
2395
2685
|
const nowMs = Date.now();
|
|
2396
|
-
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS
|
|
2686
|
+
const { end, start } = trailingUtcDayWindow(nowMs, ACTIVITY_DAYS);
|
|
2397
2687
|
const hourWindow = trailingUtcHourWindow(nowMs, 168);
|
|
2398
2688
|
const where = publicLocationWhere(locationId);
|
|
2399
2689
|
const activityDate = sql`TO_CHAR(
|
|
@@ -2469,7 +2759,7 @@ async function readLocationDetailFromSql(locationId, options = {}) {
|
|
|
2469
2759
|
addMetrics(item, row);
|
|
2470
2760
|
actors.push(item);
|
|
2471
2761
|
}
|
|
2472
|
-
const activity = activityDays$1(days, nowMs, ACTIVITY_DAYS
|
|
2762
|
+
const activity = activityDays$1(days, nowMs, ACTIVITY_DAYS);
|
|
2473
2763
|
const hourlyActivity = activityHours$2(hours, nowMs);
|
|
2474
2764
|
const recentConversationIds = recentRows.map((row) => row.conversationId);
|
|
2475
2765
|
const [accessByConversation, metricsByRoot, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
|
|
@@ -2642,230 +2932,200 @@ function imageResponse(served, versioned) {
|
|
|
2642
2932
|
/** Route parameters for one image. */
|
|
2643
2933
|
const imageParamsSchema = z.object({ id: z.string().min(1).max(4e3) }).strict();
|
|
2644
2934
|
/** The width of one image, from the fixed set, and its optional version. */
|
|
2645
|
-
const imageQuerySchema = z.object({
|
|
2646
|
-
v: z.string().min(1).max(64).optional(),
|
|
2647
|
-
w: z.string().transform(Number).refine((width) => IMAGE_WIDTHS.some((allowed) => allowed === width))
|
|
2648
|
-
}).strict();
|
|
2649
|
-
// src/api/images/routes.ts
|
|
2650
|
-
/**
|
|
2651
|
-
* Create the route that serves external images from Junior, so browsers
|
|
2652
|
-
* never load them from another host. The path has a signed id, never the
|
|
2653
|
-
* address of the image.
|
|
2654
|
-
*/
|
|
2655
|
-
function createImageRoutes() {
|
|
2656
|
-
const app = new Hono();
|
|
2657
|
-
app.get("/:id", requireViewer, validateRequest("param", imageParamsSchema, "Invalid route parameters."), validateRequest("query", imageQuerySchema, "Invalid image width."), async (context) => {
|
|
2658
|
-
const image = decodeImageId(context.req.valid("param").id);
|
|
2659
|
-
const { v, w } = context.req.valid("query");
|
|
2660
|
-
const served = image && await readImage(context.get("viewer"), image, w);
|
|
2661
|
-
if (!served) throwApiError(404, "Image not found.");
|
|
2662
|
-
return imageResponse(served, Boolean(v));
|
|
2663
|
-
});
|
|
2664
|
-
return app;
|
|
2665
|
-
}
|
|
2666
|
-
// src/api/lead/routes.ts
|
|
2667
|
-
/** Create the route that finds the viewer's Lead, and creates it on first use. */
|
|
2668
|
-
function createLeadRoutes() {
|
|
2669
|
-
const app = new Hono();
|
|
2670
|
-
app.get("/", requireViewer, async (context) => {
|
|
2671
|
-
const lead = await getLeadConversation(context.get("viewer"));
|
|
2672
|
-
const watches = await listWatches({ conversationId: lead.conversationId });
|
|
2673
|
-
const watchedConversationIds = [...new Set(watches.filter((watch) => watch.namespace === "junior" && watch.resourceType === "conversation").map((watch) => watch.identifier))];
|
|
2674
|
-
return jsonResponse(leadSchema, {
|
|
2675
|
-
conversationId: lead.conversationId,
|
|
2676
|
-
watchedConversationIds
|
|
2677
|
-
}, { headers: { "cache-control": "private, no-store" } });
|
|
2678
|
-
});
|
|
2679
|
-
return app;
|
|
2680
|
-
}
|
|
2681
|
-
const metrics$1 = juniorConversationMetrics;
|
|
2682
|
-
/** Sum the values of one metric among grouped metric rows. */
|
|
2683
|
-
function metricSum(metric) {
|
|
2684
|
-
return sql`sum(${metrics$1.value}) FILTER (WHERE ${metrics$1.metric} = ${metric})`;
|
|
2685
|
-
}
|
|
2686
|
-
/** Sum the spend of Turn metric rows read straight from their table. */
|
|
2687
|
-
const turnMetricColumns = { costMicroUsd: microUsdSql(metricSum("cost_micro_usd")) };
|
|
2688
|
-
/** Root Conversation of a person's Turn, for status, location, and surface. */
|
|
2689
|
-
const turnRoot = alias(juniorConversations, "person_turn_root");
|
|
2690
|
-
/** Root of a Conversation row: itself when it has no root. */
|
|
2691
|
-
const conversationRootId = sql`coalesce(
|
|
2692
|
-
${juniorConversations.rootConversationId},
|
|
2693
|
-
${juniorConversations.conversationId}
|
|
2694
|
-
)`;
|
|
2695
|
-
/**
|
|
2696
|
-
* Read one row per verified person and root Conversation where they ran a
|
|
2697
|
-
* Turn, over all time: the Turn range and the duration and token totals.
|
|
2698
|
-
*
|
|
2699
|
-
* The person and metric filters apply to the metric rows, and the rows are
|
|
2700
|
-
* grouped before any join. Every Run writes a `duration_ms` row, so these
|
|
2701
|
-
* two metrics mark every Turn.
|
|
2702
|
-
*/
|
|
2703
|
-
function personRoots(email) {
|
|
2704
|
-
const verifiedIdentities = getDb().select({ id: juniorIdentities.id }).from(juniorIdentities).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(verifiedActorWhere(email));
|
|
2705
|
-
const conversations = getDb().select({
|
|
2706
|
-
identityId: sql`${metrics$1.actorIdentityId}`.as("turn_identity_id"),
|
|
2707
|
-
conversationId: sql`${metrics$1.conversationId}`.as("turn_conversation_id"),
|
|
2708
|
-
firstAt: sql`min(${metrics$1.occurredAt})`.as("turn_first_at"),
|
|
2709
|
-
lastAt: sql`max(${metrics$1.occurredAt})`.as("turn_last_at"),
|
|
2710
|
-
durationMs: metricSum("duration_ms").as("turn_duration_ms"),
|
|
2711
|
-
tokens: metricSum("total_tokens").as("turn_tokens")
|
|
2712
|
-
}).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");
|
|
2713
|
-
return getDb().select({
|
|
2714
|
-
userId: sql`${juniorIdentities.userId}`.as("root_user_id"),
|
|
2715
|
-
rootConversationId: conversationRootId.as("person_root_id"),
|
|
2716
|
-
firstAt: sql`min(${conversations.firstAt})`.as("root_first_at"),
|
|
2717
|
-
lastAt: sql`max(${conversations.lastAt})`.as("root_last_at"),
|
|
2718
|
-
durationMs: sql`sum(${conversations.durationMs})`.as("root_duration_ms"),
|
|
2719
|
-
tokens: sql`sum(${conversations.tokens})`.as("root_tokens"),
|
|
2720
|
-
slackUserId: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END)`.as("root_slack_user_id"),
|
|
2721
|
-
slackUserName: sql`max(CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END)`.as("root_slack_user_name")
|
|
2722
|
-
}).from(conversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, conversations.identityId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, conversations.conversationId)).groupBy(juniorIdentities.userId, conversationRootId).as("person_roots");
|
|
2723
|
-
}
|
|
2724
|
-
/** Join a person's roots to the root Conversation rows. */
|
|
2725
|
-
function personRootJoin(roots) {
|
|
2726
|
-
return eq(turnRoot.conversationId, roots.rootConversationId);
|
|
2727
|
-
}
|
|
2728
|
-
/**
|
|
2729
|
-
* Aggregate rows from {@link personRoots} joined to {@link turnRoot}. A
|
|
2730
|
-
* Conversation counts once for each person who ran a Turn in it, and child
|
|
2731
|
-
* Conversation Turns count for the root. Each row is one root of one person,
|
|
2732
|
-
* so plain counts need no DISTINCT. Active and failed read the root's current
|
|
2733
|
-
* status.
|
|
2734
|
-
*/
|
|
2735
|
-
function rootAggregateColumns(roots) {
|
|
2736
|
-
return {
|
|
2737
|
-
active: sql`(count(*) FILTER (WHERE ${conversationIsActiveSql(turnRoot)}))::integer`,
|
|
2738
|
-
conversations: sql`count(*)::integer`,
|
|
2739
|
-
durationMs: sql`COALESCE(sum(${roots.durationMs}), 0)::double precision`,
|
|
2740
|
-
failed: sql`(count(*) FILTER (WHERE ${conversationTurnFailedSql(turnRoot)} AND ${turnRoot.stoppedAt} IS NULL))::integer`,
|
|
2741
|
-
tokens: sql`sum(${roots.tokens})::double precision`
|
|
2742
|
-
};
|
|
2743
|
-
}
|
|
2744
|
-
/**
|
|
2745
|
-
* Count the UTC days on which the grouped person ran a Turn. A correlated
|
|
2746
|
-
* subquery runs once per person through the actor index, so a bad row
|
|
2747
|
-
* estimate cannot make Postgres repeat it once per root.
|
|
2748
|
-
*/
|
|
2749
|
-
function personActiveDays() {
|
|
2750
|
-
const days = getDb().selectDistinct({ day: sql`(${metrics$1.occurredAt} AT TIME ZONE 'UTC')::date`.as("turn_day") }).from(metrics$1).innerJoin(juniorIdentities, eq(juniorIdentities.id, metrics$1.actorIdentityId)).where(and(eq(juniorIdentities.userId, juniorUsers.id), eq(juniorIdentities.kind, "user"), eq(juniorIdentities.emailVerified, true))).as("person_turn_days");
|
|
2751
|
-
return sql`(${getDb().select({ days: sql`count(*)` }).from(days)})::integer`;
|
|
2752
|
-
}
|
|
2753
|
-
/**
|
|
2754
|
-
* Select the identity, Turn range, and totals of one person from roots
|
|
2755
|
-
* grouped by person and joined to {@link juniorUsers}.
|
|
2756
|
-
*/
|
|
2757
|
-
function personTotalColumns(roots) {
|
|
2758
|
-
return {
|
|
2759
|
-
...rootAggregateColumns(roots),
|
|
2760
|
-
activeDays: personActiveDays(),
|
|
2761
|
-
email: sql`${juniorUsers.primaryEmailNormalized}`,
|
|
2762
|
-
firstSeenAt: sql`min(${roots.firstAt})`.mapWith(metrics$1.occurredAt),
|
|
2763
|
-
fullName: juniorUsers.displayName,
|
|
2764
|
-
lastSeenAt: sql`max(${roots.lastAt})`.mapWith(metrics$1.occurredAt),
|
|
2765
|
-
slackUserId: sql`max(${roots.slackUserId})`,
|
|
2766
|
-
slackUserName: sql`max(${roots.slackUserName})`
|
|
2767
|
-
};
|
|
2768
|
-
}
|
|
2769
|
-
/** Normalize emails before matching people API rows. */
|
|
2770
|
-
function normalizeEmail$1(email) {
|
|
2771
|
-
return email?.trim().toLowerCase() || void 0;
|
|
2935
|
+
const imageQuerySchema = z.object({
|
|
2936
|
+
v: z.string().min(1).max(64).optional(),
|
|
2937
|
+
w: z.string().transform(Number).refine((width) => IMAGE_WIDTHS.some((allowed) => allowed === width))
|
|
2938
|
+
}).strict();
|
|
2939
|
+
// src/api/images/routes.ts
|
|
2940
|
+
/**
|
|
2941
|
+
* Create the route that serves external images from Junior, so browsers
|
|
2942
|
+
* never load them from another host. The path has a signed id, never the
|
|
2943
|
+
* address of the image.
|
|
2944
|
+
*/
|
|
2945
|
+
function createImageRoutes() {
|
|
2946
|
+
const app = new Hono();
|
|
2947
|
+
app.get("/:id", requireViewer, validateRequest("param", imageParamsSchema, "Invalid route parameters."), validateRequest("query", imageQuerySchema, "Invalid image width."), async (context) => {
|
|
2948
|
+
const image = decodeImageId(context.req.valid("param").id);
|
|
2949
|
+
const { v, w } = context.req.valid("query");
|
|
2950
|
+
const served = image && await readImage(context.get("viewer"), image, w);
|
|
2951
|
+
if (!served) throwApiError(404, "Image not found.");
|
|
2952
|
+
return imageResponse(served, Boolean(v));
|
|
2953
|
+
});
|
|
2954
|
+
return app;
|
|
2772
2955
|
}
|
|
2773
|
-
|
|
2774
|
-
|
|
2956
|
+
// src/api/spaces/access.ts
|
|
2957
|
+
/** Validate the `:spaceId` route parameter. */
|
|
2958
|
+
const spaceParamsValidator = validateRequest("param", spaceParamsSchema, "Invalid route parameters.");
|
|
2959
|
+
/** Write one Space as the API reports it. */
|
|
2960
|
+
function spaceReport(space) {
|
|
2775
2961
|
return {
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
failed: 0
|
|
2962
|
+
...space,
|
|
2963
|
+
createdAt: space.createdAt.toISOString(),
|
|
2964
|
+
updatedAt: space.updatedAt.toISOString(),
|
|
2965
|
+
archivedAt: space.archivedAt?.toISOString() ?? null
|
|
2781
2966
|
};
|
|
2782
2967
|
}
|
|
2783
|
-
/**
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
};
|
|
2968
|
+
/**
|
|
2969
|
+
* Return the Space that the viewer reads, or a 404. A private Space is a 404
|
|
2970
|
+
* to a person who is not a member, so the error does not show it exists.
|
|
2971
|
+
*/
|
|
2972
|
+
async function requireSpace(viewerUserId, spaceId) {
|
|
2973
|
+
const space = await readSpace(viewerUserId, spaceId);
|
|
2974
|
+
if (!space) throwApiError(404, "Space was not found.");
|
|
2975
|
+
return space;
|
|
2792
2976
|
}
|
|
2793
|
-
/**
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2977
|
+
/**
|
|
2978
|
+
* Return the Space that the viewer changes. Anyone can read a public Space,
|
|
2979
|
+
* but only members change a Space.
|
|
2980
|
+
*/
|
|
2981
|
+
async function requireMemberSpace(viewerUserId, spaceId) {
|
|
2982
|
+
const space = await requireSpace(viewerUserId, spaceId);
|
|
2983
|
+
if (!space.viewerIsMember) throwApiError(403, "Join the Space to change it.");
|
|
2984
|
+
return space;
|
|
2985
|
+
}
|
|
2986
|
+
/** Respond with the Space as the viewer sees it now. */
|
|
2987
|
+
async function spaceResponse(viewerUserId, spaceId, init) {
|
|
2988
|
+
return jsonResponse(spaceSchema, spaceReport(await requireSpace(viewerUserId, spaceId)), init);
|
|
2989
|
+
}
|
|
2990
|
+
// src/api/spaces/archive.ts
|
|
2991
|
+
/** Create the route that archives or restores a Space with its Conversations. */
|
|
2992
|
+
function createSpaceArchiveRoutes(options) {
|
|
2993
|
+
const app = new Hono();
|
|
2994
|
+
app.patch("/:spaceId/archive", requireViewer, spaceParamsValidator, validateRequest("json", archiveSpaceBodySchema, "Invalid request body."), async (context) => {
|
|
2995
|
+
const viewerUserId = context.get("viewer").id;
|
|
2996
|
+
const { spaceId } = context.req.valid("param");
|
|
2997
|
+
await requireMemberSpace(viewerUserId, spaceId);
|
|
2998
|
+
await setSpaceArchive({
|
|
2999
|
+
archived: context.req.valid("json").archived,
|
|
3000
|
+
queue: options.queue,
|
|
3001
|
+
spaceId
|
|
3002
|
+
});
|
|
3003
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
2800
3004
|
});
|
|
3005
|
+
return app;
|
|
2801
3006
|
}
|
|
3007
|
+
// src/api/spaces/configuration.ts
|
|
2802
3008
|
/**
|
|
2803
|
-
*
|
|
2804
|
-
*
|
|
3009
|
+
* Create the route that reads a Space's configuration. Anyone who reads the
|
|
3010
|
+
* Space reads it. Junior changes it with its `setSpaceConfiguration` tool,
|
|
3011
|
+
* when a member asks.
|
|
2805
3012
|
*/
|
|
2806
|
-
function
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
3013
|
+
function createSpaceConfigurationRoutes() {
|
|
3014
|
+
const app = new Hono();
|
|
3015
|
+
app.get("/:spaceId/configuration", requireViewer, spaceParamsValidator, async (context) => {
|
|
3016
|
+
const { spaceId } = context.req.valid("param");
|
|
3017
|
+
await requireSpace(context.get("viewer").id, spaceId);
|
|
3018
|
+
const entries = await listSpaceConfiguration(spaceId);
|
|
3019
|
+
return jsonResponse(spaceConfigurationSchema, { entries: entries.map((entry) => ({
|
|
3020
|
+
...entry,
|
|
3021
|
+
updatedAt: entry.updatedAt.toISOString()
|
|
3022
|
+
})) });
|
|
2812
3023
|
});
|
|
3024
|
+
return app;
|
|
2813
3025
|
}
|
|
3026
|
+
// src/api/spaces/lead.ts
|
|
2814
3027
|
/**
|
|
2815
|
-
*
|
|
2816
|
-
*
|
|
3028
|
+
* Create the route that finds a Space's Lead. A member's first read creates
|
|
3029
|
+
* it. Anyone who reads the Space reads its Lead, which is public like the
|
|
3030
|
+
* Space.
|
|
2817
3031
|
*/
|
|
2818
|
-
function
|
|
2819
|
-
const
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
3032
|
+
function createSpaceLeadRoutes() {
|
|
3033
|
+
const app = new Hono();
|
|
3034
|
+
app.get("/:spaceId/lead", requireViewer, spaceParamsValidator, async (context) => {
|
|
3035
|
+
const viewer = context.get("viewer");
|
|
3036
|
+
const space = await requireSpace(viewer.id, context.req.valid("param").spaceId);
|
|
3037
|
+
const lead = space.viewerIsMember ? await getSpaceLead({
|
|
3038
|
+
member: viewer,
|
|
3039
|
+
space
|
|
3040
|
+
}) : await readSpaceLead(space.id);
|
|
3041
|
+
if (!lead) throwApiError(404, "This Space has no Lead yet.");
|
|
3042
|
+
const lastSeq = await readConversationLastEventSeq(getSqlExecutor(), lead.conversationId);
|
|
3043
|
+
const watches = await listWatches({ conversationId: lead.conversationId });
|
|
3044
|
+
const watchedConversationIds = [...new Set(watches.filter((watch) => watch.namespace === "junior" && isAgentResourceType(watch.resourceType)).map((watch) => watch.identifier))];
|
|
3045
|
+
return jsonResponse(leadSchema, {
|
|
3046
|
+
conversationId: lead.conversationId,
|
|
3047
|
+
lastSeq,
|
|
3048
|
+
watchedConversationIds
|
|
3049
|
+
}, { headers: { "cache-control": "private, no-store" } });
|
|
2824
3050
|
});
|
|
3051
|
+
return app;
|
|
2825
3052
|
}
|
|
2826
|
-
|
|
2827
|
-
function statsItems(map) {
|
|
2828
|
-
return [...map.values()].sort((left, right) => right.conversations - left.conversations || right.durationMs - left.durationMs || left.label.localeCompare(right.label));
|
|
2829
|
-
}
|
|
3053
|
+
// src/api/spaces/members.ts
|
|
2830
3054
|
/**
|
|
2831
|
-
*
|
|
2832
|
-
*
|
|
2833
|
-
*
|
|
2834
|
-
* Any provider counts, so Slack and dashboard (web) Conversations roll up to
|
|
2835
|
-
* the same person. System identities never count.
|
|
3055
|
+
* Create the routes that list a Space's members, add a member, and join or
|
|
3056
|
+
* leave it.
|
|
2836
3057
|
*/
|
|
2837
|
-
function
|
|
2838
|
-
const
|
|
2839
|
-
|
|
3058
|
+
function createSpaceMemberRoutes() {
|
|
3059
|
+
const app = new Hono();
|
|
3060
|
+
app.get("/:spaceId/members", requireViewer, spaceParamsValidator, async (context) => {
|
|
3061
|
+
const { spaceId } = context.req.valid("param");
|
|
3062
|
+
await requireSpace(context.get("viewer").id, spaceId);
|
|
3063
|
+
const members = await listSpaceMembers(spaceId);
|
|
3064
|
+
return jsonResponse(spaceMemberListSchema, { members: members.map((member) => ({
|
|
3065
|
+
...member,
|
|
3066
|
+
joinedAt: member.joinedAt.toISOString()
|
|
3067
|
+
})) });
|
|
3068
|
+
});
|
|
3069
|
+
app.post("/:spaceId/members", requireViewer, spaceParamsValidator, validateRequest("json", addSpaceMemberBodySchema, "Invalid request body."), async (context) => {
|
|
3070
|
+
const viewerUserId = context.get("viewer").id;
|
|
3071
|
+
const { spaceId } = context.req.valid("param");
|
|
3072
|
+
await requireMemberSpace(viewerUserId, spaceId);
|
|
3073
|
+
const email = normalizeIdentityEmail(context.req.valid("json").email);
|
|
3074
|
+
const person = email ? await readCachedUserByEmail(getDb(), email) : void 0;
|
|
3075
|
+
if (!person) throwApiError(404, "No person has that email.");
|
|
3076
|
+
await joinSpace(spaceId, person.user.id);
|
|
3077
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
3078
|
+
});
|
|
3079
|
+
app.put("/:spaceId/members/me", requireViewer, spaceParamsValidator, async (context) => {
|
|
3080
|
+
const viewerUserId = context.get("viewer").id;
|
|
3081
|
+
const { spaceId } = context.req.valid("param");
|
|
3082
|
+
await requireSpace(viewerUserId, spaceId);
|
|
3083
|
+
await joinSpace(spaceId, viewerUserId);
|
|
3084
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
3085
|
+
});
|
|
3086
|
+
app.delete("/:spaceId/members/me", requireViewer, spaceParamsValidator, async (context) => {
|
|
3087
|
+
const viewerUserId = context.get("viewer").id;
|
|
3088
|
+
const { spaceId } = context.req.valid("param");
|
|
3089
|
+
const space = await requireSpace(viewerUserId, spaceId);
|
|
3090
|
+
if (await leaveSpace(spaceId, viewerUserId) === "last_member") throwApiError(409, "The last member can't leave a private Space.");
|
|
3091
|
+
if (space.visibility === "private") return jsonResponse(spaceSchema, {
|
|
3092
|
+
...spaceReport(space),
|
|
3093
|
+
memberCount: space.memberCount - 1,
|
|
3094
|
+
viewerIsMember: false
|
|
3095
|
+
});
|
|
3096
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
3097
|
+
});
|
|
3098
|
+
return app;
|
|
2840
3099
|
}
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
})
|
|
3100
|
+
// src/api/spaces/space.ts
|
|
3101
|
+
/** Create the routes that list, create, read, and change Spaces. */
|
|
3102
|
+
function createSpaceRoutes() {
|
|
3103
|
+
const app = new Hono();
|
|
3104
|
+
app.get("/", requireViewer, validateRequest("query", spaceListQuerySchema, "Invalid query parameters."), async (context) => {
|
|
3105
|
+
const spaces = await listSpaces(context.get("viewer").id, context.req.valid("query"));
|
|
3106
|
+
return jsonResponse(spaceListSchema, { spaces: spaces.map(spaceReport) });
|
|
3107
|
+
});
|
|
3108
|
+
app.post("/", requireViewer, validateRequest("json", createSpaceBodySchema, "Invalid request body."), async (context) => {
|
|
3109
|
+
const body = context.req.valid("json");
|
|
3110
|
+
const space = await createSpace({
|
|
3111
|
+
creatorUserId: context.get("viewer").id,
|
|
3112
|
+
name: body.name,
|
|
3113
|
+
description: body.description ?? null,
|
|
3114
|
+
visibility: body.visibility
|
|
3115
|
+
});
|
|
3116
|
+
return jsonResponse(spaceSchema, spaceReport(space), { status: 201 });
|
|
3117
|
+
});
|
|
3118
|
+
app.get("/:spaceId", requireViewer, spaceParamsValidator, async (context) => spaceResponse(context.get("viewer").id, context.req.valid("param").spaceId));
|
|
3119
|
+
app.patch("/:spaceId", requireViewer, spaceParamsValidator, validateRequest("json", updateSpaceBodySchema, "Invalid request body."), async (context) => {
|
|
3120
|
+
const viewerUserId = context.get("viewer").id;
|
|
3121
|
+
const { spaceId } = context.req.valid("param");
|
|
3122
|
+
const { visibility, ...changes } = context.req.valid("json");
|
|
3123
|
+
if (visibility !== void 0) throwApiError(400, "A Space's visibility is set when it is created. Create a new Space for a different audience.");
|
|
3124
|
+
await requireMemberSpace(viewerUserId, spaceId);
|
|
3125
|
+
await updateSpace(spaceId, changes);
|
|
3126
|
+
return await spaceResponse(viewerUserId, spaceId);
|
|
3127
|
+
});
|
|
3128
|
+
return app;
|
|
2869
3129
|
}
|
|
2870
3130
|
// src/api/people/card.ts
|
|
2871
3131
|
const RECENT_DAYS = 30;
|
|
@@ -2969,7 +3229,7 @@ async function readPersonCard(email, viewer) {
|
|
|
2969
3229
|
}
|
|
2970
3230
|
// src/api/people/code.ts
|
|
2971
3231
|
/** Read person-scoped native code activity for one People profile. */
|
|
2972
|
-
async function readPeopleCode(email, cursor) {
|
|
3232
|
+
async function readPeopleCode(email, cursor, viewer) {
|
|
2973
3233
|
const subject = await findUserByEmail(email);
|
|
2974
3234
|
if (!subject) {
|
|
2975
3235
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -2990,7 +3250,8 @@ async function readPeopleCode(email, cursor) {
|
|
|
2990
3250
|
}
|
|
2991
3251
|
return await readPersonCodeOverview({
|
|
2992
3252
|
cursor,
|
|
2993
|
-
userId: subject.id
|
|
3253
|
+
userId: subject.id,
|
|
3254
|
+
viewer
|
|
2994
3255
|
});
|
|
2995
3256
|
}
|
|
2996
3257
|
// src/api/people/list.query.ts
|
|
@@ -3094,8 +3355,10 @@ function rangeWindow(spend, conversations) {
|
|
|
3094
3355
|
}
|
|
3095
3356
|
/**
|
|
3096
3357
|
* Count active people and root Conversations in each bucket of each series,
|
|
3097
|
-
* from one read of the Turns since `since`. The
|
|
3098
|
-
*
|
|
3358
|
+
* from one read of the Turns since `since`. The Turns are grouped by bucket,
|
|
3359
|
+
* Identity, and Conversation before any join, so the joins and the counts
|
|
3360
|
+
* read a few rows for each Conversation, not one for each Turn. Six-hour
|
|
3361
|
+
* buckets roll up hour buckets.
|
|
3099
3362
|
*
|
|
3100
3363
|
* Each count is a hashed `DISTINCT` of (bucket, person) or (bucket, root)
|
|
3101
3364
|
* pairs, which costs less than sorting for `COUNT(DISTINCT)`.
|
|
@@ -3103,11 +3366,16 @@ function rangeWindow(spend, conversations) {
|
|
|
3103
3366
|
function activityRows(since, read) {
|
|
3104
3367
|
const utc = sql`(${metrics.occurredAt} AT TIME ZONE 'UTC')`;
|
|
3105
3368
|
const readBucket = sql`date_trunc(${sql.raw(`'${read}'`)}, ${utc})`;
|
|
3369
|
+
const bucketTurns = getDb().select({
|
|
3370
|
+
bucket: readBucket.as("turn_bucket"),
|
|
3371
|
+
identityId: sql`${metrics.actorIdentityId}`.as("turn_identity_id"),
|
|
3372
|
+
conversationId: sql`${metrics.conversationId}`.as("turn_conversation_id")
|
|
3373
|
+
}).from(metrics).where(and(eq(metrics.metric, "duration_ms"), gte(metrics.occurredAt, since))).groupBy(readBucket, metrics.actorIdentityId, metrics.conversationId).as("activity_bucket_turns");
|
|
3106
3374
|
const turns = getDb().$with("activity_turns").as(getDb().select({
|
|
3107
|
-
bucket:
|
|
3375
|
+
bucket: sql`${bucketTurns.bucket}`.as("activity_bucket"),
|
|
3108
3376
|
userId: sql`${juniorUsers.id}`.as("activity_user_id"),
|
|
3109
3377
|
rootConversationId: conversationRootId.as("activity_root_id")
|
|
3110
|
-
}).from(
|
|
3378
|
+
}).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));
|
|
3111
3379
|
const unitCounts = (unit) => {
|
|
3112
3380
|
const bucket = unit === "six_hour" ? sql`date_trunc('day', ${turns.bucket}) + FLOOR(EXTRACT(HOUR FROM ${turns.bucket}) / 6) * INTERVAL '6 hours'` : sql`${turns.bucket}`;
|
|
3113
3381
|
const pairs = (kind, id) => getDb().selectDistinct({
|
|
@@ -3249,6 +3517,8 @@ async function readPeopleListFromSql() {
|
|
|
3249
3517
|
* gets the same list, so one cached copy serves them all.
|
|
3250
3518
|
*/
|
|
3251
3519
|
const readPeopleList = createCachedReport({
|
|
3520
|
+
freshMs: 9e5,
|
|
3521
|
+
keepMs: 6048e5,
|
|
3252
3522
|
key: "people-list",
|
|
3253
3523
|
read: readPeopleListFromSql,
|
|
3254
3524
|
refreshFailedEvent: "people_list.refresh.failed",
|
|
@@ -3264,7 +3534,7 @@ async function readPeoplePluginReports(args) {
|
|
|
3264
3534
|
reports: [],
|
|
3265
3535
|
source: "plugins"
|
|
3266
3536
|
});
|
|
3267
|
-
const { getPluginProfileReports } = await import("./
|
|
3537
|
+
const { getPluginProfileReports } = await import("./db-DXTOYRzR.js").then((n) => n.W);
|
|
3268
3538
|
return pluginOperationalReportFeedSchema.parse({
|
|
3269
3539
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3270
3540
|
reports: await getPluginProfileReports({
|
|
@@ -3283,7 +3553,7 @@ function emptyProfile(email, nowMs) {
|
|
|
3283
3553
|
start.setUTCDate(start.getUTCDate() - 364);
|
|
3284
3554
|
return {
|
|
3285
3555
|
activityDays: activityDays(/* @__PURE__ */ new Map(), nowMs),
|
|
3286
|
-
activityHours: activityHours(/* @__PURE__ */ new Map(), nowMs),
|
|
3556
|
+
activityHours: activityHours$1(/* @__PURE__ */ new Map(), nowMs),
|
|
3287
3557
|
activitySixHours: activitySixHours(/* @__PURE__ */ new Map(), nowMs),
|
|
3288
3558
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3289
3559
|
locations: [],
|
|
@@ -3404,7 +3674,7 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
3404
3674
|
const channel = channelExpression(turnRoot);
|
|
3405
3675
|
const hourWindow = trailingUtcHourWindow(nowMs, 168);
|
|
3406
3676
|
const [totalsRows, dayRows, hourRows, locationRows, surfaceRows, recentRows] = await Promise.all([
|
|
3407
|
-
getDb().select(personTotalColumns(roots)).from(roots).innerJoin(juniorUsers, eq(juniorUsers.id, roots.userId)).innerJoin(turnRoot, personRootJoin(roots)).groupBy(juniorUsers.id),
|
|
3677
|
+
getDb().select(personTotalColumns(roots)).from(roots).innerJoin(juniorUsers, eq(juniorUsers.id, roots.userId)).innerJoin(turnRoot, personRootJoin(roots)).where(eq(juniorUsers.primaryEmailNormalized, normalizedEmail)).groupBy(juniorUsers.id),
|
|
3408
3678
|
rootBucketRows({
|
|
3409
3679
|
email: normalizedEmail,
|
|
3410
3680
|
since: start,
|
|
@@ -3451,7 +3721,7 @@ async function readPeopleProfileFromSql(email, options = {}) {
|
|
|
3451
3721
|
]);
|
|
3452
3722
|
return {
|
|
3453
3723
|
activityDays: activityDays(days, nowMs),
|
|
3454
|
-
activityHours: activityHours(hours, nowMs),
|
|
3724
|
+
activityHours: activityHours$1(hours, nowMs),
|
|
3455
3725
|
activitySixHours: activitySixHours(hours, nowMs),
|
|
3456
3726
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3457
3727
|
locations: statsItems(locations),
|
|
@@ -3635,7 +3905,7 @@ function createPeopleRoutes(options) {
|
|
|
3635
3905
|
app.get("/:email/code", validateRequest("param", personParamsSchema, "Invalid route parameters."), validateRequest("query", personCodeQuerySchema, "Invalid code query."), async (context) => {
|
|
3636
3906
|
const { email } = context.req.valid("param");
|
|
3637
3907
|
const { cursor } = context.req.valid("query");
|
|
3638
|
-
return jsonResponse(codePersonReportSchema, await readPeopleCode(email, cursor));
|
|
3908
|
+
return jsonResponse(codePersonReportSchema, await readPeopleCode(email, cursor, context.get("viewer")));
|
|
3639
3909
|
});
|
|
3640
3910
|
app.get("/:email", validateRequest("param", personParamsSchema, "Invalid route parameters."), async (context) => {
|
|
3641
3911
|
const { email } = context.req.valid("param");
|
|
@@ -3736,6 +4006,263 @@ function createPersonalTokenRoutes() {
|
|
|
3736
4006
|
});
|
|
3737
4007
|
return app;
|
|
3738
4008
|
}
|
|
4009
|
+
// src/chat/automations/search.ts
|
|
4010
|
+
const EXACT_ID_WEIGHT = 4;
|
|
4011
|
+
/**
|
|
4012
|
+
* Find the Automations that the viewer owns or that are shared to them, as
|
|
4013
|
+
* the Automations list shows them and with its titles. A word of the title, task, or event
|
|
4014
|
+
* trigger starts with each word of the query, the title is close to the
|
|
4015
|
+
* query despite a typo, or the query holds the Automation's id. Best match
|
|
4016
|
+
* first. Reads the GIN indexes `junior_automations_search_idx` and
|
|
4017
|
+
* `junior_automations_title_trgm_idx`.
|
|
4018
|
+
*/
|
|
4019
|
+
async function searchAutomationsForViewer(viewer, query, limit) {
|
|
4020
|
+
const db = getDb();
|
|
4021
|
+
const collection = viewerAutomationCollection(viewer);
|
|
4022
|
+
const automation = alias(juniorAutomations, "search_automation");
|
|
4023
|
+
const candidates = db.select({
|
|
4024
|
+
activityAtMs: collection.activityAtMs,
|
|
4025
|
+
id: collection.id,
|
|
4026
|
+
kind: collection.kind,
|
|
4027
|
+
state: collection.state,
|
|
4028
|
+
task: collection.task,
|
|
4029
|
+
title: collection.title
|
|
4030
|
+
}).from(collection).innerJoin(automation, eq(automation.id, collection.id)).where(and(ne(automation.status, "deleted"), or(prefixMatch(automationSearchDocument(automation), query), fuzzyMatch(automationFuzzyTitle(automation), query), query.tokens.length > 0 ? inArray(automation.id, query.tokens) : void 0))).orderBy(desc(collection.activityAtMs), asc(collection.id)).limit(200).as("automation_candidates");
|
|
4031
|
+
const ranked = alias(juniorAutomations, "ranked_automation");
|
|
4032
|
+
const document = automationSearchDocument(ranked);
|
|
4033
|
+
const title = automationFuzzyTitle(ranked);
|
|
4034
|
+
const rows = await db.select({
|
|
4035
|
+
activityAtMs: candidates.activityAtMs,
|
|
4036
|
+
fuzzy: fuzzyRank(title, query),
|
|
4037
|
+
fuzzyMatched: fuzzyMatch(title, query),
|
|
4038
|
+
id: candidates.id,
|
|
4039
|
+
kind: candidates.kind,
|
|
4040
|
+
lexical: prefixRank(document, query),
|
|
4041
|
+
lexicalMatched: prefixMatch(document, query),
|
|
4042
|
+
state: candidates.state,
|
|
4043
|
+
task: candidates.task,
|
|
4044
|
+
title: candidates.title
|
|
4045
|
+
}).from(candidates).innerJoin(ranked, eq(ranked.id, candidates.id));
|
|
4046
|
+
return rankSearchMatches(scoredSearchMatches(rows, {
|
|
4047
|
+
exact: (row) => query.tokens.includes(row.id) ? 1 : void 0,
|
|
4048
|
+
fuzzy: (row) => row.fuzzyMatched ? Number(row.fuzzy) : void 0,
|
|
4049
|
+
lexical: (row) => row.lexicalMatched ? Number(row.lexical) : void 0
|
|
4050
|
+
}), {
|
|
4051
|
+
key: (row) => row.id,
|
|
4052
|
+
tiebreak: (left, right) => right.activityAtMs - left.activityAtMs || left.id.localeCompare(right.id),
|
|
4053
|
+
weights: { exact: EXACT_ID_WEIGHT }
|
|
4054
|
+
}).slice(0, limit).flatMap((row) => row.state === "deleted" ? [] : [{
|
|
4055
|
+
id: row.id,
|
|
4056
|
+
kind: row.kind,
|
|
4057
|
+
status: row.state,
|
|
4058
|
+
title: collectionRowTitle(row)
|
|
4059
|
+
}]);
|
|
4060
|
+
}
|
|
4061
|
+
// src/chat/inbox-items/search.ts
|
|
4062
|
+
/**
|
|
4063
|
+
* Find the items of the viewer's own Inbox, open and closed, as the Inbox
|
|
4064
|
+
* shows them. A word of the title or body starts with each word of the
|
|
4065
|
+
* query, or the title is close to the query despite a typo. Open items come
|
|
4066
|
+
* first, each group best match first. Reads the GIN indexes
|
|
4067
|
+
* `junior_inbox_items_search_idx` and `junior_inbox_items_title_trgm_idx`.
|
|
4068
|
+
*/
|
|
4069
|
+
async function searchInboxItemsForUser(viewer, query, limit) {
|
|
4070
|
+
const db = getDb();
|
|
4071
|
+
const items = juniorInboxItems;
|
|
4072
|
+
const candidates = db.select({ id: items.id }).from(items).where(and(or(prefixMatch(inboxItemSearchDocument(items), query), fuzzyMatch(inboxItemFuzzyTitle(items), query)), inboxItemVisibleTo(inboxItemReaderForUser(viewer)), inboxItemForUser(viewer.id))).orderBy(desc(items.updatedAt), desc(items.id)).limit(200).as("inbox_item_candidates");
|
|
4073
|
+
const item = alias(juniorInboxItems, "inbox_item");
|
|
4074
|
+
const document = inboxItemSearchDocument(item);
|
|
4075
|
+
const title = inboxItemFuzzyTitle(item);
|
|
4076
|
+
const rows = await db.select({
|
|
4077
|
+
fuzzy: fuzzyRank(title, query),
|
|
4078
|
+
fuzzyMatched: fuzzyMatch(title, query),
|
|
4079
|
+
id: item.id,
|
|
4080
|
+
lexical: prefixRank(document, query),
|
|
4081
|
+
lexicalMatched: prefixMatch(document, query),
|
|
4082
|
+
status: item.status,
|
|
4083
|
+
title: item.title,
|
|
4084
|
+
updatedAt: item.updatedAt
|
|
4085
|
+
}).from(candidates).innerJoin(item, eq(item.id, candidates.id));
|
|
4086
|
+
const ranked = rankSearchMatches(scoredSearchMatches(rows, {
|
|
4087
|
+
fuzzy: (row) => row.fuzzyMatched ? Number(row.fuzzy) : void 0,
|
|
4088
|
+
lexical: (row) => row.lexicalMatched ? Number(row.lexical) : void 0
|
|
4089
|
+
}), {
|
|
4090
|
+
key: (row) => row.id,
|
|
4091
|
+
tiebreak: (left, right) => right.updatedAt.getTime() - left.updatedAt.getTime() || right.id.localeCompare(left.id)
|
|
4092
|
+
});
|
|
4093
|
+
return [...ranked.filter((row) => row.status === "open"), ...ranked.filter((row) => row.status !== "open")].slice(0, limit).map((row) => ({
|
|
4094
|
+
id: row.id,
|
|
4095
|
+
status: row.status,
|
|
4096
|
+
title: row.title
|
|
4097
|
+
}));
|
|
4098
|
+
}
|
|
4099
|
+
// src/chat/memory/search.ts
|
|
4100
|
+
const MEMORY_SEARCH_TITLE_CHARS = 120;
|
|
4101
|
+
const VECTOR_QUERY_MIN_CHARS = 3;
|
|
4102
|
+
const QUERY_EMBEDDING_TTL_MS = 6e5;
|
|
4103
|
+
const QUERY_EMBEDDING_KEY_PREFIX = "memory-search-embedding:v1";
|
|
4104
|
+
/** `junior_stats` counter of the embedding spend of typed memory search. */
|
|
4105
|
+
const EMBEDDING_COST_STAT = {
|
|
4106
|
+
metric: "embedding_cost_micro_usd",
|
|
4107
|
+
namespace: "search"
|
|
4108
|
+
};
|
|
4109
|
+
const cachedEmbeddingSchema = z.object({
|
|
4110
|
+
dimensions: z.number().int(),
|
|
4111
|
+
model: z.string(),
|
|
4112
|
+
provider: z.string(),
|
|
4113
|
+
vectors: z.array(z.array(z.number()))
|
|
4114
|
+
});
|
|
4115
|
+
function queryEmbeddingKey(model, input) {
|
|
4116
|
+
const hash = createHash("sha256").update(JSON.stringify([input.inputType ?? "", ...input.texts])).digest("hex");
|
|
4117
|
+
return `${QUERY_EMBEDDING_KEY_PREFIX}:${model}:${hash}`;
|
|
4118
|
+
}
|
|
4119
|
+
async function recordEmbeddingCost(model, costUsd) {
|
|
4120
|
+
await runBestEffort(() => addStats([{
|
|
4121
|
+
...EMBEDDING_COST_STAT,
|
|
4122
|
+
count: usdToMicroUsdUnbiased(costUsd),
|
|
4123
|
+
name: model
|
|
4124
|
+
}]), "memory.search.embedding_cost_record_failed");
|
|
4125
|
+
}
|
|
4126
|
+
/**
|
|
4127
|
+
* Embed typed search text, and reuse the vector of the same text for a few
|
|
4128
|
+
* minutes, so a person who types it again makes no model call. A search has
|
|
4129
|
+
* no Conversation to bill, so each call adds its cost to a daily
|
|
4130
|
+
* `junior_stats` counter. The write runs with the vector query; `settled`
|
|
4131
|
+
* waits for it.
|
|
4132
|
+
*/
|
|
4133
|
+
function cachedQueryEmbedder() {
|
|
4134
|
+
const embedder = createPluginEmbedder("memory");
|
|
4135
|
+
const costWrites = [];
|
|
4136
|
+
return {
|
|
4137
|
+
embedder: {
|
|
4138
|
+
model: embedder.model,
|
|
4139
|
+
provider: embedder.provider,
|
|
4140
|
+
async embedTexts(input) {
|
|
4141
|
+
const state = getStateAdapter();
|
|
4142
|
+
const key = queryEmbeddingKey(embedder.model, input);
|
|
4143
|
+
const cached = cachedEmbeddingSchema.safeParse(await state.get(key));
|
|
4144
|
+
if (cached.success) return cached.data;
|
|
4145
|
+
const result = await embedder.embedTexts(input);
|
|
4146
|
+
const { costUsd, ...embedding } = result;
|
|
4147
|
+
if (costUsd !== void 0) costWrites.push(recordEmbeddingCost(embedder.model, costUsd));
|
|
4148
|
+
await runBestEffort(() => state.set(key, embedding, QUERY_EMBEDDING_TTL_MS), "memory.search.embedding_cache_write_failed");
|
|
4149
|
+
return result;
|
|
4150
|
+
}
|
|
4151
|
+
},
|
|
4152
|
+
settled: async () => {
|
|
4153
|
+
await Promise.all(costWrites);
|
|
4154
|
+
}
|
|
4155
|
+
};
|
|
4156
|
+
}
|
|
4157
|
+
/**
|
|
4158
|
+
* Find the memories that the Memories page shows every User, active public
|
|
4159
|
+
* memory only, with the hybrid word and vector search of automatic recall.
|
|
4160
|
+
* Text of 3 or more characters is embedded once, from a short cache when it
|
|
4161
|
+
* was typed recently; when that fails, words alone match.
|
|
4162
|
+
*/
|
|
4163
|
+
async function searchPublicMemories(text, limit) {
|
|
4164
|
+
const query = text.trim().length >= VECTOR_QUERY_MIN_CHARS ? cachedQueryEmbedder() : void 0;
|
|
4165
|
+
const memories = await searchTypedMemories({
|
|
4166
|
+
db: memoryDb(getDb()),
|
|
4167
|
+
embedder: query?.embedder,
|
|
4168
|
+
limit,
|
|
4169
|
+
nowMs: Date.now(),
|
|
4170
|
+
query: text
|
|
4171
|
+
});
|
|
4172
|
+
await query?.settled();
|
|
4173
|
+
return memories.map((memory) => ({
|
|
4174
|
+
id: memory.id,
|
|
4175
|
+
title: memory.content.slice(0, MEMORY_SEARCH_TITLE_CHARS)
|
|
4176
|
+
}));
|
|
4177
|
+
}
|
|
4178
|
+
// src/chat/todos/search.ts
|
|
4179
|
+
/**
|
|
4180
|
+
* Find the To-dos whose Conversation shows its private content to the
|
|
4181
|
+
* viewer: its root is public, or the viewer is a Participant of the root,
|
|
4182
|
+
* as `conversationAccessFromRows` decides. Other viewers see only redacted
|
|
4183
|
+
* To-dos, so a title match must not show that the To-do exists. A word of
|
|
4184
|
+
* the title starts with each word of the query, or the title is close to
|
|
4185
|
+
* the query despite a typo. Open To-dos come first, each group best match
|
|
4186
|
+
* first. Reads the GIN indexes `junior_todos_search_idx` and
|
|
4187
|
+
* `junior_todos_title_trgm_idx`.
|
|
4188
|
+
*/
|
|
4189
|
+
async function searchTodosForViewer(viewer, query, limit) {
|
|
4190
|
+
const db = getDb();
|
|
4191
|
+
const todos = juniorTodos;
|
|
4192
|
+
const conversation = alias(juniorConversations, "todo_conversation");
|
|
4193
|
+
const candidates = db.select({
|
|
4194
|
+
conversationId: todos.conversationId,
|
|
4195
|
+
id: todos.id
|
|
4196
|
+
}).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))).leftJoin(juniorDestinations, eq(juniorDestinations.id, juniorConversations.destinationId)).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");
|
|
4197
|
+
const todo = alias(juniorTodos, "todo");
|
|
4198
|
+
const document = todoSearchDocument(todo);
|
|
4199
|
+
const title = todoFuzzyTitle(todo);
|
|
4200
|
+
const rows = await db.select({
|
|
4201
|
+
conversationId: todo.conversationId,
|
|
4202
|
+
fuzzy: fuzzyRank(title, query),
|
|
4203
|
+
fuzzyMatched: fuzzyMatch(title, query),
|
|
4204
|
+
id: todo.id,
|
|
4205
|
+
lexical: prefixRank(document, query),
|
|
4206
|
+
lexicalMatched: prefixMatch(document, query),
|
|
4207
|
+
status: todo.status,
|
|
4208
|
+
title: todo.title,
|
|
4209
|
+
updatedAt: todo.updatedAt
|
|
4210
|
+
}).from(candidates).innerJoin(todo, and(eq(todo.conversationId, candidates.conversationId), eq(todo.id, candidates.id)));
|
|
4211
|
+
const ranked = rankSearchMatches(scoredSearchMatches(rows, {
|
|
4212
|
+
fuzzy: (row) => row.fuzzyMatched ? Number(row.fuzzy) : void 0,
|
|
4213
|
+
lexical: (row) => row.lexicalMatched ? Number(row.lexical) : void 0
|
|
4214
|
+
}), {
|
|
4215
|
+
key: (row) => `${row.conversationId}:${row.id}`,
|
|
4216
|
+
tiebreak: (left, right) => right.updatedAt.getTime() - left.updatedAt.getTime() || right.conversationId.localeCompare(left.conversationId) || right.id - left.id
|
|
4217
|
+
});
|
|
4218
|
+
return [...ranked.filter((row) => isOpenTodoStatus(row.status)), ...ranked.filter((row) => !isOpenTodoStatus(row.status))].slice(0, limit).map(({ conversationId, id, status, title }) => ({
|
|
4219
|
+
conversationId,
|
|
4220
|
+
id,
|
|
4221
|
+
status,
|
|
4222
|
+
title
|
|
4223
|
+
}));
|
|
4224
|
+
}
|
|
4225
|
+
// src/chat/omni-search/search.ts
|
|
4226
|
+
const OMNI_SEARCH_SOURCE_LIMIT = 8;
|
|
4227
|
+
/**
|
|
4228
|
+
* Search the named sources for text that a person types, as `viewer`. Each
|
|
4229
|
+
* source returns only what its own page shows the viewer, ranked by the
|
|
4230
|
+
* shared search ranking, and the sources read at once. Text with no letters
|
|
4231
|
+
* or digits matches nothing and reads nothing.
|
|
4232
|
+
*/
|
|
4233
|
+
async function omniSearch(input) {
|
|
4234
|
+
const query = parseTypedQuery(input.text);
|
|
4235
|
+
const wants = (source) => input.sources.includes(source);
|
|
4236
|
+
const [automations, inboxItems, memories, todos] = await Promise.all([
|
|
4237
|
+
query && wants("automations") ? searchAutomationsForViewer(input.viewer, query, OMNI_SEARCH_SOURCE_LIMIT) : [],
|
|
4238
|
+
query && wants("inboxItems") ? searchInboxItemsForUser(input.viewer, query, OMNI_SEARCH_SOURCE_LIMIT) : [],
|
|
4239
|
+
query && wants("memories") ? searchPublicMemories(input.text, OMNI_SEARCH_SOURCE_LIMIT) : [],
|
|
4240
|
+
query && wants("todos") ? searchTodosForViewer(input.viewer, query, OMNI_SEARCH_SOURCE_LIMIT) : []
|
|
4241
|
+
]);
|
|
4242
|
+
return {
|
|
4243
|
+
...wants("automations") ? { automations } : void 0,
|
|
4244
|
+
...wants("inboxItems") ? { inboxItems } : void 0,
|
|
4245
|
+
...wants("memories") ? { memories } : void 0,
|
|
4246
|
+
...wants("todos") ? { todos } : void 0
|
|
4247
|
+
};
|
|
4248
|
+
}
|
|
4249
|
+
// src/api/search/routes.ts
|
|
4250
|
+
/**
|
|
4251
|
+
* Create the search route that the command palette reads while a person
|
|
4252
|
+
* types: one request, one group for each named source.
|
|
4253
|
+
*/
|
|
4254
|
+
function createSearchRoutes() {
|
|
4255
|
+
const app = new Hono();
|
|
4256
|
+
app.get("/", requireViewer, validateRequest("query", searchQuerySchema, "Invalid search query."), async (context) => {
|
|
4257
|
+
const { q, sources } = context.req.valid("query");
|
|
4258
|
+
return jsonResponse(searchReportSchema, await omniSearch({
|
|
4259
|
+
sources,
|
|
4260
|
+
text: q,
|
|
4261
|
+
viewer: context.get("viewer")
|
|
4262
|
+
}));
|
|
4263
|
+
});
|
|
4264
|
+
return app;
|
|
4265
|
+
}
|
|
3739
4266
|
// src/api/service-accounts/routes.ts
|
|
3740
4267
|
/**
|
|
3741
4268
|
* Public URL of the OAuth callback for one plugin's service account.
|
|
@@ -4627,7 +5154,8 @@ async function rootConversationIds(conversationIds) {
|
|
|
4627
5154
|
async function visibleRowItems(user, root, inboxItemId) {
|
|
4628
5155
|
if (inboxItemId) {
|
|
4629
5156
|
const item = await getInboxItem(getDb(), inboxItemId);
|
|
4630
|
-
const
|
|
5157
|
+
const owner = item && ownerConversationId(item);
|
|
5158
|
+
const inRow = root === void 0 || (item ? await rootConversationIds([...item.conversationIds, ...owner ? [owner] : []]) : []).includes(root);
|
|
4631
5159
|
if (item?.status === "open" && inRow && await canUserReadInboxItem(item, user)) return [{
|
|
4632
5160
|
canAct: canActOnInboxItem(item, user.id),
|
|
4633
5161
|
id: item.id,
|
|
@@ -4663,8 +5191,8 @@ async function namedResources(user, triggers) {
|
|
|
4663
5191
|
/**
|
|
4664
5192
|
* Aim each trigger at its named resource, or at the resource of the item's
|
|
4665
5193
|
* subject. A viewer waits on the subject without a check, as the item
|
|
4666
|
-
* already names it. A `resolve`
|
|
4667
|
-
* who can
|
|
5194
|
+
* already names it. A `resolve` closes the item, so it needs a viewer
|
|
5195
|
+
* who can close it. Returns undefined when a trigger does not apply to
|
|
4668
5196
|
* the item.
|
|
4669
5197
|
*/
|
|
4670
5198
|
function itemTriggers(item, triggers, named) {
|
|
@@ -4790,18 +5318,12 @@ async function readItemRoots(db, items, viewer) {
|
|
|
4790
5318
|
}).from(juniorConversations).leftJoin(juniorAgentBindings, eq(juniorAgentBindings.childConversationId, juniorConversations.conversationId)).where(and(inArray(juniorConversations.conversationId, ids), isNotNull(juniorConversations.parentConversationId)));
|
|
4791
5319
|
if (children.length === 0) return /* @__PURE__ */ new Map();
|
|
4792
5320
|
const childIds = children.map((child) => child.conversationId);
|
|
4793
|
-
const
|
|
4794
|
-
agentName: juniorAgentInvocations.agentName,
|
|
4795
|
-
childConversationId: juniorAgentInvocations.childConversationId,
|
|
4796
|
-
title: juniorAgentInvocations.title
|
|
4797
|
-
}).from(juniorAgentInvocations).where(inArray(juniorAgentInvocations.childConversationId, childIds)).orderBy(juniorAgentInvocations.childConversationId, sql`${juniorAgentInvocations.title} is null`, desc(juniorAgentInvocations.createdAt))]);
|
|
4798
|
-
const invocationByChild = new Map(invocations.map((row) => [row.childConversationId, row]));
|
|
5321
|
+
const access = await readConversationAccessFromSql(db, childIds, viewer);
|
|
4799
5322
|
return new Map(children.flatMap((child) => {
|
|
4800
5323
|
const childAccess = access.get(child.conversationId);
|
|
4801
5324
|
const rootConversationId = childAccess?.rootConversationId;
|
|
4802
5325
|
if (!rootConversationId || !childAccess.canViewPrivateContent) return [];
|
|
4803
|
-
const
|
|
4804
|
-
const label = invocation?.title ?? invocation?.agentName ?? child.title ?? child.bindingName ?? kindLabel(child.kind);
|
|
5326
|
+
const label = child.title ?? child.bindingName ?? kindLabel(child.kind);
|
|
4805
5327
|
return [[child.conversationId, {
|
|
4806
5328
|
label,
|
|
4807
5329
|
rootConversationId
|
|
@@ -4899,12 +5421,14 @@ function wakePayload(reason) {
|
|
|
4899
5421
|
function inboxItemPayload(item, viewer, roots, mentions, related, wake) {
|
|
4900
5422
|
const conversationId = ownerConversationId(item);
|
|
4901
5423
|
const root = conversationId ? roots.get(conversationId) : void 0;
|
|
5424
|
+
const todo = inboxItemTodo(item);
|
|
4902
5425
|
return {
|
|
4903
5426
|
...root ? { addedByLabel: root.label } : void 0,
|
|
4904
|
-
assignedToEveryone: item
|
|
5427
|
+
assignedToEveryone: isInboxItemForEveryone(item),
|
|
4905
5428
|
assignees: item.assignees,
|
|
4906
5429
|
body: item.body,
|
|
4907
5430
|
canAct: canActOnInboxItem(item, viewer.id),
|
|
5431
|
+
canAnswer: canAnswerInboxItem(item, viewer.id),
|
|
4908
5432
|
canTake: canActOnInboxItem(item, viewer.id) && !isOnlyAssignee(item, viewer.id),
|
|
4909
5433
|
conversationIds: item.conversationIds,
|
|
4910
5434
|
createdAt: item.createdAt.toISOString(),
|
|
@@ -4924,8 +5448,10 @@ function inboxItemPayload(item, viewer, roots, mentions, related, wake) {
|
|
|
4924
5448
|
...item.closedBy ? { closedBy: item.closedBy } : void 0,
|
|
4925
5449
|
...mentions.length > 0 ? { mentions: [...mentions] } : void 0,
|
|
4926
5450
|
...related && (related.items.length > 0 || related.conversationIds.length > 0) ? { related } : void 0,
|
|
5451
|
+
...item.dedupeKey.startsWith("reply:") ? { replyNotice: true } : void 0,
|
|
4927
5452
|
...item.request ? { request: item.request } : void 0,
|
|
4928
5453
|
...item.subject ? { subject: subjectPayload(item.subject) } : void 0,
|
|
5454
|
+
...todo ? { todoId: todo.id } : void 0,
|
|
4929
5455
|
...wake ? { wake: wakePayload(wake) } : void 0
|
|
4930
5456
|
};
|
|
4931
5457
|
}
|
|
@@ -5031,10 +5557,12 @@ function createInboxItemRoutes(services) {
|
|
|
5031
5557
|
let codeChanges = 0;
|
|
5032
5558
|
let decisions = 0;
|
|
5033
5559
|
let needsViewer = 0;
|
|
5560
|
+
let todos = 0;
|
|
5034
5561
|
for (const subject of subjects) {
|
|
5035
5562
|
automations += subject.automations;
|
|
5036
5563
|
needsViewer += subject.total;
|
|
5037
5564
|
decisions += subject.decisions;
|
|
5565
|
+
todos += subject.todos;
|
|
5038
5566
|
if (subject.subjectUrl && readLinkObjectType(subject.subjectUrl, linkTypes) === "code_change") codeChanges += subject.total;
|
|
5039
5567
|
}
|
|
5040
5568
|
return jsonResponse(inboxItemCountSchema, {
|
|
@@ -5042,7 +5570,8 @@ function createInboxItemRoutes(services) {
|
|
|
5042
5570
|
codeChanges,
|
|
5043
5571
|
decisions,
|
|
5044
5572
|
needsViewer,
|
|
5045
|
-
snoozed
|
|
5573
|
+
snoozed,
|
|
5574
|
+
todos
|
|
5046
5575
|
});
|
|
5047
5576
|
});
|
|
5048
5577
|
app.get("/waiting-conversations", requireViewer, async (context) => {
|
|
@@ -5245,7 +5774,128 @@ async function readStatsReport() {
|
|
|
5245
5774
|
windowStart: start
|
|
5246
5775
|
};
|
|
5247
5776
|
}
|
|
5248
|
-
// src/
|
|
5777
|
+
// src/db/listen.ts
|
|
5778
|
+
/**
|
|
5779
|
+
* The session runs `SELECT 1` this often. A socket that drops with no close
|
|
5780
|
+
* frame reports nothing, and a `NOTIFY` sent to a dead session is lost, so
|
|
5781
|
+
* the ping is the only way to notice.
|
|
5782
|
+
*/
|
|
5783
|
+
const PING_INTERVAL_MS = 15e3;
|
|
5784
|
+
const PING_TIMEOUT_MS = 5e3;
|
|
5785
|
+
/**
|
|
5786
|
+
* Open a session on the direct endpoint of `databaseUrl` and `LISTEN` on
|
|
5787
|
+
* `channel`. The pooled endpoint cannot hold a `LISTEN`, because it shares
|
|
5788
|
+
* one server session between clients.
|
|
5789
|
+
*
|
|
5790
|
+
* `onNotify` runs for each notification. `onLost` runs at most once, when
|
|
5791
|
+
* the session fails, ends, or misses a ping. The caller then opens a new
|
|
5792
|
+
* session: a `NOTIFY` sent while no session listens is lost.
|
|
5793
|
+
*/
|
|
5794
|
+
async function openListenSession(args) {
|
|
5795
|
+
const config = { connectionString: readDirectDatabaseUrl(args.databaseUrl) };
|
|
5796
|
+
const client = args.driver === "postgres" ? new pg.Client(config) : new Client(config);
|
|
5797
|
+
let connected = false;
|
|
5798
|
+
let ended = false;
|
|
5799
|
+
let ping;
|
|
5800
|
+
const end = async () => {
|
|
5801
|
+
ended = true;
|
|
5802
|
+
clearInterval(ping);
|
|
5803
|
+
await client.end().catch(() => void 0);
|
|
5804
|
+
};
|
|
5805
|
+
const lose = (error) => {
|
|
5806
|
+
if (ended) return;
|
|
5807
|
+
end();
|
|
5808
|
+
if (connected) args.onLost(error);
|
|
5809
|
+
};
|
|
5810
|
+
client.on("error", lose);
|
|
5811
|
+
try {
|
|
5812
|
+
await client.connect();
|
|
5813
|
+
await client.query(`SET application_name = '${args.applicationName}'`);
|
|
5814
|
+
await client.query(`LISTEN "${args.channel}"`);
|
|
5815
|
+
connected = true;
|
|
5816
|
+
} catch (error) {
|
|
5817
|
+
await end();
|
|
5818
|
+
throw error;
|
|
5819
|
+
}
|
|
5820
|
+
client.on("notification", () => {
|
|
5821
|
+
if (!ended) args.onNotify();
|
|
5822
|
+
});
|
|
5823
|
+
client.on("end", () => lose(/* @__PURE__ */ new Error("LISTEN session ended")));
|
|
5824
|
+
ping = setInterval(() => {
|
|
5825
|
+
let timer;
|
|
5826
|
+
const timeout = new Promise((_, reject) => {
|
|
5827
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error("LISTEN session missed a ping")), PING_TIMEOUT_MS);
|
|
5828
|
+
});
|
|
5829
|
+
Promise.race([client.query("SELECT 1"), timeout]).catch((error) => lose(error instanceof Error ? error : new Error(String(error)))).finally(() => clearTimeout(timer));
|
|
5830
|
+
}, PING_INTERVAL_MS);
|
|
5831
|
+
ping.unref?.();
|
|
5832
|
+
return { close: end };
|
|
5833
|
+
}
|
|
5834
|
+
// src/api/versions/changes.ts
|
|
5835
|
+
/**
|
|
5836
|
+
* The channel that the `junior_notify_versions` triggers send to. They send
|
|
5837
|
+
* an empty payload, so Postgres folds the notifications of one transaction
|
|
5838
|
+
* into one.
|
|
5839
|
+
*/
|
|
5840
|
+
const VERSIONS_CHANNEL = "junior_versions";
|
|
5841
|
+
/** Lets an operator find this instance's session in `pg_stat_activity`. */
|
|
5842
|
+
const APPLICATION_NAME = "junior-versions-listen";
|
|
5843
|
+
/**
|
|
5844
|
+
* Share one direct Postgres `LISTEN` session among the versions streams of
|
|
5845
|
+
* one API instance. The session opens with the first stream and closes with
|
|
5846
|
+
* the last one.
|
|
5847
|
+
*/
|
|
5848
|
+
function createVersionChanges() {
|
|
5849
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
5850
|
+
let session;
|
|
5851
|
+
const lose = (lost, error) => {
|
|
5852
|
+
if (session !== lost) return;
|
|
5853
|
+
session = void 0;
|
|
5854
|
+
logWarn("versions_stream.listener_lost", {
|
|
5855
|
+
"error.type": error.name,
|
|
5856
|
+
"exception.message": error.message,
|
|
5857
|
+
"app.versions_stream.subscribers": subscribers.size
|
|
5858
|
+
});
|
|
5859
|
+
const ended = [...subscribers];
|
|
5860
|
+
subscribers.clear();
|
|
5861
|
+
for (const subscriber of ended) subscriber.onLost();
|
|
5862
|
+
};
|
|
5863
|
+
const connect = () => {
|
|
5864
|
+
const { sql } = getChatConfig();
|
|
5865
|
+
const opened = openListenSession({
|
|
5866
|
+
applicationName: APPLICATION_NAME,
|
|
5867
|
+
channel: VERSIONS_CHANNEL,
|
|
5868
|
+
databaseUrl: sql.databaseUrl,
|
|
5869
|
+
driver: sql.driver,
|
|
5870
|
+
onLost: (error) => lose(opened, error),
|
|
5871
|
+
onNotify: () => {
|
|
5872
|
+
for (const subscriber of subscribers) subscriber.onChange();
|
|
5873
|
+
}
|
|
5874
|
+
});
|
|
5875
|
+
opened.catch(() => {
|
|
5876
|
+
if (session === opened) session = void 0;
|
|
5877
|
+
});
|
|
5878
|
+
return opened;
|
|
5879
|
+
};
|
|
5880
|
+
return { async subscribe(subscriber) {
|
|
5881
|
+
session ??= connect();
|
|
5882
|
+
const current = session;
|
|
5883
|
+
subscribers.add(subscriber);
|
|
5884
|
+
try {
|
|
5885
|
+
await current;
|
|
5886
|
+
} catch (error) {
|
|
5887
|
+
subscribers.delete(subscriber);
|
|
5888
|
+
throw error;
|
|
5889
|
+
}
|
|
5890
|
+
return () => {
|
|
5891
|
+
if (!subscribers.delete(subscriber)) return;
|
|
5892
|
+
if (subscribers.size > 0 || session !== current) return;
|
|
5893
|
+
session = void 0;
|
|
5894
|
+
current.then((listen) => listen.close());
|
|
5895
|
+
};
|
|
5896
|
+
} };
|
|
5897
|
+
}
|
|
5898
|
+
// src/api/versions/read.ts
|
|
5249
5899
|
/**
|
|
5250
5900
|
* Build a JSON object of each Conversation's tree token by id, with no entry
|
|
5251
5901
|
* for a missing one. The tokens come from one grouped pass over all the ids.
|
|
@@ -5273,6 +5923,152 @@ async function readVersions(viewer, options) {
|
|
|
5273
5923
|
if (!row) throw new Error("Viewer user row is missing");
|
|
5274
5924
|
return row;
|
|
5275
5925
|
}
|
|
5926
|
+
// src/api/versions/stream.ts
|
|
5927
|
+
/**
|
|
5928
|
+
* A stream ends by itself after about this long. Vercel does not tell the
|
|
5929
|
+
* function when the client goes away, and a write to a closed client does
|
|
5930
|
+
* not fail, so the cap is what ends a stream that nobody reads. The client
|
|
5931
|
+
* reconnects and reads a fresh baseline. The cap also bounds how long a
|
|
5932
|
+
* revoked session keeps getting tokens.
|
|
5933
|
+
*/
|
|
5934
|
+
const STREAM_MAX_MS = 12e4;
|
|
5935
|
+
/** Ends spread out, so tabs that opened together do not reconnect together. */
|
|
5936
|
+
const STREAM_MAX_JITTER_MS = 2e4;
|
|
5937
|
+
/** The stream ends this long before the function's max duration. */
|
|
5938
|
+
const FUNCTION_DEADLINE_MARGIN_MS = 15e3;
|
|
5939
|
+
/** The client counts a stream as healthy while it hears from it this often. */
|
|
5940
|
+
const KEEPALIVE_MS = 15e3;
|
|
5941
|
+
/**
|
|
5942
|
+
* After a read, the next one waits at least this long, the same as the poll
|
|
5943
|
+
* of a present reader. A busy viewer then costs no more than the poll.
|
|
5944
|
+
*/
|
|
5945
|
+
const MIN_READ_GAP_MS = 5e3;
|
|
5946
|
+
/** The client waits this long, plus jitter, before it reconnects. */
|
|
5947
|
+
const RETRY_MS = 1e3;
|
|
5948
|
+
const RETRY_JITTER_MS = 2e3;
|
|
5949
|
+
function streamMaxMs() {
|
|
5950
|
+
const functionMaxMs = getChatConfig().functionMaxDurationSeconds * 1e3 - FUNCTION_DEADLINE_MARGIN_MS;
|
|
5951
|
+
return Math.min(STREAM_MAX_MS - STREAM_MAX_JITTER_MS / 2 + Math.random() * STREAM_MAX_JITTER_MS, functionMaxMs);
|
|
5952
|
+
}
|
|
5953
|
+
/**
|
|
5954
|
+
* Open an SSE stream of one viewer's `Versions`. The first message is the
|
|
5955
|
+
* baseline. After that, a message comes only when a write may have moved a
|
|
5956
|
+
* token and a fresh read differs from the last message. Each message is a
|
|
5957
|
+
* fresh `readVersions`, with the same access as the poll.
|
|
5958
|
+
*/
|
|
5959
|
+
async function openVersionsStream(args) {
|
|
5960
|
+
const encoder = new TextEncoder();
|
|
5961
|
+
let controller;
|
|
5962
|
+
const body = new ReadableStream({
|
|
5963
|
+
start(streamController) {
|
|
5964
|
+
controller = streamController;
|
|
5965
|
+
},
|
|
5966
|
+
cancel() {
|
|
5967
|
+
close();
|
|
5968
|
+
}
|
|
5969
|
+
});
|
|
5970
|
+
let closed = false;
|
|
5971
|
+
let unsubscribe;
|
|
5972
|
+
let keepAlive;
|
|
5973
|
+
let cap;
|
|
5974
|
+
let nextRead;
|
|
5975
|
+
let reading = false;
|
|
5976
|
+
let dirty = false;
|
|
5977
|
+
let lastReadAtMs = 0;
|
|
5978
|
+
let lastMessage;
|
|
5979
|
+
function close() {
|
|
5980
|
+
if (closed) return;
|
|
5981
|
+
closed = true;
|
|
5982
|
+
clearInterval(keepAlive);
|
|
5983
|
+
clearTimeout(cap);
|
|
5984
|
+
clearTimeout(nextRead);
|
|
5985
|
+
unsubscribe?.();
|
|
5986
|
+
try {
|
|
5987
|
+
controller.close();
|
|
5988
|
+
} catch {}
|
|
5989
|
+
}
|
|
5990
|
+
const write = (chunk) => {
|
|
5991
|
+
if (closed) return;
|
|
5992
|
+
try {
|
|
5993
|
+
controller.enqueue(encoder.encode(chunk));
|
|
5994
|
+
} catch {
|
|
5995
|
+
close();
|
|
5996
|
+
}
|
|
5997
|
+
};
|
|
5998
|
+
const read = async () => {
|
|
5999
|
+
reading = true;
|
|
6000
|
+
dirty = false;
|
|
6001
|
+
lastReadAtMs = Date.now();
|
|
6002
|
+
try {
|
|
6003
|
+
const message = JSON.stringify(await readVersions(args.viewer, { conversationIds: args.conversationIds }));
|
|
6004
|
+
if (message !== lastMessage) {
|
|
6005
|
+
lastMessage = message;
|
|
6006
|
+
write(`data: ${message}\n\n`);
|
|
6007
|
+
}
|
|
6008
|
+
} catch (error) {
|
|
6009
|
+
logException(error, "versions_stream.read_failed");
|
|
6010
|
+
close();
|
|
6011
|
+
return;
|
|
6012
|
+
} finally {
|
|
6013
|
+
reading = false;
|
|
6014
|
+
}
|
|
6015
|
+
if (dirty) scheduleRead();
|
|
6016
|
+
};
|
|
6017
|
+
function scheduleRead() {
|
|
6018
|
+
if (closed || reading || nextRead) return;
|
|
6019
|
+
nextRead = setTimeout(() => {
|
|
6020
|
+
nextRead = void 0;
|
|
6021
|
+
read();
|
|
6022
|
+
}, Math.max(0, lastReadAtMs + MIN_READ_GAP_MS - Date.now()));
|
|
6023
|
+
}
|
|
6024
|
+
try {
|
|
6025
|
+
unsubscribe = await args.changes.subscribe({
|
|
6026
|
+
onChange: () => {
|
|
6027
|
+
dirty = true;
|
|
6028
|
+
scheduleRead();
|
|
6029
|
+
},
|
|
6030
|
+
onLost: close
|
|
6031
|
+
});
|
|
6032
|
+
} catch (error) {
|
|
6033
|
+
close();
|
|
6034
|
+
throw error;
|
|
6035
|
+
}
|
|
6036
|
+
write(`retry: ${Math.round(RETRY_MS + Math.random() * RETRY_JITTER_MS)}\n\n`);
|
|
6037
|
+
keepAlive = setInterval(() => write(`event: ${VERSIONS_STREAM_KEEPALIVE_EVENT}\ndata: 1\n\n`), KEEPALIVE_MS);
|
|
6038
|
+
keepAlive.unref?.();
|
|
6039
|
+
cap = setTimeout(close, streamMaxMs());
|
|
6040
|
+
cap.unref?.();
|
|
6041
|
+
read();
|
|
6042
|
+
return new Response(body, { headers: {
|
|
6043
|
+
"cache-control": "private, no-store, no-transform",
|
|
6044
|
+
"content-type": "text/event-stream"
|
|
6045
|
+
} });
|
|
6046
|
+
}
|
|
6047
|
+
// src/api/versions/routes.ts
|
|
6048
|
+
/**
|
|
6049
|
+
* Create the routes of the dashboard change tokens: one poll, and one SSE
|
|
6050
|
+
* stream that pushes the same tokens. The streams of this API share one
|
|
6051
|
+
* Postgres `LISTEN` session.
|
|
6052
|
+
*/
|
|
6053
|
+
function createVersionsRoutes() {
|
|
6054
|
+
const app = new Hono();
|
|
6055
|
+
const changes = createVersionChanges();
|
|
6056
|
+
const query = validateRequest("query", versionsQuerySchema, "Invalid query parameters.");
|
|
6057
|
+
app.get("/", requireViewer, query, async (context) => {
|
|
6058
|
+
const headers = { "cache-control": "private, no-store" };
|
|
6059
|
+
if (getChatConfig().versionsStreamEnabled) headers[VERSIONS_STREAM_HEADER] = "1";
|
|
6060
|
+
return jsonResponse(versionsSchema, await readVersions(context.get("viewer"), context.req.valid("query")), { headers });
|
|
6061
|
+
});
|
|
6062
|
+
app.get("/stream", requireViewer, query, async (context) => {
|
|
6063
|
+
if (!getChatConfig().versionsStreamEnabled) return emptyResponse();
|
|
6064
|
+
return await openVersionsStream({
|
|
6065
|
+
changes,
|
|
6066
|
+
conversationIds: context.req.valid("query").conversationIds,
|
|
6067
|
+
viewer: context.get("viewer")
|
|
6068
|
+
});
|
|
6069
|
+
});
|
|
6070
|
+
return app;
|
|
6071
|
+
}
|
|
5276
6072
|
// src/reporting.ts
|
|
5277
6073
|
function readDescriptionText(home) {
|
|
5278
6074
|
try {
|
|
@@ -5283,7 +6079,7 @@ function readDescriptionText(home) {
|
|
|
5283
6079
|
}
|
|
5284
6080
|
/** Read discovered skills for runtime diagnostics and the Automation editor. */
|
|
5285
6081
|
async function readSkillReports() {
|
|
5286
|
-
const { discoverSkills } = await import("./skills-
|
|
6082
|
+
const { discoverSkills } = await import("./skills-BlHUDj7k.js").then((n) => n.s);
|
|
5287
6083
|
const skills = await discoverSkills();
|
|
5288
6084
|
return skillReportsSchema.parse(skills.map((skill) => ({
|
|
5289
6085
|
name: skill.name,
|
|
@@ -5297,7 +6093,7 @@ async function readSkillReports() {
|
|
|
5297
6093
|
* what the skill tells Junior. Returns null when no skill has that name.
|
|
5298
6094
|
*/
|
|
5299
6095
|
async function readSkillDetailReport(name) {
|
|
5300
|
-
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-
|
|
6096
|
+
const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-BlHUDj7k.js").then((n) => n.s);
|
|
5301
6097
|
const skill = findSkillByName(name, await discoverSkills());
|
|
5302
6098
|
if (!skill) return null;
|
|
5303
6099
|
const parsed = parseSkillFile(await fs.readFile(path.join(skill.skillPath, "SKILL.md"), "utf8"), skill.name);
|
|
@@ -5312,7 +6108,7 @@ async function readSkillDetailReport(name) {
|
|
|
5312
6108
|
}
|
|
5313
6109
|
/** Read safe configured plugin metadata for authenticated runtime diagnostics. */
|
|
5314
6110
|
async function readPlugins() {
|
|
5315
|
-
const { pluginCatalogRuntime } = await import("./
|
|
6111
|
+
const { pluginCatalogRuntime } = await import("./db-DXTOYRzR.js").then((n) => n.kr);
|
|
5316
6112
|
return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
5317
6113
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
5318
6114
|
description: plugin.manifest.description,
|
|
@@ -5323,8 +6119,8 @@ async function readPlugins() {
|
|
|
5323
6119
|
/** Read authenticated runtime discovery data. */
|
|
5324
6120
|
async function readRuntimeInfoReport() {
|
|
5325
6121
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
5326
|
-
import("./package-discovery-
|
|
5327
|
-
import("./
|
|
6122
|
+
import("./package-discovery-BI6T_RkD.js").then((n) => n.r),
|
|
6123
|
+
import("./db-DXTOYRzR.js").then((n) => n.kr),
|
|
5328
6124
|
readPlugins(),
|
|
5329
6125
|
readSkillReports()
|
|
5330
6126
|
]);
|
|
@@ -5341,7 +6137,7 @@ async function readRuntimeInfoReport() {
|
|
|
5341
6137
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
5342
6138
|
async function readPluginOperationalReportFeed() {
|
|
5343
6139
|
const nowMs = Date.now();
|
|
5344
|
-
const { getPluginOperationalReports } = await import("./
|
|
6140
|
+
const { getPluginOperationalReports } = await import("./db-DXTOYRzR.js").then((n) => n.W);
|
|
5345
6141
|
return pluginOperationalReportFeedSchema.parse({
|
|
5346
6142
|
source: "plugins",
|
|
5347
6143
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -5363,7 +6159,7 @@ function createJuniorApi(options = {}) {
|
|
|
5363
6159
|
});
|
|
5364
6160
|
app.get("/api/plugin-reports", async () => jsonResponse(pluginOperationalReportFeedSchema, await readPluginOperationalReportFeed()));
|
|
5365
6161
|
app.get("/api/stats", async () => jsonResponse(statsReportSchema, await readStatsReport()));
|
|
5366
|
-
app.
|
|
6162
|
+
app.route("/api/versions", createVersionsRoutes());
|
|
5367
6163
|
for (const path of REVALIDATED_READ_PATHS) app.use(path, revalidateContent);
|
|
5368
6164
|
const queue = options.conversationWorkQueue ?? getVercelConversationWorkQueue();
|
|
5369
6165
|
const waitUntil$1 = options.waitUntil ?? ((task) => waitUntil(typeof task === "function" ? task() : task));
|
|
@@ -5374,7 +6170,7 @@ function createJuniorApi(options = {}) {
|
|
|
5374
6170
|
}));
|
|
5375
6171
|
app.route("/api/inbox-items", createInboxItemRoutes({ delivery: {
|
|
5376
6172
|
queue,
|
|
5377
|
-
show:
|
|
6173
|
+
show: createInboxItemShow(getProductionSlackAdapter)
|
|
5378
6174
|
} }));
|
|
5379
6175
|
app.route("/api/inbox/snoozes", createInboxSnoozeRoutes());
|
|
5380
6176
|
app.route("/api/code", createCodeRoutes());
|
|
@@ -5385,10 +6181,15 @@ function createJuniorApi(options = {}) {
|
|
|
5385
6181
|
app.route("/api/cache-warming", createCacheWarmingRoutes());
|
|
5386
6182
|
app.route("/api/gateway-providers", createGatewayProviderRoutes());
|
|
5387
6183
|
app.route("/api/images", createImageRoutes());
|
|
5388
|
-
app.route("/api/lead", createLeadRoutes());
|
|
5389
6184
|
app.route("/api/objects", createObjectRoutes());
|
|
5390
6185
|
app.route("/api/people", createPeopleRoutes({ waitUntil: waitUntil$1 }));
|
|
5391
6186
|
app.route("/api/locations", createLocationRoutes());
|
|
6187
|
+
app.route("/api/search", createSearchRoutes());
|
|
6188
|
+
app.route("/api/spaces", createSpaceRoutes());
|
|
6189
|
+
app.route("/api/spaces", createSpaceArchiveRoutes({ queue }));
|
|
6190
|
+
app.route("/api/spaces", createSpaceMemberRoutes());
|
|
6191
|
+
app.route("/api/spaces", createSpaceConfigurationRoutes());
|
|
6192
|
+
app.route("/api/spaces", createSpaceLeadRoutes());
|
|
5392
6193
|
app.route("/api/user-pages", createUserPageRoutes());
|
|
5393
6194
|
app.route("/api/user-customization", createUserCustomizationRoutes());
|
|
5394
6195
|
app.route("/api/automations", createAutomationRoutes());
|