@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.
Files changed (164) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +1 -1
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.html +2 -2
  16. package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
  17. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  20. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  23. package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js +6 -1
  24. package/.next/standalone/.next/server/app/api/v1/agents/[id]/route.js.map +1 -1
  25. package/.next/standalone/.next/server/app/api/v1/agents/route.js +6 -1
  26. package/.next/standalone/.next/server/app/api/v1/agents/route.js.map +1 -1
  27. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +9 -1
  28. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.map +1 -1
  29. package/.next/standalone/.next/server/app/api/v1/bridges/route.js +9 -1
  30. package/.next/standalone/.next/server/app/api/v1/bridges/route.js.map +1 -1
  31. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +36 -29
  32. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.map +1 -1
  33. package/.next/standalone/.next/server/app/api/v1/events/route.js +7 -1
  34. package/.next/standalone/.next/server/app/api/v1/events/route.js.map +1 -1
  35. package/.next/standalone/.next/server/app/api/v1/extensions/route.js +3 -3
  36. package/.next/standalone/.next/server/app/api/v1/extensions/route.js.map +1 -1
  37. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +4 -4
  38. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.map +1 -1
  39. package/.next/standalone/.next/server/app/api/v1/health/route.js +7 -1
  40. package/.next/standalone/.next/server/app/api/v1/health/route.js.map +1 -1
  41. package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js +9 -1
  42. package/.next/standalone/.next/server/app/api/v1/mcp-servers/[name]/route.js.map +1 -1
  43. package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js +9 -1
  44. package/.next/standalone/.next/server/app/api/v1/mcp-servers/route.js.map +1 -1
  45. package/.next/standalone/.next/server/app/api/v1/models/route.js +6 -1
  46. package/.next/standalone/.next/server/app/api/v1/models/route.js.map +1 -1
  47. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +7 -1
  48. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.map +1 -1
  49. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +14 -7
  50. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.map +1 -1
  51. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js +28 -0
  52. package/.next/standalone/.next/server/app/api/v1/providers/[provider]/models/route.js.map +1 -1
  53. package/.next/standalone/.next/server/app/api/v1/providers/route.js +7 -1
  54. package/.next/standalone/.next/server/app/api/v1/providers/route.js.map +1 -1
  55. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js +16 -2
  56. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/route.js.map +1 -1
  57. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +8 -1
  58. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.map +1 -1
  59. package/.next/standalone/.next/server/app/api/v1/threads/route.js +6 -1
  60. package/.next/standalone/.next/server/app/api/v1/threads/route.js.map +1 -1
  61. package/.next/standalone/.next/server/app/api/v1/tools/route.js +10 -3
  62. package/.next/standalone/.next/server/app/api/v1/tools/route.js.map +1 -1
  63. package/.next/standalone/.next/server/app/index.html +2 -2
  64. package/.next/standalone/.next/server/app/index.rsc +3 -3
  65. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  66. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  67. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  68. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
  69. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  70. package/.next/standalone/.next/server/app/page.js +56 -0
  71. package/.next/standalone/.next/server/app/page.js.map +1 -1
  72. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  73. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  74. package/.next/standalone/.next/server/app/setup.html +1 -1
  75. package/.next/standalone/.next/server/app/setup.rsc +2 -2
  76. package/.next/standalone/.next/server/app/setup.segments/_full.segment.rsc +2 -2
  77. package/.next/standalone/.next/server/app/setup.segments/_head.segment.rsc +1 -1
  78. package/.next/standalone/.next/server/app/setup.segments/_index.segment.rsc +2 -2
  79. package/.next/standalone/.next/server/app/setup.segments/_tree.segment.rsc +2 -2
  80. package/.next/standalone/.next/server/app/setup.segments/setup/__PAGE__.segment.rsc +1 -1
  81. package/.next/standalone/.next/server/app/setup.segments/setup.segment.rsc +1 -1
  82. package/.next/standalone/.next/server/app-paths-manifest.json +1 -1
  83. package/.next/standalone/.next/server/chunks/1683.js +2 -2
  84. package/.next/standalone/.next/server/chunks/2082.js +122 -13
  85. package/.next/standalone/.next/server/chunks/2082.js.map +1 -1
  86. package/.next/standalone/.next/server/chunks/210.js +3 -3
  87. package/.next/standalone/.next/server/chunks/210.js.map +1 -1
  88. package/.next/standalone/.next/server/chunks/239.js +1902 -1487
  89. package/.next/standalone/.next/server/chunks/239.js.map +1 -1
  90. package/.next/standalone/.next/server/chunks/2447.js +9 -1
  91. package/.next/standalone/.next/server/chunks/2447.js.map +1 -1
  92. package/.next/standalone/.next/server/chunks/423.js +125 -16
  93. package/.next/standalone/.next/server/chunks/423.js.map +1 -1
  94. package/.next/standalone/.next/server/chunks/4631.js +36 -29
  95. package/.next/standalone/.next/server/chunks/4631.js.map +1 -1
  96. package/.next/standalone/.next/server/chunks/5937.js +3 -2
  97. package/.next/standalone/.next/server/chunks/5937.js.map +1 -1
  98. package/.next/standalone/.next/server/chunks/{947.js → 8866.js} +11321 -10883
  99. package/.next/standalone/.next/server/chunks/8866.js.map +1 -0
  100. package/.next/standalone/.next/server/chunks/9032.js +3 -3
  101. package/.next/standalone/.next/server/chunks/9032.js.map +1 -1
  102. package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
  103. package/.next/standalone/.next/server/middleware.js +122 -13
  104. package/.next/standalone/.next/server/pages/404.html +2 -2
  105. package/.next/standalone/.next/server/pages/500.html +1 -1
  106. package/.next/standalone/.next/server/proxy.js.map +1 -1
  107. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  108. package/.next/standalone/.next/static/chunks/app/{page-473b39ec30c7f569.js → page-a7cae65f235e2942.js} +57 -1
  109. package/.next/standalone/.next/static/chunks/app/page-a7cae65f235e2942.js.map +1 -0
  110. package/.next/standalone/.next/static/css/{6f8b1a84bcbcd467.css → e57bdbbbb5a05779.css} +2 -2
  111. package/.next/standalone/.next/static/css/e57bdbbbb5a05779.css.map +1 -0
  112. package/.next/standalone/package.json +9 -1
  113. package/CHANGELOG.md +90 -0
  114. package/README.md +30 -2
  115. package/api/types.ts +8 -0
  116. package/app/api/v1/agents/[id]/route.ts +7 -0
  117. package/app/api/v1/agents/route.ts +7 -0
  118. package/app/api/v1/events/route.ts +8 -0
  119. package/app/api/v1/extensions/route.ts +2 -2
  120. package/app/api/v1/extensions/tools/[name]/secrets/route.ts +3 -3
  121. package/app/api/v1/health/route.ts +8 -0
  122. package/app/api/v1/models/route.ts +7 -0
  123. package/app/api/v1/page-capture/route.ts +8 -0
  124. package/app/api/v1/providers/route.ts +8 -0
  125. package/app/api/v1/threads/[thread_id]/route.ts +8 -0
  126. package/app/api/v1/threads/[thread_id]/run/route.ts +9 -0
  127. package/app/api/v1/threads/route.ts +7 -0
  128. package/app/api/v1/tools/route.ts +9 -0
  129. package/components/chat/ContextUsageBar.tsx +44 -0
  130. package/lib/agents/llm.ts +25 -2
  131. package/lib/agents/run-thread.ts +13 -1
  132. package/lib/agents/stream-collector.ts +9 -1
  133. package/lib/api/serializers.test.ts +15 -0
  134. package/lib/api/serializers.ts +8 -0
  135. package/lib/db/migrations.ts +15 -0
  136. package/lib/health/runner.test.ts +24 -2
  137. package/lib/mcp/registry.ts +14 -6
  138. package/lib/providers/anthropic.test.ts +95 -0
  139. package/lib/providers/anthropic.ts +106 -10
  140. package/lib/providers/jarela-chat-model.ts +9 -1
  141. package/lib/providers/known-context-windows.ts +21 -0
  142. package/lib/providers/types.ts +21 -1
  143. package/lib/stores/message-usage.test.ts +34 -0
  144. package/lib/stores/message-usage.ts +15 -3
  145. package/lib/stores/pricing.test.ts +52 -0
  146. package/lib/stores/pricing.ts +26 -1
  147. package/lib/tools/builtins.ts +4 -0
  148. package/lib/tools/extension-surfaces.test.ts +79 -0
  149. package/lib/tools/extension-surfaces.ts +153 -0
  150. package/lib/tools/index.ts +27 -8
  151. package/lib/tools/list-tools.test.ts +76 -0
  152. package/lib/tools/list-tools.ts +84 -0
  153. package/lib/tools/mcp-servers-info.test.ts +73 -0
  154. package/lib/tools/mcp-servers-info.ts +71 -0
  155. package/lib/tools/providers-info.test.ts +73 -0
  156. package/lib/tools/providers-info.ts +106 -0
  157. package/lib/tools/registry.ts +36 -25
  158. package/lib/tools/types.ts +13 -0
  159. package/package.json +9 -1
  160. package/.next/standalone/.next/server/chunks/947.js.map +0 -1
  161. package/.next/standalone/.next/static/chunks/app/page-473b39ec30c7f569.js.map +0 -1
  162. package/.next/standalone/.next/static/css/6f8b1a84bcbcd467.css.map +0 -1
  163. /package/.next/standalone/.next/static/{T0p2VVPsJPj44rwbmjaFb → d_vhp-lJqfdjRFpnLVIqZ}/_buildManifest.js +0 -0
  164. /package/.next/standalone/.next/static/{T0p2VVPsJPj44rwbmjaFb → d_vhp-lJqfdjRFpnLVIqZ}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"../app/api/v1/builtin-tools/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,yCAAyC;AACzC,EAAE;AACF,uEAAuE;AACvE,wEAAwE;AACxE,0EAA0E;AAC1E,0EAA0E;AAC1E,uEAAuE;AACvE,+BAA+B;AAC/B,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,qEAAqE;AACrE,qEAAqE;AACrE,iEAAiE;AACjE,EAAE;AACF,qEAAqE;AACrE,wEAAwE;AACxE,sEAAsE;AACtE,yE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ACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,gEAAW;AACxC;AACA,MAAM,kFAAkB;AACxB,kBAAkB,iFAAiB;AACnC,IAAI;AACJ;AACA,+CAA+C,QAAQ,aAAa,UAAU;AAC9E,OAAO,iFAAiB,kBAAkB,QAAQ,MAAM,4DAAiB,IAAI;AAC7E,aAAa,0EAAyB;AACtC;AACA;AACA,kBAAkB,0EAAQ;AAC1B;AACA;AACA,gDAAgD,QAAQ,aAAa,4BAA4B,kBAAkB,IAAI,QAAQ,cAAc;AAC7I,cAAc,0EAAyB;AACvC;AACA;AACA;AACA,iBAAiB,uFAAsB;AACvC,2BAA2B,4EAAe,+GAA+G,uBAAuB;AAChL;AACA,MAAM,gEAAW;AACjB,qBAAqB,yEAAoB;AACzC;AACA;AACA;AACA;AACA;AACA,YAAY,8EAAgB,cAAc,mFAAqB;AAC/D;AACA;AACA,MAAM;AACN;AACA;AACA,IAAI;AACJ,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA,sHAAsH,uBAAuB;AAC7I;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,qDAAQ,GAAG,OAAO,qDAAQ,eAAe;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mEAAmE,aAAa;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,uFAAsB;AACvC;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,uFAAsB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,uFAAuB;AACrD,4BAA4B,qFAAoB;AAChD;AACA;AACA,sEAAsE,aAAa;AACnF;AACA;AACA,wBAAwB,2EAAW,WAAW,mCAAmC;AACjF,IAAI,iHAAkC,eAAe,sFAAsB;AAC3E;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL,IAAI;AACJ;AACA,EAAE;AACF;AACA,2EAA2E,aAAa;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,+EAAmB;AAChC;AACA,yDAAyD,YAAY;AACrE;AACA,wBAAwB,2EAAW,WAAW,mCAAmC;AACjF,IAAI,iHAAkC,eAAe,sFAAsB;AAC3E;AACA;AACA,UAAU,8EAAgB;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,KAAK;AACL,IAAI;AACJ;AACA,EAAE;AACF;AACA;AACA,SAAS,0CAA0C;AACnD,oBAAoB,+EAAkB,sIAAsI,oEAAW;AACvL;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF,iBAAiB,oEAAW;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,YAAY,QAAQ;AACpB;AACA;AACA;AACgN;;AAEhN;;;;;;;ACvWA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAwD;AAChC;AACyE;AAI7D;AAC8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ACL,WAAW;QACvC,OAAOyB,mCAAaA,CAAC,CAAC,kBAAkB,EAAEzB,UAAU;IACtD;IACAyD,4CAAkBA,CAACzD,UAA6BiD;IAChD,OAAOzB,mBAAYA,CAACG,IAAI,CAAC;QAAE3B;QAAUiD;IAAQ;AAC/C;;;AClE+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AAC4B;AAC9F;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","sources":["webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/router/utils/app-paths\"","webpack://@circuitwall/jarela/external node-commonjs \"node:process\"","webpack://@circuitwall/jarela/external commonjs2 \"url\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/after-task-async-storage.external.js\"","webpack://@circuitwall/jarela/external commonjs \"undici\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-page.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:async_hooks\"","webpack://@circuitwall/jarela/./lib/tools/wallclock.ts","webpack://@circuitwall/jarela/./lib/tools/registry.ts","webpack://@circuitwall/jarela/external commonjs2 \"stream\"","webpack://@circuitwall/jarela/external commonjs2 \"util\"","webpack://@circuitwall/jarela/external commonjs2 \"fs\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:child_process\"","webpack://@circuitwall/jarela/external commonjs2 \"path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:http\"","webpack://@circuitwall/jarela/./lib/api/responses.ts","webpack://@circuitwall/jarela/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/./lib/stores/builtin-tools.ts","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/./node_modules/@langchain/core/dist/tools/index.js","webpack://@circuitwall/jarela/external node-commonjs \"node:fs\"","webpack://@circuitwall/jarela/external node-commonjs \"node:url\"","webpack://@circuitwall/jarela/external node-commonjs \"node:worker_threads\"","webpack://@circuitwall/jarela/external node-commonjs \"node:path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"buffer\"","webpack://@circuitwall/jarela/external node-commonjs \"node:sqlite\"","webpack://@circuitwall/jarela/external commonjs2 \"http\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/no-fallback-error.external\"","webpack://@circuitwall/jarela/external commonjs2 \"events\"","webpack://@circuitwall/jarela/./app/api/v1/builtin-tools/route.ts","webpack://@circuitwall/jarela/?37ff"],"sourcesContent":["module.exports = require(\"next/dist/shared/lib/router/utils/app-paths\");","module.exports = require(\"node:process\");","module.exports = require(\"url\");","module.exports = require(\"next/dist/server/app-render/after-task-async-storage.external.js\");","module.exports = require(\"undici\");","module.exports = require(\"next/dist/compiled/next-server/app-page.runtime.prod.js\");","module.exports = require(\"node:async_hooks\");","// Per-call wall-clock budgets for tools.\n//\n// Every registered tool is wrapped with a Promise.race against a timer\n// the LLM controls via an injected `deadline_ms` schema field. When the\n// timer fires first, the wrapped tool returns a structured timeout result\n// to the agent instead of throwing — the turn continues, the agent gets a\n// tool message saying \"timed out\", and can recover (retry differently,\n// split the work, or move on).\n//\n// Why \"agent self-set\" instead of a global env knob: the right deadline\n// is hugely context-dependent (a 5s budget for a memory_read is right;\n// the same budget for `npm install` is absurd). The model knows what\n// it's calling, so the model picks. The `deadline_ms` field on every\n// tool's schema makes that picker explicit and self-documenting.\n//\n// Caveat: the underlying tool's promise is abandoned, not aborted. A\n// network call or subprocess started by the tool keeps running until it\n// settles into the void. Tools that own a long-lived resource (fetch,\n// exec) should use the `deadline_ms` value themselves to drive their own\n// abort signal — the wallclock wrapper is the backstop, not the only\n// mechanism.\n\nimport { z } from \"zod\";\nimport { tool, type StructuredToolInterface } from \"@langchain/core/tools\";\n\nconst DEFAULT_DEADLINE_MS = 120_000;\n\nconst DEADLINE_DESCRIPTION =\n \"Optional wall-clock budget for this tool call in milliseconds (default 120000). \" +\n \"When the budget is exceeded the call returns a structured timeout result \" +\n \"and the turn continues so you can recover — pick a value that matches \" +\n \"the expected duration (5000-15000 for fast local ops, 30000-90000 for \" +\n \"network/web calls, larger for shell commands that may build or install).\";\n\ninterface WallclockedFunc {\n (args: Record<string, unknown>, config?: unknown): Promise<unknown>;\n}\n\nexport function wrapWithWallclock<T extends StructuredToolInterface>(t: T): T {\n // Only zod-object schemas can be extended with `deadline_ms`. Other\n // schema shapes (raw JSON Schema, ZodString) pass through unchanged.\n // Those tools still get the wallclock race using the default budget.\n const schema = (t as unknown as { schema: unknown }).schema;\n const extendedSchema = schema instanceof z.ZodObject\n ? schema.extend({ deadline_ms: z.number().int().positive().optional().describe(DEADLINE_DESCRIPTION) })\n : null;\n\n const wrappedFunc: WallclockedFunc = async (args, config) => {\n const deadlineMs = readDeadlineMs(args) ?? DEFAULT_DEADLINE_MS;\n const innerArgs = stripDeadline(args);\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<string>((resolve) => {\n timer = setTimeout(() => {\n resolve(JSON.stringify({\n ok: false,\n error_code: \"tool_timeout\",\n message:\n `Tool \"${t.name}\" exceeded its wall-clock budget of ${deadlineMs}ms. ` +\n `The call was abandoned; the underlying operation may still be running in the background. ` +\n `Recover by trying a different approach, splitting the work, or moving on — do not retry the same call with the same arguments.`,\n deadline_ms: deadlineMs,\n }));\n }, deadlineMs);\n // Don't keep the event loop alive purely for a timeout race.\n (timer as unknown as { unref?: () => void }).unref?.();\n });\n\n try {\n // Cast: invoke accepts a typed input matching the original schema,\n // but the wrapper is generic over all tools.\n const work = (t as unknown as { invoke: (a: unknown, c?: unknown) => Promise<unknown> }).invoke(innerArgs, config);\n return await Promise.race([work, timeoutPromise]);\n } finally {\n if (timer) clearTimeout(timer);\n }\n };\n\n // Rebuild via the public `tool()` factory so we don't depend on\n // internal field shapes of the StructuredTool class. The new tool\n // keeps the original's name and description, swaps in the extended\n // schema, and routes invocation through wrappedFunc.\n const rebuilt = tool(\n wrappedFunc as never,\n {\n name: t.name,\n description: t.description ?? \"\",\n schema: (extendedSchema ?? schema) as never,\n } as never,\n );\n return rebuilt as unknown as T;\n}\n\nfunction readDeadlineMs(args: Record<string, unknown> | unknown): number | null {\n if (!args || typeof args !== \"object\") return null;\n const v = (args as Record<string, unknown>).deadline_ms;\n return typeof v === \"number\" && Number.isFinite(v) && v > 0 ? v : null;\n}\n\nfunction stripDeadline(args: Record<string, unknown> | unknown): Record<string, unknown> | unknown {\n if (!args || typeof args !== \"object\") return args;\n const { deadline_ms: _ignore, ...rest } = args as Record<string, unknown>;\n void _ignore;\n return rest;\n}\n\n/** Exposed for the tests. */\nexport const __DEFAULT_DEADLINE_MS = DEFAULT_DEADLINE_MS;\n","// Tool registry.\n//\n// Each built-in tool module registers its own tools at module load with\n// two orthogonal axes:\n//\n// * category — topical group (\"Memory\", \"Files\", \"Mail\", …) used by\n// the Agent editor sidebar to organise tools for users.\n// * capability — safety class (\"read\" | \"write\" | \"execute\") used by\n// the future per-capability approval gate, UI badges,\n// and the ADR-0037 output validator. See ADR-0038.\n//\n// lib/tools/index.ts only needs to side-effect-import the modules\n// (see ./builtins.ts) — there is no central map listing every tool by\n// name. Adding a new built-in tool now requires touching exactly two\n// files: the tool file itself, and an `import \"./<name>\";` line in\n// builtins.ts.\n//\n// External tools (loaded from JARELA_TOOLS_DIR at runtime) use the same\n// category vocabulary but are not stored in this registry — see\n// ./external.ts. MCP tools default to category \"MCP\". Both default to\n// capability \"execute\" until manifest-level overrides land (ADR-0038\n// follow-up).\n\nimport type { StructuredToolInterface } from \"@langchain/core/tools\";\nimport { wrapWithWallclock } from \"./wallclock\";\n\nexport type ToolCategory =\n | \"Memory\" | \"Documents\" | \"Files\" | \"Shell\" | \"Web\" | \"Images\" | \"Voice\"\n | \"Schedule\" | \"Atlassian\" | \"JiraAlign\" | \"GitHub\" | \"Mail\" | \"Calendar\" | \"Config\" | \"Agent\" | \"MCP\";\n\n// Safety class. Orthogonal to ToolCategory. See ADR-0038 for definitions\n// and tie-breakers (network reads vs writes, drafts, etc.).\nexport type Capability = \"read\" | \"write\" | \"execute\";\n\n// Optional parent grouping for the Agent editor sidebar.\nexport type ToolGroup = \"Work\" | null;\n\n// Category → group mapping. \"Work\" collapses corporate-auth tools under\n// one header in the Agent editor; everything else is a top-level category.\nconst CATEGORY_GROUPS: Record<Exclude<ToolCategory, \"MCP\">, ToolGroup> = {\n Memory: null, Documents: null, Files: null, Shell: null, Web: null, Images: null, Voice: null,\n Schedule: null, Config: null, Mail: null, Calendar: null, Agent: null,\n Atlassian: \"Work\", JiraAlign: \"Work\", GitHub: \"Work\",\n};\n\nexport type BuiltinCategory = Exclude<ToolCategory, \"MCP\">;\n\ninterface RegistryEntry {\n tool: StructuredToolInterface;\n category: BuiltinCategory;\n capability: Capability;\n group: ToolGroup;\n}\n\nconst REGISTRY = new Map<string, RegistryEntry>();\n\n/**\n * Register one or more tools under a category and capability. Call this at\n * the bottom of each tool file (after the tools are defined). Files with\n * mixed capabilities make multiple calls — see ADR-0038. Throws on\n * duplicate names — collisions are bugs, not warnings.\n */\nexport function registerTools<T extends StructuredToolInterface>(\n category: BuiltinCategory,\n capability: Capability,\n tools: readonly T[],\n): readonly T[] {\n const group = CATEGORY_GROUPS[category];\n const wrapped: T[] = [];\n for (const t of tools) {\n if (REGISTRY.has(t.name)) {\n throw new Error(`[tools] duplicate built-in tool registration: ${t.name}`);\n }\n // Every built-in tool gets the agent-controlled wall-clock wrap so a\n // single stuck call (network hang, fs on a wedged cloud-sync drive,\n // runaway shell) can't pin the turn — see lib/tools/wallclock.ts.\n const w = wrapWithWallclock(t);\n REGISTRY.set(w.name, { tool: w, category, capability, group });\n wrapped.push(w);\n }\n return wrapped;\n}\n\n/** All registered built-in tools, in registration order. */\nexport function registeredTools(): StructuredToolInterface[] {\n return Array.from(REGISTRY.values(), (e) => e.tool);\n}\n\n/** Names of all registered built-in tools — used for collision checks. */\nexport function registeredNames(): ReadonlySet<string> {\n return new Set(REGISTRY.keys());\n}\n\nexport function registeredCategory(name: string): BuiltinCategory | undefined {\n return REGISTRY.get(name)?.category;\n}\n\nexport function registeredCapability(name: string): Capability | undefined {\n return REGISTRY.get(name)?.capability;\n}\n\nexport function registeredGroup(name: string): ToolGroup | undefined {\n return REGISTRY.get(name)?.group;\n}\n\n/** Test-only: clear the registry between cases. */\nexport function _resetRegistry(): void {\n REGISTRY.clear();\n}\n","module.exports = require(\"stream\");","module.exports = require(\"util\");","module.exports = require(\"fs\");","module.exports = require(\"next/dist/server/app-render/work-async-storage.external.js\");","module.exports = require(\"node:child_process\");","module.exports = require(\"path\");","module.exports = require(\"node:http\");","// Shared HTTP response builders for app/api/v1/** route handlers.\n//\n// Goal: every error/success payload across the v1 surface has the same\n// shape. Before this lived inline, response bodies drifted —\n// `{error: \"x\"}` vs `{message: \"x\"}`, 400 vs 422 for the same condition,\n// some routes returned Zod's raw issue array, others stringified it.\n\nimport { NextResponse } from \"next/server\";\nimport type { z } from \"zod\";\nimport type { NextRequest } from \"next/server\";\n\nexport function errorResponse(message: string, status: number = 400): NextResponse {\n return NextResponse.json({ error: message }, { status });\n}\n\nexport function notFoundResponse(message: string = \"Not found\"): NextResponse {\n return errorResponse(message, 404);\n}\n\nexport function createdResponse<T>(data: T): NextResponse {\n return NextResponse.json(data, { status: 201 });\n}\n\n// Wrap a 200 JSON response with a private Cache-Control header. Use on safe\n// GET endpoints that serve user-scoped data the client refetches often (panel\n// mounts, navigation back/forward) but mutates rarely. The TTL is short\n// enough that explicit mutations — which patch the client-side ApiClient\n// cache in place — stay observably consistent without an extra roundtrip.\nexport function cachedJson<T>(data: T, maxAgeSeconds: number): NextResponse {\n return NextResponse.json(data, {\n headers: {\n \"Cache-Control\": `private, max-age=${maxAgeSeconds}`,\n },\n });\n}\n\n// Validate a JSON request body against a zod schema.\n// Returns either the parsed data or a 400 NextResponse explaining the issue.\n// Caller pattern:\n// const parsed = await validateBody(req, Schema);\n// if (parsed instanceof NextResponse) return parsed;\n// // use parsed.field\nexport async function validateBody<S extends z.ZodTypeAny>(\n req: NextRequest,\n schema: S,\n): Promise<z.infer<S> | NextResponse> {\n let raw: unknown;\n try {\n raw = await req.json();\n } catch {\n return errorResponse(\"Request body must be valid JSON\", 400);\n }\n const parsed = schema.safeParse(raw);\n if (!parsed.success) {\n return errorResponse(parsed.error.issues[0]?.message ?? \"invalid body\", 400);\n }\n return parsed.data;\n}\n","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\");","// Built-in tool category toggles.\n//\n// A category is \"enabled\" unless an explicit row in `builtin_tool_categories`\n// says otherwise. Default-enabled semantics mean upgrading installs keep\n// every category working with zero migration work.\n//\n// Disabled categories are filtered at three layers:\n// - GET /api/v1/tools (so the agent editor never offers them as permissions)\n// - getAllTools / getAllToolsAsync (so the agent runtime can't see them)\n// - executeTool (defense in depth, blocks stale agent configs)\n\nimport { getDb } from \"@/lib/db\";\nimport type { BuiltinCategory } from \"@/lib/tools/registry\";\n\ninterface Row {\n category: string;\n enabled: number;\n updated_at: string;\n}\n\nconst now = () => new Date().toISOString();\n\nexport function isCategoryEnabled(category: BuiltinCategory): boolean {\n const row = getDb()\n .prepare(\"SELECT enabled FROM builtin_tool_categories WHERE category=?\")\n .get(category) as { enabled: number } | undefined;\n return row ? row.enabled === 1 : true;\n}\n\nexport function disabledCategories(): Set<BuiltinCategory> {\n const rows = getDb()\n .prepare(\"SELECT category FROM builtin_tool_categories WHERE enabled=0\")\n .all() as unknown as Array<{ category: string }>;\n return new Set(rows.map((r) => r.category as BuiltinCategory));\n}\n\nexport function listCategoryStates(): Array<{ category: string; enabled: boolean; updated_at: string | null }> {\n const rows = getDb()\n .prepare(\"SELECT category, enabled, updated_at FROM builtin_tool_categories\")\n .all() as unknown as Row[];\n return rows.map((r) => ({\n category: r.category,\n enabled: r.enabled === 1,\n updated_at: r.updated_at,\n }));\n}\n\nexport function setCategoryEnabled(category: BuiltinCategory, enabled: boolean): void {\n getDb()\n .prepare(\n `INSERT INTO builtin_tool_categories (category, enabled, updated_at)\n VALUES (?, ?, ?)\n ON CONFLICT(category) DO UPDATE SET enabled=excluded.enabled, updated_at=excluded.updated_at`,\n )\n .run(category, enabled ? 1 : 0, now());\n}\n","module.exports = require(\"node:stream\");","module.exports = require(\"node:util\");","module.exports = require(\"next/dist/server/app-render/work-unit-async-storage.external.js\");","import { __exportAll } from \"../_virtual/_rolldown/runtime.js\";\nimport { ToolInputParsingException, _configHasToolCallId, _isToolCall } from \"./utils.js\";\nimport { ToolMessage, isDirectToolOutput } from \"../messages/tool.js\";\nimport { CallbackManager, parseCallbackConfigArg } from \"../callbacks/manager.js\";\nimport { AsyncLocalStorageProviderSingleton } from \"../singletons/async_local_storage/index.js\";\nimport \"../singletons/index.js\";\nimport { ensureConfig, mergeConfigs, patchConfig, pickRunnableConfigKeys } from \"../runnables/config.js\";\nimport { getAbortSignalError } from \"../utils/signal.js\";\nimport { interopParseAsync, isInteropZodError, isInteropZodSchema, isSimpleStringZodSchema } from \"../utils/types/zod.js\";\nimport { validatesOnlyStrings } from \"../utils/json_schema.js\";\nimport { consumeAsyncGenerator, isAsyncGenerator } from \"../runnables/iter.js\";\nimport { BaseLangChain } from \"../language_models/base.js\";\nimport { isLangChainTool, isRunnableToolLike, isStructuredTool, isStructuredToolParams } from \"./types.js\";\nimport { z } from \"zod/v3\";\nimport { validate } from \"@cfworker/json-schema\";\nimport { z as z$1 } from \"zod/v4\";\n//#region src/tools/index.ts\nvar tools_exports = /* @__PURE__ */ __exportAll({\n\tBaseToolkit: () => BaseToolkit,\n\tDynamicStructuredTool: () => DynamicStructuredTool,\n\tDynamicTool: () => DynamicTool,\n\tStructuredTool: () => StructuredTool,\n\tTool: () => Tool,\n\tToolInputParsingException: () => ToolInputParsingException,\n\tisLangChainTool: () => isLangChainTool,\n\tisRunnableToolLike: () => isRunnableToolLike,\n\tisStructuredTool: () => isStructuredTool,\n\tisStructuredToolParams: () => isStructuredToolParams,\n\ttool: () => tool\n});\n/**\n* Base class for Tools that accept input of any shape defined by a Zod schema.\n*/\nvar StructuredTool = class extends BaseLangChain {\n\t/**\n\t* Optional provider-specific extra fields for the tool.\n\t*\n\t* This is used to pass provider-specific configuration that doesn't fit into\n\t* standard tool fields.\n\t*/\n\textras;\n\t/**\n\t* Whether to return the tool's output directly.\n\t*\n\t* Setting this to true means that after the tool is called,\n\t* an agent should stop looping.\n\t*/\n\treturnDirect = false;\n\tverboseParsingErrors = false;\n\tget lc_namespace() {\n\t\treturn [\"langchain\", \"tools\"];\n\t}\n\t/**\n\t* The tool response format.\n\t*\n\t* If \"content\" then the output of the tool is interpreted as the contents of a\n\t* ToolMessage. If \"content_and_artifact\" then the output is expected to be a\n\t* two-tuple corresponding to the (content, artifact) of a ToolMessage.\n\t*\n\t* @default \"content\"\n\t*/\n\tresponseFormat = \"content\";\n\t/**\n\t* Default config object for the tool runnable.\n\t*/\n\tdefaultConfig;\n\tconstructor(fields) {\n\t\tsuper(fields ?? {});\n\t\tthis.verboseParsingErrors = fields?.verboseParsingErrors ?? this.verboseParsingErrors;\n\t\tthis.responseFormat = fields?.responseFormat ?? this.responseFormat;\n\t\tthis.defaultConfig = fields?.defaultConfig ?? this.defaultConfig;\n\t\tthis.metadata = fields?.metadata ?? this.metadata;\n\t\tthis.extras = fields?.extras ?? this.extras;\n\t}\n\t/**\n\t* Invokes the tool with the provided input and configuration.\n\t* @param input The input for the tool.\n\t* @param config Optional configuration for the tool.\n\t* @returns A Promise that resolves with the tool's output.\n\t*/\n\tasync invoke(input, config) {\n\t\tlet toolInput;\n\t\tlet enrichedConfig = ensureConfig(mergeConfigs(this.defaultConfig, config));\n\t\tif (_isToolCall(input)) {\n\t\t\ttoolInput = input.args;\n\t\t\tenrichedConfig = {\n\t\t\t\t...enrichedConfig,\n\t\t\t\ttoolCall: input\n\t\t\t};\n\t\t} else toolInput = input;\n\t\treturn this.call(toolInput, enrichedConfig);\n\t}\n\t/**\n\t* @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n\t*\n\t* Calls the tool with the provided argument, configuration, and tags. It\n\t* parses the input according to the schema, handles any errors, and\n\t* manages callbacks.\n\t* @param arg The input argument for the tool.\n\t* @param configArg Optional configuration or callbacks for the tool.\n\t* @param tags Optional tags for the tool.\n\t* @returns A Promise that resolves with a string.\n\t*/\n\tasync call(arg, configArg, tags) {\n\t\tconst inputForValidation = _isToolCall(arg) ? arg.args : arg;\n\t\tlet parsed;\n\t\tif (isInteropZodSchema(this.schema)) try {\n\t\t\tparsed = await interopParseAsync(this.schema, inputForValidation);\n\t\t} catch (e) {\n\t\t\tlet message = `Received tool input did not match expected schema`;\n\t\t\tif (this.verboseParsingErrors) message = `${message}\\nDetails: ${e.message}`;\n\t\t\tif (isInteropZodError(e)) message = `${message}\\n\\n${z$1.prettifyError(e)}`;\n\t\t\tthrow new ToolInputParsingException(message, JSON.stringify(arg));\n\t\t}\n\t\telse {\n\t\t\tconst result = validate(inputForValidation, this.schema);\n\t\t\tif (!result.valid) {\n\t\t\t\tlet message = `Received tool input did not match expected schema`;\n\t\t\t\tif (this.verboseParsingErrors) message = `${message}\\nDetails: ${result.errors.map((e) => `${e.keywordLocation}: ${e.error}`).join(\"\\n\")}`;\n\t\t\t\tthrow new ToolInputParsingException(message, JSON.stringify(arg));\n\t\t\t}\n\t\t\tparsed = inputForValidation;\n\t\t}\n\t\tconst config = parseCallbackConfigArg(configArg);\n\t\tconst callbackManager_ = CallbackManager.configure(config.callbacks, this.callbacks, config.tags || tags, this.tags, config.metadata, this.metadata, { verbose: this.verbose });\n\t\tlet toolCallId;\n\t\tif (_isToolCall(arg)) toolCallId = arg.id;\n\t\tif (!toolCallId && _configHasToolCallId(config)) toolCallId = config.toolCall.id;\n\t\tconst runManager = await callbackManager_?.handleToolStart(this.toJSON(), typeof arg === \"string\" ? arg : JSON.stringify(arg), config.runId, void 0, void 0, void 0, config.runName, toolCallId);\n\t\tdelete config.runId;\n\t\tlet result;\n\t\ttry {\n\t\t\tconst raw = await this._call(parsed, runManager, config);\n\t\t\tresult = isAsyncGenerator(raw) ? await consumeAsyncGenerator(raw, async (chunk) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait runManager?.handleToolEvent(chunk);\n\t\t\t\t} catch (streamError) {\n\t\t\t\t\tawait runManager?.handleToolError(streamError);\n\t\t\t\t}\n\t\t\t}) : raw;\n\t\t} catch (e) {\n\t\t\tawait runManager?.handleToolError(e);\n\t\t\tthrow e;\n\t\t}\n\t\tlet content;\n\t\tlet artifact;\n\t\tif (this.responseFormat === \"content_and_artifact\") if (Array.isArray(result) && result.length === 2) [content, artifact] = result;\n\t\telse throw new Error(`Tool response format is \"content_and_artifact\" but the output was not a two-tuple.\\nResult: ${JSON.stringify(result)}`);\n\t\telse content = result;\n\t\tconst formattedOutput = _formatToolOutput({\n\t\t\tcontent,\n\t\t\tartifact,\n\t\t\ttoolCallId,\n\t\t\tname: this.name,\n\t\t\tmetadata: this.metadata\n\t\t});\n\t\tawait runManager?.handleToolEnd(formattedOutput);\n\t\treturn formattedOutput;\n\t}\n};\n/**\n* Base class for Tools that accept input as a string.\n*/\nvar Tool = class extends StructuredTool {\n\tschema = z.object({ input: z.string().optional() }).transform((obj) => obj.input);\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t}\n\t/**\n\t* @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n\t*\n\t* Calls the tool with the provided argument and callbacks. It handles\n\t* string inputs specifically.\n\t* @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.\n\t* @param callbacks Optional callbacks for the tool.\n\t* @returns A Promise that resolves with a string.\n\t*/\n\tcall(arg, callbacks) {\n\t\tconst structuredArg = typeof arg === \"string\" || arg == null ? { input: arg } : arg;\n\t\treturn super.call(structuredArg, callbacks);\n\t}\n};\n/**\n* A tool that can be created dynamically from a function, name, and description.\n*/\nvar DynamicTool = class extends Tool {\n\tstatic lc_name() {\n\t\treturn \"DynamicTool\";\n\t}\n\tname;\n\tdescription;\n\tfunc;\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t\tthis.name = fields.name;\n\t\tthis.description = fields.description;\n\t\tthis.func = fields.func;\n\t\tthis.returnDirect = fields.returnDirect ?? this.returnDirect;\n\t}\n\t/**\n\t* @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n\t*/\n\tasync call(arg, configArg) {\n\t\tconst config = parseCallbackConfigArg(configArg);\n\t\tif (config.runName === void 0) config.runName = this.name;\n\t\treturn super.call(arg, config);\n\t}\n\t/** @ignore */\n\t_call(input, runManager, parentConfig) {\n\t\treturn this.func(input, runManager, parentConfig);\n\t}\n};\n/**\n* A tool that can be created dynamically from a function, name, and\n* description, designed to work with structured data. It extends the\n* StructuredTool class and overrides the _call method to execute the\n* provided function when the tool is called.\n*\n* Schema can be passed as Zod or JSON schema. The tool will not validate\n* input if JSON schema is passed.\n*\n* @template SchemaT The input schema type for the tool (Zod schema or JSON schema). Defaults to `ToolInputSchemaBase`.\n* @template SchemaOutputT The output type derived from the schema after parsing/validation. Defaults to `ToolInputSchemaOutputType<SchemaT>`.\n* @template SchemaInputT The input type derived from the schema before parsing. Defaults to `ToolInputSchemaInputType<SchemaT>`.\n* @template ToolOutputT The return type of the tool's function. Defaults to `ToolOutputType`.\n* @template NameT The literal type of the tool name (for discriminated union support). Defaults to `string`.\n*/\nvar DynamicStructuredTool = class extends StructuredTool {\n\tstatic lc_name() {\n\t\treturn \"DynamicStructuredTool\";\n\t}\n\tdescription;\n\tfunc;\n\tschema;\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t\tthis.name = fields.name;\n\t\tthis.description = fields.description;\n\t\tthis.func = fields.func;\n\t\tthis.returnDirect = fields.returnDirect ?? this.returnDirect;\n\t\tthis.schema = fields.schema;\n\t}\n\t/**\n\t* @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n\t*/\n\tasync call(arg, configArg, tags) {\n\t\tconst config = parseCallbackConfigArg(configArg);\n\t\tif (config.runName === void 0) config.runName = this.name;\n\t\treturn super.call(arg, config, tags);\n\t}\n\t_call(arg, runManager, parentConfig) {\n\t\treturn this.func(arg, runManager, parentConfig);\n\t}\n};\n/**\n* Abstract base class for toolkits in LangChain. Toolkits are collections\n* of tools that agents can use. Subclasses must implement the `tools`\n* property to provide the specific tools for the toolkit.\n*/\nvar BaseToolkit = class {\n\tgetTools() {\n\t\treturn this.tools;\n\t}\n};\nfunction tool(func, fields) {\n\tconst isSimpleStringSchema = isSimpleStringZodSchema(fields.schema);\n\tconst isStringJSONSchema = validatesOnlyStrings(fields.schema);\n\tif (!fields.schema || isSimpleStringSchema || isStringJSONSchema) return new DynamicTool({\n\t\t...fields,\n\t\tdescription: fields.description ?? fields.schema?.description ?? `${fields.name} tool`,\n\t\tfunc: async (input, runManager, config) => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst childConfig = patchConfig(config, { callbacks: runManager?.getChild() });\n\t\t\t\tAsyncLocalStorageProviderSingleton.runWithConfig(pickRunnableConfigKeys(childConfig), async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresolve(func(input, childConfig));\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\treject(e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n\tconst schema = fields.schema;\n\tconst description = fields.description ?? fields.schema.description ?? `${fields.name} tool`;\n\treturn new DynamicStructuredTool({\n\t\t...fields,\n\t\tdescription,\n\t\tschema,\n\t\tfunc: async (input, runManager, config) => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tlet listener;\n\t\t\t\tconst cleanup = () => {\n\t\t\t\t\tif (config?.signal && listener) config.signal.removeEventListener(\"abort\", listener);\n\t\t\t\t};\n\t\t\t\tif (config?.signal) {\n\t\t\t\t\tlistener = () => {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(getAbortSignalError(config.signal));\n\t\t\t\t\t};\n\t\t\t\t\tconfig.signal.addEventListener(\"abort\", listener, { once: true });\n\t\t\t\t}\n\t\t\t\tconst childConfig = patchConfig(config, { callbacks: runManager?.getChild() });\n\t\t\t\tAsyncLocalStorageProviderSingleton.runWithConfig(pickRunnableConfigKeys(childConfig), async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await func(input, childConfig);\n\t\t\t\t\t\tif (isAsyncGenerator(result)) {\n\t\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t* If the signal is aborted, we don't want to resolve the promise\n\t\t\t\t\t\t* as the promise is already rejected.\n\t\t\t\t\t\t*/\n\t\t\t\t\t\tif (config?.signal?.aborted) {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n}\nfunction _formatToolOutput(params) {\n\tconst { content, artifact, toolCallId, metadata } = params;\n\tif (toolCallId && !isDirectToolOutput(content)) if (typeof content === \"string\" || Array.isArray(content) && content.every((item) => typeof item === \"object\")) return new ToolMessage({\n\t\tstatus: \"success\",\n\t\tcontent,\n\t\tartifact,\n\t\ttool_call_id: toolCallId,\n\t\tname: params.name,\n\t\tmetadata\n\t});\n\telse return new ToolMessage({\n\t\tstatus: \"success\",\n\t\tcontent: _stringify(content),\n\t\tartifact,\n\t\ttool_call_id: toolCallId,\n\t\tname: params.name,\n\t\tmetadata\n\t});\n\telse return content;\n}\nfunction _stringify(content) {\n\ttry {\n\t\treturn JSON.stringify(content) ?? \"\";\n\t} catch (_noOp) {\n\t\treturn `${content}`;\n\t}\n}\n//#endregion\nexport { BaseToolkit, DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolInputParsingException, isLangChainTool, isRunnableToolLike, isStructuredTool, isStructuredToolParams, tool, tools_exports };\n\n//# sourceMappingURL=index.js.map","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 = require(\"events\");","import { NextRequest, NextResponse } from \"next/server\";\nimport { z } from \"zod\";\nimport { registeredTools, registeredCategory, type BuiltinCategory } from \"@/lib/tools/registry\";\nimport {\n disabledCategories,\n setCategoryEnabled,\n} from \"@/lib/stores/builtin-tools\";\nimport { errorResponse, validateBody } from \"@/lib/api/responses\";\n\n// All built-in categories the registry knows about, with their tool count\n// and current enabled state. Default-enabled (no row = on). Used by the\n// Tools tab to render per-category on/off toggles.\n\nconst ALL_VALID_CATEGORIES = new Set<string>([\n \"Memory\", \"Documents\", \"Files\", \"Shell\", \"Web\", \"Images\", \"Voice\",\n \"Schedule\", \"Atlassian\", \"JiraAlign\", \"GitHub\", \"Mail\", \"Calendar\", \"Config\",\n]);\n\ninterface CategoryRow {\n category: BuiltinCategory;\n enabled: boolean;\n toolCount: number;\n toolNames: string[];\n}\n\nfunction listCategories(): CategoryRow[] {\n const disabled = disabledCategories();\n const byCat = new Map<BuiltinCategory, string[]>();\n for (const t of registeredTools()) {\n const cat = registeredCategory(t.name);\n if (!cat) continue;\n const arr = byCat.get(cat) ?? [];\n arr.push(t.name);\n byCat.set(cat, arr);\n }\n const rows: CategoryRow[] = [];\n for (const [cat, names] of byCat) {\n rows.push({\n category: cat,\n enabled: !disabled.has(cat),\n toolCount: names.length,\n toolNames: names.sort(),\n });\n }\n rows.sort((a, b) => a.category.localeCompare(b.category));\n return rows;\n}\n\nexport async function GET() {\n return NextResponse.json(listCategories());\n}\n\nconst PatchSchema = z.object({\n category: z.string(),\n enabled: z.boolean(),\n});\n\nexport async function PATCH(req: NextRequest) {\n const parsed = await validateBody(req, PatchSchema);\n if (parsed instanceof NextResponse) return parsed;\n const { category, enabled } = parsed;\n if (!ALL_VALID_CATEGORIES.has(category)) {\n return errorResponse(`unknown category: ${category}`);\n }\n setCategoryEnabled(category as BuiltinCategory, enabled);\n return NextResponse.json({ category, enabled });\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/builtin-tools/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/builtin-tools/route\",\n pathname: \"/api/v1/builtin-tools\",\n filename: \"route\",\n bundlePath: \"app/api/v1/builtin-tools/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/builtin-tools/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/builtin-tools/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/builtin-tools/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"],"names":["z","tool","DEFAULT_DEADLINE_MS","DEADLINE_DESCRIPTION","wrapWithWallclock","t","schema","extendedSchema","ZodObject","extend","deadline_ms","number","int","positive","optional","describe","wrappedFunc","args","config","deadlineMs","readDeadlineMs","innerArgs","stripDeadline","timer","timeoutPromise","Promise","resolve","setTimeout","JSON","stringify","ok","error_code","message","name","unref","work","invoke","race","clearTimeout","rebuilt","description","v","Number","isFinite","_ignore","rest","__DEFAULT_DEADLINE_MS","CATEGORY_GROUPS","Memory","Documents","Files","Shell","Web","Images","Voice","Schedule","Config","Mail","Calendar","Agent","Atlassian","JiraAlign","GitHub","REGISTRY","Map","registerTools","category","capability","tools","group","wrapped","has","Error","w","set","push","registeredTools","Array","from","values","e","registeredNames","Set","keys","registeredCategory","get","registeredCapability","registeredGroup","_resetRegistry","clear","NextResponse","errorResponse","status","json","error","notFoundResponse","createdResponse","data","cachedJson","maxAgeSeconds","headers","validateBody","req","raw","parsed","safeParse","success","issues","getDb","now","Date","toISOString","isCategoryEnabled","row","prepare","enabled","disabledCategories","rows","all","map","r","listCategoryStates","updated_at","setCategoryEnabled","run","ALL_VALID_CATEGORIES","listCategories","disabled","byCat","cat","arr","names","toolCount","length","toolNames","sort","a","b","localeCompare","GET","PatchSchema","object","string","boolean","PATCH"],"sourceRoot":"","ignoreList":[0,3,5,12,18,26,27,36]}
