@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/pending-actions/[id]/approve/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;ACAA,4EAA4E;AAC5E,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,EAAE;AACF,uEAAuE;AACvE,uDAAuD;AAChD,SAASA,kBAAqBC,GAAW,EAAEC,OAAgB;IAChE,MAAMC,IAAIC;IACV,IAAID,CAAC,CAACF,IAAI,KAAKI,WAAWF,CAAC,CAACF,IAAI,GAAGC;IACnC,OAAOC,CAAC,CAACF,IAAI;AACf;;;;;;;;ACbA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,qDAAqD;AACrD,EAAE;AACF,yDAAyD;AACzD,0EAA0E;AAC1E,wEAAwE;AACxE,kEA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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,wBAAc;AAC3F,iCAAiC,QAAQ,EAAE,QAAQ;AACnD,0BAA0B,qBAAQ;AAClC;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA,MAAM;AACN,6BAA6B,2CAAe;AAC5C;AACA;AACA;AACA;AACA;AACA,kCAAkC,oCAAmB;AACrD;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,cAAc,qCAAY;AAC1B;AACA,SAAS;AACT;AACA;AACA;;AAEA;;;;;;;;AC7WA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;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/./lib/utils/global-state.ts","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/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/./lib/mcp/registry.ts","webpack://@circuitwall/jarela/./lib/agents/proposals.ts","webpack://@circuitwall/jarela/./app/api/v1/pending-actions/[id]/approve/route.ts","webpack://@circuitwall/jarela/?2cf0","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/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\");","// Pin a piece of state to globalThis so it survives Next.js dev hot-reload.\n//\n// Without this, every code edit re-evaluates the module, replacing the\n// in-memory state with empty containers — but any active closure still\n// references the OLD set, so listeners/timers/maps go silently dead.\n// The globalThis trick is the standard Next pattern for singletons.\n//\n// `key` must be unique across the app (it lives on globalThis); pick a\n// \"__jarela_<name>\" prefix to keep the namespace tidy.\nexport function getOrCreateGlobal<T>(key: string, factory: () => T): T {\n const g = globalThis as unknown as Record<string, unknown>;\n if (g[key] === undefined) g[key] = factory();\n return g[key] as T;\n}\n","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\");","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\");","// MCP server registry types + variable substitution.\n//\n// Discovery is online via the official MCP Registry (see\n// `lib/mcp/upstream-registry.ts` and ADR-0013). Entries flow through this\n// module's types so the picker UI, install action, and `applyVariables`\n// substitution path stay decoupled from the upstream wire format.\n\nexport interface RegistryVariable {\n /** Unique key used as `${key}` in spec strings or env values. */\n key: string;\n /** Human-readable label shown in the form. */\n label: string;\n /** Placeholder text / example value. */\n placeholder?: string;\n /** If true, hide the field as a password. */\n secret?: boolean;\n /** Pre-filled default. User can edit. */\n default?: string;\n}\n\nexport interface RegistryEntry {\n /** Slug used as the default MCP server name. */\n id: string;\n /** Display name in the picker. */\n name: string;\n /** One-line description. */\n description: string;\n /** Coarse grouping in the picker UI. */\n category: \"Local\" | \"Web\" | \"Data\" | \"Productivity\" | \"Search\" | \"Cloud\" | \"Corporate\";\n /** Author label (helps users gauge trust). */\n source: \"Official\" | \"Community\" | \"Vendor\";\n /** Homepage / docs URL — shown as a small \"?\" link in the picker. */\n url?: string;\n /** Transport. stdio runs a subprocess; http calls a remote SSE/HTTP MCP server. */\n transport: \"stdio\" | \"http\";\n /** Spec template. ${var} placeholders are replaced with user input. */\n spec: Record<string, unknown>;\n /** Optional ${} variables collected from the user before saving. */\n variables?: RegistryVariable[];\n}\n\n// Substitute `${var}` placeholders in a spec object using user-supplied values.\n// Walks objects and arrays recursively; leaves non-strings alone.\nexport function applyVariables(\n spec: Record<string, unknown>,\n values: Record<string, string>,\n): Record<string, unknown> {\n return walk(spec) as Record<string, unknown>;\n\n function walk(node: unknown): unknown {\n if (typeof node === \"string\") {\n return node.replace(/\\$\\{(\\w+)\\}/g, (_, k) => values[k] ?? `\\${${k}}`);\n }\n if (Array.isArray(node)) return node.map(walk);\n if (node && typeof node === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(node as Record<string, unknown>)) out[k] = walk(v);\n return out;\n }\n return node;\n }\n}\n","// Executes a previously-approved pending action. Strictly server-side.\n// Each `kind` maps to exactly one mutation site; nothing here touches the\n// agent loop directly — approvals just write to the same tables the UI\n// would touch, and the running agent picks up changes on its next turn.\n\nimport { getMcpServer, upsertMcpServer, type McpHttpSpec, type McpServerInput, type McpStdioSpec } from \"@/lib/stores/mcp-servers\";\nimport { invalidateMcpTools } from \"@/lib/mcp/client\";\nimport { applyVariables } from \"@/lib/mcp/registry\";\nimport { getUpstreamByName } from \"@/lib/mcp/upstream-registry\";\nimport { getAgentConfig, getAgentTools, upsertAgentConfig } from \"@/lib/stores/agent-configs\";\nimport type { ActionKind } from \"@/lib/stores/pending-actions\";\nimport { getManifest } from \"@/lib/integrations/registry\";\nimport { saveIntegration, INTEGRATIONS } from \"@/lib/stores/integrations\";\nimport { upsertModelConfig, getModelConfig } from \"@/lib/stores/model-config\";\nimport {\n createCustomHarness,\n getHarness,\n updateCustomHarness,\n} from \"@/lib/stores/harnesses\";\nimport {\n CUSTOM_HARNESS_ID_PREFIX,\n HARNESS_SECTION_KEYS,\n isBuiltinHarnessId,\n type HarnessSection,\n type HarnessSectionKey,\n} from \"@/lib/agents/harness/types\";\n\nexport interface ApplyResult {\n ok: boolean;\n detail: unknown;\n}\n\n// `extras` is approval-time material collected by the UI rather than sent\n// in the original tool-call payload. ADR-0010 requires this for any action\n// whose payload would otherwise carry a secret (set_provider_key, the\n// credential fields of enable_integration). The agent never sees `extras`.\nexport async function applyAction(\n kind: ActionKind,\n payload: unknown,\n extras?: Record<string, unknown>,\n): Promise<ApplyResult> {\n switch (kind) {\n case \"install_mcp\": return await applyInstallMcp(payload);\n case \"toggle_mcp\": return applyToggleMcp(payload);\n case \"update_agent_tools\": return applyUpdateAgentTools(payload);\n case \"update_agent\": return applyUpdateAgent(payload);\n case \"start_oauth\": return applyStartOauth(payload);\n case \"set_provider_key\": return applySetProviderKey(payload, extras);\n case \"enable_integration\": return applyEnableIntegration(payload, extras);\n case \"upsert_harness\": return applyUpsertHarness(payload);\n default: return { ok: false, detail: `unknown kind: ${kind}` };\n }\n}\n\nasync function applyInstallMcp(payload: unknown): Promise<ApplyResult> {\n const p = payload as { registry_id?: string; name?: string; spec?: Record<string, unknown>;\n transport?: \"stdio\" | \"http\"; variables?: Record<string, string> };\n // Two install modes: from a registry entry (preferred) or full custom spec.\n if (p.registry_id) {\n // `registry_id` is the fully-qualified upstream name (e.g.\n // `io.github.github/github-mcp-server`). See ADR-0013.\n const entry = await getUpstreamByName(p.registry_id);\n if (!entry) return { ok: false, detail: `registry name \"${p.registry_id}\" not found in registry.modelcontextprotocol.io` };\n const missing = (entry.variables ?? []).filter((v) => !p.variables?.[v.key]?.toString().trim());\n if (missing.length > 0) {\n return { ok: false, detail: `missing variables: ${missing.map((m) => m.key).join(\", \")}` };\n }\n const spec = applyVariables(entry.spec, p.variables ?? {});\n const name = (p.name ?? entry.id).trim();\n upsertMcpServer({ name, transport: entry.transport, spec: spec as unknown as McpStdioSpec | McpHttpSpec, enabled: true });\n invalidateMcpTools();\n return { ok: true, detail: { name, registry_id: p.registry_id } };\n }\n if (p.name && p.spec && p.transport) {\n upsertMcpServer({\n name: p.name,\n transport: p.transport,\n spec: p.spec as unknown as McpStdioSpec | McpHttpSpec,\n enabled: true,\n } satisfies McpServerInput);\n invalidateMcpTools();\n return { ok: true, detail: { name: p.name } };\n }\n return { ok: false, detail: \"install_mcp needs either registry_id+variables, or name+transport+spec\" };\n}\n\nfunction applyToggleMcp(payload: unknown): ApplyResult {\n const p = payload as { name?: string; enabled?: boolean };\n if (!p.name || typeof p.enabled !== \"boolean\") return { ok: false, detail: \"name and enabled required\" };\n const existing = getMcpServer(p.name);\n if (!existing) return { ok: false, detail: `mcp server \"${p.name}\" not found` };\n upsertMcpServer({\n name: existing.name,\n transport: existing.transport as \"stdio\" | \"http\",\n spec: JSON.parse(existing.spec) as McpStdioSpec | McpHttpSpec,\n enabled: p.enabled,\n });\n invalidateMcpTools();\n return { ok: true, detail: { name: p.name, enabled: p.enabled } };\n}\n\nfunction applyUpdateAgentTools(payload: unknown): ApplyResult {\n const p = payload as { agent_id?: string; tools?: string[] };\n if (!p.agent_id || !Array.isArray(p.tools)) return { ok: false, detail: \"agent_id and tools[] required\" };\n const existing = getAgentConfig(p.agent_id);\n if (!existing) return { ok: false, detail: `agent \"${p.agent_id}\" not found` };\n upsertAgentConfig({\n id: existing.id,\n name: existing.name,\n icon: existing.icon,\n identity: existing.identity,\n instructions: existing.instructions,\n tools: p.tools,\n model_config_name: existing.model_config_name,\n });\n return { ok: true, detail: { agent_id: p.agent_id, tools: p.tools } };\n}\n\nfunction applyUpdateAgent(payload: unknown): ApplyResult {\n const p = payload as {\n agent_id?: string;\n identity?: string;\n instructions?: string;\n history_limit?: number;\n history_window_hours?: number;\n harness_id?: string | null;\n };\n if (!p.agent_id) return { ok: false, detail: \"agent_id required\" };\n const existing = getAgentConfig(p.agent_id);\n if (!existing) return { ok: false, detail: `agent \"${p.agent_id}\" not found` };\n // ADR-0036: harness_id may now be set via update_agent. Validate the id\n // resolves before writing — upsertAgentConfig stores the value verbatim, so\n // a bad id would silently break the next agent run with \"unknown harness\".\n if (p.harness_id !== undefined && p.harness_id !== null && p.harness_id !== \"\") {\n if (!getHarness(p.harness_id)) {\n return { ok: false, detail: `harness \"${p.harness_id}\" not found` };\n }\n }\n upsertAgentConfig({\n id: existing.id,\n name: existing.name,\n icon: existing.icon,\n identity: p.identity ?? existing.identity,\n instructions: p.instructions ?? existing.instructions,\n tools: getAgentTools(existing),\n model_config_name: existing.model_config_name,\n history_limit: p.history_limit ?? existing.history_limit,\n history_window_hours: p.history_window_hours ?? existing.history_window_hours,\n harness_id: p.harness_id,\n });\n return {\n ok: true,\n detail: {\n agent_id: p.agent_id,\n identity_changed: p.identity !== undefined,\n instructions_changed: p.instructions !== undefined,\n harness_id_changed: p.harness_id !== undefined,\n },\n };\n}\n\n// ADR-0036: agent-driven edits to *custom* harness presets. Built-ins remain\n// read-only; the global default pointer stays UI-only. Creates when `id` is\n// omitted; edits when `id` matches an existing custom harness.\nfunction applyUpsertHarness(payload: unknown): ApplyResult {\n const p = payload as {\n id?: string;\n name?: string;\n description?: string;\n sections?: Partial<Record<HarnessSectionKey, Partial<HarnessSection>>>;\n };\n if (p.id && isBuiltinHarnessId(p.id)) {\n return { ok: false, detail: \"built-in harnesses are read-only\" };\n }\n const sections = p.sections ?? {};\n for (const k of Object.keys(sections)) {\n if (!HARNESS_SECTION_KEYS.includes(k as HarnessSectionKey)) {\n return { ok: false, detail: `unknown harness section: ${k}` };\n }\n }\n if (p.id && p.id.startsWith(CUSTOM_HARNESS_ID_PREFIX)) {\n const updated = updateCustomHarness(p.id, {\n name: p.name,\n description: p.description,\n sections: p.sections,\n });\n if (!updated) return { ok: false, detail: `custom harness \"${p.id}\" not found` };\n return { ok: true, detail: { id: updated.id, name: updated.name, created: false } };\n }\n if (p.id) {\n return { ok: false, detail: `harness id must start with \"${CUSTOM_HARNESS_ID_PREFIX}\" or be omitted` };\n }\n if (!p.name || !p.name.trim()) {\n return { ok: false, detail: \"name required when creating a harness\" };\n }\n const created = createCustomHarness({\n name: p.name,\n description: p.description,\n sections: p.sections ?? {},\n });\n return { ok: true, detail: { id: created.id, name: created.name, created: true } };\n}\n\n// ---------------------------------------------------------------------------\n// ADR-0010: agent-led setup actions.\n// ---------------------------------------------------------------------------\n\n// `start_oauth` applies as a no-op on persistent state — the *real* effect is\n// the browser following the authorize URL we return. The approval UI handles\n// the redirect; the apply step exists only to convert the proposal into a\n// concrete authorize_url tied to the integration's vendored scopes.\nfunction applyStartOauth(payload: unknown): ApplyResult {\n const p = payload as { integration_id?: string };\n if (!p.integration_id) return { ok: false, detail: \"integration_id required\" };\n const manifest = getManifest(p.integration_id);\n if (!manifest) return { ok: false, detail: `unknown integration \"${p.integration_id}\"` };\n // The /api/v1/integrations/<id>/oauth/start endpoint already exists for\n // gmail and outlook and computes the URL from the saved client_id/secret.\n // Surface the relative path; the browser hits it after approval.\n return {\n ok: true,\n detail: {\n integration_id: manifest.id,\n kickoff_path: `/api/v1/integrations/${manifest.id}/oauth/start`,\n authorize_method: \"POST\",\n },\n };\n}\n\n// `set_provider_key` adds (or replaces) a model_configs row. The payload\n// only declares which provider/model is being configured; the actual key\n// arrives in `extras` from the approval secret-input modal. ADR-0010\n// closes the prompt-injection vector this way: a malicious page cannot\n// trick the agent into proposing an attacker key, because the agent never\n// types or sees the key.\nfunction applySetProviderKey(\n payload: unknown,\n extras?: Record<string, unknown>,\n): ApplyResult {\n const p = payload as {\n name?: string;\n provider?: string;\n model_id?: string;\n is_default?: boolean;\n };\n if (!p.name || !p.provider || !p.model_id) {\n return { ok: false, detail: \"name, provider, and model_id required\" };\n }\n const apiKey = typeof extras?.api_key === \"string\" ? extras.api_key.trim() : \"\";\n if (!apiKey) {\n return {\n ok: false,\n detail: \"api_key was not collected by the approval UI; nothing applied\",\n };\n }\n const params: Record<string, unknown> = { api_key: apiKey };\n if (typeof extras?.base_url === \"string\" && extras.base_url.trim()) {\n params.base_url = extras.base_url.trim();\n }\n const isDefault = p.is_default ?? !getModelConfig(p.name);\n const row = upsertModelConfig(p.name, p.provider, p.model_id, params, isDefault);\n return {\n ok: true,\n detail: { name: row.name, provider: row.provider, model_id: row.model_id, is_default: !!row.is_default },\n };\n}\n\n// `enable_integration` saves credentials for one of the registered\n// integrations and (implicitly) turns its tools on by virtue of the\n// resolveAuth() helpers finding a record. Field values arrive in `extras`\n// for the same reason as set_provider_key — secrets stay out of the agent\n// payload.\nfunction applyEnableIntegration(\n payload: unknown,\n extras?: Record<string, unknown>,\n): ApplyResult {\n const p = payload as { id?: string };\n if (!p.id) return { ok: false, detail: \"id required\" };\n const manifest = getManifest(p.id);\n if (!manifest) return { ok: false, detail: `unknown integration \"${p.id}\"` };\n const def = (INTEGRATIONS as unknown as Record<string, { fields: ReadonlyArray<{ key: string }> } | undefined>)[p.id];\n if (!def) {\n return {\n ok: false,\n detail: `integration \"${p.id}\" has a manifest but no credentials schema in INTEGRATIONS — cannot enable`,\n };\n }\n // Pick only declared fields out of extras, ignore unknowns. Secrets are\n // strings; everything we declare is a string today.\n const incoming: Record<string, string> = {};\n for (const f of def.fields) {\n const v = extras?.[f.key];\n if (typeof v === \"string\") incoming[f.key] = v;\n }\n const result = saveIntegration(p.id, incoming);\n if (\"error\" in result) return { ok: false, detail: result.error };\n return { ok: true, detail: { id: p.id, configured: result.configured } };\n}\n","import { NextRequest, NextResponse, after } from \"next/server\";\nimport { getPendingAction, setActionStatus } from \"@/lib/stores/pending-actions\";\nimport { applyAction } from \"@/lib/agents/proposals\";\nimport { publish as publishNotification } from \"@/lib/notifications/bus\";\n\ntype Params = { params: Promise<{ id: string }> };\n\nexport async function POST(req: NextRequest, { params }: Params) {\n const { id } = await params;\n const action = getPendingAction(id);\n if (!action) return NextResponse.json({ error: \"not found\" }, { status: 404 });\n if (action.status !== \"pending\") {\n return NextResponse.json({ error: `already ${action.status}` }, { status: 409 });\n }\n\n // Optional approval-time secret material (ADR-0010). The agent never sees\n // these — they come from the secret-input modal in the approval banner.\n let extras: Record<string, unknown> | undefined;\n if (req.headers.get(\"content-length\") && req.headers.get(\"content-length\") !== \"0\") {\n try {\n const body = (await req.json()) as { extras?: Record<string, unknown> } | null;\n if (body && body.extras && typeof body.extras === \"object\") extras = body.extras;\n } catch {\n // Empty / non-JSON body is fine — fall back to extras=undefined.\n }\n }\n\n const result = await applyAction(action.kind, JSON.parse(action.payload), extras);\n const final = setActionStatus(id, result.ok ? \"approved\" : \"failed\", result.detail);\n\n // The user's banner already disappears the moment the response lands;\n // the notification is just for any subscribed clients (other browser\n // tabs, mobile PWA). Fire it after the response so the approving tab\n // returns immediately.\n after(() => {\n publishNotification({\n type: \"run_completed\",\n thread_id: \"\",\n agent_id: action.agent_id,\n status: result.ok ? \"done\" : \"error\",\n preview: result.ok\n ? `✅ Approved & applied: ${action.kind}`\n : `⚠️ Approval failed to apply: ${typeof result.detail === \"string\" ? result.detail : JSON.stringify(result.detail)}`,\n ts: Date.now(),\n });\n });\n\n return NextResponse.json(final);\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/pending-actions/[id]/approve/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/pending-actions/[id]/approve/route\",\n pathname: \"/api/v1/pending-actions/[id]/approve\",\n filename: \"route\",\n bundlePath: \"app/api/v1/pending-actions/[id]/approve/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/pending-actions/[id]/approve/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/pending-actions/[id]/approve/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/pending-actions/[id]/approve/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: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\");","module.exports = import(\"@langchain/mcp-adapters\");;","module.exports = require(\"events\");"],"names":["getOrCreateGlobal","key","factory","g","globalThis","undefined","applyVariables","spec","values","walk","node","replace","_","k","Array","isArray","map","out","v","Object","entries","getMcpServer","upsertMcpServer","invalidateMcpTools","getUpstreamByName","getAgentConfig","getAgentTools","upsertAgentConfig","getManifest","saveIntegration","INTEGRATIONS","upsertModelConfig","getModelConfig","createCustomHarness","getHarness","updateCustomHarness","CUSTOM_HARNESS_ID_PREFIX","HARNESS_SECTION_KEYS","isBuiltinHarnessId","applyAction","kind","payload","extras","applyInstallMcp","applyToggleMcp","applyUpdateAgentTools","applyUpdateAgent","applyStartOauth","applySetProviderKey","applyEnableIntegration","applyUpsertHarness","ok","detail","p","registry_id","entry","missing","variables","filter","toString","trim","length","m","join","name","id","transport","enabled","existing","JSON","parse","agent_id","tools","icon","identity","instructions","model_config_name","harness_id","history_limit","history_window_hours","identity_changed","instructions_changed","harness_id_changed","sections","keys","includes","startsWith","updated","description","created","integration_id","manifest","kickoff_path","authorize_method","provider","model_id","apiKey","api_key","params","base_url","isDefault","is_default","row","def","incoming","f","fields","result","error","configured","NextResponse","after","getPendingAction","setActionStatus","publish","publishNotification","POST","req","action","json","status","headers","get","body","final","type","thread_id","preview","stringify","ts","Date","now"],"sourceRoot":"","ignoreList":[0,3,5,11,16,23,36]}
|
|
1
|
+
{"version":3,"file":"../app/api/v1/pending-actions/[id]/approve/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;ACAA,4EAA4E;AAC5E,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,EAAE;AACF,uEAAuE;AACvE,uDAAuD;AAChD,SAASA,kBAAqBC,GAAW,EAAEC,OAAgB;IAChE,MAAMC,IAAIC;IACV,IAAID,CAAC,CAACF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,IAAI,EAAE,GACtC,CAAC,6BAA6B,EAAE,OAAOmE,OAAOvD,MAAM,KAAK,WAAWuD,OAAOvD,MAAM,GAAGiB,KAAK2D,SAAS,CAACrB,OAAOvD,MAAM,GAAG;YACvH6E,IAAIC,KAAKC,GAAG;QACd;IACF;IAEA,OAAOrB,mBAAYA,CAACS,IAAI,CAACK;AAC3B;;;AChD+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AAC2C;AAC7G;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,wBAAc;AAC3F,iCAAiC,QAAQ,EAAE,QAAQ;AACnD,0BAA0B,qBAAQ;AAClC;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA,MAAM;AACN,6BAA6B,2CAAe;AAC5C;AACA;AACA;AACA;AACA;AACA,kCAAkC,oCAAmB;AACrD;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,cAAc,qCAAY;AAC1B;AACA,SAAS;AACT;AACA;AACA;;AAEA;;;;;;;;AC7WA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;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/./lib/utils/global-state.ts","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/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/./lib/mcp/registry.ts","webpack://@circuitwall/jarela/./lib/agents/proposals.ts","webpack://@circuitwall/jarela/./app/api/v1/pending-actions/[id]/approve/route.ts","webpack://@circuitwall/jarela/?2cf0","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/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\");","// Pin a piece of state to globalThis so it survives Next.js dev hot-reload.\n//\n// Without this, every code edit re-evaluates the module, replacing the\n// in-memory state with empty containers — but any active closure still\n// references the OLD set, so listeners/timers/maps go silently dead.\n// The globalThis trick is the standard Next pattern for singletons.\n//\n// `key` must be unique across the app (it lives on globalThis); pick a\n// \"__jarela_<name>\" prefix to keep the namespace tidy.\nexport function getOrCreateGlobal<T>(key: string, factory: () => T): T {\n const g = globalThis as unknown as Record<string, unknown>;\n if (g[key] === undefined) g[key] = factory();\n return g[key] as T;\n}\n","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\");","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\");","/**\n * @public\n *\n * MCP server registry types + variable substitution.\n *\n * Discovery is online via the official MCP Registry (see\n * `lib/mcp/upstream-registry.ts` and ADR-0013). Entries flow through this\n * module's types so the picker UI, install action, and `applyVariables`\n * substitution path stay decoupled from the upstream wire format.\n *\n * All exports in this file are part of the package's stable public\n * surface (per `package.json#exports`). Removing or breaking them counts\n * as a breaking change under the deprecation policy in CONTRIBUTING.md.\n */\n\nexport interface RegistryVariable {\n /** Unique key used as `${key}` in spec strings or env values. */\n key: string;\n /** Human-readable label shown in the form. */\n label: string;\n /** Placeholder text / example value. */\n placeholder?: string;\n /** If true, hide the field as a password. */\n secret?: boolean;\n /** Pre-filled default. User can edit. */\n default?: string;\n}\n\nexport interface RegistryEntry {\n /** Slug used as the default MCP server name. */\n id: string;\n /** Display name in the picker. */\n name: string;\n /** One-line description. */\n description: string;\n /** Coarse grouping in the picker UI. */\n category: \"Local\" | \"Web\" | \"Data\" | \"Productivity\" | \"Search\" | \"Cloud\" | \"Corporate\";\n /** Author label (helps users gauge trust). */\n source: \"Official\" | \"Community\" | \"Vendor\";\n /** Homepage / docs URL — shown as a small \"?\" link in the picker. */\n url?: string;\n /** Transport. stdio runs a subprocess; http calls a remote SSE/HTTP MCP server. */\n transport: \"stdio\" | \"http\";\n /** Spec template. ${var} placeholders are replaced with user input. */\n spec: Record<string, unknown>;\n /** Optional ${} variables collected from the user before saving. */\n variables?: RegistryVariable[];\n}\n\n// Substitute `${var}` placeholders in a spec object using user-supplied values.\n// Walks objects and arrays recursively; leaves non-strings alone.\nexport function applyVariables(\n spec: Record<string, unknown>,\n values: Record<string, string>,\n): Record<string, unknown> {\n return walk(spec) as Record<string, unknown>;\n\n function walk(node: unknown): unknown {\n if (typeof node === \"string\") {\n return node.replace(/\\$\\{(\\w+)\\}/g, (_, k) => values[k] ?? `\\${${k}}`);\n }\n if (Array.isArray(node)) return node.map(walk);\n if (node && typeof node === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(node as Record<string, unknown>)) out[k] = walk(v);\n return out;\n }\n return node;\n }\n}\n","// Executes a previously-approved pending action. Strictly server-side.\n// Each `kind` maps to exactly one mutation site; nothing here touches the\n// agent loop directly — approvals just write to the same tables the UI\n// would touch, and the running agent picks up changes on its next turn.\n\nimport { getMcpServer, upsertMcpServer, type McpHttpSpec, type McpServerInput, type McpStdioSpec } from \"@/lib/stores/mcp-servers\";\nimport { invalidateMcpTools } from \"@/lib/mcp/client\";\nimport { applyVariables } from \"@/lib/mcp/registry\";\nimport { getUpstreamByName } from \"@/lib/mcp/upstream-registry\";\nimport { getAgentConfig, getAgentTools, upsertAgentConfig } from \"@/lib/stores/agent-configs\";\nimport type { ActionKind } from \"@/lib/stores/pending-actions\";\nimport { getManifest } from \"@/lib/integrations/registry\";\nimport { saveIntegration, INTEGRATIONS } from \"@/lib/stores/integrations\";\nimport { upsertModelConfig, getModelConfig } from \"@/lib/stores/model-config\";\nimport {\n createCustomHarness,\n getHarness,\n updateCustomHarness,\n} from \"@/lib/stores/harnesses\";\nimport {\n CUSTOM_HARNESS_ID_PREFIX,\n HARNESS_SECTION_KEYS,\n isBuiltinHarnessId,\n type HarnessSection,\n type HarnessSectionKey,\n} from \"@/lib/agents/harness/types\";\n\nexport interface ApplyResult {\n ok: boolean;\n detail: unknown;\n}\n\n// `extras` is approval-time material collected by the UI rather than sent\n// in the original tool-call payload. ADR-0010 requires this for any action\n// whose payload would otherwise carry a secret (set_provider_key, the\n// credential fields of enable_integration). The agent never sees `extras`.\nexport async function applyAction(\n kind: ActionKind,\n payload: unknown,\n extras?: Record<string, unknown>,\n): Promise<ApplyResult> {\n switch (kind) {\n case \"install_mcp\": return await applyInstallMcp(payload);\n case \"toggle_mcp\": return applyToggleMcp(payload);\n case \"update_agent_tools\": return applyUpdateAgentTools(payload);\n case \"update_agent\": return applyUpdateAgent(payload);\n case \"start_oauth\": return applyStartOauth(payload);\n case \"set_provider_key\": return applySetProviderKey(payload, extras);\n case \"enable_integration\": return applyEnableIntegration(payload, extras);\n case \"upsert_harness\": return applyUpsertHarness(payload);\n default: return { ok: false, detail: `unknown kind: ${kind}` };\n }\n}\n\nasync function applyInstallMcp(payload: unknown): Promise<ApplyResult> {\n const p = payload as { registry_id?: string; name?: string; spec?: Record<string, unknown>;\n transport?: \"stdio\" | \"http\"; variables?: Record<string, string> };\n // Two install modes: from a registry entry (preferred) or full custom spec.\n if (p.registry_id) {\n // `registry_id` is the fully-qualified upstream name (e.g.\n // `io.github.github/github-mcp-server`). See ADR-0013.\n const entry = await getUpstreamByName(p.registry_id);\n if (!entry) return { ok: false, detail: `registry name \"${p.registry_id}\" not found in registry.modelcontextprotocol.io` };\n const missing = (entry.variables ?? []).filter((v) => !p.variables?.[v.key]?.toString().trim());\n if (missing.length > 0) {\n return { ok: false, detail: `missing variables: ${missing.map((m) => m.key).join(\", \")}` };\n }\n const spec = applyVariables(entry.spec, p.variables ?? {});\n const name = (p.name ?? entry.id).trim();\n upsertMcpServer({ name, transport: entry.transport, spec: spec as unknown as McpStdioSpec | McpHttpSpec, enabled: true });\n invalidateMcpTools();\n return { ok: true, detail: { name, registry_id: p.registry_id } };\n }\n if (p.name && p.spec && p.transport) {\n upsertMcpServer({\n name: p.name,\n transport: p.transport,\n spec: p.spec as unknown as McpStdioSpec | McpHttpSpec,\n enabled: true,\n } satisfies McpServerInput);\n invalidateMcpTools();\n return { ok: true, detail: { name: p.name } };\n }\n return { ok: false, detail: \"install_mcp needs either registry_id+variables, or name+transport+spec\" };\n}\n\nfunction applyToggleMcp(payload: unknown): ApplyResult {\n const p = payload as { name?: string; enabled?: boolean };\n if (!p.name || typeof p.enabled !== \"boolean\") return { ok: false, detail: \"name and enabled required\" };\n const existing = getMcpServer(p.name);\n if (!existing) return { ok: false, detail: `mcp server \"${p.name}\" not found` };\n upsertMcpServer({\n name: existing.name,\n transport: existing.transport as \"stdio\" | \"http\",\n spec: JSON.parse(existing.spec) as McpStdioSpec | McpHttpSpec,\n enabled: p.enabled,\n });\n invalidateMcpTools();\n return { ok: true, detail: { name: p.name, enabled: p.enabled } };\n}\n\nfunction applyUpdateAgentTools(payload: unknown): ApplyResult {\n const p = payload as { agent_id?: string; tools?: string[] };\n if (!p.agent_id || !Array.isArray(p.tools)) return { ok: false, detail: \"agent_id and tools[] required\" };\n const existing = getAgentConfig(p.agent_id);\n if (!existing) return { ok: false, detail: `agent \"${p.agent_id}\" not found` };\n upsertAgentConfig({\n id: existing.id,\n name: existing.name,\n icon: existing.icon,\n identity: existing.identity,\n instructions: existing.instructions,\n tools: p.tools,\n model_config_name: existing.model_config_name,\n });\n return { ok: true, detail: { agent_id: p.agent_id, tools: p.tools } };\n}\n\nfunction applyUpdateAgent(payload: unknown): ApplyResult {\n const p = payload as {\n agent_id?: string;\n identity?: string;\n instructions?: string;\n history_limit?: number;\n history_window_hours?: number;\n harness_id?: string | null;\n };\n if (!p.agent_id) return { ok: false, detail: \"agent_id required\" };\n const existing = getAgentConfig(p.agent_id);\n if (!existing) return { ok: false, detail: `agent \"${p.agent_id}\" not found` };\n // ADR-0036: harness_id may now be set via update_agent. Validate the id\n // resolves before writing — upsertAgentConfig stores the value verbatim, so\n // a bad id would silently break the next agent run with \"unknown harness\".\n if (p.harness_id !== undefined && p.harness_id !== null && p.harness_id !== \"\") {\n if (!getHarness(p.harness_id)) {\n return { ok: false, detail: `harness \"${p.harness_id}\" not found` };\n }\n }\n upsertAgentConfig({\n id: existing.id,\n name: existing.name,\n icon: existing.icon,\n identity: p.identity ?? existing.identity,\n instructions: p.instructions ?? existing.instructions,\n tools: getAgentTools(existing),\n model_config_name: existing.model_config_name,\n history_limit: p.history_limit ?? existing.history_limit,\n history_window_hours: p.history_window_hours ?? existing.history_window_hours,\n harness_id: p.harness_id,\n });\n return {\n ok: true,\n detail: {\n agent_id: p.agent_id,\n identity_changed: p.identity !== undefined,\n instructions_changed: p.instructions !== undefined,\n harness_id_changed: p.harness_id !== undefined,\n },\n };\n}\n\n// ADR-0036: agent-driven edits to *custom* harness presets. Built-ins remain\n// read-only; the global default pointer stays UI-only. Creates when `id` is\n// omitted; edits when `id` matches an existing custom harness.\nfunction applyUpsertHarness(payload: unknown): ApplyResult {\n const p = payload as {\n id?: string;\n name?: string;\n description?: string;\n sections?: Partial<Record<HarnessSectionKey, Partial<HarnessSection>>>;\n };\n if (p.id && isBuiltinHarnessId(p.id)) {\n return { ok: false, detail: \"built-in harnesses are read-only\" };\n }\n const sections = p.sections ?? {};\n for (const k of Object.keys(sections)) {\n if (!HARNESS_SECTION_KEYS.includes(k as HarnessSectionKey)) {\n return { ok: false, detail: `unknown harness section: ${k}` };\n }\n }\n if (p.id && p.id.startsWith(CUSTOM_HARNESS_ID_PREFIX)) {\n const updated = updateCustomHarness(p.id, {\n name: p.name,\n description: p.description,\n sections: p.sections,\n });\n if (!updated) return { ok: false, detail: `custom harness \"${p.id}\" not found` };\n return { ok: true, detail: { id: updated.id, name: updated.name, created: false } };\n }\n if (p.id) {\n return { ok: false, detail: `harness id must start with \"${CUSTOM_HARNESS_ID_PREFIX}\" or be omitted` };\n }\n if (!p.name || !p.name.trim()) {\n return { ok: false, detail: \"name required when creating a harness\" };\n }\n const created = createCustomHarness({\n name: p.name,\n description: p.description,\n sections: p.sections ?? {},\n });\n return { ok: true, detail: { id: created.id, name: created.name, created: true } };\n}\n\n// ---------------------------------------------------------------------------\n// ADR-0010: agent-led setup actions.\n// ---------------------------------------------------------------------------\n\n// `start_oauth` applies as a no-op on persistent state — the *real* effect is\n// the browser following the authorize URL we return. The approval UI handles\n// the redirect; the apply step exists only to convert the proposal into a\n// concrete authorize_url tied to the integration's vendored scopes.\nfunction applyStartOauth(payload: unknown): ApplyResult {\n const p = payload as { integration_id?: string };\n if (!p.integration_id) return { ok: false, detail: \"integration_id required\" };\n const manifest = getManifest(p.integration_id);\n if (!manifest) return { ok: false, detail: `unknown integration \"${p.integration_id}\"` };\n // The /api/v1/integrations/<id>/oauth/start endpoint already exists for\n // gmail and outlook and computes the URL from the saved client_id/secret.\n // Surface the relative path; the browser hits it after approval.\n return {\n ok: true,\n detail: {\n integration_id: manifest.id,\n kickoff_path: `/api/v1/integrations/${manifest.id}/oauth/start`,\n authorize_method: \"POST\",\n },\n };\n}\n\n// `set_provider_key` adds (or replaces) a model_configs row. The payload\n// only declares which provider/model is being configured; the actual key\n// arrives in `extras` from the approval secret-input modal. ADR-0010\n// closes the prompt-injection vector this way: a malicious page cannot\n// trick the agent into proposing an attacker key, because the agent never\n// types or sees the key.\nfunction applySetProviderKey(\n payload: unknown,\n extras?: Record<string, unknown>,\n): ApplyResult {\n const p = payload as {\n name?: string;\n provider?: string;\n model_id?: string;\n is_default?: boolean;\n };\n if (!p.name || !p.provider || !p.model_id) {\n return { ok: false, detail: \"name, provider, and model_id required\" };\n }\n const apiKey = typeof extras?.api_key === \"string\" ? extras.api_key.trim() : \"\";\n if (!apiKey) {\n return {\n ok: false,\n detail: \"api_key was not collected by the approval UI; nothing applied\",\n };\n }\n const params: Record<string, unknown> = { api_key: apiKey };\n if (typeof extras?.base_url === \"string\" && extras.base_url.trim()) {\n params.base_url = extras.base_url.trim();\n }\n const isDefault = p.is_default ?? !getModelConfig(p.name);\n const row = upsertModelConfig(p.name, p.provider, p.model_id, params, isDefault);\n return {\n ok: true,\n detail: { name: row.name, provider: row.provider, model_id: row.model_id, is_default: !!row.is_default },\n };\n}\n\n// `enable_integration` saves credentials for one of the registered\n// integrations and (implicitly) turns its tools on by virtue of the\n// resolveAuth() helpers finding a record. Field values arrive in `extras`\n// for the same reason as set_provider_key — secrets stay out of the agent\n// payload.\nfunction applyEnableIntegration(\n payload: unknown,\n extras?: Record<string, unknown>,\n): ApplyResult {\n const p = payload as { id?: string };\n if (!p.id) return { ok: false, detail: \"id required\" };\n const manifest = getManifest(p.id);\n if (!manifest) return { ok: false, detail: `unknown integration \"${p.id}\"` };\n const def = (INTEGRATIONS as unknown as Record<string, { fields: ReadonlyArray<{ key: string }> } | undefined>)[p.id];\n if (!def) {\n return {\n ok: false,\n detail: `integration \"${p.id}\" has a manifest but no credentials schema in INTEGRATIONS — cannot enable`,\n };\n }\n // Pick only declared fields out of extras, ignore unknowns. Secrets are\n // strings; everything we declare is a string today.\n const incoming: Record<string, string> = {};\n for (const f of def.fields) {\n const v = extras?.[f.key];\n if (typeof v === \"string\") incoming[f.key] = v;\n }\n const result = saveIntegration(p.id, incoming);\n if (\"error\" in result) return { ok: false, detail: result.error };\n return { ok: true, detail: { id: p.id, configured: result.configured } };\n}\n","import { NextRequest, NextResponse, after } from \"next/server\";\nimport { getPendingAction, setActionStatus } from \"@/lib/stores/pending-actions\";\nimport { applyAction } from \"@/lib/agents/proposals\";\nimport { publish as publishNotification } from \"@/lib/notifications/bus\";\n\ntype Params = { params: Promise<{ id: string }> };\n\nexport async function POST(req: NextRequest, { params }: Params) {\n const { id } = await params;\n const action = getPendingAction(id);\n if (!action) return NextResponse.json({ error: \"not found\" }, { status: 404 });\n if (action.status !== \"pending\") {\n return NextResponse.json({ error: `already ${action.status}` }, { status: 409 });\n }\n\n // Optional approval-time secret material (ADR-0010). The agent never sees\n // these — they come from the secret-input modal in the approval banner.\n let extras: Record<string, unknown> | undefined;\n if (req.headers.get(\"content-length\") && req.headers.get(\"content-length\") !== \"0\") {\n try {\n const body = (await req.json()) as { extras?: Record<string, unknown> } | null;\n if (body && body.extras && typeof body.extras === \"object\") extras = body.extras;\n } catch {\n // Empty / non-JSON body is fine — fall back to extras=undefined.\n }\n }\n\n const result = await applyAction(action.kind, JSON.parse(action.payload), extras);\n const final = setActionStatus(id, result.ok ? \"approved\" : \"failed\", result.detail);\n\n // The user's banner already disappears the moment the response lands;\n // the notification is just for any subscribed clients (other browser\n // tabs, mobile PWA). Fire it after the response so the approving tab\n // returns immediately.\n after(() => {\n publishNotification({\n type: \"run_completed\",\n thread_id: \"\",\n agent_id: action.agent_id,\n status: result.ok ? \"done\" : \"error\",\n preview: result.ok\n ? `✅ Approved & applied: ${action.kind}`\n : `⚠️ Approval failed to apply: ${typeof result.detail === \"string\" ? result.detail : JSON.stringify(result.detail)}`,\n ts: Date.now(),\n });\n });\n\n return NextResponse.json(final);\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/pending-actions/[id]/approve/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/pending-actions/[id]/approve/route\",\n pathname: \"/api/v1/pending-actions/[id]/approve\",\n filename: \"route\",\n bundlePath: \"app/api/v1/pending-actions/[id]/approve/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/pending-actions/[id]/approve/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/pending-actions/[id]/approve/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/pending-actions/[id]/approve/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: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\");","module.exports = import(\"@langchain/mcp-adapters\");;","module.exports = require(\"events\");"],"names":["getOrCreateGlobal","key","factory","g","globalThis","undefined","applyVariables","spec","values","walk","node","replace","_","k","Array","isArray","map","out","v","Object","entries","getMcpServer","upsertMcpServer","invalidateMcpTools","getUpstreamByName","getAgentConfig","getAgentTools","upsertAgentConfig","getManifest","saveIntegration","INTEGRATIONS","upsertModelConfig","getModelConfig","createCustomHarness","getHarness","updateCustomHarness","CUSTOM_HARNESS_ID_PREFIX","HARNESS_SECTION_KEYS","isBuiltinHarnessId","applyAction","kind","payload","extras","applyInstallMcp","applyToggleMcp","applyUpdateAgentTools","applyUpdateAgent","applyStartOauth","applySetProviderKey","applyEnableIntegration","applyUpsertHarness","ok","detail","p","registry_id","entry","missing","variables","filter","toString","trim","length","m","join","name","id","transport","enabled","existing","JSON","parse","agent_id","tools","icon","identity","instructions","model_config_name","harness_id","history_limit","history_window_hours","identity_changed","instructions_changed","harness_id_changed","sections","keys","includes","startsWith","updated","description","created","integration_id","manifest","kickoff_path","authorize_method","provider","model_id","apiKey","api_key","params","base_url","isDefault","is_default","row","def","incoming","f","fields","result","error","configured","NextResponse","after","getPendingAction","setActionStatus","publish","publishNotification","POST","req","action","json","status","headers","get","body","final","type","thread_id","preview","stringify","ts","Date","now"],"sourceRoot":"","ignoreList":[0,3,5,11,16,23,36]}
|
|
@@ -1051,6 +1051,7 @@ module.exports = require("next/dist/compiled/next-server/app-route.runtime.prod.
|
|
|
1051
1051
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1052
1052
|
|
|
1053
1053
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1054
|
+
/* harmony export */ YY: () => (/* binding */ listKnownModels),
|
|
1054
1055
|
/* harmony export */ pN: () => (/* binding */ getKnownMaxOutputTokens),
|
|
1055
1056
|
/* harmony export */ zJ: () => (/* binding */ getKnownContextLength)
|
|
1056
1057
|
/* harmony export */ });
|
|
@@ -1272,6 +1273,33 @@ function getKnownContextLength(provider, model_id) {
|
|
|
1272
1273
|
function getKnownMaxOutputTokens(provider, model_id) {
|
|
1273
1274
|
return getKnownModelLimits(provider, model_id)?.max_output_tokens ?? null;
|
|
1274
1275
|
}
|
|
1276
|
+
// Flat catalog snapshot for one provider — used by introspection tools so
|
|
1277
|
+
// the agent can enumerate what's known statically. Returns [] for providers
|
|
1278
|
+
// without a static table (e.g. `langchain`, `mock`, externals).
|
|
1279
|
+
function listKnownModels(provider) {
|
|
1280
|
+
let table = null;
|
|
1281
|
+
switch(provider){
|
|
1282
|
+
case "anthropic":
|
|
1283
|
+
table = ANTHROPIC;
|
|
1284
|
+
break;
|
|
1285
|
+
case "gemini":
|
|
1286
|
+
table = GEMINI;
|
|
1287
|
+
break;
|
|
1288
|
+
case "openai":
|
|
1289
|
+
table = OPENAI;
|
|
1290
|
+
break;
|
|
1291
|
+
case "deepseek":
|
|
1292
|
+
table = DEEPSEEK;
|
|
1293
|
+
break;
|
|
1294
|
+
default:
|
|
1295
|
+
return [];
|
|
1296
|
+
}
|
|
1297
|
+
return Object.entries(table).map(([model_id, l])=>({
|
|
1298
|
+
model_id,
|
|
1299
|
+
context_length: l.context_length,
|
|
1300
|
+
max_output_tokens: l.max_output_tokens ?? null
|
|
1301
|
+
}));
|
|
1302
|
+
}
|
|
1275
1303
|
|
|
1276
1304
|
|
|
1277
1305
|
/***/ }),
|