@circuitwall/jarela 2.7.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +2 -1
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/routes-manifest.json +6 -0
- package/.next/standalone/.next/server/app/_global-error/page.js +68 -68
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js +58 -58
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +2 -2
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/v1/access/[identity]/route.js +127 -127
- package/.next/standalone/.next/server/app/api/v1/access/route.js +372 -372
- package/.next/standalone/.next/server/app/api/v1/agents/[id]/compact/route.js +79 -79
- package/.next/standalone/.next/server/app/api/v1/agents/[id]/display-filters/route.js +641 -641
- package/.next/standalone/.next/server/app/api/v1/agents/[id]/duplicate/route.js +723 -723
- package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js +100 -100
- package/.next/standalone/.next/server/app/api/v1/agents/[id]/thread/route.js +65 -65
- package/.next/standalone/.next/server/app/api/v1/agents/recent-replies/route.js +227 -227
- package/.next/standalone/.next/server/app/api/v1/agents/route.js +16 -16
- package/.next/standalone/.next/server/app/api/v1/allowed-sites/[hostname]/route.js +384 -384
- package/.next/standalone/.next/server/app/api/v1/allowed-sites/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/artifacts/lifecycle/route.js +23 -23
- package/.next/standalone/.next/server/app/api/v1/attachments/files/route.js +203 -203
- package/.next/standalone/.next/server/app/api/v1/attachments/images/route.js +17 -17
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +2 -2
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/[remote_jid]/route.js +760 -760
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/ignores/route.js +699 -699
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +30 -30
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +37 -37
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +480 -480
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/[route_id]/route.js +675 -675
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/routes/route.js +559 -559
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +23 -23
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/kinds/route.js +37 -37
- package/.next/standalone/.next/server/app/api/v1/bridges/route.js +1269 -1269
- package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +199 -199
- package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/config/route.js +99 -99
- package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js +23 -23
- package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/credentials/route.js +169 -169
- package/.next/standalone/.next/server/app/api/v1/credentials/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/dashboard/currency/route.js +515 -515
- package/.next/standalone/.next/server/app/api/v1/dashboard/metrics/route.js +380 -380
- package/.next/standalone/.next/server/app/api/v1/dashboard/metrics/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/dashboard/pricing/route.js +256 -256
- package/.next/standalone/.next/server/app/api/v1/dashboard/pricing/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js +80 -97
- package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js +677 -677
- package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/recall-policy/route.js +856 -0
- package/.next/standalone/.next/server/app/api/v1/documents/recall-policy/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/v1/documents/recall-policy/route_client-reference-manifest.js +1 -0
- package/.next/standalone/.next/server/app/api/v1/documents/search/route.js +299 -247
- package/.next/standalone/.next/server/app/api/v1/documents/settings/route.js +486 -486
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js +18 -11
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js +666 -666
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js +128 -100
- package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/env/route.js +207 -207
- package/.next/standalone/.next/server/app/api/v1/env-sync/allowlist/route.js +128 -128
- package/.next/standalone/.next/server/app/api/v1/env-sync/route.js +16 -16
- package/.next/standalone/.next/server/app/api/v1/events/route.js +154 -154
- package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/events/test/route.js +16 -16
- package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +97 -97
- package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/browser/activate/route.js +188 -188
- package/.next/standalone/.next/server/app/api/v1/extension/browser/foreground/route.js +93 -93
- package/.next/standalone/.next/server/app/api/v1/extension/browser/history/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/extension/browser/poll/route.js +93 -93
- package/.next/standalone/.next/server/app/api/v1/extension/browser/progress/route.js +69 -69
- package/.next/standalone/.next/server/app/api/v1/extension/browser/result/route.js +69 -69
- package/.next/standalone/.next/server/app/api/v1/extension/browser/retry/route.js +65 -65
- package/.next/standalone/.next/server/app/api/v1/extension/browser/status/route.js +223 -223
- package/.next/standalone/.next/server/app/api/v1/extension/browser/tabs/route.js +44 -44
- package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +93 -93
- package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +44 -44
- package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +16 -16
- package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/route.js +722 -722
- package/.next/standalone/.next/server/app/api/v1/extensions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js +481 -481
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js +378 -378
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +510 -510
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/files/[name]/route.js +17 -17
- package/.next/standalone/.next/server/app/api/v1/fs/browse/route.js +33 -33
- package/.next/standalone/.next/server/app/api/v1/harnesses/[id]/route.js +397 -397
- package/.next/standalone/.next/server/app/api/v1/harnesses/default/route.js +129 -129
- package/.next/standalone/.next/server/app/api/v1/harnesses/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/health/probes/route.js +757 -757
- package/.next/standalone/.next/server/app/api/v1/health/probes/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/health/route.js +228 -228
- package/.next/standalone/.next/server/app/api/v1/integrations/[name]/route.js +37 -37
- package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js +198 -198
- package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +845 -845
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +23 -23
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +106 -106
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +747 -747
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +37 -37
- package/.next/standalone/.next/server/app/api/v1/integrations/route.js +37 -37
- package/.next/standalone/.next/server/app/api/v1/lifecycle/adoption/route.js +420 -420
- package/.next/standalone/.next/server/app/api/v1/local-file/route.js +34 -34
- package/.next/standalone/.next/server/app/api/v1/logs/route.js +819 -819
- package/.next/standalone/.next/server/app/api/v1/maps/embed/route.js +217 -217
- package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js +1034 -1034
- package/.next/standalone/.next/server/app/api/v1/mcp-servers/registry/route.js +2 -2
- package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js +58 -58
- package/.next/standalone/.next/server/app/api/v1/memory/[namespace]/[key]/route.js +150 -150
- package/.next/standalone/.next/server/app/api/v1/memory/policy/route.js +72 -72
- package/.next/standalone/.next/server/app/api/v1/memory/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/memory/search/route.js +16 -16
- package/.next/standalone/.next/server/app/api/v1/models/[name]/compact-threads/route.js +72 -72
- package/.next/standalone/.next/server/app/api/v1/models/[name]/route.js +87 -538
- package/.next/standalone/.next/server/app/api/v1/models/[name]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/models/route.js +273 -722
- package/.next/standalone/.next/server/app/api/v1/models/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/catalog/route.js +73 -73
- package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js +248 -239
- package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js +128 -128
- package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/install/route.js +44 -44
- package/.next/standalone/.next/server/app/api/v1/packages/install/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js +72 -72
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js +37 -37
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js +81 -81
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js +34 -25
- package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/route.js +48 -39
- package/.next/standalone/.next/server/app/api/v1/packages/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +51 -51
- package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +863 -863
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js +230 -230
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js +44 -44
- package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/profile/location/route.js +138 -138
- package/.next/standalone/.next/server/app/api/v1/profile/route.js +51 -51
- package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js +853 -680
- package/.next/standalone/.next/server/app/api/v1/providers/[provider]/probe/route.js +65 -65
- package/.next/standalone/.next/server/app/api/v1/providers/github-copilot/auth/route.js +171 -171
- package/.next/standalone/.next/server/app/api/v1/providers/route.js +96 -96
- package/.next/standalone/.next/server/app/api/v1/proxy-config/route.js +157 -157
- package/.next/standalone/.next/server/app/api/v1/redaction/init/route.js +47 -47
- package/.next/standalone/.next/server/app/api/v1/redaction/route.js +206 -206
- package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/route.js +140 -140
- package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js +166 -166
- package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/route.js +52 -52
- package/.next/standalone/.next/server/app/api/v1/security/idle-timeout/route.js +722 -722
- package/.next/standalone/.next/server/app/api/v1/security/pin/route.js +23 -23
- package/.next/standalone/.next/server/app/api/v1/security/state/route.js +243 -243
- package/.next/standalone/.next/server/app/api/v1/security/unlock/route.js +518 -518
- package/.next/standalone/.next/server/app/api/v1/security/verify-pin/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/setup/test-key/route.js +25 -25
- package/.next/standalone/.next/server/app/api/v1/skills/[id]/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/skills/repos/[id]/route.js +609 -609
- package/.next/standalone/.next/server/app/api/v1/skills/repos/route.js +129 -129
- package/.next/standalone/.next/server/app/api/v1/skills/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/system/abort/route.js +112 -112
- package/.next/standalone/.next/server/app/api/v1/system/restart/route.js +86 -86
- package/.next/standalone/.next/server/app/api/v1/system/restart/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/tailscale/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/tasks/[agent_id]/route.js +83 -83
- package/.next/standalone/.next/server/app/api/v1/tasks/route.js +23 -23
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/activity/route.js +121 -121
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/context-pin/route.js +139 -139
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/messages/[message_id]/route.js +51 -51
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js +58 -58
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +1182 -1182
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/threads/route.js +158 -158
- package/.next/standalone/.next/server/app/api/v1/tools/route.js +137 -137
- package/.next/standalone/.next/server/app/api/v1/tools/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/update/apply/route.js +73 -73
- package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/update/route.js +72 -72
- package/.next/standalone/.next/server/app/api/v1/voice/transcribe/route.js +30 -30
- package/.next/standalone/.next/server/app/api/v1/voice/tts/route.js +79 -79
- package/.next/standalone/.next/server/app/api/v1/watchers/[id]/route.js +9 -9
- package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js +45 -45
- package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/reaction-scripts/route.js +2 -2
- package/.next/standalone/.next/server/app/api/v1/watchers/route.js +37 -37
- package/.next/standalone/.next/server/app/api/v1/watchers/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/icon.svg/route.js +55 -55
- package/.next/standalone/.next/server/app/manifest.webmanifest/route.js +18 -18
- package/.next/standalone/.next/server/app/page.js +2112 -1235
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/setup/page.js +91 -91
- package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +2 -1
- package/.next/standalone/.next/server/chunks/1244.js +136 -4
- package/.next/standalone/.next/server/chunks/1387.js +733 -57
- package/.next/standalone/.next/server/chunks/1433.js +1 -1
- package/.next/standalone/.next/server/chunks/210.js +3 -3
- package/.next/standalone/.next/server/chunks/2175.js +874 -0
- package/.next/standalone/.next/server/chunks/3042.js +34 -32
- package/.next/standalone/.next/server/chunks/309.js +21 -40
- package/.next/standalone/.next/server/chunks/3272.js +21 -40
- package/.next/standalone/.next/server/chunks/{540.js → 3326.js} +189 -61
- package/.next/standalone/.next/server/chunks/{6142.js → 3479.js} +170 -159
- package/.next/standalone/.next/server/chunks/3566.js +1 -1
- package/.next/standalone/.next/server/chunks/{5323.js → 3692.js} +31 -3
- package/.next/standalone/.next/server/chunks/4189.js +14 -2
- package/.next/standalone/.next/server/chunks/4377.js +2 -2
- package/.next/standalone/.next/server/chunks/4596.js +18 -9
- package/.next/standalone/.next/server/chunks/{639.js → 4728.js} +23676 -22755
- package/.next/standalone/.next/server/chunks/4955.js +81 -14
- package/.next/standalone/.next/server/chunks/5290.js +136 -5
- package/.next/standalone/.next/server/chunks/{2267.js → 6408.js} +990 -926
- package/.next/standalone/.next/server/chunks/{9667.js → 6911.js} +31 -3
- package/.next/standalone/.next/server/chunks/7033.js +7 -4
- package/.next/standalone/.next/server/chunks/7377.js +7 -4
- package/.next/standalone/.next/server/chunks/8461.js +31 -29
- package/.next/standalone/.next/server/chunks/9032.js +3 -3
- package/.next/standalone/.next/server/chunks/9174.js +18 -9
- package/.next/standalone/.next/server/chunks/9408.js +37 -15
- package/.next/standalone/.next/server/chunks/9824.js +2288 -2288
- package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
- package/.next/standalone/.next/server/middleware.js +104638 -104532
- package/.next/standalone/.next/server/pages/404.html +2 -2
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/preview-props.json +3 -3
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/2BAUJZ7x8eXCYpuZ-Kp7h/_buildManifest.js +1 -0
- package/.next/standalone/.next/static/chunks/{877-145c9df8aa0aee63.js → 877-367eb49b20edd3d6.js} +38 -16
- package/.next/standalone/.next/static/chunks/app/_global-error/page-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/access/[identity]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/access/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/compact/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/display-filters/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/duplicate/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/thread/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/recent-replies/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/[hostname]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/artifacts/lifecycle/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/attachments/files/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/attachments/images/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/chats/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/[remote_jid]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/lookup/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/pair/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/[route_id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/status/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/kinds/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/builtin-tools/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/config/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/credentials/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/credentials/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/currency/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/metrics/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing-task/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/delegations/codex/[job_id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/recall-policy/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/search/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/settings/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/reindex/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/env/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/allowlist/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/events/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/events/test/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/agents/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/activate/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/foreground/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/history/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/poll/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/progress/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/result/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/retry/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/status/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/tabs/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/fill/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/refine/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/turn/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extensions/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/config/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/secrets/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/files/[name]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/fs/browse/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/default/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/health/probes/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/health/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/test/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/callback/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/start/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/status/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/callback/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/start/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/status/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/lifecycle/adoption/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/local-file/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/logs/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/maps/embed/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/[name]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/registry/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/memory/[namespace]/[key]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/memory/policy/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/memory/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/memory/search/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/compact-threads/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/models/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/catalog/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/defaults/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/enabled/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/reload/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/page-capture/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/approve/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/deny/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/profile/location/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/profile/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/models/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/probe/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/providers/github-copilot/auth/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/providers/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/proxy-config/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/redaction/init/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/redaction/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/run/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/security/idle-timeout/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/security/pin/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/security/state/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/security/unlock/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/security/verify-pin/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/setup/test-key/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/skills/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/skills/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/system/abort/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/system/restart/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/tailscale/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/tasks/[agent_id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/tasks/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/activity/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/context-pin/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/messages/[message_id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/run/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/tools/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/update/apply/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/update/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/voice/transcribe/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/voice/tts/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/run/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/watchers/reaction-scripts/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/api/v1/watchers/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/manifest.webmanifest/route-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/app/{page-64585ef79400f17f.js → page-a584dfa806a1afdb.js} +1082 -205
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-6cda89771c3f8ea4.js +17 -0
- package/.next/standalone/.next/static/css/19e1cd815490b47c.css +5 -0
- package/.next/standalone/docs/adoption/changesets.json +148 -0
- package/.next/standalone/package.json +5 -4
- package/CHANGELOG.md +51 -0
- package/README.md +115 -1
- package/api/client.startup.test.ts +29 -0
- package/api/client.ts +9 -2
- package/api/types.ts +20 -1
- package/app/api/v1/dashboard/pricing-task/route.ts +3 -1
- package/app/api/v1/documents/recall-policy/route.test.ts +59 -0
- package/app/api/v1/documents/recall-policy/route.ts +20 -0
- package/app/api/v1/documents/search/route.test.ts +36 -0
- package/app/api/v1/documents/search/route.ts +17 -5
- package/app/api/v1/documents/sources/[id]/reindex/route.test.ts +44 -0
- package/app/api/v1/documents/sources/[id]/reindex/route.ts +4 -1
- package/app/api/v1/documents/sources/route.test.ts +67 -0
- package/app/api/v1/documents/sources/route.ts +20 -2
- package/app/api/v1/models/[name]/route.ts +2 -0
- package/app/api/v1/models/route.ts +4 -0
- package/app/api/v1/providers/[provider]/models/route.test.ts +28 -0
- package/app/api/v1/providers/[provider]/models/route.ts +16 -2
- package/app/globals.css +51 -4
- package/components/agents/AgentsPanel.tsx +2 -2
- package/components/agents/agent-editor/AdvancedSection.tsx +1 -1
- package/components/agents/agent-editor/ModelSection.tsx +2 -2
- package/components/bridges/BridgeEditor.tsx +1 -1
- package/components/bridges/BridgesPanel.tsx +1 -1
- package/components/chat/InputBar.tsx +1 -1
- package/components/chat/MessageList.tsx +3 -3
- package/components/chat/useUserProfileAndAgent.test.tsx +43 -1
- package/components/chat/useUserProfileAndAgent.ts +16 -5
- package/components/credentials/CredentialsPanel.tsx +1 -1
- package/components/dashboard/CostBreakdown.test.tsx +34 -0
- package/components/dashboard/CostBreakdown.tsx +21 -0
- package/components/dashboard/DashboardPanel.test.tsx +9 -0
- package/components/dashboard/DashboardPanel.tsx +3 -3
- package/components/dashboard/Donuts.tsx +5 -2
- package/components/dashboard/ModelPricingSection.test.tsx +42 -0
- package/components/dashboard/ModelPricingSection.tsx +23 -21
- package/components/dashboard/Series.test.tsx +1 -0
- package/components/dashboard/Series.tsx +5 -0
- package/components/dashboard/SummaryCards.tsx +39 -27
- package/components/dashboard/VendorModelReportSection.tsx +2 -0
- package/components/documents/AddSourceFields.tsx +52 -15
- package/components/documents/AddSourceForm.tsx +61 -19
- package/components/documents/DocumentsPanel.tsx +22 -2
- package/components/documents/RecallExclusions.tsx +73 -0
- package/components/documents/SearchProbe.tsx +42 -5
- package/components/documents/helpers.ts +17 -3
- package/components/documents/indexing-controls.test.tsx +137 -0
- package/components/documents/useDocumentsPanel.test.tsx +87 -0
- package/components/documents/useDocumentsPanel.ts +47 -6
- package/components/env/EnvVarsPanel.tsx +1 -1
- package/components/harness/HarnessPanel.tsx +2 -2
- package/components/integrations/NetworkPanel.tsx +1 -1
- package/components/layout/AgentCardControls.test.tsx +162 -0
- package/components/layout/AgentCardControls.tsx +126 -0
- package/components/layout/AgentSwitcher.test.tsx +37 -0
- package/components/layout/AgentSwitcher.tsx +28 -3
- package/components/layout/AppShell.tsx +16 -9
- package/components/layout/MenuPanel.test.tsx +125 -2
- package/components/layout/MenuPanel.tsx +96 -2
- package/components/logs/LogsPanel.tsx +1 -1
- package/components/mcp/MCPPanel.tsx +1 -1
- package/components/memory/UnifiedMemoryPanel.tsx +4 -4
- package/components/models/CapBadges.tsx +1 -1
- package/components/models/EmbeddingModelSection.test.tsx +41 -0
- package/components/models/EmbeddingModelSection.tsx +5 -0
- package/components/models/ModelFeatureGuide.tsx +16 -8
- package/components/models/ModelsPanel.tsx +8 -3
- package/components/models/model-editor/ModelEditorBody.tsx +1 -0
- package/components/models/model-editor/ModelIdSection.tsx +5 -0
- package/components/profile/ProfileEditor.test.tsx +70 -0
- package/components/profile/ProfileEditor.tsx +6 -2
- package/components/profile/ProfilePanel.test.tsx +6 -0
- package/components/profile/ProfilePanel.tsx +1 -1
- package/components/scheduled-tasks/ScheduledTasksPanel.tsx +1 -1
- package/components/settings/AppearancePanel.tsx +1 -1
- package/components/settings/SettingsPanel.test.tsx +23 -0
- package/components/settings/SettingsPanel.tsx +2 -2
- package/components/skills/SkillsPanel.tsx +1 -1
- package/components/tools/BrowserPanel.tsx +1 -1
- package/components/tools/PackagesPanel.tsx +1 -1
- package/components/tools/UnifiedPackageList.tsx +1 -1
- package/components/ui/PanelHeader.tsx +1 -1
- package/components/ui/SubTabBar.tsx +1 -1
- package/docs/INSTALL.md +7 -5
- package/hooks/useAgents.ts +2 -2
- package/lib/agents/prepare/system-prompt.test.ts +65 -0
- package/lib/agents/prepare/system-prompt.ts +27 -20
- package/lib/agents/prompt-registry.test.ts +42 -0
- package/lib/agents/prompt-registry.ts +21 -0
- package/lib/bridges/whatsapp.inbound.test.ts +38 -1
- package/lib/bridges/whatsapp.ts +10 -33
- package/lib/db/index.ts +2 -0
- package/lib/db/migrations.test.ts +10 -0
- package/lib/db/migrations.ts +10 -0
- package/lib/db/statement-cache.test.ts +77 -0
- package/lib/db/statement-cache.ts +31 -0
- package/lib/documents/indexer.test.ts +16 -1
- package/lib/documents/indexer.ts +8 -7
- package/lib/documents/mail-source-config.ts +31 -0
- package/lib/documents/recall-policy.ts +24 -0
- package/lib/documents/remote/icloud.ts +56 -0
- package/lib/documents/remote/index.ts +4 -1
- package/lib/documents/remote/mail.test.ts +232 -0
- package/lib/documents/remote/mail.ts +48 -40
- package/lib/documents/search.test.ts +81 -2
- package/lib/documents/search.ts +47 -7
- package/lib/embeddings/cache.test.ts +16 -2
- package/lib/embeddings/index.test.ts +7 -0
- package/lib/embeddings/index.ts +12 -1
- package/lib/integrations/deepseek-web/manifest.ts +68 -0
- package/lib/integrations/gmail/manifest.ts +2 -3
- package/lib/integrations/icloud/manifest.ts +19 -5
- package/lib/integrations/registry.test.ts +8 -0
- package/lib/integrations/registry.ts +2 -0
- package/lib/lifecycle/changeset-build.test.ts +3 -0
- package/lib/lifecycle/changeset-build.ts +6 -0
- package/lib/lifecycle/changesets.ts +9 -0
- package/lib/pricing/llm-extract.ts +1 -1
- package/lib/pricing/maintenance-task.ts +19 -3
- package/lib/pricing/model-updates.test.ts +192 -0
- package/lib/pricing/model-updates.ts +205 -0
- package/lib/stores/app-settings.ts +17 -1
- package/lib/stores/dashboard-metrics-cache.test.ts +44 -0
- package/lib/stores/dashboard-metrics.test.ts +47 -4
- package/lib/stores/dashboard-metrics.ts +73 -8
- package/lib/stores/document-sources.ts +1 -0
- package/lib/stores/integrations.test.ts +20 -0
- package/lib/stores/integrations.ts +15 -4
- package/lib/stores/langgraph-store.test.ts +53 -0
- package/lib/stores/langgraph-store.ts +9 -21
- package/lib/stores/model-metadata.ts +89 -0
- package/lib/stores/threads.test.ts +34 -0
- package/lib/stores/threads.ts +17 -20
- package/lib/stores/tool-stats.test.ts +31 -0
- package/lib/stores/tool-stats.ts +16 -0
- package/lib/stores/version-adoption.test.ts +8 -0
- package/lib/stores/version-adoption.ts +5 -2
- package/lib/tools/general/documents.test.ts +5 -0
- package/lib/tools/general/pricing-maintenance.test.ts +5 -0
- package/lib/tools/general/pricing-maintenance.ts +4 -1
- package/lib/tools/packages/default-packages/icloud.test.ts +49 -0
- package/lib/tools/packages/default-packages/icloud.ts +8 -6
- package/lib/tools/packages/default-packages.test.ts +16 -0
- package/lib/tools/packages/langchain-packages.ts +2 -2
- package/lib/tools/runtime/category-filter.test.ts +22 -0
- package/lib/tools/web/deepseek.test.ts +76 -0
- package/lib/tools/web/deepseek.ts +68 -0
- package/lib/tools/web/fetch.test.ts +130 -2
- package/lib/tools/web/fetch.ts +48 -1
- package/lib/tools/web/search.test.ts +139 -2
- package/lib/tools/web/search.ts +48 -1
- package/lib/triggers/handlers/scheduled-task.test.ts +18 -0
- package/lib/triggers/handlers/scheduled-task.ts +6 -0
- package/lib/ui/feature-readiness.test.ts +7 -0
- package/lib/ui/feature-readiness.ts +2 -1
- package/package.json +5 -4
- package/scripts/check-npm-package.mjs +1 -0
- package/scripts/jarela-bin.mjs +3 -0
- package/scripts/runtime-version.mjs +19 -0
- package/scripts/start-prod.mjs +3 -0
- package/.next/standalone/.next/static/6qLnqWdsfBTJOAJApUYXy/_buildManifest.js +0 -1
- package/.next/standalone/.next/static/chunks/app/_global-error/page-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/access/[identity]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/access/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/compact/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/display-filters/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/duplicate/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/[id]/thread/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/recent-replies/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/agents/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/[hostname]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/allowed-sites/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/artifacts/lifecycle/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/attachments/files/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/attachments/images/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/chats/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/[remote_jid]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/ignores/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/lookup/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/pair/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/[route_id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/routes/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/[id]/status/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/kinds/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/bridges/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/builtin-tools/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/config/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/credentials/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/credentials/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/currency/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/metrics/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/dashboard/pricing-task/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/delegations/codex/[job_id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/search/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/settings/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/reindex/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/documents/sources/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/env/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/allowlist/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/env-sync/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/events/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/events/test/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/agents/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/activate/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/foreground/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/history/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/poll/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/progress/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/result/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/retry/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/status/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/browser/tabs/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/fill/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/refine/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extension/turn/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extensions/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/config/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/extensions/tools/[name]/secrets/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/files/[name]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/fs/browse/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/default/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/harnesses/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/health/probes/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/health/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/[name]/test/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/callback/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/start/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/gmail/oauth/status/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/callback/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/start/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/outlook/oauth/status/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/integrations/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/lifecycle/adoption/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/local-file/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/logs/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/maps/embed/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/[name]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/registry/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/mcp-servers/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/memory/[namespace]/[key]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/memory/policy/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/memory/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/memory/search/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/compact-threads/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/models/[name]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/models/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/catalog/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/defaults/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/install/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/enabled/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/[name]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/manifests/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/reload/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/packages/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/page-capture/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/approve/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/[id]/deny/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/pending-actions/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/profile/location/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/profile/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/models/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/providers/[provider]/probe/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/providers/github-copilot/auth/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/providers/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/proxy-config/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/redaction/init/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/redaction/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/[id]/run/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/scheduled-tasks/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/security/idle-timeout/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/security/pin/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/security/state/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/security/unlock/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/security/verify-pin/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/setup/test-key/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/skills/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/skills/repos/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/skills/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/system/abort/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/system/restart/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/tailscale/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/tasks/[agent_id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/tasks/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/activity/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/context-pin/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/messages/[message_id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/[thread_id]/run/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/threads/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/tools/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/update/apply/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/update/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/voice/transcribe/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/voice/tts/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/watchers/[id]/run/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/watchers/reaction-scripts/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/api/v1/watchers/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/app/manifest.webmanifest/route-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f6b126e5c5b11551.js +0 -17
- package/.next/standalone/.next/static/css/c4a8bed1da2c748f.css +0 -5
- /package/.next/standalone/.next/static/{6qLnqWdsfBTJOAJApUYXy → 2BAUJZ7x8eXCYpuZ-Kp7h}/_ssgManifest.js +0 -0
|
@@ -54,139 +54,50 @@ module.exports = require("next/dist/server/runtime-reacts.external.js");
|
|
|
54
54
|
|
|
55
55
|
/***/ }),
|
|
56
56
|
|
|
57
|
-
/***/
|
|
58
|
-
/***/ ((module) => {
|
|
59
|
-
|
|
60
|
-
module.exports = require("node:stream");
|
|
61
|
-
|
|
62
|
-
/***/ }),
|
|
63
|
-
|
|
64
|
-
/***/ 176760:
|
|
65
|
-
/***/ ((module) => {
|
|
66
|
-
|
|
67
|
-
module.exports = require("node:path");
|
|
68
|
-
|
|
69
|
-
/***/ }),
|
|
70
|
-
|
|
71
|
-
/***/ 200261:
|
|
72
|
-
/***/ ((module) => {
|
|
73
|
-
|
|
74
|
-
module.exports = require("next/dist/shared/lib/router/utils/app-paths");
|
|
75
|
-
|
|
76
|
-
/***/ }),
|
|
77
|
-
|
|
78
|
-
/***/ 257975:
|
|
79
|
-
/***/ ((module) => {
|
|
80
|
-
|
|
81
|
-
module.exports = require("node:util");
|
|
82
|
-
|
|
83
|
-
/***/ }),
|
|
84
|
-
|
|
85
|
-
/***/ 309956:
|
|
86
|
-
/***/ ((module) => {
|
|
87
|
-
|
|
88
|
-
module.exports = require("undici");
|
|
89
|
-
|
|
90
|
-
/***/ }),
|
|
91
|
-
|
|
92
|
-
/***/ 328354:
|
|
93
|
-
/***/ ((module) => {
|
|
94
|
-
|
|
95
|
-
module.exports = require("util");
|
|
96
|
-
|
|
97
|
-
/***/ }),
|
|
98
|
-
|
|
99
|
-
/***/ 333873:
|
|
100
|
-
/***/ ((module) => {
|
|
101
|
-
|
|
102
|
-
module.exports = require("path");
|
|
103
|
-
|
|
104
|
-
/***/ }),
|
|
105
|
-
|
|
106
|
-
/***/ 344708:
|
|
107
|
-
/***/ ((module) => {
|
|
108
|
-
|
|
109
|
-
module.exports = require("node:https");
|
|
110
|
-
|
|
111
|
-
/***/ }),
|
|
112
|
-
|
|
113
|
-
/***/ 358500:
|
|
114
|
-
/***/ ((module) => {
|
|
115
|
-
|
|
116
|
-
module.exports = require("node:timers/promises");
|
|
117
|
-
|
|
118
|
-
/***/ }),
|
|
119
|
-
|
|
120
|
-
/***/ 379551:
|
|
121
|
-
/***/ ((module) => {
|
|
122
|
-
|
|
123
|
-
module.exports = require("url");
|
|
124
|
-
|
|
125
|
-
/***/ }),
|
|
126
|
-
|
|
127
|
-
/***/ 380481:
|
|
128
|
-
/***/ ((module) => {
|
|
129
|
-
|
|
130
|
-
module.exports = require("node:readline");
|
|
131
|
-
|
|
132
|
-
/***/ }),
|
|
133
|
-
|
|
134
|
-
/***/ 399253:
|
|
135
|
-
/***/ ((module) => {
|
|
136
|
-
|
|
137
|
-
module.exports = import("@huggingface/transformers");;
|
|
138
|
-
|
|
139
|
-
/***/ }),
|
|
140
|
-
|
|
141
|
-
/***/ 419121:
|
|
142
|
-
/***/ ((module) => {
|
|
143
|
-
|
|
144
|
-
module.exports = require("next/dist/server/app-render/action-async-storage.external.js");
|
|
145
|
-
|
|
146
|
-
/***/ }),
|
|
147
|
-
|
|
148
|
-
/***/ 455511:
|
|
149
|
-
/***/ ((module) => {
|
|
150
|
-
|
|
151
|
-
module.exports = require("crypto");
|
|
152
|
-
|
|
153
|
-
/***/ }),
|
|
154
|
-
|
|
155
|
-
/***/ 498913:
|
|
57
|
+
/***/ 132582:
|
|
156
58
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
157
59
|
|
|
158
60
|
__webpack_require__.r(__webpack_exports__);
|
|
159
61
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
160
|
-
/* harmony export */
|
|
161
|
-
/* harmony export */
|
|
162
|
-
/* harmony export */
|
|
163
|
-
/* harmony export */
|
|
62
|
+
/* harmony export */ handler: () => (/* binding */ handler),
|
|
63
|
+
/* harmony export */ patchFetch: () => (/* binding */ patchFetch),
|
|
64
|
+
/* harmony export */ routeModule: () => (/* binding */ routeModule),
|
|
65
|
+
/* harmony export */ serverHooks: () => (/* binding */ serverHooks),
|
|
66
|
+
/* harmony export */ workAsyncStorage: () => (/* binding */ workAsyncStorage),
|
|
67
|
+
/* harmony export */ workUnitAsyncStorage: () => (/* binding */ workUnitAsyncStorage)
|
|
164
68
|
/* harmony export */ });
|
|
165
|
-
/* harmony import */ var
|
|
166
|
-
/* harmony import */ var
|
|
167
|
-
/* harmony import */ var
|
|
168
|
-
/* harmony import */ var
|
|
169
|
-
/* harmony import */ var
|
|
170
|
-
/* harmony import */ var
|
|
171
|
-
/* harmony import */ var
|
|
172
|
-
/* harmony import */ var
|
|
173
|
-
/* harmony import */ var
|
|
174
|
-
/* harmony import */ var
|
|
175
|
-
/* harmony import */ var
|
|
176
|
-
/* harmony import */ var
|
|
177
|
-
/* harmony import */ var
|
|
178
|
-
/* harmony import */ var
|
|
179
|
-
/* harmony import */ var
|
|
180
|
-
/* harmony import */ var
|
|
181
|
-
/* harmony import */ var
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
*/
|
|
69
|
+
/* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(319225);
|
|
70
|
+
/* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__);
|
|
71
|
+
/* harmony import */ var next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(684006);
|
|
72
|
+
/* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8317);
|
|
73
|
+
/* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__);
|
|
74
|
+
/* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(799373);
|
|
75
|
+
/* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__);
|
|
76
|
+
/* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(434775);
|
|
77
|
+
/* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__);
|
|
78
|
+
/* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(524235);
|
|
79
|
+
/* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__);
|
|
80
|
+
/* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(200261);
|
|
81
|
+
/* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__);
|
|
82
|
+
/* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(754365);
|
|
83
|
+
/* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__);
|
|
84
|
+
/* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(590771);
|
|
85
|
+
/* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__);
|
|
86
|
+
/* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(473461);
|
|
87
|
+
/* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__);
|
|
88
|
+
/* harmony import */ var next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(767798);
|
|
89
|
+
/* harmony import */ var next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(192280);
|
|
90
|
+
/* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(662018);
|
|
91
|
+
/* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__);
|
|
92
|
+
/* harmony import */ var next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(445696);
|
|
93
|
+
/* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(347929);
|
|
94
|
+
/* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__);
|
|
95
|
+
/* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(986439);
|
|
96
|
+
/* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__);
|
|
97
|
+
/* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(710246);
|
|
98
|
+
/* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__);
|
|
99
|
+
/* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(137527);
|
|
100
|
+
/* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__);
|
|
190
101
|
|
|
191
102
|
|
|
192
103
|
|
|
@@ -203,1163 +114,1252 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
203
114
|
|
|
204
115
|
|
|
205
116
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// We inject the nextConfigOutput here so that we can use them in the route
|
|
120
|
+
// module.
|
|
121
|
+
const nextConfigOutput = "standalone"
|
|
122
|
+
const routeModule = new next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__.AppRouteRouteModule({
|
|
123
|
+
definition: {
|
|
124
|
+
kind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
|
|
125
|
+
page: "/api/v1/threads/[thread_id]/run/route",
|
|
126
|
+
pathname: "/api/v1/threads/[thread_id]/run",
|
|
127
|
+
filename: "route",
|
|
128
|
+
bundlePath: "app/api/v1/threads/[thread_id]/run/route"
|
|
129
|
+
},
|
|
130
|
+
distDir: ".next" || 0,
|
|
131
|
+
relativeProjectDir: false || '',
|
|
132
|
+
resolvedPagePath: "/home/runner/work/jarela/jarela/app/api/v1/threads/[thread_id]/run/route.ts",
|
|
133
|
+
nextConfigOutput,
|
|
134
|
+
// The lazy require factory ensures that:
|
|
135
|
+
// - In dev: devRequestTimingInternalsEnd is set before userland executes,
|
|
136
|
+
// correctly attributing module load time to application-code rather than
|
|
137
|
+
// framework internals.
|
|
138
|
+
// - In all modes: async modules (route files with top-level await) are
|
|
139
|
+
// handled correctly — require() returns a Promise for such modules, which
|
|
140
|
+
// ensureUserland() awaits before the first request is handled.
|
|
141
|
+
userland: ()=>__webpack_require__(498913),
|
|
142
|
+
// In Turbopack dev mode, also provide a synchronous per-request getter so
|
|
143
|
+
// server HMR updates are picked up without re-executing the entry chunk.
|
|
144
|
+
// Using require() (synchronous) avoids adding async overhead that would be
|
|
145
|
+
// incorrectly attributed to application-code time in devRequestTiming.
|
|
146
|
+
... false ? 0 : {}
|
|
147
|
+
});
|
|
148
|
+
// Pull out the exports that we need to expose from the module. This should
|
|
149
|
+
// be eliminated when we've moved the other routes to the new format. These
|
|
150
|
+
// are used to hook into the route.
|
|
151
|
+
const { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;
|
|
152
|
+
function patchFetch() {
|
|
153
|
+
return (0,next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__.patchFetch)({
|
|
154
|
+
workAsyncStorage,
|
|
155
|
+
workUnitAsyncStorage
|
|
156
|
+
});
|
|
210
157
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return 0;
|
|
158
|
+
|
|
159
|
+
async function handler(req, res, ctx) {
|
|
160
|
+
if (ctx.requestMeta) {
|
|
161
|
+
(0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.setRequestMeta)(req, ctx.requestMeta);
|
|
216
162
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return (0,_lib_tools_support_result_refs__WEBPACK_IMPORTED_MODULE_11__/* .parseToolResultReferenceEnvelope */ .SE)(payload)?.bytes ?? 0;
|
|
220
|
-
}
|
|
221
|
-
function persistRunErrorMarker(thread_id, src) {
|
|
222
|
-
const raw = (src.errorMessage ?? "").trim();
|
|
223
|
-
const message = raw.length > 0 ? raw : "run failed";
|
|
224
|
-
// Cap the persisted body so a stack trace can't bloat the row.
|
|
225
|
-
const truncated = message.length > 2048 ? message.slice(0, 2045) + "…" : message;
|
|
226
|
-
const metadata = {
|
|
227
|
-
kind: "run_error",
|
|
228
|
-
code: src.errorCode ?? "run_crashed"
|
|
229
|
-
};
|
|
230
|
-
if (src.errorCredentialId) metadata.credential_id = src.errorCredentialId;
|
|
231
|
-
if (src.errorProvider) metadata.provider = src.errorProvider;
|
|
232
|
-
if (src.routeDecision) metadata.routing = src.routeDecision;
|
|
233
|
-
try {
|
|
234
|
-
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .addMessage */ .tj)(thread_id, "assistant", truncated, null, "run_error", metadata, "failed", (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)(src.errorCode));
|
|
235
|
-
} catch (err) {
|
|
236
|
-
console.error("[run] failed to persist run_error marker", err);
|
|
163
|
+
if (routeModule.isDev) {
|
|
164
|
+
(0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.addRequestMeta)(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());
|
|
237
165
|
}
|
|
238
|
-
|
|
239
|
-
//
|
|
240
|
-
//
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
message_metadata: zod__WEBPACK_IMPORTED_MODULE_14__/* .strictObject */ .rej({
|
|
246
|
-
hidden_from_chat: zod__WEBPACK_IMPORTED_MODULE_14__/* .boolean */ .zMY()
|
|
247
|
-
}).optional(),
|
|
248
|
-
// ADR-0096 — exact first-hot message seq; null clears the pin.
|
|
249
|
-
hot_since_seq: zod__WEBPACK_IMPORTED_MODULE_14__/* .number */ .aig().int().positive().nullable().optional(),
|
|
250
|
-
// ADR-0044 — automation channels the chat panel's filter toolbar has
|
|
251
|
-
// toggled on for this turn (scheduled_task/watcher/bridge). "chat" is
|
|
252
|
-
// unioned in server-side regardless of what the client sends, so callers
|
|
253
|
-
// don't have to remember to include it. Omitted = today's chat-only scope.
|
|
254
|
-
channels: zod__WEBPACK_IMPORTED_MODULE_14__/* .array */ .YOg(zod__WEBPACK_IMPORTED_MODULE_14__/* .string */ .YjP()).optional()
|
|
255
|
-
});
|
|
256
|
-
// POST is the *command* half of the run lifecycle (ADR-0008). It accepts the
|
|
257
|
-
// new user message, registers a run in the in-memory registry, kicks the
|
|
258
|
-
// agent loop off in a detached async task, and returns 202 after the user
|
|
259
|
-
// transcript is durable. The
|
|
260
|
-
// caller must follow up with a GET on this same path (as an `EventSource`)
|
|
261
|
-
// to subscribe to the chunk stream — see GET below.
|
|
262
|
-
//
|
|
263
|
-
// Splitting submit from subscribe gives us a single reliable streaming
|
|
264
|
-
// primitive across all browsers (EventSource is the only WebKit-native
|
|
265
|
-
// streaming API that survives iOS Safari + Tailscale HTTP/2 proxies). It
|
|
266
|
-
// also collapses what was previously a WS sidecar + SSE-over-POST +
|
|
267
|
-
// SSE-GET-reattach trio into one transport.
|
|
268
|
-
async function POST(req, { params }) {
|
|
269
|
-
const { thread_id } = await params;
|
|
270
|
-
const parsed = await (0,_lib_api_responses__WEBPACK_IMPORTED_MODULE_7__/* .validateBody */ .Jb)(req, RunBody);
|
|
271
|
-
if (parsed instanceof next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse) return parsed;
|
|
272
|
-
const message = parsed.message;
|
|
273
|
-
const attachments = parsed.attachments;
|
|
274
|
-
const stream_options = parsed.stream_options;
|
|
275
|
-
if (typeof parsed.hot_since_seq === "number" && !(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .isValidThreadContextCursor */ .m9)(thread_id, parsed.hot_since_seq)) {
|
|
276
|
-
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
277
|
-
error: "Boundary seq does not belong to this thread",
|
|
278
|
-
code: "invalid_boundary"
|
|
279
|
-
}, {
|
|
280
|
-
status: 400
|
|
281
|
-
});
|
|
166
|
+
let srcPage = "/api/v1/threads/[thread_id]/run/route";
|
|
167
|
+
// turbopack doesn't normalize `/index` in the page name
|
|
168
|
+
// so we need to to process dynamic routes properly
|
|
169
|
+
// TODO: fix turbopack providing differing value from webpack
|
|
170
|
+
if (false) {} else if (srcPage === '/index') {
|
|
171
|
+
// we always normalize /index specifically
|
|
172
|
+
srcPage = '/';
|
|
282
173
|
}
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
//
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
174
|
+
const multiZoneDraftMode = false;
|
|
175
|
+
// Registering `instrumentation.ts` usually installs the tracer provider, so
|
|
176
|
+
// do it before starting the request span. The span is started before
|
|
177
|
+
// `prepare`, so route module preparation is part of the request's trace.
|
|
178
|
+
// When this request triggers registration, the lifecycle spans of
|
|
179
|
+
// `instrumentation.ts` are emitted inside the request span.
|
|
180
|
+
const { instrumentation } = await routeModule.ensureInstrumentation(req, {
|
|
181
|
+
deferSpans: true
|
|
182
|
+
});
|
|
183
|
+
return routeModule.traceRequest(req, {
|
|
184
|
+
tracer: (0,next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.getTracer)(),
|
|
185
|
+
spanName: `${req.method || 'GET'} ${srcPage}`,
|
|
186
|
+
httpTarget: req.url,
|
|
187
|
+
instrumentation
|
|
188
|
+
}, (requestSpan, requestRootSpan)=>handleRequest(req, res, ctx, srcPage, multiZoneDraftMode, requestSpan, requestRootSpan));
|
|
189
|
+
}
|
|
190
|
+
async function handleRequest(req, res, ctx, srcPage, multiZoneDraftMode, requestSpan, requestRootSpan) {
|
|
191
|
+
const prepareResult = await routeModule.prepare(req, res, {
|
|
192
|
+
srcPage,
|
|
193
|
+
multiZoneDraftMode
|
|
194
|
+
});
|
|
195
|
+
if (!prepareResult) {
|
|
196
|
+
res.statusCode = 400;
|
|
197
|
+
res.end('Bad Request');
|
|
198
|
+
ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
const { buildId, deploymentId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest, previewProps } = prepareResult;
|
|
202
|
+
const normalizedSrcPage = (0,next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__.normalizeAppPath)(srcPage);
|
|
203
|
+
// Only this route's prerenders can establish ISR or admit generated params.
|
|
204
|
+
const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]) && (routeModule.isDev || (0,next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__.isRouteCacheOwner)(resolvedPathname, routeModule.cacheOwner, prerenderManifest.routes[resolvedPathname]));
|
|
205
|
+
let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || isPrerendered);
|
|
206
|
+
const render404 = async ()=>{
|
|
207
|
+
// TODO: should route-module itself handle rendering the 404
|
|
208
|
+
if (routerServerContext == null ? void 0 : routerServerContext.render404) {
|
|
209
|
+
await routerServerContext.render404(req, res, parsedUrl, false);
|
|
210
|
+
} else {
|
|
211
|
+
res.end('This page could not be found');
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
};
|
|
215
|
+
if (isIsr && !isDraftMode) {
|
|
216
|
+
const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];
|
|
217
|
+
if (prerenderInfo) {
|
|
218
|
+
if (prerenderInfo.fallback === false && !isPrerendered) {
|
|
219
|
+
if (nextConfig.adapterPath) {
|
|
220
|
+
return await render404();
|
|
221
|
+
}
|
|
222
|
+
throw new next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
let cacheKey = null;
|
|
227
|
+
if (isIsr && !routeModule.isDev && !isDraftMode) {
|
|
228
|
+
cacheKey = resolvedPathname;
|
|
229
|
+
// ensure /index and / is normalized to one key
|
|
230
|
+
cacheKey = cacheKey === '/index' ? '/' : cacheKey;
|
|
231
|
+
}
|
|
232
|
+
// Before rendering (which initializes component tree modules), we have to
|
|
233
|
+
// set the reference manifests to our global store so Server Action's
|
|
234
|
+
// encryption util can access to them at the top level of the page module.
|
|
235
|
+
if (serverActionsManifest && clientReferenceManifest) {
|
|
236
|
+
(0,next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__.setManifestsSingleton)({
|
|
237
|
+
page: srcPage,
|
|
238
|
+
clientReferenceManifest,
|
|
239
|
+
serverActionsManifest
|
|
302
240
|
});
|
|
303
241
|
}
|
|
304
|
-
const
|
|
305
|
-
const
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
242
|
+
const method = req.method || 'GET';
|
|
243
|
+
const tracer = (0,next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.getTracer)();
|
|
244
|
+
const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);
|
|
245
|
+
const isMinimalMode = Boolean((0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'minimalMode'));
|
|
246
|
+
const incrementalCache = (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, previewProps, prerenderManifest, isMinimalMode);
|
|
247
|
+
incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();
|
|
248
|
+
globalThis.__incrementalCache = incrementalCache;
|
|
249
|
+
const context = {
|
|
250
|
+
params,
|
|
251
|
+
previewProps,
|
|
252
|
+
renderOpts: {
|
|
253
|
+
experimental: {
|
|
254
|
+
authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
|
|
255
|
+
useCacheTimeout: nextConfig.experimental.useCacheTimeout,
|
|
256
|
+
durableUseCacheEntries: Boolean(nextConfig.experimental.durableUseCacheEntries)
|
|
257
|
+
},
|
|
258
|
+
cacheComponents: Boolean(nextConfig.cacheComponents),
|
|
259
|
+
validationLevel: nextConfig.experimental.instantInsights.validationLevel,
|
|
260
|
+
isDraftMode,
|
|
261
|
+
incrementalCache,
|
|
262
|
+
hmrRefreshHash: (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'hmrRefreshHash'),
|
|
263
|
+
cacheLifeProfiles: nextConfig.cacheLife,
|
|
264
|
+
staticPageGenerationTimeout: nextConfig.staticPageGenerationTimeout,
|
|
265
|
+
waitUntil: ctx.waitUntil,
|
|
266
|
+
onClose: (cb)=>{
|
|
267
|
+
res.on('close', cb);
|
|
268
|
+
},
|
|
269
|
+
onAfterTaskError: undefined
|
|
270
|
+
},
|
|
271
|
+
sharedContext: {
|
|
272
|
+
buildId,
|
|
273
|
+
deploymentId
|
|
274
|
+
}
|
|
315
275
|
};
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
276
|
+
const nodeNextReq = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextRequest(req);
|
|
277
|
+
const nodeNextRes = new next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__.NodeNextResponse(res);
|
|
278
|
+
const nextReq = next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__.NextRequestAdapter.fromNodeNextRequest(nodeNextReq, (0,next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__.signalFromNodeResponse)(res));
|
|
279
|
+
const responseGenerator = async ({ previousCacheEntry })=>{
|
|
280
|
+
try {
|
|
281
|
+
if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {
|
|
282
|
+
res.statusCode = 404;
|
|
283
|
+
// on-demand revalidate always sets this header
|
|
284
|
+
res.setHeader('x-nextjs-cache', 'REVALIDATED');
|
|
285
|
+
res.end('This page could not be found');
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
const response = cacheKey === null ? await routeModule.handle(nextReq, context) : await routeModule.prerender(nextReq, context);
|
|
289
|
+
req.fetchMetrics = context.renderOpts.fetchMetrics;
|
|
290
|
+
let pendingWaitUntil = context.renderOpts.pendingWaitUntil;
|
|
291
|
+
// Attempt using provided waitUntil if available
|
|
292
|
+
// if it's not we fallback to sendResponse's handling
|
|
293
|
+
if (pendingWaitUntil) {
|
|
294
|
+
if (ctx.waitUntil) {
|
|
295
|
+
ctx.waitUntil(pendingWaitUntil);
|
|
296
|
+
pendingWaitUntil = undefined;
|
|
332
297
|
}
|
|
333
|
-
}
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
298
|
+
}
|
|
299
|
+
const cacheTags = context.renderOpts.collectedTags;
|
|
300
|
+
// If the request is for a static response, we can cache it so long
|
|
301
|
+
// as it's not edge.
|
|
302
|
+
if (isIsr) {
|
|
303
|
+
const blob = await response.blob();
|
|
304
|
+
// Copy the headers from the response.
|
|
305
|
+
const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.toNodeOutgoingHttpHeaders)(response.headers);
|
|
306
|
+
if (cacheTags) {
|
|
307
|
+
headers[next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER] = cacheTags;
|
|
308
|
+
}
|
|
309
|
+
if (!headers['content-type'] && blob.type) {
|
|
310
|
+
headers['content-type'] = blob.type;
|
|
311
|
+
}
|
|
312
|
+
const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;
|
|
313
|
+
const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.INFINITE_CACHE ? // route has a numeric `revalidate` but didn't declare an
|
|
314
|
+
// explicit `expire` (e.g. via `cacheLife`). This mirrors the
|
|
315
|
+
// build-time fallback in `build/index.ts` so cache entries
|
|
316
|
+
// and the response Cache-Control header agree on the route's
|
|
317
|
+
// effective expire. Routes that opt out of revalidation
|
|
318
|
+
// (`revalidate: false`) or that are dynamic (`revalidate: 0`)
|
|
319
|
+
// keep `expire: undefined`.
|
|
320
|
+
revalidate !== false && revalidate > 0 ? nextConfig.expireTime : undefined : context.renderOpts.collectedExpire;
|
|
321
|
+
// Create the cache entry for the response.
|
|
322
|
+
const cacheEntry = {
|
|
323
|
+
value: {
|
|
324
|
+
kind: next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE,
|
|
325
|
+
status: response.status,
|
|
326
|
+
body: Buffer.from(await blob.arrayBuffer()),
|
|
327
|
+
headers
|
|
328
|
+
},
|
|
329
|
+
cacheControl: {
|
|
330
|
+
revalidate,
|
|
331
|
+
expire
|
|
352
332
|
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
errorCode: code
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .finishRun */ .JH)(active, "error");
|
|
333
|
+
};
|
|
334
|
+
return cacheEntry;
|
|
335
|
+
} else {
|
|
336
|
+
// send response without caching if not ISR
|
|
337
|
+
await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, response, pendingWaitUntil);
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
} catch (err) {
|
|
341
|
+
// if this is a background revalidate we need to report
|
|
342
|
+
// the request error here as it won't be bubbled
|
|
343
|
+
if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {
|
|
344
|
+
const silenceLog = false;
|
|
345
|
+
await routeModule.onRequestError(req, err, {
|
|
346
|
+
routerKind: 'App Router',
|
|
347
|
+
routePath: srcPage,
|
|
348
|
+
routeType: 'route',
|
|
349
|
+
revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
|
|
350
|
+
isStaticGeneration: cacheKey !== null,
|
|
351
|
+
isOnDemandRevalidate
|
|
352
|
+
})
|
|
353
|
+
}, silenceLog, routerServerContext);
|
|
354
|
+
}
|
|
355
|
+
throw err;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const handleResponse = async (currentSpan)=>{
|
|
359
|
+
try {
|
|
360
|
+
var _cacheEntry_value;
|
|
361
|
+
const cacheEntry = await routeModule.handleResponse({
|
|
362
|
+
req,
|
|
363
|
+
nextConfig,
|
|
364
|
+
cacheKey,
|
|
365
|
+
routeKind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
|
|
366
|
+
isFallback: false,
|
|
367
|
+
previewProps,
|
|
368
|
+
prerenderManifest,
|
|
369
|
+
isRoutePPREnabled: false,
|
|
370
|
+
isOnDemandRevalidate,
|
|
371
|
+
revalidateOnlyGenerated,
|
|
372
|
+
responseGenerator,
|
|
373
|
+
waitUntil: ctx.waitUntil,
|
|
374
|
+
isMinimalMode
|
|
375
|
+
});
|
|
376
|
+
if (cacheEntry !== null && 'error' in cacheEntry) {
|
|
377
|
+
throw cacheEntry.error;
|
|
378
|
+
}
|
|
379
|
+
// we don't create a cacheEntry for ISR
|
|
380
|
+
if (!isIsr) {
|
|
405
381
|
return;
|
|
406
382
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
//
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
if (
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
383
|
+
if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE) {
|
|
384
|
+
var _cacheEntry_value1;
|
|
385
|
+
throw new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`);
|
|
386
|
+
}
|
|
387
|
+
if (!isMinimalMode) {
|
|
388
|
+
res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');
|
|
389
|
+
}
|
|
390
|
+
// Draft mode should never be cached
|
|
391
|
+
if (isDraftMode) {
|
|
392
|
+
res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
|
|
393
|
+
}
|
|
394
|
+
const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.fromNodeOutgoingHttpHeaders)(cacheEntry.value.headers);
|
|
395
|
+
if (!(isMinimalMode && isIsr)) {
|
|
396
|
+
headers.delete(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER);
|
|
397
|
+
}
|
|
398
|
+
// If cache control is already set on the response we don't
|
|
399
|
+
// override it to allow users to customize it via next.config
|
|
400
|
+
if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {
|
|
401
|
+
headers.set('Cache-Control', (0,next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__.getCacheControlHeader)(cacheEntry.cacheControl));
|
|
402
|
+
}
|
|
403
|
+
await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.
|
|
404
|
+
new Response(cacheEntry.value.body, {
|
|
405
|
+
headers,
|
|
406
|
+
status: cacheEntry.value.status || 200
|
|
407
|
+
}));
|
|
408
|
+
return;
|
|
409
|
+
} catch (err) {
|
|
410
|
+
if (!(err instanceof next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError)) {
|
|
411
|
+
const silenceLog = false;
|
|
412
|
+
await routeModule.onRequestError(req, err, {
|
|
413
|
+
routerKind: 'App Router',
|
|
414
|
+
routePath: normalizedSrcPage,
|
|
415
|
+
routeType: 'route',
|
|
416
|
+
revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
|
|
417
|
+
isStaticGeneration: cacheKey !== null,
|
|
418
|
+
isOnDemandRevalidate
|
|
419
|
+
})
|
|
420
|
+
}, silenceLog, routerServerContext);
|
|
421
|
+
}
|
|
422
|
+
// rethrow so that we can handle serving error page
|
|
423
|
+
// If this is during static generation, throw the error again.
|
|
424
|
+
if (isIsr) throw err;
|
|
425
|
+
// Otherwise, send a 500 response unless the original response has
|
|
426
|
+
// already committed. In that case, preserve its status code for
|
|
427
|
+
// telemetry while still recording the failure and terminating a response
|
|
428
|
+
// that the failed pipeline left open.
|
|
429
|
+
if (res.headersSent) {
|
|
430
|
+
if (currentSpan) {
|
|
431
|
+
const error = err instanceof Error ? err : new Error('Unknown app route error');
|
|
432
|
+
currentSpan.recordException(error);
|
|
433
|
+
currentSpan.setStatus({
|
|
434
|
+
code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR,
|
|
435
|
+
message: error.message
|
|
436
|
+
});
|
|
437
|
+
currentSpan.setAttribute('error.type', error.name);
|
|
460
438
|
}
|
|
461
|
-
if (
|
|
462
|
-
|
|
463
|
-
toolResultCount = resultEvents.length;
|
|
464
|
-
toolResultBytes = resultEvents.reduce((sum, ev)=>sum + estimatePayloadBytes(ev.payload), 0);
|
|
465
|
-
toolResultBytesSpilled = resultEvents.reduce((sum, ev)=>sum + spilledToolResultBytes(ev.payload), 0);
|
|
439
|
+
if (!res.writableEnded && !res.destroyed) {
|
|
440
|
+
res.end();
|
|
466
441
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
442
|
+
} else {
|
|
443
|
+
await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, new Response(null, {
|
|
444
|
+
status: 500
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
447
|
+
return;
|
|
448
|
+
} finally{
|
|
449
|
+
;
|
|
450
|
+
(()=>{
|
|
451
|
+
if (!currentSpan) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
let statusCode = res.statusCode;
|
|
455
|
+
currentSpan.setAttributes({
|
|
456
|
+
'http.status_code': statusCode,
|
|
457
|
+
'next.rsc': false
|
|
472
458
|
});
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
if (collected.terminal === "error" && collected.errorMessage && !collected.aborted) {
|
|
479
|
-
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
480
|
-
type: "error",
|
|
481
|
-
data: {
|
|
482
|
-
message: collected.errorMessage,
|
|
483
|
-
code: "stream_error"
|
|
484
|
-
}
|
|
459
|
+
if (statusCode && statusCode >= 500) {
|
|
460
|
+
// For 5xx status codes: SHOULD be set to 'Error' span status.
|
|
461
|
+
// x-ref: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
|
462
|
+
currentSpan.setStatus({
|
|
463
|
+
code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR
|
|
485
464
|
});
|
|
465
|
+
// For span status 'Error', SHOULD set 'error.type' attribute.
|
|
466
|
+
currentSpan.setAttribute('error.type', statusCode.toString());
|
|
486
467
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
// returns the bare marker when the partial is empty, which forces
|
|
492
|
-
// persistAssistantMessage past its skip-empty guard so the thread
|
|
493
|
-
// always has a row recording what happened.
|
|
494
|
-
const contentToPersist = collected.aborted ? (0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .withInterruptMarker */ .IC)(collected.assistantContent) : collected.assistantContent;
|
|
495
|
-
const noResponse = collected.terminal === "done" && !collected.aborted && !contentToPersist.trim() && !collected.toolEvents.length && !prepared.signal_delivery?.signals.length;
|
|
496
|
-
const transcriptStatus = collected.aborted ? "interrupted" : collected.terminal === "done" && !noResponse ? "completed" : "failed";
|
|
497
|
-
const statusReason = transcriptStatus === "interrupted" ? "Stopped by user." : noResponse ? "The model completed without producing a response." : transcriptStatus === "failed" ? (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)(collected.errorCode) : null;
|
|
498
|
-
const draft = assistantDraftState.current;
|
|
499
|
-
(0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .persistAssistantMessage */ ._w)(thread_id, contentToPersist, collected.usedTools, collected.toolEvents, null, collected.usage ?? null, prepared.context_snapshot ?? null, prepared.source_manifest ?? null, routeDecision, prepared.memory_recall ? {
|
|
500
|
-
memory_recall: prepared.memory_recall
|
|
501
|
-
} : null, collected.terminal === "done" && !collected.aborted ? prepared.signal_delivery : undefined, draft ? {
|
|
502
|
-
draftMessageId: draft.msg_id,
|
|
503
|
-
transcriptStatus,
|
|
504
|
-
statusReason
|
|
505
|
-
} : undefined);
|
|
506
|
-
// If the turn failed AND persistAssistantMessage skipped writing
|
|
507
|
-
// a row (no content + no tool events + not aborted), persist a
|
|
508
|
-
// synthetic `run_error` marker so the failure survives reload
|
|
509
|
-
// and cross-device sync. history-window filters these rows out
|
|
510
|
-
// of the LLM budget; the UI renders them as a compact chip.
|
|
511
|
-
// See ADR-0069.
|
|
512
|
-
if (terminal === "error" && !collected.aborted && !collected.assistantContent.trim() && (!collected.toolEvents || collected.toolEvents.length === 0) && !assistantDraftState.current) {
|
|
513
|
-
persistRunErrorMarker(thread_id, {
|
|
514
|
-
...collected,
|
|
515
|
-
routeDecision
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
// Steering queued during the FINAL model call never reaches
|
|
519
|
-
// preModelHook — the react graph goes straight to END once the
|
|
520
|
-
// model stops emitting tool calls. Those messages are already in
|
|
521
|
-
// the transcript, so run a continuation rather than dropping them
|
|
522
|
-
// (ADR-0080). Skipped on abort: the user cancelled deliberately.
|
|
523
|
-
if (!collected.aborted) {
|
|
524
|
-
const undelivered = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .drainSteering */ .QK)(thread_id);
|
|
525
|
-
if (undelivered.length > 0) {
|
|
526
|
-
void (0,_lib_agents_agent_turn__WEBPACK_IMPORTED_MODULE_3__.runAgentTurn)({
|
|
527
|
-
thread_id,
|
|
528
|
-
queue_source: "user",
|
|
529
|
-
message: undelivered.join("\n\n"),
|
|
530
|
-
skip_persist_user_message: true,
|
|
531
|
-
history_append_message: STEERING_CONTINUATION_PREFIX + undelivered.join("\n\n")
|
|
532
|
-
}).catch((err)=>console.error("[run] steering continuation failed", err));
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
} catch (persistErr) {
|
|
536
|
-
terminal = "error";
|
|
537
|
-
const draft = assistantDraftState.current;
|
|
538
|
-
if (draft && (0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .getThreadMessageBySeq */ .wc)(thread_id, draft.seq)?.transcript_status === "in_progress") {
|
|
539
|
-
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .updateMessageContent */ .e8)(draft.msg_id, draft.visibleContent, {
|
|
540
|
-
transcriptStatus: "failed",
|
|
541
|
-
statusReason: (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)("persist_error")
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
545
|
-
type: "error",
|
|
546
|
-
data: {
|
|
547
|
-
message: `persist failed: ${persistErr.message}`,
|
|
548
|
-
code: "persist_error"
|
|
549
|
-
}
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
} catch (err) {
|
|
553
|
-
terminal = "error";
|
|
554
|
-
const errMsg = err.message ?? String(err);
|
|
555
|
-
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
556
|
-
type: "error",
|
|
557
|
-
data: {
|
|
558
|
-
message: errMsg,
|
|
559
|
-
code: "run_crashed"
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
// Same marker semantics as above but for the outer crash path — the
|
|
563
|
-
// stream threw before collectStream could emit an error chunk.
|
|
564
|
-
try {
|
|
565
|
-
const draft = assistantDraftState.current;
|
|
566
|
-
if (draft && (0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .getThreadMessageBySeq */ .wc)(thread_id, draft.seq)?.transcript_status === "in_progress") {
|
|
567
|
-
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .updateMessageContent */ .e8)(draft.msg_id, draft.visibleContent, {
|
|
568
|
-
category: draft.visibleContent ? null : "run_error",
|
|
569
|
-
transcriptStatus: "failed",
|
|
570
|
-
statusReason: (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)("run_crashed")
|
|
571
|
-
});
|
|
572
|
-
} else if (!draft) {
|
|
573
|
-
persistRunErrorMarker(thread_id, {
|
|
574
|
-
errorMessage: errMsg,
|
|
575
|
-
errorCode: "run_crashed",
|
|
576
|
-
routeDecision: prepared.route_decision ?? null
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
} catch (persistErr) {
|
|
580
|
-
console.error("[run] failed to persist run_error marker", persistErr);
|
|
468
|
+
const rootSpanAttributes = tracer.getRootSpanAttributes();
|
|
469
|
+
// We were unable to get attributes, probably OTEL is not enabled
|
|
470
|
+
if (!rootSpanAttributes) {
|
|
471
|
+
return;
|
|
581
472
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const ttftValue = ttftMs ?? totalMs;
|
|
586
|
-
const toolList = Array.from(toolsUsed).join(",") || "none";
|
|
587
|
-
const assistantChars = assistantContent.length;
|
|
588
|
-
const assistantBytes = estimateUtf8Bytes(assistantContent);
|
|
589
|
-
const inTok = inputTokens ?? -1;
|
|
590
|
-
const outTok = outputTokens ?? -1;
|
|
591
|
-
const cacheRead = cacheReadTokens ?? -1;
|
|
592
|
-
const cacheCreate = cacheCreateTokens ?? -1;
|
|
593
|
-
const cacheDenom = Math.max(0, inTok) + Math.max(0, cacheRead) + Math.max(0, cacheCreate);
|
|
594
|
-
const cacheReadPct = cacheDenom > 0 && cacheRead >= 0 ? Math.round(cacheRead / cacheDenom * 1000) / 10 : -1;
|
|
595
|
-
console.info(`[perf.run] thread=${thread_id} status=${terminal}` + ` queue_ms=${queueWaitMs}` + ` prep_ms=${prepDurationMs}` + ` ttft_ms=${ttftValue}` + ` stream_ms=${streamDurationMs}` + ` total_ms=${totalMs}` + ` input_tokens=${inTok}` + ` output_tokens=${outTok}` + ` cache_read_tokens=${cacheRead}` + ` cache_create_tokens=${cacheCreate}` + ` cache_read_pct=${cacheReadPct}` + ` thinking_tokens=${thinkingTokens ?? -1}` + ` assistant_chars=${assistantChars}` + ` assistant_bytes=${assistantBytes}` + ` tool_results=${toolResultCount}` + ` tool_result_bytes=${toolResultBytes}` + ` tool_result_bytes_spilled=${toolResultBytesSpilled}` + ` tools=${toolList}` + ` error_code=${terminalErrorCode ?? "-"}`);
|
|
473
|
+
if (rootSpanAttributes.get('next.span_type') !== next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest) {
|
|
474
|
+
console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);
|
|
475
|
+
return;
|
|
596
476
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
preview: assistantContent.replace(/\s+/g, " ").trim().slice(0, 120),
|
|
604
|
-
ts: Date.now()
|
|
477
|
+
const route = rootSpanAttributes.get('next.route') || normalizedSrcPage;
|
|
478
|
+
const name = `${method} ${route}`;
|
|
479
|
+
currentSpan.setAttributes({
|
|
480
|
+
'next.route': route,
|
|
481
|
+
'http.route': route,
|
|
482
|
+
'next.span_name': name
|
|
605
483
|
});
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
thread_id,
|
|
614
|
-
error: err.message
|
|
615
|
-
}), {
|
|
616
|
-
status: 503,
|
|
617
|
-
headers: {
|
|
618
|
-
"Content-Type": "application/json"
|
|
484
|
+
currentSpan.updateName(name);
|
|
485
|
+
// Propagate http.route to the request's root span if it isn't the
|
|
486
|
+
// request span (e.g. a platform-created HTTP span in adapter
|
|
487
|
+
// deployments).
|
|
488
|
+
if (requestRootSpan && requestRootSpan !== currentSpan) {
|
|
489
|
+
requestRootSpan.setAttribute('http.route', route);
|
|
490
|
+
requestRootSpan.updateName(name);
|
|
619
491
|
}
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
throw err;
|
|
623
|
-
}
|
|
624
|
-
try {
|
|
625
|
-
persistedTurn = await (0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .persistThreadRunUserMessage */ .Ie)({
|
|
626
|
-
thread_id,
|
|
627
|
-
message,
|
|
628
|
-
attachments,
|
|
629
|
-
message_metadata: parsed.message_metadata,
|
|
630
|
-
context_profile: contextProfile,
|
|
631
|
-
_onTranscriptUserPersisted: ()=>{
|
|
632
|
-
assistantDraftState.current = (0,_lib_agents_transcript_draft__WEBPACK_IMPORTED_MODULE_12__/* .createAssistantTranscriptDraft */ .q)(thread_id);
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
releaseAdmission(true);
|
|
636
|
-
} catch (err) {
|
|
637
|
-
releaseAdmission(false);
|
|
638
|
-
if (err instanceof _lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .RunThreadError */ .op) {
|
|
639
|
-
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
640
|
-
error: err.message,
|
|
641
|
-
code: err.code
|
|
642
|
-
}, {
|
|
643
|
-
status: err.status
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
console.error("[run] failed to persist submitted user message", err);
|
|
647
|
-
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
648
|
-
error: "Failed to persist submitted user message",
|
|
649
|
-
code: "transcript_persist_failed"
|
|
650
|
-
}, {
|
|
651
|
-
status: 500
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
return new Response(JSON.stringify({
|
|
655
|
-
accepted: true,
|
|
656
|
-
thread_id,
|
|
657
|
-
queue_position: position
|
|
658
|
-
}), {
|
|
659
|
-
status: 202,
|
|
660
|
-
headers: {
|
|
661
|
-
"Content-Type": "application/json"
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
// GET is the *query* half of the run lifecycle (ADR-0008). Attaches to an
|
|
666
|
-
// active (or recently-finished, within the registry TTL) run and streams
|
|
667
|
-
// chunks as Server-Sent Events. Always consumed client-side via
|
|
668
|
-
// `EventSource` — never `fetch().body.getReader()`, which is unreliable on
|
|
669
|
-
// iOS Safari for long-lived streaming responses.
|
|
670
|
-
//
|
|
671
|
-
// Emits a single synthetic `done` event and closes when there's no run to
|
|
672
|
-
// attach to (run never existed, or it finished + TTL-evicted before the GET
|
|
673
|
-
// arrived). We deliberately do NOT return 404 here: browsers map a 404 SSE
|
|
674
|
-
// response onto `EventSource.onerror` with no terminal event, which trips
|
|
675
|
-
// EventSource's auto-reconnect logic and leaves the client in a "stream
|
|
676
|
-
// open but silent" state — UIs gating on a `done` event hang forever
|
|
677
|
-
// showing the Stop/Reconnecting affordances. A 200 with `data: {"type":
|
|
678
|
-
// "done"}\n\n` makes the iterator drain cleanly on every transport.
|
|
679
|
-
//
|
|
680
|
-
// `show_tools` / `show_thinking` query params let the caller suppress
|
|
681
|
-
// chunk types it doesn't want to render. Defaults: both on. The full
|
|
682
|
-
// `StreamOptions` shape is only meaningful on the POST (tool policy &
|
|
683
|
-
// agent run config are run-wide settings, not per-subscriber filters).
|
|
684
|
-
async function GET(req, { params }) {
|
|
685
|
-
const { thread_id } = await params;
|
|
686
|
-
const showTools = req.nextUrl.searchParams.get("show_tools") !== "false";
|
|
687
|
-
const showThinking = req.nextUrl.searchParams.get("show_thinking") !== "false";
|
|
688
|
-
const awaitContinuation = req.nextUrl.searchParams.get("await_continuation") === "true";
|
|
689
|
-
const stream_options = {
|
|
690
|
-
filters: {
|
|
691
|
-
include_tools: showTools,
|
|
692
|
-
include_thinking: showThinking
|
|
492
|
+
})();
|
|
693
493
|
}
|
|
694
494
|
};
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
// Next's `after()` and hasn't reached `startRun` yet), hold the SSE
|
|
701
|
-
// open briefly so we don't return a synthetic `done` for a run
|
|
702
|
-
// that's about to register. If nothing appears in time, fall
|
|
703
|
-
// through to the same `done`-and-close path as a truly idle thread.
|
|
704
|
-
const queued = (0,_lib_agents_run_queue__WEBPACK_IMPORTED_MODULE_4__.getQueueDepth)(thread_id) > 0 ? await (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .waitForRun */ .Cs)(thread_id, 5000) : null;
|
|
705
|
-
if (!queued) {
|
|
706
|
-
const stream = new ReadableStream({
|
|
707
|
-
start (controller) {
|
|
708
|
-
try {
|
|
709
|
-
controller.enqueue(sse({
|
|
710
|
-
type: "done"
|
|
711
|
-
}));
|
|
712
|
-
} catch {}
|
|
713
|
-
try {
|
|
714
|
-
controller.close();
|
|
715
|
-
} catch {}
|
|
716
|
-
}
|
|
717
|
-
});
|
|
718
|
-
return (0,_lib_api_sse__WEBPACK_IMPORTED_MODULE_16__/* .sseResponse */ .t)(stream);
|
|
719
|
-
}
|
|
495
|
+
// When invoked directly, the request span was started before `prepare`;
|
|
496
|
+
// record the request target as normalized by it. next-server's request span
|
|
497
|
+
// already has it.
|
|
498
|
+
if (!isWrappedByNextServer && req.url !== undefined) {
|
|
499
|
+
requestSpan == null ? void 0 : requestSpan.setAttribute('http.target', req.url);
|
|
720
500
|
}
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
const SteerBody = zod__WEBPACK_IMPORTED_MODULE_14__/* .object */ .Ikc({
|
|
724
|
-
message: zod__WEBPACK_IMPORTED_MODULE_14__/* .string */ .YjP().min(1)
|
|
725
|
-
});
|
|
726
|
-
// The steering text is already the last user row in the transcript, so the
|
|
727
|
-
// continuation only needs to explain why the agent is seeing it late.
|
|
728
|
-
const STEERING_CONTINUATION_PREFIX = "↪ You finished the previous reply before reading this. The user said, while you were still writing:\n\n";
|
|
729
|
-
// PATCH steers the currently-running agent: the message is queued and the
|
|
730
|
-
// agent's preModelHook delivers it before the next model call, alongside the
|
|
731
|
-
// tool results it should react to (ADR-0080). 409 means there was nothing to
|
|
732
|
-
// steer, and the caller should submit a normal run instead.
|
|
733
|
-
async function PATCH(req, { params }) {
|
|
734
|
-
const { thread_id } = await params;
|
|
735
|
-
const body = await (0,_lib_api_responses__WEBPACK_IMPORTED_MODULE_7__/* .validateBody */ .Jb)(req, SteerBody);
|
|
736
|
-
if (body instanceof next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse) return body;
|
|
737
|
-
if (!(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .pushSteering */ .mx)(thread_id, body.message)) {
|
|
738
|
-
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
739
|
-
steered: false,
|
|
740
|
-
reason: "no_active_run"
|
|
741
|
-
}, {
|
|
742
|
-
status: 409
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
// Persist only once the queue accepted it, so a 409 fallback to POST /run
|
|
746
|
-
// doesn't write the same message twice.
|
|
747
|
-
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .addMessage */ .tj)(thread_id, "user", body.message);
|
|
748
|
-
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
749
|
-
steered: true
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
// DELETE aborts the currently-running agent for this thread. The agent stream
|
|
753
|
-
// loop in llm.ts catches the resulting AbortError and emits a synthetic
|
|
754
|
-
// `error` + `done` event pair so subscribers (and the client's queue-drain
|
|
755
|
-
// hook) finish cleanly.
|
|
756
|
-
async function DELETE(_req, { params }) {
|
|
757
|
-
const { thread_id } = await params;
|
|
758
|
-
const aborted = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .abortRun */ .KD)(thread_id, "user_interrupted");
|
|
759
|
-
return new Response(JSON.stringify({
|
|
760
|
-
aborted
|
|
761
|
-
}), {
|
|
762
|
-
status: aborted ? 200 : 404,
|
|
763
|
-
headers: {
|
|
764
|
-
"Content-Type": "application/json"
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
function attachStream(thread_id, stream_options) {
|
|
769
|
-
// Captured by both start() and cancel() so the cancel branch can tear
|
|
770
|
-
// down the poll timer + subscription when the client disconnects.
|
|
771
|
-
// Without this, navigating away from a long-running thread leaks an
|
|
772
|
-
// event subscriber + 2Hz setInterval per visit until the run finishes
|
|
773
|
-
// (or forever if it doesn't).
|
|
774
|
-
let poll = null;
|
|
775
|
-
let unsubscribe = null;
|
|
776
|
-
let clientGone = false;
|
|
777
|
-
const stream = new ReadableStream({
|
|
778
|
-
start (controller) {
|
|
779
|
-
const safeEnqueue = (chunk)=>{
|
|
780
|
-
if (clientGone) return;
|
|
781
|
-
try {
|
|
782
|
-
controller.enqueue(chunk);
|
|
783
|
-
} catch {
|
|
784
|
-
clientGone = true;
|
|
785
|
-
}
|
|
786
|
-
};
|
|
787
|
-
const onEvent = (ev)=>{
|
|
788
|
-
if (!(0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .shouldEmitChunk */ .ib)(ev.type, stream_options)) return;
|
|
789
|
-
safeEnqueue(sse({
|
|
790
|
-
type: ev.type,
|
|
791
|
-
...ev.data
|
|
792
|
-
}));
|
|
793
|
-
};
|
|
794
|
-
const sub = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .subscribe */ .B1)(thread_id, onEvent);
|
|
795
|
-
unsubscribe = sub.unsubscribe;
|
|
796
|
-
if (!sub.run) {
|
|
797
|
-
try {
|
|
798
|
-
controller.close();
|
|
799
|
-
} catch {}
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
// If run already terminal, close after replay.
|
|
803
|
-
if (sub.run.status !== "running") {
|
|
804
|
-
try {
|
|
805
|
-
controller.close();
|
|
806
|
-
} catch {}
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
// When the run finishes (status changes), close our response. We
|
|
810
|
-
// poll lightly because the run might finish due to other subscribers'
|
|
811
|
-
// signals; simpler than wiring a second listener channel.
|
|
812
|
-
poll = setInterval(()=>{
|
|
813
|
-
const r = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .getRun */ .Mh)(thread_id);
|
|
814
|
-
if (!r || r.status !== "running") {
|
|
815
|
-
if (poll) {
|
|
816
|
-
clearInterval(poll);
|
|
817
|
-
poll = null;
|
|
818
|
-
}
|
|
819
|
-
if (unsubscribe) {
|
|
820
|
-
unsubscribe();
|
|
821
|
-
unsubscribe = null;
|
|
822
|
-
}
|
|
823
|
-
if (!clientGone) {
|
|
824
|
-
try {
|
|
825
|
-
controller.close();
|
|
826
|
-
} catch {}
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
}, 500);
|
|
830
|
-
poll.unref?.();
|
|
831
|
-
},
|
|
832
|
-
cancel () {
|
|
833
|
-
// Client navigated away — agent run keeps going in registry, but
|
|
834
|
-
// tear down OUR poll + subscription so we don't leak a timer +
|
|
835
|
-
// subscriber per disconnect.
|
|
836
|
-
clientGone = true;
|
|
837
|
-
if (poll) {
|
|
838
|
-
clearInterval(poll);
|
|
839
|
-
poll = null;
|
|
840
|
-
}
|
|
841
|
-
if (unsubscribe) {
|
|
842
|
-
unsubscribe();
|
|
843
|
-
unsubscribe = null;
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
});
|
|
847
|
-
return (0,_lib_api_sse__WEBPACK_IMPORTED_MODULE_16__/* .sseResponse */ .t)(stream);
|
|
501
|
+
await handleResponse(requestSpan);
|
|
848
502
|
}
|
|
849
503
|
|
|
504
|
+
//# sourceMappingURL=app-route.js.map
|
|
505
|
+
|
|
850
506
|
|
|
851
507
|
/***/ }),
|
|
852
508
|
|
|
853
|
-
/***/
|
|
509
|
+
/***/ 157075:
|
|
854
510
|
/***/ ((module) => {
|
|
855
511
|
|
|
856
|
-
module.exports = require("
|
|
512
|
+
module.exports = require("node:stream");
|
|
857
513
|
|
|
858
514
|
/***/ }),
|
|
859
515
|
|
|
860
|
-
/***/
|
|
861
|
-
/***/ ((
|
|
516
|
+
/***/ 176760:
|
|
517
|
+
/***/ ((module) => {
|
|
862
518
|
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
// and Cloudflare. See ADR-0009 for the proxy story.
|
|
870
|
-
function sseResponse(stream, opts = {}) {
|
|
871
|
-
const { disableProxyBuffering = true } = opts;
|
|
872
|
-
const headers = {
|
|
873
|
-
"Content-Type": "text/event-stream",
|
|
874
|
-
"Cache-Control": "no-cache",
|
|
875
|
-
Connection: "keep-alive"
|
|
876
|
-
};
|
|
877
|
-
if (disableProxyBuffering) headers["X-Accel-Buffering"] = "no";
|
|
878
|
-
return new Response(stream, {
|
|
879
|
-
headers
|
|
880
|
-
});
|
|
881
|
-
}
|
|
519
|
+
module.exports = require("node:path");
|
|
520
|
+
|
|
521
|
+
/***/ }),
|
|
522
|
+
|
|
523
|
+
/***/ 200261:
|
|
524
|
+
/***/ ((module) => {
|
|
882
525
|
|
|
526
|
+
module.exports = require("next/dist/shared/lib/router/utils/app-paths");
|
|
883
527
|
|
|
884
528
|
/***/ }),
|
|
885
529
|
|
|
886
|
-
/***/
|
|
530
|
+
/***/ 257975:
|
|
887
531
|
/***/ ((module) => {
|
|
888
532
|
|
|
889
|
-
module.exports =
|
|
533
|
+
module.exports = require("node:util");
|
|
890
534
|
|
|
891
535
|
/***/ }),
|
|
892
536
|
|
|
893
|
-
/***/
|
|
537
|
+
/***/ 309956:
|
|
894
538
|
/***/ ((module) => {
|
|
895
539
|
|
|
896
|
-
module.exports = require("
|
|
540
|
+
module.exports = require("undici");
|
|
897
541
|
|
|
898
542
|
/***/ }),
|
|
899
543
|
|
|
900
|
-
/***/
|
|
544
|
+
/***/ 328354:
|
|
901
545
|
/***/ ((module) => {
|
|
902
546
|
|
|
903
|
-
module.exports = require("
|
|
547
|
+
module.exports = require("util");
|
|
904
548
|
|
|
905
549
|
/***/ }),
|
|
906
550
|
|
|
907
|
-
/***/
|
|
551
|
+
/***/ 333873:
|
|
908
552
|
/***/ ((module) => {
|
|
909
553
|
|
|
910
|
-
module.exports = require("
|
|
554
|
+
module.exports = require("path");
|
|
911
555
|
|
|
912
556
|
/***/ }),
|
|
913
557
|
|
|
914
|
-
/***/
|
|
915
|
-
/***/ ((
|
|
558
|
+
/***/ 344708:
|
|
559
|
+
/***/ ((module) => {
|
|
916
560
|
|
|
917
|
-
|
|
918
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
919
|
-
/* harmony export */ handler: () => (/* binding */ handler),
|
|
920
|
-
/* harmony export */ patchFetch: () => (/* binding */ patchFetch),
|
|
921
|
-
/* harmony export */ routeModule: () => (/* binding */ routeModule),
|
|
922
|
-
/* harmony export */ serverHooks: () => (/* binding */ serverHooks),
|
|
923
|
-
/* harmony export */ workAsyncStorage: () => (/* binding */ workAsyncStorage),
|
|
924
|
-
/* harmony export */ workUnitAsyncStorage: () => (/* binding */ workUnitAsyncStorage)
|
|
925
|
-
/* harmony export */ });
|
|
926
|
-
/* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(319225);
|
|
927
|
-
/* harmony import */ var next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__);
|
|
928
|
-
/* harmony import */ var next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(684006);
|
|
929
|
-
/* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8317);
|
|
930
|
-
/* harmony import */ var next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__);
|
|
931
|
-
/* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(799373);
|
|
932
|
-
/* harmony import */ var next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__);
|
|
933
|
-
/* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(434775);
|
|
934
|
-
/* harmony import */ var next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__);
|
|
935
|
-
/* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(524235);
|
|
936
|
-
/* harmony import */ var next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_app_render_manifests_singleton__WEBPACK_IMPORTED_MODULE_5__);
|
|
937
|
-
/* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(200261);
|
|
938
|
-
/* harmony import */ var next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(next_dist_shared_lib_router_utils_app_paths__WEBPACK_IMPORTED_MODULE_6__);
|
|
939
|
-
/* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(754365);
|
|
940
|
-
/* harmony import */ var next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_base_http_node__WEBPACK_IMPORTED_MODULE_7__);
|
|
941
|
-
/* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(590771);
|
|
942
|
-
/* harmony import */ var next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_web_spec_extension_adapters_next_request__WEBPACK_IMPORTED_MODULE_8__);
|
|
943
|
-
/* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(473461);
|
|
944
|
-
/* harmony import */ var next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__);
|
|
945
|
-
/* harmony import */ var next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(767798);
|
|
946
|
-
/* harmony import */ var next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(192280);
|
|
947
|
-
/* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(662018);
|
|
948
|
-
/* harmony import */ var next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__);
|
|
949
|
-
/* harmony import */ var next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(445696);
|
|
950
|
-
/* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(347929);
|
|
951
|
-
/* harmony import */ var next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__);
|
|
952
|
-
/* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(986439);
|
|
953
|
-
/* harmony import */ var next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__);
|
|
954
|
-
/* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(710246);
|
|
955
|
-
/* harmony import */ var next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_lib_route_cache_key__WEBPACK_IMPORTED_MODULE_16__);
|
|
956
|
-
/* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(137527);
|
|
957
|
-
/* harmony import */ var next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__);
|
|
561
|
+
module.exports = require("node:https");
|
|
958
562
|
|
|
563
|
+
/***/ }),
|
|
959
564
|
|
|
565
|
+
/***/ 358500:
|
|
566
|
+
/***/ ((module) => {
|
|
960
567
|
|
|
568
|
+
module.exports = require("node:timers/promises");
|
|
961
569
|
|
|
570
|
+
/***/ }),
|
|
962
571
|
|
|
572
|
+
/***/ 379551:
|
|
573
|
+
/***/ ((module) => {
|
|
963
574
|
|
|
575
|
+
module.exports = require("url");
|
|
964
576
|
|
|
577
|
+
/***/ }),
|
|
965
578
|
|
|
579
|
+
/***/ 380481:
|
|
580
|
+
/***/ ((module) => {
|
|
966
581
|
|
|
582
|
+
module.exports = require("node:readline");
|
|
967
583
|
|
|
584
|
+
/***/ }),
|
|
968
585
|
|
|
586
|
+
/***/ 399253:
|
|
587
|
+
/***/ ((module) => {
|
|
969
588
|
|
|
589
|
+
module.exports = import("@huggingface/transformers");;
|
|
970
590
|
|
|
591
|
+
/***/ }),
|
|
971
592
|
|
|
593
|
+
/***/ 419121:
|
|
594
|
+
/***/ ((module) => {
|
|
972
595
|
|
|
596
|
+
module.exports = require("next/dist/server/app-render/action-async-storage.external.js");
|
|
973
597
|
|
|
598
|
+
/***/ }),
|
|
974
599
|
|
|
600
|
+
/***/ 455511:
|
|
601
|
+
/***/ ((module) => {
|
|
975
602
|
|
|
976
|
-
|
|
977
|
-
// module.
|
|
978
|
-
const nextConfigOutput = "standalone"
|
|
979
|
-
const routeModule = new next_dist_server_route_modules_app_route_module_compiled__WEBPACK_IMPORTED_MODULE_0__.AppRouteRouteModule({
|
|
980
|
-
definition: {
|
|
981
|
-
kind: next_dist_server_route_kind__WEBPACK_IMPORTED_MODULE_1__.RouteKind.APP_ROUTE,
|
|
982
|
-
page: "/api/v1/threads/[thread_id]/run/route",
|
|
983
|
-
pathname: "/api/v1/threads/[thread_id]/run",
|
|
984
|
-
filename: "route",
|
|
985
|
-
bundlePath: "app/api/v1/threads/[thread_id]/run/route"
|
|
986
|
-
},
|
|
987
|
-
distDir: ".next" || 0,
|
|
988
|
-
relativeProjectDir: false || '',
|
|
989
|
-
resolvedPagePath: "/home/runner/work/jarela/jarela/app/api/v1/threads/[thread_id]/run/route.ts",
|
|
990
|
-
nextConfigOutput,
|
|
991
|
-
// The lazy require factory ensures that:
|
|
992
|
-
// - In dev: devRequestTimingInternalsEnd is set before userland executes,
|
|
993
|
-
// correctly attributing module load time to application-code rather than
|
|
994
|
-
// framework internals.
|
|
995
|
-
// - In all modes: async modules (route files with top-level await) are
|
|
996
|
-
// handled correctly — require() returns a Promise for such modules, which
|
|
997
|
-
// ensureUserland() awaits before the first request is handled.
|
|
998
|
-
userland: ()=>__webpack_require__(498913),
|
|
999
|
-
// In Turbopack dev mode, also provide a synchronous per-request getter so
|
|
1000
|
-
// server HMR updates are picked up without re-executing the entry chunk.
|
|
1001
|
-
// Using require() (synchronous) avoids adding async overhead that would be
|
|
1002
|
-
// incorrectly attributed to application-code time in devRequestTiming.
|
|
1003
|
-
... false ? 0 : {}
|
|
1004
|
-
});
|
|
1005
|
-
// Pull out the exports that we need to expose from the module. This should
|
|
1006
|
-
// be eliminated when we've moved the other routes to the new format. These
|
|
1007
|
-
// are used to hook into the route.
|
|
1008
|
-
const { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;
|
|
1009
|
-
function patchFetch() {
|
|
1010
|
-
return (0,next_dist_server_lib_patch_fetch__WEBPACK_IMPORTED_MODULE_2__.patchFetch)({
|
|
1011
|
-
workAsyncStorage,
|
|
1012
|
-
workUnitAsyncStorage
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
603
|
+
module.exports = require("crypto");
|
|
1015
604
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
605
|
+
/***/ }),
|
|
606
|
+
|
|
607
|
+
/***/ 498913:
|
|
608
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
609
|
+
|
|
610
|
+
__webpack_require__.r(__webpack_exports__);
|
|
611
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
612
|
+
/* harmony export */ DELETE: () => (/* binding */ DELETE),
|
|
613
|
+
/* harmony export */ GET: () => (/* binding */ GET),
|
|
614
|
+
/* harmony export */ PATCH: () => (/* binding */ PATCH),
|
|
615
|
+
/* harmony export */ POST: () => (/* binding */ POST)
|
|
616
|
+
/* harmony export */ });
|
|
617
|
+
/* harmony import */ var next_server__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(945592);
|
|
618
|
+
/* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(497377);
|
|
619
|
+
/* harmony import */ var _lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(954031);
|
|
620
|
+
/* harmony import */ var _lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(968564);
|
|
621
|
+
/* harmony import */ var _lib_agents_agent_turn__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(362032);
|
|
622
|
+
/* harmony import */ var _lib_agents_run_queue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(603944);
|
|
623
|
+
/* harmony import */ var _lib_agents_stream_collector__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(230685);
|
|
624
|
+
/* harmony import */ var _lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(783042);
|
|
625
|
+
/* harmony import */ var _lib_notifications_bus__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(776445);
|
|
626
|
+
/* harmony import */ var _lib_api_sse__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(553854);
|
|
627
|
+
/* harmony import */ var _lib_api_responses__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(739947);
|
|
628
|
+
/* harmony import */ var _lib_agents_turn_profile__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(874532);
|
|
629
|
+
/* harmony import */ var _lib_agents_model_router__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(256236);
|
|
630
|
+
/* harmony import */ var _lib_env_config__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(367500);
|
|
631
|
+
/* harmony import */ var _lib_tools_support_result_refs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(224822);
|
|
632
|
+
/* harmony import */ var _api_message_content__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(509104);
|
|
633
|
+
/* harmony import */ var _lib_agents_transcript_draft__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(587627);
|
|
634
|
+
/**
|
|
635
|
+
* @public — `POST /api/v1/threads/[thread_id]/run` (submit run),
|
|
636
|
+
* `GET /api/v1/threads/[thread_id]/run` (subscribe via SSE)
|
|
637
|
+
*
|
|
638
|
+
* Agent execution endpoint. Submit a run, then stream tokens, tool
|
|
639
|
+
* calls, and final state. The split-and-subscribe shape lets reconnects
|
|
640
|
+
* pick up an in-flight stream. See `docs/api.md`.
|
|
641
|
+
*/
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
const enc = new TextEncoder();
|
|
659
|
+
const sse = (obj)=>enc.encode(`data: ${JSON.stringify(obj)}\n\n`);
|
|
660
|
+
function estimateUtf8Bytes(text) {
|
|
661
|
+
return enc.encode(text).byteLength;
|
|
1046
662
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
if (!prepareResult) {
|
|
1053
|
-
res.statusCode = 400;
|
|
1054
|
-
res.end('Bad Request');
|
|
1055
|
-
ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());
|
|
1056
|
-
return null;
|
|
663
|
+
function estimatePayloadBytes(payload) {
|
|
664
|
+
try {
|
|
665
|
+
return estimateUtf8Bytes(JSON.stringify(payload));
|
|
666
|
+
} catch {
|
|
667
|
+
return 0;
|
|
1057
668
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
return null;
|
|
669
|
+
}
|
|
670
|
+
function spilledToolResultBytes(payload) {
|
|
671
|
+
return (0,_lib_tools_support_result_refs__WEBPACK_IMPORTED_MODULE_11__/* .parseToolResultReferenceEnvelope */ .SE)(payload)?.bytes ?? 0;
|
|
672
|
+
}
|
|
673
|
+
function persistRunErrorMarker(thread_id, src) {
|
|
674
|
+
const raw = (src.errorMessage ?? "").trim();
|
|
675
|
+
const message = raw.length > 0 ? raw : "run failed";
|
|
676
|
+
// Cap the persisted body so a stack trace can't bloat the row.
|
|
677
|
+
const truncated = message.length > 2048 ? message.slice(0, 2045) + "…" : message;
|
|
678
|
+
const metadata = {
|
|
679
|
+
kind: "run_error",
|
|
680
|
+
code: src.errorCode ?? "run_crashed"
|
|
1071
681
|
};
|
|
1072
|
-
if (
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
throw new next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError();
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
682
|
+
if (src.errorCredentialId) metadata.credential_id = src.errorCredentialId;
|
|
683
|
+
if (src.errorProvider) metadata.provider = src.errorProvider;
|
|
684
|
+
if (src.routeDecision) metadata.routing = src.routeDecision;
|
|
685
|
+
try {
|
|
686
|
+
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .addMessage */ .tj)(thread_id, "assistant", truncated, null, "run_error", metadata, "failed", (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)(src.errorCode));
|
|
687
|
+
} catch (err) {
|
|
688
|
+
console.error("[run] failed to persist run_error marker", err);
|
|
1082
689
|
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
690
|
+
}
|
|
691
|
+
// `attachments` and `stream_options` are passed through to prepareThreadRun
|
|
692
|
+
// which does its own structural handling — keep loose at this boundary.
|
|
693
|
+
const RunBody = zod__WEBPACK_IMPORTED_MODULE_14__/* .object */ .Ikc({
|
|
694
|
+
message: zod__WEBPACK_IMPORTED_MODULE_14__/* .string */ .YjP(),
|
|
695
|
+
attachments: zod__WEBPACK_IMPORTED_MODULE_14__/* .array */ .YOg(zod__WEBPACK_IMPORTED_MODULE_14__/* .unknown */ .L5J()).optional(),
|
|
696
|
+
stream_options: zod__WEBPACK_IMPORTED_MODULE_14__/* .unknown */ .L5J().optional(),
|
|
697
|
+
message_metadata: zod__WEBPACK_IMPORTED_MODULE_14__/* .strictObject */ .rej({
|
|
698
|
+
hidden_from_chat: zod__WEBPACK_IMPORTED_MODULE_14__/* .boolean */ .zMY()
|
|
699
|
+
}).optional(),
|
|
700
|
+
// ADR-0096 — exact first-hot message seq; null clears the pin.
|
|
701
|
+
hot_since_seq: zod__WEBPACK_IMPORTED_MODULE_14__/* .number */ .aig().int().positive().nullable().optional(),
|
|
702
|
+
// ADR-0044 — automation channels the chat panel's filter toolbar has
|
|
703
|
+
// toggled on for this turn (scheduled_task/watcher/bridge). "chat" is
|
|
704
|
+
// unioned in server-side regardless of what the client sends, so callers
|
|
705
|
+
// don't have to remember to include it. Omitted = today's chat-only scope.
|
|
706
|
+
channels: zod__WEBPACK_IMPORTED_MODULE_14__/* .array */ .YOg(zod__WEBPACK_IMPORTED_MODULE_14__/* .string */ .YjP()).optional()
|
|
707
|
+
});
|
|
708
|
+
// POST is the *command* half of the run lifecycle (ADR-0008). It accepts the
|
|
709
|
+
// new user message, registers a run in the in-memory registry, kicks the
|
|
710
|
+
// agent loop off in a detached async task, and returns 202 after the user
|
|
711
|
+
// transcript is durable. The
|
|
712
|
+
// caller must follow up with a GET on this same path (as an `EventSource`)
|
|
713
|
+
// to subscribe to the chunk stream — see GET below.
|
|
714
|
+
//
|
|
715
|
+
// Splitting submit from subscribe gives us a single reliable streaming
|
|
716
|
+
// primitive across all browsers (EventSource is the only WebKit-native
|
|
717
|
+
// streaming API that survives iOS Safari + Tailscale HTTP/2 proxies). It
|
|
718
|
+
// also collapses what was previously a WS sidecar + SSE-over-POST +
|
|
719
|
+
// SSE-GET-reattach trio into one transport.
|
|
720
|
+
async function POST(req, { params }) {
|
|
721
|
+
const { thread_id } = await params;
|
|
722
|
+
const parsed = await (0,_lib_api_responses__WEBPACK_IMPORTED_MODULE_7__/* .validateBody */ .Jb)(req, RunBody);
|
|
723
|
+
if (parsed instanceof next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse) return parsed;
|
|
724
|
+
const message = parsed.message;
|
|
725
|
+
const attachments = parsed.attachments;
|
|
726
|
+
const stream_options = parsed.stream_options;
|
|
727
|
+
if (typeof parsed.hot_since_seq === "number" && !(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .isValidThreadContextCursor */ .m9)(thread_id, parsed.hot_since_seq)) {
|
|
728
|
+
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
729
|
+
error: "Boundary seq does not belong to this thread",
|
|
730
|
+
code: "invalid_boundary"
|
|
731
|
+
}, {
|
|
732
|
+
status: 400
|
|
733
|
+
});
|
|
1088
734
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
735
|
+
const hot_since_seq = parsed.hot_since_seq;
|
|
736
|
+
const channels = parsed.channels ? Array.from(new Set([
|
|
737
|
+
"chat",
|
|
738
|
+
...parsed.channels
|
|
739
|
+
])) : undefined;
|
|
740
|
+
// Per-thread priority queue (lib/agents/run-queue.ts). Every entry point
|
|
741
|
+
// that drives an agent on a thread goes through this — HTTP POST,
|
|
742
|
+
// scheduler, watcher, trigger, bridge — so concurrent fires on the same
|
|
743
|
+
// thread_id serialises instead of racing the LangGraph checkpoint store;
|
|
744
|
+
// interactive work runs before waiting background work without preemption.
|
|
745
|
+
// If the queue is already at the soft cap, reject with 503 so the
|
|
746
|
+
// caller can back off rather than pin yet more work in memory.
|
|
747
|
+
const thread = (0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .getThread */ .fG)(thread_id);
|
|
748
|
+
if (!thread) {
|
|
749
|
+
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
750
|
+
error: "Thread not found",
|
|
751
|
+
code: "thread_not_found"
|
|
752
|
+
}, {
|
|
753
|
+
status: 404
|
|
1097
754
|
});
|
|
1098
755
|
}
|
|
1099
|
-
const
|
|
1100
|
-
const
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
experimental: {
|
|
1111
|
-
authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
|
|
1112
|
-
useCacheTimeout: nextConfig.experimental.useCacheTimeout,
|
|
1113
|
-
durableUseCacheEntries: Boolean(nextConfig.experimental.durableUseCacheEntries)
|
|
1114
|
-
},
|
|
1115
|
-
cacheComponents: Boolean(nextConfig.cacheComponents),
|
|
1116
|
-
validationLevel: nextConfig.experimental.instantInsights.validationLevel,
|
|
1117
|
-
isDraftMode,
|
|
1118
|
-
incrementalCache,
|
|
1119
|
-
hmrRefreshHash: (0,next_dist_server_request_meta__WEBPACK_IMPORTED_MODULE_3__.getRequestMeta)(req, 'hmrRefreshHash'),
|
|
1120
|
-
cacheLifeProfiles: nextConfig.cacheLife,
|
|
1121
|
-
staticPageGenerationTimeout: nextConfig.staticPageGenerationTimeout,
|
|
1122
|
-
waitUntil: ctx.waitUntil,
|
|
1123
|
-
onClose: (cb)=>{
|
|
1124
|
-
res.on('close', cb);
|
|
1125
|
-
},
|
|
1126
|
-
onAfterTaskError: undefined
|
|
1127
|
-
},
|
|
1128
|
-
sharedContext: {
|
|
1129
|
-
buildId,
|
|
1130
|
-
deploymentId
|
|
1131
|
-
}
|
|
756
|
+
const pinnedModelConfigName = (0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .snapshotThreadModelConfigName */ .Fd)(thread_id);
|
|
757
|
+
const contextProfile = (0,_lib_agents_turn_profile__WEBPACK_IMPORTED_MODULE_8__/* .resolveTurnProfile */ .LJ)("user");
|
|
758
|
+
const enqueuedAt = Date.now();
|
|
759
|
+
let position;
|
|
760
|
+
let releaseAdmission;
|
|
761
|
+
const admission = new Promise((resolve)=>{
|
|
762
|
+
releaseAdmission = resolve;
|
|
763
|
+
});
|
|
764
|
+
let persistedTurn = null;
|
|
765
|
+
const assistantDraftState = {
|
|
766
|
+
current: null
|
|
1132
767
|
};
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
768
|
+
try {
|
|
769
|
+
({ position } = (0,_lib_agents_run_queue__WEBPACK_IMPORTED_MODULE_4__/* .enqueueThreadRun */ .M6)(thread_id, "user", async ()=>{
|
|
770
|
+
if (!await admission) return;
|
|
771
|
+
const admittedTurn = persistedTurn;
|
|
772
|
+
if (!admittedTurn) return;
|
|
773
|
+
// startRun is called once it's our turn so the registry only ever
|
|
774
|
+
// holds one active entry per thread at a time. Subscribers that
|
|
775
|
+
// attach via GET before our turn comes will see no run yet and the
|
|
776
|
+
// SSE handler emits a synthetic done — the client reopens the
|
|
777
|
+
// EventSource and picks up the stream once we're running.
|
|
778
|
+
const active = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .startRun */ .AD)(thread_id, thread?.agent_id ?? null);
|
|
779
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
780
|
+
type: "status",
|
|
781
|
+
data: {
|
|
782
|
+
phase: "starting",
|
|
783
|
+
label: "Starting…"
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
const runStartedAt = Date.now();
|
|
787
|
+
const queueWaitMs = Math.max(0, runStartedAt - enqueuedAt);
|
|
788
|
+
const perfTelemetryEnabled = (0,_lib_env_config__WEBPACK_IMPORTED_MODULE_10__/* .getConfig */ .z)().perfTelemetryEnabled;
|
|
789
|
+
let prepDurationMs = 0;
|
|
790
|
+
let ttftMs = null;
|
|
791
|
+
let streamDurationMs = 0;
|
|
792
|
+
const toolsUsed = new Set();
|
|
793
|
+
let prepared;
|
|
794
|
+
try {
|
|
795
|
+
const activatedUserMessage = (0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .updateMessageContent */ .e8)(admittedTurn.userMessageId, admittedTurn.storedContent, {
|
|
796
|
+
transcriptStatus: "completed"
|
|
797
|
+
});
|
|
798
|
+
if (!activatedUserMessage) throw new Error("Submitted user message no longer exists");
|
|
799
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
800
|
+
type: "status",
|
|
801
|
+
data: {
|
|
802
|
+
phase: "preparing",
|
|
803
|
+
label: "Preparing context…"
|
|
804
|
+
}
|
|
805
|
+
});
|
|
806
|
+
const prepStartedAt = Date.now();
|
|
807
|
+
prepared = await (0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .prepareThreadRun */ .fn)({
|
|
808
|
+
thread_id,
|
|
809
|
+
message,
|
|
810
|
+
options: stream_options,
|
|
811
|
+
attachments: admittedTurn.attachments,
|
|
812
|
+
signal: active.abort.signal,
|
|
813
|
+
hot_since_seq,
|
|
814
|
+
channels,
|
|
815
|
+
context_profile: contextProfile,
|
|
816
|
+
_pinned_model_config_name: pinnedModelConfigName,
|
|
817
|
+
_onCompacting: ()=>(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
818
|
+
type: "status",
|
|
819
|
+
data: {
|
|
820
|
+
phase: "compacting",
|
|
821
|
+
label: "Compacting earlier messages…"
|
|
822
|
+
}
|
|
823
|
+
}),
|
|
824
|
+
_user_message_persisted: true,
|
|
825
|
+
_idle_ms_before_user: admittedTurn.idleMsBefore
|
|
826
|
+
});
|
|
827
|
+
prepDurationMs = Date.now() - prepStartedAt;
|
|
828
|
+
} catch (err) {
|
|
829
|
+
// Prep failure (unknown agent, model misconfig, …). With queueing
|
|
830
|
+
// the HTTP request has already returned 202, so the error has to
|
|
831
|
+
// surface as an SSE chunk to any attached subscriber. There may
|
|
832
|
+
// be no subscriber if the GET hasn't connected yet — the chunk
|
|
833
|
+
// is buffered on the ActiveRun for the next attach.
|
|
834
|
+
const message_ = err instanceof _lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .RunThreadError */ .op ? err.message : String(err);
|
|
835
|
+
const code = err instanceof _lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .RunThreadError */ .op ? err.code : "run_prepare_error";
|
|
836
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
837
|
+
type: "error",
|
|
838
|
+
data: {
|
|
839
|
+
message: message_,
|
|
840
|
+
code
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
const draft = assistantDraftState.current;
|
|
844
|
+
if (draft) {
|
|
845
|
+
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .updateMessageContent */ .e8)(draft.msg_id, draft.visibleContent, {
|
|
846
|
+
category: "run_error",
|
|
847
|
+
transcriptStatus: "failed",
|
|
848
|
+
statusReason: (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)(code)
|
|
849
|
+
});
|
|
850
|
+
} else {
|
|
851
|
+
persistRunErrorMarker(thread_id, {
|
|
852
|
+
errorMessage: message_,
|
|
853
|
+
errorCode: code
|
|
854
|
+
});
|
|
1154
855
|
}
|
|
856
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .finishRun */ .JH)(active, "error");
|
|
857
|
+
return;
|
|
1155
858
|
}
|
|
1156
|
-
|
|
1157
|
-
//
|
|
1158
|
-
//
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
859
|
+
// Drive the agent to completion regardless of client connection. Events
|
|
860
|
+
// go to the registry; the GET subscriber (and any reattaching clients)
|
|
861
|
+
// receive them via subscribe().
|
|
862
|
+
//
|
|
863
|
+
// CRITICAL: finishRun() MUST run no matter what — if it doesn't, the
|
|
864
|
+
// run is pinned as "running" forever and the TTL eviction (scheduled
|
|
865
|
+
// inside finishRun()) never fires, so a leaked entry never self-heals.
|
|
866
|
+
// Wrap the whole body in try/finally.
|
|
867
|
+
let terminal = "error";
|
|
868
|
+
let assistantContent = "";
|
|
869
|
+
let terminalErrorCode;
|
|
870
|
+
let inputTokens = null;
|
|
871
|
+
let outputTokens = null;
|
|
872
|
+
let cacheReadTokens = null;
|
|
873
|
+
let cacheCreateTokens = null;
|
|
874
|
+
let thinkingTokens = null;
|
|
875
|
+
let toolResultCount = 0;
|
|
876
|
+
let toolResultBytes = 0;
|
|
877
|
+
let toolResultBytesSpilled = 0;
|
|
878
|
+
try {
|
|
879
|
+
const startedAt = Date.now();
|
|
880
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
881
|
+
type: "status",
|
|
882
|
+
data: {
|
|
883
|
+
phase: "thinking",
|
|
884
|
+
label: "Thinking…"
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
const streamStartedAt = Date.now();
|
|
888
|
+
const collected = await (0,_lib_agents_stream_collector__WEBPACK_IMPORTED_MODULE_15__/* .collectStream */ .V)(prepared.stream, {
|
|
889
|
+
onChunk: (chunk)=>{
|
|
890
|
+
if (ttftMs === null && chunk.type !== "heartbeat") {
|
|
891
|
+
ttftMs = Math.max(0, Date.now() - runStartedAt);
|
|
892
|
+
}
|
|
893
|
+
if (chunk.type === "tool_call") {
|
|
894
|
+
const toolName = chunk.data && typeof chunk.data.name === "string" ? chunk.data.name : "";
|
|
895
|
+
if (toolName) toolsUsed.add(toolName);
|
|
896
|
+
}
|
|
897
|
+
const draft = assistantDraftState.current;
|
|
898
|
+
if (draft) (0,_lib_agents_transcript_draft__WEBPACK_IMPORTED_MODULE_12__/* .persistAssistantDraftChunk */ .j)(draft, chunk);
|
|
899
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, chunk);
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
streamDurationMs = Date.now() - streamStartedAt;
|
|
903
|
+
assistantContent = collected.assistantContent;
|
|
904
|
+
terminal = collected.terminal;
|
|
905
|
+
terminalErrorCode = collected.errorCode;
|
|
906
|
+
if (collected.usage) {
|
|
907
|
+
inputTokens = collected.usage.input_tokens;
|
|
908
|
+
outputTokens = collected.usage.output_tokens;
|
|
909
|
+
cacheReadTokens = collected.usage.cache_read_input_tokens ?? 0;
|
|
910
|
+
cacheCreateTokens = collected.usage.cache_creation_input_tokens ?? 0;
|
|
911
|
+
thinkingTokens = collected.usage.thinking_tokens ?? null;
|
|
912
|
+
}
|
|
913
|
+
if (collected.toolEvents?.length) {
|
|
914
|
+
const resultEvents = collected.toolEvents.filter((ev)=>ev.phase === "result");
|
|
915
|
+
toolResultCount = resultEvents.length;
|
|
916
|
+
toolResultBytes = resultEvents.reduce((sum, ev)=>sum + estimatePayloadBytes(ev.payload), 0);
|
|
917
|
+
toolResultBytesSpilled = resultEvents.reduce((sum, ev)=>sum + spilledToolResultBytes(ev.payload), 0);
|
|
918
|
+
}
|
|
919
|
+
const routeDecision = (0,_lib_agents_model_router__WEBPACK_IMPORTED_MODULE_9__/* .finalizeRouteDecision */ .Kp)(collected.routeDecision ?? prepared.route_decision ?? null, {
|
|
920
|
+
durationMs: Date.now() - startedAt,
|
|
921
|
+
terminal: collected.terminal,
|
|
922
|
+
errorCode: collected.errorCode,
|
|
923
|
+
retryCount: collected.routeDecision?.retry_count ?? prepared.route_decision?.retry_count ?? 0
|
|
924
|
+
});
|
|
925
|
+
// If the stream threw mid-iteration, collectStream returns terminal="error"
|
|
926
|
+
// but no `error` chunk was broadcast — surface one to subscribers. Skip
|
|
927
|
+
// when the run was deliberately aborted: llm.ts already emitted an
|
|
928
|
+
// `error{code:"aborted"}` chunk for that path and re-broadcasting as
|
|
929
|
+
// `stream_error` would mask the intent.
|
|
930
|
+
if (collected.terminal === "error" && collected.errorMessage && !collected.aborted) {
|
|
931
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
932
|
+
type: "error",
|
|
933
|
+
data: {
|
|
934
|
+
message: collected.errorMessage,
|
|
935
|
+
code: "stream_error"
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
try {
|
|
940
|
+
// On a user abort (Stop / steer), append the interrupt footer so
|
|
941
|
+
// the partial reply is never silently dropped and the next agent
|
|
942
|
+
// turn sees a clear marker explaining the cut. withInterruptMarker
|
|
943
|
+
// returns the bare marker when the partial is empty, which forces
|
|
944
|
+
// persistAssistantMessage past its skip-empty guard so the thread
|
|
945
|
+
// always has a row recording what happened.
|
|
946
|
+
const contentToPersist = collected.aborted ? (0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .withInterruptMarker */ .IC)(collected.assistantContent) : collected.assistantContent;
|
|
947
|
+
const noResponse = collected.terminal === "done" && !collected.aborted && !contentToPersist.trim() && !collected.toolEvents.length && !prepared.signal_delivery?.signals.length;
|
|
948
|
+
const transcriptStatus = collected.aborted ? "interrupted" : collected.terminal === "done" && !noResponse ? "completed" : "failed";
|
|
949
|
+
const statusReason = transcriptStatus === "interrupted" ? "Stopped by user." : noResponse ? "The model completed without producing a response." : transcriptStatus === "failed" ? (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)(collected.errorCode) : null;
|
|
950
|
+
const draft = assistantDraftState.current;
|
|
951
|
+
(0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .persistAssistantMessage */ ._w)(thread_id, contentToPersist, collected.usedTools, collected.toolEvents, null, collected.usage ?? null, prepared.context_snapshot ?? null, prepared.source_manifest ?? null, routeDecision, prepared.memory_recall ? {
|
|
952
|
+
memory_recall: prepared.memory_recall
|
|
953
|
+
} : null, collected.terminal === "done" && !collected.aborted ? prepared.signal_delivery : undefined, draft ? {
|
|
954
|
+
draftMessageId: draft.msg_id,
|
|
955
|
+
transcriptStatus,
|
|
956
|
+
statusReason
|
|
957
|
+
} : undefined);
|
|
958
|
+
// If the turn failed AND persistAssistantMessage skipped writing
|
|
959
|
+
// a row (no content + no tool events + not aborted), persist a
|
|
960
|
+
// synthetic `run_error` marker so the failure survives reload
|
|
961
|
+
// and cross-device sync. history-window filters these rows out
|
|
962
|
+
// of the LLM budget; the UI renders them as a compact chip.
|
|
963
|
+
// See ADR-0069.
|
|
964
|
+
if (terminal === "error" && !collected.aborted && !collected.assistantContent.trim() && (!collected.toolEvents || collected.toolEvents.length === 0) && !assistantDraftState.current) {
|
|
965
|
+
persistRunErrorMarker(thread_id, {
|
|
966
|
+
...collected,
|
|
967
|
+
routeDecision
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
// Steering queued during the FINAL model call never reaches
|
|
971
|
+
// preModelHook — the react graph goes straight to END once the
|
|
972
|
+
// model stops emitting tool calls. Those messages are already in
|
|
973
|
+
// the transcript, so run a continuation rather than dropping them
|
|
974
|
+
// (ADR-0080). Skipped on abort: the user cancelled deliberately.
|
|
975
|
+
if (!collected.aborted) {
|
|
976
|
+
const undelivered = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .drainSteering */ .QK)(thread_id);
|
|
977
|
+
if (undelivered.length > 0) {
|
|
978
|
+
void (0,_lib_agents_agent_turn__WEBPACK_IMPORTED_MODULE_3__.runAgentTurn)({
|
|
979
|
+
thread_id,
|
|
980
|
+
queue_source: "user",
|
|
981
|
+
message: undelivered.join("\n\n"),
|
|
982
|
+
skip_persist_user_message: true,
|
|
983
|
+
history_append_message: STEERING_CONTINUATION_PREFIX + undelivered.join("\n\n")
|
|
984
|
+
}).catch((err)=>console.error("[run] steering continuation failed", err));
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
} catch (persistErr) {
|
|
988
|
+
terminal = "error";
|
|
989
|
+
const draft = assistantDraftState.current;
|
|
990
|
+
if (draft && (0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .getThreadMessageBySeq */ .wc)(thread_id, draft.seq)?.transcript_status === "in_progress") {
|
|
991
|
+
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .updateMessageContent */ .e8)(draft.msg_id, draft.visibleContent, {
|
|
992
|
+
transcriptStatus: "failed",
|
|
993
|
+
statusReason: (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)("persist_error")
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
997
|
+
type: "error",
|
|
998
|
+
data: {
|
|
999
|
+
message: `persist failed: ${persistErr.message}`,
|
|
1000
|
+
code: "persist_error"
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
} catch (err) {
|
|
1005
|
+
terminal = "error";
|
|
1006
|
+
const errMsg = err.message ?? String(err);
|
|
1007
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .broadcast */ .mq)(active, {
|
|
1008
|
+
type: "error",
|
|
1009
|
+
data: {
|
|
1010
|
+
message: errMsg,
|
|
1011
|
+
code: "run_crashed"
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
// Same marker semantics as above but for the outer crash path — the
|
|
1015
|
+
// stream threw before collectStream could emit an error chunk.
|
|
1016
|
+
try {
|
|
1017
|
+
const draft = assistantDraftState.current;
|
|
1018
|
+
if (draft && (0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .getThreadMessageBySeq */ .wc)(thread_id, draft.seq)?.transcript_status === "in_progress") {
|
|
1019
|
+
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .updateMessageContent */ .e8)(draft.msg_id, draft.visibleContent, {
|
|
1020
|
+
category: draft.visibleContent ? null : "run_error",
|
|
1021
|
+
transcriptStatus: "failed",
|
|
1022
|
+
statusReason: (0,_api_message_content__WEBPACK_IMPORTED_MODULE_13__/* .safeTranscriptFailureReason */ .U)("run_crashed")
|
|
1023
|
+
});
|
|
1024
|
+
} else if (!draft) {
|
|
1025
|
+
persistRunErrorMarker(thread_id, {
|
|
1026
|
+
errorMessage: errMsg,
|
|
1027
|
+
errorCode: "run_crashed",
|
|
1028
|
+
routeDecision: prepared.route_decision ?? null
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
} catch (persistErr) {
|
|
1032
|
+
console.error("[run] failed to persist run_error marker", persistErr);
|
|
1165
1033
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1034
|
+
} finally{
|
|
1035
|
+
if (perfTelemetryEnabled) {
|
|
1036
|
+
const totalMs = Math.max(0, Date.now() - runStartedAt);
|
|
1037
|
+
const ttftValue = ttftMs ?? totalMs;
|
|
1038
|
+
const toolList = Array.from(toolsUsed).join(",") || "none";
|
|
1039
|
+
const assistantChars = assistantContent.length;
|
|
1040
|
+
const assistantBytes = estimateUtf8Bytes(assistantContent);
|
|
1041
|
+
const inTok = inputTokens ?? -1;
|
|
1042
|
+
const outTok = outputTokens ?? -1;
|
|
1043
|
+
const cacheRead = cacheReadTokens ?? -1;
|
|
1044
|
+
const cacheCreate = cacheCreateTokens ?? -1;
|
|
1045
|
+
const cacheDenom = Math.max(0, inTok) + Math.max(0, cacheRead) + Math.max(0, cacheCreate);
|
|
1046
|
+
const cacheReadPct = cacheDenom > 0 && cacheRead >= 0 ? Math.round(cacheRead / cacheDenom * 1000) / 10 : -1;
|
|
1047
|
+
console.info(`[perf.run] thread=${thread_id} status=${terminal}` + ` queue_ms=${queueWaitMs}` + ` prep_ms=${prepDurationMs}` + ` ttft_ms=${ttftValue}` + ` stream_ms=${streamDurationMs}` + ` total_ms=${totalMs}` + ` input_tokens=${inTok}` + ` output_tokens=${outTok}` + ` cache_read_tokens=${cacheRead}` + ` cache_create_tokens=${cacheCreate}` + ` cache_read_pct=${cacheReadPct}` + ` thinking_tokens=${thinkingTokens ?? -1}` + ` assistant_chars=${assistantChars}` + ` assistant_bytes=${assistantBytes}` + ` tool_results=${toolResultCount}` + ` tool_result_bytes=${toolResultBytes}` + ` tool_result_bytes_spilled=${toolResultBytesSpilled}` + ` tools=${toolList}` + ` error_code=${terminalErrorCode ?? "-"}`);
|
|
1168
1048
|
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
// Create the cache entry for the response.
|
|
1179
|
-
const cacheEntry = {
|
|
1180
|
-
value: {
|
|
1181
|
-
kind: next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE,
|
|
1182
|
-
status: response.status,
|
|
1183
|
-
body: Buffer.from(await blob.arrayBuffer()),
|
|
1184
|
-
headers
|
|
1185
|
-
},
|
|
1186
|
-
cacheControl: {
|
|
1187
|
-
revalidate,
|
|
1188
|
-
expire
|
|
1189
|
-
}
|
|
1190
|
-
};
|
|
1191
|
-
return cacheEntry;
|
|
1192
|
-
} else {
|
|
1193
|
-
// send response without caching if not ISR
|
|
1194
|
-
await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, response, pendingWaitUntil);
|
|
1195
|
-
return null;
|
|
1049
|
+
(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .finishRun */ .JH)(active, terminal);
|
|
1050
|
+
(0,_lib_notifications_bus__WEBPACK_IMPORTED_MODULE_6__/* .publish */ .mk)({
|
|
1051
|
+
type: "run_completed",
|
|
1052
|
+
thread_id,
|
|
1053
|
+
agent_id: thread?.agent_id ?? null,
|
|
1054
|
+
status: terminal,
|
|
1055
|
+
preview: assistantContent.replace(/\s+/g, " ").trim().slice(0, 120),
|
|
1056
|
+
ts: Date.now()
|
|
1057
|
+
});
|
|
1196
1058
|
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1059
|
+
}));
|
|
1060
|
+
} catch (err) {
|
|
1061
|
+
if (err instanceof _lib_agents_run_queue__WEBPACK_IMPORTED_MODULE_4__/* .QueueFullError */ .Zm) {
|
|
1062
|
+
return new Response(JSON.stringify({
|
|
1063
|
+
accepted: false,
|
|
1064
|
+
code: "queue_full",
|
|
1065
|
+
thread_id,
|
|
1066
|
+
error: err.message
|
|
1067
|
+
}), {
|
|
1068
|
+
status: 503,
|
|
1069
|
+
headers: {
|
|
1070
|
+
"Content-Type": "application/json"
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
throw err;
|
|
1075
|
+
}
|
|
1076
|
+
try {
|
|
1077
|
+
persistedTurn = await (0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .persistThreadRunUserMessage */ .Ie)({
|
|
1078
|
+
thread_id,
|
|
1079
|
+
message,
|
|
1080
|
+
attachments,
|
|
1081
|
+
message_metadata: parsed.message_metadata,
|
|
1082
|
+
context_profile: contextProfile,
|
|
1083
|
+
_onTranscriptUserPersisted: ()=>{
|
|
1084
|
+
assistantDraftState.current = (0,_lib_agents_transcript_draft__WEBPACK_IMPORTED_MODULE_12__/* .createAssistantTranscriptDraft */ .q)(thread_id);
|
|
1211
1085
|
}
|
|
1212
|
-
|
|
1086
|
+
});
|
|
1087
|
+
releaseAdmission(true);
|
|
1088
|
+
} catch (err) {
|
|
1089
|
+
releaseAdmission(false);
|
|
1090
|
+
if (err instanceof _lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .RunThreadError */ .op) {
|
|
1091
|
+
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
1092
|
+
error: err.message,
|
|
1093
|
+
code: err.code
|
|
1094
|
+
}, {
|
|
1095
|
+
status: err.status
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
console.error("[run] failed to persist submitted user message", err);
|
|
1099
|
+
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
1100
|
+
error: "Failed to persist submitted user message",
|
|
1101
|
+
code: "transcript_persist_failed"
|
|
1102
|
+
}, {
|
|
1103
|
+
status: 500
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
return new Response(JSON.stringify({
|
|
1107
|
+
accepted: true,
|
|
1108
|
+
thread_id,
|
|
1109
|
+
queue_position: position
|
|
1110
|
+
}), {
|
|
1111
|
+
status: 202,
|
|
1112
|
+
headers: {
|
|
1113
|
+
"Content-Type": "application/json"
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
// GET is the *query* half of the run lifecycle (ADR-0008). Attaches to an
|
|
1118
|
+
// active (or recently-finished, within the registry TTL) run and streams
|
|
1119
|
+
// chunks as Server-Sent Events. Always consumed client-side via
|
|
1120
|
+
// `EventSource` — never `fetch().body.getReader()`, which is unreliable on
|
|
1121
|
+
// iOS Safari for long-lived streaming responses.
|
|
1122
|
+
//
|
|
1123
|
+
// Emits a single synthetic `done` event and closes when there's no run to
|
|
1124
|
+
// attach to (run never existed, or it finished + TTL-evicted before the GET
|
|
1125
|
+
// arrived). We deliberately do NOT return 404 here: browsers map a 404 SSE
|
|
1126
|
+
// response onto `EventSource.onerror` with no terminal event, which trips
|
|
1127
|
+
// EventSource's auto-reconnect logic and leaves the client in a "stream
|
|
1128
|
+
// open but silent" state — UIs gating on a `done` event hang forever
|
|
1129
|
+
// showing the Stop/Reconnecting affordances. A 200 with `data: {"type":
|
|
1130
|
+
// "done"}\n\n` makes the iterator drain cleanly on every transport.
|
|
1131
|
+
//
|
|
1132
|
+
// `show_tools` / `show_thinking` query params let the caller suppress
|
|
1133
|
+
// chunk types it doesn't want to render. Defaults: both on. The full
|
|
1134
|
+
// `StreamOptions` shape is only meaningful on the POST (tool policy &
|
|
1135
|
+
// agent run config are run-wide settings, not per-subscriber filters).
|
|
1136
|
+
async function GET(req, { params }) {
|
|
1137
|
+
const { thread_id } = await params;
|
|
1138
|
+
const showTools = req.nextUrl.searchParams.get("show_tools") !== "false";
|
|
1139
|
+
const showThinking = req.nextUrl.searchParams.get("show_thinking") !== "false";
|
|
1140
|
+
const awaitContinuation = req.nextUrl.searchParams.get("await_continuation") === "true";
|
|
1141
|
+
const stream_options = {
|
|
1142
|
+
filters: {
|
|
1143
|
+
include_tools: showTools,
|
|
1144
|
+
include_thinking: showThinking
|
|
1213
1145
|
}
|
|
1214
1146
|
};
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
// we don't create a cacheEntry for ISR
|
|
1237
|
-
if (!isIsr) {
|
|
1238
|
-
return;
|
|
1239
|
-
}
|
|
1240
|
-
if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== next_dist_server_response_cache__WEBPACK_IMPORTED_MODULE_17__.CachedRouteKind.APP_ROUTE) {
|
|
1241
|
-
var _cacheEntry_value1;
|
|
1242
|
-
throw new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`);
|
|
1243
|
-
}
|
|
1244
|
-
if (!isMinimalMode) {
|
|
1245
|
-
res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');
|
|
1246
|
-
}
|
|
1247
|
-
// Draft mode should never be cached
|
|
1248
|
-
if (isDraftMode) {
|
|
1249
|
-
res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
|
|
1250
|
-
}
|
|
1251
|
-
const headers = (0,next_dist_server_web_utils__WEBPACK_IMPORTED_MODULE_12__.fromNodeOutgoingHttpHeaders)(cacheEntry.value.headers);
|
|
1252
|
-
if (!(isMinimalMode && isIsr)) {
|
|
1253
|
-
headers.delete(next_dist_lib_constants__WEBPACK_IMPORTED_MODULE_14__.NEXT_CACHE_TAGS_HEADER);
|
|
1254
|
-
}
|
|
1255
|
-
// If cache control is already set on the response we don't
|
|
1256
|
-
// override it to allow users to customize it via next.config
|
|
1257
|
-
if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {
|
|
1258
|
-
headers.set('Cache-Control', (0,next_dist_server_lib_cache_control__WEBPACK_IMPORTED_MODULE_13__.getCacheControlHeader)(cacheEntry.cacheControl));
|
|
1259
|
-
}
|
|
1260
|
-
await (0,next_dist_server_send_response__WEBPACK_IMPORTED_MODULE_11__/* .sendResponse */ .I)(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.
|
|
1261
|
-
new Response(cacheEntry.value.body, {
|
|
1262
|
-
headers,
|
|
1263
|
-
status: cacheEntry.value.status || 200
|
|
1264
|
-
}));
|
|
1265
|
-
return;
|
|
1266
|
-
} catch (err) {
|
|
1267
|
-
if (!(err instanceof next_dist_shared_lib_no_fallback_error_external__WEBPACK_IMPORTED_MODULE_15__.NoFallbackError)) {
|
|
1268
|
-
const silenceLog = false;
|
|
1269
|
-
await routeModule.onRequestError(req, err, {
|
|
1270
|
-
routerKind: 'App Router',
|
|
1271
|
-
routePath: normalizedSrcPage,
|
|
1272
|
-
routeType: 'route',
|
|
1273
|
-
revalidateReason: (0,next_dist_server_instrumentation_utils__WEBPACK_IMPORTED_MODULE_10__.getRevalidateReason)({
|
|
1274
|
-
isStaticGeneration: cacheKey !== null,
|
|
1275
|
-
isOnDemandRevalidate
|
|
1276
|
-
})
|
|
1277
|
-
}, silenceLog, routerServerContext);
|
|
1278
|
-
}
|
|
1279
|
-
// rethrow so that we can handle serving error page
|
|
1280
|
-
// If this is during static generation, throw the error again.
|
|
1281
|
-
if (isIsr) throw err;
|
|
1282
|
-
// Otherwise, send a 500 response unless the original response has
|
|
1283
|
-
// already committed. In that case, preserve its status code for
|
|
1284
|
-
// telemetry while still recording the failure and terminating a response
|
|
1285
|
-
// that the failed pipeline left open.
|
|
1286
|
-
if (res.headersSent) {
|
|
1287
|
-
if (currentSpan) {
|
|
1288
|
-
const error = err instanceof Error ? err : new Error('Unknown app route error');
|
|
1289
|
-
currentSpan.recordException(error);
|
|
1290
|
-
currentSpan.setStatus({
|
|
1291
|
-
code: next_dist_server_lib_trace_tracer__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR,
|
|
1292
|
-
message: error.message
|
|
1293
|
-
});
|
|
1294
|
-
currentSpan.setAttribute('error.type', error.name);
|
|
1147
|
+
const run = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .getRun */ .Mh)(thread_id);
|
|
1148
|
+
if (!run || awaitContinuation && run.status !== "running") {
|
|
1149
|
+
// Cold attach. If the per-thread queue already has work pending
|
|
1150
|
+
// (typical when the chat is reopened just after firing a scheduled
|
|
1151
|
+
// task / watcher / bridge turn — the request was enqueued via
|
|
1152
|
+
// Next's `after()` and hasn't reached `startRun` yet), hold the SSE
|
|
1153
|
+
// open briefly so we don't return a synthetic `done` for a run
|
|
1154
|
+
// that's about to register. If nothing appears in time, fall
|
|
1155
|
+
// through to the same `done`-and-close path as a truly idle thread.
|
|
1156
|
+
const queued = (0,_lib_agents_run_queue__WEBPACK_IMPORTED_MODULE_4__.getQueueDepth)(thread_id) > 0 ? await (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .waitForRun */ .Cs)(thread_id, 5000) : null;
|
|
1157
|
+
if (!queued) {
|
|
1158
|
+
const stream = new ReadableStream({
|
|
1159
|
+
start (controller) {
|
|
1160
|
+
try {
|
|
1161
|
+
controller.enqueue(sse({
|
|
1162
|
+
type: "done"
|
|
1163
|
+
}));
|
|
1164
|
+
} catch {}
|
|
1165
|
+
try {
|
|
1166
|
+
controller.close();
|
|
1167
|
+
} catch {}
|
|
1295
1168
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1169
|
+
});
|
|
1170
|
+
return (0,_lib_api_sse__WEBPACK_IMPORTED_MODULE_16__/* .sseResponse */ .t)(stream);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return attachStream(thread_id, stream_options);
|
|
1174
|
+
}
|
|
1175
|
+
const SteerBody = zod__WEBPACK_IMPORTED_MODULE_14__/* .object */ .Ikc({
|
|
1176
|
+
message: zod__WEBPACK_IMPORTED_MODULE_14__/* .string */ .YjP().min(1)
|
|
1177
|
+
});
|
|
1178
|
+
// The steering text is already the last user row in the transcript, so the
|
|
1179
|
+
// continuation only needs to explain why the agent is seeing it late.
|
|
1180
|
+
const STEERING_CONTINUATION_PREFIX = "↪ You finished the previous reply before reading this. The user said, while you were still writing:\n\n";
|
|
1181
|
+
// PATCH steers the currently-running agent: the message is queued and the
|
|
1182
|
+
// agent's preModelHook delivers it before the next model call, alongside the
|
|
1183
|
+
// tool results it should react to (ADR-0080). 409 means there was nothing to
|
|
1184
|
+
// steer, and the caller should submit a normal run instead.
|
|
1185
|
+
async function PATCH(req, { params }) {
|
|
1186
|
+
const { thread_id } = await params;
|
|
1187
|
+
const body = await (0,_lib_api_responses__WEBPACK_IMPORTED_MODULE_7__/* .validateBody */ .Jb)(req, SteerBody);
|
|
1188
|
+
if (body instanceof next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse) return body;
|
|
1189
|
+
if (!(0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .pushSteering */ .mx)(thread_id, body.message)) {
|
|
1190
|
+
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
1191
|
+
steered: false,
|
|
1192
|
+
reason: "no_active_run"
|
|
1193
|
+
}, {
|
|
1194
|
+
status: 409
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
// Persist only once the queue accepted it, so a 409 fallback to POST /run
|
|
1198
|
+
// doesn't write the same message twice.
|
|
1199
|
+
(0,_lib_stores_threads__WEBPACK_IMPORTED_MODULE_5__/* .addMessage */ .tj)(thread_id, "user", body.message);
|
|
1200
|
+
return next_server__WEBPACK_IMPORTED_MODULE_0__.NextResponse.json({
|
|
1201
|
+
steered: true
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
// DELETE aborts the currently-running agent for this thread. The agent stream
|
|
1205
|
+
// loop in llm.ts catches the resulting AbortError and emits a synthetic
|
|
1206
|
+
// `error` + `done` event pair so subscribers (and the client's queue-drain
|
|
1207
|
+
// hook) finish cleanly.
|
|
1208
|
+
async function DELETE(_req, { params }) {
|
|
1209
|
+
const { thread_id } = await params;
|
|
1210
|
+
const aborted = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .abortRun */ .KD)(thread_id, "user_interrupted");
|
|
1211
|
+
return new Response(JSON.stringify({
|
|
1212
|
+
aborted
|
|
1213
|
+
}), {
|
|
1214
|
+
status: aborted ? 200 : 404,
|
|
1215
|
+
headers: {
|
|
1216
|
+
"Content-Type": "application/json"
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
function attachStream(thread_id, stream_options) {
|
|
1221
|
+
// Captured by both start() and cancel() so the cancel branch can tear
|
|
1222
|
+
// down the poll timer + subscription when the client disconnects.
|
|
1223
|
+
// Without this, navigating away from a long-running thread leaks an
|
|
1224
|
+
// event subscriber + 2Hz setInterval per visit until the run finishes
|
|
1225
|
+
// (or forever if it doesn't).
|
|
1226
|
+
let poll = null;
|
|
1227
|
+
let unsubscribe = null;
|
|
1228
|
+
let clientGone = false;
|
|
1229
|
+
const stream = new ReadableStream({
|
|
1230
|
+
start (controller) {
|
|
1231
|
+
const safeEnqueue = (chunk)=>{
|
|
1232
|
+
if (clientGone) return;
|
|
1233
|
+
try {
|
|
1234
|
+
controller.enqueue(chunk);
|
|
1235
|
+
} catch {
|
|
1236
|
+
clientGone = true;
|
|
1298
1237
|
}
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1238
|
+
};
|
|
1239
|
+
const onEvent = (ev)=>{
|
|
1240
|
+
if (!(0,_lib_agents_run_thread__WEBPACK_IMPORTED_MODULE_1__/* .shouldEmitChunk */ .ib)(ev.type, stream_options)) return;
|
|
1241
|
+
safeEnqueue(sse({
|
|
1242
|
+
type: ev.type,
|
|
1243
|
+
...ev.data
|
|
1302
1244
|
}));
|
|
1245
|
+
};
|
|
1246
|
+
const sub = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .subscribe */ .B1)(thread_id, onEvent);
|
|
1247
|
+
unsubscribe = sub.unsubscribe;
|
|
1248
|
+
if (!sub.run) {
|
|
1249
|
+
try {
|
|
1250
|
+
controller.close();
|
|
1251
|
+
} catch {}
|
|
1252
|
+
return;
|
|
1303
1253
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
if (
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
if (rootSpanAttributes.get('next.span_type') !== next_dist_server_lib_trace_constants__WEBPACK_IMPORTED_MODULE_9__.BaseServerSpan.handleRequest) {
|
|
1331
|
-
console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);
|
|
1332
|
-
return;
|
|
1333
|
-
}
|
|
1334
|
-
const route = rootSpanAttributes.get('next.route') || normalizedSrcPage;
|
|
1335
|
-
const name = `${method} ${route}`;
|
|
1336
|
-
currentSpan.setAttributes({
|
|
1337
|
-
'next.route': route,
|
|
1338
|
-
'http.route': route,
|
|
1339
|
-
'next.span_name': name
|
|
1340
|
-
});
|
|
1341
|
-
currentSpan.updateName(name);
|
|
1342
|
-
// Propagate http.route to the request's root span if it isn't the
|
|
1343
|
-
// request span (e.g. a platform-created HTTP span in adapter
|
|
1344
|
-
// deployments).
|
|
1345
|
-
if (requestRootSpan && requestRootSpan !== currentSpan) {
|
|
1346
|
-
requestRootSpan.setAttribute('http.route', route);
|
|
1347
|
-
requestRootSpan.updateName(name);
|
|
1254
|
+
// If run already terminal, close after replay.
|
|
1255
|
+
if (sub.run.status !== "running") {
|
|
1256
|
+
try {
|
|
1257
|
+
controller.close();
|
|
1258
|
+
} catch {}
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
// When the run finishes (status changes), close our response. We
|
|
1262
|
+
// poll lightly because the run might finish due to other subscribers'
|
|
1263
|
+
// signals; simpler than wiring a second listener channel.
|
|
1264
|
+
poll = setInterval(()=>{
|
|
1265
|
+
const r = (0,_lib_agents_run_registry__WEBPACK_IMPORTED_MODULE_2__/* .getRun */ .Mh)(thread_id);
|
|
1266
|
+
if (!r || r.status !== "running") {
|
|
1267
|
+
if (poll) {
|
|
1268
|
+
clearInterval(poll);
|
|
1269
|
+
poll = null;
|
|
1270
|
+
}
|
|
1271
|
+
if (unsubscribe) {
|
|
1272
|
+
unsubscribe();
|
|
1273
|
+
unsubscribe = null;
|
|
1274
|
+
}
|
|
1275
|
+
if (!clientGone) {
|
|
1276
|
+
try {
|
|
1277
|
+
controller.close();
|
|
1278
|
+
} catch {}
|
|
1279
|
+
}
|
|
1348
1280
|
}
|
|
1349
|
-
})
|
|
1281
|
+
}, 500);
|
|
1282
|
+
poll.unref?.();
|
|
1283
|
+
},
|
|
1284
|
+
cancel () {
|
|
1285
|
+
// Client navigated away — agent run keeps going in registry, but
|
|
1286
|
+
// tear down OUR poll + subscription so we don't leak a timer +
|
|
1287
|
+
// subscriber per disconnect.
|
|
1288
|
+
clientGone = true;
|
|
1289
|
+
if (poll) {
|
|
1290
|
+
clearInterval(poll);
|
|
1291
|
+
poll = null;
|
|
1292
|
+
}
|
|
1293
|
+
if (unsubscribe) {
|
|
1294
|
+
unsubscribe();
|
|
1295
|
+
unsubscribe = null;
|
|
1296
|
+
}
|
|
1350
1297
|
}
|
|
1298
|
+
});
|
|
1299
|
+
return (0,_lib_api_sse__WEBPACK_IMPORTED_MODULE_16__/* .sseResponse */ .t)(stream);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
/***/ }),
|
|
1304
|
+
|
|
1305
|
+
/***/ 529294:
|
|
1306
|
+
/***/ ((module) => {
|
|
1307
|
+
|
|
1308
|
+
module.exports = require("next/dist/server/app-render/work-async-storage.external.js");
|
|
1309
|
+
|
|
1310
|
+
/***/ }),
|
|
1311
|
+
|
|
1312
|
+
/***/ 553854:
|
|
1313
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1314
|
+
|
|
1315
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1316
|
+
/* harmony export */ t: () => (/* binding */ sseResponse)
|
|
1317
|
+
/* harmony export */ });
|
|
1318
|
+
// Shared response builder for Server-Sent Event streams. Centralises the
|
|
1319
|
+
// content-type / cache-control / connection / proxy-buffering headers so
|
|
1320
|
+
// every SSE endpoint behaves identically through nginx, tailscale-serve,
|
|
1321
|
+
// and Cloudflare. See ADR-0009 for the proxy story.
|
|
1322
|
+
function sseResponse(stream, opts = {}) {
|
|
1323
|
+
const { disableProxyBuffering = true } = opts;
|
|
1324
|
+
const headers = {
|
|
1325
|
+
"Content-Type": "text/event-stream",
|
|
1326
|
+
"Cache-Control": "no-cache",
|
|
1327
|
+
Connection: "keep-alive"
|
|
1351
1328
|
};
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
requestSpan == null ? void 0 : requestSpan.setAttribute('http.target', req.url);
|
|
1357
|
-
}
|
|
1358
|
-
await handleResponse(requestSpan);
|
|
1329
|
+
if (disableProxyBuffering) headers["X-Accel-Buffering"] = "no";
|
|
1330
|
+
return new Response(stream, {
|
|
1331
|
+
headers
|
|
1332
|
+
});
|
|
1359
1333
|
}
|
|
1360
1334
|
|
|
1361
|
-
//# sourceMappingURL=app-route.js.map
|
|
1362
1335
|
|
|
1336
|
+
/***/ }),
|
|
1337
|
+
|
|
1338
|
+
/***/ 590347:
|
|
1339
|
+
/***/ ((module) => {
|
|
1340
|
+
|
|
1341
|
+
module.exports = import("@langchain/mcp-adapters");;
|
|
1342
|
+
|
|
1343
|
+
/***/ }),
|
|
1344
|
+
|
|
1345
|
+
/***/ 594735:
|
|
1346
|
+
/***/ ((module) => {
|
|
1347
|
+
|
|
1348
|
+
module.exports = require("events");
|
|
1349
|
+
|
|
1350
|
+
/***/ }),
|
|
1351
|
+
|
|
1352
|
+
/***/ 629021:
|
|
1353
|
+
/***/ ((module) => {
|
|
1354
|
+
|
|
1355
|
+
module.exports = require("fs");
|
|
1356
|
+
|
|
1357
|
+
/***/ }),
|
|
1358
|
+
|
|
1359
|
+
/***/ 638522:
|
|
1360
|
+
/***/ ((module) => {
|
|
1361
|
+
|
|
1362
|
+
module.exports = require("node:zlib");
|
|
1363
1363
|
|
|
1364
1364
|
/***/ }),
|
|
1365
1365
|
|
|
@@ -1574,7 +1574,7 @@ module.exports = require("next/dist/shared/lib/no-fallback-error.external");
|
|
|
1574
1574
|
var __webpack_require__ = require("../../../../../../webpack-runtime.js");
|
|
1575
1575
|
__webpack_require__.C(exports);
|
|
1576
1576
|
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
|
|
1577
|
-
var __webpack_exports__ = __webpack_require__.X(0, [2970,7377,1813,4891,513,6299,563,8808,
|
|
1577
|
+
var __webpack_exports__ = __webpack_require__.X(0, [2970,7377,1813,4891,513,6299,563,8808,3692,4992,1244,3042,3566,2068,4377,1638,5585,6923,9174,3175,3479,4189,3326,4955,6408,6845,1387], () => (__webpack_exec__(132582)));
|
|
1578
1578
|
module.exports = __webpack_exports__;
|
|
1579
1579
|
|
|
1580
1580
|
})();
|