1
+ {"version":3,"file":"../app/api/v1/builtin-tools/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,4EAAY,CAAC,4EAAY;AAChD,MAAM,gEAAW;AACjB;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,gEAAW;AACxC;AACA,MAAM,kFAAkB;AACxB,kBAAkB,iFAAiB;AACnC,IAAI;AACJ;AACA,+CAA+C,QAAQ,aAAa,UAAU;AAC9E,OAAO,iFAAiB,kBAAkB,QAAQ,MAAM,4DAAiB,IAAI;AAC7E,aAAa,0EAAyB;AACtC;AACA;AACA,kBAAkB,0EAAQ;AAC1B;AACA;AACA,gDAAgD,QAAQ,aAAa,4BAA4B,kBAAkB,IAAI,QAAQ,cAAc;AAC7I,cAAc,0EAAyB;AACvC;AACA;AACA;AACA,iBAAiB,uFAAsB;AACvC,2BAA2B,4EAAe,+GAA+G,uBAAuB;AAChL;AACA,MAAM,gEAAW;AACjB,qBAAqB,yEAAoB;AACzC;AACA;AACA;AACA;AACA;AACA,YAAY,8EAAgB,cAAc,mFAAqB;AAC/D;AACA;AACA,MAAM;AACN;AACA;AACA,IAAI;AACJ,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA,sHAAsH,uBAAuB;AAC7I;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,qDAAQ,GAAG,OAAO,qDAAQ,eAAe;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mEAAmE,aAAa;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,uFAAsB;AACvC;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,uFAAsB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,uFAAuB;AACrD,4BAA4B,qFAAoB;AAChD;AACA;AACA,sEAAsE,aAAa;AACnF;AACA;AACA,wBAAwB,2EAAW,WAAW,mCAAmC;AACjF,IAAI,iHAAkC,eAAe,sFAAsB;AAC3E;AACA;AACA,OAAO;AACP;AACA;AACA,KAAK;AACL,IAAI;AACJ;AACA,EAAE;AACF;AACA,2EAA2E,aAAa;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,+EAAmB;AAChC;AACA,yDAAyD,YAAY;AACrE;AACA,wBAAwB,2EAAW,WAAW,mCAAmC;AACjF,IAAI,iHAAkC,eAAe,sFAAsB;AAC3E;AACA;AACA,UAAU,8EAAgB;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,KAAK;AACL,IAAI;AACJ;AACA,EAAE;AACF;AACA;AACA,SAAS,0CAA0C;AACnD,oBAAoB,+EAAkB,sIAAsI,oEAAW;AACvL;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF,iBAAiB,oEAAW;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,YAAY,QAAQ;AACpB;AACA;AACA;AACgN;;AAEhN;;;;;;;ACvWA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;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BAAkBd,mBAAYA,EAAE,OAAOc;IAC3C,MAAM,EAAEtC,QAAQ,EAAEiD,OAAO,EAAE,GAAGX;IAC9B,IAAI,CAACqB,qBAAqBtD,GAAG,CAACL,WAAW;QACvC,OAAOyB,mCAAaA,CAAC,CAAC,kBAAkB,EAAEzB,UAAU;IACtD;IACAyD,4CAAkBA,CAACzD,UAA6BiD;IAChD,OAAOzB,mBAAYA,CAACG,IAAI,CAAC;QAAE3B;QAAUiD;IAAQ;AAC/C;;;AClE+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AAC4B;AAC9F;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","sources":["webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/router/utils/app-paths\"","webpack://@circuitwall/jarela/external node-commonjs \"node:process\"","webpack://@circuitwall/jarela/external commonjs2 \"url\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/after-task-async-storage.external.js\"","webpack://@circuitwall/jarela/external commonjs \"undici\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-page.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:async_hooks\"","webpack://@circuitwall/jarela/./lib/tools/wallclock.ts","webpack://@circuitwall/jarela/./lib/tools/registry.ts","webpack://@circuitwall/jarela/external commonjs2 \"stream\"","webpack://@circuitwall/jarela/external commonjs2 \"util\"","webpack://@circuitwall/jarela/external commonjs2 \"fs\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:child_process\"","webpack://@circuitwall/jarela/external commonjs2 \"path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:http\"","webpack://@circuitwall/jarela/./lib/api/responses.ts","webpack://@circuitwall/jarela/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/./lib/stores/builtin-tools.ts","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/./node_modules/@langchain/core/dist/tools/index.js","webpack://@circuitwall/jarela/external node-commonjs \"node:fs\"","webpack://@circuitwall/jarela/external node-commonjs \"node:url\"","webpack://@circuitwall/jarela/external node-commonjs \"node:worker_threads\"","webpack://@circuitwall/jarela/external node-commonjs \"node:path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"buffer\"","webpack://@circuitwall/jarela/external node-commonjs \"node:sqlite\"","webpack://@circuitwall/jarela/external commonjs2 \"http\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/shared/lib/no-fallback-error.external\"","webpack://@circuitwall/jarela/external commonjs2 \"events\"","webpack://@circuitwall/jarela/./app/api/v1/builtin-tools/route.ts","webpack://@circuitwall/jarela/?37ff"],"sourcesContent":["module.exports = require(\"next/dist/shared/lib/router/utils/app-paths\");","module.exports = require(\"node:process\");","module.exports = require(\"url\");","module.exports = require(\"next/dist/server/app-render/after-task-async-storage.external.js\");","module.exports = require(\"undici\");","module.exports = require(\"next/dist/compiled/next-server/app-page.runtime.prod.js\");","module.exports = require(\"node:async_hooks\");","// Per-call wall-clock budgets for tools.\n//\n// Every registered tool is wrapped with a Promise.race against a timer\n// the LLM controls via an injected `deadline_ms` schema field. When the\n// timer fires first, the wrapped tool returns a structured timeout result\n// to the agent instead of throwing — the turn continues, the agent gets a\n// tool message saying \"timed out\", and can recover (retry differently,\n// split the work, or move on).\n//\n// Why \"agent self-set\" instead of a global env knob: the right deadline\n// is hugely context-dependent (a 5s budget for a memory_read is right;\n// the same budget for `npm install` is absurd). The model knows what\n// it's calling, so the model picks. The `deadline_ms` field on every\n// tool's schema makes that picker explicit and self-documenting.\n//\n// Caveat: the underlying tool's promise is abandoned, not aborted. A\n// network call or subprocess started by the tool keeps running until it\n// settles into the void. Tools that own a long-lived resource (fetch,\n// exec) should use the `deadline_ms` value themselves to drive their own\n// abort signal — the wallclock wrapper is the backstop, not the only\n// mechanism.\n\nimport { z } from \"zod\";\nimport { tool, type StructuredToolInterface } from \"@langchain/core/tools\";\n\nconst DEFAULT_DEADLINE_MS = 120_000;\n\nconst DEADLINE_DESCRIPTION =\n \"Optional wall-clock budget for this tool call in milliseconds (default 120000). \" +\n \"When the budget is exceeded the call returns a structured timeout result \" +\n \"and the turn continues so you can recover — pick a value that matches \" +\n \"the expected duration (5000-15000 for fast local ops, 30000-90000 for \" +\n \"network/web calls, larger for shell commands that may build or install).\";\n\ninterface WallclockedFunc {\n (args: Record<string, unknown>, config?: unknown): Promise<unknown>;\n}\n\nexport function wrapWithWallclock<T extends StructuredToolInterface>(t: T): T {\n // Only zod-object schemas can be extended with `deadline_ms`. Other\n // schema shapes (raw JSON Schema, ZodString) pass through unchanged.\n // Those tools still get the wallclock race using the default budget.\n const schema = (t as unknown as { schema: unknown }).schema;\n const extendedSchema = schema instanceof z.ZodObject\n ? schema.extend({ deadline_ms: z.number().int().positive().optional().describe(DEADLINE_DESCRIPTION) })\n : null;\n\n const wrappedFunc: WallclockedFunc = async (args, config) => {\n const deadlineMs = readDeadlineMs(args) ?? DEFAULT_DEADLINE_MS;\n const innerArgs = stripDeadline(args);\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<string>((resolve) => {\n timer = setTimeout(() => {\n resolve(JSON.stringify({\n ok: false,\n error_code: \"tool_timeout\",\n message:\n `Tool \"${t.name}\" exceeded its wall-clock budget of ${deadlineMs}ms. ` +\n `The call was abandoned; the underlying operation may still be running in the background. ` +\n `Recover by trying a different approach, splitting the work, or moving on — do not retry the same call with the same arguments.`,\n deadline_ms: deadlineMs,\n }));\n }, deadlineMs);\n // Don't keep the event loop alive purely for a timeout race.\n (timer as unknown as { unref?: () => void }).unref?.();\n });\n\n try {\n // Cast: invoke accepts a typed input matching the original schema,\n // but the wrapper is generic over all tools.\n const work = (t as unknown as { invoke: (a: unknown, c?: unknown) => Promise<unknown> }).invoke(innerArgs, config);\n return await Promise.race([work, timeoutPromise]);\n } finally {\n if (timer) clearTimeout(timer);\n }\n };\n\n // Rebuild via the public `tool()` factory so we don't depend on\n // internal field shapes of the StructuredTool class. The new tool\n // keeps the original's name and description, swaps in the extended\n // schema, and routes invocation through wrappedFunc.\n const rebuilt = tool(\n wrappedFunc as never,\n {\n name: t.name,\n description: t.description ?? \"\",\n schema: (extendedSchema ?? schema) as never,\n } as never,\n );\n return rebuilt as unknown as T;\n}\n\nfunction readDeadlineMs(args: Record<string, unknown> | unknown): number | null {\n if (!args || typeof args !== \"object\") return null;\n const v = (args as Record<string, unknown>).deadline_ms;\n return typeof v === \"number\" && Number.isFinite(v) && v > 0 ? v : null;\n}\n\nfunction stripDeadline(args: Record<string, unknown> | unknown): Record<string, unknown> | unknown {\n if (!args || typeof args !== \"object\") return args;\n const { deadline_ms: _ignore, ...rest } = args as Record<string, unknown>;\n void _ignore;\n return rest;\n}\n\n/** Exposed for the tests. */\nexport const __DEFAULT_DEADLINE_MS = DEFAULT_DEADLINE_MS;\n","/**\n * Tool registry.\n *\n * Each built-in tool module registers its own tools at module load with\n * two orthogonal axes:\n *\n * - category — topical group (\"Memory\", \"Files\", \"Mail\", …) used by\n * the Agent editor sidebar to organise tools for users.\n * - capability — safety class (\"read\" | \"write\" | \"execute\") used by\n * the future per-capability approval gate, UI badges,\n * and the ADR-0037 output validator. See ADR-0038.\n *\n * `lib/tools/index.ts` only needs to side-effect-import the modules\n * (see ./builtins.ts) — there is no central map listing every tool by\n * name. Adding a new built-in tool now requires touching exactly two\n * files: the tool file itself, and an `import \"./<name>\";` line in\n * builtins.ts.\n *\n * External tools (loaded from JARELA_TOOLS_DIR at runtime) use the same\n * category vocabulary but are not stored in this registry — see\n * ./external.ts. MCP tools default to category \"MCP\". Both default to\n * capability \"execute\" until manifest-level overrides land (ADR-0038\n * follow-up).\n *\n * Public surface (per `package.json#exports`): `ToolCategory`,\n * `Capability`, `ToolGroup`, `BuiltinCategory`, `registerTools`.\n * Everything else (`registeredTools` / `registeredNames` /\n * `registeredCategory` / etc.) is `@internal` — used only by the in-tree\n * runtime, not part of the plugin contract.\n */\n\nimport type { StructuredToolInterface } from \"@langchain/core/tools\";\nimport { wrapWithWallclock } from \"./wallclock\";\n\nexport type ToolCategory =\n | \"Memory\" | \"Documents\" | \"Files\" | \"Shell\" | \"Web\" | \"Images\" | \"Voice\"\n | \"Schedule\" | \"Atlassian\" | \"JiraAlign\" | \"GitHub\" | \"Mail\" | \"Calendar\" | \"Config\" | \"Agent\" | \"MCP\";\n\n// Safety class. Orthogonal to ToolCategory. See ADR-0038 for definitions\n// and tie-breakers (network reads vs writes, drafts, etc.).\nexport type Capability = \"read\" | \"write\" | \"execute\";\n\n// Optional parent grouping for the Agent editor sidebar.\nexport type ToolGroup = \"Work\" | null;\n\n// Category → group mapping. \"Work\" collapses corporate-auth tools under\n// one header in the Agent editor; everything else is a top-level category.\nconst CATEGORY_GROUPS: Record<Exclude<ToolCategory, \"MCP\">, ToolGroup> = {\n Memory: null, Documents: null, Files: null, Shell: null, Web: null, Images: null, Voice: null,\n Schedule: null, Config: null, Mail: null, Calendar: null, Agent: null,\n Atlassian: \"Work\", JiraAlign: \"Work\", GitHub: \"Work\",\n};\n\nexport type BuiltinCategory = Exclude<ToolCategory, \"MCP\">;\n\ninterface RegistryEntry {\n tool: StructuredToolInterface;\n category: BuiltinCategory;\n capability: Capability;\n group: ToolGroup;\n}\n\nconst REGISTRY = new Map<string, RegistryEntry>();\n\n/**\n * Register one or more tools under a category and capability. Call this at\n * the bottom of each tool file (after the tools are defined). Files with\n * mixed capabilities make multiple calls — see ADR-0038. Throws on\n * duplicate names — collisions are bugs, not warnings.\n */\nexport function registerTools<T extends StructuredToolInterface>(\n category: BuiltinCategory,\n capability: Capability,\n tools: readonly T[],\n): readonly T[] {\n const group = CATEGORY_GROUPS[category];\n const wrapped: T[] = [];\n for (const t of tools) {\n if (REGISTRY.has(t.name)) {\n throw new Error(`[tools] duplicate built-in tool registration: ${t.name}`);\n }\n // Every built-in tool gets the agent-controlled wall-clock wrap so a\n // single stuck call (network hang, fs on a wedged cloud-sync drive,\n // runaway shell) can't pin the turn — see lib/tools/wallclock.ts.\n const w = wrapWithWallclock(t);\n REGISTRY.set(w.name, { tool: w, category, capability, group });\n wrapped.push(w);\n }\n return wrapped;\n}\n\n/** @internal — all registered built-in tools, in registration order. */\nexport function registeredTools(): StructuredToolInterface[] {\n return Array.from(REGISTRY.values(), (e) => e.tool);\n}\n\n/** @internal — names of all registered built-in tools, used for collision checks. */\nexport function registeredNames(): ReadonlySet<string> {\n return new Set(REGISTRY.keys());\n}\n\n/** @internal */\nexport function registeredCategory(name: string): BuiltinCategory | undefined {\n return REGISTRY.get(name)?.category;\n}\n\n/** @internal */\nexport function registeredCapability(name: string): Capability | undefined {\n return REGISTRY.get(name)?.capability;\n}\n\n/** @internal */\nexport function registeredGroup(name: string): ToolGroup | undefined {\n return REGISTRY.get(name)?.group;\n}\n\n/** @internal — test-only: clear the registry between cases. */\nexport function _resetRegistry(): void {\n REGISTRY.clear();\n}\n","module.exports = require(\"stream\");","module.exports = require(\"util\");","module.exports = require(\"fs\");","module.exports = require(\"next/dist/server/app-render/work-async-storage.external.js\");","module.exports = require(\"node:child_process\");","module.exports = require(\"path\");","module.exports = require(\"node:http\");","// Shared HTTP response builders for app/api/v1/** route handlers.\n//\n// Goal: every error/success payload across the v1 surface has the same\n// shape. Before this lived inline, response bodies drifted —\n// `{error: \"x\"}` vs `{message: \"x\"}`, 400 vs 422 for the same condition,\n// some routes returned Zod's raw issue array, others stringified it.\n\nimport { NextResponse } from \"next/server\";\nimport type { z } from \"zod\";\nimport type { NextRequest } from \"next/server\";\n\nexport function errorResponse(message: string, status: number = 400): NextResponse {\n return NextResponse.json({ error: message }, { status });\n}\n\nexport function notFoundResponse(message: string = \"Not found\"): NextResponse {\n return errorResponse(message, 404);\n}\n\nexport function createdResponse<T>(data: T): NextResponse {\n return NextResponse.json(data, { status: 201 });\n}\n\n// Wrap a 200 JSON response with a private Cache-Control header. Use on safe\n// GET endpoints that serve user-scoped data the client refetches often (panel\n// mounts, navigation back/forward) but mutates rarely. The TTL is short\n// enough that explicit mutations — which patch the client-side ApiClient\n// cache in place — stay observably consistent without an extra roundtrip.\nexport function cachedJson<T>(data: T, maxAgeSeconds: number): NextResponse {\n return NextResponse.json(data, {\n headers: {\n \"Cache-Control\": `private, max-age=${maxAgeSeconds}`,\n },\n });\n}\n\n// Validate a JSON request body against a zod schema.\n// Returns either the parsed data or a 400 NextResponse explaining the issue.\n// Caller pattern:\n// const parsed = await validateBody(req, Schema);\n// if (parsed instanceof NextResponse) return parsed;\n// // use parsed.field\nexport async function validateBody<S extends z.ZodTypeAny>(\n req: NextRequest,\n schema: S,\n): Promise<z.infer<S> | NextResponse> {\n let raw: unknown;\n try {\n raw = await req.json();\n } catch {\n return errorResponse(\"Request body must be valid JSON\", 400);\n }\n const parsed = schema.safeParse(raw);\n if (!parsed.success) {\n return errorResponse(parsed.error.issues[0]?.message ?? \"invalid body\", 400);\n }\n return parsed.data;\n}\n","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\");","// Built-in tool category toggles.\n//\n// A category is \"enabled\" unless an explicit row in `builtin_tool_categories`\n// says otherwise. Default-enabled semantics mean upgrading installs keep\n// every category working with zero migration work.\n//\n// Disabled categories are filtered at three layers:\n// - GET /api/v1/tools (so the agent editor never offers them as permissions)\n// - getAllTools / getAllToolsAsync (so the agent runtime can't see them)\n// - executeTool (defense in depth, blocks stale agent configs)\n\nimport { getDb } from \"@/lib/db\";\nimport type { BuiltinCategory } from \"@/lib/tools/registry\";\n\ninterface Row {\n category: string;\n enabled: number;\n updated_at: string;\n}\n\nconst now = () => new Date().toISOString();\n\nexport function isCategoryEnabled(category: BuiltinCategory): boolean {\n const row = getDb()\n .prepare(\"SELECT enabled FROM builtin_tool_categories WHERE category=?\")\n .get(category) as { enabled: number } | undefined;\n return row ? row.enabled === 1 : true;\n}\n\nexport function disabledCategories(): Set<BuiltinCategory> {\n const rows = getDb()\n .prepare(\"SELECT category FROM builtin_tool_categories WHERE enabled=0\")\n .all() as unknown as Array<{ category: string }>;\n return new Set(rows.map((r) => r.category as BuiltinCategory));\n}\n\nexport function listCategoryStates(): Array<{ category: string; enabled: boolean; updated_at: string | null }> {\n const rows = getDb()\n .prepare(\"SELECT category, enabled, updated_at FROM builtin_tool_categories\")\n .all() as unknown as Row[];\n return rows.map((r) => ({\n category: r.category,\n enabled: r.enabled === 1,\n updated_at: r.updated_at,\n }));\n}\n\nexport function setCategoryEnabled(category: BuiltinCategory, enabled: boolean): void {\n getDb()\n .prepare(\n `INSERT INTO builtin_tool_categories (category, enabled, updated_at)\n VALUES (?, ?, ?)\n ON CONFLICT(category) DO UPDATE SET enabled=excluded.enabled, updated_at=excluded.updated_at`,\n )\n .run(category, enabled ? 1 : 0, now());\n}\n","module.exports = require(\"node:stream\");","module.exports = require(\"node:util\");","module.exports = require(\"next/dist/server/app-render/work-unit-async-storage.external.js\");","import { __exportAll } from \"../_virtual/_rolldown/runtime.js\";\nimport { ToolInputParsingException, _configHasToolCallId, _isToolCall } from \"./utils.js\";\nimport { ToolMessage, isDirectToolOutput } from \"../messages/tool.js\";\nimport { CallbackManager, parseCallbackConfigArg } from \"../callbacks/manager.js\";\nimport { AsyncLocalStorageProviderSingleton } from \"../singletons/async_local_storage/index.js\";\nimport \"../singletons/index.js\";\nimport { ensureConfig, mergeConfigs, patchConfig, pickRunnableConfigKeys } from \"../runnables/config.js\";\nimport { getAbortSignalError } from \"../utils/signal.js\";\nimport { interopParseAsync, isInteropZodError, isInteropZodSchema, isSimpleStringZodSchema } from \"../utils/types/zod.js\";\nimport { validatesOnlyStrings } from \"../utils/json_schema.js\";\nimport { consumeAsyncGenerator, isAsyncGenerator } from \"../runnables/iter.js\";\nimport { BaseLangChain } from \"../language_models/base.js\";\nimport { isLangChainTool, isRunnableToolLike, isStructuredTool, isStructuredToolParams } from \"./types.js\";\nimport { z } from \"zod/v3\";\nimport { validate } from \"@cfworker/json-schema\";\nimport { z as z$1 } from \"zod/v4\";\n//#region src/tools/index.ts\nvar tools_exports = /* @__PURE__ */ __exportAll({\n\tBaseToolkit: () => BaseToolkit,\n\tDynamicStructuredTool: () => DynamicStructuredTool,\n\tDynamicTool: () => DynamicTool,\n\tStructuredTool: () => StructuredTool,\n\tTool: () => Tool,\n\tToolInputParsingException: () => ToolInputParsingException,\n\tisLangChainTool: () => isLangChainTool,\n\tisRunnableToolLike: () => isRunnableToolLike,\n\tisStructuredTool: () => isStructuredTool,\n\tisStructuredToolParams: () => isStructuredToolParams,\n\ttool: () => tool\n});\n/**\n* Base class for Tools that accept input of any shape defined by a Zod schema.\n*/\nvar StructuredTool = class extends BaseLangChain {\n\t/**\n\t* Optional provider-specific extra fields for the tool.\n\t*\n\t* This is used to pass provider-specific configuration that doesn't fit into\n\t* standard tool fields.\n\t*/\n\textras;\n\t/**\n\t* Whether to return the tool's output directly.\n\t*\n\t* Setting this to true means that after the tool is called,\n\t* an agent should stop looping.\n\t*/\n\treturnDirect = false;\n\tverboseParsingErrors = false;\n\tget lc_namespace() {\n\t\treturn [\"langchain\", \"tools\"];\n\t}\n\t/**\n\t* The tool response format.\n\t*\n\t* If \"content\" then the output of the tool is interpreted as the contents of a\n\t* ToolMessage. If \"content_and_artifact\" then the output is expected to be a\n\t* two-tuple corresponding to the (content, artifact) of a ToolMessage.\n\t*\n\t* @default \"content\"\n\t*/\n\tresponseFormat = \"content\";\n\t/**\n\t* Default config object for the tool runnable.\n\t*/\n\tdefaultConfig;\n\tconstructor(fields) {\n\t\tsuper(fields ?? {});\n\t\tthis.verboseParsingErrors = fields?.verboseParsingErrors ?? this.verboseParsingErrors;\n\t\tthis.responseFormat = fields?.responseFormat ?? this.responseFormat;\n\t\tthis.defaultConfig = fields?.defaultConfig ?? this.defaultConfig;\n\t\tthis.metadata = fields?.metadata ?? this.metadata;\n\t\tthis.extras = fields?.extras ?? this.extras;\n\t}\n\t/**\n\t* Invokes the tool with the provided input and configuration.\n\t* @param input The input for the tool.\n\t* @param config Optional configuration for the tool.\n\t* @returns A Promise that resolves with the tool's output.\n\t*/\n\tasync invoke(input, config) {\n\t\tlet toolInput;\n\t\tlet enrichedConfig = ensureConfig(mergeConfigs(this.defaultConfig, config));\n\t\tif (_isToolCall(input)) {\n\t\t\ttoolInput = input.args;\n\t\t\tenrichedConfig = {\n\t\t\t\t...enrichedConfig,\n\t\t\t\ttoolCall: input\n\t\t\t};\n\t\t} else toolInput = input;\n\t\treturn this.call(toolInput, enrichedConfig);\n\t}\n\t/**\n\t* @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n\t*\n\t* Calls the tool with the provided argument, configuration, and tags. It\n\t* parses the input according to the schema, handles any errors, and\n\t* manages callbacks.\n\t* @param arg The input argument for the tool.\n\t* @param configArg Optional configuration or callbacks for the tool.\n\t* @param tags Optional tags for the tool.\n\t* @returns A Promise that resolves with a string.\n\t*/\n\tasync call(arg, configArg, tags) {\n\t\tconst inputForValidation = _isToolCall(arg) ? arg.args : arg;\n\t\tlet parsed;\n\t\tif (isInteropZodSchema(this.schema)) try {\n\t\t\tparsed = await interopParseAsync(this.schema, inputForValidation);\n\t\t} catch (e) {\n\t\t\tlet message = `Received tool input did not match expected schema`;\n\t\t\tif (this.verboseParsingErrors) message = `${message}\\nDetails: ${e.message}`;\n\t\t\tif (isInteropZodError(e)) message = `${message}\\n\\n${z$1.prettifyError(e)}`;\n\t\t\tthrow new ToolInputParsingException(message, JSON.stringify(arg));\n\t\t}\n\t\telse {\n\t\t\tconst result = validate(inputForValidation, this.schema);\n\t\t\tif (!result.valid) {\n\t\t\t\tlet message = `Received tool input did not match expected schema`;\n\t\t\t\tif (this.verboseParsingErrors) message = `${message}\\nDetails: ${result.errors.map((e) => `${e.keywordLocation}: ${e.error}`).join(\"\\n\")}`;\n\t\t\t\tthrow new ToolInputParsingException(message, JSON.stringify(arg));\n\t\t\t}\n\t\t\tparsed = inputForValidation;\n\t\t}\n\t\tconst config = parseCallbackConfigArg(configArg);\n\t\tconst callbackManager_ = CallbackManager.configure(config.callbacks, this.callbacks, config.tags || tags, this.tags, config.metadata, this.metadata, { verbose: this.verbose });\n\t\tlet toolCallId;\n\t\tif (_isToolCall(arg)) toolCallId = arg.id;\n\t\tif (!toolCallId && _configHasToolCallId(config)) toolCallId = config.toolCall.id;\n\t\tconst runManager = await callbackManager_?.handleToolStart(this.toJSON(), typeof arg === \"string\" ? arg : JSON.stringify(arg), config.runId, void 0, void 0, void 0, config.runName, toolCallId);\n\t\tdelete config.runId;\n\t\tlet result;\n\t\ttry {\n\t\t\tconst raw = await this._call(parsed, runManager, config);\n\t\t\tresult = isAsyncGenerator(raw) ? await consumeAsyncGenerator(raw, async (chunk) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait runManager?.handleToolEvent(chunk);\n\t\t\t\t} catch (streamError) {\n\t\t\t\t\tawait runManager?.handleToolError(streamError);\n\t\t\t\t}\n\t\t\t}) : raw;\n\t\t} catch (e) {\n\t\t\tawait runManager?.handleToolError(e);\n\t\t\tthrow e;\n\t\t}\n\t\tlet content;\n\t\tlet artifact;\n\t\tif (this.responseFormat === \"content_and_artifact\") if (Array.isArray(result) && result.length === 2) [content, artifact] = result;\n\t\telse throw new Error(`Tool response format is \"content_and_artifact\" but the output was not a two-tuple.\\nResult: ${JSON.stringify(result)}`);\n\t\telse content = result;\n\t\tconst formattedOutput = _formatToolOutput({\n\t\t\tcontent,\n\t\t\tartifact,\n\t\t\ttoolCallId,\n\t\t\tname: this.name,\n\t\t\tmetadata: this.metadata\n\t\t});\n\t\tawait runManager?.handleToolEnd(formattedOutput);\n\t\treturn formattedOutput;\n\t}\n};\n/**\n* Base class for Tools that accept input as a string.\n*/\nvar Tool = class extends StructuredTool {\n\tschema = z.object({ input: z.string().optional() }).transform((obj) => obj.input);\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t}\n\t/**\n\t* @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n\t*\n\t* Calls the tool with the provided argument and callbacks. It handles\n\t* string inputs specifically.\n\t* @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.\n\t* @param callbacks Optional callbacks for the tool.\n\t* @returns A Promise that resolves with a string.\n\t*/\n\tcall(arg, callbacks) {\n\t\tconst structuredArg = typeof arg === \"string\" || arg == null ? { input: arg } : arg;\n\t\treturn super.call(structuredArg, callbacks);\n\t}\n};\n/**\n* A tool that can be created dynamically from a function, name, and description.\n*/\nvar DynamicTool = class extends Tool {\n\tstatic lc_name() {\n\t\treturn \"DynamicTool\";\n\t}\n\tname;\n\tdescription;\n\tfunc;\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t\tthis.name = fields.name;\n\t\tthis.description = fields.description;\n\t\tthis.func = fields.func;\n\t\tthis.returnDirect = fields.returnDirect ?? this.returnDirect;\n\t}\n\t/**\n\t* @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n\t*/\n\tasync call(arg, configArg) {\n\t\tconst config = parseCallbackConfigArg(configArg);\n\t\tif (config.runName === void 0) config.runName = this.name;\n\t\treturn super.call(arg, config);\n\t}\n\t/** @ignore */\n\t_call(input, runManager, parentConfig) {\n\t\treturn this.func(input, runManager, parentConfig);\n\t}\n};\n/**\n* A tool that can be created dynamically from a function, name, and\n* description, designed to work with structured data. It extends the\n* StructuredTool class and overrides the _call method to execute the\n* provided function when the tool is called.\n*\n* Schema can be passed as Zod or JSON schema. The tool will not validate\n* input if JSON schema is passed.\n*\n* @template SchemaT The input schema type for the tool (Zod schema or JSON schema). Defaults to `ToolInputSchemaBase`.\n* @template SchemaOutputT The output type derived from the schema after parsing/validation. Defaults to `ToolInputSchemaOutputType<SchemaT>`.\n* @template SchemaInputT The input type derived from the schema before parsing. Defaults to `ToolInputSchemaInputType<SchemaT>`.\n* @template ToolOutputT The return type of the tool's function. Defaults to `ToolOutputType`.\n* @template NameT The literal type of the tool name (for discriminated union support). Defaults to `string`.\n*/\nvar DynamicStructuredTool = class extends StructuredTool {\n\tstatic lc_name() {\n\t\treturn \"DynamicStructuredTool\";\n\t}\n\tdescription;\n\tfunc;\n\tschema;\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t\tthis.name = fields.name;\n\t\tthis.description = fields.description;\n\t\tthis.func = fields.func;\n\t\tthis.returnDirect = fields.returnDirect ?? this.returnDirect;\n\t\tthis.schema = fields.schema;\n\t}\n\t/**\n\t* @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n\t*/\n\tasync call(arg, configArg, tags) {\n\t\tconst config = parseCallbackConfigArg(configArg);\n\t\tif (config.runName === void 0) config.runName = this.name;\n\t\treturn super.call(arg, config, tags);\n\t}\n\t_call(arg, runManager, parentConfig) {\n\t\treturn this.func(arg, runManager, parentConfig);\n\t}\n};\n/**\n* Abstract base class for toolkits in LangChain. Toolkits are collections\n* of tools that agents can use. Subclasses must implement the `tools`\n* property to provide the specific tools for the toolkit.\n*/\nvar BaseToolkit = class {\n\tgetTools() {\n\t\treturn this.tools;\n\t}\n};\nfunction tool(func, fields) {\n\tconst isSimpleStringSchema = isSimpleStringZodSchema(fields.schema);\n\tconst isStringJSONSchema = validatesOnlyStrings(fields.schema);\n\tif (!fields.schema || isSimpleStringSchema || isStringJSONSchema) return new DynamicTool({\n\t\t...fields,\n\t\tdescription: fields.description ?? fields.schema?.description ?? `${fields.name} tool`,\n\t\tfunc: async (input, runManager, config) => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst childConfig = patchConfig(config, { callbacks: runManager?.getChild() });\n\t\t\t\tAsyncLocalStorageProviderSingleton.runWithConfig(pickRunnableConfigKeys(childConfig), async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresolve(func(input, childConfig));\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\treject(e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n\tconst schema = fields.schema;\n\tconst description = fields.description ?? fields.schema.description ?? `${fields.name} tool`;\n\treturn new DynamicStructuredTool({\n\t\t...fields,\n\t\tdescription,\n\t\tschema,\n\t\tfunc: async (input, runManager, config) => {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tlet listener;\n\t\t\t\tconst cleanup = () => {\n\t\t\t\t\tif (config?.signal && listener) config.signal.removeEventListener(\"abort\", listener);\n\t\t\t\t};\n\t\t\t\tif (config?.signal) {\n\t\t\t\t\tlistener = () => {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(getAbortSignalError(config.signal));\n\t\t\t\t\t};\n\t\t\t\t\tconfig.signal.addEventListener(\"abort\", listener, { once: true });\n\t\t\t\t}\n\t\t\t\tconst childConfig = patchConfig(config, { callbacks: runManager?.getChild() });\n\t\t\t\tAsyncLocalStorageProviderSingleton.runWithConfig(pickRunnableConfigKeys(childConfig), async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await func(input, childConfig);\n\t\t\t\t\t\tif (isAsyncGenerator(result)) {\n\t\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t* If the signal is aborted, we don't want to resolve the promise\n\t\t\t\t\t\t* as the promise is already rejected.\n\t\t\t\t\t\t*/\n\t\t\t\t\t\tif (config?.signal?.aborted) {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\treject(e);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n}\nfunction _formatToolOutput(params) {\n\tconst { content, artifact, toolCallId, metadata } = params;\n\tif (toolCallId && !isDirectToolOutput(content)) if (typeof content === \"string\" || Array.isArray(content) && content.every((item) => typeof item === \"object\")) return new ToolMessage({\n\t\tstatus: \"success\",\n\t\tcontent,\n\t\tartifact,\n\t\ttool_call_id: toolCallId,\n\t\tname: params.name,\n\t\tmetadata\n\t});\n\telse return new ToolMessage({\n\t\tstatus: \"success\",\n\t\tcontent: _stringify(content),\n\t\tartifact,\n\t\ttool_call_id: toolCallId,\n\t\tname: params.name,\n\t\tmetadata\n\t});\n\telse return content;\n}\nfunction _stringify(content) {\n\ttry {\n\t\treturn JSON.stringify(content) ?? \"\";\n\t} catch (_noOp) {\n\t\treturn `${content}`;\n\t}\n}\n//#endregion\nexport { BaseToolkit, DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolInputParsingException, isLangChainTool, isRunnableToolLike, isStructuredTool, isStructuredToolParams, tool, tools_exports };\n\n//# sourceMappingURL=index.js.map","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 = require(\"events\");","import { NextRequest, NextResponse } from \"next/server\";\nimport { z } from \"zod\";\nimport { registeredTools, registeredCategory, type BuiltinCategory } from \"@/lib/tools/registry\";\nimport {\n disabledCategories,\n setCategoryEnabled,\n} from \"@/lib/stores/builtin-tools\";\nimport { errorResponse, validateBody } from \"@/lib/api/responses\";\n\n// All built-in categories the registry knows about, with their tool count\n// and current enabled state. Default-enabled (no row = on). Used by the\n// Tools tab to render per-category on/off toggles.\n\nconst ALL_VALID_CATEGORIES = new Set<string>([\n \"Memory\", \"Documents\", \"Files\", \"Shell\", \"Web\", \"Images\", \"Voice\",\n \"Schedule\", \"Atlassian\", \"JiraAlign\", \"GitHub\", \"Mail\", \"Calendar\", \"Config\",\n]);\n\ninterface CategoryRow {\n category: BuiltinCategory;\n enabled: boolean;\n toolCount: number;\n toolNames: string[];\n}\n\nfunction listCategories(): CategoryRow[] {\n const disabled = disabledCategories();\n const byCat = new Map<BuiltinCategory, string[]>();\n for (const t of registeredTools()) {\n const cat = registeredCategory(t.name);\n if (!cat) continue;\n const arr = byCat.get(cat) ?? [];\n arr.push(t.name);\n byCat.set(cat, arr);\n }\n const rows: CategoryRow[] = [];\n for (const [cat, names] of byCat) {\n rows.push({\n category: cat,\n enabled: !disabled.has(cat),\n toolCount: names.length,\n toolNames: names.sort(),\n });\n }\n rows.sort((a, b) => a.category.localeCompare(b.category));\n return rows;\n}\n\nexport async function GET() {\n return NextResponse.json(listCategories());\n}\n\nconst PatchSchema = z.object({\n category: z.string(),\n enabled: z.boolean(),\n});\n\nexport async function PATCH(req: NextRequest) {\n const parsed = await validateBody(req, PatchSchema);\n if (parsed instanceof NextResponse) return parsed;\n const { category, enabled } = parsed;\n if (!ALL_VALID_CATEGORIES.has(category)) {\n return errorResponse(`unknown category: ${category}`);\n }\n setCategoryEnabled(category as BuiltinCategory, enabled);\n return NextResponse.json({ category, enabled });\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/builtin-tools/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/builtin-tools/route\",\n pathname: \"/api/v1/builtin-tools\",\n filename: \"route\",\n bundlePath: \"app/api/v1/builtin-tools/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/builtin-tools/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/builtin-tools/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/builtin-tools/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"],"names":["z","tool","DEFAULT_DEADLINE_MS","DEADLINE_DESCRIPTION","wrapWithWallclock","t","schema","extendedSchema","ZodObject","extend","deadline_ms","number","int","positive","optional","describe","wrappedFunc","args","config","deadlineMs","readDeadlineMs","innerArgs","stripDeadline","timer","timeoutPromise","Promise","resolve","setTimeout","JSON","stringify","ok","error_code","message","name","unref","work","invoke","race","clearTimeout","rebuilt","description","v","Number","isFinite","_ignore","rest","__DEFAULT_DEADLINE_MS","CATEGORY_GROUPS","Memory","Documents","Files","Shell","Web","Images","Voice","Schedule","Config","Mail","Calendar","Agent","Atlassian","JiraAlign","GitHub","REGISTRY","Map","registerTools","category","capability","tools","group","wrapped","has","Error","w","set","push","registeredTools","Array","from","values","e","registeredNames","Set","keys","registeredCategory","get","registeredCapability","registeredGroup","_resetRegistry","clear","NextResponse","errorResponse","status","json","error","notFoundResponse","createdResponse","data","cachedJson","maxAgeSeconds","headers","validateBody","req","raw","parsed","safeParse","success","issues","getDb","now","Date","toISOString","isCategoryEnabled","row","prepare","enabled","disabledCategories","rows","all","map","r","listCategoryStates","updated_at","setCategoryEnabled","run","ALL_VALID_CATEGORIES","listCategories","disabled","byCat","cat","arr","names","toolCount","length","toolNames","sort","a","b","localeCompare","GET","PatchSchema","object","string","boolean","PATCH"],"sourceRoot":"","ignoreList":[0,3,5,12,18,26,27,36]}
@@ -173,7 +173,13 @@ var runtime = __webpack_require__(18135);
173
173
  // EXTERNAL MODULE: ./lib/api/sse.ts
