@circuitwall/jarela 1.2.0 → 1.4.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 (96) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +2 -2
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  5. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  21. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  22. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +3 -3
  23. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +3 -3
  25. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +3 -3
  27. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +3 -3
  29. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +3 -3
  31. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +218 -7
  33. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.map +1 -1
  34. package/.next/standalone/.next/server/app/api/v1/events/route.js +3 -3
  35. package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +8 -1
  37. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.map +1 -1
  38. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +8 -1
  39. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.map +1 -1
  40. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +8 -1
  41. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.map +1 -1
  42. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +8 -1
  43. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.map +1 -1
  44. package/.next/standalone/.next/server/app/api/v1/extensions/route.js +2 -2
  45. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +2 -2
  46. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +37 -3
  47. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.map +1 -1
  48. package/.next/standalone/.next/server/app/api/v1/tools/route.js +2 -2
  49. package/.next/standalone/.next/server/app/page.js +10 -18
  50. package/.next/standalone/.next/server/app/page.js.map +1 -1
  51. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  52. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  53. package/.next/standalone/.next/server/chunks/210.js +1 -1
  54. package/.next/standalone/.next/server/chunks/239.js +5335 -5230
  55. package/.next/standalone/.next/server/chunks/239.js.map +1 -1
  56. package/.next/standalone/.next/server/chunks/{1683.js → 241.js} +210 -36
  57. package/.next/standalone/.next/server/chunks/241.js.map +1 -0
  58. package/.next/standalone/.next/server/chunks/{8135.js → 2539.js} +218 -36
  59. package/.next/standalone/.next/server/chunks/2539.js.map +1 -0
  60. package/.next/standalone/.next/server/chunks/4631.js +218 -7
  61. package/.next/standalone/.next/server/chunks/4631.js.map +1 -1
  62. package/.next/standalone/.next/server/chunks/8866.js +13389 -13073
  63. package/.next/standalone/.next/server/chunks/8866.js.map +1 -1
  64. package/.next/standalone/.next/server/chunks/9032.js +1 -1
  65. package/.next/standalone/.next/server/chunks/9032.js.map +1 -1
  66. package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
  67. package/.next/standalone/.next/server/pages/404.html +1 -1
  68. package/.next/standalone/.next/server/pages/500.html +1 -1
  69. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  70. package/.next/standalone/.next/static/chunks/app/{page-62e0d5f2404b403b.js → page-74846c864241b96d.js} +11 -19
  71. package/.next/standalone/.next/static/chunks/app/page-74846c864241b96d.js.map +1 -0
  72. package/.next/standalone/package.json +2 -1
  73. package/CHANGELOG.md +98 -0
  74. package/README.md +51 -26
  75. package/components/chat/InputBar.tsx +10 -1
  76. package/components/ui/BootScreen.tsx +0 -10
  77. package/lib/agents/agent-turn.ts +9 -0
  78. package/lib/agents/prepare/request.ts +9 -0
  79. package/lib/agents/run-thread.ts +9 -1
  80. package/lib/api/extension-turn.ts +7 -0
  81. package/lib/api/page-capture.test.ts +58 -0
  82. package/lib/api/page-capture.ts +31 -1
  83. package/lib/bridges/attachment-store.test.ts +440 -0
  84. package/lib/bridges/attachment-store.ts +184 -0
  85. package/lib/bridges/whatsapp.ts +50 -32
  86. package/lib/tools/async-results-tool.ts +114 -0
  87. package/lib/tools/async-results.test.ts +481 -0
  88. package/lib/tools/async-results.ts +165 -0
  89. package/lib/tools/builtins.ts +1 -0
  90. package/lib/tools/wallclock.ts +114 -8
  91. package/package.json +2 -1
  92. package/.next/standalone/.next/server/chunks/1683.js.map +0 -1
  93. package/.next/standalone/.next/server/chunks/8135.js.map +0 -1
  94. package/.next/standalone/.next/static/chunks/app/page-62e0d5f2404b403b.js.map +0 -1
  95. /package/.next/standalone/.next/static/{2xWP8843jbntFGKLnHK6R → AV5AO0yTRABo-NgwxhDe7}/_buildManifest.js +0 -0
  96. /package/.next/standalone/.next/static/{2xWP8843jbntFGKLnHK6R → AV5AO0yTRABo-NgwxhDe7}/_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,yEAAyE;AACzE,qEAAqE;AACrE,aAAa;AAEW;AACmD;AAE3E,MAAME,sBAAsB;AAE5B,MAAMC,uBACJ,qFACA,8EACA,2EACA,2EACA;AAMK,SAASC,kBAAqDC,CAAI;IACvE,oEAAoE;IACpE,qEAAqE;IAC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A;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC7W+D;AAC2B;AACpB;AACY;AACc;AAChE;AACyE;AAChD;AACiE;AAC3D;AACgB;AACpB;AACgD;AAChF;AACsB;AACf;AAClC;AACA,oCAAoC,kFAAW;AAC/C;AACA;AACA;AACA;AACA;AACA,kCAAkC,0EAAyB;AAC3D,wBAAwB,iEAAe;AACvC,2BAA2B,oEAAkB;AAC7C,yBAAyB,kEAAgB;AACzC,+BAA+B,wEAAsB;AACrD;AACA,CAAC;AACD;AACA;AACA;AACA,mCAAmC,6EAAa;AAChD;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,oBAAoB;AACpB;AACA;AACA;AACA;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","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/./app/api/v1/builtin-tools/route.ts","webpack://@circuitwall/jarela/?07b1","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: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\""],"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 { 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","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: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\");"],"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,29,37]}
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,uEAA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AACL,WAAW;QACvC,OAAOyB,mCAAaA,CAAC,CAAC,kBAAkB,EAAEzB,UAAU;IACtD;IACAsD,4CAAkBA,CAACtD,UAA6B8C;IAChD,OAAOtB,mBAAYA,CAACG,IAAI,CAAC;QAAE3B;QAAU8C;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC7W+D;AAC2B;AACpB;AACY;AACc;AAChE;AACyE;AAChD;AACiE;AAC3D;AACgB;AACpB;AACgD;AAChF;AACsB;AACf;AAClC;AACA,oCAAoC,kFAAW;AAC/C;AACA;AACA;AACA;AACA;AACA,kCAAkC,0EAAyB;AAC3D,wBAAwB,iEAAe;AACvC,2BAA2B,oEAAkB;AAC7C,yBAAyB,kEAAgB;AACzC,+BAA+B,wEAAsB;AACrD;AACA,CAAC;AACD;AACA;AACA;AACA,mCAAmC,6EAAa;AAChD;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,oBAAoB;AACpB;AACA;AACA;AACA;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;;;;;;;;;;;;;;;;;;ACAA,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,uEAAuE;AACvE,kEAAkE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S,OAAOnI,GAAG;IACvB,IAAI,CAACiI,UAAU;QACb9J,QAAQC,IAAI,CACV,CAAC,sCAAsC,EAAE+J,OAAOnI,GAAG,CAAC,OAAO,EAAEmI,OAAOxM,IAAI,CAAC,EAAE,CAAC,GAC5E,CAAC,4BAA4B,EAAEgL,YAAY,KAAK,CAAC;IAErD;AACF;AAEA,sBAAsB,GACf,SAASyB;IACdvB,MAAMxD,KAAK;IACX,IAAIyD,SAAS;QACXuB,cAAcvB;QACdA,UAAU;IACZ;AACF;AAEA,sBAAsB,GACf,SAASwB,mBAAmBtI,GAAW,EAAEuI,UAAkB;IAChE,MAAMjB,MAAMT,MAAM5D,GAAG,CAACjD;IACtB,IAAIsH,KAAKA,IAAID,WAAW,GAAGkB;AAC7B","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/./app/api/v1/builtin-tools/route.ts","webpack://@circuitwall/jarela/?07b1","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: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/./lib/tools/async-results.ts"],"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\";\nimport {\n startAsyncCall,\n completeAsyncCall,\n failAsyncCall,\n} from \"./async-results\";\n\nconst DEFAULT_DEADLINE_MS = 120_000;\n\n// Hard ceiling so a runaway `deadline_ms` from the LLM (or a typo of\n// \"10 minutes\" as 100_000_000) can't park a single turn for hours. The\n// operator can raise or lower this with JARELA_TOOL_MAX_DEADLINE_MS\n// (integer milliseconds). Anything above the ceiling is clamped and a\n// warning is logged once per call.\nexport const DEFAULT_MAX_DEADLINE_MS = 30 * 60 * 1000;\n\nexport function getMaxDeadlineMs(): number {\n const raw = process.env.JARELA_TOOL_MAX_DEADLINE_MS;\n if (!raw) return DEFAULT_MAX_DEADLINE_MS;\n const n = Number(raw);\n return Number.isFinite(n) && n > 0 ? Math.floor(n) : DEFAULT_MAX_DEADLINE_MS;\n}\n\nconst DEADLINE_DESCRIPTION =\n \"Optional wall-clock budget for this tool call in milliseconds (default 120000, hard ceiling 1800000 / 30 min). \" +\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 \"Values above the ceiling are clamped; use `async_run: true` for work that genuinely needs more.\";\n\nconst ASYNC_RUN_DESCRIPTION =\n \"Optional. Set true to fire this tool in the background and get back a \" +\n \"tracking key immediately instead of waiting for the result. Use for \" +\n \"long-running calls (large fetches, slow shell builds) when you want to \" +\n \"keep the conversation moving. Retrieve the result later by calling \" +\n \"`tool_result_get` with the returned key. The original `deadline_ms` \" +\n \"still applies — it just runs in the background.\";\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({\n deadline_ms: z.number().int().positive().optional().describe(DEADLINE_DESCRIPTION),\n async_run: z.boolean().optional().describe(ASYNC_RUN_DESCRIPTION),\n })\n : null;\n\n const wrappedFunc: WallclockedFunc = async (args, config) => {\n const requested = readDeadlineMs(args) ?? DEFAULT_DEADLINE_MS;\n const ceiling = getMaxDeadlineMs();\n const deadlineMs = Math.min(requested, ceiling);\n if (requested > ceiling) {\n console.warn(\n `[wallclock] tool=\"${t.name}\" requested deadline_ms=${requested} exceeds ceiling ${ceiling}; clamped. ` +\n `Use async_run: true for work that genuinely needs more, or raise JARELA_TOOL_MAX_DEADLINE_MS.`,\n );\n }\n const asyncRun = readAsyncRun(args);\n const innerArgs = stripWrapperFields(args);\n\n if (asyncRun) {\n return runAsync(t, innerArgs, config, deadlineMs);\n }\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 readAsyncRun(args: Record<string, unknown> | unknown): boolean {\n if (!args || typeof args !== \"object\") return false;\n return (args as Record<string, unknown>).async_run === true;\n}\n\nfunction stripWrapperFields(args: Record<string, unknown> | unknown): Record<string, unknown> | unknown {\n if (!args || typeof args !== \"object\") return args;\n const { deadline_ms: _d, async_run: _a, ...rest } = args as Record<string, unknown>;\n void _d; void _a;\n return rest;\n}\n\n/**\n * Fire the tool detached and return a pointer the agent can poll via\n * `tool_result_get`. The same `deadline_ms` still applies — when the\n * timer wins, the slot is marked errored with a timeout message.\n */\nfunction runAsync<T extends StructuredToolInterface>(\n t: T,\n innerArgs: unknown,\n config: unknown,\n deadlineMs: number,\n): string {\n const key = startAsyncCall(t.name);\n const startedAt = Date.now();\n\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n failAsyncCall(\n key,\n `Tool \"${t.name}\" exceeded its background wall-clock budget of ${deadlineMs}ms. ` +\n \"The underlying operation may still be running but its result is discarded.\",\n );\n }, deadlineMs);\n (timer as unknown as { unref?: () => void }).unref?.();\n\n void (async () => {\n try {\n const work = (t as unknown as { invoke: (a: unknown, c?: unknown) => Promise<unknown> })\n .invoke(innerArgs, config);\n const result = await work;\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n completeAsyncCall(\n key,\n typeof result === \"string\" ? result : JSON.stringify(result),\n );\n } catch (err) {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n failAsyncCall(key, err);\n }\n })();\n\n return JSON.stringify({\n ok: true,\n async: true,\n key,\n tool: t.name,\n started_at: startedAt,\n deadline_ms: deadlineMs,\n hint: `Call tool_result_get with key=\"${key}\" to retrieve the result. Pass wait_ms to short-poll.`,\n });\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 { 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","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: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\");","// In-process keyed store for async tool results.\n//\n// When the wallclock wrapper sees `async_run: true` on a tool call it\n// returns immediately with a key, kicks the real invocation off in the\n// background, and parks the eventual result here. The agent later\n// retrieves the result via the `tool_result_get` built-in.\n//\n// Scope is deliberately per-process, in-memory:\n// - The data lives only as long as the Next.js server process. A\n// restart wipes both the agent's in-context keys and these results\n// simultaneously, so we can't end up with the LLM holding a key\n// that survived the value.\n// - No on-disk persistence means no schema migration, no PII spill,\n// no risk of leaking long-running secrets between sessions.\n//\n// Memory hygiene:\n// - TTL (DEFAULT_TTL_MS) caps how long a finished result hangs around\n// unread. A background sweeper runs on a slow interval.\n// - Cap on concurrent entries (MAX_ENTRIES). When exceeded, the\n// oldest *finished* entry is evicted first; if none, the oldest\n// pending entry is dropped (with a console warn).\n\nimport crypto from \"node:crypto\";\n\nexport type AsyncStatus = \"pending\" | \"done\" | \"error\";\n\nexport interface AsyncResultRecord {\n key: string;\n tool: string;\n status: AsyncStatus;\n started_at: number;\n finished_at: number | null;\n /** Stringified tool result. Tools return JSON strings; we keep that. */\n result: string | null;\n /** Plain message when the underlying call threw. */\n error: string | null;\n}\n\n/** How long a finished result stays around if nobody reads it. */\nexport const DEFAULT_TTL_MS = 10 * 60 * 1000;\n\n/** Soft cap on total entries (pending + finished). */\nexport const MAX_ENTRIES = 256;\n\n/** How often the background sweeper runs. */\nconst SWEEP_INTERVAL_MS = 60 * 1000;\n\nconst STORE = new Map<string, AsyncResultRecord>();\n\nlet sweeper: ReturnType<typeof setInterval> | null = null;\n\nfunction ensureSweeper(): void {\n if (sweeper) return;\n sweeper = setInterval(() => {\n sweepExpired(DEFAULT_TTL_MS);\n }, SWEEP_INTERVAL_MS);\n (sweeper as unknown as { unref?: () => void }).unref?.();\n}\n\n/**\n * Carve out a slot for a new async tool call and return its key.\n * The key is opaque and URL-safe — the agent treats it as a token.\n */\nexport function startAsyncCall(tool: string): string {\n ensureSweeper();\n enforceCap();\n const key = `async_${crypto.randomBytes(8).toString(\"hex\")}`;\n STORE.set(key, {\n key,\n tool,\n status: \"pending\",\n started_at: Date.now(),\n finished_at: null,\n result: null,\n error: null,\n });\n return key;\n}\n\n/** Mark a pending call as completed successfully. */\nexport function completeAsyncCall(key: string, result: string): void {\n const rec = STORE.get(key);\n if (!rec) return;\n rec.status = \"done\";\n rec.result = result;\n rec.finished_at = Date.now();\n}\n\n/** Mark a pending call as failed. */\nexport function failAsyncCall(key: string, err: unknown): void {\n const rec = STORE.get(key);\n if (!rec) return;\n rec.status = \"error\";\n rec.error = err instanceof Error ? err.message : String(err);\n rec.finished_at = Date.now();\n}\n\n/** Read a record without consuming it. */\nexport function getAsyncResult(key: string): AsyncResultRecord | null {\n return STORE.get(key) ?? null;\n}\n\n/** Read and immediately delete a record. */\nexport function consumeAsyncResult(key: string): AsyncResultRecord | null {\n const rec = STORE.get(key);\n if (!rec) return null;\n STORE.delete(key);\n return rec;\n}\n\n/** Snapshot of all current records (newest first). For tool_result_list. */\nexport function listAsyncResults(): AsyncResultRecord[] {\n return [...STORE.values()].sort((a, b) => b.started_at - a.started_at);\n}\n\n/**\n * Drop finished entries older than `ttlMs` (measured from `finished_at`).\n * Pending entries are never expired here — a stuck tool would otherwise\n * vanish out from under the agent.\n */\nexport function sweepExpired(ttlMs: number): number {\n const now = Date.now();\n let removed = 0;\n for (const [k, r] of STORE) {\n if (r.status === \"pending\") continue;\n if (r.finished_at == null) continue;\n if (now - r.finished_at >= ttlMs) {\n STORE.delete(k);\n removed++;\n }\n }\n return removed;\n}\n\nfunction enforceCap(): void {\n if (STORE.size < MAX_ENTRIES) return;\n // Prefer evicting finished entries (oldest first). Only if every entry\n // is pending do we drop a pending one.\n const sorted = [...STORE.values()].sort((a, b) => a.started_at - b.started_at);\n const finished = sorted.find((r) => r.status !== \"pending\");\n const victim = finished ?? sorted[0];\n if (!victim) return;\n STORE.delete(victim.key);\n if (!finished) {\n console.warn(\n `[async-results] evicted pending entry ${victim.key} (tool=${victim.tool}) ` +\n `to make room — STORE cap of ${MAX_ENTRIES} hit.`,\n );\n }\n}\n\n/** Test-only helper. */\nexport function __resetStore(): void {\n STORE.clear();\n if (sweeper) {\n clearInterval(sweeper);\n sweeper = null;\n }\n}\n\n/** Test-only helper. */\nexport function __backdateFinished(key: string, finishedAt: number): void {\n const rec = STORE.get(key);\n if (rec) rec.finished_at = finishedAt;\n}\n"],"names":["z","tool","startAsyncCall","completeAsyncCall","failAsyncCall","DEFAULT_DEADLINE_MS","DEFAULT_MAX_DEADLINE_MS","getMaxDeadlineMs","raw","process","env","JARELA_TOOL_MAX_DEADLINE_MS","n","Number","isFinite","Math","floor","DEADLINE_DESCRIPTION","ASYNC_RUN_DESCRIPTION","wrapWithWallclock","t","schema","extendedSchema","ZodObject","extend","deadline_ms","number","int","positive","optional","describe","async_run","boolean","wrappedFunc","args","config","requested","readDeadlineMs","ceiling","deadlineMs","min","console","warn","name","asyncRun","readAsyncRun","innerArgs","stripWrapperFields","runAsync","timer","timeoutPromise","Promise","resolve","setTimeout","JSON","stringify","ok","error_code","message","unref","work","invoke","race","clearTimeout","rebuilt","description","v","_d","_a","rest","key","startedAt","Date","now","settled","result","err","async","started_at","hint","__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","parsed","safeParse","success","issues","getDb","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","PATCH","crypto","DEFAULT_TTL_MS","MAX_ENTRIES","SWEEP_INTERVAL_MS","STORE","sweeper","ensureSweeper","setInterval","sweepExpired","enforceCap","randomBytes","toString","finished_at","rec","String","getAsyncResult","consumeAsyncResult","delete","listAsyncResults","ttlMs","removed","k","size","sorted","finished","find","victim","__resetStore","clearInterval","__backdateFinished","finishedAt"],"sourceRoot":"","ignoreList":[0,3,5,12,18,26,29,37]}
@@ -362,8 +362,8 @@ var response_cache = __webpack_require__(37527);
362
362
  var bus = __webpack_require__(76445);
