ai-agent-router 0.2.1 → 0.2.2
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/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/fallback-build-manifest.json +2 -2
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +3 -3
- package/.next/required-server-files.js +4 -4
- package/.next/required-server-files.json +4 -4
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/server/app/api/gateway/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/gateway/models/route.js.nft.json +1 -1
- package/.next/server/app/api/gateway/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/apply/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/available-models/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/restore/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/save/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/status/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/test/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/openclaw/apply/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/openclaw/available-models/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/openclaw/preview/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/openclaw/save/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/openclaw/status/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/opencode/apply/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/opencode/available-models/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/opencode/preview/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/opencode/save/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/opencode/status/route.js.nft.json +1 -1
- package/.next/server/app/api/logs/route.js.nft.json +1 -1
- package/.next/server/app/api/models/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/test/route.js.nft.json +1 -1
- package/.next/server/app/api/service/force-stop/route.js.nft.json +1 -1
- package/.next/server/app/api/service/start/route.js.nft.json +1 -1
- package/.next/server/app/api/service/status/route.js.nft.json +1 -1
- package/.next/server/app/api/service/stop/route.js.nft.json +1 -1
- package/.next/server/app/ide/page.js +1 -1
- package/.next/server/app/ide/page.js.nft.json +1 -1
- package/.next/server/app/ide/page_client-reference-manifest.js +1 -1
- package/.next/server/app/ide.html +1 -1
- package/.next/server/app/ide.rsc +3 -3
- package/.next/server/app/ide.segments/_full.segment.rsc +3 -3
- package/.next/server/app/ide.segments/_head.segment.rsc +1 -1
- package/.next/server/app/ide.segments/_index.segment.rsc +2 -2
- package/.next/server/app/ide.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/ide.segments/ide/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/ide.segments/ide.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/logs/page.js +1 -1
- package/.next/server/app/logs/page.js.nft.json +1 -1
- package/.next/server/app/logs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/logs.html +1 -1
- package/.next/server/app/logs.rsc +2 -2
- package/.next/server/app/logs.segments/_full.segment.rsc +2 -2
- package/.next/server/app/logs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/logs.segments/_index.segment.rsc +2 -2
- package/.next/server/app/logs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/logs.segments/logs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/logs.segments/logs.segment.rsc +1 -1
- package/.next/server/app/models/page.js +1 -1
- package/.next/server/app/models/page.js.nft.json +1 -1
- package/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/.next/server/app/models.html +1 -1
- package/.next/server/app/models.rsc +2 -2
- package/.next/server/app/models.segments/_full.segment.rsc +2 -2
- package/.next/server/app/models.segments/_head.segment.rsc +1 -1
- package/.next/server/app/models.segments/_index.segment.rsc +2 -2
- package/.next/server/app/models.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/models.segments/models/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/models.segments/models.segment.rsc +1 -1
- package/.next/server/app/page.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/providers/page.js +1 -1
- package/.next/server/app/providers/page.js.nft.json +1 -1
- package/.next/server/app/providers/page_client-reference-manifest.js +1 -1
- package/.next/server/app/providers.html +1 -1
- package/.next/server/app/providers.rsc +2 -2
- package/.next/server/app/providers.segments/_full.segment.rsc +2 -2
- package/.next/server/app/providers.segments/_head.segment.rsc +1 -1
- package/.next/server/app/providers.segments/_index.segment.rsc +2 -2
- package/.next/server/app/providers.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/providers.segments/providers/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/providers.segments/providers.segment.rsc +1 -1
- package/.next/server/chunks/[root-of-the-server]__3a204d25._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__3a204d25._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__4a8f9bc7._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__4a8f9bc7._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__5e8276bc._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__5e8276bc._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__c1b4b601._.js +16 -16
- package/.next/server/chunks/[root-of-the-server]__c1b4b601._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__f0461b8d._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__f0461b8d._.js.map +1 -1
- package/.next/server/chunks/ssr/_69468f4c._.js +3 -0
- package/.next/server/chunks/ssr/_69468f4c._.js.map +1 -0
- package/.next/server/chunks/ssr/src_app_ide_page_tsx_8962793b._.js +1 -1
- package/.next/server/chunks/ssr/src_app_ide_page_tsx_8962793b._.js.map +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/6992685fe009e8fd.css +1 -0
- package/.next/static/chunks/8ccc14e022ff6de3.js +1 -0
- package/README.md +31 -4
- package/dist/package.json +55 -0
- package/dist/src/app/api/config/route.js +17 -0
- package/dist/src/app/api/ide/claude/apply/route.js +84 -0
- package/dist/src/app/api/ide/claude/restore/route.js +30 -0
- package/dist/src/app/api/ide/claude/save/route.js +79 -0
- package/dist/src/app/components/Footer.js +11 -0
- package/dist/src/app/ide/page.js +62 -2
- package/dist/src/app/layout.js +5 -1
- package/dist/src/cli/index.js +0 -0
- package/dist/src/db/database.js +21 -2
- package/package.json +1 -1
- package/src/app/api/config/route.ts +17 -0
- package/src/app/api/ide/claude/apply/route.ts +94 -0
- package/src/app/api/ide/claude/restore/route.ts +36 -1
- package/src/app/api/ide/claude/save/route.ts +91 -1
- package/src/app/components/Footer.tsx +9 -0
- package/src/app/ide/page.tsx +71 -5
- package/src/app/layout.tsx +3 -1
- package/src/db/database.ts +27 -2
- package/.next/server/chunks/ssr/src_app_b2b1d928._.js +0 -3
- package/.next/server/chunks/ssr/src_app_b2b1d928._.js.map +0 -1
- package/.next/static/chunks/0f120c117962200b.css +0 -1
- package/.next/static/chunks/8ed839b2e4948968.js +0 -1
- /package/.next/static/{dYin74gcpdlg8TGoGv-_d → cf2SWIkI5HVbnDjLExI42}/_buildManifest.js +0 -0
- /package/.next/static/{dYin74gcpdlg8TGoGv-_d → cf2SWIkI5HVbnDjLExI42}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{dYin74gcpdlg8TGoGv-_d → cf2SWIkI5HVbnDjLExI42}/_ssgManifest.js +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
2:I[97367,["/_next/static/chunks/ff1a16fafef87110.js","/_next/static/chunks/d2be314c3ece3fbe.js"],"ViewportBoundary"]
|
|
3
3
|
3:I[97367,["/_next/static/chunks/ff1a16fafef87110.js","/_next/static/chunks/d2be314c3ece3fbe.js"],"MetadataBoundary"]
|
|
4
4
|
4:"$Sreact.suspense"
|
|
5
|
-
0:{"buildId":"
|
|
5
|
+
0:{"buildId":"cf2SWIkI5HVbnDjLExI42","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"AAR - AI Agent Router"}],["$","meta","1",{"name":"description","content":"Unified API gateway for managing multiple AI model providers"}]]}]}]}],null]}],"loading":null,"isPartial":false}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
2:I[97100,["/_next/static/chunks/8cf1e5f00ebaea52.js"],"ToastProvider"]
|
|
3
3
|
3:I[39756,["/_next/static/chunks/ff1a16fafef87110.js","/_next/static/chunks/d2be314c3ece3fbe.js"],"default"]
|
|
4
4
|
4:I[37457,["/_next/static/chunks/ff1a16fafef87110.js","/_next/static/chunks/d2be314c3ece3fbe.js"],"default"]
|
|
5
|
-
:HL["/_next/static/chunks/
|
|
6
|
-
0:{"buildId":"
|
|
5
|
+
:HL["/_next/static/chunks/6992685fe009e8fd.css","style"]
|
|
6
|
+
0:{"buildId":"cf2SWIkI5HVbnDjLExI42","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/chunks/6992685fe009e8fd.css","precedence":"next"}],["$","script","script-0",{"src":"/_next/static/chunks/8cf1e5f00ebaea52.js","async":true}]],["$","html",null,{"lang":"zh-CN","suppressHydrationWarning":true,"children":["$","body",null,{"className":"pb-10","children":[["$","$L2",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","template":["$","$L4",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}],["$","footer",null,{"className":"fixed bottom-0 left-0 right-0 py-2 text-center text-xs text-gray-400 bg-gray-50 border-t border-gray-200","children":["$","span",null,{"children":["AAR v","0.2.2"]}]}]]}]}]]}],"loading":null,"isPartial":false}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
:HL["/_next/static/chunks/
|
|
2
|
-
0:{"buildId":"
|
|
1
|
+
:HL["/_next/static/chunks/6992685fe009e8fd.css","style"]
|
|
2
|
+
0:{"buildId":"cf2SWIkI5HVbnDjLExI42","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"providers","paramType":null,"paramKey":"providers","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":false}},"isRootLayout":true},"staleTime":300}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
3:I[77707,["/_next/static/chunks/8cf1e5f00ebaea52.js","/_next/static/chunks/a89fdf03c5b0dfbd.js"],"default"]
|
|
4
4
|
6:I[97367,["/_next/static/chunks/ff1a16fafef87110.js","/_next/static/chunks/d2be314c3ece3fbe.js"],"OutletBoundary"]
|
|
5
5
|
7:"$Sreact.suspense"
|
|
6
|
-
0:{"buildId":"
|
|
6
|
+
0:{"buildId":"cf2SWIkI5HVbnDjLExI42","rsc":["$","$1","c",{"children":[["$","$L2",null,{"Component":"$3","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@4","$@5"]}}],[["$","script","script-0",{"src":"/_next/static/chunks/a89fdf03c5b0dfbd.js","async":true}]],["$","$L6",null,{"children":["$","$7",null,{"name":"Next.MetadataOutlet","children":"$@8"}]}]]}],"loading":null,"isPartial":false}
|
|
7
7
|
4:{}
|
|
8
8
|
5:"$0:rsc:props:children:0:props:serverProvidedParams:params"
|
|
9
9
|
8:null
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
1:"$Sreact.fragment"
|
|
2
2
|
2:I[39756,["/_next/static/chunks/ff1a16fafef87110.js","/_next/static/chunks/d2be314c3ece3fbe.js"],"default"]
|
|
3
3
|
3:I[37457,["/_next/static/chunks/ff1a16fafef87110.js","/_next/static/chunks/d2be314c3ece3fbe.js"],"default"]
|
|
4
|
-
0:{"buildId":"
|
|
4
|
+
0:{"buildId":"cf2SWIkI5HVbnDjLExI42","rsc":["$","$1","c",{"children":[null,["$","$L2",null,{"parallelRouterKey":"children","template":["$","$L3",null,{}]}]]}],"loading":null,"isPartial":false}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70952,e=>{"use strict";var t=e.i(47909),r=e.i(74017),n=e.i(96250),
|
|
1
|
+
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70952,e=>{"use strict";var t=e.i(47909),r=e.i(74017),n=e.i(96250),s=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),u=e.i(87718),c=e.i(95169),d=e.i(47587),p=e.i(66012),x=e.i(70101),h=e.i(26937),f=e.i(10372),R=e.i(93695);e.i(52474);var g=e.i(220),v=e.i(89171),y=e.i(22734),m=e.i(14747),E=e.i(46786);let w=(0,m.join)((0,E.homedir)(),".claude"),C=(0,m.join)(w,"settings.json"),N=(0,m.join)(w,"settings.json.aar.bak"),b=(0,m.join)((0,E.homedir)(),".aar","backups");async function k(e){try{let e;if(!(0,y.existsSync)(N))return v.NextResponse.json({error:"No backup file found. Please apply configuration first before restoring."},{status:404});let t=(0,y.readFileSync)(N,"utf-8");if(!(0,y.existsSync)(w))return v.NextResponse.json({error:"Claude config directory does not exist"},{status:500});let r=function(e,t){try{if(!(0,y.existsSync)(e))return{success:!0};(0,y.existsSync)(b)||(0,y.mkdirSync)(b,{recursive:!0});let r=new Date().toISOString().replace(/[:.]/g,"-"),n=(0,m.join)(b,`${t}-${r}.json`);return(0,y.copyFileSync)(e,n),{success:!0,backupPath:n}}catch(e){return{success:!1,error:`Backup to AAR failed: ${e.message}`}}}(C,"settings-before-restore");r.success||console.warn("[IDE Restore] Current config backup warning:",r.error),(0,y.copyFileSync)(N,C);try{e=JSON.parse(t)}catch(e){return v.NextResponse.json({error:"Backup file is corrupted or invalid JSON",backupContent:t},{status:500})}return v.NextResponse.json({success:!0,message:"Configuration restored successfully",config:e})}catch(e){return console.error("IDE Restore API error:",e),v.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}async function S(e){try{if(!(0,y.existsSync)(N))return v.NextResponse.json({error:"No backup file found"},{status:404});return(0,y.unlinkSync)(N),v.NextResponse.json({success:!0,message:"Backup file deleted successfully"})}catch(e){return console.error("IDE Delete Backup API error:",e),v.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}e.s(["DELETE",()=>S,"POST",()=>k],1282);var j=e.i(1282);let A=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/ide/claude/restore/route",pathname:"/api/ide/claude/restore",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/claude/restore/route.ts",nextConfigOutput:"",userland:j}),{workAsyncStorage:P,workUnitAsyncStorage:T,serverHooks:O}=A;function I(){return(0,n.patchFetch)({workAsyncStorage:P,workUnitAsyncStorage:T})}async function q(e,t,n){A.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let v="/api/ide/claude/restore/route";v=v.replace(/\/index$/,"")||"/";let y=await A.prepare(e,t,{srcPage:v,multiZoneDraftMode:!1});if(!y)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:m,params:E,nextConfig:w,parsedUrl:C,isDraftMode:N,prerenderManifest:b,routerServerContext:k,isOnDemandRevalidate:S,revalidateOnlyGenerated:j,resolvedPathname:P,clientReferenceManifest:T,serverActionsManifest:O}=y,I=(0,i.normalizeAppPath)(v),q=!!(b.dynamicRoutes[I]||b.routes[P]),_=async()=>((null==k?void 0:k.render404)?await k.render404(e,t,C,!1):t.end("This page could not be found"),null);if(q&&!N){let e=!!b.routes[P],t=b.dynamicRoutes[I];if(t&&!1===t.fallback&&!e){if(w.experimental.adapterPath)return await _();throw new R.NoFallbackError}}let D=null;!q||A.isDev||N||(D="/index"===(D=P)?"/":D);let H=!0===A.isDev||!q,U=q&&!H;O&&T&&(0,o.setManifestsSingleton)({page:v,clientReferenceManifest:T,serverActionsManifest:O});let M=e.method||"GET",$=(0,a.getTracer)(),F=$.getActiveScopeSpan(),B={params:E,prerenderManifest:b,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:H,incrementalCache:(0,s.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:w.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n,s)=>A.onRequestError(e,t,n,s,k)},sharedContext:{buildId:m}},K=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),G=u.NextRequestAdapter.fromNodeNextRequest(K,(0,u.signalFromNodeResponse)(t));try{let o=async e=>A.handle(G,B).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=$.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==c.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=r.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${v}`)}),i=!!(0,s.getRequestMeta)(e,"minimalMode"),l=async s=>{var a,l;let u=async({previousCacheEntry:r})=>{try{if(!i&&S&&j&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(s);e.fetchMetrics=B.renderOpts.fetchMetrics;let l=B.renderOpts.pendingWaitUntil;l&&n.waitUntil&&(n.waitUntil(l),l=void 0);let u=B.renderOpts.collectedTags;if(!q)return await (0,p.sendResponse)(K,L,a,B.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,x.toNodeOutgoingHttpHeaders)(a.headers);u&&(t[f.NEXT_CACHE_TAGS_HEADER]=u),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==B.renderOpts.collectedRevalidate&&!(B.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&B.renderOpts.collectedRevalidate,n=void 0===B.renderOpts.collectedExpire||B.renderOpts.collectedExpire>=f.INFINITE_CACHE?void 0:B.renderOpts.collectedExpire;return{value:{kind:g.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:n}}}}catch(t){throw(null==r?void 0:r.isStale)&&await A.onRequestError(e,t,{routerKind:"App Router",routePath:v,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:S})},!1,k),t}},c=await A.handleResponse({req:e,nextConfig:w,cacheKey:D,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:b,isRoutePPREnabled:!1,isOnDemandRevalidate:S,revalidateOnlyGenerated:j,responseGenerator:u,waitUntil:n.waitUntil,isMinimalMode:i});if(!q)return null;if((null==c||null==(a=c.value)?void 0:a.kind)!==g.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(l=c.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});i||t.setHeader("x-nextjs-cache",S?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),N&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let R=(0,x.fromNodeOutgoingHttpHeaders)(c.value.headers);return i&&q||R.delete(f.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||R.get("Cache-Control")||R.set("Cache-Control",(0,h.getCacheControlHeader)(c.cacheControl)),await (0,p.sendResponse)(K,L,new Response(c.value.body,{headers:R,status:c.value.status||200})),null};F?await l(F):await $.withPropagatedContext(e.headers,()=>$.trace(c.BaseServerSpan.handleRequest,{spanName:`${M} ${v}`,kind:a.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof R.NoFallbackError||await A.onRequestError(e,t,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:S})},!1,k),q)throw t;return await (0,p.sendResponse)(K,L,new Response(null,{status:500})),null}}e.s(["handler",()=>q,"patchFetch",()=>I,"routeModule",()=>A,"serverHooks",()=>O,"workAsyncStorage",()=>P,"workUnitAsyncStorage",()=>T],70952)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=%5Broot-of-the-server%5D__3a204d25._.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/app/api/ide/claude/restore/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, copyFileSync, unlinkSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\n\n// Claude settings.json 文件路径\nconst CLAUDE_DIR = join(homedir(), '.claude');\nconst SETTINGS_FILE = join(CLAUDE_DIR, 'settings.json');\nconst BACKUP_FILE = join(CLAUDE_DIR, 'settings.json.aar.bak');\n\n/**\n * 还原 Claude IDE 配置\n */\nexport async function POST(request: NextRequest) {\n try {\n // 检查备份文件是否存在\n const backupExists = existsSync(BACKUP_FILE);\n\n if (!backupExists) {\n return NextResponse.json(\n { error: 'No backup file found. Please apply configuration first before restoring.' },\n { status: 404 }\n );\n }\n\n // 读取备份文件\n const backupContent = readFileSync(BACKUP_FILE, 'utf-8');\n\n // 确保目录存在\n if (!existsSync(CLAUDE_DIR)) {\n return NextResponse.json(\n { error: 'Claude config directory does not exist' },\n { status: 500 }\n );\n }\n\n // 将备份内容复制到原配置文件\n copyFileSync(BACKUP_FILE, SETTINGS_FILE);\n\n // 尝试解析备份内容以验证格式\n let parsedBackup: any;\n try {\n parsedBackup = JSON.parse(backupContent);\n } catch (error: any) {\n return NextResponse.json(\n {\n error: 'Backup file is corrupted or invalid JSON',\n backupContent // 返回原始内容供调试\n },\n { status: 500 }\n );\n }\n\n return NextResponse.json({\n success: true,\n message: 'Configuration restored successfully',\n config: parsedBackup,\n });\n } catch (error: any) {\n console.error('IDE Restore API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n\n/**\n * 删除备份文件(可选功能)\n */\nexport async function DELETE(request: NextRequest) {\n try {\n // 检查备份文件是否存在\n if (!existsSync(BACKUP_FILE)) {\n return NextResponse.json(\n { error: 'No backup file found' },\n { status: 404 }\n );\n }\n\n // 删除备份文件\n unlinkSync(BACKUP_FILE);\n\n return NextResponse.json({\n success: true,\n message: 'Backup file deleted successfully',\n });\n } catch (error: any) {\n console.error('IDE Delete Backup API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/ide/claude/restore/route\",\n pathname: \"/api/ide/claude/restore\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/ide/claude/restore/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/claude/restore/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"8iCCAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA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cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[1]}
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/next/dist/esm/build/templates/app-route.js","../../../src/app/api/ide/claude/restore/route.ts"],"sourcesContent":["import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/ide/claude/restore/route\",\n pathname: \"/api/ide/claude/restore\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/ide/claude/restore/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/claude/restore/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n","import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, copyFileSync, unlinkSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\n\n// Claude settings.json 文件路径\nconst CLAUDE_DIR = join(homedir(), '.claude');\nconst SETTINGS_FILE = join(CLAUDE_DIR, 'settings.json');\nconst BACKUP_FILE = join(CLAUDE_DIR, 'settings.json.aar.bak');\n\n// AAR 备份目录\nconst AAR_BACKUP_DIR = join(homedir(), '.aar', 'backups');\n\n/**\n * 还原 Claude IDE 配置\n */\nexport async function POST(request: NextRequest) {\n try {\n // 检查备份文件是否存在\n const backupExists = existsSync(BACKUP_FILE);\n\n if (!backupExists) {\n return NextResponse.json(\n { error: 'No backup file found. Please apply configuration first before restoring.' },\n { status: 404 }\n );\n }\n\n // 读取备份文件\n const backupContent = readFileSync(BACKUP_FILE, 'utf-8');\n\n // 确保目录存在\n if (!existsSync(CLAUDE_DIR)) {\n return NextResponse.json(\n { error: 'Claude config directory does not exist' },\n { status: 500 }\n );\n }\n\n // 在还原前,先备份当前配置到 ~/.aar/backups 目录\n const currentBackup = backupToAar(SETTINGS_FILE, 'settings-before-restore');\n if (!currentBackup.success) {\n console.warn('[IDE Restore] Current config backup warning:', currentBackup.error);\n }\n\n // 将备份内容复制到原配置文件\n copyFileSync(BACKUP_FILE, SETTINGS_FILE);\n\n // 尝试解析备份内容以验证格式\n let parsedBackup: any;\n try {\n parsedBackup = JSON.parse(backupContent);\n } catch (error: any) {\n return NextResponse.json(\n {\n error: 'Backup file is corrupted or invalid JSON',\n backupContent // 返回原始内容供调试\n },\n { status: 500 }\n );\n }\n\n return NextResponse.json({\n success: true,\n message: 'Configuration restored successfully',\n config: parsedBackup,\n });\n } catch (error: any) {\n console.error('IDE Restore API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n\n/**\n * 删除备份文件(可选功能)\n */\nexport async function DELETE(request: NextRequest) {\n try {\n // 检查备份文件是否存在\n if (!existsSync(BACKUP_FILE)) {\n return NextResponse.json(\n { error: 'No backup file found' },\n { status: 404 }\n );\n }\n\n // 删除备份文件\n unlinkSync(BACKUP_FILE);\n\n return NextResponse.json({\n success: true,\n message: 'Backup file deleted successfully',\n });\n } catch (error: any) {\n console.error('IDE Delete Backup API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n\n/**\n * 备份文件到 ~/.aar/backups 目录\n */\nfunction backupToAar(filePath: string, backupName: string): { success: boolean; backupPath?: string; error?: string } {\n try {\n if (!existsSync(filePath)) {\n return { success: true }; // 文件不存在,无需备份\n }\n \n if (!existsSync(AAR_BACKUP_DIR)) {\n mkdirSync(AAR_BACKUP_DIR, { recursive: true });\n }\n \n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\n const backupPath = join(AAR_BACKUP_DIR, `${backupName}-${timestamp}.json`);\n copyFileSync(filePath, backupPath);\n \n return { success: true, backupPath };\n } catch (error: any) {\n return {\n success: false,\n error: `Backup to AAR failed: ${error.message}`,\n };\n }\n}\n"],"names":[],"mappings":"8iCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAA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gB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[0]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},56048,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),p=e.i(47587),c=e.i(66012),v=e.i(70101),R=e.i(26937),h=e.i(10372),E=e.i(93695);e.i(52474);var g=e.i(220),x=e.i(89171),A=e.i(22734),O=e.i(14747),_=e.i(46786),f=e.i(71560),C=e.i(97731);let T=(0,O.join)((0,_.homedir)(),".claude"),N=(0,O.join)(T,"settings.json"),m=(0,O.join)((0,_.homedir)(),".aar"),w=(0,O.join)(m,"settings.tmp.json");async function y(e){try{var t,r,a;let n,s,i,{haiku:o,sonnet:l,opus:d,default:u,reasoning:p}=await e.json();if(void 0===o&&void 0===l&&void 0===d&&void 0===u&&void 0===p)return x.NextResponse.json({error:"No model settings provided"},{status:400});let c=await I(),v=await P(),R=(0,A.existsSync)(N),h=!1;if(R){let e=JSON.parse((0,A.readFileSync)(N,"utf-8")),t=e.env?.ANTHROPIC_BASE_URL,r=e.env?.ANTHROPIC_AUTH_TOKEN;h=t===c&&r===v}R&&h?(n=N,s="applied",t=c,r=v,a={haiku:o,sonnet:l,opus:d,default:u,reasoning:p},i={router_provider:"aar",env:{ANTHROPIC_AUTH_TOKEN:r,ANTHROPIC_BASE_URL:t,ANTHROPIC_DEFAULT_HAIKU_MODEL:a.haiku,ANTHROPIC_DEFAULT_OPUS_MODEL:a.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:a.sonnet,ANTHROPIC_MODEL:a.default,ANTHROPIC_REASONING_MODEL:a.reasoning,API_TIMEOUT_MS:"3000000",CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:1,hasCompletedOnboarding:!0}}):(n=w,s="temp",i={modelMapping:{haiku:o,sonnet:l,opus:d,default:u,reasoning:p},isTemp:!0,savedAt:new Date().toISOString()});let E=n===N?T:m;(0,A.existsSync)(E)||(0,A.mkdirSync)(E,{recursive:!0});let g=JSON.stringify(i,null,2);return(0,A.writeFileSync)(n,g,"utf-8"),console.log("[IDE Save] Configuration saved:",{saveType:s,savePath:n,isCurrentGatewayApplied:h,config:"temp"===s?i:{baseUrl:i.env?.ANTHROPIC_BASE_URL,hasApiKey:!!i.env?.ANTHROPIC_AUTH_TOKEN,modelMapping:{haiku:i.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,sonnet:i.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,opus:i.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,default:i.env?.ANTHROPIC_MODEL,reasoning:i.env?.ANTHROPIC_REASONING_MODEL}}}),x.NextResponse.json({success:!0,message:"applied"===s?"配置已更新到 Claude Code":"配置已保存(临时)",saveType:s,savePath:n===N?"~/.claude/settings.json":"~/.aar/settings.tmp.json",config:i})}catch(e){return console.error("IDE Save API error:",e),x.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}async function I(){await (0,f.getDatabase)();let e=await (0,C.getConfig)("port"),t=e?.value||"1357";return`http://localhost:${t}`}async function P(){await (0,f.getDatabase)();let e=await (0,C.getConfig)("api_key");return e?.value||"your-gateway-api-key"}e.s(["POST",()=>y],25785);var S=e.i(25785);let H=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/ide/claude/save/route",pathname:"/api/ide/claude/save",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/claude/save/route.ts",nextConfigOutput:"",userland:S}),{workAsyncStorage:D,workUnitAsyncStorage:U,serverHooks:b}=H;function j(){return(0,a.patchFetch)({workAsyncStorage:D,workUnitAsyncStorage:U})}async function k(e,t,a){H.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/ide/claude/save/route";x=x.replace(/\/index$/,"")||"/";let A=await H.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!A)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:O,params:_,nextConfig:f,parsedUrl:C,isDraftMode:T,prerenderManifest:N,routerServerContext:m,isOnDemandRevalidate:w,revalidateOnlyGenerated:y,resolvedPathname:I,clientReferenceManifest:P,serverActionsManifest:S}=A,D=(0,o.normalizeAppPath)(x),U=!!(N.dynamicRoutes[D]||N.routes[I]),b=async()=>((null==m?void 0:m.render404)?await m.render404(e,t,C,!1):t.end("This page could not be found"),null);if(U&&!T){let e=!!N.routes[I],t=N.dynamicRoutes[D];if(t&&!1===t.fallback&&!e){if(f.experimental.adapterPath)return await b();throw new E.NoFallbackError}}let j=null;!U||H.isDev||T||(j="/index"===(j=I)?"/":j);let k=!0===H.isDev||!U,L=U&&!k;S&&P&&(0,i.setManifestsSingleton)({page:x,clientReferenceManifest:P,serverActionsManifest:S});let M=e.method||"GET",q=(0,s.getTracer)(),F=q.getActiveScopeSpan(),K={params:_,prerenderManifest:N,renderOpts:{experimental:{authInterrupts:!!f.experimental.authInterrupts},cacheComponents:!!f.cacheComponents,supportsDynamicResponse:k,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:f.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>H.onRequestError(e,t,a,n,m)},sharedContext:{buildId:O}},$=new l.NodeNextRequest(e),B=new l.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest($,(0,d.signalFromNodeResponse)(t));try{let i=async e=>H.handle(G,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=q.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${M} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${x}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let d=async({previousCacheEntry:r})=>{try{if(!o&&w&&y&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let d=K.renderOpts.collectedTags;if(!U)return await (0,c.sendResponse)($,B,s,K.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,v.toNodeOutgoingHttpHeaders)(s.headers);d&&(t[h.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,a=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:g.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await H.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:L,isOnDemandRevalidate:w})},!1,m),t}},u=await H.handleResponse({req:e,nextConfig:f,cacheKey:j,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:w,revalidateOnlyGenerated:y,responseGenerator:d,waitUntil:a.waitUntil,isMinimalMode:o});if(!U)return null;if((null==u||null==(s=u.value)?void 0:s.kind)!==g.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",w?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),T&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let E=(0,v.fromNodeOutgoingHttpHeaders)(u.value.headers);return o&&U||E.delete(h.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||E.get("Cache-Control")||E.set("Cache-Control",(0,R.getCacheControlHeader)(u.cacheControl)),await (0,c.sendResponse)($,B,new Response(u.value.body,{headers:E,status:u.value.status||200})),null};F?await l(F):await q.withPropagatedContext(e.headers,()=>q.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:s.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof E.NoFallbackError||await H.onRequestError(e,t,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:L,isOnDemandRevalidate:w})},!1,m),U)throw t;return await (0,c.sendResponse)($,B,new Response(null,{status:500})),null}}e.s(["handler",()=>k,"patchFetch",()=>j,"routeModule",()=>H,"serverHooks",()=>b,"workAsyncStorage",()=>D,"workUnitAsyncStorage",()=>U],56048)}];
|
|
1
|
+
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},56048,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),u=e.i(87718),d=e.i(95169),c=e.i(47587),p=e.i(66012),v=e.i(70101),g=e.i(26937),h=e.i(10372),R=e.i(93695);e.i(52474);var E=e.i(220),x=e.i(89171),f=e.i(22734),A=e.i(14747),O=e.i(46786),_=e.i(71560),C=e.i(97731);let m=(0,A.join)((0,O.homedir)(),".claude"),y=(0,A.join)(m,"settings.json"),N=(0,A.join)((0,O.homedir)(),".claude.json"),T=(0,A.join)((0,O.homedir)(),".aar"),S=(0,A.join)(T,"settings.tmp.json"),w=(0,A.join)(T,"backups");async function I(e){try{let n,s,i,{haiku:o,sonnet:l,opus:u,default:d,reasoning:c}=await e.json();if(void 0===o&&void 0===l&&void 0===u&&void 0===d&&void 0===c)return x.NextResponse.json({error:"No model settings provided"},{status:400});let p=await P(),v=await D(),g=(0,f.existsSync)(y),h=!1;if(g){let e=JSON.parse((0,f.readFileSync)(y,"utf-8")),t=e.env?.ANTHROPIC_BASE_URL,r=e.env?.ANTHROPIC_AUTH_TOKEN;h=t===p&&r===v}if(g&&h){var t,r,a;n=y,s="applied";let e=H(y,"settings"),g=H(N,"claude");e.success||console.warn("[IDE Save] Settings backup warning:",e.error),g.success||console.warn("[IDE Save] Claude.json backup warning:",g.error),t=p,r=v,a={haiku:o,sonnet:l,opus:u,default:d,reasoning:c},i={router_provider:"aar",env:{ANTHROPIC_AUTH_TOKEN:r,ANTHROPIC_BASE_URL:t,ANTHROPIC_DEFAULT_HAIKU_MODEL:a.haiku,ANTHROPIC_DEFAULT_OPUS_MODEL:a.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:a.sonnet,ANTHROPIC_MODEL:a.default,ANTHROPIC_REASONING_MODEL:a.reasoning,API_TIMEOUT_MS:"3000000",CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:1,hasCompletedOnboarding:!0}};let h=function(){try{let e={},t=!1;if((0,f.existsSync)(N))try{let t=(0,f.readFileSync)(N,"utf-8");e=JSON.parse(t)}catch{e={}}else t=!0;if(!0===e.hasCompletedOnboarding)return{success:!0,created:!1};return e.hasCompletedOnboarding=!0,(0,f.writeFileSync)(N,JSON.stringify(e,null,2),"utf-8"),{success:!0,created:t}}catch(e){return{success:!1,created:!1,error:`Failed to update claude.json: ${e.message}`}}}();h.success||console.warn("[IDE Save] Onboarding update warning:",h.error)}else n=S,s="temp",i={modelMapping:{haiku:o,sonnet:l,opus:u,default:d,reasoning:c},isTemp:!0,savedAt:new Date().toISOString()};let R=n===y?m:T;(0,f.existsSync)(R)||(0,f.mkdirSync)(R,{recursive:!0});let E=JSON.stringify(i,null,2);return(0,f.writeFileSync)(n,E,"utf-8"),console.log("[IDE Save] Configuration saved:",{saveType:s,savePath:n,isCurrentGatewayApplied:h,config:"temp"===s?i:{baseUrl:i.env?.ANTHROPIC_BASE_URL,hasApiKey:!!i.env?.ANTHROPIC_AUTH_TOKEN,modelMapping:{haiku:i.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,sonnet:i.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,opus:i.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,default:i.env?.ANTHROPIC_MODEL,reasoning:i.env?.ANTHROPIC_REASONING_MODEL}}}),x.NextResponse.json({success:!0,message:"applied"===s?"配置已更新到 Claude Code":"配置已保存(临时)",saveType:s,savePath:n===y?"~/.claude/settings.json":"~/.aar/settings.tmp.json",config:i})}catch(e){return console.error("IDE Save API error:",e),x.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}async function P(){await (0,_.getDatabase)();let e=await (0,C.getConfig)("port"),t=e?.value||"1357";return`http://localhost:${t}`}async function D(){await (0,_.getDatabase)();let e=await (0,C.getConfig)("api_key");return e?.value||"your-gateway-api-key"}function H(e,t){try{if(!(0,f.existsSync)(e))return{success:!0};(0,f.existsSync)(w)||(0,f.mkdirSync)(w,{recursive:!0});let r=new Date().toISOString().replace(/[:.]/g,"-"),a=(0,A.join)(w,`${t}-${r}.json`);return(0,f.copyFileSync)(e,a),{success:!0,backupPath:a}}catch(e){return{success:!1,error:`Backup to AAR failed: ${e.message}`}}}e.s(["POST",()=>I],25785);var b=e.i(25785);let j=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/ide/claude/save/route",pathname:"/api/ide/claude/save",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/claude/save/route.ts",nextConfigOutput:"",userland:b}),{workAsyncStorage:U,workUnitAsyncStorage:k,serverHooks:L}=j;function M(){return(0,a.patchFetch)({workAsyncStorage:U,workUnitAsyncStorage:k})}async function F(e,t,a){j.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/ide/claude/save/route";x=x.replace(/\/index$/,"")||"/";let f=await j.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!f)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:A,params:O,nextConfig:_,parsedUrl:C,isDraftMode:m,prerenderManifest:y,routerServerContext:N,isOnDemandRevalidate:T,revalidateOnlyGenerated:S,resolvedPathname:w,clientReferenceManifest:I,serverActionsManifest:P}=f,D=(0,o.normalizeAppPath)(x),H=!!(y.dynamicRoutes[D]||y.routes[w]),b=async()=>((null==N?void 0:N.render404)?await N.render404(e,t,C,!1):t.end("This page could not be found"),null);if(H&&!m){let e=!!y.routes[w],t=y.dynamicRoutes[D];if(t&&!1===t.fallback&&!e){if(_.experimental.adapterPath)return await b();throw new R.NoFallbackError}}let U=null;!H||j.isDev||m||(U="/index"===(U=w)?"/":U);let k=!0===j.isDev||!H,L=H&&!k;P&&I&&(0,i.setManifestsSingleton)({page:x,clientReferenceManifest:I,serverActionsManifest:P});let M=e.method||"GET",F=(0,s.getTracer)(),q=F.getActiveScopeSpan(),K={params:O,prerenderManifest:y,renderOpts:{experimental:{authInterrupts:!!_.experimental.authInterrupts},cacheComponents:!!_.cacheComponents,supportsDynamicResponse:k,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:_.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>j.onRequestError(e,t,a,n,N)},sharedContext:{buildId:A}},$=new l.NodeNextRequest(e),B=new l.NodeNextResponse(t),G=u.NextRequestAdapter.fromNodeNextRequest($,(0,u.signalFromNodeResponse)(t));try{let i=async e=>j.handle(G,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==d.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${M} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${x}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let u=async({previousCacheEntry:r})=>{try{if(!o&&T&&S&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let u=K.renderOpts.collectedTags;if(!H)return await (0,p.sendResponse)($,B,s,K.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,v.toNodeOutgoingHttpHeaders)(s.headers);u&&(t[h.NEXT_CACHE_TAGS_HEADER]=u),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,a=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:E.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await j.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:L,isOnDemandRevalidate:T})},!1,N),t}},d=await j.handleResponse({req:e,nextConfig:_,cacheKey:U,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:T,revalidateOnlyGenerated:S,responseGenerator:u,waitUntil:a.waitUntil,isMinimalMode:o});if(!H)return null;if((null==d||null==(s=d.value)?void 0:s.kind)!==E.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(l=d.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",T?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),m&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let R=(0,v.fromNodeOutgoingHttpHeaders)(d.value.headers);return o&&H||R.delete(h.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||R.get("Cache-Control")||R.set("Cache-Control",(0,g.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)($,B,new Response(d.value.body,{headers:R,status:d.value.status||200})),null};q?await l(q):await F.withPropagatedContext(e.headers,()=>F.trace(d.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:s.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof R.NoFallbackError||await j.onRequestError(e,t,{routerKind:"App Router",routePath:D,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:L,isOnDemandRevalidate:T})},!1,N),H)throw t;return await (0,p.sendResponse)($,B,new Response(null,{status:500})),null}}e.s(["handler",()=>F,"patchFetch",()=>M,"routeModule",()=>j,"serverHooks",()=>L,"workAsyncStorage",()=>U,"workUnitAsyncStorage",()=>k],56048)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=%5Broot-of-the-server%5D__4a8f9bc7._.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/app/api/ide/claude/save/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport { getDatabase } from '@/db/database';\nimport { getConfig } from '@/db/queries';\n\n// Claude settings.json 文件路径\nconst CLAUDE_DIR = join(homedir(), '.claude');\nconst SETTINGS_FILE = join(CLAUDE_DIR, 'settings.json');\n\n// AAR 临时配置目录和文件\nconst AAR_DIR = join(homedir(), '.aar');\nconst TEMP_SETTINGS_FILE = join(AAR_DIR, 'settings.tmp.json');\n\ntype SaveRequest = {\n haiku?: string;\n sonnet?: string;\n opus?: string;\n default?: string;\n reasoning?: string;\n};\n\n/**\n * 保存 IDE 配置\n * - 如果当前已应用配置( ~/.claude/settings.json 存在且匹配当前网关),直接更新 settings.json\n * - 如果未应用网关配置,保存到 ~/.aar/settings.tmp.json(临时存储)\n */\nexport async function POST(request: NextRequest) {\n try {\n const body: SaveRequest = await request.json();\n const { haiku, sonnet, opus, default: defaultModel, reasoning: reasoningModel } = body;\n\n // 验证请求参数 - 至少需要一个设置\n if (haiku === undefined && sonnet === undefined && opus === undefined &&\n defaultModel === undefined && reasoningModel === undefined) {\n return NextResponse.json(\n { error: 'No model settings provided' },\n { status: 400 }\n );\n }\n\n // 获取当前网关地址和API Key(从数据库读取)\n const gatewayAddress = await getGatewayAddress();\n const gatewayApiKey = await getGatewayApiKey();\n\n // 检查当前配置状态\n const settingsFileExists = existsSync(SETTINGS_FILE);\n let isCurrentGatewayApplied = false;\n\n if (settingsFileExists) {\n const currentConfig = JSON.parse(readFileSync(SETTINGS_FILE, 'utf-8'));\n const appliedBaseUrl = currentConfig.env?.ANTHROPIC_BASE_URL;\n const appliedApiKey = currentConfig.env?.ANTHROPIC_AUTH_TOKEN;\n isCurrentGatewayApplied = appliedBaseUrl === gatewayAddress && appliedApiKey === gatewayApiKey;\n }\n\n // 决定保存位置和方式\n let savePath: string;\n let saveType: string;\n let mergedConfig: any;\n\n if (settingsFileExists && isCurrentGatewayApplied) {\n // 已应用当前网关配置,更新 settings.json\n savePath = SETTINGS_FILE;\n saveType = 'applied';\n mergedConfig = generateClaudeConfig(gatewayAddress, gatewayApiKey, {\n haiku: haiku,\n sonnet: sonnet,\n opus: opus,\n default: defaultModel,\n reasoning: reasoningModel\n });\n } else {\n // 未应用网络关配置,保存到临时文件 ~/.aar/settings.tmp.json\n savePath = TEMP_SETTINGS_FILE;\n saveType = 'temp';\n\n // 临时配置只保存模型映射,不包含网关信息\n mergedConfig = {\n modelMapping: {\n haiku: haiku,\n sonnet: sonnet,\n opus: opus,\n default: defaultModel,\n reasoning: reasoningModel,\n },\n // 标记这是临时配置,需要应用时才获取网关信息\n isTemp: true,\n savedAt: new Date().toISOString(),\n };\n }\n\n // 确保目录存在\n const targetDir = savePath === SETTINGS_FILE ? CLAUDE_DIR : AAR_DIR;\n if (!existsSync(targetDir)) {\n mkdirSync(targetDir, { recursive: true });\n }\n\n // 写入配置\n const jsonString = JSON.stringify(mergedConfig, null, 2);\n writeFileSync(savePath, jsonString, 'utf-8');\n\n console.log('[IDE Save] Configuration saved:', {\n saveType,\n savePath,\n isCurrentGatewayApplied,\n config: saveType === 'temp' ? mergedConfig : {\n baseUrl: mergedConfig.env?.ANTHROPIC_BASE_URL,\n hasApiKey: !!mergedConfig.env?.ANTHROPIC_AUTH_TOKEN,\n modelMapping: {\n haiku: mergedConfig.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,\n sonnet: mergedConfig.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,\n opus: mergedConfig.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,\n default: mergedConfig.env?.ANTHROPIC_MODEL,\n reasoning: mergedConfig.env?.ANTHROPIC_REASONING_MODEL,\n },\n },\n });\n\n return NextResponse.json({\n success: true,\n message: saveType === 'applied'\n ? '配置已更新到 Claude Code'\n : '配置已保存(临时)',\n saveType,\n savePath: savePath === SETTINGS_FILE ? '~/.claude/settings.json' : '~/.aar/settings.tmp.json',\n config: mergedConfig,\n });\n } catch (error: any) {\n console.error('IDE Save API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n\n/**\n * 获取当前网关地址(从数据库读取)\n */\nasync function getGatewayAddress(): Promise<string> {\n await getDatabase();\n const portConfig = await getConfig('port');\n const port = portConfig?.value || '1357';\n return `http://localhost:${port}`;\n}\n\n/**\n * 获取当前网关 API Key(从数据库读取)\n */\nasync function getGatewayApiKey(): Promise<string> {\n await getDatabase();\n const apiKeyConfig = await getConfig('api_key');\n return apiKeyConfig?.value || 'your-gateway-api-key';\n}\n\n/**\n * 生成完整的 Claude 配置(用于更新 settings.json)\n */\nfunction generateClaudeConfig(\n gatewayAddress: string,\n gatewayApiKey: string,\n modelMapping: SaveRequest\n): any {\n return {\n router_provider: 'aar',\n env: {\n ANTHROPIC_AUTH_TOKEN: gatewayApiKey,\n ANTHROPIC_BASE_URL: gatewayAddress,\n ANTHROPIC_DEFAULT_HAIKU_MODEL: modelMapping.haiku,\n ANTHROPIC_DEFAULT_OPUS_MODEL: modelMapping.opus,\n ANTHROPIC_DEFAULT_SONNET_MODEL: modelMapping.sonnet,\n ANTHROPIC_MODEL: modelMapping.default,\n ANTHROPIC_REASONING_MODEL: modelMapping.reasoning,\n API_TIMEOUT_MS: '3000000',\n CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: 1,\n hasCompletedOnboarding: true,\n },\n };\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/ide/claude/save/route\",\n pathname: \"/api/ide/claude/save\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/ide/claude/save/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/claude/save/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"8iCCAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA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AM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,GAEf,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[1]}
|
|
1
|
+
{"version":3,"sources":["../../../src/app/api/ide/claude/save/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport { getDatabase } from '@/db/database';\nimport { getConfig } from '@/db/queries';\n\n// Claude settings.json 文件路径\nconst CLAUDE_DIR = join(homedir(), '.claude');\nconst SETTINGS_FILE = join(CLAUDE_DIR, 'settings.json');\n\n// Claude 登录配置文件(用于 hasCompletedOnboarding)\nconst CLAUDE_JSON_FILE = join(homedir(), '.claude.json');\n\n// AAR 临时配置目录和文件\nconst AAR_DIR = join(homedir(), '.aar');\nconst TEMP_SETTINGS_FILE = join(AAR_DIR, 'settings.tmp.json');\n\n// AAR 备份目录\nconst AAR_BACKUP_DIR = join(AAR_DIR, 'backups');\n\ntype SaveRequest = {\n haiku?: string;\n sonnet?: string;\n opus?: string;\n default?: string;\n reasoning?: string;\n};\n\n/**\n * 保存 IDE 配置\n * - 如果当前已应用配置( ~/.claude/settings.json 存在且匹配当前网关),直接更新 settings.json\n * - 如果未应用网关配置,保存到 ~/.aar/settings.tmp.json(临时存储)\n */\nexport async function POST(request: NextRequest) {\n try {\n const body: SaveRequest = await request.json();\n const { haiku, sonnet, opus, default: defaultModel, reasoning: reasoningModel } = body;\n\n // 验证请求参数 - 至少需要一个设置\n if (haiku === undefined && sonnet === undefined && opus === undefined &&\n defaultModel === undefined && reasoningModel === undefined) {\n return NextResponse.json(\n { error: 'No model settings provided' },\n { status: 400 }\n );\n }\n\n // 获取当前网关地址和API Key(从数据库读取)\n const gatewayAddress = await getGatewayAddress();\n const gatewayApiKey = await getGatewayApiKey();\n\n // 检查当前配置状态\n const settingsFileExists = existsSync(SETTINGS_FILE);\n let isCurrentGatewayApplied = false;\n\n if (settingsFileExists) {\n const currentConfig = JSON.parse(readFileSync(SETTINGS_FILE, 'utf-8'));\n const appliedBaseUrl = currentConfig.env?.ANTHROPIC_BASE_URL;\n const appliedApiKey = currentConfig.env?.ANTHROPIC_AUTH_TOKEN;\n isCurrentGatewayApplied = appliedBaseUrl === gatewayAddress && appliedApiKey === gatewayApiKey;\n }\n\n // 决定保存位置和方式\n let savePath: string;\n let saveType: string;\n let mergedConfig: any;\n\n if (settingsFileExists && isCurrentGatewayApplied) {\n // 已应用当前网关配置,更新 settings.json\n savePath = SETTINGS_FILE;\n saveType = 'applied';\n \n // 备份到 ~/.aar/backups 目录\n const settingsBackup = backupToAar(SETTINGS_FILE, 'settings');\n const claudeJsonBackup = backupToAar(CLAUDE_JSON_FILE, 'claude');\n \n if (!settingsBackup.success) {\n console.warn('[IDE Save] Settings backup warning:', settingsBackup.error);\n }\n if (!claudeJsonBackup.success) {\n console.warn('[IDE Save] Claude.json backup warning:', claudeJsonBackup.error);\n }\n \n mergedConfig = generateClaudeConfig(gatewayAddress, gatewayApiKey, {\n haiku: haiku,\n sonnet: sonnet,\n opus: opus,\n default: defaultModel,\n reasoning: reasoningModel\n });\n \n // 确保 ~/.claude.json 包含 hasCompletedOnboarding: true\n const onboardingResult = ensureClaudeOnboarding();\n if (!onboardingResult.success) {\n console.warn('[IDE Save] Onboarding update warning:', onboardingResult.error);\n }\n } else {\n // 未应用网络关配置,保存到临时文件 ~/.aar/settings.tmp.json\n savePath = TEMP_SETTINGS_FILE;\n saveType = 'temp';\n\n // 临时配置只保存模型映射,不包含网关信息\n mergedConfig = {\n modelMapping: {\n haiku: haiku,\n sonnet: sonnet,\n opus: opus,\n default: defaultModel,\n reasoning: reasoningModel,\n },\n // 标记这是临时配置,需要应用时才获取网关信息\n isTemp: true,\n savedAt: new Date().toISOString(),\n };\n }\n\n // 确保目录存在\n const targetDir = savePath === SETTINGS_FILE ? CLAUDE_DIR : AAR_DIR;\n if (!existsSync(targetDir)) {\n mkdirSync(targetDir, { recursive: true });\n }\n\n // 写入配置\n const jsonString = JSON.stringify(mergedConfig, null, 2);\n writeFileSync(savePath, jsonString, 'utf-8');\n\n console.log('[IDE Save] Configuration saved:', {\n saveType,\n savePath,\n isCurrentGatewayApplied,\n config: saveType === 'temp' ? mergedConfig : {\n baseUrl: mergedConfig.env?.ANTHROPIC_BASE_URL,\n hasApiKey: !!mergedConfig.env?.ANTHROPIC_AUTH_TOKEN,\n modelMapping: {\n haiku: mergedConfig.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,\n sonnet: mergedConfig.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,\n opus: mergedConfig.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,\n default: mergedConfig.env?.ANTHROPIC_MODEL,\n reasoning: mergedConfig.env?.ANTHROPIC_REASONING_MODEL,\n },\n },\n });\n\n return NextResponse.json({\n success: true,\n message: saveType === 'applied'\n ? '配置已更新到 Claude Code'\n : '配置已保存(临时)',\n saveType,\n savePath: savePath === SETTINGS_FILE ? '~/.claude/settings.json' : '~/.aar/settings.tmp.json',\n config: mergedConfig,\n });\n } catch (error: any) {\n console.error('IDE Save API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n\n/**\n * 获取当前网关地址(从数据库读取)\n */\nasync function getGatewayAddress(): Promise<string> {\n await getDatabase();\n const portConfig = await getConfig('port');\n const port = portConfig?.value || '1357';\n return `http://localhost:${port}`;\n}\n\n/**\n * 获取当前网关 API Key(从数据库读取)\n */\nasync function getGatewayApiKey(): Promise<string> {\n await getDatabase();\n const apiKeyConfig = await getConfig('api_key');\n return apiKeyConfig?.value || 'your-gateway-api-key';\n}\n\n/**\n * 生成完整的 Claude 配置(用于更新 settings.json)\n */\nfunction generateClaudeConfig(\n gatewayAddress: string,\n gatewayApiKey: string,\n modelMapping: SaveRequest\n): any {\n return {\n router_provider: 'aar',\n env: {\n ANTHROPIC_AUTH_TOKEN: gatewayApiKey,\n ANTHROPIC_BASE_URL: gatewayAddress,\n ANTHROPIC_DEFAULT_HAIKU_MODEL: modelMapping.haiku,\n ANTHROPIC_DEFAULT_OPUS_MODEL: modelMapping.opus,\n ANTHROPIC_DEFAULT_SONNET_MODEL: modelMapping.sonnet,\n ANTHROPIC_MODEL: modelMapping.default,\n ANTHROPIC_REASONING_MODEL: modelMapping.reasoning,\n API_TIMEOUT_MS: '3000000',\n CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: 1,\n hasCompletedOnboarding: true,\n },\n };\n}\n\n/**\n * 备份文件到 ~/.aar/backups 目录\n */\nfunction backupToAar(filePath: string, backupName: string): { success: boolean; backupPath?: string; error?: string } {\n try {\n if (!existsSync(filePath)) {\n return { success: true }; // 文件不存在,无需备份\n }\n \n if (!existsSync(AAR_BACKUP_DIR)) {\n mkdirSync(AAR_BACKUP_DIR, { recursive: true });\n }\n \n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\n const backupPath = join(AAR_BACKUP_DIR, `${backupName}-${timestamp}.json`);\n copyFileSync(filePath, backupPath);\n \n return { success: true, backupPath };\n } catch (error: any) {\n return {\n success: false,\n error: `Backup to AAR failed: ${error.message}`,\n };\n }\n}\n\n/**\n * 确保 ~/.claude.json 文件中包含 hasCompletedOnboarding: true\n * 这允许用户跳过 Claude 登录使用自定义模型\n */\nfunction ensureClaudeOnboarding(): { success: boolean; created: boolean; error?: string } {\n try {\n let config: any = {};\n let created = false;\n \n if (existsSync(CLAUDE_JSON_FILE)) {\n try {\n const content = readFileSync(CLAUDE_JSON_FILE, 'utf-8');\n config = JSON.parse(content);\n } catch {\n // 文件存在但解析失败,使用空对象\n config = {};\n }\n } else {\n created = true;\n }\n \n // 检查是否已经有 hasCompletedOnboarding\n if (config.hasCompletedOnboarding === true) {\n return { success: true, created: false };\n }\n \n // 添加 hasCompletedOnboarding\n config.hasCompletedOnboarding = true;\n writeFileSync(CLAUDE_JSON_FILE, JSON.stringify(config, null, 2), 'utf-8');\n \n return { success: true, created };\n } catch (error: any) {\n return {\n success: false,\n created: false,\n error: `Failed to update claude.json: ${error.message}`,\n };\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/ide/claude/save/route\",\n pathname: \"/api/ide/claude/save\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/ide/claude/save/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/claude/save/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"8iCCAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,CAAA,CAAA,OAAA,IAAA,EAAA,EAAA,CAAA,CAAA,KDhBA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAGA,IAAM,EAAa,CAAA,EAAA,EAAA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,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,GAEf,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[1]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},26994,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),u=e.i(87718),d=e.i(95169),c=e.i(47587),p=e.i(66012),x=e.i(70101),h=e.i(26937),f=e.i(10372),R=e.i(93695);e.i(52474);var v=e.i(220),g=e.i(89171),y=e.i(22734),E=e.i(14747),A=e.i(46786),m=e.i(71560),w=e.i(97731);let C=(0,E.join)((0,A.homedir)(),".claude"),N=(0,E.join)(C,"settings.json"),O=(0,E.join)(C,"settings.json.aar.bak");async function _(e){try{let t,{haiku:r,sonnet:a,opus:n,default:s,reasoning:i}=await e.json();if(void 0===r||void 0===a||void 0===n||void 0===s||void 0===i)return g.NextResponse.json({error:"Missing required fields: haiku, sonnet, opus, default, reasoning"},{status:400});let o=await T(),l=await S(),u={haiku:r,sonnet:a,opus:n,default:s,reasoning:i},d=b(o,l,u),c=function(){try{if((0,y.existsSync)(N)){let e=(0,y.readFileSync)(N,"utf-8"),t=!1;try{let r=JSON.parse(e);t="aar"===r.router_provider}catch{t=!1}return t||(0,y.writeFileSync)(O,e,"utf-8"),{success:!0,existed:!0,isFromAar:t}}return{success:!0,existed:!1,isFromAar:!1}}catch(e){return{success:!1,existed:!1,isFromAar:!1,error:`Backup failed: ${e.message}`}}}();if(!c.success)return g.NextResponse.json({error:c.error},{status:500});if((0,y.existsSync)(C)||(0,y.mkdirSync)(C,{recursive:!0}),(0,y.existsSync)(N))try{let e=JSON.parse((0,y.readFileSync)(N,"utf-8"));t={...e,env:{...e.env||{},...d},router_provider:"aar"}}catch{t=P(o,l,u)}else t=P(o,l,u);let p=function(e){try{let t=JSON.stringify(e,null,2);return JSON.parse(t),(0,y.writeFileSync)(N,t,"utf-8"),{success:!0}}catch(e){return{success:!1,error:`Validation or write failed: ${e.message}`}}}(t);if(!p.success)return g.NextResponse.json({error:p.error},{status:500});return g.NextResponse.json({success:!0,message:"Configuration applied successfully",config:t,backup:c.existed?"Created backup":"No existing config to backup",previousWasFromAar:c.existed&&c.isFromAar})}catch(e){return console.error("IDE Apply API error:",e),g.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}async function T(){await (0,m.getDatabase)();let e=await (0,w.getConfig)("port"),t=e?.value||"1357";return`http://localhost:${t}`}async function S(){await (0,m.getDatabase)();let e=await (0,w.getConfig)("api_key");return e?.value||"your-gateway-api-key"}function b(e,t,r){return{ANTHROPIC_AUTH_TOKEN:t,ANTHROPIC_BASE_URL:e,ANTHROPIC_DEFAULT_HAIKU_MODEL:r.haiku,ANTHROPIC_DEFAULT_OPUS_MODEL:r.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:r.sonnet,ANTHROPIC_MODEL:r.default,ANTHROPIC_REASONING_MODEL:r.reasoning,API_TIMEOUT_MS:"3000000",CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:1,hasCompletedOnboarding:!0}}function P(e,t,r){return{router_provider:"aar",env:b(e,t,r)}}e.s(["POST",()=>_],8245);var k=e.i(8245);let I=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/ide/claude/apply/route",pathname:"/api/ide/claude/apply",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/claude/apply/route.ts",nextConfigOutput:"",userland:k}),{workAsyncStorage:j,workUnitAsyncStorage:D,serverHooks:H}=I;function U(){return(0,a.patchFetch)({workAsyncStorage:j,workUnitAsyncStorage:D})}async function q(e,t,a){I.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/ide/claude/apply/route";g=g.replace(/\/index$/,"")||"/";let y=await I.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!y)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:E,params:A,nextConfig:m,parsedUrl:w,isDraftMode:C,prerenderManifest:N,routerServerContext:O,isOnDemandRevalidate:_,revalidateOnlyGenerated:T,resolvedPathname:S,clientReferenceManifest:b,serverActionsManifest:P}=y,k=(0,o.normalizeAppPath)(g),j=!!(N.dynamicRoutes[k]||N.routes[S]),D=async()=>((null==O?void 0:O.render404)?await O.render404(e,t,w,!1):t.end("This page could not be found"),null);if(j&&!C){let e=!!N.routes[S],t=N.dynamicRoutes[k];if(t&&!1===t.fallback&&!e){if(m.experimental.adapterPath)return await D();throw new R.NoFallbackError}}let H=null;!j||I.isDev||C||(H="/index"===(H=S)?"/":H);let U=!0===I.isDev||!j,q=j&&!U;P&&b&&(0,i.setManifestsSingleton)({page:g,clientReferenceManifest:b,serverActionsManifest:P});let F=e.method||"GET",M=(0,s.getTracer)(),L=M.getActiveScopeSpan(),$={params:A,prerenderManifest:N,renderOpts:{experimental:{authInterrupts:!!m.experimental.authInterrupts},cacheComponents:!!m.cacheComponents,supportsDynamicResponse:U,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:m.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>I.onRequestError(e,t,a,n,O)},sharedContext:{buildId:E}},K=new l.NodeNextRequest(e),B=new l.NodeNextResponse(t),G=u.NextRequestAdapter.fromNodeNextRequest(K,(0,u.signalFromNodeResponse)(t));try{let i=async e=>I.handle(G,$).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=M.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==d.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${F} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${F} ${g}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let u=async({previousCacheEntry:r})=>{try{if(!o&&_&&T&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=$.renderOpts.fetchMetrics;let l=$.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let u=$.renderOpts.collectedTags;if(!j)return await (0,p.sendResponse)(K,B,s,$.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,x.toNodeOutgoingHttpHeaders)(s.headers);u&&(t[f.NEXT_CACHE_TAGS_HEADER]=u),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==$.renderOpts.collectedRevalidate&&!($.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&$.renderOpts.collectedRevalidate,a=void 0===$.renderOpts.collectedExpire||$.renderOpts.collectedExpire>=f.INFINITE_CACHE?void 0:$.renderOpts.collectedExpire;return{value:{kind:v.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await I.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:q,isOnDemandRevalidate:_})},!1,O),t}},d=await I.handleResponse({req:e,nextConfig:m,cacheKey:H,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:_,revalidateOnlyGenerated:T,responseGenerator:u,waitUntil:a.waitUntil,isMinimalMode:o});if(!j)return null;if((null==d||null==(s=d.value)?void 0:s.kind)!==v.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(l=d.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",_?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let R=(0,x.fromNodeOutgoingHttpHeaders)(d.value.headers);return o&&j||R.delete(f.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||R.get("Cache-Control")||R.set("Cache-Control",(0,h.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(K,B,new Response(d.value.body,{headers:R,status:d.value.status||200})),null};L?await l(L):await M.withPropagatedContext(e.headers,()=>M.trace(d.BaseServerSpan.handleRequest,{spanName:`${F} ${g}`,kind:s.SpanKind.SERVER,attributes:{"http.method":F,"http.target":e.url}},l))}catch(t){if(t instanceof R.NoFallbackError||await I.onRequestError(e,t,{routerKind:"App Router",routePath:k,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:q,isOnDemandRevalidate:_})},!1,O),j)throw t;return await (0,p.sendResponse)(K,B,new Response(null,{status:500})),null}}e.s(["handler",()=>q,"patchFetch",()=>U,"routeModule",()=>I,"serverHooks",()=>H,"workAsyncStorage",()=>j,"workUnitAsyncStorage",()=>D],26994)}];
|
|
1
|
+
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},26994,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),u=e.i(87718),c=e.i(95169),d=e.i(47587),p=e.i(66012),h=e.i(70101),g=e.i(26937),x=e.i(10372),f=e.i(93695);e.i(52474);var y=e.i(220),R=e.i(89171),v=e.i(22734),m=e.i(14747),E=e.i(46786),w=e.i(71560),A=e.i(97731);let C=(0,m.join)((0,E.homedir)(),".claude"),O=(0,m.join)(C,"settings.json"),S=(0,m.join)(C,"settings.json.aar.bak"),N=(0,m.join)((0,E.homedir)(),".claude.json"),_=(0,m.join)((0,E.homedir)(),".aar","backups");async function b(e){try{let t,{haiku:r,sonnet:a,opus:n,default:s,reasoning:i}=await e.json();if(void 0===r||void 0===a||void 0===n||void 0===s||void 0===i)return R.NextResponse.json({error:"Missing required fields: haiku, sonnet, opus, default, reasoning"},{status:400});let o=await T(),l=await k(),u={haiku:r,sonnet:a,opus:n,default:s,reasoning:i},c=j(o,l,u),d=I(O,"settings"),p=I(N,"claude");d.success||console.warn("[Claude Apply] Settings backup warning:",d.error),p.success||console.warn("[Claude Apply] Claude.json backup warning:",p.error);let h=function(){try{if((0,v.existsSync)(O)){let e=(0,v.readFileSync)(O,"utf-8"),t=!1;try{let r=JSON.parse(e);t="aar"===r.router_provider}catch{t=!1}return t||(0,v.writeFileSync)(S,e,"utf-8"),{success:!0,existed:!0,isFromAar:t}}return{success:!0,existed:!1,isFromAar:!1}}catch(e){return{success:!1,existed:!1,isFromAar:!1,error:`Backup failed: ${e.message}`}}}();if(!h.success)return R.NextResponse.json({error:h.error},{status:500});if((0,v.existsSync)(C)||(0,v.mkdirSync)(C,{recursive:!0}),(0,v.existsSync)(O))try{let e=JSON.parse((0,v.readFileSync)(O,"utf-8"));t={...e,env:{...e.env||{},...c},router_provider:"aar"}}catch{t=P(o,l,u)}else t=P(o,l,u);let g=function(e){try{let t=JSON.stringify(e,null,2);return JSON.parse(t),(0,v.writeFileSync)(O,t,"utf-8"),{success:!0}}catch(e){return{success:!1,error:`Validation or write failed: ${e.message}`}}}(t);if(!g.success)return R.NextResponse.json({error:g.error},{status:500});let x=function(){try{let e={},t=!1;if((0,v.existsSync)(N))try{let t=(0,v.readFileSync)(N,"utf-8");e=JSON.parse(t)}catch{e={}}else t=!0;if(!0===e.hasCompletedOnboarding)return{success:!0,created:!1};return e.hasCompletedOnboarding=!0,(0,v.writeFileSync)(N,JSON.stringify(e,null,2),"utf-8"),{success:!0,created:t}}catch(e){return{success:!1,created:!1,error:`Failed to update claude.json: ${e.message}`}}}();return x.success||console.warn("[Claude Apply] Onboarding update warning:",x.error),R.NextResponse.json({success:!0,message:"Configuration applied successfully",config:t,backup:h.existed?"Created backup":"No existing config to backup",previousWasFromAar:h.existed&&h.isFromAar,onboarding:x.created?"Created ~/.claude.json":"Updated ~/.claude.json",aarBackups:{settings:d.backupPath,claudeJson:p.backupPath}})}catch(e){return console.error("IDE Apply API error:",e),R.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}async function T(){await (0,w.getDatabase)();let e=await (0,A.getConfig)("port"),t=e?.value||"1357";return`http://localhost:${t}`}async function k(){await (0,w.getDatabase)();let e=await (0,A.getConfig)("api_key");return e?.value||"your-gateway-api-key"}function j(e,t,r){return{ANTHROPIC_AUTH_TOKEN:t,ANTHROPIC_BASE_URL:e,ANTHROPIC_DEFAULT_HAIKU_MODEL:r.haiku,ANTHROPIC_DEFAULT_OPUS_MODEL:r.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:r.sonnet,ANTHROPIC_MODEL:r.default,ANTHROPIC_REASONING_MODEL:r.reasoning,API_TIMEOUT_MS:"3000000",CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:1,hasCompletedOnboarding:!0}}function P(e,t,r){return{router_provider:"aar",env:j(e,t,r)}}function I(e,t){try{if(!(0,v.existsSync)(e))return{success:!0};(0,v.existsSync)(_)||(0,v.mkdirSync)(_,{recursive:!0});let r=new Date().toISOString().replace(/[:.]/g,"-"),a=(0,m.join)(_,`${t}-${r}.json`);return(0,v.copyFileSync)(e,a),{success:!0,backupPath:a}}catch(e){return{success:!1,error:`Backup to AAR failed: ${e.message}`}}}e.s(["POST",()=>b],8245);var D=e.i(8245);let H=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/ide/claude/apply/route",pathname:"/api/ide/claude/apply",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/claude/apply/route.ts",nextConfigOutput:"",userland:D}),{workAsyncStorage:U,workUnitAsyncStorage:F,serverHooks:q}=H;function M(){return(0,a.patchFetch)({workAsyncStorage:U,workUnitAsyncStorage:F})}async function L(e,t,a){H.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let R="/api/ide/claude/apply/route";R=R.replace(/\/index$/,"")||"/";let v=await H.prepare(e,t,{srcPage:R,multiZoneDraftMode:!1});if(!v)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:m,params:E,nextConfig:w,parsedUrl:A,isDraftMode:C,prerenderManifest:O,routerServerContext:S,isOnDemandRevalidate:N,revalidateOnlyGenerated:_,resolvedPathname:b,clientReferenceManifest:T,serverActionsManifest:k}=v,j=(0,o.normalizeAppPath)(R),P=!!(O.dynamicRoutes[j]||O.routes[b]),I=async()=>((null==S?void 0:S.render404)?await S.render404(e,t,A,!1):t.end("This page could not be found"),null);if(P&&!C){let e=!!O.routes[b],t=O.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(w.experimental.adapterPath)return await I();throw new f.NoFallbackError}}let D=null;!P||H.isDev||C||(D="/index"===(D=b)?"/":D);let U=!0===H.isDev||!P,F=P&&!U;k&&T&&(0,i.setManifestsSingleton)({page:R,clientReferenceManifest:T,serverActionsManifest:k});let q=e.method||"GET",M=(0,s.getTracer)(),L=M.getActiveScopeSpan(),$={params:E,prerenderManifest:O,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:U,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:w.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>H.onRequestError(e,t,a,n,S)},sharedContext:{buildId:m}},B=new l.NodeNextRequest(e),K=new l.NodeNextResponse(t),J=u.NextRequestAdapter.fromNodeNextRequest(B,(0,u.signalFromNodeResponse)(t));try{let i=async e=>H.handle(J,$).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=M.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==c.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${q} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${q} ${R}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let u=async({previousCacheEntry:r})=>{try{if(!o&&N&&_&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=$.renderOpts.fetchMetrics;let l=$.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let u=$.renderOpts.collectedTags;if(!P)return await (0,p.sendResponse)(B,K,s,$.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(s.headers);u&&(t[x.NEXT_CACHE_TAGS_HEADER]=u),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==$.renderOpts.collectedRevalidate&&!($.renderOpts.collectedRevalidate>=x.INFINITE_CACHE)&&$.renderOpts.collectedRevalidate,a=void 0===$.renderOpts.collectedExpire||$.renderOpts.collectedExpire>=x.INFINITE_CACHE?void 0:$.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await H.onRequestError(e,t,{routerKind:"App Router",routePath:R,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:F,isOnDemandRevalidate:N})},!1,S),t}},c=await H.handleResponse({req:e,nextConfig:w,cacheKey:D,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:O,isRoutePPREnabled:!1,isOnDemandRevalidate:N,revalidateOnlyGenerated:_,responseGenerator:u,waitUntil:a.waitUntil,isMinimalMode:o});if(!P)return null;if((null==c||null==(s=c.value)?void 0:s.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(l=c.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",N?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,h.fromNodeOutgoingHttpHeaders)(c.value.headers);return o&&P||f.delete(x.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,g.getCacheControlHeader)(c.cacheControl)),await (0,p.sendResponse)(B,K,new Response(c.value.body,{headers:f,status:c.value.status||200})),null};L?await l(L):await M.withPropagatedContext(e.headers,()=>M.trace(c.BaseServerSpan.handleRequest,{spanName:`${q} ${R}`,kind:s.SpanKind.SERVER,attributes:{"http.method":q,"http.target":e.url}},l))}catch(t){if(t instanceof f.NoFallbackError||await H.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,d.getRevalidateReason)({isStaticGeneration:F,isOnDemandRevalidate:N})},!1,S),P)throw t;return await (0,p.sendResponse)(B,K,new Response(null,{status:500})),null}}e.s(["handler",()=>L,"patchFetch",()=>M,"routeModule",()=>H,"serverHooks",()=>q,"workAsyncStorage",()=>U,"workUnitAsyncStorage",()=>F],26994)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=%5Broot-of-the-server%5D__5e8276bc._.js.map
|