174
174
  var sse = __webpack_require__(53854);
175
175
  ;// ./app/api/v1/events/route.ts
176
-
176
+ /**
177
+ * @public — `GET /api/v1/events` (Server-Sent Events)
178
+ *
179
+ * Live notification stream — run completion, watcher fires, queue
180
+ * progress, etc. UI subscribes here for real-time updates; external
181
+ * scripts can subscribe over the same SSE wire format. See `docs/api.md`.
182
+ */
177
183
 
178
184
 
179
185
 
@@ -1 +1 @@
1
- {"version":3,"file":"../app/api/v1/events/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAa;AACb,IAAI,KAAmC,EAAE,EAExC,CAAC;AACF,QAAQ,KAAqC,EAAE,EAc1C,CAAC;AACN,YAAY,KAAsC,EAAE,EAM3C,CAAC;AACV,gBAAgB,KAAqB,EAAE,EAE1B,CAAC;AACd,gBAAgB,2CAAoF;AACpG;AACA;AACA;AACA;;AAEA;;;;;;;ACnCA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACCiE;AAChB;AACO;AACZ;AAE5C,MAAMK,MAAM,IAAIC;AAChB,MAAMC,SAAGA,GAAG,CAACC,MAAiCH,IAAII,MAAM,CAAC,CAAC,MAAM,EAAEC,KAAKC,SAAS,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OtC,0BAAWA,CAACoB,QAAQ;QAAEmB,uBAAuB;IAAM;AAC5D;;;ACpE+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AACqB;AACvF;AACA;AACA;AACA,wBAAwB,mCAAmB;AAC3C;AACA,cAAc,oBAAS;AACvB;AACA;AACA;AACA;AACA,KAAK;AACL,aAAa,OAAoC,IAAI,CAAE;AACvD,wBAAwB,MAAuC;AAC/D;AACA;AACA;AACA,cAAc,qBAAQ;AACtB;AACA;AACA;AACA;AACA,OAAO,MAAsD,GAAG,CAE3D,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA,QAAQ,sDAAsD;AAC9D;AACA,WAAW,0BAAW;AACtB;AACA;AACA,KAAK;AACL;AAC0F;AACnF;AACP;AACA,QAAQ,+BAAc;AACtB;AACA;AACA,QAAQ,+BAAc;AACtB;AACA;AACA;AACA;AACA;AACA,QAAQ,KAAqB,EAAE,EAE1B,CAAC;AACN;AACA;AACA;AACA,+BAA+B,KAAwC;AACvE;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,6NAA6N;AACzO,8BAA8B,+BAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,2CAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,6CAAqB;AAC7B;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,mBAAmB,0BAAS;AAC5B;AACA;AACA,kCAAkC,+BAAc;AAChD,6BAA6B,+BAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,4BAA4B,oBAAe;AAC3C,4BAA4B,qBAAgB;AAC5C,oBAAoB,+BAAkB,kCAAkC,uCAAsB;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,iEAAiE,wBAAc;AAC/E,+DAA+D,yCAAyC;AACxG;AACA;AACA;AACA;AACA,oCAAoC,QAAQ,EAAE,MAAM;AACpD;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,uCAAuC,QAAQ,EAAE,QAAQ;AACzD;AACA,aAAa;AACb;AACA;AACA;AACA,+CAA+C,oBAAoB;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,uCAAyB;AACjE;AACA,oCAAoC,oCAAsB;AAC1D;AACA;AACA;AACA;AACA,sJAAsJ,4BAAc;AACpK,0IAA0I,4BAAc;AACxJ;AACA;AACA;AACA,sCAAsC,8BAAe;AACrD;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,8BAA8B,qCAAY;AAC1C;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,oCAAmB;AACjE;AACA;AACA,6BAA6B;AAC7B,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,oBAAS;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,qIAAqI,8BAAe;AACpJ;AACA,2GAA2G,iHAAiH;AAC5N;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,yCAA2B;AAC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qCAA+C;AAC/C;AACA;AACA;AACA;AACA,CAAC,EAAC;AACF,iBAAiB,mBAAO,CAAC,KAAqB;AAC9C,sBAAsB,mBAAO,CAAC,KAAiB;AAC/C,eAAe,mBAAO,CAAC,KAAa;AACpC;AACA;AACA;AACA,IAAI,KAAmC;AACvC;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;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;;;;;;;ACrEA","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 \"undici\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-page.runtime.prod.js\"","webpack://@circuitwall/jarela/external commonjs2 \"assert\"","webpack://@circuitwall/jarela/external module \"@whiskeysockets/baileys\"","webpack://@circuitwall/jarela/external node-commonjs \"node:async_hooks\"","webpack://@circuitwall/jarela/./node_modules/next/dist/server/route-modules/app-route/module.compiled.js","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/./app/api/v1/events/route.ts","webpack://@circuitwall/jarela/?1b72","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:dns\"","webpack://@circuitwall/jarela/external node-commonjs \"node:https\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-route.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:os\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs/promises\"","webpack://@circuitwall/jarela/./lib/api/sse.ts","webpack://@circuitwall/jarela/external commonjs2 \"crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"https\"","webpack://@circuitwall/jarela/external node-commonjs \"node:stream\"","webpack://@circuitwall/jarela/external node-commonjs \"node:util\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-unit-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs\"","webpack://@circuitwall/jarela/external node-commonjs \"node:url\"","webpack://@circuitwall/jarela/external commonjs2 \"zlib\"","webpack://@circuitwall/jarela/external node-commonjs \"node:worker_threads\"","webpack://@circuitwall/jarela/external node-commonjs \"node:path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:net\"","webpack://@circuitwall/jarela/external node-commonjs \"node:crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"buffer\"","webpack://@circuitwall/jarela/external commonjs2 \"fs/promises\"","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/./node_modules/next/dist/server/send-response.js","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(\"undici\");","module.exports = require(\"next/dist/compiled/next-server/app-page.runtime.prod.js\");","module.exports = require(\"assert\");","module.exports = import(\"@whiskeysockets/baileys\");;","module.exports = require(\"node:async_hooks\");","\"use strict\";\nif (process.env.NEXT_RUNTIME === 'edge') {\n module.exports = require('next/dist/server/route-modules/app-route/module.js');\n} else {\n if (process.env.__NEXT_EXPERIMENTAL_REACT) {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo-experimental.runtime.dev.js');\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route-experimental.runtime.dev.js');\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo-experimental.runtime.prod.js');\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route-experimental.runtime.prod.js');\n }\n }\n } else {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.dev.js');\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route.runtime.dev.js');\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.prod.js');\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route.runtime.prod.js');\n }\n }\n }\n}\n\n//# sourceMappingURL=module.compiled.js.map","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\");","import { NextRequest } from \"next/server\";\nimport { recentSince, subscribe } from \"@/lib/notifications/bus\";\nimport { startScheduler } from \"@/lib/scheduler\";\nimport { startAllBridges } from \"@/lib/bridges/runtime\";\nimport { sseResponse } from \"@/lib/api/sse\";\n\nconst enc = new TextEncoder();\nconst sse = (obj: Record<string, unknown>) => enc.encode(`data: ${JSON.stringify(obj)}\\n\\n`);\n\n// Long-lived SSE stream of app events (run completions, scheduled-task fires).\n// The browser subscribes once on app boot and renders Web Notifications.\n// Pass `?since=<unixMs>` to replay events newer than a timestamp on reconnect.\nexport function GET(req: NextRequest) {\n // Wake the scheduler on every SSE subscription. Cheap (idempotent), and\n // guarantees a freshly-loaded dev server has a ticking scheduler the\n // moment the UI opens its event stream — before this, the scheduler was\n // only started lazily on the first agent run, so a server restart could\n // leave scheduled tasks dormant until you sent a chat message.\n startScheduler();\n\n // Bring up enabled bridges (WhatsApp adapters). Idempotent — runtime.ts\n // pins state to globalThis so this is a no-op after the first call.\n // Fire-and-forget: bridge connect can take seconds, the SSE stream below\n // mustn't block waiting for WebSocket handshakes.\n void startAllBridges().catch((err) => {\n console.error(\"[bridges] startAllBridges failed:\", err);\n });\n\n const url = new URL(req.url);\n const sinceTs = Number(url.searchParams.get(\"since\")) || 0;\n\n const stream = new ReadableStream({\n start(controller) {\n let alive = true;\n const safeEnqueue = (chunk: Uint8Array) => {\n if (!alive) return;\n try { controller.enqueue(chunk); } catch { alive = false; }\n };\n\n // Replay anything missed since the client's last seen timestamp.\n for (const ev of recentSince(sinceTs)) {\n safeEnqueue(sse({ ...ev }));\n }\n\n // Subscribe to live events.\n const unsubscribe = subscribe((ev) => {\n safeEnqueue(sse({ ...ev }));\n });\n\n // Heartbeat so intermediate proxies don't time out the connection.\n const heartbeat = setInterval(() => {\n safeEnqueue(enc.encode(\": heartbeat\\n\\n\"));\n }, 30_000);\n heartbeat.unref?.();\n\n const cleanup = () => {\n alive = false;\n clearInterval(heartbeat);\n unsubscribe();\n try { controller.close(); } catch { /* */ }\n };\n\n req.signal.addEventListener(\"abort\", cleanup);\n },\n cancel() { /* alive flag flips on next enqueue attempt */ },\n });\n\n return sseResponse(stream, { disableProxyBuffering: false });\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/events/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/events/route\",\n pathname: \"/api/v1/events\",\n filename: \"route\",\n bundlePath: \"app/api/v1/events/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/events/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/events/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/events/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:child_process\");","module.exports = require(\"path\");","module.exports = require(\"node:http\");","module.exports = require(\"node:dns\");","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\");","// Shared response builder for Server-Sent Event streams. Centralises the\n// content-type / cache-control / connection / proxy-buffering headers so\n// every SSE endpoint behaves identically through nginx, tailscale-serve,\n// and Cloudflare. See ADR-0009 for the proxy story.\n\nexport interface SseResponseOptions {\n /**\n * Set `X-Accel-Buffering: no`. Required when intermediate proxies\n * (nginx, tailscale-serve) might coalesce small chunks and break SSE\n * framing. Default: true.\n */\n disableProxyBuffering?: boolean;\n}\n\nexport function sseResponse(\n stream: ReadableStream,\n opts: SseResponseOptions = {},\n): Response {\n const { disableProxyBuffering = true } = opts;\n const headers: Record<string, string> = {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n };\n if (disableProxyBuffering) headers[\"X-Accel-Buffering\"] = \"no\";\n return new Response(stream, { headers });\n}\n","module.exports = require(\"crypto\");","module.exports = require(\"https\");","module.exports = require(\"node:stream\");","module.exports = require(\"node:util\");","module.exports = require(\"next/dist/server/app-render/work-unit-async-storage.external.js\");","module.exports = require(\"node:fs\");","module.exports = require(\"node:url\");","module.exports = require(\"zlib\");","module.exports = require(\"node:worker_threads\");","module.exports = require(\"node:path\");","module.exports = require(\"node:net\");","module.exports = require(\"node:crypto\");","module.exports = require(\"buffer\");","module.exports = require(\"fs/promises\");","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\");;","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"sendResponse\", {\n enumerable: true,\n get: function() {\n return sendResponse;\n }\n});\nconst _helpers = require(\"./base-http/helpers\");\nconst _pipereadable = require(\"./pipe-readable\");\nconst _utils = require(\"./web/utils\");\nasync function sendResponse(req, res, response, waitUntil) {\n if (// The type check here ensures that `req` is correctly typed, and the\n // environment variable check provides dead code elimination.\n process.env.NEXT_RUNTIME !== 'edge' && (0, _helpers.isNodeNextResponse)(res)) {\n var // Copy over the response headers.\n _response_headers;\n // Copy over the response status.\n res.statusCode = response.status;\n res.statusMessage = response.statusText;\n // TODO: this is not spec-compliant behavior and we should not restrict\n // headers that are allowed to appear many times.\n //\n // See:\n // https://github.com/vercel/next.js/pull/70127\n const headersWithMultipleValuesAllowed = [\n // can add more headers to this list if needed\n 'set-cookie',\n 'www-authenticate',\n 'proxy-authenticate',\n 'vary'\n ];\n (_response_headers = response.headers) == null ? void 0 : _response_headers.forEach((value, name)=>{\n // `x-middleware-set-cookie` is an internal header not needed for the response\n if (name.toLowerCase() === 'x-middleware-set-cookie') {\n return;\n }\n // The append handling is special cased for `set-cookie`.\n if (name.toLowerCase() === 'set-cookie') {\n // TODO: (wyattjoh) replace with native response iteration when we can upgrade undici\n for (const cookie of (0, _utils.splitCookiesString)(value)){\n res.appendHeader(name, cookie);\n }\n } else {\n // only append the header if it is either not present in the outbound response\n // or if the header supports multiple values\n const isHeaderPresent = typeof res.getHeader(name) !== 'undefined';\n if (headersWithMultipleValuesAllowed.includes(name.toLowerCase()) || !isHeaderPresent) {\n res.appendHeader(name, value);\n }\n }\n });\n /**\n * The response can't be directly piped to the underlying response. The\n * following is duplicated from the edge runtime handler.\n *\n * See packages/next/server/next-server.ts\n */ const { originalResponse } = res;\n // A response body must not be sent for HEAD requests. See https://httpwg.org/specs/rfc9110.html#HEAD\n if (response.body && req.method !== 'HEAD') {\n await (0, _pipereadable.pipeToNodeResponse)(response.body, originalResponse, waitUntil);\n } else {\n originalResponse.end();\n }\n }\n}\n\n//# sourceMappingURL=send-response.js.map","module.exports = require(\"events\");"],"names":["recentSince","subscribe","startScheduler","startAllBridges","sseResponse","enc","TextEncoder","sse","obj","encode","JSON","stringify","GET","req","catch","err","console","error","url","URL","sinceTs","Number","searchParams","get","stream","ReadableStream","start","controller","alive","safeEnqueue","chunk","enqueue","ev","unsubscribe","heartbeat","setInterval","unref","cleanup","clearInterval","close","signal","addEventListener","cancel","disableProxyBuffering","opts","headers","Connection","Response"],"sourceRoot":"","ignoreList":[0,4,8,12,20,28,40,42]}
1
+ {"version":3,"file":"../app/api/v1/events/route.js","mappings":";;;;;;;;;;AAAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAa;AACb,IAAI,KAAmC,EAAE,EAExC,CAAC;AACF,QAAQ,KAAqC,EAAE,EAc1C,CAAC;AACN,YAAY,KAAsC,EAAE,EAM3C,CAAC;AACV,gBAAgB,KAAqB,EAAE,EAE1B,CAAC;AACd,gBAAgB,2CAAoF;AACpG;AACA;AACA;AACA;;AAEA;;;;;;;ACnCA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;ACAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;;;;;;CAMC,GAGgE;AAChB;AACO;AACZ;AAE5C,MAAMK,MAAM,IAAIC;AAChB,MAAMC,SAAGA,GAAG,CAACC,MAAiCH,IAAII,MAAM,CAAC,CAAC,MAAM,EAAEC,KAAKC,SAAS,CAACH,KAAK,IAAI,CAAC;AAE3F,+EAA+E;AAC/E,yEAAyE;AACzE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AC5E+F;AACvC;AACqB;AACkB;AACvB;AACgB;AACT;AACK;AACmC;AACjD;AACO;AACf;AACsC;AACzB;AACM;AACC;AAChB;AACqB;AACvF;AACA;AACA;AACA,wBAAwB,mCAAmB;AAC3C;AACA,cAAc,oBAAS;AACvB;AACA;AACA;AACA;AACA,KAAK;AACL,aAAa,OAAoC,IAAI,CAAE;AACvD,wBAAwB,MAAuC;AAC/D;AACA;AACA;AACA,cAAc,qBAAQ;AACtB;AACA;AACA;AACA;AACA,OAAO,MAAsD,GAAG,CAE3D,CAAC;AACN,CAAC;AACD;AACA;AACA;AACA,QAAQ,sDAAsD;AAC9D;AACA,WAAW,0BAAW;AACtB;AACA;AACA,KAAK;AACL;AAC0F;AACnF;AACP;AACA,QAAQ,+BAAc;AACtB;AACA;AACA,QAAQ,+BAAc;AACtB;AACA;AACA;AACA;AACA;AACA,QAAQ,KAAqB,EAAE,EAE1B,CAAC;AACN;AACA;AACA;AACA,+BAA+B,KAAwC;AACvE;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,6NAA6N;AACzO,8BAA8B,+BAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,2CAAe;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,6CAAqB;AAC7B;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,mBAAmB,0BAAS;AAC5B;AACA;AACA,kCAAkC,+BAAc;AAChD,6BAA6B,+BAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,4BAA4B,oBAAe;AAC3C,4BAA4B,qBAAgB;AAC5C,oBAAoB,+BAAkB,kCAAkC,uCAAsB;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,iEAAiE,wBAAc;AAC/E,+DAA+D,yCAAyC;AACxG;AACA;AACA;AACA;AACA,oCAAoC,QAAQ,EAAE,MAAM;AACpD;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,uCAAuC,QAAQ,EAAE,QAAQ;AACzD;AACA,aAAa;AACb;AACA;AACA;AACA,+CAA+C,oBAAoB;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,uCAAyB;AACjE;AACA,oCAAoC,oCAAsB;AAC1D;AACA;AACA;AACA;AACA,sJAAsJ,4BAAc;AACpK,0IAA0I,4BAAc;AACxJ;AACA;AACA;AACA,sCAAsC,8BAAe;AACrD;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,8BAA8B,qCAAY;AAC1C;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,oCAAmB;AACjE;AACA;AACA,6BAA6B;AAC7B,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,oBAAS;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,qIAAqI,8BAAe;AACpJ;AACA,2GAA2G,iHAAiH;AAC5N;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,yCAA2B;AACvD;AACA,+BAA+B,oCAAsB;AACrD;AACA;AACA;AACA;AACA,6CAA6C,u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mBAAO,CAAC,KAAqB;AAC9C,sBAAsB,mBAAO,CAAC,KAAiB;AAC/C,eAAe,mBAAO,CAAC,KAAa;AACpC;AACA;AACA;AACA,IAAI,KAAmC;AACvC;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;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;;;;;;;ACrEA","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 \"undici\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-page.runtime.prod.js\"","webpack://@circuitwall/jarela/external commonjs2 \"assert\"","webpack://@circuitwall/jarela/external module \"@whiskeysockets/baileys\"","webpack://@circuitwall/jarela/external node-commonjs \"node:async_hooks\"","webpack://@circuitwall/jarela/./node_modules/next/dist/server/route-modules/app-route/module.compiled.js","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/./app/api/v1/events/route.ts","webpack://@circuitwall/jarela/?1b72","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:dns\"","webpack://@circuitwall/jarela/external node-commonjs \"node:https\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/compiled/next-server/app-route.runtime.prod.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:os\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs/promises\"","webpack://@circuitwall/jarela/./lib/api/sse.ts","webpack://@circuitwall/jarela/external commonjs2 \"crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"https\"","webpack://@circuitwall/jarela/external node-commonjs \"node:stream\"","webpack://@circuitwall/jarela/external node-commonjs \"node:util\"","webpack://@circuitwall/jarela/external commonjs \"next/dist/server/app-render/work-unit-async-storage.external.js\"","webpack://@circuitwall/jarela/external node-commonjs \"node:fs\"","webpack://@circuitwall/jarela/external node-commonjs \"node:url\"","webpack://@circuitwall/jarela/external commonjs2 \"zlib\"","webpack://@circuitwall/jarela/external node-commonjs \"node:worker_threads\"","webpack://@circuitwall/jarela/external node-commonjs \"node:path\"","webpack://@circuitwall/jarela/external node-commonjs \"node:net\"","webpack://@circuitwall/jarela/external node-commonjs \"node:crypto\"","webpack://@circuitwall/jarela/external commonjs2 \"buffer\"","webpack://@circuitwall/jarela/external commonjs2 \"fs/promises\"","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/./node_modules/next/dist/server/send-response.js","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(\"undici\");","module.exports = require(\"next/dist/compiled/next-server/app-page.runtime.prod.js\");","module.exports = require(\"assert\");","module.exports = import(\"@whiskeysockets/baileys\");;","module.exports = require(\"node:async_hooks\");","\"use strict\";\nif (process.env.NEXT_RUNTIME === 'edge') {\n module.exports = require('next/dist/server/route-modules/app-route/module.js');\n} else {\n if (process.env.__NEXT_EXPERIMENTAL_REACT) {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo-experimental.runtime.dev.js');\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route-experimental.runtime.dev.js');\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo-experimental.runtime.prod.js');\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route-experimental.runtime.prod.js');\n }\n }\n } else {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.dev.js');\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route.runtime.dev.js');\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.prod.js');\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route.runtime.prod.js');\n }\n }\n }\n}\n\n//# sourceMappingURL=module.compiled.js.map","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\");","/**\n * @public — `GET /api/v1/events` (Server-Sent Events)\n *\n * Live notification stream — run completion, watcher fires, queue\n * progress, etc. UI subscribes here for real-time updates; external\n * scripts can subscribe over the same SSE wire format. See `docs/api.md`.\n */\n\nimport { NextRequest } from \"next/server\";\nimport { recentSince, subscribe } from \"@/lib/notifications/bus\";\nimport { startScheduler } from \"@/lib/scheduler\";\nimport { startAllBridges } from \"@/lib/bridges/runtime\";\nimport { sseResponse } from \"@/lib/api/sse\";\n\nconst enc = new TextEncoder();\nconst sse = (obj: Record<string, unknown>) => enc.encode(`data: ${JSON.stringify(obj)}\\n\\n`);\n\n// Long-lived SSE stream of app events (run completions, scheduled-task fires).\n// The browser subscribes once on app boot and renders Web Notifications.\n// Pass `?since=<unixMs>` to replay events newer than a timestamp on reconnect.\nexport function GET(req: NextRequest) {\n // Wake the scheduler on every SSE subscription. Cheap (idempotent), and\n // guarantees a freshly-loaded dev server has a ticking scheduler the\n // moment the UI opens its event stream — before this, the scheduler was\n // only started lazily on the first agent run, so a server restart could\n // leave scheduled tasks dormant until you sent a chat message.\n startScheduler();\n\n // Bring up enabled bridges (WhatsApp adapters). Idempotent — runtime.ts\n // pins state to globalThis so this is a no-op after the first call.\n // Fire-and-forget: bridge connect can take seconds, the SSE stream below\n // mustn't block waiting for WebSocket handshakes.\n void startAllBridges().catch((err) => {\n console.error(\"[bridges] startAllBridges failed:\", err);\n });\n\n const url = new URL(req.url);\n const sinceTs = Number(url.searchParams.get(\"since\")) || 0;\n\n const stream = new ReadableStream({\n start(controller) {\n let alive = true;\n const safeEnqueue = (chunk: Uint8Array) => {\n if (!alive) return;\n try { controller.enqueue(chunk); } catch { alive = false; }\n };\n\n // Replay anything missed since the client's last seen timestamp.\n for (const ev of recentSince(sinceTs)) {\n safeEnqueue(sse({ ...ev }));\n }\n\n // Subscribe to live events.\n const unsubscribe = subscribe((ev) => {\n safeEnqueue(sse({ ...ev }));\n });\n\n // Heartbeat so intermediate proxies don't time out the connection.\n const heartbeat = setInterval(() => {\n safeEnqueue(enc.encode(\": heartbeat\\n\\n\"));\n }, 30_000);\n heartbeat.unref?.();\n\n const cleanup = () => {\n alive = false;\n clearInterval(heartbeat);\n unsubscribe();\n try { controller.close(); } catch { /* */ }\n };\n\n req.signal.addEventListener(\"abort\", cleanup);\n },\n cancel() { /* alive flag flips on next enqueue attempt */ },\n });\n\n return sseResponse(stream, { disableProxyBuffering: false });\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/events/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/events/route\",\n pathname: \"/api/v1/events\",\n filename: \"route\",\n bundlePath: \"app/api/v1/events/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/events/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/events/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/events/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:child_process\");","module.exports = require(\"path\");","module.exports = require(\"node:http\");","module.exports = require(\"node:dns\");","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\");","// Shared response builder for Server-Sent Event streams. Centralises the\n// content-type / cache-control / connection / proxy-buffering headers so\n// every SSE endpoint behaves identically through nginx, tailscale-serve,\n// and Cloudflare. See ADR-0009 for the proxy story.\n\nexport interface SseResponseOptions {\n /**\n * Set `X-Accel-Buffering: no`. Required when intermediate proxies\n * (nginx, tailscale-serve) might coalesce small chunks and break SSE\n * framing. Default: true.\n */\n disableProxyBuffering?: boolean;\n}\n\nexport function sseResponse(\n stream: ReadableStream,\n opts: SseResponseOptions = {},\n): Response {\n const { disableProxyBuffering = true } = opts;\n const headers: Record<string, string> = {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n };\n if (disableProxyBuffering) headers[\"X-Accel-Buffering\"] = \"no\";\n return new Response(stream, { headers });\n}\n","module.exports = require(\"crypto\");","module.exports = require(\"https\");","module.exports = require(\"node:stream\");","module.exports = require(\"node:util\");","module.exports = require(\"next/dist/server/app-render/work-unit-async-storage.external.js\");","module.exports = require(\"node:fs\");","module.exports = require(\"node:url\");","module.exports = require(\"zlib\");","module.exports = require(\"node:worker_threads\");","module.exports = require(\"node:path\");","module.exports = require(\"node:net\");","module.exports = require(\"node:crypto\");","module.exports = require(\"buffer\");","module.exports = require(\"fs/promises\");","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\");;","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"sendResponse\", {\n enumerable: true,\n get: function() {\n return sendResponse;\n }\n});\nconst _helpers = require(\"./base-http/helpers\");\nconst _pipereadable = require(\"./pipe-readable\");\nconst _utils = require(\"./web/utils\");\nasync function sendResponse(req, res, response, waitUntil) {\n if (// The type check here ensures that `req` is correctly typed, and the\n // environment variable check provides dead code elimination.\n process.env.NEXT_RUNTIME !== 'edge' && (0, _helpers.isNodeNextResponse)(res)) {\n var // Copy over the response headers.\n _response_headers;\n // Copy over the response status.\n res.statusCode = response.status;\n res.statusMessage = response.statusText;\n // TODO: this is not spec-compliant behavior and we should not restrict\n // headers that are allowed to appear many times.\n //\n // See:\n // https://github.com/vercel/next.js/pull/70127\n const headersWithMultipleValuesAllowed = [\n // can add more headers to this list if needed\n 'set-cookie',\n 'www-authenticate',\n 'proxy-authenticate',\n 'vary'\n ];\n (_response_headers = response.headers) == null ? void 0 : _response_headers.forEach((value, name)=>{\n // `x-middleware-set-cookie` is an internal header not needed for the response\n if (name.toLowerCase() === 'x-middleware-set-cookie') {\n return;\n }\n // The append handling is special cased for `set-cookie`.\n if (name.toLowerCase() === 'set-cookie') {\n // TODO: (wyattjoh) replace with native response iteration when we can upgrade undici\n for (const cookie of (0, _utils.splitCookiesString)(value)){\n res.appendHeader(name, cookie);\n }\n } else {\n // only append the header if it is either not present in the outbound response\n // or if the header supports multiple values\n const isHeaderPresent = typeof res.getHeader(name) !== 'undefined';\n if (headersWithMultipleValuesAllowed.includes(name.toLowerCase()) || !isHeaderPresent) {\n res.appendHeader(name, value);\n }\n }\n });\n /**\n * The response can't be directly piped to the underlying response. The\n * following is duplicated from the edge runtime handler.\n *\n * See packages/next/server/next-server.ts\n */ const { originalResponse } = res;\n // A response body must not be sent for HEAD requests. See https://httpwg.org/specs/rfc9110.html#HEAD\n if (response.body && req.method !== 'HEAD') {\n await (0, _pipereadable.pipeToNodeResponse)(response.body, originalResponse, waitUntil);\n } else {\n originalResponse.end();\n }\n }\n}\n\n//# sourceMappingURL=send-response.js.map","module.exports = require(\"events\");"],"names":["recentSince","subscribe","startScheduler","startAllBridges","sseResponse","enc","TextEncoder","sse","obj","encode","JSON","stringify","GET","req","catch","err","console","error","url","URL","sinceTs","Number","searchParams","get","stream","ReadableStream","start","controller","alive","safeEnqueue","chunk","enqueue","ev","unsubscribe","heartbeat","setInterval","unref","cleanup","clearInterval","close","signal","addEventListener","cancel","disableProxyBuffering","opts","headers","Connection","Response"],"sourceRoot":"","ignoreList":[0,4,8,12,20,28,40,42]}