trouteai 1.0.7 → 1.0.8
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/.build/next/BUILD_ID +1 -1
- package/.build/next/build-manifest.json +3 -3
- package/.build/next/fallback-build-manifest.json +3 -3
- package/.build/next/server/app/(dashboard)/dashboard/activity/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/analytics/combo-health/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/analytics/utilization/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/audit/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/cache/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/combos/[id]/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/combos/live/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/combos/playground/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/costs/budget/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/costs/pricing/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/costs/quota-share/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/logs/activity/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/logs/console/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/logs/proxy/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/logs/timeline/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/provider-stats/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/runtime/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/advanced/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/ai/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/appearance/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/cache/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/feature-flags/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/general/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/resilience/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/routing/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/security/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/settings/sidebar/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/system/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/system/proxy/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/(dashboard)/home/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/400/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/401/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/403/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/408/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/429/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/500/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/502/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/503/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/_global-error.html +1 -1
- package/.build/next/server/app/_global-error.rsc +1 -1
- package/.build/next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.build/next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.build/next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.build/next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/api/combos/test/route.js +156 -156
- package/.build/next/server/app/api/compression/compare/verify/route.js +2 -2
- package/.build/next/server/app/api/models/test/route.js +143 -143
- package/.build/next/server/app/api/models/test-all/route.js +143 -143
- package/.build/next/server/app/api/usage/[connectionId]/route.js +2 -2
- package/.build/next/server/app/api/usage/codex-reset-credit/route.js +2 -2
- package/.build/next/server/app/api/usage/provider-limits/route.js +2 -2
- package/.build/next/server/app/api/v1/antigravity/route.js +125 -125
- package/.build/next/server/app/api/v1/api/chat/route.js +127 -127
- package/.build/next/server/app/api/v1/chat/completions/route.js +133 -133
- package/.build/next/server/app/api/v1/completions/route.js +131 -131
- package/.build/next/server/app/api/v1/messages/count_tokens/route.js +2 -2
- package/.build/next/server/app/api/v1/messages/route.js +129 -129
- package/.build/next/server/app/api/v1/providers/[provider]/chat/completions/route.js +124 -124
- package/.build/next/server/app/api/v1/responses/[...path]/route.js +125 -125
- package/.build/next/server/app/api/v1/responses/route.js +133 -133
- package/.build/next/server/app/api/v1/videos/generations/route.js +2 -2
- package/.build/next/server/app/api/v1/vscode/[token]/api/chat/route.js +131 -131
- package/.build/next/server/app/api/v1/vscode/[token]/chat/completions/route.js +132 -132
- package/.build/next/server/app/api/v1/vscode/[token]/responses/route.js +131 -131
- package/.build/next/server/app/api/v1/vscode/[token]/v1/chat/completions/route.js +132 -132
- package/.build/next/server/app/api/v1/vscode/raw/[token]/api/chat/route.js +131 -131
- package/.build/next/server/app/api/v1/vscode/raw/[token]/chat/completions/route.js +132 -132
- package/.build/next/server/app/api/v1/vscode/raw/[token]/responses/route.js +131 -131
- package/.build/next/server/app/api/v1/vscode/raw/[token]/v1/chat/completions/route.js +132 -132
- package/.build/next/server/app/api/v1beta/models/[...path]/route.js +128 -128
- package/.build/next/server/app/auth/callback/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/connect/codex/[token]/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/forbidden/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/maintenance/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/.build/next/server/app/page_client-reference-manifest.js +1 -1
- package/.build/next/server/chunks/{1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0071t6-gy8206.js → 1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0cdytbweqx6b7.js} +1 -1
- package/.build/next/server/chunks/{1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_03uipan87s4vs.js → 1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0dv1_6icxx4nr.js} +1 -1
- package/.build/next/server/chunks/{1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_04qcux733c716.js → 1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0feukx8b--i7y.js} +1 -1
- package/.build/next/server/chunks/{1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_04y--asln23t-.js → 1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0foh2lmr9t9jf.js} +1 -1
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0ieu8lrtllaog.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0jow9no35q-gl.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0k39__s-5wenx.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0lu36e9zlm6y2.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0q3hd0z__qhm1.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0svnbjltkehm0.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0tp3k6-k_smkk.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0tw8hx-r12mrw.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0vdgv0qv9t25q.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_13pu0wi09xd-q.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_16gcrutnx6jpm.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_170l4-im9-rts.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_18ujd4t8o0iap.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1kuob30li3zz4.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1oghu697pywz1.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1oz1ky4cqo5la.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1t1tpwfjdroz-.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1twzsl5g2kx-m.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1u4l5hhlfmkq7.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1wgek1bfzkudf.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1yazcd_f60euz.js +3 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1zg9eixcilibu.js +3 -0
- package/.build/next/server/chunks/{[root-of-the-server]__0y-c0o33nm9k7._.js → [root-of-the-server]__013qtg6e7nrnt._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__0s1n86lqib-r8._.js → [root-of-the-server]__01cuuk82yhow-._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__03j1rri4jmffc._.js +1 -1
- package/.build/next/server/chunks/{[root-of-the-server]__053e56_stref0._.js → [root-of-the-server]__04-wq1d8ad7-c._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__09e_jeovzn41x._.js → [root-of-the-server]__04ex4wx450p98._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__0sh-ax_s9lxgs._.js → [root-of-the-server]__054pm2e42ihgb._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__06a582l--8gfi._.js +1 -1
- package/.build/next/server/chunks/{[root-of-the-server]__14qrr7cz7ih12._.js → [root-of-the-server]__08mchwc4bo740._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__0cdyf9uauo7s-._.js → [root-of-the-server]__0_potadi-xpgt._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__0b6xbrajo6q7j._.js → [root-of-the-server]__0au1tn-inyd_g._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__0dnxb-t5a29qw._.js → [root-of-the-server]__0bi89tb8hq7gp._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__0bjb6df6ao16p._.js +3 -0
- package/.build/next/server/chunks/{[root-of-the-server]__0bqjf5vfej0y0._.js → [root-of-the-server]__0bn0fnmy3cyov._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__0c8uunduj0rcb._.js +3 -0
- package/.build/next/server/chunks/{[root-of-the-server]__0cyc8ns5c-hak._.js → [root-of-the-server]__0cfm4y8lfzabg._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__0h2tv7welidf2._.js +1 -1
- package/.build/next/server/chunks/[root-of-the-server]__0h6jczejtzur4._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__0jboht3yosva1._.js +1 -1
- package/.build/next/server/chunks/[root-of-the-server]__0kmh0llofhi-t._.js +3 -0
- package/.build/next/server/chunks/{[root-of-the-server]__19fndg4-8fl2p._.js → [root-of-the-server]__0oe87-hbfx_wt._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__0pkk8q-mwrlhb._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__0pr6ndvl99m80._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__0q4kt78fse6u1._.js +1 -1
- package/.build/next/server/chunks/{[root-of-the-server]__0puajugwbae33._.js → [root-of-the-server]__0qwx0hffq93lu._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__03wxkz1ocd2m9._.js → [root-of-the-server]__0qzppsy_m_vb2._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__0tadcednrqwvh._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__0tmd8acngsii3._.js +3 -0
- package/.build/next/server/chunks/{[root-of-the-server]__0urs4jrktsqji._.js → [root-of-the-server]__0vrh-4tf0ft8-._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__0w0-w78j-o7zx._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__0yhdbb9w6oy0w._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__0yovqcjs0srde._.js +3 -0
- package/.build/next/server/chunks/{[root-of-the-server]__155hah7mtxxeu._.js → [root-of-the-server]__0yrk_78ixd453._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__0e_cgryo2zwu7._.js → [root-of-the-server]__0z24jgzvrqjf-._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__1-elrzh0r1gn1._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__13g59axrgpk8f._.js +3 -0
- package/.build/next/server/chunks/{[root-of-the-server]__0fqufbrh_mxe6._.js → [root-of-the-server]__14htch0up35mq._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__16__ky70mzpki._.js +1 -1
- package/.build/next/server/chunks/[root-of-the-server]__175s6rzt1gxf5._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__183u7xm7s7a0k._.js +3 -0
- package/.build/next/server/chunks/{[root-of-the-server]__1b7gfspxmfn7w._.js → [root-of-the-server]__1_bm64-b9rvps._.js} +2 -2
- package/.build/next/server/chunks/{[root-of-the-server]__0_89zuvif-ac0._.js → [root-of-the-server]__1_u2c9t8ghphk._.js} +2 -2
- package/.build/next/server/chunks/[root-of-the-server]__1asmrtinwnms1._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1cs67f0gx1m2b._.js +1 -1
- package/.build/next/server/chunks/{[root-of-the-server]__0cya_vem8spaz._.js → [root-of-the-server]__1di-si5n-wa-0._.js} +1 -1
- package/.build/next/server/chunks/[root-of-the-server]__1eqvp0su82wa0._.js +1 -1
- package/.build/next/server/chunks/[root-of-the-server]__1f5u7fc6i-lh2._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1gvcl_1847dlk._.js +1 -1
- package/.build/next/server/chunks/[root-of-the-server]__1gvwvri5-zmqs._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1mfz-ys8z6-vj._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1trre9oa-f-0-._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1vwllhi2yaj22._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1waj1qbbu8d0o._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1x9t7o--7d3xv._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1xi0yu215obtp._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1xrpvccwm0tui._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1xxb_la5pyyty._.js +1 -1
- package/.build/next/server/chunks/[root-of-the-server]__1yyq83bab1_34._.js +3 -0
- package/.build/next/server/chunks/[root-of-the-server]__1zvn7n_eg3bv6._.js +3 -0
- package/.build/next/server/chunks/_0-whad0_ydcsy._.js +1 -1
- package/.build/next/server/chunks/{_05uyjdaba145h._.js → _01jw2l_g1m495._.js} +1 -1
- package/.build/next/server/chunks/_02r_3f8xhg8a_._.js +16 -0
- package/.build/next/server/chunks/{_0-7-wo2rhe742._.js → _03qfav-eclfsv._.js} +1 -1
- package/.build/next/server/chunks/{_045qaiya-q9mx._.js → _06tafvn_2upb9._.js} +1 -1
- package/.build/next/server/chunks/{_0bnzv1p-iih9y._.js → _070swycte4f2y._.js} +1 -1
- package/.build/next/server/chunks/{_0ozkcut9ays1g._.js → _08crm5ua26ded._.js} +1 -1
- package/.build/next/server/chunks/{_0cnrejialoejq._.js → _09pw38n0fvjve._.js} +133 -118
- package/.build/next/server/chunks/_0_owpim-84v6c._.js +1 -1
- package/.build/next/server/chunks/_0bjni2b0bk48x._.js +7 -0
- package/.build/next/server/chunks/_0cthudnt9nl4t._.js +3 -0
- package/.build/next/server/chunks/_0dtaqfgy6-5ws._.js +3 -0
- package/.build/next/server/chunks/{_1gwyqrv4jj-h0._.js → _0dx0f1oye7vfm._.js} +1 -1
- package/.build/next/server/chunks/_0gqrj_t8bk-8t._.js +1 -1
- package/.build/next/server/chunks/_0heuo1apizyqe._.js +1 -1
- package/.build/next/server/chunks/{_0hmkgx75fn7mt._.js → _0jbl3xtidh76w._.js} +1 -1
- package/.build/next/server/chunks/_0jzperkk-1ag9._.js +1 -1
- package/.build/next/server/chunks/_0nntu-lmwlb6z._.js +1 -1
- package/.build/next/server/chunks/_0ntfaxua3a497._.js +3 -0
- package/.build/next/server/chunks/{_1mf3kg0sol0_p._.js → _0pqtuwqkanzsg._.js} +133 -118
- package/.build/next/server/chunks/{_0syxc2wl5qdnf._.js → _0q0iu436_75a8._.js} +1 -1
- package/.build/next/server/chunks/_0qa8wnj0oms8q._.js +3 -0
- package/.build/next/server/chunks/{_0i0eoe3j0-x0v._.js → _0r-1igk81_7eg._.js} +1 -1
- package/.build/next/server/chunks/{_0iclxqeesd_hr._.js → _0rffd_e2te-9v._.js} +1 -1
- package/.build/next/server/chunks/{_0fr8xxna2d5zn._.js → _0rtwo7u0mrb9r._.js} +1 -1
- package/.build/next/server/chunks/_0srkl-vgqcos7._.js +1 -1
- package/.build/next/server/chunks/_0tjk31-3k5hyf._.js +1 -1
- package/.build/next/server/chunks/_0tu5ehvbm4nc0._.js +3 -0
- package/.build/next/server/chunks/_0u8bko69-zd_z._.js +3 -0
- package/.build/next/server/chunks/_0v2kg-vv66amt._.js +3 -0
- package/.build/next/server/chunks/_0xujjs2b429r3._.js +3 -0
- package/.build/next/server/chunks/_0zvrsdbnkncnv._.js +3 -0
- package/.build/next/server/chunks/{_15efjsoc2b-sk._.js → _0zzir4fs7j_1p._.js} +2 -2
- package/.build/next/server/chunks/_10bcih89e-jn4._.js +3 -0
- package/.build/next/server/chunks/_10fwjeqnb57r-._.js +3 -0
- package/.build/next/server/chunks/_12_v3uivh86bs._.js +3 -0
- package/.build/next/server/chunks/_12ra9yaf_1dyr._.js +650 -0
- package/.build/next/server/chunks/_12rywigtphiop._.js +1 -1
- package/.build/next/server/chunks/_14cqpo0o-pr27._.js +3 -0
- package/.build/next/server/chunks/_14lqp4-f8wqgn._.js +3 -0
- package/.build/next/server/chunks/_159dadvt3pm1n._.js +3 -0
- package/.build/next/server/chunks/_1644hhqg6d_ln._.js +1 -1
- package/.build/next/server/chunks/{_1avfc3einmg1h._.js → _16_wwhbnnhkuh._.js} +1 -1
- package/.build/next/server/chunks/_16an60huh6tbs._.js +9 -9
- package/.build/next/server/chunks/_16i__1nx0epf7._.js +3 -0
- package/.build/next/server/chunks/_178o182dc7ex1._.js +3 -0
- package/.build/next/server/chunks/_188c9_xzcpc31._.js +1 -1
- package/.build/next/server/chunks/_19fzj3u7s0yz1._.js +3 -0
- package/.build/next/server/chunks/_19sfk-pzknkyv._.js +3 -0
- package/.build/next/server/chunks/_1_r1zgsvs713w._.js +3 -0
- package/.build/next/server/chunks/_1b6zyz_ay2ym5._.js +3 -0
- package/.build/next/server/chunks/_1btzlsw6io52c._.js +3 -0
- package/.build/next/server/chunks/{_0b_i4b8q0n1wz._.js → _1ft8yf-b3j8b8._.js} +147 -132
- package/.build/next/server/chunks/_1i00v3yjot-q_._.js +3 -0
- package/.build/next/server/chunks/{_0j524iax5w-bz._.js → _1kwnwtivfzp5u._.js} +1 -1
- package/.build/next/server/chunks/_1n9cbjvt_d82t._.js +1 -1
- package/.build/next/server/chunks/{_1wos-_82xr837._.js → _1q0_qh1mlc-1m._.js} +147 -132
- package/.build/next/server/chunks/{_0u-x3uzfboviu._.js → _1qmyzv3q9s7el._.js} +1 -1
- package/.build/next/server/chunks/_1qqqu7qtmx3if._.js +3 -0
- package/.build/next/server/chunks/_1r-xz7njt1agb._.js +62 -0
- package/.build/next/server/chunks/_1r3w1g8gzsrx3._.js +3 -0
- package/.build/next/server/chunks/{_1zcs33t-he7xd._.js → _1t7-qccr20ews._.js} +10 -10
- package/.build/next/server/chunks/_1uj3ppmpkxnlt._.js +3 -0
- package/.build/next/server/chunks/_1vgt3hw061lvz._.js +3 -0
- package/.build/next/server/chunks/_1xsk0mm2-hw63._.js +3 -0
- package/.build/next/server/chunks/_1yia8a_9rs285._.js +3 -0
- package/.build/next/server/chunks/_1yq_qtnhzgne_._.js +3 -0
- package/.build/next/server/chunks/_1z1_7oxdwqiqe._.js +3 -0
- package/.build/next/server/chunks/{_0zea7hovhgt2_._.js → _1zk9j5avh9do1._.js} +2 -2
- package/.build/next/server/chunks/_1zmyssg1ql6gl._.js +3 -3
- package/.build/next/server/chunks/_1zzqi2vrqln8r._.js +3 -0
- package/.build/next/server/chunks/_20wczne8lusnr._.js +1 -1
- package/.build/next/server/chunks/{node_modules_0_a57i8xt9icf._.js → node_modules_00j-j70vb5l89._.js} +1 -1
- package/.build/next/server/chunks/{node_modules_0-_w__4n53410._.js → node_modules_00rveaxr6xn-1._.js} +1 -1
- package/.build/next/server/chunks/{node_modules_06km3ub1t353p._.js → node_modules_0318sxb9xejre._.js} +1 -1
- package/.build/next/server/chunks/{node_modules_070w8pzva2-b5._.js → node_modules_03eegbwr1ykhv._.js} +1 -1
- package/.build/next/server/chunks/node_modules_04kmq4fi-fcs3._.js +3 -0
- package/.build/next/server/chunks/node_modules_0clpxklowdv39._.js +3 -0
- package/.build/next/server/chunks/node_modules_0ixloym14amfv._.js +3 -0
- package/.build/next/server/chunks/node_modules_0jcobbm12qhmj._.js +3 -0
- package/.build/next/server/chunks/node_modules_0lav-ieym04zb._.js +3 -0
- package/.build/next/server/chunks/node_modules_0meaikpo6sp-0._.js +3 -0
- package/.build/next/server/chunks/node_modules_0qjpghqow25tc._.js +3 -0
- package/.build/next/server/chunks/node_modules_0t3d23hihdgmu._.js +3 -0
- package/.build/next/server/chunks/node_modules_0trsqf3qottck._.js +3 -0
- package/.build/next/server/chunks/node_modules_0voxtqt-anw9e._.js +3 -0
- package/.build/next/server/chunks/node_modules_0vrbvfb6201w6._.js +3 -0
- package/.build/next/server/chunks/node_modules_1-kv_qmpt4341._.js +3 -0
- package/.build/next/server/chunks/node_modules_10rbyfmbpi425._.js +3 -0
- package/.build/next/server/chunks/node_modules_135e3rn3qtd-6._.js +3 -0
- package/.build/next/server/chunks/node_modules_17pyrt2it4bgr._.js +3 -0
- package/.build/next/server/chunks/node_modules_1ir4um6mro95r._.js +3 -0
- package/.build/next/server/chunks/node_modules_1j_0ubaizcezn._.js +3 -0
- package/.build/next/server/chunks/node_modules_1n05kwizfpjo6._.js +3 -0
- package/.build/next/server/chunks/node_modules_1n47vn0307_u5._.js +3 -0
- package/.build/next/server/chunks/node_modules_1srzy9xr2ioyr._.js +3 -0
- package/.build/next/server/chunks/node_modules_1tqglxa-ymtqw._.js +3 -0
- package/.build/next/server/chunks/node_modules_1z6rpfu7winx2._.js +3 -0
- package/.build/next/server/chunks/{node_modules_@aws-sdk_032-tpe7346hb._.js → node_modules_@aws-sdk_03kfydhiseqdg._.js} +2 -2
- package/.build/next/server/chunks/{node_modules_@aws-sdk_04o_8bax4fbo4._.js → node_modules_@aws-sdk_0_s99dpim75pu._.js} +2 -2
- package/.build/next/server/chunks/{node_modules_@aws-sdk_0_at_8j5m5taa._.js → node_modules_@aws-sdk_0bv_r2pcdu10h._.js} +2 -2
- package/.build/next/server/chunks/{node_modules_@aws-sdk_0cpedsd2e8nj9._.js → node_modules_@aws-sdk_0f5qnmpxmag01._.js} +2 -2
- package/.build/next/server/chunks/node_modules_@aws-sdk_0nlcm-f5ytb4h._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0obp77rs96mvi._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0oylq1k5y_3ce._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0qf0zztgs682s._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0rgyt30cubjzf._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0vi2hngy9pnuy._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0x510i9ngxcyf._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0y-e4gqf903o3._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0yhl9bvr9ueqh._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0yqxb4ienz6kj._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_0yttguxby4mdi._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_10101hyu_zjk4._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_123n4jie1tq6a._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_15qb522ckeehe._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_1_n1vj3j0xfms._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_1ix0scvbr4xd9._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_1lza3gi_jvmio._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_1mdahx12zwp_1._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_1nk8tt26yrxh-._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_1ot6491i27kfo._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_1vcgyijr8-gln._.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_204anorh-zvk-._.js +3 -0
- package/.build/next/server/chunks/{node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0-2dpkdybmydz.js → node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_01m33xoynofsl.js} +1 -1
- package/.build/next/server/chunks/{node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_00c1icqvrqz-s.js → node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_06adt_ianv_md.js} +1 -1
- package/.build/next/server/chunks/{node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_039_xf84osnel.js → node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_07njywm0sbeyv.js} +1 -1
- package/.build/next/server/chunks/{node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_03hjwb47vuwm9.js → node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_080lter3o8zcp.js} +1 -1
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_09_cxlxlqf67s.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_09ov7ntve-mx7.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0kbpnxnu2ejlc.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0ki8jbo6k_atz.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0npewtp_nops5.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0q715b8wgpb1u.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0yy3fcwj_b5be.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1-4ppt5kmz50x.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1-ky0eo80twjx.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_11u9jygsvvu5c.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_12s0w02i5mlzh.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_12sb57-_mdan4.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_13be-a641383i.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_14nxcn9iwq7oj.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_15sqaub981ncp.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_16mb7bvgqd72p.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1a96ybufo8-_d.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1epmqjkncfa-t.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1ymjdx7brv1u5.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1zmx4t1zp2plx.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1ztb14nbvq-v8.js +3 -0
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_20swopgb7gs5p.js +3 -0
- package/.build/next/server/chunks/{node_modules_ioredis_built_index_1-s3egdocnznd.js → node_modules_ioredis_built_index_0bym26c4shwf9.js} +1 -1
- package/.build/next/server/chunks/{node_modules_ioredis_built_index_14ex7cglfl3pz.js → node_modules_ioredis_built_index_0olys7xgnfo0i.js} +1 -1
- package/.build/next/server/chunks/{node_modules_ioredis_built_index_1a9ll1mwrmtob.js → node_modules_ioredis_built_index_14ct1dd055dku.js} +1 -1
- package/.build/next/server/chunks/{node_modules_ioredis_built_index_1w1hzk4_-8xu5.js → node_modules_ioredis_built_index_1ik97n_251xek.js} +1 -1
- package/.build/next/server/chunks/node_modules_ioredis_built_index_1vv514_mvh8ve.js +3 -0
- package/.build/next/server/chunks/open-sse_02t7zn7htyw-9._.js +1 -1
- package/.build/next/server/chunks/open-sse_03ipq-9xg4l9m._.js +1 -1
- package/.build/next/server/chunks/open-sse_0h0zluguzhqef._.js +16 -3
- package/.build/next/server/chunks/open-sse_0s84hi7h9418d._.js +16 -3
- package/.build/next/server/chunks/open-sse_1b6ivsct5ejh3._.js +1 -1
- package/.build/next/server/chunks/open-sse_1r2up99lm4jtz._.js +1 -1
- package/.build/next/server/chunks/open-sse_1tgbautgb4f7f._.js +16 -3
- package/.build/next/server/chunks/{open-sse_services_02bmh-sbso22m._.js → open-sse_services_00hw3r8y1gfsk._.js} +1 -1
- package/.build/next/server/chunks/open-sse_services_03wu42_5vmj9o._.js +2 -2
- package/.build/next/server/chunks/open-sse_services_0ct5y5fs-6yum._.js +2 -2
- package/.build/next/server/chunks/{open-sse_services_04dvqigm0hy_b._.js → open-sse_services_0faya5lemfn3z._.js} +1 -1
- package/.build/next/server/chunks/{open-sse_services_0884oo1_foqx1._.js → open-sse_services_0fqgcvavo8wg0._.js} +1 -1
- package/.build/next/server/chunks/{open-sse_services_0cjgk3rys3phs._.js → open-sse_services_0gp_perj2ozc7._.js} +1 -1
- package/.build/next/server/chunks/open-sse_services_0luw8b50a275y._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_0lz8kz3o3n32w._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_0o2xbv4-s_hgc._.js +2 -2
- package/.build/next/server/chunks/open-sse_services_0uzit9opfex07._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_10-13kqpampl8._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_11px-eu6wpco1._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_12xf6ogfm7fk6._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_13aor5_u0vw67._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_17to5z2yz9tp5._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_1_z10i8xets76._.js +2 -2
- package/.build/next/server/chunks/open-sse_services_1aofhb43cunjk._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_1bmzbrj-w51an._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_1cfnib8brx231._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_1m558021-9l1o._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_1mixpyyaadj44._.js +2 -2
- package/.build/next/server/chunks/open-sse_services_1pb9vai4pzp46._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_1u1h_rm99qyq_._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_1v47txy532v7j._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_1zn2whnlx96gx._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_20qr88u5g_bzt._.js +3 -0
- package/.build/next/server/chunks/open-sse_services_kiroRegion_ts_1plr7t56zivs5._.js +1 -1
- package/.build/next/server/chunks/open-sse_utils_requestLogger_ts_0bd_-kg8s0mnb._.js +1 -1
- package/.build/next/server/chunks/open-sse_utils_requestLogger_ts_0o1bn8tbcrdys._.js +1 -1
- package/.build/next/server/chunks/{src_0gff8n1288m1s._.js → src_06dmt2gh7c2r5._.js} +1 -1
- package/.build/next/server/chunks/src_072_u91zja_z6._.js +1 -1
- package/.build/next/server/chunks/{src_0ogv5rsf3ovzt._.js → src_0iivcw6e2y8b-._.js} +1 -1
- package/.build/next/server/chunks/src_0jsr5vm5qt_kk._.js +1 -1
- package/.build/next/server/chunks/{src_1gr5o5rdqanpt._.js → src_0l9p-6g-6c00r._.js} +1 -1
- package/.build/next/server/chunks/src_1m93lsr72gv4e._.js +1 -1
- package/.build/next/server/chunks/src_1p24y5m9owsdz._.js +1 -1
- package/.build/next/server/chunks/{src_1w9wqtyffs4jp._.js → src_20-a3old2hlv7._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_0t6aj24w2w4um._.js → src_lib_05upj47v7jd8d._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_18c9gtbeeedlu._.js → src_lib_0g6dvcltrlrt1._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_plugins_manager_ts_03te14cdfjqt1._.js → src_lib_plugins_manager_ts_06-b_e2ssdrqp._.js} +2 -2
- package/.build/next/server/chunks/{src_lib_plugins_manager_ts_082ank_n7lv72._.js → src_lib_plugins_manager_ts_07a371xptxn0i._.js} +2 -2
- package/.build/next/server/chunks/{src_lib_plugins_manager_ts_08h-7dzhghsw_._.js → src_lib_plugins_manager_ts_07iwfiw5lpzv6._.js} +2 -2
- package/.build/next/server/chunks/{src_lib_plugins_manager_ts_08obzclzfmgdo._.js → src_lib_plugins_manager_ts_094zfas129qox._.js} +2 -2
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_09x05wttn6gky._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0eicpmorbgq_0._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0j45w1t53tqiq._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0jtsoy2o58_fe._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0k2l6fz_allhv._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0m4u5d2zpf0jx._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0r69m_ija5052._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0rd7v66pzywb8._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0u9_z3h42wsrr._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_12ucso7gp_9we._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_16wp__3_qev5x._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1d_p6ksvmoo3y._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1l-e0sne7qzzx._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1lf_y4ssq-plx._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1qlgxrqwigi2t._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1u2eu34-upcvy._.js +3 -0
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_218376dd7xrc4._.js +3 -0
- package/.build/next/server/chunks/{src_lib_quota_0gw-asus4493x._.js → src_lib_quota_05418fyg4agnh._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_quota_0mglshbqfhgw7._.js → src_lib_quota_05bcp_6tt7jbr._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_quota_0zwicsy-gs0ct._.js → src_lib_quota_0nybt-asgnvf4._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_quota_1o_jx24-m_fom._.js → src_lib_quota_0vqp3tcjqt1dw._.js} +1 -1
- package/.build/next/server/chunks/src_lib_quota_19hosofplhjh1._.js +3 -0
- package/.build/next/server/chunks/{src_lib_quota_quotaKey_ts_0e9929u5mgny4._.js → src_lib_quota_quotaKey_ts_00sufley9tfda._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_quota_quotaKey_ts_06gq2e2g0ozlr._.js → src_lib_quota_quotaKey_ts_05unnu3n41ko_._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_quota_quotaKey_ts_07_2e5snrn1ck._.js → src_lib_quota_quotaKey_ts_0_9lralwqmbb2._.js} +1 -1
- package/.build/next/server/chunks/{src_lib_quota_quotaKey_ts_0e3c15o4yzmvf._.js → src_lib_quota_quotaKey_ts_0anxeaf_zkp8o._.js} +1 -1
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0ffo874n5oku6._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0jafzf3ifgkuv._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0llm3vdjpfanc._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0o6z11z1bom_m._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0txirnznm274h._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0xuq_g-h5m3c1._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_10_ltppb3vez-._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_151pluvj7g-vc._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1ceheb324j-3o._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1es9tfkkri56i._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1g0ppe_dhr5q1._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1lyayo5r_xxjv._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1mc353kr74tft._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1q-_0jqsbdlh5._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1qd-81-a26uej._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1qg73wxhhll-s._.js +3 -0
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1t-h7vqoh9u3s._.js +3 -0
- package/.build/next/server/chunks/src_shared_constants_1vndx1xsi1o3x._.js +1 -1
- package/.build/next/server/chunks/{src_shared_services_03_eh-49sw70b._.js → src_shared_services_057p4bz8pl04k._.js} +1 -1
- package/.build/next/server/chunks/{src_shared_services_04hl1xzqthbh1._.js → src_shared_services_080e2ej5vl6ay._.js} +1 -1
- package/.build/next/server/chunks/{src_shared_services_0fjvc-g7uuyno._.js → src_shared_services_0eedv-3vaf69y._.js} +1 -1
- package/.build/next/server/chunks/{src_shared_services_0kg6hc95fd11s._.js → src_shared_services_0erucmxdso94e._.js} +1 -1
- package/.build/next/server/chunks/{src_shared_services_04z41n7bdg09x._.js → src_shared_services_0lt7_o14ml7sz._.js} +1 -1
- package/.build/next/server/chunks/{src_shared_services_06s-_f77zvc_v._.js → src_shared_services_0mv_oizuaavj6._.js} +1 -1
- package/.build/next/server/chunks/src_shared_services_0pbe9rzf7waje._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_0yf7zz4c9vtx-._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_0zulbbb3ttk64._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_1-1kghymkipsb._.js +3 -0
- package/.build/next/server/chunks/{src_shared_services_13msbx-c1194y._.js → src_shared_services_106s8shtblhd5._.js} +1 -1
- package/.build/next/server/chunks/src_shared_services_11l3nwnjgyxm-._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_12t1-ga9w38dz._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_14w2j2iqdj9eb._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_176ndx2kuwev7._.js +3 -0
- package/.build/next/server/chunks/{src_shared_services_1jmf68l2lf9nz._.js → src_shared_services_1e0qskhl18qx6._.js} +1 -1
- package/.build/next/server/chunks/src_shared_services_1egld-y_7xfyo._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_1fhzl753fxvsf._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_1rjiu-sbe0cc_._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_1w8ezwxiuwg4-._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_1y_ma3zvgiio6._.js +3 -0
- package/.build/next/server/chunks/src_shared_services_1ypadc9tai46y._.js +3 -0
- package/.build/next/server/chunks/{src_shared_services_modelSyncScheduler_ts_0jprbetg42idf._.js → src_shared_services_modelSyncScheduler_ts_091bx-fd70d-_._.js} +1 -1
- package/.build/next/server/chunks/{src_shared_services_modelSyncScheduler_ts_1w5s8oci38o86._.js → src_shared_services_modelSyncScheduler_ts_0x1-b0_nhg8oa._.js} +1 -1
- package/.build/next/server/chunks/{src_shared_services_modelSyncScheduler_ts_1admvvz7wu5mb._.js → src_shared_services_modelSyncScheduler_ts_1xd6j5kaxzekj._.js} +1 -1
- package/.build/next/server/chunks/{src_shared_services_modelSyncScheduler_ts_1nid3ygpp832c._.js → src_shared_services_modelSyncScheduler_ts_1zp-x3g0jwv9s._.js} +1 -1
- package/.build/next/server/chunks/ssr/_0rb4h6lptmehu._.js +1 -1
- package/.build/next/server/chunks/ssr/_1ucg-1lxpwd_3._.js +2 -2
- package/.build/next/server/chunks/ssr/_1wo8wxqh1dk5a._.js +2 -2
- package/.build/next/server/middleware-build-manifest.js +3 -3
- package/.build/next/server/pages/500.html +1 -1
- package/.build/next/static/chunks/{0v_saoyx2w57z.js → 273ss8mst5n0x.js} +1 -1
- package/.build/next/static/chunks/{0wxtns-mya-et.css → 36imcs53bs6ue.css} +1 -1
- package/.build/next/static/chunks/{2yhtmu668hmia.js → 41ia4t5lkoy-u.js} +1 -1
- package/open-sse/config/claudeTokens.ts +108 -0
- package/open-sse/executors/base.ts +17 -0
- package/open-sse/executors/kiro.ts +415 -66
- package/open-sse/handlers/chatCore/nonStreamingResponseParse.ts +14 -0
- package/open-sse/handlers/chatCore.ts +23 -3
- package/open-sse/handlers/responseTranslator.ts +19 -1
- package/open-sse/handlers/sseParser.ts +17 -0
- package/open-sse/services/combo/targetExhaustion.ts +16 -1
- package/open-sse/services/combo.ts +2 -0
- package/open-sse/services/kiroRegion.ts +20 -0
- package/open-sse/services/usage/kimi.ts +64 -5
- package/open-sse/services/webSearchResultText.ts +100 -0
- package/open-sse/translator/request/claude-to-openai.ts +189 -3
- package/open-sse/translator/request/openai-to-kiro.ts +119 -10
- package/open-sse/translator/response/kiro-to-openai.ts +16 -0
- package/open-sse/translator/response/openai-to-claude.ts +62 -3
- package/open-sse/utils/contextOverflowError.ts +63 -0
- package/open-sse/utils/pdfText.ts +1252 -0
- package/open-sse/utils/requestLogger.ts +4 -1
- package/open-sse/utils/stream.ts +19 -6
- package/open-sse/utils/streamHelpers.ts +3 -1
- package/package.json +1 -1
- package/src/app/api/v1/messages/count_tokens/route.ts +64 -6
- package/src/domain/quotaCache.ts +4 -2
- package/src/shared/components/CommandPalette.tsx +2 -2
- package/src/shared/components/Sidebar.tsx +3 -3
- package/src/sse/handlers/chat.ts +30 -0
- package/src/sse/handlers/webSearchEmulation.ts +1181 -0
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0agn1t27_-87q.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0bdbaz8ncan3j.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0ic-xl80j3ahf.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0j-gka-h5--g7.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0jikxjpd83y3m.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0pcsfxk7rl_qj.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_0rour4wnl6mch.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1-vgf7hsozo4d.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1-wk-99yzo_ij.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_11j-oo1fko_w9.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_163fonx9p1t53.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1_scz53f35ozv.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1b-oarr-rdyrt.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1b31tiezn9knj.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1bc7yeb23me7o.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1cy8wnhh8esbt.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1hcyk-boxbura.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1hjr8tkngjpn2.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1i9ijw0wkft95.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1o4j3aexo9biu.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_1pvenj5ob2aem.js +0 -3
- package/.build/next/server/chunks/1q96_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_2024waa5dd1lu.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__0hsw8ehbw3i2o._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__0jojq4ni9peyl._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__0k_9tln3gjdsg._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__0yjugdbzmjz__._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__0yku0wexi8ghl._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__0yt9iwxll_l6u._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__0zgbbqlctz_ss._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1-1xnobnihmvu._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__10y_wajcozqre._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__12ww6_t3hg59j._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__172v_j4xarr6o._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__176x6fzvqwsiv._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__17ud9_3_ssk8k._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__19ocgqujae39l._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1cwkjoabvk0op._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1idr_msgwldj7._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1jb65mvmckdjg._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1ks8m6fd5ayhs._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1m7e1c6uyafq0._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1my791be0ej2f._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1ohivgmoa4y7_._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1pwuqglvqb8ae._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1q9d4sa50girl._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1qqnlb8mlv5qn._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1sbq18_dr5ht1._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__1wcvw0tlzacfj._.js +0 -3
- package/.build/next/server/chunks/[root-of-the-server]__20gdw36eknl9h._.js +0 -3
- package/.build/next/server/chunks/_0mqzrek7ffz5c._.js +0 -3
- package/.build/next/server/chunks/_0re9_1xpmi1in._.js +0 -3
- package/.build/next/server/chunks/_0v223bkfoc35x._.js +0 -3
- package/.build/next/server/chunks/_0w7y9fwzdv184._.js +0 -3
- package/.build/next/server/chunks/_1--z-c5w3yh_b._.js +0 -3
- package/.build/next/server/chunks/_11dfub0-g5hqx._.js +0 -3
- package/.build/next/server/chunks/_13xv49s2emgbh._.js +0 -12
- package/.build/next/server/chunks/_142m98dl-v5qx._.js +0 -3
- package/.build/next/server/chunks/_16fb5lg934z_y._.js +0 -3
- package/.build/next/server/chunks/_16ldvpp3ltmg_._.js +0 -3
- package/.build/next/server/chunks/_18nswcjdn-o_d._.js +0 -3
- package/.build/next/server/chunks/_19d_r4e56lw6c._.js +0 -3
- package/.build/next/server/chunks/_19lsyjj_cdcma._.js +0 -3
- package/.build/next/server/chunks/_1_a8xtb4eim3-._.js +0 -3
- package/.build/next/server/chunks/_1c99m13xvj0dv._.js +0 -3
- package/.build/next/server/chunks/_1do5vraekw7a_._.js +0 -3
- package/.build/next/server/chunks/_1e-2ziz7vbvj9._.js +0 -3
- package/.build/next/server/chunks/_1foat8d-cw4p_._.js +0 -3
- package/.build/next/server/chunks/_1lg1a1-ip82th._.js +0 -3
- package/.build/next/server/chunks/_1lyng1xt6yaki._.js +0 -3
- package/.build/next/server/chunks/_1nprpllrhv5ur._.js +0 -3
- package/.build/next/server/chunks/_1nxn6ans9h-yd._.js +0 -3
- package/.build/next/server/chunks/_1ohylflm1s935._.js +0 -3
- package/.build/next/server/chunks/_1omvf1ucof_yl._.js +0 -3
- package/.build/next/server/chunks/_1p60mk1s2dj0m._.js +0 -3
- package/.build/next/server/chunks/_1p628qecv5bcu._.js +0 -3
- package/.build/next/server/chunks/_1t0wesdzmxm--._.js +0 -3
- package/.build/next/server/chunks/_1tryysi-zw-uk._.js +0 -3
- package/.build/next/server/chunks/_1u2fevomxng1z._.js +0 -3
- package/.build/next/server/chunks/_1u9svjs_bx9zp._.js +0 -3
- package/.build/next/server/chunks/_1ukh92xt_h9ls._.js +0 -3
- package/.build/next/server/chunks/_1v87bx9e8bvly._.js +0 -3
- package/.build/next/server/chunks/_1vf7irr1wo9p-._.js +0 -3
- package/.build/next/server/chunks/_1wkk7z3fobxbo._.js +0 -3
- package/.build/next/server/chunks/node_modules_0_x6ms_t9skng._.js +0 -3
- package/.build/next/server/chunks/node_modules_0gohbx9aorh0u._.js +0 -3
- package/.build/next/server/chunks/node_modules_0kv7lp09lm4-8._.js +0 -3
- package/.build/next/server/chunks/node_modules_0l3c--_iz3xqs._.js +0 -3
- package/.build/next/server/chunks/node_modules_0p85cgv7zv71m._.js +0 -3
- package/.build/next/server/chunks/node_modules_0taa189fdyrvj._.js +0 -3
- package/.build/next/server/chunks/node_modules_0u4h-ppwf7yix._.js +0 -3
- package/.build/next/server/chunks/node_modules_0xbbdz3qows09._.js +0 -3
- package/.build/next/server/chunks/node_modules_0z17bntb8cv10._.js +0 -3
- package/.build/next/server/chunks/node_modules_12n0xi55k1732._.js +0 -3
- package/.build/next/server/chunks/node_modules_12w64fw3z-bcd._.js +0 -3
- package/.build/next/server/chunks/node_modules_17q-udh619fx5._.js +0 -3
- package/.build/next/server/chunks/node_modules_19z_pj5419z4n._.js +0 -3
- package/.build/next/server/chunks/node_modules_1kx78kk7zgs6_._.js +0 -3
- package/.build/next/server/chunks/node_modules_1l6a6ml6v2i_k._.js +0 -3
- package/.build/next/server/chunks/node_modules_1lkgfl4ettcxp._.js +0 -3
- package/.build/next/server/chunks/node_modules_1t9hizql924bp._.js +0 -3
- package/.build/next/server/chunks/node_modules_1tdhc46ytvj0n._.js +0 -3
- package/.build/next/server/chunks/node_modules_1uk_qp0gbho8r._.js +0 -3
- package/.build/next/server/chunks/node_modules_1w0h0i7jkq9fa._.js +0 -3
- package/.build/next/server/chunks/node_modules_1xtwpfq69aty8._.js +0 -3
- package/.build/next/server/chunks/node_modules_1zlh23qg1uq5s._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_0fukg5x40kwub._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_0g1gza5ppvhr8._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_0h_fcdlqd8s5n._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_0jpc8oc6b6i93._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_0r_t1m5o9vn66._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_0rr7gmwwe5-dh._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_0v_xskgrff6wd._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_0zuuhl2wpxt8p._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_11ckwzfy422am._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_11d97npmgf-3r._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_12_vv1aumcw9-._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_18d7kh8fes7vc._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1d2_q1k2wkf5s._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1glhxo4bsedyk._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1jk-2_ih5r8hp._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1mq27hyj74pss._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1n6-p7yy8md7l._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1os1eoc8tim1y._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1req4zcx_0cnx._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1wwzw_mr_0uhv._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_1xyy_nekye31j._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_20myne_q7f2m8._.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_04gwvpkl1nug0.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0630cbcbg0avk.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_092bd6v9u3x5d.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0a--3zhc3833c.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0cig_ru63jzhj.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0e_80iimfmh81.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0hmbodnfjrup6.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0pbaee_84omvg.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0xwupvdbu9jfl.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_0yd50kn037tj7.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1167_x8-auv93.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_126xpn2yg3grm.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_16ku3dxvhzhkk.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_19bzdp_-n6sq0.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1dqajoz1ygnbf.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1o4k7zmx1j2bu.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1oavue5eviexc.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1rqp1l_ptnubg.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1rw3-4dmewdr4.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1tyx-v56ebpk_.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_1wn_1b_n7nq-2.js +0 -3
- package/.build/next/server/chunks/node_modules_@aws-sdk_credential-provider-sso_dist-es_loadSso_20yftlrkp9ara.js +0 -3
- package/.build/next/server/chunks/node_modules_ioredis_built_index_1yvlsm3ny3pj9.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0cukrrcbxl1gr._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0ef13xoz5w433._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0hdeb5rg-7ctc._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0jjlzdp9t8t3p._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0jyo433yl_s3-._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0k5f57mkiskrt._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0w0o42y4k_0xp._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0x51vcvrd1uy1._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_0yenufzwhjgz0._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_138omazpx4xu1._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_162a5-wghb28k._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_1blmj_n8yoazn._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_1c2_vovh6b_pe._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_1fgkobij47qea._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_1iuacwne-axoo._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_1ktbqi-1t65pn._.js +0 -3
- package/.build/next/server/chunks/open-sse_services_1mdjfnli_1im9._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0_8jhcn7g0hyd._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0b48oh-otx_ol._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0fnwm57tvxp50._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0qdw6u_-fb9qe._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0u63lwdqoezav._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0uw_jlq70rwri._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_0yxhkyvrf6-x_._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1-91nmo9cckkg._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_11dshqgaqa7k2._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_12z3np4ktvyaw._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1548t2uj3kl8c._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_198mvq_7kkncw._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1cax0u9i8n09r._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1dw31gw8gv5b4._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1j3eh7kbz5s33._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1jgvga752m2_v._.js +0 -3
- package/.build/next/server/chunks/src_lib_plugins_manager_ts_1umjhh6i4065t._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_1vpqly464si1q._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0eqloedth3662._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0gsym2up09qbd._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0lqr7nuv40xhn._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0qo8767hpoa2_._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0r56lkpo6ejtl._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0u2q7i-ffa3-0._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_0y54fg642lkx_._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_144c1_26o_xs_._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1a5p04dslzkkr._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1fqs-9wvkwg8u._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1g_t5orpm0h2k._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1kydk56tgu8ni._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1mpll1mny1n6b._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1sd-o-ncs0v_b._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1u5q9l5wugo13._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1vebln5zz0jh1._.js +0 -3
- package/.build/next/server/chunks/src_lib_quota_quotaKey_ts_1xazcu5ici-w1._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_083ix1a7l974z._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_093xyaxwtg-ji._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_0i9oken9kxj9j._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_0r-8-60-r4v_r._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_0r7xmlmt1k9hy._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_0rg59_7jmlgm-._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_126q0wbgkzp5l._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_12se2mvwbr2q0._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_1fwlbkehafca_._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_1m3xkf85ae5xt._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_1obo27zju04g-._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_1rnq7eju312ri._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_1vt2-qejrwg77._.js +0 -3
- package/.build/next/server/chunks/src_shared_services_1z51753rm-kau._.js +0 -3
- /package/.build/next/static/{i-vPbUKTIijARm707KH3L → ScDemTJTEZMscCIzRWSqu}/_buildManifest.js +0 -0
- /package/.build/next/static/{i-vPbUKTIijARm707KH3L → ScDemTJTEZMscCIzRWSqu}/_clientMiddlewareManifest.js +0 -0
- /package/.build/next/static/{i-vPbUKTIijARm707KH3L → ScDemTJTEZMscCIzRWSqu}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,1181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic's web search server tool (`web_search_YYYYMMDD`, used by Claude Code's WebSearch)
|
|
3
|
+
* for targets that cannot run it: Kiro and OpenAI chat-completions providers get it as a plain
|
|
4
|
+
* function and answer with a `tool_use` nobody runs, so Claude Code saw "no usable results".
|
|
5
|
+
*
|
|
6
|
+
* TRouteAI runs it itself, the way the real API does: the model gets a `web_search` function;
|
|
7
|
+
* when it calls it, TRouteAI searches (a configured search provider, else free DuckDuckGo),
|
|
8
|
+
* reads the top pages, gives the model the results and asks again, until it answers. The client
|
|
9
|
+
* gets the Messages API's own blocks: `server_tool_use`, `web_search_tool_result` (title, URL,
|
|
10
|
+
* `encrypted_content`) and the model's text, streaming or not, with
|
|
11
|
+
* `usage.server_tool_use.web_search_requests`. The web fetch server tool (`web_fetch_YYYYMMDD`)
|
|
12
|
+
* runs the same way: TRouteAI opens the URL (public addresses only; like the real tool, only
|
|
13
|
+
* URLs that appeared earlier in the conversation) and answers with `web_fetch_tool_result`.
|
|
14
|
+
*
|
|
15
|
+
* When no search works at all, the request goes to a model with native web search instead
|
|
16
|
+
* (`TROUTEAI_WEB_SEARCH_FALLBACK_MODEL`, else the best Sonnet of an active Claude account);
|
|
17
|
+
* without one the model answers from what it knows and the client gets the search error block.
|
|
18
|
+
*/
|
|
19
|
+
import { randomBytes } from "node:crypto";
|
|
20
|
+
|
|
21
|
+
import { getComboModelString, isComboStepDisabled } from "@/lib/combos/steps";
|
|
22
|
+
import { getCustomModels, getModelIsHidden } from "@/lib/db/models";
|
|
23
|
+
import { getProviderConnections } from "@/lib/db/providers";
|
|
24
|
+
import { executeWebSearch } from "@/lib/search/executeWebSearch";
|
|
25
|
+
import { safeOutboundFetch } from "@/shared/network/safeOutboundFetch";
|
|
26
|
+
import { isPrivateHost } from "@/shared/network/outboundUrlGuard";
|
|
27
|
+
import { getModelsByProviderId } from "@trouteai/open-sse/config/providerModels.ts";
|
|
28
|
+
import { freeWebSearch } from "@trouteai/open-sse/services/freeWebSearch.ts";
|
|
29
|
+
import { getTargetFormat } from "@trouteai/open-sse/services/provider.ts";
|
|
30
|
+
import {
|
|
31
|
+
encodeWebSearchContent,
|
|
32
|
+
formatWebSearchResultsForModel,
|
|
33
|
+
type WebSearchResultItem,
|
|
34
|
+
} from "@trouteai/open-sse/services/webSearchResultText.ts";
|
|
35
|
+
import { getComboForModel, getModelInfo } from "../services/model";
|
|
36
|
+
|
|
37
|
+
type JsonRecord = Record<string, unknown>;
|
|
38
|
+
type Log = {
|
|
39
|
+
info?: (tag: string, msg: string) => void;
|
|
40
|
+
warn?: (tag: string, msg: string) => void;
|
|
41
|
+
debug?: (tag: string, msg: string) => void;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Target formats that cannot run Anthropic's server tools (they get TRouteAI's run of it). */
|
|
45
|
+
const EMULATED_TARGET_FORMATS = new Set(["kiro", "openai"]);
|
|
46
|
+
const DEFAULT_MAX_USES = 5;
|
|
47
|
+
const MAX_USES_CAP = 10;
|
|
48
|
+
const RESULTS_PER_SEARCH = 5;
|
|
49
|
+
const PAGES_READ_PER_SEARCH = 3;
|
|
50
|
+
const PAGE_TEXT_CHARS = 3000;
|
|
51
|
+
const PAGE_FETCH_TIMEOUT_MS = 6000;
|
|
52
|
+
const PAGE_MAX_BYTES = 768 * 1024;
|
|
53
|
+
const PING_INTERVAL_MS = 10_000;
|
|
54
|
+
const BROWSER_UA =
|
|
55
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0 Safari/537.36";
|
|
56
|
+
|
|
57
|
+
function isServerWebSearchTool(tool: unknown): tool is JsonRecord {
|
|
58
|
+
if (!tool || typeof tool !== "object" || Array.isArray(tool)) return false;
|
|
59
|
+
const t = tool as JsonRecord;
|
|
60
|
+
return typeof t.type === "string" && /^web_search_\d{8}$/.test(t.type) && !t.function;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isServerWebFetchTool(tool: unknown): tool is JsonRecord {
|
|
64
|
+
if (!tool || typeof tool !== "object" || Array.isArray(tool)) return false;
|
|
65
|
+
const t = tool as JsonRecord;
|
|
66
|
+
return typeof t.type === "string" && /^web_fetch_\d{8}$/.test(t.type) && !t.function;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** True when a Claude-format request carries Anthropic's web search server tool. */
|
|
70
|
+
export function hasClaudeServerWebSearchTool(body: unknown): boolean {
|
|
71
|
+
const tools = (body as JsonRecord | null)?.tools;
|
|
72
|
+
return Array.isArray(tools) && tools.some(isServerWebSearchTool);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** True when a Claude-format request carries Anthropic's web search or web fetch server tool. */
|
|
76
|
+
export function hasClaudeServerWebTool(body: unknown): boolean {
|
|
77
|
+
const tools = (body as JsonRecord | null)?.tools;
|
|
78
|
+
return (
|
|
79
|
+
Array.isArray(tools) && tools.some((t) => isServerWebSearchTool(t) || isServerWebFetchTool(t))
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function modelNeedsEmulation(modelStr: string): Promise<boolean> {
|
|
84
|
+
const info = await getModelInfo(modelStr).catch(() => null);
|
|
85
|
+
const provider = info?.provider;
|
|
86
|
+
if (!provider) return false;
|
|
87
|
+
try {
|
|
88
|
+
return EMULATED_TARGET_FORMATS.has(String(getTargetFormat(provider)));
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Whether the request's target cannot run the server tool. For a combo: when any switched-on
|
|
96
|
+
* step cannot (a later step may answer it after the first one fails).
|
|
97
|
+
*/
|
|
98
|
+
export async function webSearchNeedsEmulation(modelStr: string, depth = 0): Promise<boolean> {
|
|
99
|
+
if (!modelStr || depth > 3) return false;
|
|
100
|
+
const combo = (await getComboForModel(modelStr).catch(() => null)) as JsonRecord | null;
|
|
101
|
+
const steps = Array.isArray(combo?.models) ? (combo.models as unknown[]) : null;
|
|
102
|
+
if (!steps) return modelNeedsEmulation(modelStr);
|
|
103
|
+
for (const step of steps) {
|
|
104
|
+
if (isComboStepDisabled(step)) continue;
|
|
105
|
+
const rec = step as JsonRecord | null;
|
|
106
|
+
if (rec && typeof rec === "object" && rec.kind === "combo-ref") {
|
|
107
|
+
if (await webSearchNeedsEmulation(String(rec.comboName || ""), depth + 1)) return true;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const model = getComboModelString(step);
|
|
111
|
+
if (model && (await modelNeedsEmulation(model))) return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ── Search ───────────────────────────────────────────────────────────────
|
|
117
|
+
|
|
118
|
+
function hostOf(url: string): string {
|
|
119
|
+
try {
|
|
120
|
+
return new URL(url).hostname.toLowerCase();
|
|
121
|
+
} catch {
|
|
122
|
+
return "";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function domainMatches(host: string, domain: string): boolean {
|
|
127
|
+
const d = domain
|
|
128
|
+
.toLowerCase()
|
|
129
|
+
.replace(/^\*\./, "")
|
|
130
|
+
.replace(/^www\./, "");
|
|
131
|
+
const h = host.replace(/^www\./, "");
|
|
132
|
+
return h === d || h.endsWith(`.${d}`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function stringList(value: unknown): string[] {
|
|
136
|
+
return Array.isArray(value)
|
|
137
|
+
? value
|
|
138
|
+
.filter((v): v is string => typeof v === "string" && v.trim() !== "")
|
|
139
|
+
.map((v) => v.trim())
|
|
140
|
+
: [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type SearchOptions = { allowed: string[]; blocked: string[]; apiKeyId?: string | null };
|
|
144
|
+
|
|
145
|
+
async function runSearch(
|
|
146
|
+
query: string,
|
|
147
|
+
opts: SearchOptions,
|
|
148
|
+
log?: Log
|
|
149
|
+
): Promise<{ items: WebSearchResultItem[]; provider: string }> {
|
|
150
|
+
const keep = (url: string) => {
|
|
151
|
+
const host = hostOf(url);
|
|
152
|
+
if (!host) return false;
|
|
153
|
+
if (opts.blocked.some((d) => domainMatches(host, d))) return false;
|
|
154
|
+
if (opts.allowed.length && !opts.allowed.some((d) => domainMatches(host, d))) return false;
|
|
155
|
+
return true;
|
|
156
|
+
};
|
|
157
|
+
let lastError = "";
|
|
158
|
+
try {
|
|
159
|
+
const { data } = await executeWebSearch({
|
|
160
|
+
query,
|
|
161
|
+
max_results: RESULTS_PER_SEARCH,
|
|
162
|
+
filters: {
|
|
163
|
+
...(opts.allowed.length ? { include_domains: opts.allowed } : {}),
|
|
164
|
+
...(opts.blocked.length ? { exclude_domains: opts.blocked } : {}),
|
|
165
|
+
},
|
|
166
|
+
apiKeyId: opts.apiKeyId ?? null,
|
|
167
|
+
});
|
|
168
|
+
const items = (data.results || [])
|
|
169
|
+
.filter((r) => r?.url && keep(r.url))
|
|
170
|
+
.map((r) => ({
|
|
171
|
+
title: r.title || r.url,
|
|
172
|
+
url: r.url,
|
|
173
|
+
snippet: r.snippet || "",
|
|
174
|
+
pageAge: r.published_at ? String(r.published_at) : null,
|
|
175
|
+
// A search provider that returns page text saves the page fetch.
|
|
176
|
+
...(r.content?.text ? { pageText: String(r.content.text).slice(0, PAGE_TEXT_CHARS) } : {}),
|
|
177
|
+
}));
|
|
178
|
+
if (items.length) return { items, provider: data.provider };
|
|
179
|
+
} catch (error) {
|
|
180
|
+
lastError = error instanceof Error ? error.message : String(error);
|
|
181
|
+
}
|
|
182
|
+
// Free DuckDuckGo search: no account needed. Domain rules become site: operators.
|
|
183
|
+
const operators = [
|
|
184
|
+
...(opts.allowed.length === 1 ? [`site:${opts.allowed[0]}`] : []),
|
|
185
|
+
...opts.blocked.map((d) => `-site:${d}`),
|
|
186
|
+
];
|
|
187
|
+
const q = [query, ...operators].join(" ").slice(0, 400);
|
|
188
|
+
try {
|
|
189
|
+
const free = await freeWebSearch(q, RESULTS_PER_SEARCH + 3, 10_000);
|
|
190
|
+
const items = free
|
|
191
|
+
.filter((r) => keep(r.url))
|
|
192
|
+
.slice(0, RESULTS_PER_SEARCH)
|
|
193
|
+
.map((r) => ({
|
|
194
|
+
title: r.title || r.url,
|
|
195
|
+
url: r.url,
|
|
196
|
+
snippet: r.snippet || "",
|
|
197
|
+
pageAge: null,
|
|
198
|
+
}));
|
|
199
|
+
return { items, provider: "duckduckgo-free" };
|
|
200
|
+
} catch (error) {
|
|
201
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
202
|
+
log?.warn?.(
|
|
203
|
+
"WEBSEARCH",
|
|
204
|
+
`search failed (${lastError ? `${lastError.slice(0, 120)}; ` : ""}free search: ${message.slice(0, 120)})`
|
|
205
|
+
);
|
|
206
|
+
throw new Error("web search unavailable");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Cut `<tag ...> ... </tag>` (and `<!-- -->`) spans out of the page in one pass. */
|
|
211
|
+
function removeSpans(html: string, tags: string[]): string {
|
|
212
|
+
const lower = html.toLowerCase();
|
|
213
|
+
const openers = [
|
|
214
|
+
...tags.map((t) => ({ open: `<${t}`, close: `</${t}`, end: ">" })),
|
|
215
|
+
{ open: "<!--", close: "-->", end: "" },
|
|
216
|
+
];
|
|
217
|
+
const nextAt = openers.map(() => -2);
|
|
218
|
+
let out = "";
|
|
219
|
+
let i = 0;
|
|
220
|
+
while (i < html.length) {
|
|
221
|
+
let best = -1;
|
|
222
|
+
let which = -1;
|
|
223
|
+
for (let k = 0; k < openers.length; k++) {
|
|
224
|
+
if (nextAt[k] !== -1 && nextAt[k] < i) nextAt[k] = lower.indexOf(openers[k].open, i);
|
|
225
|
+
if (nextAt[k] !== -1 && (best === -1 || nextAt[k] < best)) {
|
|
226
|
+
best = nextAt[k];
|
|
227
|
+
which = k;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (best === -1) {
|
|
231
|
+
out += html.slice(i);
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
const o = openers[which];
|
|
235
|
+
const boundary = lower.charAt(best + o.open.length);
|
|
236
|
+
if (o.end && /[a-z0-9-]/.test(boundary)) {
|
|
237
|
+
// `<scripts>` or `<navbar>`: not the tag, keep it.
|
|
238
|
+
out += html.slice(i, best + 1);
|
|
239
|
+
i = best + 1;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
out += `${html.slice(i, best)} `;
|
|
243
|
+
const close = lower.indexOf(o.close, best + o.open.length);
|
|
244
|
+
if (close === -1) break;
|
|
245
|
+
if (!o.end) {
|
|
246
|
+
i = close + o.close.length;
|
|
247
|
+
} else {
|
|
248
|
+
const end = lower.indexOf(">", close);
|
|
249
|
+
i = end === -1 ? html.length : end + 1;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return out;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function htmlToText(html: string): string {
|
|
256
|
+
let s = html.slice(0, PAGE_MAX_BYTES);
|
|
257
|
+
const lower = s.toLowerCase();
|
|
258
|
+
const bodyStart = lower.indexOf("<body");
|
|
259
|
+
if (bodyStart !== -1) {
|
|
260
|
+
const open = lower.indexOf(">", bodyStart);
|
|
261
|
+
const close = lower.lastIndexOf("</body");
|
|
262
|
+
s = s.slice(open === -1 ? bodyStart : open + 1, close > bodyStart ? close : undefined);
|
|
263
|
+
}
|
|
264
|
+
s = removeSpans(s, [
|
|
265
|
+
"script",
|
|
266
|
+
"style",
|
|
267
|
+
"noscript",
|
|
268
|
+
"svg",
|
|
269
|
+
"template",
|
|
270
|
+
"iframe",
|
|
271
|
+
"nav",
|
|
272
|
+
"footer",
|
|
273
|
+
"header",
|
|
274
|
+
"aside",
|
|
275
|
+
"form",
|
|
276
|
+
"head",
|
|
277
|
+
]);
|
|
278
|
+
s = s.replace(
|
|
279
|
+
/<\/?(p|div|br|li|ul|ol|h[1-6]|tr|table|section|article|pre|blockquote)\b[^>]{0,500}>/gi,
|
|
280
|
+
"\n"
|
|
281
|
+
);
|
|
282
|
+
s = s.replace(/<[^>]{0,2000}>/g, " ");
|
|
283
|
+
s = s
|
|
284
|
+
.replace(/ /gi, " ")
|
|
285
|
+
.replace(/</gi, "<")
|
|
286
|
+
.replace(/>/gi, ">")
|
|
287
|
+
.replace(/"/gi, '"')
|
|
288
|
+
.replace(/�*39;|'/gi, "'")
|
|
289
|
+
.replace(/&#(\d{1,6});/g, (_, n) => {
|
|
290
|
+
const code = Number(n);
|
|
291
|
+
return code > 0 && code < 0x110000 ? String.fromCodePoint(code) : " ";
|
|
292
|
+
})
|
|
293
|
+
.replace(/&/gi, "&");
|
|
294
|
+
return s
|
|
295
|
+
.split("\n")
|
|
296
|
+
.map((line) => line.replace(/[ \t\r\f\v]+/g, " ").trim())
|
|
297
|
+
.filter((line) => line.length > 1)
|
|
298
|
+
.join("\n")
|
|
299
|
+
.replace(/\n{3,}/g, "\n\n");
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
type Fetched = { status: number; contentType: string; bytes: Buffer; url: string };
|
|
303
|
+
|
|
304
|
+
/** GET a public URL (redirects followed by hand, each hop checked as public); null on failure. */
|
|
305
|
+
async function fetchUrl(
|
|
306
|
+
url: string,
|
|
307
|
+
signal: AbortSignal | null | undefined,
|
|
308
|
+
maxBytes: number,
|
|
309
|
+
accept: string
|
|
310
|
+
): Promise<Fetched | null> {
|
|
311
|
+
let current = url;
|
|
312
|
+
for (let hop = 0; hop < 5; hop++) {
|
|
313
|
+
if (signal?.aborted) return null;
|
|
314
|
+
let res: Response;
|
|
315
|
+
try {
|
|
316
|
+
res = await safeOutboundFetch(current, {
|
|
317
|
+
method: "GET",
|
|
318
|
+
guard: "public-only",
|
|
319
|
+
allowRedirect: false,
|
|
320
|
+
timeoutMs: PAGE_FETCH_TIMEOUT_MS,
|
|
321
|
+
retry: false,
|
|
322
|
+
headers: { "User-Agent": BROWSER_UA, Accept: accept },
|
|
323
|
+
});
|
|
324
|
+
} catch {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
if (res.status >= 300 && res.status < 400) {
|
|
328
|
+
const location = res.headers.get("location");
|
|
329
|
+
await res.body?.cancel().catch(() => {});
|
|
330
|
+
if (!location) return null;
|
|
331
|
+
try {
|
|
332
|
+
current = new URL(location, current).href;
|
|
333
|
+
} catch {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
const contentType = (res.headers.get("content-type") || "").toLowerCase();
|
|
339
|
+
if (!res.ok) {
|
|
340
|
+
await res.body?.cancel().catch(() => {});
|
|
341
|
+
return { status: res.status, contentType, bytes: Buffer.alloc(0), url: current };
|
|
342
|
+
}
|
|
343
|
+
const reader = res.body?.getReader();
|
|
344
|
+
if (!reader) return { status: res.status, contentType, bytes: Buffer.alloc(0), url: current };
|
|
345
|
+
const chunks: Uint8Array[] = [];
|
|
346
|
+
let size = 0;
|
|
347
|
+
while (size <= maxBytes) {
|
|
348
|
+
const { done, value } = await reader.read().catch(() => ({ done: true, value: undefined }));
|
|
349
|
+
if (done || !value) break;
|
|
350
|
+
chunks.push(value);
|
|
351
|
+
size += value.length;
|
|
352
|
+
}
|
|
353
|
+
await reader.cancel().catch(() => {});
|
|
354
|
+
return {
|
|
355
|
+
status: res.status,
|
|
356
|
+
contentType,
|
|
357
|
+
bytes: Buffer.concat(chunks.map((c) => Buffer.from(c))),
|
|
358
|
+
url: current,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** Readable text of a public page, for search results. */
|
|
365
|
+
async function fetchPageText(url: string, signal?: AbortSignal | null): Promise<string> {
|
|
366
|
+
const got = await fetchUrl(url, signal, PAGE_MAX_BYTES, "text/html,text/plain;q=0.9,*/*;q=0.5");
|
|
367
|
+
if (!got || got.status !== 200) return "";
|
|
368
|
+
if (!/text\/html|text\/plain|application\/xhtml/.test(got.contentType)) return "";
|
|
369
|
+
const raw = got.bytes.subarray(0, PAGE_MAX_BYTES).toString("utf8");
|
|
370
|
+
const text = got.contentType.includes("text/plain") ? raw : htmlToText(raw);
|
|
371
|
+
return text.slice(0, PAGE_TEXT_CHARS);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// ── Web fetch ──────────────────────────────────────────────────────────────
|
|
375
|
+
|
|
376
|
+
const FETCH_MAX_URL = 250;
|
|
377
|
+
const FETCH_MAX_HTML_BYTES = 4 * 1024 * 1024;
|
|
378
|
+
const FETCH_MAX_PDF_BYTES = 32 * 1024 * 1024;
|
|
379
|
+
/** Text of a fetched page given to the model when max_content_tokens is not set. */
|
|
380
|
+
const FETCH_DEFAULT_TEXT_CHARS = 100_000;
|
|
381
|
+
|
|
382
|
+
export type FetchedDocument =
|
|
383
|
+
| { ok: true; url: string; title: string; text?: string; pdfBase64?: string }
|
|
384
|
+
| { ok: false; errorCode: string };
|
|
385
|
+
|
|
386
|
+
function titleOf(html: string): string {
|
|
387
|
+
const m = /<title[^>]{0,200}>([\s\S]{0,500}?)<\/title>/i.exec(html.slice(0, 200_000));
|
|
388
|
+
return m ? htmlToText(m[1]).replace(/\s+/g, " ").trim().slice(0, 300) : "";
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** One web fetch, as the real tool does it: text and HTML as text, PDF as base64. */
|
|
392
|
+
async function fetchDocument(
|
|
393
|
+
url: string,
|
|
394
|
+
maxChars: number,
|
|
395
|
+
signal: AbortSignal | null | undefined
|
|
396
|
+
): Promise<FetchedDocument> {
|
|
397
|
+
const got = await fetchUrl(
|
|
398
|
+
url,
|
|
399
|
+
signal,
|
|
400
|
+
FETCH_MAX_PDF_BYTES,
|
|
401
|
+
"text/html,application/xhtml+xml,text/plain;q=0.9,application/pdf;q=0.9,*/*;q=0.5"
|
|
402
|
+
);
|
|
403
|
+
if (!got) return { ok: false, errorCode: "url_not_accessible" };
|
|
404
|
+
if (got.status === 429) return { ok: false, errorCode: "too_many_requests" };
|
|
405
|
+
if (got.status !== 200) return { ok: false, errorCode: "url_not_accessible" };
|
|
406
|
+
const type = got.contentType;
|
|
407
|
+
const isPdf = type.includes("application/pdf") || got.bytes.subarray(0, 5).toString() === "%PDF-";
|
|
408
|
+
if (isPdf) {
|
|
409
|
+
if (got.bytes.length > FETCH_MAX_PDF_BYTES)
|
|
410
|
+
return { ok: false, errorCode: "content_too_large" };
|
|
411
|
+
return { ok: true, url: got.url, title: "", pdfBase64: got.bytes.toString("base64") };
|
|
412
|
+
}
|
|
413
|
+
const textual =
|
|
414
|
+
/text\/|application\/(xhtml\+xml|xml|json|javascript|x-javascript|rss\+xml|atom\+xml)/.test(
|
|
415
|
+
type
|
|
416
|
+
) || type === "";
|
|
417
|
+
if (!textual) return { ok: false, errorCode: "unsupported_content_type" };
|
|
418
|
+
const raw = got.bytes.subarray(0, FETCH_MAX_HTML_BYTES).toString("utf8");
|
|
419
|
+
const html = /html|xml/.test(type) || /^\s*<(!doctype|html)/i.test(raw.slice(0, 200));
|
|
420
|
+
let text = html ? htmlToText(raw.slice(0, FETCH_MAX_HTML_BYTES)) : raw;
|
|
421
|
+
if (text.length > maxChars) text = `${text.slice(0, maxChars)}\n[... cut at the content limit]`;
|
|
422
|
+
return { ok: true, url: got.url, title: html ? titleOf(raw) : "", text };
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const URL_IN_TEXT = /https?:\/\/[^\s"'<>`{}|\\^[\]]+/gi;
|
|
426
|
+
|
|
427
|
+
function normalizeUrl(raw: string): string {
|
|
428
|
+
try {
|
|
429
|
+
const u = new URL(raw.replace(/[.,;:!?)]+$/, ""));
|
|
430
|
+
u.hash = "";
|
|
431
|
+
let s = u.href;
|
|
432
|
+
if (s.endsWith("/") && u.pathname !== "/") s = s.slice(0, -1);
|
|
433
|
+
if (u.pathname === "/" && !u.search) s = `${u.protocol}//${u.host}`;
|
|
434
|
+
return s.toLowerCase();
|
|
435
|
+
} catch {
|
|
436
|
+
return "";
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function urlsIn(text: string, into: Set<string>) {
|
|
441
|
+
for (const m of text.matchAll(URL_IN_TEXT)) {
|
|
442
|
+
const n = normalizeUrl(m[0]);
|
|
443
|
+
if (n) into.add(n);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** A URL that looks like it carries a credential (user:password@, or a key / token parameter). */
|
|
448
|
+
function urlHasCredential(url: URL): boolean {
|
|
449
|
+
if (url.username || url.password) return true;
|
|
450
|
+
for (const key of url.searchParams.keys()) {
|
|
451
|
+
if (/(^|[_-])(key|apikey|token|secret|password|passwd|pwd|auth|signature|sig)$/i.test(key)) {
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
type UrlSourceRule = { type: string; tools: string[] };
|
|
459
|
+
type UrlSources = {
|
|
460
|
+
user: UrlSourceRule;
|
|
461
|
+
client: UrlSourceRule;
|
|
462
|
+
server: UrlSourceRule;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
function urlSourceRule(value: unknown): UrlSourceRule {
|
|
466
|
+
const v = (value || {}) as JsonRecord;
|
|
467
|
+
const type = typeof v.type === "string" ? v.type : "all";
|
|
468
|
+
const tools = Array.isArray(v.tools)
|
|
469
|
+
? (v.tools as JsonRecord[]).map((t) => String(t?.name || "")).filter(Boolean)
|
|
470
|
+
: [];
|
|
471
|
+
return { type, tools };
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function ruleAllows(rule: UrlSourceRule, toolName: string): boolean {
|
|
475
|
+
if (rule.type === "none") return false;
|
|
476
|
+
if (rule.type === "only") return rule.tools.includes(toolName);
|
|
477
|
+
if (rule.type === "except") return !rule.tools.includes(toolName);
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* The URLs the web fetch tool may open (the real API's rule: URLs that appeared earlier in user
|
|
483
|
+
* messages, client tool results or web search / fetch results, as `url_sources` allows), and the
|
|
484
|
+
* URLs the user wrote (a URL with a credential must come from there).
|
|
485
|
+
*/
|
|
486
|
+
function priorContextUrls(
|
|
487
|
+
messages: unknown[],
|
|
488
|
+
sources: UrlSources
|
|
489
|
+
): { allowed: Set<string>; user: Set<string> } {
|
|
490
|
+
const allowed = new Set<string>();
|
|
491
|
+
const user = new Set<string>();
|
|
492
|
+
const toolNames = new Map<string, string>();
|
|
493
|
+
for (const m of messages as JsonRecord[]) {
|
|
494
|
+
const content = m?.content;
|
|
495
|
+
if (m?.role === "assistant" && Array.isArray(content)) {
|
|
496
|
+
for (const b of content as JsonRecord[]) {
|
|
497
|
+
if ((b?.type === "tool_use" || b?.type === "server_tool_use") && b.id) {
|
|
498
|
+
toolNames.set(String(b.id), String(b.name || ""));
|
|
499
|
+
}
|
|
500
|
+
if (b?.type === "web_search_tool_result" && ruleAllows(sources.server, "web_search")) {
|
|
501
|
+
for (const r of Array.isArray(b.content) ? (b.content as JsonRecord[]) : []) {
|
|
502
|
+
if (typeof r?.url === "string") urlsIn(r.url, allowed);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
if (b?.type === "web_fetch_tool_result" && ruleAllows(sources.server, "web_fetch")) {
|
|
506
|
+
const res = b.content as JsonRecord | undefined;
|
|
507
|
+
if (typeof res?.url === "string") urlsIn(res.url, allowed);
|
|
508
|
+
const src = (res?.content as JsonRecord | undefined)?.source as JsonRecord | undefined;
|
|
509
|
+
if (src?.type === "text" && typeof src.data === "string") urlsIn(src.data, allowed);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
if (m?.role !== "user") continue;
|
|
515
|
+
if (typeof content === "string") {
|
|
516
|
+
urlsIn(content, user);
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
for (const b of Array.isArray(content) ? (content as JsonRecord[]) : []) {
|
|
520
|
+
if (b?.type === "text" && typeof b.text === "string") urlsIn(b.text, user);
|
|
521
|
+
if (b?.type === "tool_result") {
|
|
522
|
+
const name = toolNames.get(String(b.tool_use_id || "")) || "";
|
|
523
|
+
if (!ruleAllows(sources.client, name)) continue;
|
|
524
|
+
const parts = typeof b.content === "string" ? [b.content] : [];
|
|
525
|
+
for (const c of Array.isArray(b.content) ? (b.content as JsonRecord[]) : []) {
|
|
526
|
+
if (c?.type === "text" && typeof c.text === "string") parts.push(c.text);
|
|
527
|
+
}
|
|
528
|
+
for (const p of parts) urlsIn(p, allowed);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (sources.user.type !== "none") for (const u of user) allowed.add(u);
|
|
533
|
+
return { allowed, user };
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
async function searchWithPages(
|
|
537
|
+
query: string,
|
|
538
|
+
opts: SearchOptions,
|
|
539
|
+
signal: AbortSignal | null | undefined,
|
|
540
|
+
log?: Log
|
|
541
|
+
): Promise<WebSearchResultItem[]> {
|
|
542
|
+
const { items, provider } = await runSearch(query, opts, log);
|
|
543
|
+
if (process.env.TROUTEAI_WEB_SEARCH_READ_PAGES !== "0") {
|
|
544
|
+
await Promise.all(
|
|
545
|
+
items.slice(0, PAGES_READ_PER_SEARCH).map(async (item) => {
|
|
546
|
+
if (!item.pageText) item.pageText = await fetchPageText(item.url, signal);
|
|
547
|
+
})
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
log?.info?.(
|
|
551
|
+
"WEBSEARCH",
|
|
552
|
+
`"${query.slice(0, 80)}": ${items.length} results via ${provider}, ${items.filter((i) => i.pageText).length} pages read`
|
|
553
|
+
);
|
|
554
|
+
return items;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// ── Native fallback ──────────────────────────────────────────────────────
|
|
558
|
+
|
|
559
|
+
function versionOf(id: string): number {
|
|
560
|
+
const m = /(?:opus|sonnet|haiku|fable)-(\d+)(?:[-.](\d))?(?:$|[^0-9])/.exec(id);
|
|
561
|
+
return m ? Number(m[1]) + (m[2] ? Number(m[2]) / 10 : 0) : 0;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/** A model that runs web search itself, for when TRouteAI's own search is not reachable. */
|
|
565
|
+
export async function resolveNativeWebSearchModel(): Promise<string | null> {
|
|
566
|
+
const configured = (process.env.TROUTEAI_WEB_SEARCH_FALLBACK_MODEL || "").trim();
|
|
567
|
+
if (configured) return configured.toLowerCase() === "off" ? null : configured;
|
|
568
|
+
for (const provider of ["claude", "anthropic"]) {
|
|
569
|
+
const connections = (await getProviderConnections({ provider }).catch(
|
|
570
|
+
() => []
|
|
571
|
+
)) as JsonRecord[];
|
|
572
|
+
if (!connections.some((c) => c?.isActive !== false)) continue;
|
|
573
|
+
const custom = ((await getCustomModels(provider).catch(() => [])) || []) as JsonRecord[];
|
|
574
|
+
const ids = new Set<string>([
|
|
575
|
+
...getModelsByProviderId(provider).map((m) => m.id),
|
|
576
|
+
...custom.map((m) => String(m?.id || "")).filter(Boolean),
|
|
577
|
+
]);
|
|
578
|
+
const visible = [...ids].filter((id) => {
|
|
579
|
+
try {
|
|
580
|
+
return !getModelIsHidden(provider, id);
|
|
581
|
+
} catch {
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
const byVersion = (a: string, b: string) => versionOf(b) - versionOf(a);
|
|
586
|
+
const pick = visible.filter((id) => id.includes("sonnet")).sort(byVersion)[0];
|
|
587
|
+
if (pick) return `${provider}/${pick}`;
|
|
588
|
+
}
|
|
589
|
+
return null;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// ── The loop ─────────────────────────────────────────────────────────────
|
|
593
|
+
|
|
594
|
+
const newId = (prefix: string) => `${prefix}${randomBytes(12).toString("base64url")}`;
|
|
595
|
+
|
|
596
|
+
type Usage = {
|
|
597
|
+
input_tokens: number;
|
|
598
|
+
output_tokens: number;
|
|
599
|
+
cache_creation_input_tokens: number;
|
|
600
|
+
cache_read_input_tokens: number;
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
function addUsage(total: Usage, usage: unknown) {
|
|
604
|
+
const u = (usage || {}) as JsonRecord;
|
|
605
|
+
const n = (v: unknown) => (typeof v === "number" && Number.isFinite(v) ? v : 0);
|
|
606
|
+
total.input_tokens += n(u.input_tokens);
|
|
607
|
+
total.output_tokens += n(u.output_tokens);
|
|
608
|
+
total.cache_creation_input_tokens += n(u.cache_creation_input_tokens);
|
|
609
|
+
total.cache_read_input_tokens += n(u.cache_read_input_tokens);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
type Emitter = {
|
|
613
|
+
start(message: JsonRecord): void;
|
|
614
|
+
block(block: JsonRecord): void;
|
|
615
|
+
ping(): void;
|
|
616
|
+
finish(message: JsonRecord): void;
|
|
617
|
+
fail(message: string): void;
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
export type WebSearchEmulationArgs = {
|
|
621
|
+
request: { signal?: AbortSignal | null };
|
|
622
|
+
body: JsonRecord;
|
|
623
|
+
/** One non-streaming model turn through TRouteAI's normal routing (Claude format in/out). */
|
|
624
|
+
callModel: (body: JsonRecord) => Promise<Response>;
|
|
625
|
+
apiKeyId?: string | null;
|
|
626
|
+
log?: Log;
|
|
627
|
+
/** Tests: replace the search (default: configured provider, else DuckDuckGo, + page text). */
|
|
628
|
+
search?: (query: string, opts: SearchOptions) => Promise<WebSearchResultItem[]>;
|
|
629
|
+
/** Tests: replace the choice of the native web search model. */
|
|
630
|
+
nativeModel?: () => Promise<string | null>;
|
|
631
|
+
/** Tests: replace the web fetch (default: a public-only GET, HTML as text, PDF as base64). */
|
|
632
|
+
fetch?: (url: string, maxChars: number) => Promise<FetchedDocument>;
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
export async function runWebSearchEmulation(args: WebSearchEmulationArgs): Promise<Response> {
|
|
636
|
+
const { body, callModel, log } = args;
|
|
637
|
+
const signal = args.request?.signal ?? null;
|
|
638
|
+
const search =
|
|
639
|
+
args.search ||
|
|
640
|
+
((query: string, opts: SearchOptions) => searchWithPages(query, opts, signal, log));
|
|
641
|
+
const nativeModel = args.nativeModel || resolveNativeWebSearchModel;
|
|
642
|
+
const fetchDoc =
|
|
643
|
+
args.fetch || ((url: string, maxChars: number) => fetchDocument(url, maxChars, signal));
|
|
644
|
+
const tools = Array.isArray(body.tools) ? (body.tools as unknown[]) : [];
|
|
645
|
+
const searchTool = tools.find(isServerWebSearchTool) as JsonRecord | undefined;
|
|
646
|
+
const fetchTool = tools.find(isServerWebFetchTool) as JsonRecord | undefined;
|
|
647
|
+
const clientTools = tools.filter(
|
|
648
|
+
(t) => !isServerWebSearchTool(t) && !isServerWebFetchTool(t)
|
|
649
|
+
) as JsonRecord[];
|
|
650
|
+
const clientToolNames = new Set(clientTools.map((t) => String(t?.name || "")));
|
|
651
|
+
const fnName = clientToolNames.has("web_search") ? "trouteai_web_search" : "web_search";
|
|
652
|
+
const fetchFnName = clientToolNames.has("web_fetch") ? "trouteai_web_fetch" : "web_fetch";
|
|
653
|
+
const usesOf = (tool: JsonRecord | undefined) =>
|
|
654
|
+
Math.min(
|
|
655
|
+
MAX_USES_CAP,
|
|
656
|
+
Math.max(1, Number(tool?.max_uses) > 0 ? Number(tool?.max_uses) : DEFAULT_MAX_USES)
|
|
657
|
+
);
|
|
658
|
+
const maxUses = usesOf(searchTool);
|
|
659
|
+
const maxFetches = usesOf(fetchTool);
|
|
660
|
+
const fetchMaxChars =
|
|
661
|
+
Number(fetchTool?.max_content_tokens) > 0
|
|
662
|
+
? Math.min(400_000, Math.ceil(Number(fetchTool?.max_content_tokens) * 3))
|
|
663
|
+
: FETCH_DEFAULT_TEXT_CHARS;
|
|
664
|
+
const fetchCitations = (fetchTool?.citations as JsonRecord | undefined)?.enabled === true;
|
|
665
|
+
const urlSources: UrlSources = {
|
|
666
|
+
user: urlSourceRule((fetchTool?.url_sources as JsonRecord | undefined)?.user_input),
|
|
667
|
+
client: urlSourceRule((fetchTool?.url_sources as JsonRecord | undefined)?.client_tool_results),
|
|
668
|
+
server: urlSourceRule((fetchTool?.url_sources as JsonRecord | undefined)?.server_tool_results),
|
|
669
|
+
};
|
|
670
|
+
const searchOptions: SearchOptions = {
|
|
671
|
+
allowed: stringList(searchTool?.allowed_domains),
|
|
672
|
+
blocked: stringList(searchTool?.blocked_domains),
|
|
673
|
+
apiKeyId: args.apiKeyId,
|
|
674
|
+
};
|
|
675
|
+
const fetchDomains = {
|
|
676
|
+
allowed: stringList(fetchTool?.allowed_domains),
|
|
677
|
+
blocked: stringList(fetchTool?.blocked_domains),
|
|
678
|
+
};
|
|
679
|
+
const fnTool = {
|
|
680
|
+
name: fnName,
|
|
681
|
+
description:
|
|
682
|
+
"Search the web for current information. Returns the top results with title, URL, a " +
|
|
683
|
+
"summary and the text of the first pages. Use it when the answer needs recent or outside facts.",
|
|
684
|
+
input_schema: {
|
|
685
|
+
type: "object",
|
|
686
|
+
properties: { query: { type: "string", description: "The search query" } },
|
|
687
|
+
required: ["query"],
|
|
688
|
+
},
|
|
689
|
+
};
|
|
690
|
+
const fetchFnTool = {
|
|
691
|
+
name: fetchFnName,
|
|
692
|
+
description:
|
|
693
|
+
"Fetch the full content of a web page or PDF by its URL. Only URLs that appeared earlier " +
|
|
694
|
+
"in the conversation (written by the user, in a tool result, or in web search / fetch " +
|
|
695
|
+
"results) can be fetched.",
|
|
696
|
+
input_schema: {
|
|
697
|
+
type: "object",
|
|
698
|
+
properties: { url: { type: "string", description: "The URL to fetch" } },
|
|
699
|
+
required: ["url"],
|
|
700
|
+
},
|
|
701
|
+
};
|
|
702
|
+
const choice = body.tool_choice as JsonRecord | undefined;
|
|
703
|
+
const forcedName =
|
|
704
|
+
choice?.type === "tool" && searchTool && choice.name === searchTool.name
|
|
705
|
+
? fnName
|
|
706
|
+
: choice?.type === "tool" && fetchTool && choice.name === fetchTool.name
|
|
707
|
+
? fetchFnName
|
|
708
|
+
: choice?.type === "any" && clientTools.length === 0 && !(searchTool && fetchTool)
|
|
709
|
+
? searchTool
|
|
710
|
+
? fnName
|
|
711
|
+
: fetchFnName
|
|
712
|
+
: "";
|
|
713
|
+
const forced = choice?.type === "any" || !!forcedName;
|
|
714
|
+
const messages = [...((body.messages as unknown[]) || [])];
|
|
715
|
+
const { allowed: fetchableUrls, user: userUrls } = priorContextUrls(messages, urlSources);
|
|
716
|
+
const turnBody = (withSearch: boolean, withFetch: boolean, first: boolean): JsonRecord => {
|
|
717
|
+
const serverFns = [
|
|
718
|
+
...(searchTool && withSearch ? [fnTool] : []),
|
|
719
|
+
...(fetchTool && withFetch ? [fetchFnTool] : []),
|
|
720
|
+
];
|
|
721
|
+
const next: JsonRecord = {
|
|
722
|
+
...body,
|
|
723
|
+
stream: false,
|
|
724
|
+
messages,
|
|
725
|
+
tools: [...clientTools, ...serverFns],
|
|
726
|
+
};
|
|
727
|
+
if ((next.tools as unknown[]).length === 0) delete next.tools;
|
|
728
|
+
if (forced && first && forcedName && serverFns.some((f) => f.name === forcedName)) {
|
|
729
|
+
next.tool_choice = { type: "tool", name: forcedName };
|
|
730
|
+
} else if (body.tool_choice && (forced || serverFns.length === 0)) {
|
|
731
|
+
if ((next.tools as unknown[] | undefined)?.length) {
|
|
732
|
+
next.tool_choice = first && choice?.type === "any" ? { type: "any" } : { type: "auto" };
|
|
733
|
+
} else delete next.tool_choice;
|
|
734
|
+
}
|
|
735
|
+
return next;
|
|
736
|
+
};
|
|
737
|
+
const isServerFn = (b: JsonRecord) =>
|
|
738
|
+
b?.type === "tool_use" &&
|
|
739
|
+
((!!searchTool && b.name === fnName) || (!!fetchTool && b.name === fetchFnName));
|
|
740
|
+
const checkFetchUrl = (url: string): string => {
|
|
741
|
+
if (!url) return "invalid_tool_input";
|
|
742
|
+
if (url.length > FETCH_MAX_URL) return "url_too_long";
|
|
743
|
+
let parsed: URL;
|
|
744
|
+
try {
|
|
745
|
+
parsed = new URL(url);
|
|
746
|
+
} catch {
|
|
747
|
+
return "invalid_tool_input";
|
|
748
|
+
}
|
|
749
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return "invalid_tool_input";
|
|
750
|
+
const host = parsed.hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
751
|
+
if (host === "localhost" || isPrivateHost(host)) return "url_not_allowed";
|
|
752
|
+
if (fetchDomains.blocked.some((d) => domainMatches(host, d))) return "url_not_allowed";
|
|
753
|
+
if (fetchDomains.allowed.length && !fetchDomains.allowed.some((d) => domainMatches(host, d))) {
|
|
754
|
+
return "url_not_allowed";
|
|
755
|
+
}
|
|
756
|
+
const normalized = normalizeUrl(url);
|
|
757
|
+
if (urlHasCredential(parsed) && !userUrls.has(normalized)) return "url_not_allowed";
|
|
758
|
+
if (!fetchableUrls.has(normalized)) return "url_not_in_prior_context";
|
|
759
|
+
return "";
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
// First model turn before any byte goes out: its errors keep their normal status code.
|
|
763
|
+
const firstRes = await callModel(turnBody(true, true, true));
|
|
764
|
+
if (!firstRes.ok) return firstRes;
|
|
765
|
+
let current = (await firstRes.json().catch(() => null)) as JsonRecord | null;
|
|
766
|
+
if (!current || !Array.isArray(current.content)) {
|
|
767
|
+
return new Response(
|
|
768
|
+
JSON.stringify({
|
|
769
|
+
type: "error",
|
|
770
|
+
error: { type: "api_error", message: "The model answered in an unexpected format" },
|
|
771
|
+
}),
|
|
772
|
+
{
|
|
773
|
+
status: 502,
|
|
774
|
+
headers: { "content-type": "application/json" },
|
|
775
|
+
}
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// The first search, also before any byte goes out: when no search works at all, a model with
|
|
780
|
+
// its own web search takes the whole request instead.
|
|
781
|
+
const firstCalls = searchTool
|
|
782
|
+
? (current.content as JsonRecord[]).filter((b) => b?.type === "tool_use" && b.name === fnName)
|
|
783
|
+
: [];
|
|
784
|
+
let prefetched: Map<string, WebSearchResultItem[] | Error> | null = null;
|
|
785
|
+
if (firstCalls.length > 0) {
|
|
786
|
+
prefetched = new Map();
|
|
787
|
+
const firstQuery = String((firstCalls[0].input as JsonRecord | undefined)?.query || "").trim();
|
|
788
|
+
try {
|
|
789
|
+
prefetched.set(String(firstCalls[0].id), await search(firstQuery, searchOptions));
|
|
790
|
+
} catch (error) {
|
|
791
|
+
const native = await nativeModel().catch(() => null);
|
|
792
|
+
if (native) {
|
|
793
|
+
log?.warn?.("WEBSEARCH", `no web search reachable; sending this request to ${native}`);
|
|
794
|
+
const routed = await callModel({ ...body, model: native });
|
|
795
|
+
if (routed.ok) return routed;
|
|
796
|
+
await routed.body?.cancel().catch(() => {});
|
|
797
|
+
}
|
|
798
|
+
prefetched.set(String(firstCalls[0].id), error as Error);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
const wantStream = body.stream === true;
|
|
803
|
+
const total: Usage = {
|
|
804
|
+
input_tokens: 0,
|
|
805
|
+
output_tokens: 0,
|
|
806
|
+
cache_creation_input_tokens: 0,
|
|
807
|
+
cache_read_input_tokens: 0,
|
|
808
|
+
};
|
|
809
|
+
let searches = 0;
|
|
810
|
+
let fetches = 0;
|
|
811
|
+
const serverToolUsage = () => ({
|
|
812
|
+
...(searchTool ? { web_search_requests: searches } : {}),
|
|
813
|
+
...(fetchTool ? { web_fetch_requests: fetches } : {}),
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
let cancelled = false;
|
|
817
|
+
const stopped = () => cancelled || !!signal?.aborted;
|
|
818
|
+
const run = async (emit: Emitter) => {
|
|
819
|
+
const out: JsonRecord[] = [];
|
|
820
|
+
const push = (block: JsonRecord) => {
|
|
821
|
+
out.push(block);
|
|
822
|
+
emit.block(block);
|
|
823
|
+
};
|
|
824
|
+
emit.start(current as JsonRecord);
|
|
825
|
+
let withSearch = true;
|
|
826
|
+
let withFetch = true;
|
|
827
|
+
for (let turn = 0; turn < MAX_USES_CAP + 2; turn++) {
|
|
828
|
+
const msg = current as JsonRecord;
|
|
829
|
+
addUsage(total, msg.usage);
|
|
830
|
+
const content = (msg.content as JsonRecord[]) || [];
|
|
831
|
+
const calls = content.filter(isServerFn);
|
|
832
|
+
const clientCall = content.some((b) => b?.type === "tool_use" && !isServerFn(b));
|
|
833
|
+
const results: JsonRecord[] = [];
|
|
834
|
+
for (const block of content) {
|
|
835
|
+
if (!isServerFn(block)) {
|
|
836
|
+
push(block);
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
if (block.name === fetchFnName && fetchTool) {
|
|
840
|
+
const url = String((block.input as JsonRecord | undefined)?.url || "").trim();
|
|
841
|
+
const srvId = newId("srvtoolu_");
|
|
842
|
+
push({
|
|
843
|
+
type: "server_tool_use",
|
|
844
|
+
id: srvId,
|
|
845
|
+
name: String(fetchTool.name || "web_fetch"),
|
|
846
|
+
input: { url },
|
|
847
|
+
});
|
|
848
|
+
let errorCode = "";
|
|
849
|
+
let doc: FetchedDocument | null = null;
|
|
850
|
+
if (fetches >= maxFetches) {
|
|
851
|
+
errorCode = "max_uses_exceeded";
|
|
852
|
+
} else {
|
|
853
|
+
fetches++; // failed fetches count against the limit, as in the real tool
|
|
854
|
+
errorCode = checkFetchUrl(url);
|
|
855
|
+
if (!errorCode) {
|
|
856
|
+
doc = await fetchDoc(url, fetchMaxChars).catch(
|
|
857
|
+
() => ({ ok: false, errorCode: "unavailable" }) as FetchedDocument
|
|
858
|
+
);
|
|
859
|
+
if (!doc.ok) errorCode = (doc as { errorCode: string }).errorCode;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
if (doc?.ok) {
|
|
863
|
+
const docBlock: JsonRecord = doc.pdfBase64
|
|
864
|
+
? {
|
|
865
|
+
type: "document",
|
|
866
|
+
source: { type: "base64", media_type: "application/pdf", data: doc.pdfBase64 },
|
|
867
|
+
}
|
|
868
|
+
: {
|
|
869
|
+
type: "document",
|
|
870
|
+
source: { type: "text", media_type: "text/plain", data: doc.text || "" },
|
|
871
|
+
...(doc.title ? { title: doc.title } : {}),
|
|
872
|
+
};
|
|
873
|
+
if (fetchCitations) docBlock.citations = { enabled: true };
|
|
874
|
+
push({
|
|
875
|
+
type: "web_fetch_tool_result",
|
|
876
|
+
tool_use_id: srvId,
|
|
877
|
+
content: {
|
|
878
|
+
type: "web_fetch_result",
|
|
879
|
+
url: doc.url,
|
|
880
|
+
content: docBlock,
|
|
881
|
+
retrieved_at: new Date().toISOString(),
|
|
882
|
+
},
|
|
883
|
+
});
|
|
884
|
+
results.push({
|
|
885
|
+
type: "tool_result",
|
|
886
|
+
tool_use_id: block.id,
|
|
887
|
+
content: [
|
|
888
|
+
{ type: "text", text: `Fetched ${doc.url}${doc.title ? ` (${doc.title})` : ""}:` },
|
|
889
|
+
docBlock,
|
|
890
|
+
],
|
|
891
|
+
});
|
|
892
|
+
// Links on a fetched page can be fetched next, as in the real tool.
|
|
893
|
+
fetchableUrls.add(normalizeUrl(doc.url));
|
|
894
|
+
if (doc.text && ruleAllows(urlSources.server, "web_fetch")) {
|
|
895
|
+
urlsIn(doc.text, fetchableUrls);
|
|
896
|
+
}
|
|
897
|
+
} else {
|
|
898
|
+
push({
|
|
899
|
+
type: "web_fetch_tool_result",
|
|
900
|
+
tool_use_id: srvId,
|
|
901
|
+
content: { type: "web_fetch_tool_result_error", error_code: errorCode },
|
|
902
|
+
});
|
|
903
|
+
results.push({
|
|
904
|
+
type: "tool_result",
|
|
905
|
+
tool_use_id: block.id,
|
|
906
|
+
is_error: true,
|
|
907
|
+
content:
|
|
908
|
+
errorCode === "url_not_in_prior_context"
|
|
909
|
+
? "This URL cannot be fetched: only URLs that appeared earlier in the conversation (from the user, a tool result or a web search) can be. Search for it first or ask the user for it."
|
|
910
|
+
: errorCode === "max_uses_exceeded"
|
|
911
|
+
? "The fetch limit for this request is reached. Answer now with what you have."
|
|
912
|
+
: `The page could not be fetched (${errorCode}).`,
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
const query = String((block.input as JsonRecord | undefined)?.query || "").trim();
|
|
918
|
+
const srvId = newId("srvtoolu_");
|
|
919
|
+
push({
|
|
920
|
+
type: "server_tool_use",
|
|
921
|
+
id: srvId,
|
|
922
|
+
name: String(searchTool?.name || "web_search"),
|
|
923
|
+
input: { query },
|
|
924
|
+
});
|
|
925
|
+
let items: WebSearchResultItem[] | null = null;
|
|
926
|
+
let errorCode = "";
|
|
927
|
+
if (searches >= maxUses) {
|
|
928
|
+
errorCode = "max_uses_exceeded";
|
|
929
|
+
} else if (!query) {
|
|
930
|
+
errorCode = "invalid_tool_input";
|
|
931
|
+
} else {
|
|
932
|
+
searches++;
|
|
933
|
+
const pre = prefetched?.get(String(block.id));
|
|
934
|
+
const got =
|
|
935
|
+
pre !== undefined ? pre : await search(query, searchOptions).catch((e) => e as Error);
|
|
936
|
+
if (got instanceof Error) errorCode = "unavailable";
|
|
937
|
+
else items = got;
|
|
938
|
+
}
|
|
939
|
+
// Search results can be fetched next (combined search + fetch).
|
|
940
|
+
if (items && ruleAllows(urlSources.server, "web_search")) {
|
|
941
|
+
for (const it of items) fetchableUrls.add(normalizeUrl(it.url));
|
|
942
|
+
}
|
|
943
|
+
push({
|
|
944
|
+
type: "web_search_tool_result",
|
|
945
|
+
tool_use_id: srvId,
|
|
946
|
+
content: items
|
|
947
|
+
? items.map((it) => ({
|
|
948
|
+
type: "web_search_result",
|
|
949
|
+
title: it.title,
|
|
950
|
+
url: it.url,
|
|
951
|
+
encrypted_content: encodeWebSearchContent(it),
|
|
952
|
+
page_age: it.pageAge || null,
|
|
953
|
+
}))
|
|
954
|
+
: { type: "web_search_tool_result_error", error_code: errorCode },
|
|
955
|
+
});
|
|
956
|
+
results.push({
|
|
957
|
+
type: "tool_result",
|
|
958
|
+
tool_use_id: block.id,
|
|
959
|
+
content: items
|
|
960
|
+
? formatWebSearchResultsForModel(query, items)
|
|
961
|
+
: errorCode === "max_uses_exceeded"
|
|
962
|
+
? "The search limit for this request is reached. Answer now with what you have."
|
|
963
|
+
: "The web search is not available right now. Answer from what you know and say that you could not search.",
|
|
964
|
+
...(items ? {} : { is_error: true }),
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
prefetched = null;
|
|
968
|
+
const done = calls.length === 0 || clientCall || stopped();
|
|
969
|
+
if (done) {
|
|
970
|
+
emit.finish({
|
|
971
|
+
...msg,
|
|
972
|
+
usage: { ...total, server_tool_use: serverToolUsage() },
|
|
973
|
+
});
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
// Next turn: the model's own blocks (thinking keeps its signature) + the results.
|
|
977
|
+
messages.push({ role: "assistant", content }, { role: "user", content: results });
|
|
978
|
+
if (searches >= maxUses) withSearch = false;
|
|
979
|
+
if (fetches >= maxFetches) withFetch = false;
|
|
980
|
+
const res = await callModel(turnBody(withSearch, withFetch, false));
|
|
981
|
+
if (!res.ok) {
|
|
982
|
+
const text = await res.text().catch(() => "");
|
|
983
|
+
let message = `The model request failed (HTTP ${res.status})`;
|
|
984
|
+
try {
|
|
985
|
+
const parsed = JSON.parse(text);
|
|
986
|
+
message = String(parsed?.error?.message || parsed?.message || message);
|
|
987
|
+
} catch {}
|
|
988
|
+
emit.fail(message);
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
current = (await res.json().catch(() => null)) as JsonRecord | null;
|
|
992
|
+
if (!current || !Array.isArray(current.content)) {
|
|
993
|
+
emit.fail("The model answered in an unexpected format");
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
emit.finish({
|
|
998
|
+
...(current as JsonRecord),
|
|
999
|
+
usage: { ...total, server_tool_use: serverToolUsage() },
|
|
1000
|
+
});
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
if (!wantStream) {
|
|
1004
|
+
const blocks: JsonRecord[] = [];
|
|
1005
|
+
const result: { final: JsonRecord | null; failure: string } = { final: null, failure: "" };
|
|
1006
|
+
await run({
|
|
1007
|
+
start() {},
|
|
1008
|
+
block: (b) => blocks.push(b),
|
|
1009
|
+
ping() {},
|
|
1010
|
+
finish: (m) => {
|
|
1011
|
+
result.final = m;
|
|
1012
|
+
},
|
|
1013
|
+
fail: (m) => {
|
|
1014
|
+
result.failure = m;
|
|
1015
|
+
},
|
|
1016
|
+
});
|
|
1017
|
+
if (result.failure || !result.final) {
|
|
1018
|
+
return new Response(
|
|
1019
|
+
JSON.stringify({
|
|
1020
|
+
type: "error",
|
|
1021
|
+
error: { type: "api_error", message: result.failure || "Web search failed" },
|
|
1022
|
+
}),
|
|
1023
|
+
{ status: 502, headers: { "content-type": "application/json" } }
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
const f = result.final;
|
|
1027
|
+
return new Response(
|
|
1028
|
+
JSON.stringify({
|
|
1029
|
+
id: f.id,
|
|
1030
|
+
type: "message",
|
|
1031
|
+
role: "assistant",
|
|
1032
|
+
model: f.model,
|
|
1033
|
+
content: blocks,
|
|
1034
|
+
stop_reason: f.stop_reason ?? "end_turn",
|
|
1035
|
+
stop_sequence: f.stop_sequence ?? null,
|
|
1036
|
+
stop_details: f.stop_details ?? null,
|
|
1037
|
+
usage: f.usage,
|
|
1038
|
+
}),
|
|
1039
|
+
{ status: 200, headers: { "content-type": "application/json" } }
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
const encoder = new TextEncoder();
|
|
1044
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
1045
|
+
async start(controller) {
|
|
1046
|
+
let closed = false;
|
|
1047
|
+
const send = (event: string, data: JsonRecord) => {
|
|
1048
|
+
if (closed) return;
|
|
1049
|
+
try {
|
|
1050
|
+
controller.enqueue(encoder.encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`));
|
|
1051
|
+
} catch {
|
|
1052
|
+
closed = true;
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
let index = 0;
|
|
1056
|
+
const pinger = setInterval(() => send("ping", { type: "ping" }), PING_INTERVAL_MS);
|
|
1057
|
+
const chunks = (text: string, size: number) =>
|
|
1058
|
+
text.match(new RegExp(`[\\s\\S]{1,${size}}`, "g")) || [];
|
|
1059
|
+
const emit: Emitter = {
|
|
1060
|
+
start(m) {
|
|
1061
|
+
send("message_start", {
|
|
1062
|
+
type: "message_start",
|
|
1063
|
+
message: {
|
|
1064
|
+
id: m.id,
|
|
1065
|
+
type: "message",
|
|
1066
|
+
role: "assistant",
|
|
1067
|
+
model: m.model,
|
|
1068
|
+
content: [],
|
|
1069
|
+
stop_reason: null,
|
|
1070
|
+
stop_sequence: null,
|
|
1071
|
+
usage: {
|
|
1072
|
+
input_tokens: (m.usage as JsonRecord | undefined)?.input_tokens ?? 0,
|
|
1073
|
+
output_tokens: 0,
|
|
1074
|
+
cache_creation_input_tokens: 0,
|
|
1075
|
+
cache_read_input_tokens: 0,
|
|
1076
|
+
},
|
|
1077
|
+
},
|
|
1078
|
+
});
|
|
1079
|
+
},
|
|
1080
|
+
block(b) {
|
|
1081
|
+
const i = index++;
|
|
1082
|
+
if (b.type === "text") {
|
|
1083
|
+
send("content_block_start", {
|
|
1084
|
+
type: "content_block_start",
|
|
1085
|
+
index: i,
|
|
1086
|
+
content_block: { type: "text", text: "" },
|
|
1087
|
+
});
|
|
1088
|
+
for (const piece of chunks(String(b.text || ""), 200)) {
|
|
1089
|
+
send("content_block_delta", {
|
|
1090
|
+
type: "content_block_delta",
|
|
1091
|
+
index: i,
|
|
1092
|
+
delta: { type: "text_delta", text: piece },
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
} else if (b.type === "thinking") {
|
|
1096
|
+
send("content_block_start", {
|
|
1097
|
+
type: "content_block_start",
|
|
1098
|
+
index: i,
|
|
1099
|
+
content_block: { type: "thinking", thinking: "" },
|
|
1100
|
+
});
|
|
1101
|
+
for (const piece of chunks(String(b.thinking || ""), 400)) {
|
|
1102
|
+
send("content_block_delta", {
|
|
1103
|
+
type: "content_block_delta",
|
|
1104
|
+
index: i,
|
|
1105
|
+
delta: { type: "thinking_delta", thinking: piece },
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
if (typeof b.signature === "string" && b.signature) {
|
|
1109
|
+
send("content_block_delta", {
|
|
1110
|
+
type: "content_block_delta",
|
|
1111
|
+
index: i,
|
|
1112
|
+
delta: { type: "signature_delta", signature: b.signature },
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
} else if (b.type === "tool_use" || b.type === "server_tool_use") {
|
|
1116
|
+
send("content_block_start", {
|
|
1117
|
+
type: "content_block_start",
|
|
1118
|
+
index: i,
|
|
1119
|
+
content_block: { type: b.type, id: b.id, name: b.name, input: {} },
|
|
1120
|
+
});
|
|
1121
|
+
send("content_block_delta", {
|
|
1122
|
+
type: "content_block_delta",
|
|
1123
|
+
index: i,
|
|
1124
|
+
delta: { type: "input_json_delta", partial_json: JSON.stringify(b.input ?? {}) },
|
|
1125
|
+
});
|
|
1126
|
+
} else {
|
|
1127
|
+
send("content_block_start", {
|
|
1128
|
+
type: "content_block_start",
|
|
1129
|
+
index: i,
|
|
1130
|
+
content_block: b,
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
send("content_block_stop", { type: "content_block_stop", index: i });
|
|
1134
|
+
},
|
|
1135
|
+
ping() {
|
|
1136
|
+
send("ping", { type: "ping" });
|
|
1137
|
+
},
|
|
1138
|
+
finish(m) {
|
|
1139
|
+
send("message_delta", {
|
|
1140
|
+
type: "message_delta",
|
|
1141
|
+
delta: {
|
|
1142
|
+
stop_reason: m.stop_reason ?? "end_turn",
|
|
1143
|
+
stop_sequence: m.stop_sequence ?? null,
|
|
1144
|
+
stop_details: m.stop_details ?? null,
|
|
1145
|
+
},
|
|
1146
|
+
usage: m.usage,
|
|
1147
|
+
});
|
|
1148
|
+
send("message_stop", { type: "message_stop" });
|
|
1149
|
+
},
|
|
1150
|
+
fail(message) {
|
|
1151
|
+
send("error", { type: "error", error: { type: "api_error", message } });
|
|
1152
|
+
},
|
|
1153
|
+
};
|
|
1154
|
+
try {
|
|
1155
|
+
await run(emit);
|
|
1156
|
+
} catch (error) {
|
|
1157
|
+
emit.fail(error instanceof Error ? error.message : "Web search failed");
|
|
1158
|
+
} finally {
|
|
1159
|
+
clearInterval(pinger);
|
|
1160
|
+
if (!closed && !cancelled) {
|
|
1161
|
+
closed = true;
|
|
1162
|
+
try {
|
|
1163
|
+
controller.close();
|
|
1164
|
+
} catch {}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
},
|
|
1168
|
+
cancel() {
|
|
1169
|
+
// The client went away: no further model turns or searches.
|
|
1170
|
+
cancelled = true;
|
|
1171
|
+
},
|
|
1172
|
+
});
|
|
1173
|
+
return new Response(stream, {
|
|
1174
|
+
status: 200,
|
|
1175
|
+
headers: {
|
|
1176
|
+
"content-type": "text/event-stream",
|
|
1177
|
+
"cache-control": "no-cache",
|
|
1178
|
+
connection: "keep-alive",
|
|
1179
|
+
},
|
|
1180
|
+
});
|
|
1181
|
+
}
|