363
363
  // EXTERNAL MODULE: ./lib/scheduler/index.ts
364
364
  var scheduler = __webpack_require__(11781);
365
- // EXTERNAL MODULE: ./lib/bridges/runtime.ts + 4 modules
366
- var runtime = __webpack_require__(18135);
365
+ // EXTERNAL MODULE: ./lib/bridges/runtime.ts + 5 modules
366
+ var runtime = __webpack_require__(32539);
367
367
  // EXTERNAL MODULE: ./lib/api/sse.ts
368
368
  var sse = __webpack_require__(53854);
369
369
  // EXTERNAL MODULE: ./lib/crypto/master-key.ts + 1 modules
@@ -921,7 +921,7 @@ module.exports = require("events");
921
921
  var __webpack_require__ = require("../../../../webpack-runtime.js");
922
922
  __webpack_require__.C(exports);
923
923
  var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
924
- var __webpack_exports__ = __webpack_require__.X(0, [4741,1050,2497,9883,513,7226,6299,1382,8571,6505,2082,7500,3175,4631,9983,3524,5937,9137,239,8135], () => (__webpack_exec__(89582)));
924
+ var __webpack_exports__ = __webpack_require__.X(0, [4741,1050,2497,9883,513,7226,6299,1382,8571,6505,2082,7500,3175,4631,9983,3524,5937,9137,239,2539], () => (__webpack_exec__(89582)));
925
925
  module.exports = __webpack_exports__;
926
926
 
927
927
  })();