@circuitwall/jarela 0.14.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +1 -1
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +2 -2
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js +6 -1
- package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/agents/route.js +6 -1
- package/.next/standalone/.next/server/app/api/v1/agents/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +9 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/route.js +9 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +36 -29
- package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/events/route.js +7 -1
- package/.next/standalone/.next/server/app/api/v1/events/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/route.js +3 -3
- package/.next/standalone/.next/server/app/api/v1/extensions/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +4 -4
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/health/route.js +7 -1
- package/.next/standalone/.next/server/app/api/v1/health/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js +9 -1
- package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js +9 -1
- package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/models/route.js +6 -1
- package/.next/standalone/.next/server/app/api/v1/models/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +7 -1
- package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +14 -7
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js +28 -0
- package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/providers/route.js +7 -1
- package/.next/standalone/.next/server/app/api/v1/providers/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js +16 -2
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/threads/route.js +6 -1
- package/.next/standalone/.next/server/app/api/v1/threads/route.js.map +1 -1
- package/.next/standalone/.next/server/app/api/v1/tools/route.js +10 -3
- package/.next/standalone/.next/server/app/api/v1/tools/route.js.map +1 -1
- package/.next/standalone/.next/server/app/index.html +2 -2
- package/.next/standalone/.next/server/app/index.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page.js +56 -0
- package/.next/standalone/.next/server/app/page.js.map +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/setup.html +1 -1
- package/.next/standalone/.next/server/app/setup.rsc +2 -2
- package/.next/standalone/.next/server/app/setup.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/setup.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/setup.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/setup.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/setup.segments/setup/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/setup.segments/setup.segment.rsc +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +1 -1
- package/.next/standalone/.next/server/chunks/1683.js +2 -2
- package/.next/standalone/.next/server/chunks/2082.js +122 -13
- package/.next/standalone/.next/server/chunks/2082.js.map +1 -1
- package/.next/standalone/.next/server/chunks/210.js +3 -3
- package/.next/standalone/.next/server/chunks/210.js.map +1 -1
- package/.next/standalone/.next/server/chunks/239.js +1902 -1487
- package/.next/standalone/.next/server/chunks/239.js.map +1 -1
- package/.next/standalone/.next/server/chunks/2447.js +9 -1
- package/.next/standalone/.next/server/chunks/2447.js.map +1 -1
- package/.next/standalone/.next/server/chunks/423.js +125 -16
- package/.next/standalone/.next/server/chunks/423.js.map +1 -1
- package/.next/standalone/.next/server/chunks/4631.js +36 -29
- package/.next/standalone/.next/server/chunks/4631.js.map +1 -1
- package/.next/standalone/.next/server/chunks/5937.js +3 -2
- package/.next/standalone/.next/server/chunks/5937.js.map +1 -1
- package/.next/standalone/.next/server/chunks/{947.js → 8866.js} +11321 -10883
- package/.next/standalone/.next/server/chunks/8866.js.map +1 -0
- package/.next/standalone/.next/server/chunks/9032.js +3 -3
- package/.next/standalone/.next/server/chunks/9032.js.map +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
- package/.next/standalone/.next/server/middleware.js +122 -13
- package/.next/standalone/.next/server/pages/404.html +2 -2
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/proxy.js.map +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/app/{page-473b39ec30c7f569.js → page-a7cae65f235e2942.js} +57 -1
- package/.next/standalone/.next/static/chunks/app/page-a7cae65f235e2942.js.map +1 -0
- package/.next/standalone/.next/static/css/{6f8b1a84bcbcd467.css → e57bdbbbb5a05779.css} +2 -2
- package/.next/standalone/.next/static/css/e57bdbbbb5a05779.css.map +1 -0
- package/.next/standalone/package.json +9 -1
- package/CHANGELOG.md +90 -0
- package/README.md +30 -2
- package/api/types.ts +8 -0
- package/app/api/v1/agents/[id]/route.ts +7 -0
- package/app/api/v1/agents/route.ts +7 -0
- package/app/api/v1/events/route.ts +8 -0
- package/app/api/v1/extensions/route.ts +2 -2
- package/app/api/v1/extensions/tools/[name]/secrets/route.ts +3 -3
- package/app/api/v1/health/route.ts +8 -0
- package/app/api/v1/models/route.ts +7 -0
- package/app/api/v1/page-capture/route.ts +8 -0
- package/app/api/v1/providers/route.ts +8 -0
- package/app/api/v1/threads/[thread_id]/route.ts +8 -0
- package/app/api/v1/threads/[thread_id]/run/route.ts +9 -0
- package/app/api/v1/threads/route.ts +7 -0
- package/app/api/v1/tools/route.ts +9 -0
- package/components/chat/ContextUsageBar.tsx +44 -0
- package/lib/agents/llm.ts +25 -2
- package/lib/agents/run-thread.ts +13 -1
- package/lib/agents/stream-collector.ts +9 -1
- package/lib/api/serializers.test.ts +15 -0
- package/lib/api/serializers.ts +8 -0
- package/lib/db/migrations.ts +15 -0
- package/lib/health/runner.test.ts +24 -2
- package/lib/mcp/registry.ts +14 -6
- package/lib/providers/anthropic.test.ts +95 -0
- package/lib/providers/anthropic.ts +106 -10
- package/lib/providers/jarela-chat-model.ts +9 -1
- package/lib/providers/known-context-windows.ts +21 -0
- package/lib/providers/types.ts +21 -1
- package/lib/stores/message-usage.test.ts +34 -0
- package/lib/stores/message-usage.ts +15 -3
- package/lib/stores/pricing.test.ts +52 -0
- package/lib/stores/pricing.ts +26 -1
- package/lib/tools/builtins.ts +4 -0
- package/lib/tools/extension-surfaces.test.ts +79 -0
- package/lib/tools/extension-surfaces.ts +153 -0
- package/lib/tools/index.ts +27 -8
- package/lib/tools/list-tools.test.ts +76 -0
- package/lib/tools/list-tools.ts +84 -0
- package/lib/tools/mcp-servers-info.test.ts +73 -0
- package/lib/tools/mcp-servers-info.ts +71 -0
- package/lib/tools/providers-info.test.ts +73 -0
- package/lib/tools/providers-info.ts +106 -0
- package/lib/tools/registry.ts +36 -25
- package/lib/tools/types.ts +13 -0
- package/package.json +9 -1
- package/.next/standalone/.next/server/chunks/947.js.map +0 -1
- package/.next/standalone/.next/static/chunks/app/page-473b39ec30c7f569.js.map +0 -1
- package/.next/standalone/.next/static/css/6f8b1a84bcbcd467.css.map +0 -1
- /package/.next/standalone/.next/static/{T0p2VVPsJPj44rwbmjaFb → d_vhp-lJqfdjRFpnLVIqZ}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{T0p2VVPsJPj44rwbmjaFb → d_vhp-lJqfdjRFpnLVIqZ}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"../app/api/v1/health/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACA2C;AACmB;AACpB;AACmB;AACP;AAE/C,SAASM,IAAIC,GAAY;IAC9B,sEAAsE;IACtE,+CAA+C;IAC/CJ,oBAAKA;IACL,oEAAoE;IACpE,+DAA+D;IAC/D,MAAMK,OAAgC;QACpCC,QAAQ;QACRC,QAAQT,0CAAgBA,GAAGU,GAAG,CAAC,CAACC,IAAMA,EAAEC,EAAE;QAC1CC,QAAQ;YAAEC,QAAQX,yCAAkBA;QAAG;IACzC;IACA,IAAIC,oCAAiBA,CAACE,MAAM;QAC1BC,KAAKQ,OAAO,GAAGd,kBAAOA;IACxB;IACA,OAAOF,mBAAYA,CAACiB,IAAI,CAACT;AAC3B;;;ACrB+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AACqB;AACvF;AACA;AACA;AACA,wBAAwB,mCAAmB;AAC3C;AACA,cAAc,oBAAS;AACvB;AACA;AACA;AACA;AACA,KAAK;AACL,aAAa,OAAoC,IAAI,CAAE;AACvD,wBAAwB,MAAuC;AAC/D;AACA;AACA;AACA,cAAc,qBAAQ;AACtB;AACA;AACA;AACA;AACA,OAAO,MAAsD,GAAG,CAE3D,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA,QAAQ,sDAAsD;AAC9D;AACA,WAAW,0BAAW;AACtB;AACA;AACA,KAAK;AACL;AAC0F;AACnF;AACP;AACA,QAAQ,+BAAc;AACtB;AACA;AACA,QAAQ,+BAAc;AACtB;AACA;AACA;AACA;AACA;AACA,QAAQ,KAAqB,EAAE,EAE1B,CAAC;AACN;AACA;AACA;AACA,+BAA+B,KAAwC;AACvE;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,6NAA6N;AACzO,8BAA8B,+BAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,2CAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,6CAAqB;AAC7B;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,mBAAmB,0BAAS;AAC5B;AACA;AACA,kCAAkC,+BAAc;AAChD,6BAA6B,+BAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,4BAA4B,oBAAe;AAC3C,4BAA4B,qBAAgB;AAC5C,oBAAoB,+BAAkB,kCAAkC,uCAAsB;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,iEAAiE,wBAAc;AAC/E,+DAA+D,yCAAyC;AACxG;AACA;AACA;AACA;AACA,oCAAoC,QAAQ,EAAE,MAAM;AACpD;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,uCAAuC,QAAQ,EAAE,QAAQ;AACzD;AACA,aAAa;AACb;AACA;AACA;AACA,+CAA+C,oBAAoB;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,uCAAyB;AACjE;AACA,oCAAoC,oCAAsB;AAC1D;AACA;AACA;AACA;AACA,sJAAsJ,4BAAc;AACpK,0IAA0I,4BAAc;AACxJ;AACA;AACA;AACA,sCAAsC,8BAAe;AACrD;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,8BAA8B,qCAAY;AAC1C;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,oCAAmB;AACjE;AACA;AACA,6BAA6B;AAC7B,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,oBAAS;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,qIAAqI,8BAAe;AACpJ;AACA,2GAA2G,iHAAiH;AAC5N;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,yCAA2B;AACvD;AACA,+BAA+B,oCAAsB;AACrD;AACA;AACA;AACA;AACA,6CAA6C,uCAAqB;AAClE;AACA,kBAAkB,qCAAY;AAC9B;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA,6EAA6E,wBA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,wDAAKA,GACFiE,OAAO,CAAC,uEACRgC,GAAG,CAACzC,KAAK+C,SAAS,CAACuB,OAAO9E,OAAOtC;IACpC,OAAOoH;AACT;;;;;;;;AC1XA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;ACAiC;AAEjC,MAAM9E,MAAM,IAAM,IAAIC,OAAOC,WAAW;AASjC,SAASwG;IACd,OAAO1J,wDAAKA,GACTiE,OAAO,CAAC,wDACRC,GAAG;AACR;AAEO,SAASyF,eAAe5H,QAAgB,EAAE6H,WAA2B;IAC1E,MAAMC,UAAU9H,SAASC,IAAI;IAC7B,IAAI,CAAC6H,SAAS,MAAM,IAAIC,MAAM;IAC9B9J,wDAAKA,GACFiE,OAAO,CACN,CAAC;;6EAEsE,CAAC,EAEzEgC,GAAG,CAAC4D,SAASD,aAAa5H,UAAU,MAAMgB;IAC7C,OAAOhD,wDAAKA,GACTiE,OAAO,CAAC,mDACR3C,GAAG,CAACuI;AACT;AAEO,SAASE,oBAAoBhI,QAAgB;IAClD/B,wDAAKA,GAAGiE,OAAO,CAAC,iDAAiDgC,GAAG,CAAClE;AACvE;AAEO,SAAShB,cAAcgB,QAAgB;IAC5C,MAAMqB,MAAMpD,QACTiE,OAAO,CAAC,mDACR3C,GAAG,CAACS;IACP,OAAO,CAAC,CAACqB;AACX;AAEO,SAASpC,cAAce,QAAgB;IAC5C,IAAI;QACF/B,QACGiE,OAAO,CAAC,+DACRgC,GAAG,CAACjD,OAAOjB;IAChB,EAAE,OAAM;IACN,8CAA8C;IAChD;AACF;;;;;;;;ACnDA","sources":["webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/router/utils/app-paths\"","webpack://@circuitwall/jarela/external node-commonjs \"node:process\"","webpack://@circuitwall/jarela/external commonjs2 \"url\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/after-task-async-storage.external.js\"","webpack://@circuitwall/jarela/external commonjs \"undici\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-page.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:async_hooks\"","webpack://@circuitwall/jarela/external commonjs2 \"stream\"","webpack://@circuitwall/jarela/external commonjs2 \"util\"","webpack://@circuitwall/jarela/external commonjs2 \"fs\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:child_process\"","webpack://@circuitwall/jarela/./app/api/v1/health/route.ts","webpack://@circuitwall/jarela/?0bfb","webpack://@circuitwall/jarela/external commonjs2 \"path\"","webpack://@circuitwall/jarela/./lib/auth/access.ts","webpack://@circuitwall/jarela/external node-commonjs \"node:http\"","webpack://@circuitwall/jarela/./lib/stores/agent-configs.ts","webpack://@circuitwall/jarela/external node-commonjs \"node:https\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-route.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:os\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs/promises\"","webpack://@circuitwall/jarela/external commonjs2 \"crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"https\"","webpack://@circuitwall/jarela/external node-commonjs \"node:stream\"","webpack://@circuitwall/jarela/external node-commonjs \"node:util\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-unit-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs\"","webpack://@circuitwall/jarela/external node-commonjs \"node:url\"","webpack://@circuitwall/jarela/external node-commonjs \"node:worker_threads\"","webpack://@circuitwall/jarela/external node-commonjs \"node:path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"buffer\"","webpack://@circuitwall/jarela/external node-commonjs \"node:sqlite\"","webpack://@circuitwall/jarela/external commonjs2 \"http\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/no-fallback-error.external\"","webpack://@circuitwall/jarela/./lib/stores/access.ts","webpack://@circuitwall/jarela/external commonjs2 \"events\""],"sourcesContent":["module.exports = require(\"next/dist/shared/lib/router/utils/app-paths\");","module.exports = require(\"node:process\");","module.exports = require(\"url\");","module.exports = require(\"next/dist/server/app-render/after-task-async-storage.external.js\");","module.exports = require(\"undici\");","module.exports = require(\"next/dist/compiled/next-server/app-page.runtime.prod.js\");","module.exports = require(\"node:async_hooks\");","module.exports = require(\"stream\");","module.exports = require(\"util\");","module.exports = require(\"fs\");","module.exports = require(\"next/dist/server/app-render/work-async-storage.external.js\");","module.exports = require(\"node:child_process\");","import { NextResponse } from \"next/server\";\nimport { listAgentConfigs } from \"@/lib/stores/agent-configs\";\nimport { DB_PATH, getDb } from \"@/lib/db\";\nimport { getMasterKeySource } from \"@/lib/crypto/master-key\";\nimport { isLoopbackRequest } from \"@/lib/auth/access\";\n\nexport function GET(req: Request) {\n // Touch the DB so master-key bootstrap has definitely run by the time\n // we report its source. getDb() is idempotent.\n getDb();\n // db_path leaks the host's filesystem layout. Only expose it to the\n // local user (loopback Host); tailnet clients see status only.\n const body: Record<string, unknown> = {\n status: \"ok\",\n agents: listAgentConfigs().map((a) => a.id),\n crypto: { source: getMasterKeySource() },\n };\n if (isLoopbackRequest(req)) {\n body.db_path = DB_PATH;\n }\n return NextResponse.json(body);\n}\n","import { AppRouteRouteModule } from \"next/dist/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/lib/constants\";\nimport { NoFallbackError } from \"next/dist/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/server/response-cache\";\nimport * as userland from \"/home/runner/work/jarela/jarela/app/api/v1/health/route.ts\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"standalone\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/v1/health/route\",\n pathname: \"/api/v1/health\",\n filename: \"route\",\n bundlePath: \"app/api/v1/health/route\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"/home/runner/work/jarela/jarela/app/api/v1/health/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"/home/runner/work/jarela/jarela/app/api/v1/health/route.ts\")\n } : {}\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 (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/v1/health/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, deploymentId, 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.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 isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n 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 deploymentId\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 let parentSpan;\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 // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\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 (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\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), undefined, !isWrappedByNextServer);\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","module.exports = require(\"path\");","import { isWhitelisted, touchLastSeen } from \"@/lib/stores/access\";\n\n// Loopback host header signal — only meaningful when the server is bound to\n// 127.0.0.1 (the default). When a reverse proxy fronts Jarela, the proxy is\n// expected to preserve the client's original Host header, so this still\n// distinguishes \"local user typed localhost\" from \"tailnet client\".\nconst LOOPBACK_HOST = /^(localhost|127\\.0\\.0\\.1|\\[::1\\])(:|$)/;\nconst LOOPBACK_IP = /^(127\\.|::1$|::ffff:127\\.)/;\n\nexport type AccessReason = \"loopback\" | \"whitelisted\" | \"no-identity\" | \"not-whitelisted\";\n\nexport interface AccessResult {\n allowed: boolean;\n identity: string | null;\n reason: AccessReason;\n}\n\ninterface HeaderBag {\n get(name: string): string | null;\n}\n\ninterface NodeHeaders {\n [name: string]: string | string[] | undefined;\n}\n\nfunction readHeader(\n headers: HeaderBag | NodeHeaders,\n name: string,\n): string | null {\n if (typeof (headers as HeaderBag).get === \"function\") {\n return (headers as HeaderBag).get(name);\n }\n const lookup = name.toLowerCase();\n const v = (headers as NodeHeaders)[lookup] ?? (headers as NodeHeaders)[name];\n if (Array.isArray(v)) return v[0] ?? null;\n return v ?? null;\n}\n\nexport interface RequireAccessArgs {\n headers: HeaderBag | NodeHeaders;\n host: string | null;\n remoteAddress?: string | null;\n}\n\nexport function requireAccess({ headers, host, remoteAddress }: RequireAccessArgs): AccessResult {\n // If tailscaled is proxying this request through `tailscale serve` it\n // *always* injects the Tailscale-User-Login header. Whenever the header\n // is present, treat the request as a tailnet request and enforce the\n // whitelist, regardless of whether the source IP / Host header looks\n // like loopback. Otherwise a non-whitelisted tailnet user could chat\n // just because the proxy is local.\n const identity = readHeader(headers, \"tailscale-user-login\")?.trim() || null;\n if (identity) {\n if (isWhitelisted(identity)) {\n touchLastSeen(identity);\n return { allowed: true, identity, reason: \"whitelisted\" };\n }\n return { allowed: false, identity, reason: \"not-whitelisted\" };\n }\n\n // No tailscale identity → only loopback is allowed (the host machine's\n // own user typing http://localhost:4312).\n\n // 1. Actual TCP source available — most reliable loopback signal. Used\n // by callers that have the raw socket (e.g. raw Node handlers).\n if (remoteAddress && LOOPBACK_IP.test(remoteAddress)) {\n return { allowed: true, identity: null, reason: \"loopback\" };\n }\n\n // 2. HTTP middleware path: socket source not available, fall back to Host\n // header. Only trustworthy when the bind is 127.0.0.1 (default).\n if (!remoteAddress && host && LOOPBACK_HOST.test(host)) {\n return { allowed: true, identity: null, reason: \"loopback\" };\n }\n\n return { allowed: false, identity: null, reason: \"no-identity\" };\n}\n\n// Convenience wrapper for API route handlers — they only have `Request`.\nexport function isLoopbackRequest(req: Request): boolean {\n const host = req.headers.get(\"host\");\n return !!host && LOOPBACK_HOST.test(host);\n}\n\n// ---------------------------------------------------------------------------\n// CSRF / cross-origin / DNS-rebinding defense\n// ---------------------------------------------------------------------------\n//\n// The proxy auth above accepts any loopback request — but every page in the\n// user's browser can issue `fetch(\"http://127.0.0.1:4312/...\")`, and a\n// remote DNS-rebinding attacker can make `evil.com` resolve to `127.0.0.1`\n// so the request looks loopback to the kernel. We need to confirm the\n// request *originated* same-origin, not just that the socket terminated on\n// loopback.\n//\n// Defense in depth:\n// 1. `Sec-Fetch-Site` — sent by every modern browser. `same-origin` and\n// `none` (top-level nav, address-bar) are safe; `cross-site` and\n// `same-site` are not. Header absent = non-browser caller (curl,\n// installer scripts) — allow, since those can't be tricked into\n// attaching cookies/auth.\n// 2. `Origin` — when present, scheme+host+port must match `Host`. Blocks\n// DNS rebinding because the Origin reflects the URL the attacker's\n// page was loaded from (`https://evil.com`), not the resolved IP.\n//\n// Read-only methods (GET / HEAD / OPTIONS) skip the check: the legitimate\n// SSE attach uses GET and is intentionally cross-tab in some PWA flows,\n// and these methods shouldn't have side effects anyway.\n\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\nconst SAFE_FETCH_SITES = new Set([\"same-origin\", \"none\"]);\n\nexport type OriginCheckReason =\n | \"safe-method\"\n | \"no-headers\"\n | \"same-origin\"\n | \"cross-site\"\n | \"origin-mismatch\";\n\nexport interface OriginCheckResult {\n allowed: boolean;\n reason: OriginCheckReason;\n}\n\nexport interface ValidateRequestOriginArgs {\n method: string;\n headers: HeaderBag | NodeHeaders;\n host: string | null;\n}\n\nexport function validateRequestOrigin({\n method,\n headers,\n host,\n}: ValidateRequestOriginArgs): OriginCheckResult {\n if (SAFE_METHODS.has(method.toUpperCase())) {\n return { allowed: true, reason: \"safe-method\" };\n }\n\n const secFetchSite = readHeader(headers, \"sec-fetch-site\");\n const origin = readHeader(headers, \"origin\");\n\n // Neither header → non-browser caller. The loopback bind plus the\n // tailnet identity check already gate this.\n if (!secFetchSite && !origin) {\n return { allowed: true, reason: \"no-headers\" };\n }\n\n if (secFetchSite && !SAFE_FETCH_SITES.has(secFetchSite)) {\n return { allowed: false, reason: \"cross-site\" };\n }\n\n if (origin && host) {\n try {\n const originHost = new URL(origin).host;\n if (originHost !== host) {\n return { allowed: false, reason: \"origin-mismatch\" };\n }\n } catch {\n // Malformed Origin → reject.\n return { allowed: false, reason: \"origin-mismatch\" };\n }\n }\n\n return { allowed: true, reason: \"same-origin\" };\n}\n","module.exports = require(\"node:http\");","import { getDb } from \"@/lib/db\";\nimport { MBTI_PRESETS, type MbtiType } from \"@/lib/agents/adaptive-persona-presets\";\n\nconst now = () => new Date().toISOString();\n\nexport interface AgentConfigRow {\n id: string;\n name: string;\n icon: string | null;\n identity: string;\n instructions: string;\n tools: string; // JSON string[]\n model_config_name: string | null;\n is_default: number;\n history_limit: number; // 0 = unlimited\n history_window_hours: number; // 0 = no time bound\n never_reply: number; // 1 = run the agent but don't auto-send replies via bridges\n adaptive_persona_enabled: number; // 1 = use runtime mood/tone adaptation hints\n adaptive_persona_strength: number; // 0..100, how strongly to adapt to cues\n adaptive_empathy: number; // 0..100, baseline empathetic tone\n adaptive_expressiveness: number; // 0..100, restrained -> energetic\n adaptive_verbosity: number; // 0..100, concise -> detailed\n adaptive_mbti: string; // one of 16 MBTI types\n voice_enabled: number; // 1 = expose mic/play UI for this agent\n voice_model: string; // Gemini TTS model id\n voice_name: string; // Gemini prebuilt voice name (Kore, Puck, …)\n voice_stt_model: string; // Gemini multimodal model used for transcription\n voice_auto_speak: number; // 1 = auto-play reply when user sent voice\n display_filters: string | null; // JSON: Partial<DisplayFilters>; NULL = inherit defaults (ADR-0022)\n harness_id: string | null; // ADR-0033: per-agent harness override; NULL = inherit global default\n delegate_targets: string | null; // JSON string[] of agent ids this agent may delegate to; NULL/'[]' = none\n // ADR-0043. JSON-encoded `{ hot, warm, facts }` — any positive numbers; the\n // backend divides by sum so the UI can ship raw weights and never has to\n // reconcile to 100. NULL = inherit the model config's value.\n context_tier_proportions: string | null;\n // Per-agent override of the anti-hallucination classifier mode/model.\n // NULL on either column = inherit the global JARELA_HALLUCINATION_DETECTOR_*\n // env knob.\n anti_hallucination_mode: string | null; // \"off\" | \"report\" | \"enforce\"\n anti_hallucination_model_config: string | null; // saved model config name\n // When 1, the system prompt is augmented with a citation-link directive\n // and the assistant turn is post-checked by `anti_hallucination_model_config`\n // for {source link present, source previously visited in this thread}.\n // Independent of `anti_hallucination_mode` — stall detection and citation\n // enforcement can be on/off in any combination.\n require_source_links: number;\n created_at: string;\n updated_at: string;\n}\n\nexport interface AgentTierProportions {\n hot: number;\n warm: number;\n facts: number;\n}\n\n/**\n * Parse the JSON-encoded per-agent override of context tier proportions.\n * Returns `null` for NULL, blank, malformed JSON, or any payload that\n * doesn't have three finite non-negative numeric fields. Callers fall\n * back to the model config's value (or built-in defaults) on null.\n */\nexport function getAgentTierProportions(row: AgentConfigRow): AgentTierProportions | null {\n const raw = row.context_tier_proportions;\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as Partial<AgentTierProportions>;\n const hot = Number(parsed.hot);\n const warm = Number(parsed.warm);\n const facts = Number(parsed.facts);\n if (![hot, warm, facts].every((n) => Number.isFinite(n) && n >= 0)) return null;\n if (hot + warm + facts <= 0) return null;\n return { hot, warm, facts };\n } catch {\n return null;\n }\n}\n\nexport function listAgentConfigs(): AgentConfigRow[] {\n return getDb()\n .prepare(\"SELECT * FROM agent_configs ORDER BY is_default DESC, created_at ASC\")\n .all() as unknown as AgentConfigRow[];\n}\n\nexport function getDefaultAgentConfig(): AgentConfigRow | null {\n return (\n (getDb()\n .prepare(\"SELECT * FROM agent_configs WHERE is_default=1 LIMIT 1\")\n .get() as unknown as AgentConfigRow) ?? null\n );\n}\n\nexport function getAgentConfig(id: string): AgentConfigRow | null {\n return (\n (getDb()\n .prepare(\"SELECT * FROM agent_configs WHERE id=?\")\n .get(id) as unknown as AgentConfigRow) ?? null\n );\n}\n\nexport interface UpsertAgentInput {\n id: string;\n name: string;\n icon?: string | null;\n identity: string;\n instructions: string;\n tools: string[];\n model_config_name?: string | null;\n is_default?: boolean;\n history_limit?: number;\n history_window_hours?: number;\n never_reply?: boolean;\n adaptive_persona_enabled?: boolean;\n adaptive_persona_strength?: number;\n adaptive_empathy?: number;\n adaptive_expressiveness?: number;\n adaptive_verbosity?: number;\n adaptive_mbti?: MbtiType;\n voice_enabled?: boolean;\n voice_model?: string;\n voice_name?: string;\n voice_stt_model?: string;\n voice_auto_speak?: boolean;\n harness_id?: string | null;\n delegate_targets?: string[];\n // ADR-0043. Pass `null` to clear the override and inherit from the model.\n // Pass `undefined` to keep whatever's already on the row (PATCH semantics).\n context_tier_proportions?: AgentTierProportions | null;\n // Per-agent anti-hallucination classifier override. `null` = clear the\n // override (inherit env). `undefined` = keep existing.\n anti_hallucination_mode?: \"off\" | \"regex\" | \"model\" | null;\n anti_hallucination_model_config?: string | null;\n // Citation enforcement (independent of stall detector). `undefined` = keep\n // existing. `false` = disable.\n require_source_links?: boolean;\n}\n\n/**\n * Parse the JSON-encoded delegate whitelist into a deduped string[]. Returns\n * an empty array for NULL, blank, or malformed JSON (delegation is opt-in).\n */\n/**\n * Parse the agent's tool allowlist (`tools` column, stored as a JSON string).\n * Returns an empty array on NULL/blank/malformed JSON — same defensive shape\n * as parseDelegateTargets. Callers that previously did `JSON.parse(cfg.tools)`\n * inline should switch to this getter so the serialization contract stays\n * owned by this store.\n */\nexport function getAgentTools(cfg: Pick<AgentConfigRow, \"tools\"> | null | undefined): string[] {\n if (!cfg?.tools) return [];\n try {\n const parsed = JSON.parse(cfg.tools);\n if (!Array.isArray(parsed)) return [];\n return parsed.filter((x): x is string => typeof x === \"string\" && x.length > 0);\n } catch {\n return [];\n }\n}\n\nexport function parseDelegateTargets(raw: string | null | undefined): string[] {\n if (!raw) return [];\n try {\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n const ids = parsed.filter((x): x is string => typeof x === \"string\" && x.length > 0);\n return Array.from(new Set(ids));\n } catch {\n return [];\n }\n}\n\nexport function upsertAgentConfig(input: UpsertAgentInput): AgentConfigRow {\n const t = now();\n const db = getDb();\n const existing = getAgentConfig(input.id);\n const created_at = existing?.created_at ?? t;\n const mbti = input.adaptive_mbti ?? toMbti(existing?.adaptive_mbti) ?? \"INTJ\";\n const preset = MBTI_PRESETS[mbti];\n const strength = input.adaptive_persona_strength ?? preset.strength;\n const empathy = input.adaptive_empathy ?? preset.empathy;\n const expressiveness = input.adaptive_expressiveness ?? preset.expressiveness;\n const verbosity = input.adaptive_verbosity ?? preset.verbosity;\n if (input.is_default) db.prepare(\"UPDATE agent_configs SET is_default=0\").run();\n // harness_id: explicit `undefined` means \"keep existing\"; explicit `null`\n // means \"use the global default\". Empty string is normalised to null too,\n // matching how the AgentEditor sends \"\" for the inherit option.\n const harnessId =\n input.harness_id === undefined\n ? (existing?.harness_id ?? null)\n : (input.harness_id && input.harness_id.length > 0 ? input.harness_id : null);\n // delegate_targets: undefined = keep existing; explicit empty array clears.\n const delegateTargets = input.delegate_targets === undefined\n ? (existing?.delegate_targets ?? null)\n : JSON.stringify(Array.from(new Set(input.delegate_targets.filter((id) => id && id !== input.id))));\n // context_tier_proportions: undefined = keep existing; null = clear and\n // inherit from the model; object = serialise as JSON. Negative values are\n // clamped to 0 so the upsert can't poison the column with bad data.\n const tierProportions =\n input.context_tier_proportions === undefined\n ? (existing?.context_tier_proportions ?? null)\n : input.context_tier_proportions === null\n ? null\n : JSON.stringify({\n hot: Math.max(0, Number(input.context_tier_proportions.hot) || 0),\n warm: Math.max(0, Number(input.context_tier_proportions.warm) || 0),\n facts: Math.max(0, Number(input.context_tier_proportions.facts) || 0),\n });\n // Anti-hallucination override: `undefined` keeps existing; `null` clears\n // the override (inherits env). Empty-string model is normalised to null\n // so the editor can ship \"\" for the inherit option.\n const antiHallucMode =\n input.anti_hallucination_mode === undefined\n ? (existing?.anti_hallucination_mode ?? null)\n : input.anti_hallucination_mode === null\n ? null\n : (input.anti_hallucination_mode === \"off\" || input.anti_hallucination_mode === \"regex\" || input.anti_hallucination_mode === \"model\")\n ? input.anti_hallucination_mode\n : null;\n const antiHallucModel =\n input.anti_hallucination_model_config === undefined\n ? (existing?.anti_hallucination_model_config ?? null)\n : input.anti_hallucination_model_config && input.anti_hallucination_model_config.trim().length > 0\n ? input.anti_hallucination_model_config.trim()\n : null;\n const requireSourceLinks =\n input.require_source_links === undefined\n ? (existing?.require_source_links ?? 0)\n : (input.require_source_links ? 1 : 0);\n db.prepare(\n `INSERT OR REPLACE INTO agent_configs\n (id, name, icon, identity, instructions, tools, model_config_name, is_default,\n history_limit, history_window_hours, never_reply,\n adaptive_persona_enabled, adaptive_persona_strength, adaptive_empathy, adaptive_expressiveness, adaptive_verbosity, adaptive_mbti,\n voice_enabled, voice_model, voice_name, voice_stt_model, voice_auto_speak,\n harness_id, delegate_targets, context_tier_proportions,\n anti_hallucination_mode, anti_hallucination_model_config, require_source_links,\n created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`\n )\n .run(\n input.id,\n input.name,\n input.icon ?? null,\n input.identity,\n input.instructions,\n JSON.stringify(input.tools),\n input.model_config_name ?? null,\n input.is_default ? 1 : (existing?.is_default ?? 0),\n input.history_limit ?? existing?.history_limit ?? 50,\n input.history_window_hours ?? existing?.history_window_hours ?? 8,\n // never_reply is a boolean toggle — explicit `undefined` means \"keep existing\"\n // (important for PATCH-style updates that omit the field).\n input.never_reply === undefined\n ? (existing?.never_reply ?? 0)\n : (input.never_reply ? 1 : 0),\n input.adaptive_persona_enabled === undefined\n ? (existing?.adaptive_persona_enabled ?? 0)\n : (input.adaptive_persona_enabled ? 1 : 0),\n clampPercent(strength, existing?.adaptive_persona_strength ?? 50),\n clampPercent(empathy, existing?.adaptive_empathy ?? 50),\n clampPercent(expressiveness, existing?.adaptive_expressiveness ?? 50),\n clampPercent(verbosity, existing?.adaptive_verbosity ?? 50),\n mbti,\n input.voice_enabled === undefined\n ? (existing?.voice_enabled ?? 0)\n : (input.voice_enabled ? 1 : 0),\n (input.voice_model ?? existing?.voice_model ?? \"gemini-2.5-flash-preview-tts\").trim() ||\n \"gemini-2.5-flash-preview-tts\",\n (input.voice_name ?? existing?.voice_name ?? \"Kore\").trim() || \"Kore\",\n (input.voice_stt_model ?? existing?.voice_stt_model ?? \"gemini-2.5-flash\").trim() ||\n \"gemini-2.5-flash\",\n input.voice_auto_speak === undefined\n ? (existing?.voice_auto_speak ?? 1)\n : (input.voice_auto_speak ? 1 : 0),\n harnessId,\n delegateTargets,\n tierProportions,\n antiHallucMode,\n antiHallucModel,\n requireSourceLinks,\n created_at,\n t,\n );\n return getAgentConfig(input.id)!;\n}\n\nfunction clampPercent(next: number | undefined, fallback: number): number {\n const n = Number.isFinite(next) ? Number(next) : fallback;\n return Math.max(0, Math.min(100, Math.round(n)));\n}\n\nfunction toMbti(v: string | null | undefined): MbtiType | null {\n if (!v) return null;\n return (v in MBTI_PRESETS ? v : null) as MbtiType | null;\n}\n\nexport function deleteAgentConfig(id: string): boolean {\n return (\n (getDb().prepare(\"DELETE FROM agent_configs WHERE id=?\").run(id) as { changes: number }).changes > 0\n );\n}\n\nexport function generateAgentId(name: string): string {\n const slug = name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 40);\n const suffix = Math.random().toString(36).slice(2, 6);\n return slug ? `${slug}-${suffix}` : `agent-${suffix}`;\n}\n\n// ── ADR-0022: per-agent message-channel display filters ─────────────────\n// Canonical channel keys mirrored in `hooks/useMessageFilters.ts`. Kept\n// in sync there by importing this constant — single source of truth.\nexport const DISPLAY_FILTER_KEYS = [\n \"scheduled_task\",\n \"watcher\",\n \"bridge\",\n \"synthetic\",\n \"tool_use\",\n \"thinking\",\n] as const;\nexport type DisplayFilterKey = (typeof DISPLAY_FILTER_KEYS)[number];\nexport type DisplayFilters = Record<DisplayFilterKey, boolean>;\n\nexport const DISPLAY_FILTER_DEFAULTS: DisplayFilters = {\n scheduled_task: true,\n watcher: true,\n bridge: true,\n synthetic: true,\n tool_use: true,\n thinking: true,\n};\n\nfunction parseDisplayFilters(raw: string | null | undefined): DisplayFilters {\n if (!raw) return { ...DISPLAY_FILTER_DEFAULTS };\n try {\n const parsed = JSON.parse(raw) as Partial<DisplayFilters>;\n // Merge over defaults so newly-added channels stay visible on old rows.\n return { ...DISPLAY_FILTER_DEFAULTS, ...parsed };\n } catch {\n return { ...DISPLAY_FILTER_DEFAULTS };\n }\n}\n\nexport function getAgentDisplayFilters(id: string): DisplayFilters | null {\n const row = getAgentConfig(id);\n if (!row) return null;\n return parseDisplayFilters(row.display_filters);\n}\n\n/**\n * Merge a partial filter map into the agent's stored prefs. Pass `null` to\n * reset to defaults (clears the column). Safe against concurrent toggles\n * from multiple browser tabs because the merge happens server-side.\n */\nexport function updateAgentDisplayFilters(\n id: string,\n patch: Partial<DisplayFilters> | null,\n): DisplayFilters | null {\n const row = getAgentConfig(id);\n if (!row) return null;\n if (patch === null) {\n getDb()\n .prepare(\"UPDATE agent_configs SET display_filters=NULL, updated_at=? WHERE id=?\")\n .run(now(), id);\n return { ...DISPLAY_FILTER_DEFAULTS };\n }\n const current = parseDisplayFilters(row.display_filters);\n const next: DisplayFilters = { ...current };\n for (const k of DISPLAY_FILTER_KEYS) {\n if (k in patch && typeof patch[k] === \"boolean\") next[k] = patch[k] as boolean;\n }\n getDb()\n .prepare(\"UPDATE agent_configs SET display_filters=?, updated_at=? WHERE id=?\")\n .run(JSON.stringify(next), now(), id);\n return next;\n}\n","module.exports = require(\"node:https\");","module.exports = require(\"next/dist/compiled/next-server/app-route.runtime.prod.js\");","module.exports = require(\"node:os\");","module.exports = require(\"node:fs/promises\");","module.exports = require(\"crypto\");","module.exports = require(\"https\");","module.exports = require(\"node:stream\");","module.exports = require(\"node:util\");","module.exports = require(\"next/dist/server/app-render/work-unit-async-storage.external.js\");","module.exports = require(\"node:fs\");","module.exports = require(\"node:url\");","module.exports = require(\"node:worker_threads\");","module.exports = require(\"node:path\");","module.exports = require(\"node:crypto\");","module.exports = require(\"buffer\");","module.exports = require(\"node:sqlite\");","module.exports = require(\"http\");","module.exports = require(\"next/dist/shared/lib/no-fallback-error.external\");","import { getDb } from \"@/lib/db\";\n\nconst now = () => new Date().toISOString();\n\nexport interface WhitelistEntry {\n identity: string;\n display_name: string | null;\n added_at: string;\n last_seen_at: string | null;\n}\n\nexport function listWhitelist(): WhitelistEntry[] {\n return getDb()\n .prepare(\"SELECT * FROM access_whitelist ORDER BY added_at ASC\")\n .all() as unknown as WhitelistEntry[];\n}\n\nexport function addToWhitelist(identity: string, displayName?: string | null): WhitelistEntry {\n const trimmed = identity.trim();\n if (!trimmed) throw new Error(\"identity is required\");\n getDb()\n .prepare(\n `INSERT INTO access_whitelist (identity, display_name, added_at, last_seen_at)\n VALUES (?, ?, ?, NULL)\n ON CONFLICT(identity) DO UPDATE SET display_name=excluded.display_name`,\n )\n .run(trimmed, displayName?.trim() || null, now());\n return getDb()\n .prepare(\"SELECT * FROM access_whitelist WHERE identity=?\")\n .get(trimmed) as unknown as WhitelistEntry;\n}\n\nexport function removeFromWhitelist(identity: string): void {\n getDb().prepare(\"DELETE FROM access_whitelist WHERE identity=?\").run(identity);\n}\n\nexport function isWhitelisted(identity: string): boolean {\n const row = getDb()\n .prepare(\"SELECT 1 FROM access_whitelist WHERE identity=?\")\n .get(identity);\n return !!row;\n}\n\nexport function touchLastSeen(identity: string): void {\n try {\n getDb()\n .prepare(\"UPDATE access_whitelist SET last_seen_at=? WHERE identity=?\")\n .run(now(), identity);\n } catch {\n // best-effort — never let this fail a request\n }\n}\n","module.exports = require(\"events\");"],"names":["NextResponse","listAgentConfigs","DB_PATH","getDb","getMasterKeySource","isLoopbackRequest","GET","req","body","status","agents","map","a","id","crypto","source","db_path","json","isWhitelisted","touchLastSeen","LOOPBACK_HOST","LOOPBACK_IP","readHeader","headers","name","get","lookup","toLowerCase","v","Array","isArray","requireAccess","host","remoteAddress","identity","trim","allowed","reason","test","SAFE_METHODS","Set","SAFE_FETCH_SITES","validateRequestOrigin","method","has","toUpperCase","secFetchSite","origin","originHost","URL","MBTI_PRESETS","now","Date","toISOString","getAgentTierProportions","row","raw","context_tier_proportions","parsed","JSON","parse","hot","Number","warm","facts","every","n","isFinite","prepare","all","getDefaultAgentConfig","getAgentConfig","getAgentTools","cfg","tools","filter","x","length","parseDelegateTargets","ids","from","upsertAgentConfig","input","t","db","existing","created_at","mbti","adaptive_mbti","toMbti","preset","strength","adaptive_persona_strength","empathy","adaptive_empathy","expressiveness","adaptive_expressiveness","verbosity","adaptive_verbosity","is_default","run","harnessId","harness_id","undefined","delegateTargets","delegate_targets","stringify","tierProportions","Math","max","antiHallucMode","anti_hallucination_mode","antiHallucModel","anti_hallucination_model_config","requireSourceLinks","require_source_links","icon","instructions","model_config_name","history_limit","history_window_hours","never_reply","adaptive_persona_enabled","clampPercent","voice_enabled","voice_model","voice_name","voice_stt_model","voice_auto_speak","next","fallback","min","round","deleteAgentConfig","changes","generateAgentId","slug","replace","slice","suffix","random","toString","DISPLAY_FILTER_KEYS","DISPLAY_FILTER_DEFAULTS","scheduled_task","watcher","bridge","synthetic","tool_use","thinking","parseDisplayFilters","getAgentDisplayFilters","display_filters","updateAgentDisplayFilters","patch","current","k","listWhitelist","addToWhitelist","displayName","trimmed","Error","removeFromWhitelist"],"sourceRoot":"","ignoreList":[0,3,5,10,19,26,35]}
|
|
1
|
+
{"version":3,"file":"../app/api/v1/health/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;;;;;;CAMC,GAE0C;AACmB;AACpB;AACmB;AACP;AAE/C,SAASM,IAAIC,GAAY;IAC9B,sEAAsE;IACtE,+CAA+C;IAC/CJ,oBAAKA;IACL,oEAAoE;IACpE,+DAA+D;IAC/D,MAAMK,OAAgC;QACpCC,QAAQ;QACRC,QAAQT,0CAAgBA,GAAGU,GAAG,CAAC,CAACC,IAAMA,EAAEC,EAAE;QAC1CC,QAAQ;YAAEC,QAAQX,yCAAkBA;QAAG;IACzC;IACA,IAAIC,oCAAiBA,CAACE,MAAM;QAC1BC,KAAKQ,OAAO,GAAGd,kBAAOA;IACxB;IACA,OAAOF,mBAAYA,CAACiB,IAAI,CAACT;AAC3B;;;AC7B+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AACqB;AACvF;AACA;AACA;AACA,wBAAwB,mCAAmB;AAC3C;AACA,cAAc,oBAAS;AACvB;AACA;AACA;AACA;AACA,KAAK;AACL,aAAa,OAAoC,IAAI,CAAE;AACvD,wBAAwB,MAAuC;AAC/D;AACA;AACA;AACA,cAAc,qBAAQ;AACtB;AACA;AACA;AACA;AACA,OAAO,MAAsD,GAAG,CAE3D,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA,QAAQ,sDAAsD;AAC9D;AACA,WAAW,0BAAW;AACtB;AACA;AACA,KAAK;AACL;AAC0F;AACnF;AACP;AACA,QAAQ,+BAAc;AACtB;AACA;AACA,QAAQ,+BAAc;AACtB;AACA;AACA;AACA;AACA;AACA,QAAQ,KAAqB,EAAE,EAE1B,CAAC;AACN;AACA;AACA;AACA,+BAA+B,KAAwC;AACvE;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,6NAA6N;AACzO,8BAA8B,+BAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,2CAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,6CAAqB;AAC7B;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,mBAAmB,0BAAS;AAC5B;AACA;AACA,kCAAkC,+BAAc;AAChD,6BAA6B,+BAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,4BAA4B,oBAAe;AAC3C,4BAA4B,qBAAgB;AAC5C,oBAAoB,+BAAkB,kCAAkC,uCAAsB;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,iEAAiE,wBAAc;AAC/E,+DAA+D,yCAAyC;AACxG;AACA;AACA;AACA;AACA,oCAAoC,QAAQ,EAAE,MAAM;AACpD;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,uCAAuC,QAAQ,EAAE,QAAQ;AACzD;AACA,aAAa;AACb;AACA;AACA;AACA,+CAA+C,oBAAoB;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,uCAAyB;AACjE;AACA,oCAAoC,oCAAsB;AAC1D;AACA;AACA;AACA;AACA,sJAAsJ,4BAAc;AACpK,0IAA0I,4BAAc;AACxJ;AACA;AACA;AACA,sCAAsC,8BAAe;AACrD;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,8BAA8B,qCAAY;AAC1C;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,oCAAmB;AACjE;AACA;AACA,6BAA6B;AAC7B,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,oBAAS;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,qIAAqI,8BAAe;AACpJ;AACA,2GAA2G,iHAAiH;AAC5N;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,yCAA2B;AACvD;AACA,+BAA+B,oCAAsB;AACrD;AACA;AACA;AACA;AAC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,CAACjD,OAAOjB;IAChB,EAAE,OAAM;IACN,8CAA8C;IAChD;AACF;;;;;;;;ACnDA","sources":["webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/router/utils/app-paths\"","webpack://@circuitwall/jarela/external node-commonjs \"node:process\"","webpack://@circuitwall/jarela/external commonjs2 \"url\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/after-task-async-storage.external.js\"","webpack://@circuitwall/jarela/external commonjs \"undici\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-page.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:async_hooks\"","webpack://@circuitwall/jarela/external commonjs2 \"stream\"","webpack://@circuitwall/jarela/external commonjs2 \"util\"","webpack://@circuitwall/jarela/external commonjs2 \"fs\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:child_process\"","webpack://@circuitwall/jarela/./app/api/v1/health/route.ts","webpack://@circuitwall/jarela/?0bfb","webpack://@circuitwall/jarela/external commonjs2 \"path\"","webpack://@circuitwall/jarela/./lib/auth/access.ts","webpack://@circuitwall/jarela/external node-commonjs \"node:http\"","webpack://@circuitwall/jarela/./lib/stores/agent-configs.ts","webpack://@circuitwall/jarela/external node-commonjs \"node:https\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-route.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:os\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs/promises\"","webpack://@circuitwall/jarela/external commonjs2 \"crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"https\"","webpack://@circuitwall/jarela/external node-commonjs \"node:stream\"","webpack://@circuitwall/jarela/external node-commonjs \"node:util\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-unit-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs\"","webpack://@circuitwall/jarela/external node-commonjs \"node:url\"","webpack://@circuitwall/jarela/external node-commonjs \"node:worker_threads\"","webpack://@circuitwall/jarela/external node-commonjs \"node:path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"buffer\"","webpack://@circuitwall/jarela/external node-commonjs \"node:sqlite\"","webpack://@circuitwall/jarela/external commonjs2 \"http\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/no-fallback-error.external\"","webpack://@circuitwall/jarela/./lib/stores/access.ts","webpack://@circuitwall/jarela/external commonjs2 \"events\""],"sourcesContent":["module.exports = require(\"next/dist/shared/lib/router/utils/app-paths\");","module.exports = require(\"node:process\");","module.exports = require(\"url\");","module.exports = require(\"next/dist/server/app-render/after-task-async-storage.external.js\");","module.exports = require(\"undici\");","module.exports = require(\"next/dist/compiled/next-server/app-page.runtime.prod.js\");","module.exports = require(\"node:async_hooks\");","module.exports = require(\"stream\");","module.exports = require(\"util\");","module.exports = require(\"fs\");","module.exports = require(\"next/dist/server/app-render/work-async-storage.external.js\");","module.exports = require(\"node:child_process\");","/**\n * @public — `GET /api/v1/health`\n *\n * Liveness/readiness probe. Returns DB-path, agent count, and basic\n * runtime metadata. The browser extension and external uptime monitors\n * poll this. See `docs/api.md`.\n */\n\nimport { NextResponse } from \"next/server\";\nimport { listAgentConfigs } from \"@/lib/stores/agent-configs\";\nimport { DB_PATH, getDb } from \"@/lib/db\";\nimport { getMasterKeySource } from \"@/lib/crypto/master-key\";\nimport { isLoopbackRequest } from \"@/lib/auth/access\";\n\nexport function GET(req: Request) {\n // Touch the DB so master-key bootstrap has definitely run by the time\n // we report its source. getDb() is idempotent.\n getDb();\n // db_path leaks the host's filesystem layout. Only expose it to the\n // local user (loopback Host); tailnet clients see status only.\n const body: Record<string, unknown> = {\n status: \"ok\",\n agents: listAgentConfigs().map((a) => a.id),\n crypto: { source: getMasterKeySource() },\n };\n if (isLoopbackRequest(req)) {\n body.db_path = DB_PATH;\n }\n return NextResponse.json(body);\n}\n","import { AppRouteRouteModule } from \"next/dist/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/lib/constants\";\nimport { NoFallbackError } from \"next/dist/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/server/response-cache\";\nimport * as userland from \"/home/runner/work/jarela/jarela/app/api/v1/health/route.ts\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"standalone\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/v1/health/route\",\n pathname: \"/api/v1/health\",\n filename: \"route\",\n bundlePath: \"app/api/v1/health/route\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"/home/runner/work/jarela/jarela/app/api/v1/health/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"/home/runner/work/jarela/jarela/app/api/v1/health/route.ts\")\n } : {}\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 (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/v1/health/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, deploymentId, 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.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 isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n 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 deploymentId\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 let parentSpan;\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 // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\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 (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\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), undefined, !isWrappedByNextServer);\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","module.exports = require(\"path\");","import { isWhitelisted, touchLastSeen } from \"@/lib/stores/access\";\n\n// Loopback host header signal — only meaningful when the server is bound to\n// 127.0.0.1 (the default). When a reverse proxy fronts Jarela, the proxy is\n// expected to preserve the client's original Host header, so this still\n// distinguishes \"local user typed localhost\" from \"tailnet client\".\nconst LOOPBACK_HOST = /^(localhost|127\\.0\\.0\\.1|\\[::1\\])(:|$)/;\nconst LOOPBACK_IP = /^(127\\.|::1$|::ffff:127\\.)/;\n\nexport type AccessReason = \"loopback\" | \"whitelisted\" | \"no-identity\" | \"not-whitelisted\";\n\nexport interface AccessResult {\n allowed: boolean;\n identity: string | null;\n reason: AccessReason;\n}\n\ninterface HeaderBag {\n get(name: string): string | null;\n}\n\ninterface NodeHeaders {\n [name: string]: string | string[] | undefined;\n}\n\nfunction readHeader(\n headers: HeaderBag | NodeHeaders,\n name: string,\n): string | null {\n if (typeof (headers as HeaderBag).get === \"function\") {\n return (headers as HeaderBag).get(name);\n }\n const lookup = name.toLowerCase();\n const v = (headers as NodeHeaders)[lookup] ?? (headers as NodeHeaders)[name];\n if (Array.isArray(v)) return v[0] ?? null;\n return v ?? null;\n}\n\nexport interface RequireAccessArgs {\n headers: HeaderBag | NodeHeaders;\n host: string | null;\n remoteAddress?: string | null;\n}\n\nexport function requireAccess({ headers, host, remoteAddress }: RequireAccessArgs): AccessResult {\n // If tailscaled is proxying this request through `tailscale serve` it\n // *always* injects the Tailscale-User-Login header. Whenever the header\n // is present, treat the request as a tailnet request and enforce the\n // whitelist, regardless of whether the source IP / Host header looks\n // like loopback. Otherwise a non-whitelisted tailnet user could chat\n // just because the proxy is local.\n const identity = readHeader(headers, \"tailscale-user-login\")?.trim() || null;\n if (identity) {\n if (isWhitelisted(identity)) {\n touchLastSeen(identity);\n return { allowed: true, identity, reason: \"whitelisted\" };\n }\n return { allowed: false, identity, reason: \"not-whitelisted\" };\n }\n\n // No tailscale identity → only loopback is allowed (the host machine's\n // own user typing http://localhost:4312).\n\n // 1. Actual TCP source available — most reliable loopback signal. Used\n // by callers that have the raw socket (e.g. raw Node handlers).\n if (remoteAddress && LOOPBACK_IP.test(remoteAddress)) {\n return { allowed: true, identity: null, reason: \"loopback\" };\n }\n\n // 2. HTTP middleware path: socket source not available, fall back to Host\n // header. Only trustworthy when the bind is 127.0.0.1 (default).\n if (!remoteAddress && host && LOOPBACK_HOST.test(host)) {\n return { allowed: true, identity: null, reason: \"loopback\" };\n }\n\n return { allowed: false, identity: null, reason: \"no-identity\" };\n}\n\n// Convenience wrapper for API route handlers — they only have `Request`.\nexport function isLoopbackRequest(req: Request): boolean {\n const host = req.headers.get(\"host\");\n return !!host && LOOPBACK_HOST.test(host);\n}\n\n// ---------------------------------------------------------------------------\n// CSRF / cross-origin / DNS-rebinding defense\n// ---------------------------------------------------------------------------\n//\n// The proxy auth above accepts any loopback request — but every page in the\n// user's browser can issue `fetch(\"http://127.0.0.1:4312/...\")`, and a\n// remote DNS-rebinding attacker can make `evil.com` resolve to `127.0.0.1`\n// so the request looks loopback to the kernel. We need to confirm the\n// request *originated* same-origin, not just that the socket terminated on\n// loopback.\n//\n// Defense in depth:\n// 1. `Sec-Fetch-Site` — sent by every modern browser. `same-origin` and\n// `none` (top-level nav, address-bar) are safe; `cross-site` and\n// `same-site` are not. Header absent = non-browser caller (curl,\n// installer scripts) — allow, since those can't be tricked into\n// attaching cookies/auth.\n// 2. `Origin` — when present, scheme+host+port must match `Host`. Blocks\n// DNS rebinding because the Origin reflects the URL the attacker's\n// page was loaded from (`https://evil.com`), not the resolved IP.\n//\n// Read-only methods (GET / HEAD / OPTIONS) skip the check: the legitimate\n// SSE attach uses GET and is intentionally cross-tab in some PWA flows,\n// and these methods shouldn't have side effects anyway.\n\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\nconst SAFE_FETCH_SITES = new Set([\"same-origin\", \"none\"]);\n\nexport type OriginCheckReason =\n | \"safe-method\"\n | \"no-headers\"\n | \"same-origin\"\n | \"cross-site\"\n | \"origin-mismatch\";\n\nexport interface OriginCheckResult {\n allowed: boolean;\n reason: OriginCheckReason;\n}\n\nexport interface ValidateRequestOriginArgs {\n method: string;\n headers: HeaderBag | NodeHeaders;\n host: string | null;\n}\n\nexport function validateRequestOrigin({\n method,\n headers,\n host,\n}: ValidateRequestOriginArgs): OriginCheckResult {\n if (SAFE_METHODS.has(method.toUpperCase())) {\n return { allowed: true, reason: \"safe-method\" };\n }\n\n const secFetchSite = readHeader(headers, \"sec-fetch-site\");\n const origin = readHeader(headers, \"origin\");\n\n // Neither header → non-browser caller. The loopback bind plus the\n // tailnet identity check already gate this.\n if (!secFetchSite && !origin) {\n return { allowed: true, reason: \"no-headers\" };\n }\n\n if (secFetchSite && !SAFE_FETCH_SITES.has(secFetchSite)) {\n return { allowed: false, reason: \"cross-site\" };\n }\n\n if (origin && host) {\n try {\n const originHost = new URL(origin).host;\n if (originHost !== host) {\n return { allowed: false, reason: \"origin-mismatch\" };\n }\n } catch {\n // Malformed Origin → reject.\n return { allowed: false, reason: \"origin-mismatch\" };\n }\n }\n\n return { allowed: true, reason: \"same-origin\" };\n}\n","module.exports = require(\"node:http\");","import { getDb } from \"@/lib/db\";\nimport { MBTI_PRESETS, type MbtiType } from \"@/lib/agents/adaptive-persona-presets\";\n\nconst now = () => new Date().toISOString();\n\nexport interface AgentConfigRow {\n id: string;\n name: string;\n icon: string | null;\n identity: string;\n instructions: string;\n tools: string; // JSON string[]\n model_config_name: string | null;\n is_default: number;\n history_limit: number; // 0 = unlimited\n history_window_hours: number; // 0 = no time bound\n never_reply: number; // 1 = run the agent but don't auto-send replies via bridges\n adaptive_persona_enabled: number; // 1 = use runtime mood/tone adaptation hints\n adaptive_persona_strength: number; // 0..100, how strongly to adapt to cues\n adaptive_empathy: number; // 0..100, baseline empathetic tone\n adaptive_expressiveness: number; // 0..100, restrained -> energetic\n adaptive_verbosity: number; // 0..100, concise -> detailed\n adaptive_mbti: string; // one of 16 MBTI types\n voice_enabled: number; // 1 = expose mic/play UI for this agent\n voice_model: string; // Gemini TTS model id\n voice_name: string; // Gemini prebuilt voice name (Kore, Puck, …)\n voice_stt_model: string; // Gemini multimodal model used for transcription\n voice_auto_speak: number; // 1 = auto-play reply when user sent voice\n display_filters: string | null; // JSON: Partial<DisplayFilters>; NULL = inherit defaults (ADR-0022)\n harness_id: string | null; // ADR-0033: per-agent harness override; NULL = inherit global default\n delegate_targets: string | null; // JSON string[] of agent ids this agent may delegate to; NULL/'[]' = none\n // ADR-0043. JSON-encoded `{ hot, warm, facts }` — any positive numbers; the\n // backend divides by sum so the UI can ship raw weights and never has to\n // reconcile to 100. NULL = inherit the model config's value.\n context_tier_proportions: string | null;\n // Per-agent override of the anti-hallucination classifier mode/model.\n // NULL on either column = inherit the global JARELA_HALLUCINATION_DETECTOR_*\n // env knob.\n anti_hallucination_mode: string | null; // \"off\" | \"report\" | \"enforce\"\n anti_hallucination_model_config: string | null; // saved model config name\n // When 1, the system prompt is augmented with a citation-link directive\n // and the assistant turn is post-checked by `anti_hallucination_model_config`\n // for {source link present, source previously visited in this thread}.\n // Independent of `anti_hallucination_mode` — stall detection and citation\n // enforcement can be on/off in any combination.\n require_source_links: number;\n created_at: string;\n updated_at: string;\n}\n\nexport interface AgentTierProportions {\n hot: number;\n warm: number;\n facts: number;\n}\n\n/**\n * Parse the JSON-encoded per-agent override of context tier proportions.\n * Returns `null` for NULL, blank, malformed JSON, or any payload that\n * doesn't have three finite non-negative numeric fields. Callers fall\n * back to the model config's value (or built-in defaults) on null.\n */\nexport function getAgentTierProportions(row: AgentConfigRow): AgentTierProportions | null {\n const raw = row.context_tier_proportions;\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as Partial<AgentTierProportions>;\n const hot = Number(parsed.hot);\n const warm = Number(parsed.warm);\n const facts = Number(parsed.facts);\n if (![hot, warm, facts].every((n) => Number.isFinite(n) && n >= 0)) return null;\n if (hot + warm + facts <= 0) return null;\n return { hot, warm, facts };\n } catch {\n return null;\n }\n}\n\nexport function listAgentConfigs(): AgentConfigRow[] {\n return getDb()\n .prepare(\"SELECT * FROM agent_configs ORDER BY is_default DESC, created_at ASC\")\n .all() as unknown as AgentConfigRow[];\n}\n\nexport function getDefaultAgentConfig(): AgentConfigRow | null {\n return (\n (getDb()\n .prepare(\"SELECT * FROM agent_configs WHERE is_default=1 LIMIT 1\")\n .get() as unknown as AgentConfigRow) ?? null\n );\n}\n\nexport function getAgentConfig(id: string): AgentConfigRow | null {\n return (\n (getDb()\n .prepare(\"SELECT * FROM agent_configs WHERE id=?\")\n .get(id) as unknown as AgentConfigRow) ?? null\n );\n}\n\nexport interface UpsertAgentInput {\n id: string;\n name: string;\n icon?: string | null;\n identity: string;\n instructions: string;\n tools: string[];\n model_config_name?: string | null;\n is_default?: boolean;\n history_limit?: number;\n history_window_hours?: number;\n never_reply?: boolean;\n adaptive_persona_enabled?: boolean;\n adaptive_persona_strength?: number;\n adaptive_empathy?: number;\n adaptive_expressiveness?: number;\n adaptive_verbosity?: number;\n adaptive_mbti?: MbtiType;\n voice_enabled?: boolean;\n voice_model?: string;\n voice_name?: string;\n voice_stt_model?: string;\n voice_auto_speak?: boolean;\n harness_id?: string | null;\n delegate_targets?: string[];\n // ADR-0043. Pass `null` to clear the override and inherit from the model.\n // Pass `undefined` to keep whatever's already on the row (PATCH semantics).\n context_tier_proportions?: AgentTierProportions | null;\n // Per-agent anti-hallucination classifier override. `null` = clear the\n // override (inherit env). `undefined` = keep existing.\n anti_hallucination_mode?: \"off\" | \"regex\" | \"model\" | null;\n anti_hallucination_model_config?: string | null;\n // Citation enforcement (independent of stall detector). `undefined` = keep\n // existing. `false` = disable.\n require_source_links?: boolean;\n}\n\n/**\n * Parse the JSON-encoded delegate whitelist into a deduped string[]. Returns\n * an empty array for NULL, blank, or malformed JSON (delegation is opt-in).\n */\n/**\n * Parse the agent's tool allowlist (`tools` column, stored as a JSON string).\n * Returns an empty array on NULL/blank/malformed JSON — same defensive shape\n * as parseDelegateTargets. Callers that previously did `JSON.parse(cfg.tools)`\n * inline should switch to this getter so the serialization contract stays\n * owned by this store.\n */\nexport function getAgentTools(cfg: Pick<AgentConfigRow, \"tools\"> | null | undefined): string[] {\n if (!cfg?.tools) return [];\n try {\n const parsed = JSON.parse(cfg.tools);\n if (!Array.isArray(parsed)) return [];\n return parsed.filter((x): x is string => typeof x === \"string\" && x.length > 0);\n } catch {\n return [];\n }\n}\n\nexport function parseDelegateTargets(raw: string | null | undefined): string[] {\n if (!raw) return [];\n try {\n const parsed = JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n const ids = parsed.filter((x): x is string => typeof x === \"string\" && x.length > 0);\n return Array.from(new Set(ids));\n } catch {\n return [];\n }\n}\n\nexport function upsertAgentConfig(input: UpsertAgentInput): AgentConfigRow {\n const t = now();\n const db = getDb();\n const existing = getAgentConfig(input.id);\n const created_at = existing?.created_at ?? t;\n const mbti = input.adaptive_mbti ?? toMbti(existing?.adaptive_mbti) ?? \"INTJ\";\n const preset = MBTI_PRESETS[mbti];\n const strength = input.adaptive_persona_strength ?? preset.strength;\n const empathy = input.adaptive_empathy ?? preset.empathy;\n const expressiveness = input.adaptive_expressiveness ?? preset.expressiveness;\n const verbosity = input.adaptive_verbosity ?? preset.verbosity;\n if (input.is_default) db.prepare(\"UPDATE agent_configs SET is_default=0\").run();\n // harness_id: explicit `undefined` means \"keep existing\"; explicit `null`\n // means \"use the global default\". Empty string is normalised to null too,\n // matching how the AgentEditor sends \"\" for the inherit option.\n const harnessId =\n input.harness_id === undefined\n ? (existing?.harness_id ?? null)\n : (input.harness_id && input.harness_id.length > 0 ? input.harness_id : null);\n // delegate_targets: undefined = keep existing; explicit empty array clears.\n const delegateTargets = input.delegate_targets === undefined\n ? (existing?.delegate_targets ?? null)\n : JSON.stringify(Array.from(new Set(input.delegate_targets.filter((id) => id && id !== input.id))));\n // context_tier_proportions: undefined = keep existing; null = clear and\n // inherit from the model; object = serialise as JSON. Negative values are\n // clamped to 0 so the upsert can't poison the column with bad data.\n const tierProportions =\n input.context_tier_proportions === undefined\n ? (existing?.context_tier_proportions ?? null)\n : input.context_tier_proportions === null\n ? null\n : JSON.stringify({\n hot: Math.max(0, Number(input.context_tier_proportions.hot) || 0),\n warm: Math.max(0, Number(input.context_tier_proportions.warm) || 0),\n facts: Math.max(0, Number(input.context_tier_proportions.facts) || 0),\n });\n // Anti-hallucination override: `undefined` keeps existing; `null` clears\n // the override (inherits env). Empty-string model is normalised to null\n // so the editor can ship \"\" for the inherit option.\n const antiHallucMode =\n input.anti_hallucination_mode === undefined\n ? (existing?.anti_hallucination_mode ?? null)\n : input.anti_hallucination_mode === null\n ? null\n : (input.anti_hallucination_mode === \"off\" || input.anti_hallucination_mode === \"regex\" || input.anti_hallucination_mode === \"model\")\n ? input.anti_hallucination_mode\n : null;\n const antiHallucModel =\n input.anti_hallucination_model_config === undefined\n ? (existing?.anti_hallucination_model_config ?? null)\n : input.anti_hallucination_model_config && input.anti_hallucination_model_config.trim().length > 0\n ? input.anti_hallucination_model_config.trim()\n : null;\n const requireSourceLinks =\n input.require_source_links === undefined\n ? (existing?.require_source_links ?? 0)\n : (input.require_source_links ? 1 : 0);\n db.prepare(\n `INSERT OR REPLACE INTO agent_configs\n (id, name, icon, identity, instructions, tools, model_config_name, is_default,\n history_limit, history_window_hours, never_reply,\n adaptive_persona_enabled, adaptive_persona_strength, adaptive_empathy, adaptive_expressiveness, adaptive_verbosity, adaptive_mbti,\n voice_enabled, voice_model, voice_name, voice_stt_model, voice_auto_speak,\n harness_id, delegate_targets, context_tier_proportions,\n anti_hallucination_mode, anti_hallucination_model_config, require_source_links,\n created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`\n )\n .run(\n input.id,\n input.name,\n input.icon ?? null,\n input.identity,\n input.instructions,\n JSON.stringify(input.tools),\n input.model_config_name ?? null,\n input.is_default ? 1 : (existing?.is_default ?? 0),\n input.history_limit ?? existing?.history_limit ?? 50,\n input.history_window_hours ?? existing?.history_window_hours ?? 8,\n // never_reply is a boolean toggle — explicit `undefined` means \"keep existing\"\n // (important for PATCH-style updates that omit the field).\n input.never_reply === undefined\n ? (existing?.never_reply ?? 0)\n : (input.never_reply ? 1 : 0),\n input.adaptive_persona_enabled === undefined\n ? (existing?.adaptive_persona_enabled ?? 0)\n : (input.adaptive_persona_enabled ? 1 : 0),\n clampPercent(strength, existing?.adaptive_persona_strength ?? 50),\n clampPercent(empathy, existing?.adaptive_empathy ?? 50),\n clampPercent(expressiveness, existing?.adaptive_expressiveness ?? 50),\n clampPercent(verbosity, existing?.adaptive_verbosity ?? 50),\n mbti,\n input.voice_enabled === undefined\n ? (existing?.voice_enabled ?? 0)\n : (input.voice_enabled ? 1 : 0),\n (input.voice_model ?? existing?.voice_model ?? \"gemini-2.5-flash-preview-tts\").trim() ||\n \"gemini-2.5-flash-preview-tts\",\n (input.voice_name ?? existing?.voice_name ?? \"Kore\").trim() || \"Kore\",\n (input.voice_stt_model ?? existing?.voice_stt_model ?? \"gemini-2.5-flash\").trim() ||\n \"gemini-2.5-flash\",\n input.voice_auto_speak === undefined\n ? (existing?.voice_auto_speak ?? 1)\n : (input.voice_auto_speak ? 1 : 0),\n harnessId,\n delegateTargets,\n tierProportions,\n antiHallucMode,\n antiHallucModel,\n requireSourceLinks,\n created_at,\n t,\n );\n return getAgentConfig(input.id)!;\n}\n\nfunction clampPercent(next: number | undefined, fallback: number): number {\n const n = Number.isFinite(next) ? Number(next) : fallback;\n return Math.max(0, Math.min(100, Math.round(n)));\n}\n\nfunction toMbti(v: string | null | undefined): MbtiType | null {\n if (!v) return null;\n return (v in MBTI_PRESETS ? v : null) as MbtiType | null;\n}\n\nexport function deleteAgentConfig(id: string): boolean {\n return (\n (getDb().prepare(\"DELETE FROM agent_configs WHERE id=?\").run(id) as { changes: number }).changes > 0\n );\n}\n\nexport function generateAgentId(name: string): string {\n const slug = name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 40);\n const suffix = Math.random().toString(36).slice(2, 6);\n return slug ? `${slug}-${suffix}` : `agent-${suffix}`;\n}\n\n// ── ADR-0022: per-agent message-channel display filters ─────────────────\n// Canonical channel keys mirrored in `hooks/useMessageFilters.ts`. Kept\n// in sync there by importing this constant — single source of truth.\nexport const DISPLAY_FILTER_KEYS = [\n \"scheduled_task\",\n \"watcher\",\n \"bridge\",\n \"synthetic\",\n \"tool_use\",\n \"thinking\",\n] as const;\nexport type DisplayFilterKey = (typeof DISPLAY_FILTER_KEYS)[number];\nexport type DisplayFilters = Record<DisplayFilterKey, boolean>;\n\nexport const DISPLAY_FILTER_DEFAULTS: DisplayFilters = {\n scheduled_task: true,\n watcher: true,\n bridge: true,\n synthetic: true,\n tool_use: true,\n thinking: true,\n};\n\nfunction parseDisplayFilters(raw: string | null | undefined): DisplayFilters {\n if (!raw) return { ...DISPLAY_FILTER_DEFAULTS };\n try {\n const parsed = JSON.parse(raw) as Partial<DisplayFilters>;\n // Merge over defaults so newly-added channels stay visible on old rows.\n return { ...DISPLAY_FILTER_DEFAULTS, ...parsed };\n } catch {\n return { ...DISPLAY_FILTER_DEFAULTS };\n }\n}\n\nexport function getAgentDisplayFilters(id: string): DisplayFilters | null {\n const row = getAgentConfig(id);\n if (!row) return null;\n return parseDisplayFilters(row.display_filters);\n}\n\n/**\n * Merge a partial filter map into the agent's stored prefs. Pass `null` to\n * reset to defaults (clears the column). Safe against concurrent toggles\n * from multiple browser tabs because the merge happens server-side.\n */\nexport function updateAgentDisplayFilters(\n id: string,\n patch: Partial<DisplayFilters> | null,\n): DisplayFilters | null {\n const row = getAgentConfig(id);\n if (!row) return null;\n if (patch === null) {\n getDb()\n .prepare(\"UPDATE agent_configs SET display_filters=NULL, updated_at=? WHERE id=?\")\n .run(now(), id);\n return { ...DISPLAY_FILTER_DEFAULTS };\n }\n const current = parseDisplayFilters(row.display_filters);\n const next: DisplayFilters = { ...current };\n for (const k of DISPLAY_FILTER_KEYS) {\n if (k in patch && typeof patch[k] === \"boolean\") next[k] = patch[k] as boolean;\n }\n getDb()\n .prepare(\"UPDATE agent_configs SET display_filters=?, updated_at=? WHERE id=?\")\n .run(JSON.stringify(next), now(), id);\n return next;\n}\n","module.exports = require(\"node:https\");","module.exports = require(\"next/dist/compiled/next-server/app-route.runtime.prod.js\");","module.exports = require(\"node:os\");","module.exports = require(\"node:fs/promises\");","module.exports = require(\"crypto\");","module.exports = require(\"https\");","module.exports = require(\"node:stream\");","module.exports = require(\"node:util\");","module.exports = require(\"next/dist/server/app-render/work-unit-async-storage.external.js\");","module.exports = require(\"node:fs\");","module.exports = require(\"node:url\");","module.exports = require(\"node:worker_threads\");","module.exports = require(\"node:path\");","module.exports = require(\"node:crypto\");","module.exports = require(\"buffer\");","module.exports = require(\"node:sqlite\");","module.exports = require(\"http\");","module.exports = require(\"next/dist/shared/lib/no-fallback-error.external\");","import { getDb } from \"@/lib/db\";\n\nconst now = () => new Date().toISOString();\n\nexport interface WhitelistEntry {\n identity: string;\n display_name: string | null;\n added_at: string;\n last_seen_at: string | null;\n}\n\nexport function listWhitelist(): WhitelistEntry[] {\n return getDb()\n .prepare(\"SELECT * FROM access_whitelist ORDER BY added_at ASC\")\n .all() as unknown as WhitelistEntry[];\n}\n\nexport function addToWhitelist(identity: string, displayName?: string | null): WhitelistEntry {\n const trimmed = identity.trim();\n if (!trimmed) throw new Error(\"identity is required\");\n getDb()\n .prepare(\n `INSERT INTO access_whitelist (identity, display_name, added_at, last_seen_at)\n VALUES (?, ?, ?, NULL)\n ON CONFLICT(identity) DO UPDATE SET display_name=excluded.display_name`,\n )\n .run(trimmed, displayName?.trim() || null, now());\n return getDb()\n .prepare(\"SELECT * FROM access_whitelist WHERE identity=?\")\n .get(trimmed) as unknown as WhitelistEntry;\n}\n\nexport function removeFromWhitelist(identity: string): void {\n getDb().prepare(\"DELETE FROM access_whitelist WHERE identity=?\").run(identity);\n}\n\nexport function isWhitelisted(identity: string): boolean {\n const row = getDb()\n .prepare(\"SELECT 1 FROM access_whitelist WHERE identity=?\")\n .get(identity);\n return !!row;\n}\n\nexport function touchLastSeen(identity: string): void {\n try {\n getDb()\n .prepare(\"UPDATE access_whitelist SET last_seen_at=? WHERE identity=?\")\n .run(now(), identity);\n } catch {\n // best-effort — never let this fail a request\n }\n}\n","module.exports = require(\"events\");"],"names":["NextResponse","listAgentConfigs","DB_PATH","getDb","getMasterKeySource","isLoopbackRequest","GET","req","body","status","agents","map","a","id","crypto","source","db_path","json","isWhitelisted","touchLastSeen","LOOPBACK_HOST","LOOPBACK_IP","readHeader","headers","name","get","lookup","toLowerCase","v","Array","isArray","requireAccess","host","remoteAddress","identity","trim","allowed","reason","test","SAFE_METHODS","Set","SAFE_FETCH_SITES","validateRequestOrigin","method","has","toUpperCase","secFetchSite","origin","originHost","URL","MBTI_PRESETS","now","Date","toISOString","getAgentTierProportions","row","raw","context_tier_proportions","parsed","JSON","parse","hot","Number","warm","facts","every","n","isFinite","prepare","all","getDefaultAgentConfig","getAgentConfig","getAgentTools","cfg","tools","filter","x","length","parseDelegateTargets","ids","from","upsertAgentConfig","input","t","db","existing","created_at","mbti","adaptive_mbti","toMbti","preset","strength","adaptive_persona_strength","empathy","adaptive_empathy","expressiveness","adaptive_expressiveness","verbosity","adaptive_verbosity","is_default","run","harnessId","harness_id","undefined","delegateTargets","delegate_targets","stringify","tierProportions","Math","max","antiHallucMode","anti_hallucination_mode","antiHallucModel","anti_hallucination_model_config","requireSourceLinks","require_source_links","icon","instructions","model_config_name","history_limit","history_window_hours","never_reply","adaptive_persona_enabled","clampPercent","voice_enabled","voice_model","voice_name","voice_stt_model","voice_auto_speak","next","fallback","min","round","deleteAgentConfig","changes","generateAgentId","slug","replace","slice","suffix","random","toString","DISPLAY_FILTER_KEYS","DISPLAY_FILTER_DEFAULTS","scheduled_task","watcher","bridge","synthetic","tool_use","thinking","parseDisplayFilters","getAgentDisplayFilters","display_filters","updateAgentDisplayFilters","patch","current","k","listWhitelist","addToWhitelist","displayName","trimmed","Error","removeFromWhitelist"],"sourceRoot":"","ignoreList":[0,3,5,10,19,26,35]}
|
|
@@ -866,6 +866,12 @@ function mcpServerToResponse(r) {
|
|
|
866
866
|
* chat panel's `ContextUsageBar` consumes. Returns `null` for messages
|
|
867
867
|
* that have no snapshot (user turns and legacy assistant rows recorded
|
|
868
868
|
* before the per-turn snapshot landed in ADR-0041).
|
|
869
|
+
*
|
|
870
|
+
* Anthropic prompt-cache tokens (PR #181 + the cache-fidelity follow-up)
|
|
871
|
+
* are surfaced as additive fields so future UI work can render a
|
|
872
|
+
* "served from cache" badge without another wire change. Both are
|
|
873
|
+
* `null` for rows that predate cache plumbing or for providers that
|
|
874
|
+
* don't expose a cache breakdown.
|
|
869
875
|
*/ function messageUsageToResponse(u) {
|
|
870
876
|
if (!u) return null;
|
|
871
877
|
return {
|
|
@@ -878,7 +884,9 @@ function mcpServerToResponse(r) {
|
|
|
878
884
|
hot_budget_tokens: u.hot_budget_tokens,
|
|
879
885
|
warm_budget_tokens: u.warm_budget_tokens,
|
|
880
886
|
facts_budget_tokens: u.facts_budget_tokens,
|
|
881
|
-
context_window_tokens: u.context_window_tokens
|
|
887
|
+
context_window_tokens: u.context_window_tokens,
|
|
888
|
+
cache_creation_input_tokens: u.cache_creation_input_tokens,
|
|
889
|
+
cache_read_input_tokens: u.cache_read_input_tokens
|
|
882
890
|
};
|
|
883
891
|
}
|
|
884
892
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"../app/api/v1/mcp-servers/[name]/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;ACAA,kEAAkE;AAClE,EAAE;AACF,uEAAuE;AACvE,6DAA6D;AAC7D,yEAAyE;AACzE,qEAAqE;AAE1B;AAIpC,SAASC,cAAcC,OAAe,EAAEC,SAAiB,GAAG;IACjE,OAAOH,qDAAYA,CAACI,IAAI,CAAC;QAAEC,OAAOH;IAAQ,GAAG;QAAEC;IAAO;AACxD;AAEO,SAASG,iBAAiBJ,UAAkB,WAAW;IAC5D,OAAOD,cAAcC,SAAS;AAChC;AAEO,SAASK,gBAAmBC,IAAO;IACxC,OAAOR,qDAAYA,CAACI,IAAI,CAACI,MAAM;QAAEL,QAAQ;IAAI;AAC/C;AAEA,4EAA4E;AAC5E,8EAA8E;AAC9E,wEAAwE;AACxE,yEAAyE;AACzE,0EAA0E;AACnE,SAASM,WAAcD,IAAO,EAAEE,aAAqB;IAC1D,OAAOV,qDAAYA,CAACI,IAAI,CAACI,MAAM;QAC7BG,SAAS;YACP,iBAAiB,CAAC,iBA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;QACzEC,SAASJ,KAAKI,OAAO,IAAKL,SAASK,OAAO,KAAK;IACjD;IACAd,oCAAkBA;IAClB,OAAOvB,mBAAYA,CAACI,IAAI,CAACoB,2CAAmBA,CAACU;AAC/C;AAEO,eAAeI,OAAOX,IAAiB,EAAE,EAAEC,MAAM,EAAU;IAChE,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMD;IACvB,MAAMW,KAAKnB,uCAAeA,CAACS;IAC3B,IAAI,CAACU,IAAI,OAAOjC,sCAAgBA,CAAC;IACjCiB,oCAAkBA;IAClB,OAAOvB,mBAAYA,CAACI,IAAI,CAAC;QAAEoC,SAAS;IAAK;AAC3C;;;AC1C+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AACiC;AACnG;AACA;AACA;AACA,wBAAwB,mCAAmB;AAC3C;AACA,cAAc,oBAAS;AACvB;AACA;AACA;AACA;AACA,KAAK;AACL,aAAa,OAAoC,IAAI,CAAE;AACvD,wBAAwB,MAAuC;AAC/D;AACA;AACA;AACA,cAAc,qBAAQ;AACtB;AACA;AACA;AACA;AACA,OAAO,MAAsD,GAAG,CAE3D,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA,QAAQ,sDAAsD;AAC9D;AACA,WAAW,0BAAW;AACtB;AACA;AACA,KAAK;AACL;AAC0F;AACnF;AACP;AACA,QAAQ,+BAAc;AACtB;AACA;AACA,QAAQ,+BAAc;AACtB;AACA;AACA;AACA;AACA;AACA,QAAQ,KAAqB,EAAE,EAE1B,CAAC;AACN;AACA;AACA;AACA,+BAA+B,KAAwC;AACvE;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,6NAA6N;AACzO,8BAA8B,+BAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,2CAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,6CAAqB;AAC7B;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,mBAAmB,0BAAS;AAC5B;AACA;AACA,kCAAkC,+BAAc;AAChD,6BAA6B,+BAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,4BAA4B,oBAAe;AAC3C,4BAA4B,qBAAgB;AAC5C,oBAAoB,+BAAkB,kCAAkC,uCAAsB;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,iEAAiE,wBAAc;AAC/E,+DAA+D,yCAAyC;AACxG;AACA;AACA;AACA;AACA,oCAAoC,QAAQ,EAAE,MAAM;AACpD;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,uCAAuC,QAAQ,EAAE,QAAQ;AACzD;AACA,aAAa;AACb;AACA;AACA;AACA,+CAA+C,oBAAoB;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,uCAAyB;AACjE;AACA,oCAAoC,oCAAsB;AAC1D;AACA;AACA;AACA;AACA,sJAAsJ,4BAAc;AACpK,0IAA0I,4BAAc;AACxJ;AACA;AACA;AACA,sCAAsC,8BAAe;AACrD;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,8BAA8B,qCAAY;AAC1C;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;A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B,EAAEnB,UAAU;QACxBwB,aAAaC,2BAA2BN,EAAEK,WAAW;QACrDE,UAAUP,EAAEO,QAAQ,IAAI;QACxBC,OAAOrB,uBAAuBc,UAAUQ,GAAG,CAACT,EAAEE,MAAM;QACpDQ,UAAUC,gCAAgCX,EAAEU,QAAQ;IACtD;AACF;AAEA;;iDAEiD,GAC1C,SAASJ,2BAA2BtF,GAA8B;IACvE,IAAI,CAACA,KAAK,OAAO4F;IACjB,IAAI;QACF,MAAM3F,SAAS2B,KAAKC,KAAK,CAAC7B;QAC1B,OAAO6F,MAAMC,OAAO,CAAC7F,UAAUA,SAAS2F;IAC1C,EAAE,OAAM;QACN,OAAOA;IACT;AACF;AAEA;;sEAEsE,GAC/D,SAASD,gCAAgC3F,GAA8B;IAC5E,IAAI,CAACA,KAAK,OAAO;IACjB,IAAI;QACF,MAAMC,SAAS2B,KAAKC,KAAK,CAAC7B;QAC1B,IAAI,CAACC,UAAU,OAAOA,WAAW,YAAY4F,MAAMC,OAAO,CAAC7F,SAAS,OAAO;QAC3E,OAAOA;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;CAMC,GACM,SAAS8F,2BACdC,qBAAgD,EAChDC,aAAqB;IAErB,IAAI,OAAOD,0BAA0B,YAAYA,wBAAwB,GAAG;QAC1E,OAAOA;IACT;IACA,OAAOC;AACT;;;;;;;;ACjKA;;;;;;;ACAA;;;;;;;ACAA","sources":["webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/router/utils/app-paths\"","webpack://@circuitwall/jarela/external node-commonjs \"node:process\"","webpack://@circuitwall/jarela/external commonjs2 \"url\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/after-task-async-storage.external.js\"","webpack://@circuitwall/jarela/external commonjs \"undici\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-page.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:async_hooks\"","webpack://@circuitwall/jarela/external commonjs2 \"stream\"","webpack://@circuitwall/jarela/external commonjs2 \"util\"","webpack://@circuitwall/jarela/external commonjs2 \"fs\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:child_process\"","webpack://@circuitwall/jarela/external commonjs2 \"path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:http\"","webpack://@circuitwall/jarela/./lib/api/responses.ts","webpack://@circuitwall/jarela/./app/api/v1/mcp-servers/[name]/route.ts","webpack://@circuitwall/jarela/?2233","webpack://@circuitwall/jarela/external node-commonjs \"node:https\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-route.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:os\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs/promises\"","webpack://@circuitwall/jarela/./lib/utils/json.ts","webpack://@circuitwall/jarela/external commonjs2 \"crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"https\"","webpack://@circuitwall/jarela/external node-commonjs \"node:stream\"","webpack://@circuitwall/jarela/external node-commonjs \"node:util\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-unit-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs\"","webpack://@circuitwall/jarela/external node-commonjs \"node:url\"","webpack://@circuitwall/jarela/external node-commonjs \"node:worker_threads\"","webpack://@circuitwall/jarela/external node-commonjs \"node:path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"buffer\"","webpack://@circuitwall/jarela/external node-commonjs \"node:sqlite\"","webpack://@circuitwall/jarela/external commonjs2 \"http\"","webpack://@circuitwall/jarela/./lib/api/serializers.ts","webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/no-fallback-error.external\"","webpack://@circuitwall/jarela/external module \"@langchain/mcp-adapters\"","webpack://@circuitwall/jarela/external commonjs2 \"events\""],"sourcesContent":["module.exports = require(\"next/dist/shared/lib/router/utils/app-paths\");","module.exports = require(\"node:process\");","module.exports = require(\"url\");","module.exports = require(\"next/dist/server/app-render/after-task-async-storage.external.js\");","module.exports = require(\"undici\");","module.exports = require(\"next/dist/compiled/next-server/app-page.runtime.prod.js\");","module.exports = require(\"node:async_hooks\");","module.exports = require(\"stream\");","module.exports = require(\"util\");","module.exports = require(\"fs\");","module.exports = require(\"next/dist/server/app-render/work-async-storage.external.js\");","module.exports = require(\"node:child_process\");","module.exports = require(\"path\");","module.exports = require(\"node:http\");","// Shared HTTP response builders for app/api/v1/** route handlers.\n//\n// Goal: every error/success payload across the v1 surface has the same\n// shape. Before this lived inline, response bodies drifted —\n// `{error: \"x\"}` vs `{message: \"x\"}`, 400 vs 422 for the same condition,\n// some routes returned Zod's raw issue array, others stringified it.\n\nimport { NextResponse } from \"next/server\";\nimport type { z } from \"zod\";\nimport type { NextRequest } from \"next/server\";\n\nexport function errorResponse(message: string, status: number = 400): NextResponse {\n return NextResponse.json({ error: message }, { status });\n}\n\nexport function notFoundResponse(message: string = \"Not found\"): NextResponse {\n return errorResponse(message, 404);\n}\n\nexport function createdResponse<T>(data: T): NextResponse {\n return NextResponse.json(data, { status: 201 });\n}\n\n// Wrap a 200 JSON response with a private Cache-Control header. Use on safe\n// GET endpoints that serve user-scoped data the client refetches often (panel\n// mounts, navigation back/forward) but mutates rarely. The TTL is short\n// enough that explicit mutations — which patch the client-side ApiClient\n// cache in place — stay observably consistent without an extra roundtrip.\nexport function cachedJson<T>(data: T, maxAgeSeconds: number): NextResponse {\n return NextResponse.json(data, {\n headers: {\n \"Cache-Control\": `private, max-age=${maxAgeSeconds}`,\n },\n });\n}\n\n// Validate a JSON request body against a zod schema.\n// Returns either the parsed data or a 400 NextResponse explaining the issue.\n// Caller pattern:\n// const parsed = await validateBody(req, Schema);\n// if (parsed instanceof NextResponse) return parsed;\n// // use parsed.field\nexport async function validateBody<S extends z.ZodTypeAny>(\n req: NextRequest,\n schema: S,\n): Promise<z.infer<S> | NextResponse> {\n let raw: unknown;\n try {\n raw = await req.json();\n } catch {\n return errorResponse(\"Request body must be valid JSON\", 400);\n }\n const parsed = schema.safeParse(raw);\n if (!parsed.success) {\n return errorResponse(parsed.error.issues[0]?.message ?? \"invalid body\", 400);\n }\n return parsed.data;\n}\n","import { NextRequest, NextResponse } from \"next/server\";\nimport {\n deleteMcpServer,\n getMcpServer,\n upsertMcpServer,\n type McpServerInput,\n} from \"@/lib/stores/mcp-servers\";\nimport { invalidateMcpTools } from \"@/lib/mcp/client\";\nimport { mcpServerToResponse } from \"@/lib/api/serializers\";\nimport { notFoundResponse } from \"@/lib/api/responses\";\nimport { parseJsonSafe } from \"@/lib/utils/json\";\n\ntype Params = { params: Promise<{ name: string }> };\n\nexport async function GET(_req: NextRequest, { params }: Params) {\n const { name } = await params;\n const r = getMcpServer(name);\n if (!r) return notFoundResponse(\"MCP server not found\");\n return NextResponse.json(mcpServerToResponse(r));\n}\n\nexport async function PUT(req: NextRequest, { params }: Params) {\n const { name } = await params;\n const existing = getMcpServer(name);\n if (!existing) return notFoundResponse(\"MCP server not found\");\n const body = (await req.json()) as Partial<McpServerInput>;\n const row = upsertMcpServer({\n name,\n transport: body.transport ?? (existing.transport as \"stdio\" | \"http\"),\n spec: body.spec ?? parseJsonSafe<McpServerInput[\"spec\"]>(existing.spec, {} as McpServerInput[\"spec\"]),\n enabled: body.enabled ?? (existing.enabled === 1),\n });\n invalidateMcpTools();\n return NextResponse.json(mcpServerToResponse(row));\n}\n\nexport async function DELETE(_req: NextRequest, { params }: Params) {\n const { name } = await params;\n const ok = deleteMcpServer(name);\n if (!ok) return notFoundResponse(\"MCP server not found\");\n invalidateMcpTools();\n return NextResponse.json({ deleted: true });\n}\n","import { AppRouteRouteModule } from \"next/dist/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/lib/constants\";\nimport { NoFallbackError } from \"next/dist/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/server/response-cache\";\nimport * as userland from \"/home/runner/work/jarela/jarela/app/api/v1/mcp-servers/[name]/route.ts\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"standalone\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/v1/mcp-servers/[name]/route\",\n pathname: \"/api/v1/mcp-servers/[name]\",\n filename: \"route\",\n bundlePath: \"app/api/v1/mcp-servers/[name]/route\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"/home/runner/work/jarela/jarela/app/api/v1/mcp-servers/[name]/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"/home/runner/work/jarela/jarela/app/api/v1/mcp-servers/[name]/route.ts\")\n } : {}\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 (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/v1/mcp-servers/[name]/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, deploymentId, 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.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 isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n 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 deploymentId\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 let parentSpan;\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 // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\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 (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\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), undefined, !isWrappedByNextServer);\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","module.exports = require(\"node:https\");","module.exports = require(\"next/dist/compiled/next-server/app-route.runtime.prod.js\");","module.exports = require(\"node:os\");","module.exports = require(\"node:fs/promises\");","// JSON.parse with a fallback value when the input is malformed (or empty).\n// Used everywhere we read responses from external APIs — they're contractually\n// JSON but a transient 502 / proxy interstitial occasionally returns HTML.\nexport function parseJsonSafe<T>(text: string, fallback: T): T;\nexport function parseJsonSafe<T>(text: string): T | undefined;\nexport function parseJsonSafe<T>(text: string, fallback?: T): T | undefined {\n try {\n return JSON.parse(text) as T;\n } catch {\n return fallback;\n }\n}\n","module.exports = require(\"crypto\");","module.exports = require(\"https\");","module.exports = require(\"node:stream\");","module.exports = require(\"node:util\");","module.exports = require(\"next/dist/server/app-render/work-unit-async-storage.external.js\");","module.exports = require(\"node:fs\");","module.exports = require(\"node:url\");","module.exports = require(\"node:worker_threads\");","module.exports = require(\"node:path\");","module.exports = require(\"node:crypto\");","module.exports = require(\"buffer\");","module.exports = require(\"node:sqlite\");","module.exports = require(\"http\");","// Row → JSON-response serializers shared between list (`route.ts`) and\n// item (`[id]/route.ts`) handlers. Keeping these in one place stops the\n// list and item shapes from drifting (they were copy-pasted before).\n\nimport type { AgentConfigRow } from \"@/lib/stores/agent-configs\";\nimport { getAgentTierProportions, parseDelegateTargets } from \"@/lib/stores/agent-configs\";\nimport type { BridgeRow } from \"@/lib/stores/bridges\";\nimport type { McpServerRow } from \"@/lib/stores/mcp-servers\";\nimport type { MessageRow } from \"@/lib/stores/threads\";\nimport type { MessageUsageRow } from \"@/lib/stores/message-usage\";\nimport { parseJsonSafe } from \"@/lib/utils/json\";\n\nexport function agentToResponse(a: AgentConfigRow) {\n return {\n id: a.id,\n name: a.name,\n icon: a.icon,\n identity: a.identity,\n instructions: a.instructions,\n tools: parseJsonSafe<string[]>(a.tools, []),\n model_config_name: a.model_config_name,\n is_default: !!a.is_default,\n history_limit: a.history_limit,\n history_window_hours: a.history_window_hours,\n never_reply: !!a.never_reply,\n adaptive_persona_enabled: !!a.adaptive_persona_enabled,\n adaptive_persona_strength: a.adaptive_persona_strength,\n adaptive_empathy: a.adaptive_empathy,\n adaptive_expressiveness: a.adaptive_expressiveness,\n adaptive_verbosity: a.adaptive_verbosity,\n adaptive_mbti: a.adaptive_mbti,\n voice_enabled: !!a.voice_enabled,\n voice_model: a.voice_model,\n voice_name: a.voice_name,\n voice_stt_model: a.voice_stt_model,\n voice_auto_speak: !!a.voice_auto_speak,\n harness_id: a.harness_id,\n delegate_targets: parseDelegateTargets(a.delegate_targets),\n context_tier_proportions: getAgentTierProportions(a),\n anti_hallucination_mode: (a.anti_hallucination_mode === \"off\" || a.anti_hallucination_mode === \"regex\" || a.anti_hallucination_mode === \"model\")\n ? a.anti_hallucination_mode\n : null,\n anti_hallucination_model_config: a.anti_hallucination_model_config,\n require_source_links: !!a.require_source_links,\n created_at: a.created_at,\n updated_at: a.updated_at,\n };\n}\n\nexport function bridgeToResponse(r: BridgeRow) {\n return {\n id: r.id,\n kind: r.kind,\n name: r.name,\n status: r.status,\n last_error: r.last_error,\n paired_id: r.paired_id,\n enabled: r.enabled === 1,\n created_at: r.created_at,\n updated_at: r.updated_at,\n };\n}\n\nexport function mcpServerToResponse(r: McpServerRow) {\n return {\n name: r.name,\n transport: r.transport,\n spec: parseJsonSafe<unknown>(r.spec, null),\n enabled: r.enabled === 1,\n last_error: r.last_error,\n created_at: r.created_at,\n updated_at: r.updated_at,\n };\n}\n\n/**\n * Shape a `message_usage` row into the over-the-wire `usage` object the\n * chat panel's `ContextUsageBar` consumes. Returns `null` for messages\n * that have no snapshot (user turns and legacy assistant rows recorded\n * before the per-turn snapshot landed in ADR-0041).\n */\nexport function messageUsageToResponse(u: MessageUsageRow | undefined | null) {\n if (!u) return null;\n return {\n input_tokens: u.input_tokens,\n output_tokens: u.output_tokens,\n hot_tokens: u.hot_tokens,\n warm_tokens: u.warm_tokens,\n facts_tokens: u.facts_tokens,\n overhead_tokens: u.overhead_tokens,\n hot_budget_tokens: u.hot_budget_tokens,\n warm_budget_tokens: u.warm_budget_tokens,\n facts_budget_tokens: u.facts_budget_tokens,\n context_window_tokens: u.context_window_tokens,\n };\n}\n\n/**\n * Shape one message row into its over-the-wire form, attaching its\n * per-turn `usage` snapshot when one exists. Pure data-shaping helper\n * extracted from the threads GET route so the wire contract has unit\n * coverage.\n */\nexport function messageToResponse(\n m: MessageRow,\n usageById: ReadonlyMap<string, MessageUsageRow>,\n) {\n return {\n id: m.msg_id,\n role: m.role,\n content: m.content,\n created_at: m.created_at,\n tool_events: parseToolEventsForResponse(m.tool_events),\n category: m.category ?? null,\n usage: messageUsageToResponse(usageById.get(m.msg_id)),\n metadata: parseMessageMetadataForResponse(m.metadata),\n };\n}\n\n/** Tolerant `tool_events` JSON parser shared with the route. Bad JSON\n * and non-array payloads collapse to `undefined` so the wire shape\n * always matches the typed client expectation. */\nexport function parseToolEventsForResponse(raw: string | null | undefined): unknown[] | undefined {\n if (!raw) return undefined;\n try {\n const parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Tolerant `metadata` JSON parser. Returns `null` for missing/blank/\n * malformed/non-object payloads so the wire shape stays a plain object\n * or null — readers can rely on `metadata?.citations?...` chaining. */\nexport function parseMessageMetadataForResponse(raw: string | null | undefined): Record<string, unknown> | null {\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw);\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return null;\n return parsed as Record<string, unknown>;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve the bar's 100% baseline. Per-row `context_window_tokens`\n * (snapshotted at run time) wins so the bar matches the cap the agent\n * actually applied; legacy rows fall back to the model-config value;\n * unconfigured agents fall back to the default. Centralised so the\n * route and the UI share the same precedence rule.\n */\nexport function resolveContextWindowTokens(\n modelConfiguredTokens: number | null | undefined,\n defaultTokens: number,\n): number {\n if (typeof modelConfiguredTokens === \"number\" && modelConfiguredTokens > 0) {\n return modelConfiguredTokens;\n }\n return defaultTokens;\n}\n","module.exports = require(\"next/dist/shared/lib/no-fallback-error.external\");","module.exports = import(\"@langchain/mcp-adapters\");;","module.exports = require(\"events\");"],"names":["NextResponse","errorResponse","message","status","json","error","notFoundResponse","createdResponse","data","cachedJson","maxAgeSeconds","headers","validateBody","req","schema","raw","parsed","safeParse","success","issues","deleteMcpServer","getMcpServer","upsertMcpServer","invalidateMcpTools","mcpServerToResponse","parseJsonSafe","GET","_req","params","name","r","PUT","existing","body","row","transport","spec","enabled","DELETE","ok","deleted","text","fallback","JSON","parse","getAgentTierProportions","parseDelegateTargets","agentToResponse","a","id","icon","identity","instructions","tools","model_config_name","is_default","history_limit","history_window_hours","never_reply","adaptive_persona_enabled","adaptive_persona_strength","adaptive_empathy","adaptive_expressiveness","adaptive_verbosity","adaptive_mbti","voice_enabled","voice_model","voice_name","voice_stt_model","voice_auto_speak","harness_id","delegate_targets","context_tier_proportions","anti_hallucination_mode","anti_hallucination_model_config","require_source_links","created_at","updated_at","bridgeToResponse","kind","last_error","paired_id","messageUsageToResponse","u","input_tokens","output_tokens","hot_tokens","warm_tokens","facts_tokens","overhead_tokens","hot_budget_tokens","warm_budget_tokens","facts_budget_tokens","context_window_tokens","messageToResponse","m","usageById","msg_id","role","content","tool_events","parseToolEventsForResponse","category","usage","get","metadata","parseMessageMetadataForResponse","undefined","Array","isArray","resolveContextWindowTokens","modelConfiguredTokens","defaultTokens"],"sourceRoot":"","ignoreList":[0,3,5,10,18,26,36]}
|
|
1
|
+
{"version":3,"file":"../app/api/v1/mcp-servers/[name]/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;ACAA,kEAAkE;AAClE,EAAE;AACF,uEAAuE;AACvE,6DAA6D;AAC7D,yEAAyE;AACzE,qEAAqE;AAE1B;AAIpC,SAASC,cAAcC,OAAe,EAAEC,SAAiB,GAAG;IACjE,OAAOH,qDAAYA,CAACI,IAAI,CAAC;QAAEC,OAAOH;IAAQ,GAAG;QAAEC;IAAO;AACxD;AAEO,SAASG,iBAAiBJ,UAAkB,WAAW;IAC5D,OAAOD,cAAcC,SAAS;AAChC;AAEO,SAASK,gBAAmBC,IAAO;IACxC,OAAOR,qDAAYA,CAACI,IAAI,CAACI,MAAM;QAAEL,QAAQ;IAAI;AAC/C;AAEA,4EAA4E;AAC5E,8EAA8E;AAC9E,wEAAwE;AACxE,yEAAyE;AACzE,0EAA0E;AACnE,SAASM,WAAcD,IAAO,EAAEE,aAAqB;IAC1D,OAAOV,qDAAYA,CAACI,IAAI,CAACI,MAAM;QAC7BG,SAAS;YACP,iBAAiB,CAAC,iBAAiB,EAAED,eAAe;QACtD;IACF;AACF;AAEA,qDAAqD;AACrD,6EAA6E;AAC7E,kBAAkB;AAClB,oDAAoD;AACpD,uDAAuD;AACvD,wBAAwB;AACjB,eAAeE,aACpBC,GAAgB,EAChBC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OAAOX,IAAiB,EAAE,EAAEC,MAAM,EAAU;IAChE,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMD;IACvB,MAAMW,KAAKnB,uCAAeA,CAACS;IAC3B,IAAI,CAACU,IAAI,OAAOjC,sCAAgBA,CAAC;IACjCiB,oCAAkBA;IAClB,OAAOvB,mBAAYA,CAACI,IAAI,CAAC;QAAEoC,SAAS;IAAK;AAC3C;;;AC1C+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AACiC;AACnG;AACA;AACA;AACA,wBAAwB,mCAAmB;AAC3C;AACA,cAAc,oBAAS;AACvB;AACA;AACA;AACA;AACA,KAAK;AACL,aAAa,OAAoC,IAAI,CAAE;AACvD,wBAAwB,MAAuC;AAC/D;AACA;AACA;AACA,cAAc,qBAAQ;AACtB;AACA;AACA;AACA;AACA,OAAO,MAAsD,GAAG,CAE3D,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA,QAAQ,sDAAsD;AAC9D;AACA,WAAW,0BAAW;AACtB;AACA;AACA,KAAK;AACL;AAC0F;AACnF;AACP;AACA,QAAQ,+BAAc;AACtB;AACA;AACA,QAAQ,+BAAc;AACtB;AACA;AACA;AACA;AACA;AACA,QAAQ,KAAqB,EAAE,EAE1B,CAAC;AACN;AACA;AACA;AACA,+BAA+B,KAAwC;AACvE;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,6NAA6N;AACzO,8BAA8B,+BAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,2CAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,6CAAqB;AAC7B;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,mBAAmB,0BAAS;AAC5B;AACA;AACA,kCAAkC,+BAAc;AAChD,6BAA6B,+BAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,4BAA4B,oBAAe;AAC3C,4BAA4B,qBAAgB;AAC5C,oBAAoB,+BAAkB,kCAAkC,uCAAsB;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,iEAAiE,wBAAc;AAC/E,+DAA+D,yCAAyC;AACxG;AACA;AACA;AACA;AACA,oCAAoC,QAAQ,EAAE,MAAM;AACpD;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,uCAAuC,QAAQ,EAAE,QAAQ;AACzD;AACA,aAAa;AACb;AACA;AACA;AACA,+CAA+C,oBAAoB;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,uCAAyB;AACjE;AACA,oCAAoC,oCAAsB;AAC1D;AACA;AACA;AACA;AACA,sJAAsJ,4BAAc;AACpK,0IAA0I,4BAAc;AACxJ;AACA;AACA;AACA,sCAAsC,8BAAe;AACrD;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,8BAA8B,qCAAY;AAC1C;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,oCAAmB;AACjE;AACA;AACA,6BAA6B;AAC7B,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,oBAAS;AACpC;AACA;AACA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AQ,IAAI;QACxBC,OAAOvB,uBAAuBgB,UAAUQ,GAAG,CAACT,EAAEE,MAAM;QACpDQ,UAAUC,gCAAgCX,EAAEU,QAAQ;IACtD;AACF;AAEA;;iDAEiD,GAC1C,SAASJ,2BAA2BxF,GAA8B;IACvE,IAAI,CAACA,KAAK,OAAO8F;IACjB,IAAI;QACF,MAAM7F,SAAS2B,KAAKC,KAAK,CAAC7B;QAC1B,OAAO+F,MAAMC,OAAO,CAAC/F,UAAUA,SAAS6F;IAC1C,EAAE,OAAM;QACN,OAAOA;IACT;AACF;AAEA;;sEAEsE,GAC/D,SAASD,gCAAgC7F,GAA8B;IAC5E,IAAI,CAACA,KAAK,OAAO;IACjB,IAAI;QACF,MAAMC,SAAS2B,KAAKC,KAAK,CAAC7B;QAC1B,IAAI,CAACC,UAAU,OAAOA,WAAW,YAAY8F,MAAMC,OAAO,CAAC/F,SAAS,OAAO;QAC3E,OAAOA;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;CAMC,GACM,SAASgG,2BACdC,qBAAgD,EAChDC,aAAqB;IAErB,IAAI,OAAOD,0BAA0B,YAAYA,wBAAwB,GAAG;QAC1E,OAAOA;IACT;IACA,OAAOC;AACT;;;;;;;;ACzKA;;;;;;;ACAA;;;;;;;ACAA","sources":["webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/router/utils/app-paths\"","webpack://@circuitwall/jarela/external node-commonjs \"node:process\"","webpack://@circuitwall/jarela/external commonjs2 \"url\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/after-task-async-storage.external.js\"","webpack://@circuitwall/jarela/external commonjs \"undici\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-page.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:async_hooks\"","webpack://@circuitwall/jarela/external commonjs2 \"stream\"","webpack://@circuitwall/jarela/external commonjs2 \"util\"","webpack://@circuitwall/jarela/external commonjs2 \"fs\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:child_process\"","webpack://@circuitwall/jarela/external commonjs2 \"path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:http\"","webpack://@circuitwall/jarela/./lib/api/responses.ts","webpack://@circuitwall/jarela/./app/api/v1/mcp-servers/[name]/route.ts","webpack://@circuitwall/jarela/?2233","webpack://@circuitwall/jarela/external node-commonjs \"node:https\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-route.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:os\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs/promises\"","webpack://@circuitwall/jarela/./lib/utils/json.ts","webpack://@circuitwall/jarela/external commonjs2 \"crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"https\"","webpack://@circuitwall/jarela/external node-commonjs \"node:stream\"","webpack://@circuitwall/jarela/external node-commonjs \"node:util\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-unit-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs\"","webpack://@circuitwall/jarela/external node-commonjs \"node:url\"","webpack://@circuitwall/jarela/external node-commonjs \"node:worker_threads\"","webpack://@circuitwall/jarela/external node-commonjs \"node:path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"buffer\"","webpack://@circuitwall/jarela/external node-commonjs \"node:sqlite\"","webpack://@circuitwall/jarela/external commonjs2 \"http\"","webpack://@circuitwall/jarela/./lib/api/serializers.ts","webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/no-fallback-error.external\"","webpack://@circuitwall/jarela/external module \"@langchain/mcp-adapters\"","webpack://@circuitwall/jarela/external commonjs2 \"events\""],"sourcesContent":["module.exports = require(\"next/dist/shared/lib/router/utils/app-paths\");","module.exports = require(\"node:process\");","module.exports = require(\"url\");","module.exports = require(\"next/dist/server/app-render/after-task-async-storage.external.js\");","module.exports = require(\"undici\");","module.exports = require(\"next/dist/compiled/next-server/app-page.runtime.prod.js\");","module.exports = require(\"node:async_hooks\");","module.exports = require(\"stream\");","module.exports = require(\"util\");","module.exports = require(\"fs\");","module.exports = require(\"next/dist/server/app-render/work-async-storage.external.js\");","module.exports = require(\"node:child_process\");","module.exports = require(\"path\");","module.exports = require(\"node:http\");","// Shared HTTP response builders for app/api/v1/** route handlers.\n//\n// Goal: every error/success payload across the v1 surface has the same\n// shape. Before this lived inline, response bodies drifted —\n// `{error: \"x\"}` vs `{message: \"x\"}`, 400 vs 422 for the same condition,\n// some routes returned Zod's raw issue array, others stringified it.\n\nimport { NextResponse } from \"next/server\";\nimport type { z } from \"zod\";\nimport type { NextRequest } from \"next/server\";\n\nexport function errorResponse(message: string, status: number = 400): NextResponse {\n return NextResponse.json({ error: message }, { status });\n}\n\nexport function notFoundResponse(message: string = \"Not found\"): NextResponse {\n return errorResponse(message, 404);\n}\n\nexport function createdResponse<T>(data: T): NextResponse {\n return NextResponse.json(data, { status: 201 });\n}\n\n// Wrap a 200 JSON response with a private Cache-Control header. Use on safe\n// GET endpoints that serve user-scoped data the client refetches often (panel\n// mounts, navigation back/forward) but mutates rarely. The TTL is short\n// enough that explicit mutations — which patch the client-side ApiClient\n// cache in place — stay observably consistent without an extra roundtrip.\nexport function cachedJson<T>(data: T, maxAgeSeconds: number): NextResponse {\n return NextResponse.json(data, {\n headers: {\n \"Cache-Control\": `private, max-age=${maxAgeSeconds}`,\n },\n });\n}\n\n// Validate a JSON request body against a zod schema.\n// Returns either the parsed data or a 400 NextResponse explaining the issue.\n// Caller pattern:\n// const parsed = await validateBody(req, Schema);\n// if (parsed instanceof NextResponse) return parsed;\n// // use parsed.field\nexport async function validateBody<S extends z.ZodTypeAny>(\n req: NextRequest,\n schema: S,\n): Promise<z.infer<S> | NextResponse> {\n let raw: unknown;\n try {\n raw = await req.json();\n } catch {\n return errorResponse(\"Request body must be valid JSON\", 400);\n }\n const parsed = schema.safeParse(raw);\n if (!parsed.success) {\n return errorResponse(parsed.error.issues[0]?.message ?? \"invalid body\", 400);\n }\n return parsed.data;\n}\n","import { NextRequest, NextResponse } from \"next/server\";\nimport {\n deleteMcpServer,\n getMcpServer,\n upsertMcpServer,\n type McpServerInput,\n} from \"@/lib/stores/mcp-servers\";\nimport { invalidateMcpTools } from \"@/lib/mcp/client\";\nimport { mcpServerToResponse } from \"@/lib/api/serializers\";\nimport { notFoundResponse } from \"@/lib/api/responses\";\nimport { parseJsonSafe } from \"@/lib/utils/json\";\n\ntype Params = { params: Promise<{ name: string }> };\n\nexport async function GET(_req: NextRequest, { params }: Params) {\n const { name } = await params;\n const r = getMcpServer(name);\n if (!r) return notFoundResponse(\"MCP server not found\");\n return NextResponse.json(mcpServerToResponse(r));\n}\n\nexport async function PUT(req: NextRequest, { params }: Params) {\n const { name } = await params;\n const existing = getMcpServer(name);\n if (!existing) return notFoundResponse(\"MCP server not found\");\n const body = (await req.json()) as Partial<McpServerInput>;\n const row = upsertMcpServer({\n name,\n transport: body.transport ?? (existing.transport as \"stdio\" | \"http\"),\n spec: body.spec ?? parseJsonSafe<McpServerInput[\"spec\"]>(existing.spec, {} as McpServerInput[\"spec\"]),\n enabled: body.enabled ?? (existing.enabled === 1),\n });\n invalidateMcpTools();\n return NextResponse.json(mcpServerToResponse(row));\n}\n\nexport async function DELETE(_req: NextRequest, { params }: Params) {\n const { name } = await params;\n const ok = deleteMcpServer(name);\n if (!ok) return notFoundResponse(\"MCP server not found\");\n invalidateMcpTools();\n return NextResponse.json({ deleted: true });\n}\n","import { AppRouteRouteModule } from \"next/dist/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/lib/constants\";\nimport { NoFallbackError } from \"next/dist/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/server/response-cache\";\nimport * as userland from \"/home/runner/work/jarela/jarela/app/api/v1/mcp-servers/[name]/route.ts\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"standalone\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/v1/mcp-servers/[name]/route\",\n pathname: \"/api/v1/mcp-servers/[name]\",\n filename: \"route\",\n bundlePath: \"app/api/v1/mcp-servers/[name]/route\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"/home/runner/work/jarela/jarela/app/api/v1/mcp-servers/[name]/route.ts\",\n nextConfigOutput,\n // The static import is used for initialization (methods, dynamic, etc.).\n userland: userland,\n // In Turbopack dev mode, also provide a getter that calls require() on every\n // request. This re-reads from devModuleCache so HMR updates are picked up,\n // and the async wrapper unwraps async-module Promises (ESM-only\n // serverExternalPackages) automatically.\n ...process.env.TURBOPACK && process.env.__NEXT_DEV_SERVER ? {\n getUserland: ()=>import(\"/home/runner/work/jarela/jarela/app/api/v1/mcp-servers/[name]/route.ts\")\n } : {}\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 (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/v1/mcp-servers/[name]/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, deploymentId, 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.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 isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n 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 deploymentId\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 let parentSpan;\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 // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\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 (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\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), undefined, !isWrappedByNextServer);\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","module.exports = require(\"node:https\");","module.exports = require(\"next/dist/compiled/next-server/app-route.runtime.prod.js\");","module.exports = require(\"node:os\");","module.exports = require(\"node:fs/promises\");","// JSON.parse with a fallback value when the input is malformed (or empty).\n// Used everywhere we read responses from external APIs — they're contractually\n// JSON but a transient 502 / proxy interstitial occasionally returns HTML.\nexport function parseJsonSafe<T>(text: string, fallback: T): T;\nexport function parseJsonSafe<T>(text: string): T | undefined;\nexport function parseJsonSafe<T>(text: string, fallback?: T): T | undefined {\n try {\n return JSON.parse(text) as T;\n } catch {\n return fallback;\n }\n}\n","module.exports = require(\"crypto\");","module.exports = require(\"https\");","module.exports = require(\"node:stream\");","module.exports = require(\"node:util\");","module.exports = require(\"next/dist/server/app-render/work-unit-async-storage.external.js\");","module.exports = require(\"node:fs\");","module.exports = require(\"node:url\");","module.exports = require(\"node:worker_threads\");","module.exports = require(\"node:path\");","module.exports = require(\"node:crypto\");","module.exports = require(\"buffer\");","module.exports = require(\"node:sqlite\");","module.exports = require(\"http\");","// Row → JSON-response serializers shared between list (`route.ts`) and\n// item (`[id]/route.ts`) handlers. Keeping these in one place stops the\n// list and item shapes from drifting (they were copy-pasted before).\n\nimport type { AgentConfigRow } from \"@/lib/stores/agent-configs\";\nimport { getAgentTierProportions, parseDelegateTargets } from \"@/lib/stores/agent-configs\";\nimport type { BridgeRow } from \"@/lib/stores/bridges\";\nimport type { McpServerRow } from \"@/lib/stores/mcp-servers\";\nimport type { MessageRow } from \"@/lib/stores/threads\";\nimport type { MessageUsageRow } from \"@/lib/stores/message-usage\";\nimport { parseJsonSafe } from \"@/lib/utils/json\";\n\nexport function agentToResponse(a: AgentConfigRow) {\n return {\n id: a.id,\n name: a.name,\n icon: a.icon,\n identity: a.identity,\n instructions: a.instructions,\n tools: parseJsonSafe<string[]>(a.tools, []),\n model_config_name: a.model_config_name,\n is_default: !!a.is_default,\n history_limit: a.history_limit,\n history_window_hours: a.history_window_hours,\n never_reply: !!a.never_reply,\n adaptive_persona_enabled: !!a.adaptive_persona_enabled,\n adaptive_persona_strength: a.adaptive_persona_strength,\n adaptive_empathy: a.adaptive_empathy,\n adaptive_expressiveness: a.adaptive_expressiveness,\n adaptive_verbosity: a.adaptive_verbosity,\n adaptive_mbti: a.adaptive_mbti,\n voice_enabled: !!a.voice_enabled,\n voice_model: a.voice_model,\n voice_name: a.voice_name,\n voice_stt_model: a.voice_stt_model,\n voice_auto_speak: !!a.voice_auto_speak,\n harness_id: a.harness_id,\n delegate_targets: parseDelegateTargets(a.delegate_targets),\n context_tier_proportions: getAgentTierProportions(a),\n anti_hallucination_mode: (a.anti_hallucination_mode === \"off\" || a.anti_hallucination_mode === \"regex\" || a.anti_hallucination_mode === \"model\")\n ? a.anti_hallucination_mode\n : null,\n anti_hallucination_model_config: a.anti_hallucination_model_config,\n require_source_links: !!a.require_source_links,\n created_at: a.created_at,\n updated_at: a.updated_at,\n };\n}\n\nexport function bridgeToResponse(r: BridgeRow) {\n return {\n id: r.id,\n kind: r.kind,\n name: r.name,\n status: r.status,\n last_error: r.last_error,\n paired_id: r.paired_id,\n enabled: r.enabled === 1,\n created_at: r.created_at,\n updated_at: r.updated_at,\n };\n}\n\nexport function mcpServerToResponse(r: McpServerRow) {\n return {\n name: r.name,\n transport: r.transport,\n spec: parseJsonSafe<unknown>(r.spec, null),\n enabled: r.enabled === 1,\n last_error: r.last_error,\n created_at: r.created_at,\n updated_at: r.updated_at,\n };\n}\n\n/**\n * Shape a `message_usage` row into the over-the-wire `usage` object the\n * chat panel's `ContextUsageBar` consumes. Returns `null` for messages\n * that have no snapshot (user turns and legacy assistant rows recorded\n * before the per-turn snapshot landed in ADR-0041).\n *\n * Anthropic prompt-cache tokens (PR #181 + the cache-fidelity follow-up)\n * are surfaced as additive fields so future UI work can render a\n * \"served from cache\" badge without another wire change. Both are\n * `null` for rows that predate cache plumbing or for providers that\n * don't expose a cache breakdown.\n */\nexport function messageUsageToResponse(u: MessageUsageRow | undefined | null) {\n if (!u) return null;\n return {\n input_tokens: u.input_tokens,\n output_tokens: u.output_tokens,\n hot_tokens: u.hot_tokens,\n warm_tokens: u.warm_tokens,\n facts_tokens: u.facts_tokens,\n overhead_tokens: u.overhead_tokens,\n hot_budget_tokens: u.hot_budget_tokens,\n warm_budget_tokens: u.warm_budget_tokens,\n facts_budget_tokens: u.facts_budget_tokens,\n context_window_tokens: u.context_window_tokens,\n cache_creation_input_tokens: u.cache_creation_input_tokens,\n cache_read_input_tokens: u.cache_read_input_tokens,\n };\n}\n\n/**\n * Shape one message row into its over-the-wire form, attaching its\n * per-turn `usage` snapshot when one exists. Pure data-shaping helper\n * extracted from the threads GET route so the wire contract has unit\n * coverage.\n */\nexport function messageToResponse(\n m: MessageRow,\n usageById: ReadonlyMap<string, MessageUsageRow>,\n) {\n return {\n id: m.msg_id,\n role: m.role,\n content: m.content,\n created_at: m.created_at,\n tool_events: parseToolEventsForResponse(m.tool_events),\n category: m.category ?? null,\n usage: messageUsageToResponse(usageById.get(m.msg_id)),\n metadata: parseMessageMetadataForResponse(m.metadata),\n };\n}\n\n/** Tolerant `tool_events` JSON parser shared with the route. Bad JSON\n * and non-array payloads collapse to `undefined` so the wire shape\n * always matches the typed client expectation. */\nexport function parseToolEventsForResponse(raw: string | null | undefined): unknown[] | undefined {\n if (!raw) return undefined;\n try {\n const parsed = JSON.parse(raw);\n return Array.isArray(parsed) ? parsed : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Tolerant `metadata` JSON parser. Returns `null` for missing/blank/\n * malformed/non-object payloads so the wire shape stays a plain object\n * or null — readers can rely on `metadata?.citations?...` chaining. */\nexport function parseMessageMetadataForResponse(raw: string | null | undefined): Record<string, unknown> | null {\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw);\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return null;\n return parsed as Record<string, unknown>;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve the bar's 100% baseline. Per-row `context_window_tokens`\n * (snapshotted at run time) wins so the bar matches the cap the agent\n * actually applied; legacy rows fall back to the model-config value;\n * unconfigured agents fall back to the default. Centralised so the\n * route and the UI share the same precedence rule.\n */\nexport function resolveContextWindowTokens(\n modelConfiguredTokens: number | null | undefined,\n defaultTokens: number,\n): number {\n if (typeof modelConfiguredTokens === \"number\" && modelConfiguredTokens > 0) {\n return modelConfiguredTokens;\n }\n return defaultTokens;\n}\n","module.exports = require(\"next/dist/shared/lib/no-fallback-error.external\");","module.exports = import(\"@langchain/mcp-adapters\");;","module.exports = require(\"events\");"],"names":["NextResponse","errorResponse","message","status","json","error","notFoundResponse","createdResponse","data","cachedJson","maxAgeSeconds","headers","validateBody","req","schema","raw","parsed","safeParse","success","issues","deleteMcpServer","getMcpServer","upsertMcpServer","invalidateMcpTools","mcpServerToResponse","parseJsonSafe","GET","_req","params","name","r","PUT","existing","body","row","transport","spec","enabled","DELETE","ok","deleted","text","fallback","JSON","parse","getAgentTierProportions","parseDelegateTargets","agentToResponse","a","id","icon","identity","instructions","tools","model_config_name","is_default","history_limit","history_window_hours","never_reply","adaptive_persona_enabled","adaptive_persona_strength","adaptive_empathy","adaptive_expressiveness","adaptive_verbosity","adaptive_mbti","voice_enabled","voice_model","voice_name","voice_stt_model","voice_auto_speak","harness_id","delegate_targets","context_tier_proportions","anti_hallucination_mode","anti_hallucination_model_config","require_source_links","created_at","updated_at","bridgeToResponse","kind","last_error","paired_id","messageUsageToResponse","u","input_tokens","output_tokens","hot_tokens","warm_tokens","facts_tokens","overhead_tokens","hot_budget_tokens","warm_budget_tokens","facts_budget_tokens","context_window_tokens","cache_creation_input_tokens","cache_read_input_tokens","messageToResponse","m","usageById","msg_id","role","content","tool_events","parseToolEventsForResponse","category","usage","get","metadata","parseMessageMetadataForResponse","undefined","Array","isArray","resolveContextWindowTokens","modelConfiguredTokens","defaultTokens"],"sourceRoot":"","ignoreList":[0,3,5,10,18,26,36]}
|