fleetlens 0.16.1 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/web/.next/BUILD_ID +1 -1
- package/app/apps/web/.next/build-manifest.json +3 -3
- package/app/apps/web/.next/prerender-manifest.json +3 -3
- package/app/apps/web/.next/server/app/_global-error.html +1 -1
- package/app/apps/web/.next/server/app/_global-error.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/agent/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/changelog/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/day/[date]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/day/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/digest/[date]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/digest/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/insights/[key]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/insights/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/parallelism/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/print/[key]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/runs/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/team/onboarding/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/team/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/usage/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__02faosk._.js +3 -3
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__09cgmam._.js +2 -2
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0tk8p3d._.js +2 -2
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0u6pamj._.js +2 -2
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__12jomao._.js +2 -2
- package/app/apps/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0sr4wr_.js +1 -1
- package/app/apps/web/.next/server/chunks/packages_parser_dist_06d9se1._.js +1 -1
- package/app/apps/web/.next/server/chunks/packages_parser_dist_10ihc3~._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/_0k8yioi._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/apps_web_app_sessions_[id]_session-view_tsx_0-9t5~.._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/apps_web_app_sessions_sessions-grid_tsx_0bri5x.._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0n7_p1d._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js +1 -1
- package/app/apps/web/.next/server/chunks/ssr/packages_parser_dist_0mx_509._.js +1 -1
- package/app/apps/web/.next/server/middleware-build-manifest.js +3 -3
- package/app/apps/web/.next/server/middleware-manifest.json +5 -5
- package/app/apps/web/.next/server/pages/500.html +1 -1
- package/app/apps/web/.next/server/server-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/server-reference-manifest.json +1 -1
- package/app/apps/web/.next/static/chunks/0jes0m38a9ib_.js +14 -0
- package/app/apps/web/.next/static/chunks/{07bzlfv97o1ig.js → 0p5ee8wje3zi~.js} +1 -1
- package/app/apps/web/.next/static/chunks/{0awkd5df28gvj.js → 0~uugvb4izjd2.js} +1 -1
- package/app/apps/web/app/sessions/[id]/session-view.tsx +6 -2
- package/app/apps/web/app/sessions/sessions-grid.tsx +5 -1
- package/app/apps/web/lib/agent/run.ts +24 -5
- package/app/apps/web/lib/changelog-data.generated.ts +1 -1
- package/app/apps/web/package.json +1 -1
- package/app/apps/web/tsconfig.tsbuildinfo +1 -1
- package/dist/daemon-worker.js +140 -17
- package/dist/index.js +148 -25
- package/menubar/FleetlensMenubar.app/Contents/Info.plist +2 -2
- package/menubar/FleetlensMenubar.app/Contents/MacOS/FleetlensMenubar +0 -0
- package/package.json +1 -1
- package/app/apps/web/.next/static/chunks/0at6brbse8wn2.js +0 -14
- /package/app/apps/web/.next/static/{d1mwRtSMG-R7wb8o9KxM3 → q_fQaCe85j7F9VawBRe81}/_buildManifest.js +0 -0
- /package/app/apps/web/.next/static/{d1mwRtSMG-R7wb8o9KxM3 → q_fQaCe85j7F9VawBRe81}/_clientMiddlewareManifest.js +0 -0
- /package/app/apps/web/.next/static/{d1mwRtSMG-R7wb8o9KxM3 → q_fQaCe85j7F9VawBRe81}/_ssgManifest.js +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
globalThis.__RSC_MANIFEST = globalThis.__RSC_MANIFEST || {};
|
|
2
|
-
globalThis.__RSC_MANIFEST["/usage/page"] = {"moduleLoading":{"prefix":"","crossOrigin":null},"clientModules":{"[project]/node_modules/next/dist/esm/client/components/layout-router.js <module evaluation>":{"id":39756,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/layout-router.js":{"id":39756,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/render-from-template-context.js <module evaluation>":{"id":37457,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":37457,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/client-page.js <module evaluation>":{"id":47257,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/client-page.js":{"id":47257,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/client-segment.js <module evaluation>":{"id":92825,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/client-segment.js":{"id":92825,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js <module evaluation>":{"id":68017,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js":{"id":68017,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/lib/framework/boundary-components.js <module evaluation>":{"id":97367,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/lib/framework/boundary-components.js":{"id":97367,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js <module evaluation>":{"id":27201,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js":{"id":27201,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/sidebar.tsx <module evaluation>":{"id":86566,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/sidebar.tsx":{"id":86566,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/live-refresher.tsx <module evaluation>":{"id":51878,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/live-refresher.tsx":{"id":51878,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/live-sessions-widget.tsx <module evaluation>":{"id":23884,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/live-sessions-widget.tsx":{"id":23884,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/job-queue-widget.tsx <module evaluation>":{"id":62887,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/job-queue-widget.tsx":{"id":62887,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/menubar-install-banner.tsx <module evaluation>":{"id":7879,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/menubar-install-banner.tsx":{"id":7879,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/client/app-dir/link.js <module evaluation>":{"id":22016,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js","/_next/static/chunks/0rrcj195v1nd..js"],"async":false},"[project]/node_modules/next/dist/client/app-dir/link.js":{"id":22016,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js","/_next/static/chunks/0rrcj195v1nd..js"],"async":false},"[project]/node_modules/next/dist/client/components/builtin/global-error.js <module evaluation>":{"id":68027,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/node_modules/next/dist/client/components/builtin/global-error.js":{"id":68027,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js"],"async":false},"[project]/apps/web/components/usage-charts-dashboard.tsx <module evaluation>":{"id":36373,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js","/_next/static/chunks/0rrcj195v1nd..js"],"async":false},"[project]/apps/web/components/usage-charts-dashboard.tsx":{"id":36373,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0at6brbse8wn2.js","/_next/static/chunks/0rrcj195v1nd..js"],"async":false}},"ssrModuleMapping":{"39756":{"*":{"id":2420,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"37457":{"*":{"id":24017,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"47257":{"*":{"id":77682,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"92825":{"*":{"id":97296,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"68017":{"*":{"id":61660,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"97367":{"*":{"id":90574,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"27201":{"*":{"id":60704,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"86566":{"*":{"id":44422,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"51878":{"*":{"id":46069,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"23884":{"*":{"id":1568,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"62887":{"*":{"id":22309,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"7879":{"*":{"id":10605,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"22016":{"*":{"id":38246,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js","server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_12vc-v-._.js","server/chunks/ssr/apps_web_components_usage-charts-dashboard_tsx_0bgr_uv._.js"],"async":false}},"68027":{"*":{"id":40622,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js","server/chunks/ssr/node_modules_09w7yel._.js"],"async":false}},"36373":{"*":{"id":64405,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js","server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_12vc-v-._.js","server/chunks/ssr/apps_web_components_usage-charts-dashboard_tsx_0bgr_uv._.js"],"async":false}}},"edgeSSRModuleMapping":{},"rscModuleMapping":{"39756":{"*":{"id":26768,"name":"*","chunks":[],"async":false}},"37457":{"*":{"id":17910,"name":"*","chunks":[],"async":false}},"47257":{"*":{"id":92977,"name":"*","chunks":[],"async":false}},"92825":{"*":{"id":48552,"name":"*","chunks":[],"async":false}},"68017":{"*":{"id":83919,"name":"*","chunks":[],"async":false}},"97367":{"*":{"id":24150,"name":"*","chunks":[],"async":false}},"27201":{"*":{"id":40771,"name":"*","chunks":[],"async":false}},"86566":{"*":{"id":10398,"name":"*","chunks":[],"async":false}},"51878":{"*":{"id":11272,"name":"*","chunks":[],"async":false}},"23884":{"*":{"id":62615,"name":"*","chunks":[],"async":false}},"62887":{"*":{"id":5900,"name":"*","chunks":[],"async":false}},"7879":{"*":{"id":46147,"name":"*","chunks":[],"async":false}},"22016":{"*":{"id":84707,"name":"*","chunks":[],"async":false}},"68027":{"*":{"id":82509,"name":"*","chunks":[],"async":false}},"36373":{"*":{"id":51071,"name":"*","chunks":[],"async":false}}},"edgeRscModuleMapping":{},"entryCSSFiles":{"[project]/apps/web/app/layout":[{"path":"static/chunks/0d~7p_ye7v7_5.css","inlined":false}],"[project]/node_modules/next/dist/client/components/builtin/global-error":[{"path":"static/chunks/0d~7p_ye7v7_5.css","inlined":false}],"[project]/apps/web/app/usage/page":[{"path":"static/chunks/0d~7p_ye7v7_5.css","inlined":false}]},"entryJSFiles":{"[project]/apps/web/app/layout":["static/chunks/0389wb_f0j78j.js","static/chunks/0at6brbse8wn2.js"],"[project]/node_modules/next/dist/client/components/builtin/global-error":["static/chunks/0389wb_f0j78j.js","static/chunks/0at6brbse8wn2.js"],"[project]/apps/web/app/usage/page":["static/chunks/0389wb_f0j78j.js","static/chunks/0at6brbse8wn2.js","static/chunks/0rrcj195v1nd..js"]}};
|
|
2
|
+
globalThis.__RSC_MANIFEST["/usage/page"] = {"moduleLoading":{"prefix":"","crossOrigin":null},"clientModules":{"[project]/node_modules/next/dist/esm/client/components/layout-router.js <module evaluation>":{"id":39756,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/layout-router.js":{"id":39756,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/render-from-template-context.js <module evaluation>":{"id":37457,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/render-from-template-context.js":{"id":37457,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/client-page.js <module evaluation>":{"id":47257,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/client-page.js":{"id":47257,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/client-segment.js <module evaluation>":{"id":92825,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/client-segment.js":{"id":92825,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js <module evaluation>":{"id":68017,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/client/components/http-access-fallback/error-boundary.js":{"id":68017,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/lib/framework/boundary-components.js <module evaluation>":{"id":97367,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/lib/framework/boundary-components.js":{"id":97367,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js <module evaluation>":{"id":27201,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/esm/lib/metadata/generate/icon-mark.js":{"id":27201,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/sidebar.tsx <module evaluation>":{"id":86566,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/sidebar.tsx":{"id":86566,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/live-refresher.tsx <module evaluation>":{"id":51878,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/live-refresher.tsx":{"id":51878,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/live-sessions-widget.tsx <module evaluation>":{"id":23884,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/live-sessions-widget.tsx":{"id":23884,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/job-queue-widget.tsx <module evaluation>":{"id":62887,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/job-queue-widget.tsx":{"id":62887,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/menubar-install-banner.tsx <module evaluation>":{"id":7879,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/menubar-install-banner.tsx":{"id":7879,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/client/app-dir/link.js <module evaluation>":{"id":22016,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js","/_next/static/chunks/0rrcj195v1nd..js"],"async":false},"[project]/node_modules/next/dist/client/app-dir/link.js":{"id":22016,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js","/_next/static/chunks/0rrcj195v1nd..js"],"async":false},"[project]/node_modules/next/dist/client/components/builtin/global-error.js <module evaluation>":{"id":68027,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/node_modules/next/dist/client/components/builtin/global-error.js":{"id":68027,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js"],"async":false},"[project]/apps/web/components/usage-charts-dashboard.tsx <module evaluation>":{"id":36373,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js","/_next/static/chunks/0rrcj195v1nd..js"],"async":false},"[project]/apps/web/components/usage-charts-dashboard.tsx":{"id":36373,"name":"*","chunks":["/_next/static/chunks/0389wb_f0j78j.js","/_next/static/chunks/0jes0m38a9ib_.js","/_next/static/chunks/0rrcj195v1nd..js"],"async":false}},"ssrModuleMapping":{"39756":{"*":{"id":2420,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"37457":{"*":{"id":24017,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"47257":{"*":{"id":77682,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"92825":{"*":{"id":97296,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"68017":{"*":{"id":61660,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"97367":{"*":{"id":90574,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"27201":{"*":{"id":60704,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"86566":{"*":{"id":44422,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"51878":{"*":{"id":46069,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"23884":{"*":{"id":1568,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"62887":{"*":{"id":22309,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"7879":{"*":{"id":10605,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js"],"async":false}},"22016":{"*":{"id":38246,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js","server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_12vc-v-._.js","server/chunks/ssr/apps_web_components_usage-charts-dashboard_tsx_0bgr_uv._.js"],"async":false}},"68027":{"*":{"id":40622,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js","server/chunks/ssr/node_modules_09w7yel._.js"],"async":false}},"36373":{"*":{"id":64405,"name":"*","chunks":["server/chunks/ssr/[root-of-the-server]__0f3q8gt._.js","server/chunks/ssr/node_modules_next_0w2y7fz._.js","server/chunks/ssr/apps_web_components_0x014hn._.js","server/chunks/ssr/node_modules_next_dist_0t-hj0x._.js","server/chunks/ssr/node_modules_next_dist_0e1izl_._.js","server/chunks/ssr/apps_web_lib_changelog_ts_0nb5_-s._.js","server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_12vc-v-._.js","server/chunks/ssr/apps_web_components_usage-charts-dashboard_tsx_0bgr_uv._.js"],"async":false}}},"edgeSSRModuleMapping":{},"rscModuleMapping":{"39756":{"*":{"id":26768,"name":"*","chunks":[],"async":false}},"37457":{"*":{"id":17910,"name":"*","chunks":[],"async":false}},"47257":{"*":{"id":92977,"name":"*","chunks":[],"async":false}},"92825":{"*":{"id":48552,"name":"*","chunks":[],"async":false}},"68017":{"*":{"id":83919,"name":"*","chunks":[],"async":false}},"97367":{"*":{"id":24150,"name":"*","chunks":[],"async":false}},"27201":{"*":{"id":40771,"name":"*","chunks":[],"async":false}},"86566":{"*":{"id":10398,"name":"*","chunks":[],"async":false}},"51878":{"*":{"id":11272,"name":"*","chunks":[],"async":false}},"23884":{"*":{"id":62615,"name":"*","chunks":[],"async":false}},"62887":{"*":{"id":5900,"name":"*","chunks":[],"async":false}},"7879":{"*":{"id":46147,"name":"*","chunks":[],"async":false}},"22016":{"*":{"id":84707,"name":"*","chunks":[],"async":false}},"68027":{"*":{"id":82509,"name":"*","chunks":[],"async":false}},"36373":{"*":{"id":51071,"name":"*","chunks":[],"async":false}}},"edgeRscModuleMapping":{},"entryCSSFiles":{"[project]/apps/web/app/layout":[{"path":"static/chunks/0d~7p_ye7v7_5.css","inlined":false}],"[project]/node_modules/next/dist/client/components/builtin/global-error":[{"path":"static/chunks/0d~7p_ye7v7_5.css","inlined":false}],"[project]/apps/web/app/usage/page":[{"path":"static/chunks/0d~7p_ye7v7_5.css","inlined":false}]},"entryJSFiles":{"[project]/apps/web/app/layout":["static/chunks/0389wb_f0j78j.js","static/chunks/0jes0m38a9ib_.js"],"[project]/node_modules/next/dist/client/components/builtin/global-error":["static/chunks/0389wb_f0j78j.js","static/chunks/0jes0m38a9ib_.js"],"[project]/apps/web/app/usage/page":["static/chunks/0389wb_f0j78j.js","static/chunks/0jes0m38a9ib_.js","static/chunks/0rrcj195v1nd..js"]}};
|
|
3
3
|
|
|
@@ -17,14 +17,14 @@ Rules:
|
|
|
17
17
|
- Cite sessions inline as markdown links using each hit's url, e.g. [fix daemon crash](/sessions/abc-123). Cite the sessions you actually drew from — not every hit. These session urls (and real web URLs from tool results) are the ONLY things you may link; never link file names, paths, or documents — mention them as plain text.
|
|
18
18
|
- When asked for a prompt / context pack / handoff, output it as a single fenced code block tagged \`prompt\` (\`\`\`prompt … \`\`\`). Make it self-contained: goal, relevant repo/file paths, decisions already made, known gotchas, and what to do next. No session links inside the block — the next agent can't open them.
|
|
19
19
|
- Be concise. Lead with the answer, then supporting detail. Don't narrate your tool use.
|
|
20
|
-
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,n.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,n.existsSync)(o()))return[];let e=[];for(let t of(0,n.readdirSync)(o())){if(!t.endsWith(".json"))continue;let n=d(t.slice(0,-5));n&&e.push({id:n.id,title:n.title,updated_at:n.updated_at,status:n.status,messageCount:n.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,d,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,u],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,d=e,u=0,m={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,m);let f=e=>{if(m.discarded)return;let t=Date.now();if(e||!(t-u<750)){u=t;try{l(d)}catch{}}},g=e=>{let t={seq:++i,...e};for(let e of(m.events.push(t),d=c(d,t),f("delta"!==t.type),m.subscribers))try{e(t)}catch{}},y=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],
|
|
20
|
+
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,n.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,n.existsSync)(o()))return[];let e=[];for(let t of(0,n.readdirSync)(o())){if(!t.endsWith(".json"))continue;let n=d(t.slice(0,-5));n&&e.push({id:n.id,title:n.title,updated_at:n.updated_at,status:n.status,messageCount:n.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,d,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,u],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,d=e,u=0,m={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,m);let f=e=>{if(m.discarded)return;let t=Date.now();if(e||!(t-u<750)){u=t;try{l(d)}catch{}}},g=e=>{let t={seq:++i,...e};for(let e of(m.events.push(t),d=c(d,t),f("delta"!==t.type),m.subscribers))try{e(t)}catch{}},y=(0,a.cclensPath)("agent-runtime");(0,n.mkdirSync)(y,{recursive:!0});let x=(0,s.join)(y,"settings.json");(0,n.writeFileSync)(x,JSON.stringify({hooks:{SessionStart:[{hooks:[{type:"command",command:'node -e "setTimeout(()=>{},2000)"'}]}]}}));let v=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--settings",x,"--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],_=function(e){let t=e.slice(-12).map(e=>({role:e.role,text:e.text.length>4e3?e.text.slice(0,4e3)+"…":e.text})),n=t.pop();if(!n)return"";if(0===t.length)return n.text;let s=t.map(e=>`${"user"===e.role?"User":"You (assistant)"}: ${e.text}`).join("\n\n");return`Conversation so far:
|
|
21
21
|
|
|
22
22
|
${s}
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
User's new message: ${n.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),
|
|
26
|
+
User's new message: ${n.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),w=setTimeout(()=>{g({type:"error",message:"timed out after 5 minutes"}),m.kill()},3e5),R=()=>{clearTimeout(w),f(!0),h.runs.delete(e.id)},S=e=>{var i,l,u;let c,h,f,x,w;if(m.stoppedByUser||"running"!==d.status){m.stoppedByUser&&"running"===d.status&&g({type:"error",message:"stopped by user"}),R();return}let k=(i=o.model,l=_.length,u=p(),h=(0,a.cclensPath)("llm-runs"),f=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,x=(0,s.join)(h,`${f}.jsonl`),(w=(e,t=!1)=>{try{let s=JSON.stringify(e)+"\n";t?((0,n.mkdirSync)(h,{recursive:!0}),(0,n.writeFileSync)(x,s)):(0,n.appendFileSync)(x,s)}catch{}})({_meta:{type:"start",run_id:f,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),w({_meta:{type:"payload",run_id:f,system_prompt:u,user_prompt:_}}),{line:e=>{try{(0,n.appendFileSync)(x,e+"\n")}catch{}},end:e=>w({_meta:{type:"end",run_id:f,ts:new Date().toISOString(),...e}})}),b=Date.now(),C=(0,t.spawn)("claude",v,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:y});m.kill=()=>{try{C.kill("SIGTERM")}catch{}},C.stdin.write(_),C.stdin.end();let E=!1,A="",N="",T=!1,q=new Set,O=new Map,U=t=>{let n;try{n=JSON.parse(t)}catch{return}if("stream_event"!==n.type&&k.line(t),"system"===n.type&&"init"===n.subtype){let t=n.mcp_servers,s=t?.find(e=>"fleetlens"===e.name);if(s&&"connected"!==s.status){E=!0,k.end({runtime:"detached",elapsed_ms:Date.now()-b,mcp_status:s.status,retried:e<3});try{C.kill("SIGTERM")}catch{}e<3?setTimeout(()=>S(e+1),750):(g({type:"error",message:`session tools failed to connect (mcp status: ${s.status}) — try again`}),R())}return}if("stream_event"===n.type){let e=n.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&q.add(e.index),g({type:"delta",text:t.text}))}return}if("assistant"===n.type){let e=n.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||q.has(t)||g({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var n;let t,s="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");O.set(s,r),g({type:"tool",id:s,name:r,input:(t=JSON.stringify(n=e.input)??"{}").length<=300?n:{_truncated:t.slice(0,300)+"…"}})}}),q=new Set;return}if("user"===n.type){let e=n.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",n=e.content,s=Array.isArray(n)?n.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof n?n:"";g({type:"tool_result",id:t,name:O.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(s),isError:!0===e.is_error})}return}"result"===n.type&&(T=!0,c=n.usage,g({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},j=new TextDecoder("utf-8");C.stdout.on("data",e=>{if(E)return;let t=(N+=j.decode(e,{stream:!0})).split("\n");for(let e of(N=t.pop()??"",t)){let t=e.trim();t&&!E&&U(t)}}),C.stderr.on("data",e=>{A.length<4e3&&(A+=e.toString("utf8"))}),C.on("close",e=>{E||(T||"running"!==d.status||g({type:"error",message:m.stoppedByUser?"stopped by user":A.trim().slice(0,400)||`claude exited with code ${e}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),R())}),C.on("error",e=>{E||(g({type:"error",message:`Failed to spawn claude: ${e.message}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:-1,error:e.message}),R())})};S(1)}],45092)},37483,e=>{"use strict";var t=e.i(47909),n=e.i(74017),s=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),m=e.i(74838),f=e.i(10372),g=e.i(93695);e.i(52474);var y=e.i(220),x=e.i(84497),v=e.i(45092);async function _(e,{params:t}){let{id:n}=await t,s=Number(new URL(e.url).searchParams.get("after")??0)||0,r=new TextEncoder;return new Response(new ReadableStream({start(t){let a=!1,o=e=>{if(!a)try{t.enqueue(r.encode(`data: ${JSON.stringify(e)}
|
|
27
27
|
|
|
28
|
-
`))}catch{a=!0}},i=()=>{if(!a){a=!0,clearInterval(l);try{t.close()}catch{}}},l=setInterval(()=>{if(!a)try{t.enqueue(r.encode(": ping\n\n"))}catch{a=!0}},2e4),d=(0,v.getRun)(n);if(!d){let e=(0,x.readChat)(n);o({type:"sync",status:e?(0,v.reconcileChat)(e).status:"gone"}),i();return}let u=e=>{e.seq>s&&o(e),("done"===e.type||"error"===e.type)&&(d.subscribers.delete(u),i())};for(let e of d.events)u(e);a||d.subscribers.add(u),e.signal.addEventListener("abort",()=>{d.subscribers.delete(u),i()})}}),{headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})}e.s(["GET",0,_,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],43469);var w=e.i(43469);let R=new t.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/agent/chats/[id]/events/route",pathname:"/api/agent/chats/[id]/events",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/[id]/events/route.ts",nextConfigOutput:"standalone",userland:w,...{}}),{workAsyncStorage:S,workUnitAsyncStorage:k,serverHooks:b}=R;async function C(e,t,s){s.requestMeta&&(0,r.setRequestMeta)(e,s.requestMeta),R.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/agent/chats/[id]/events/route";x=x.replace(/\/index$/,"")||"/";let v=await R.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!v)return t.statusCode=400,t.end("Bad Request"),null==s.waitUntil||s.waitUntil.call(s,Promise.resolve()),null;let{buildId:_,params:w,nextConfig:S,parsedUrl:k,isDraftMode:b,prerenderManifest:C,routerServerContext:E,isOnDemandRevalidate:A,revalidateOnlyGenerated:
|
|
28
|
+
`))}catch{a=!0}},i=()=>{if(!a){a=!0,clearInterval(l);try{t.close()}catch{}}},l=setInterval(()=>{if(!a)try{t.enqueue(r.encode(": ping\n\n"))}catch{a=!0}},2e4),d=(0,v.getRun)(n);if(!d){let e=(0,x.readChat)(n);o({type:"sync",status:e?(0,v.reconcileChat)(e).status:"gone"}),i();return}let u=e=>{e.seq>s&&o(e),("done"===e.type||"error"===e.type)&&(d.subscribers.delete(u),i())};for(let e of d.events)u(e);a||d.subscribers.add(u),e.signal.addEventListener("abort",()=>{d.subscribers.delete(u),i()})}}),{headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})}e.s(["GET",0,_,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],43469);var w=e.i(43469);let R=new t.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/agent/chats/[id]/events/route",pathname:"/api/agent/chats/[id]/events",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/[id]/events/route.ts",nextConfigOutput:"standalone",userland:w,...{}}),{workAsyncStorage:S,workUnitAsyncStorage:k,serverHooks:b}=R;async function C(e,t,s){s.requestMeta&&(0,r.setRequestMeta)(e,s.requestMeta),R.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/agent/chats/[id]/events/route";x=x.replace(/\/index$/,"")||"/";let v=await R.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!v)return t.statusCode=400,t.end("Bad Request"),null==s.waitUntil||s.waitUntil.call(s,Promise.resolve()),null;let{buildId:_,params:w,nextConfig:S,parsedUrl:k,isDraftMode:b,prerenderManifest:C,routerServerContext:E,isOnDemandRevalidate:A,revalidateOnlyGenerated:N,resolvedPathname:T,clientReferenceManifest:q,serverActionsManifest:O}=v,U=(0,i.normalizeAppPath)(x),j=!!(C.dynamicRoutes[U]||C.routes[T]),I=async()=>((null==E?void 0:E.render404)?await E.render404(e,t,k,!1):t.end("This page could not be found"),null);if(j&&!b){let e=!!C.routes[T],t=C.dynamicRoutes[U];if(t&&!1===t.fallback&&!e){if(S.adapterPath)return await I();throw new g.NoFallbackError}}let D=null;!j||R.isDev||b||(D="/index"===(D=T)?"/":D);let $=!0===R.isDev||!j,P=j&&!$;O&&q&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:q,serverActionsManifest:O});let M=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),B=!!(null==E?void 0:E.isWrappedByNextServer),L=!!(0,r.getRequestMeta)(e,"minimalMode"),J=(0,r.getRequestMeta)(e,"incrementalCache")||await R.getIncrementalCache(e,S,C,L);null==J||J.resetRequestCache(),globalThis.__incrementalCache=J;let G={params:w,previewProps:C.preview,renderOpts:{experimental:{authInterrupts:!!S.experimental.authInterrupts},cacheComponents:!!S.cacheComponents,supportsDynamicResponse:$,incrementalCache:J,cacheLifeProfiles:S.cacheLife,waitUntil:s.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,n,s,r)=>R.onRequestError(e,t,s,r,E)},sharedContext:{buildId:_}},K=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),Y=d.NextRequestAdapter.fromNodeNextRequest(K,(0,d.signalFromNodeResponse)(t));try{let r,o=async e=>R.handle(Y,G).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let n=F.getRootSpanAttributes();if(!n)return;if(n.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${n.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let s=n.get("next.route");if(s){let t=`${M} ${s}`;e.setAttributes({"next.route":s,"http.route":s,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",s),r.updateName(t))}else e.updateName(`${M} ${x}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:n})=>{try{if(!L&&A&&N&&!n)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=G.renderOpts.fetchMetrics;let i=G.renderOpts.pendingWaitUntil;i&&s.waitUntil&&(s.waitUntil(i),i=void 0);let l=G.renderOpts.collectedTags;if(!j)return await (0,p.sendResponse)(K,W,a,G.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[f.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let n=void 0!==G.renderOpts.collectedRevalidate&&!(G.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&G.renderOpts.collectedRevalidate,s=void 0===G.renderOpts.collectedExpire||G.renderOpts.collectedExpire>=f.INFINITE_CACHE?void 0:G.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:n,expire:s}}}}catch(t){throw(null==n?void 0:n.isStale)&&await R.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),t}},d=await R.handleResponse({req:e,nextConfig:S,cacheKey:D,routeKind:n.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:N,responseGenerator:l,waitUntil:s.waitUntil,isMinimalMode:L});if(!j)return null;if((null==d||null==(a=d.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",A?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return L&&j||u.delete(f.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(K,W,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:a.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!B))}catch(t){if(t instanceof g.NoFallbackError||await R.onRequestError(e,t,{routerKind:"App Router",routePath:U,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),j)throw t;return await (0,p.sendResponse)(K,W,new Response(null,{status:500})),null}}e.s(["handler",0,C,"patchFetch",0,function(){return(0,s.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:k})},"routeModule",0,R,"serverHooks",0,b,"workAsyncStorage",0,S,"workUnitAsyncStorage",0,k],37483)}];
|
|
29
29
|
|
|
30
30
|
//# sourceMappingURL=%5Broot-of-the-server%5D__02faosk._.js.map
|
|
@@ -17,12 +17,12 @@ Rules:
|
|
|
17
17
|
- Cite sessions inline as markdown links using each hit's url, e.g. [fix daemon crash](/sessions/abc-123). Cite the sessions you actually drew from — not every hit. These session urls (and real web URLs from tool results) are the ONLY things you may link; never link file names, paths, or documents — mention them as plain text.
|
|
18
18
|
- When asked for a prompt / context pack / handoff, output it as a single fenced code block tagged \`prompt\` (\`\`\`prompt … \`\`\`). Make it self-contained: goal, relevant repo/file paths, decisions already made, known gotchas, and what to do next. No session links inside the block — the next agent can't open them.
|
|
19
19
|
- Be concise. Lead with the answer, then supporting detail. Don't narrate your tool use.
|
|
20
|
-
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,s.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,s.existsSync)(o()))return[];let e=[];for(let t of(0,s.readdirSync)(o())){if(!t.endsWith(".json"))continue;let s=u(t.slice(0,-5));s&&e.push({id:s.id,title:s.title,updated_at:s.updated_at,status:s.status,messageCount:s.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,u,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,d],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,u=e,d=0,g={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,g);let m=e=>{if(g.discarded)return;let t=Date.now();if(e||!(t-d<750)){d=t;try{l(u)}catch{}}},f=e=>{let t={seq:++i,...e};for(let e of(g.events.push(t),u=c(u,t),m("delta"!==t.type),g.subscribers))try{e(t)}catch{}},y=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],
|
|
20
|
+
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,s.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,s.existsSync)(o()))return[];let e=[];for(let t of(0,s.readdirSync)(o())){if(!t.endsWith(".json"))continue;let s=u(t.slice(0,-5));s&&e.push({id:s.id,title:s.title,updated_at:s.updated_at,status:s.status,messageCount:s.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,u,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,d],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,u=e,d=0,g={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,g);let m=e=>{if(g.discarded)return;let t=Date.now();if(e||!(t-d<750)){d=t;try{l(u)}catch{}}},f=e=>{let t={seq:++i,...e};for(let e of(g.events.push(t),u=c(u,t),m("delta"!==t.type),g.subscribers))try{e(t)}catch{}},y=(0,a.cclensPath)("agent-runtime");(0,s.mkdirSync)(y,{recursive:!0});let _=(0,n.join)(y,"settings.json");(0,s.writeFileSync)(_,JSON.stringify({hooks:{SessionStart:[{hooks:[{type:"command",command:'node -e "setTimeout(()=>{},2000)"'}]}]}}));let x=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--settings",_,"--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],w=function(e){let t=e.slice(-12).map(e=>({role:e.role,text:e.text.length>4e3?e.text.slice(0,4e3)+"…":e.text})),s=t.pop();if(!s)return"";if(0===t.length)return s.text;let n=t.map(e=>`${"user"===e.role?"User":"You (assistant)"}: ${e.text}`).join("\n\n");return`Conversation so far:
|
|
21
21
|
|
|
22
22
|
${n}
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
User's new message: ${s.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),w=setTimeout(()=>{f({type:"error",message:"timed out after 5 minutes"}),g.kill()},3e5),v=()=>{clearTimeout(w),m(!0),h.runs.delete(e.id)},R=e=>{var i,l,d;let c,h,m,w,k;if(g.stoppedByUser||"running"!==u.status){g.stoppedByUser&&"running"===u.status&&f({type:"error",message:"stopped by user"}),v();return}let S=(i=o.model,l=x.length,d=p(),h=(0,a.cclensPath)("llm-runs"),m=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,w=(0,n.join)(h,`${m}.jsonl`),(k=(e,t=!1)=>{try{let n=JSON.stringify(e)+"\n";t?((0,s.mkdirSync)(h,{recursive:!0}),(0,s.writeFileSync)(w,n)):(0,s.appendFileSync)(w,n)}catch{}})({_meta:{type:"start",run_id:m,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),k({_meta:{type:"payload",run_id:m,system_prompt:d,user_prompt:x}}),{line:e=>{try{(0,s.appendFileSync)(w,e+"\n")}catch{}},end:e=>k({_meta:{type:"end",run_id:m,ts:new Date().toISOString(),...e}})}),C=Date.now(),D=(0,t.spawn)("claude",y,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:_});g.kill=()=>{try{D.kill("SIGTERM")}catch{}},D.stdin.write(x),D.stdin.end();let b=!1,E="",A="",N=!1,T=new Set,j=new Map,O=t=>{let s;try{s=JSON.parse(t)}catch{return}if("stream_event"!==s.type&&S.line(t),"system"===s.type&&"init"===s.subtype){let t=s.mcp_servers,n=t?.find(e=>"fleetlens"===e.name);if(n&&"connected"!==n.status){b=!0,S.end({runtime:"detached",elapsed_ms:Date.now()-C,mcp_status:n.status,retried:e<3});try{D.kill("SIGTERM")}catch{}e<3?setTimeout(()=>R(e+1),750):(f({type:"error",message:`session tools failed to connect (mcp status: ${n.status}) — try again`}),v())}return}if("stream_event"===s.type){let e=s.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&T.add(e.index),f({type:"delta",text:t.text}))}return}if("assistant"===s.type){let e=s.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||T.has(t)||f({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var s;let t,n="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");j.set(n,r),f({type:"tool",id:n,name:r,input:(t=JSON.stringify(s=e.input)??"{}").length<=300?s:{_truncated:t.slice(0,300)+"…"}})}}),T=new Set;return}if("user"===s.type){let e=s.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",s=e.content,n=Array.isArray(s)?s.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof s?s:"";f({type:"tool_result",id:t,name:j.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(n),isError:!0===e.is_error})}return}"result"===s.type&&(N=!0,c=s.usage,f({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},q=new TextDecoder("utf-8");D.stdout.on("data",e=>{if(b)return;let t=(A+=q.decode(e,{stream:!0})).split("\n");for(let e of(A=t.pop()??"",t)){let t=e.trim();t&&!b&&O(t)}}),D.stderr.on("data",e=>{E.length<4e3&&(E+=e.toString("utf8"))}),D.on("close",e=>{b||(N||"running"!==u.status||f({type:"error",message:g.stoppedByUser?"stopped by user":E.trim().slice(0,400)||`claude exited with code ${e}`}),S.end({runtime:"detached",elapsed_ms:Date.now()-C,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),v())}),D.on("error",e=>{b||(f({type:"error",message:`Failed to spawn claude: ${e.message}`}),S.end({runtime:"detached",elapsed_ms:Date.now()-C,exit_code:-1,error:e.message}),v())})};R(1)}],45092)},48711,e=>{"use strict";var t=e.i(47909),s=e.i(74017),n=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),u=e.i(87718),d=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),g=e.i(74838),m=e.i(10372),f=e.i(93695);e.i(52474);var y=e.i(220);e.i(82111);var _=e.i(56614),x=e.i(84497),w=e.i(84777),v=e.i(45092);async function R(e,{params:t}){let s,{id:n}=await t;try{s=await e.json()}catch{return Response.json({error:"invalid JSON"},{status:400})}let r=s.text?.trim();if(!r)return Response.json({error:"text is required"},{status:400});let a=(0,x.readChat)(n);if(!a)return Response.json({error:"not found"},{status:404});if(a=(0,v.reconcileChat)(a),(0,v.getRun)(n))return Response.json({error:"a run is already active for this chat"},{status:409});if((0,v.activeRunCount)()>=v.MAX_CONCURRENT_RUNS)return Response.json({error:`at most ${v.MAX_CONCURRENT_RUNS} chats can run at once`},{status:429});let o=!a.messages.some(e=>"user"===e.role);return a={...a,title:o?(0,w.chatTitle)(r):a.title,status:"running",updated_at:new Date().toISOString(),messages:[...a.messages,{role:"user",text:r},(0,w.newAssistantMessage)()]},(0,x.writeChat)(a),(0,v.startRun)(a,{model:s.model||(0,_.readSettings)().ai_features.model||"sonnet",mcpUrl:new URL("/api/agent/mcp",e.url).toString()}),Response.json(a,{status:202})}e.s(["POST",0,R,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],53749);var k=e.i(53749);let S=new t.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/agent/chats/[id]/messages/route",pathname:"/api/agent/chats/[id]/messages",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/[id]/messages/route.ts",nextConfigOutput:"standalone",userland:k,...{}}),{workAsyncStorage:C,workUnitAsyncStorage:D,serverHooks:b}=S;async function E(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),S.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let _="/api/agent/chats/[id]/messages/route";_=_.replace(/\/index$/,"")||"/";let x=await S.prepare(e,t,{srcPage:_,multiZoneDraftMode:!1});if(!x)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:w,params:v,nextConfig:R,parsedUrl:k,isDraftMode:C,prerenderManifest:D,routerServerContext:b,isOnDemandRevalidate:E,revalidateOnlyGenerated:A,resolvedPathname:N,clientReferenceManifest:T,serverActionsManifest:j}=x,O=(0,i.normalizeAppPath)(_),q=!!(D.dynamicRoutes[O]||D.routes[N]),U=async()=>((null==b?void 0:b.render404)?await b.render404(e,t,k,!1):t.end("This page could not be found"),null);if(q&&!C){let e=!!D.routes[N],t=D.dynamicRoutes[O];if(t&&!1===t.fallback&&!e){if(R.adapterPath)return await U();throw new f.NoFallbackError}}let M=null;!q||S.isDev||C||(M="/index"===(M=N)?"/":M);let I=!0===S.isDev||!q,$=q&&!I;j&&T&&(0,o.setManifestsSingleton)({page:_,clientReferenceManifest:T,serverActionsManifest:j});let P=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),L=!!(null==b?void 0:b.isWrappedByNextServer),B=!!(0,r.getRequestMeta)(e,"minimalMode"),Y=(0,r.getRequestMeta)(e,"incrementalCache")||await S.getIncrementalCache(e,R,D,B);null==Y||Y.resetRequestCache(),globalThis.__incrementalCache=Y;let W={params:v,previewProps:D.preview,renderOpts:{experimental:{authInterrupts:!!R.experimental.authInterrupts},cacheComponents:!!R.cacheComponents,supportsDynamicResponse:I,incrementalCache:Y,cacheLifeProfiles:R.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>S.onRequestError(e,t,n,r,b)},sharedContext:{buildId:w}},J=new l.NodeNextRequest(e),K=new l.NodeNextResponse(t),G=u.NextRequestAdapter.fromNodeNextRequest(J,(0,u.signalFromNodeResponse)(t));try{let r,o=async e=>S.handle(G,W).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=F.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==d.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=s.get("next.route");if(n){let t=`${P} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${P} ${_}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:s})=>{try{if(!B&&E&&A&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=W.renderOpts.fetchMetrics;let i=W.renderOpts.pendingWaitUntil;i&&n.waitUntil&&(n.waitUntil(i),i=void 0);let l=W.renderOpts.collectedTags;if(!q)return await (0,p.sendResponse)(J,K,a,W.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[m.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==W.renderOpts.collectedRevalidate&&!(W.renderOpts.collectedRevalidate>=m.INFINITE_CACHE)&&W.renderOpts.collectedRevalidate,n=void 0===W.renderOpts.collectedExpire||W.renderOpts.collectedExpire>=m.INFINITE_CACHE?void 0:W.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:n}}}}catch(t){throw(null==s?void 0:s.isStale)&&await S.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:E})},!1,b),t}},u=await S.handleResponse({req:e,nextConfig:R,cacheKey:M,routeKind:s.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:D,isRoutePPREnabled:!1,isOnDemandRevalidate:E,revalidateOnlyGenerated:A,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:B});if(!q)return null;if((null==u||null==(a=u.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(i=u.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});B||t.setHeader("x-nextjs-cache",E?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let d=(0,h.fromNodeOutgoingHttpHeaders)(u.value.headers);return B&&q||d.delete(m.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||d.get("Cache-Control")||d.set("Cache-Control",(0,g.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(J,K,new Response(u.value.body,{headers:d,status:u.value.status||200})),null};L&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(d.BaseServerSpan.handleRequest,{spanName:`${P} ${_}`,kind:a.SpanKind.SERVER,attributes:{"http.method":P,"http.target":e.url}},i),void 0,!L))}catch(t){if(t instanceof f.NoFallbackError||await S.onRequestError(e,t,{routerKind:"App Router",routePath:O,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:E})},!1,b),q)throw t;return await (0,p.sendResponse)(J,K,new Response(null,{status:500})),null}}e.s(["handler",0,E,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:C,workUnitAsyncStorage:D})},"routeModule",0,S,"serverHooks",0,b,"workAsyncStorage",0,C,"workUnitAsyncStorage",0,D],48711)}];
|
|
26
|
+
User's new message: ${s.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),v=setTimeout(()=>{f({type:"error",message:"timed out after 5 minutes"}),g.kill()},3e5),R=()=>{clearTimeout(v),m(!0),h.runs.delete(e.id)},k=e=>{var i,l,d;let c,h,m,_,v;if(g.stoppedByUser||"running"!==u.status){g.stoppedByUser&&"running"===u.status&&f({type:"error",message:"stopped by user"}),R();return}let S=(i=o.model,l=w.length,d=p(),h=(0,a.cclensPath)("llm-runs"),m=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,_=(0,n.join)(h,`${m}.jsonl`),(v=(e,t=!1)=>{try{let n=JSON.stringify(e)+"\n";t?((0,s.mkdirSync)(h,{recursive:!0}),(0,s.writeFileSync)(_,n)):(0,s.appendFileSync)(_,n)}catch{}})({_meta:{type:"start",run_id:m,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),v({_meta:{type:"payload",run_id:m,system_prompt:d,user_prompt:w}}),{line:e=>{try{(0,s.appendFileSync)(_,e+"\n")}catch{}},end:e=>v({_meta:{type:"end",run_id:m,ts:new Date().toISOString(),...e}})}),C=Date.now(),D=(0,t.spawn)("claude",x,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:y});g.kill=()=>{try{D.kill("SIGTERM")}catch{}},D.stdin.write(w),D.stdin.end();let b=!1,E="",A="",N=!1,T=new Set,j=new Map,O=t=>{let s;try{s=JSON.parse(t)}catch{return}if("stream_event"!==s.type&&S.line(t),"system"===s.type&&"init"===s.subtype){let t=s.mcp_servers,n=t?.find(e=>"fleetlens"===e.name);if(n&&"connected"!==n.status){b=!0,S.end({runtime:"detached",elapsed_ms:Date.now()-C,mcp_status:n.status,retried:e<3});try{D.kill("SIGTERM")}catch{}e<3?setTimeout(()=>k(e+1),750):(f({type:"error",message:`session tools failed to connect (mcp status: ${n.status}) — try again`}),R())}return}if("stream_event"===s.type){let e=s.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&T.add(e.index),f({type:"delta",text:t.text}))}return}if("assistant"===s.type){let e=s.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||T.has(t)||f({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var s;let t,n="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");j.set(n,r),f({type:"tool",id:n,name:r,input:(t=JSON.stringify(s=e.input)??"{}").length<=300?s:{_truncated:t.slice(0,300)+"…"}})}}),T=new Set;return}if("user"===s.type){let e=s.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",s=e.content,n=Array.isArray(s)?s.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof s?s:"";f({type:"tool_result",id:t,name:j.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(n),isError:!0===e.is_error})}return}"result"===s.type&&(N=!0,c=s.usage,f({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},q=new TextDecoder("utf-8");D.stdout.on("data",e=>{if(b)return;let t=(A+=q.decode(e,{stream:!0})).split("\n");for(let e of(A=t.pop()??"",t)){let t=e.trim();t&&!b&&O(t)}}),D.stderr.on("data",e=>{E.length<4e3&&(E+=e.toString("utf8"))}),D.on("close",e=>{b||(N||"running"!==u.status||f({type:"error",message:g.stoppedByUser?"stopped by user":E.trim().slice(0,400)||`claude exited with code ${e}`}),S.end({runtime:"detached",elapsed_ms:Date.now()-C,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),R())}),D.on("error",e=>{b||(f({type:"error",message:`Failed to spawn claude: ${e.message}`}),S.end({runtime:"detached",elapsed_ms:Date.now()-C,exit_code:-1,error:e.message}),R())})};k(1)}],45092)},48711,e=>{"use strict";var t=e.i(47909),s=e.i(74017),n=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),u=e.i(87718),d=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),g=e.i(74838),m=e.i(10372),f=e.i(93695);e.i(52474);var y=e.i(220);e.i(82111);var _=e.i(56614),x=e.i(84497),w=e.i(84777),v=e.i(45092);async function R(e,{params:t}){let s,{id:n}=await t;try{s=await e.json()}catch{return Response.json({error:"invalid JSON"},{status:400})}let r=s.text?.trim();if(!r)return Response.json({error:"text is required"},{status:400});let a=(0,x.readChat)(n);if(!a)return Response.json({error:"not found"},{status:404});if(a=(0,v.reconcileChat)(a),(0,v.getRun)(n))return Response.json({error:"a run is already active for this chat"},{status:409});if((0,v.activeRunCount)()>=v.MAX_CONCURRENT_RUNS)return Response.json({error:`at most ${v.MAX_CONCURRENT_RUNS} chats can run at once`},{status:429});let o=!a.messages.some(e=>"user"===e.role);return a={...a,title:o?(0,w.chatTitle)(r):a.title,status:"running",updated_at:new Date().toISOString(),messages:[...a.messages,{role:"user",text:r},(0,w.newAssistantMessage)()]},(0,x.writeChat)(a),(0,v.startRun)(a,{model:s.model||(0,_.readSettings)().ai_features.model||"sonnet",mcpUrl:new URL("/api/agent/mcp",e.url).toString()}),Response.json(a,{status:202})}e.s(["POST",0,R,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],53749);var k=e.i(53749);let S=new t.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/agent/chats/[id]/messages/route",pathname:"/api/agent/chats/[id]/messages",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/[id]/messages/route.ts",nextConfigOutput:"standalone",userland:k,...{}}),{workAsyncStorage:C,workUnitAsyncStorage:D,serverHooks:b}=S;async function E(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),S.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let _="/api/agent/chats/[id]/messages/route";_=_.replace(/\/index$/,"")||"/";let x=await S.prepare(e,t,{srcPage:_,multiZoneDraftMode:!1});if(!x)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:w,params:v,nextConfig:R,parsedUrl:k,isDraftMode:C,prerenderManifest:D,routerServerContext:b,isOnDemandRevalidate:E,revalidateOnlyGenerated:A,resolvedPathname:N,clientReferenceManifest:T,serverActionsManifest:j}=x,O=(0,i.normalizeAppPath)(_),q=!!(D.dynamicRoutes[O]||D.routes[N]),U=async()=>((null==b?void 0:b.render404)?await b.render404(e,t,k,!1):t.end("This page could not be found"),null);if(q&&!C){let e=!!D.routes[N],t=D.dynamicRoutes[O];if(t&&!1===t.fallback&&!e){if(R.adapterPath)return await U();throw new f.NoFallbackError}}let M=null;!q||S.isDev||C||(M="/index"===(M=N)?"/":M);let I=!0===S.isDev||!q,$=q&&!I;j&&T&&(0,o.setManifestsSingleton)({page:_,clientReferenceManifest:T,serverActionsManifest:j});let P=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),L=!!(null==b?void 0:b.isWrappedByNextServer),B=!!(0,r.getRequestMeta)(e,"minimalMode"),Y=(0,r.getRequestMeta)(e,"incrementalCache")||await S.getIncrementalCache(e,R,D,B);null==Y||Y.resetRequestCache(),globalThis.__incrementalCache=Y;let J={params:v,previewProps:D.preview,renderOpts:{experimental:{authInterrupts:!!R.experimental.authInterrupts},cacheComponents:!!R.cacheComponents,supportsDynamicResponse:I,incrementalCache:Y,cacheLifeProfiles:R.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>S.onRequestError(e,t,n,r,b)},sharedContext:{buildId:w}},W=new l.NodeNextRequest(e),K=new l.NodeNextResponse(t),G=u.NextRequestAdapter.fromNodeNextRequest(W,(0,u.signalFromNodeResponse)(t));try{let r,o=async e=>S.handle(G,J).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=F.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==d.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=s.get("next.route");if(n){let t=`${P} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${P} ${_}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:s})=>{try{if(!B&&E&&A&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=J.renderOpts.fetchMetrics;let i=J.renderOpts.pendingWaitUntil;i&&n.waitUntil&&(n.waitUntil(i),i=void 0);let l=J.renderOpts.collectedTags;if(!q)return await (0,p.sendResponse)(W,K,a,J.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[m.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==J.renderOpts.collectedRevalidate&&!(J.renderOpts.collectedRevalidate>=m.INFINITE_CACHE)&&J.renderOpts.collectedRevalidate,n=void 0===J.renderOpts.collectedExpire||J.renderOpts.collectedExpire>=m.INFINITE_CACHE?void 0:J.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:n}}}}catch(t){throw(null==s?void 0:s.isStale)&&await S.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:E})},!1,b),t}},u=await S.handleResponse({req:e,nextConfig:R,cacheKey:M,routeKind:s.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:D,isRoutePPREnabled:!1,isOnDemandRevalidate:E,revalidateOnlyGenerated:A,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:B});if(!q)return null;if((null==u||null==(a=u.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(i=u.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});B||t.setHeader("x-nextjs-cache",E?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let d=(0,h.fromNodeOutgoingHttpHeaders)(u.value.headers);return B&&q||d.delete(m.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||d.get("Cache-Control")||d.set("Cache-Control",(0,g.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(W,K,new Response(u.value.body,{headers:d,status:u.value.status||200})),null};L&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(d.BaseServerSpan.handleRequest,{spanName:`${P} ${_}`,kind:a.SpanKind.SERVER,attributes:{"http.method":P,"http.target":e.url}},i),void 0,!L))}catch(t){if(t instanceof f.NoFallbackError||await S.onRequestError(e,t,{routerKind:"App Router",routePath:O,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:$,isOnDemandRevalidate:E})},!1,b),q)throw t;return await (0,p.sendResponse)(W,K,new Response(null,{status:500})),null}}e.s(["handler",0,E,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:C,workUnitAsyncStorage:D})},"routeModule",0,S,"serverHooks",0,b,"workAsyncStorage",0,C,"workUnitAsyncStorage",0,D],48711)}];
|
|
27
27
|
|
|
28
28
|
//# sourceMappingURL=%5Broot-of-the-server%5D__09cgmam._.js.map
|
|
@@ -17,12 +17,12 @@ Rules:
|
|
|
17
17
|
- Cite sessions inline as markdown links using each hit's url, e.g. [fix daemon crash](/sessions/abc-123). Cite the sessions you actually drew from — not every hit. These session urls (and real web URLs from tool results) are the ONLY things you may link; never link file names, paths, or documents — mention them as plain text.
|
|
18
18
|
- When asked for a prompt / context pack / handoff, output it as a single fenced code block tagged \`prompt\` (\`\`\`prompt … \`\`\`). Make it self-contained: goal, relevant repo/file paths, decisions already made, known gotchas, and what to do next. No session links inside the block — the next agent can't open them.
|
|
19
19
|
- Be concise. Lead with the answer, then supporting detail. Don't narrate your tool use.
|
|
20
|
-
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,s.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,s.existsSync)(o()))return[];let e=[];for(let t of(0,s.readdirSync)(o())){if(!t.endsWith(".json"))continue;let s=d(t.slice(0,-5));s&&e.push({id:s.id,title:s.title,updated_at:s.updated_at,status:s.status,messageCount:s.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,d,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,u],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,d=e,u=0,m={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,m);let g=e=>{if(m.discarded)return;let t=Date.now();if(e||!(t-u<750)){u=t;try{l(d)}catch{}}},f=e=>{let t={seq:++i,...e};for(let e of(m.events.push(t),d=c(d,t),g("delta"!==t.type),m.subscribers))try{e(t)}catch{}},y=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],
|
|
20
|
+
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,s.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,s.existsSync)(o()))return[];let e=[];for(let t of(0,s.readdirSync)(o())){if(!t.endsWith(".json"))continue;let s=d(t.slice(0,-5));s&&e.push({id:s.id,title:s.title,updated_at:s.updated_at,status:s.status,messageCount:s.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,d,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,u],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,d=e,u=0,m={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,m);let g=e=>{if(m.discarded)return;let t=Date.now();if(e||!(t-u<750)){u=t;try{l(d)}catch{}}},f=e=>{let t={seq:++i,...e};for(let e of(m.events.push(t),d=c(d,t),g("delta"!==t.type),m.subscribers))try{e(t)}catch{}},y=(0,a.cclensPath)("agent-runtime");(0,s.mkdirSync)(y,{recursive:!0});let x=(0,n.join)(y,"settings.json");(0,s.writeFileSync)(x,JSON.stringify({hooks:{SessionStart:[{hooks:[{type:"command",command:'node -e "setTimeout(()=>{},2000)"'}]}]}}));let _=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--settings",x,"--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],v=function(e){let t=e.slice(-12).map(e=>({role:e.role,text:e.text.length>4e3?e.text.slice(0,4e3)+"…":e.text})),s=t.pop();if(!s)return"";if(0===t.length)return s.text;let n=t.map(e=>`${"user"===e.role?"User":"You (assistant)"}: ${e.text}`).join("\n\n");return`Conversation so far:
|
|
21
21
|
|
|
22
22
|
${n}
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
User's new message: ${s.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),v=setTimeout(()=>{f({type:"error",message:"timed out after 5 minutes"}),m.kill()},3e5),w=()=>{clearTimeout(v),g(!0),h.runs.delete(e.id)},R=e=>{var i,l,u;let c,h,g,v,k;if(m.stoppedByUser||"running"!==d.status){m.stoppedByUser&&"running"===d.status&&f({type:"error",message:"stopped by user"}),w();return}let S=(i=o.model,l=_.length,u=p(),h=(0,a.cclensPath)("llm-runs"),g=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,v=(0,n.join)(h,`${g}.jsonl`),(k=(e,t=!1)=>{try{let n=JSON.stringify(e)+"\n";t?((0,s.mkdirSync)(h,{recursive:!0}),(0,s.writeFileSync)(v,n)):(0,s.appendFileSync)(v,n)}catch{}})({_meta:{type:"start",run_id:g,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),k({_meta:{type:"payload",run_id:g,system_prompt:u,user_prompt:_}}),{line:e=>{try{(0,s.appendFileSync)(v,e+"\n")}catch{}},end:e=>k({_meta:{type:"end",run_id:g,ts:new Date().toISOString(),...e}})}),b=Date.now(),C=(0,t.spawn)("claude",y,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:x});m.kill=()=>{try{C.kill("SIGTERM")}catch{}},C.stdin.write(_),C.stdin.end();let E=!1,A="",N="",T=!1,q=new Set,O=new Map,U=t=>{let s;try{s=JSON.parse(t)}catch{return}if("stream_event"!==s.type&&S.line(t),"system"===s.type&&"init"===s.subtype){let t=s.mcp_servers,n=t?.find(e=>"fleetlens"===e.name);if(n&&"connected"!==n.status){E=!0,S.end({runtime:"detached",elapsed_ms:Date.now()-b,mcp_status:n.status,retried:e<3});try{C.kill("SIGTERM")}catch{}e<3?setTimeout(()=>R(e+1),750):(f({type:"error",message:`session tools failed to connect (mcp status: ${n.status}) — try again`}),w())}return}if("stream_event"===s.type){let e=s.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&q.add(e.index),f({type:"delta",text:t.text}))}return}if("assistant"===s.type){let e=s.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||q.has(t)||f({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var s;let t,n="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");O.set(n,r),f({type:"tool",id:n,name:r,input:(t=JSON.stringify(s=e.input)??"{}").length<=300?s:{_truncated:t.slice(0,300)+"…"}})}}),q=new Set;return}if("user"===s.type){let e=s.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",s=e.content,n=Array.isArray(s)?s.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof s?s:"";f({type:"tool_result",id:t,name:O.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(n),isError:!0===e.is_error})}return}"result"===s.type&&(T=!0,c=s.usage,f({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},j=new TextDecoder("utf-8");C.stdout.on("data",e=>{if(E)return;let t=(N+=j.decode(e,{stream:!0})).split("\n");for(let e of(N=t.pop()??"",t)){let t=e.trim();t&&!E&&U(t)}}),C.stderr.on("data",e=>{A.length<4e3&&(A+=e.toString("utf8"))}),C.on("close",e=>{E||(T||"running"!==d.status||f({type:"error",message:m.stoppedByUser?"stopped by user":A.trim().slice(0,400)||`claude exited with code ${e}`}),S.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),w())}),C.on("error",e=>{E||(f({type:"error",message:`Failed to spawn claude: ${e.message}`}),S.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:-1,error:e.message}),w())})};R(1)}],45092)},1766,e=>{"use strict";var t=e.i(47909),s=e.i(74017),n=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),m=e.i(74838),g=e.i(10372),f=e.i(93695);e.i(52474);var y=e.i(220),x=e.i(45092);async function _(e,{params:t}){let{id:s}=await t;return(0,x.killRun)(s),Response.json({ok:!0})}e.s(["POST",0,_,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],14733);var v=e.i(14733);let w=new t.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/agent/chats/[id]/stop/route",pathname:"/api/agent/chats/[id]/stop",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/[id]/stop/route.ts",nextConfigOutput:"standalone",userland:v,...{}}),{workAsyncStorage:R,workUnitAsyncStorage:k,serverHooks:S}=w;async function b(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),w.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/agent/chats/[id]/stop/route";x=x.replace(/\/index$/,"")||"/";let _=await w.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!_)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:v,params:R,nextConfig:k,parsedUrl:S,isDraftMode:b,prerenderManifest:C,routerServerContext:E,isOnDemandRevalidate:A,revalidateOnlyGenerated:N,resolvedPathname:T,clientReferenceManifest:q,serverActionsManifest:O}=_,U=(0,i.normalizeAppPath)(x),j=!!(C.dynamicRoutes[U]||C.routes[T]),D=async()=>((null==E?void 0:E.render404)?await E.render404(e,t,S,!1):t.end("This page could not be found"),null);if(j&&!b){let e=!!C.routes[T],t=C.dynamicRoutes[U];if(t&&!1===t.fallback&&!e){if(k.adapterPath)return await D();throw new f.NoFallbackError}}let I=null;!j||w.isDev||b||(I="/index"===(I=T)?"/":I);let $=!0===w.isDev||!j,P=j&&!$;O&&q&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:q,serverActionsManifest:O});let M=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),B=!!(null==E?void 0:E.isWrappedByNextServer),L=!!(0,r.getRequestMeta)(e,"minimalMode"),K=(0,r.getRequestMeta)(e,"incrementalCache")||await w.getIncrementalCache(e,k,C,L);null==K||K.resetRequestCache(),globalThis.__incrementalCache=K;let G={params:R,previewProps:C.preview,renderOpts:{experimental:{authInterrupts:!!k.experimental.authInterrupts},cacheComponents:!!k.cacheComponents,supportsDynamicResponse:$,incrementalCache:K,cacheLifeProfiles:k.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>w.onRequestError(e,t,n,r,E)},sharedContext:{buildId:v}},J=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),Y=d.NextRequestAdapter.fromNodeNextRequest(J,(0,d.signalFromNodeResponse)(t));try{let r,o=async e=>w.handle(Y,G).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=F.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=s.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${M} ${x}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:s})=>{try{if(!L&&A&&N&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=G.renderOpts.fetchMetrics;let i=G.renderOpts.pendingWaitUntil;i&&n.waitUntil&&(n.waitUntil(i),i=void 0);let l=G.renderOpts.collectedTags;if(!j)return await (0,p.sendResponse)(J,W,a,G.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[g.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==G.renderOpts.collectedRevalidate&&!(G.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&G.renderOpts.collectedRevalidate,n=void 0===G.renderOpts.collectedExpire||G.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:G.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:n}}}}catch(t){throw(null==s?void 0:s.isStale)&&await w.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),t}},d=await w.handleResponse({req:e,nextConfig:k,cacheKey:I,routeKind:s.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:N,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:L});if(!j)return null;if((null==d||null==(a=d.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",A?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return L&&j||u.delete(g.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(J,W,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:a.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!B))}catch(t){if(t instanceof f.NoFallbackError||await w.onRequestError(e,t,{routerKind:"App Router",routePath:U,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),j)throw t;return await (0,p.sendResponse)(J,W,new Response(null,{status:500})),null}}e.s(["handler",0,b,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:R,workUnitAsyncStorage:k})},"routeModule",0,w,"serverHooks",0,S,"workAsyncStorage",0,R,"workUnitAsyncStorage",0,k],1766)}];
|
|
26
|
+
User's new message: ${s.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),w=setTimeout(()=>{f({type:"error",message:"timed out after 5 minutes"}),m.kill()},3e5),R=()=>{clearTimeout(w),g(!0),h.runs.delete(e.id)},S=e=>{var i,l,u;let c,h,g,x,w;if(m.stoppedByUser||"running"!==d.status){m.stoppedByUser&&"running"===d.status&&f({type:"error",message:"stopped by user"}),R();return}let k=(i=o.model,l=v.length,u=p(),h=(0,a.cclensPath)("llm-runs"),g=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,x=(0,n.join)(h,`${g}.jsonl`),(w=(e,t=!1)=>{try{let n=JSON.stringify(e)+"\n";t?((0,s.mkdirSync)(h,{recursive:!0}),(0,s.writeFileSync)(x,n)):(0,s.appendFileSync)(x,n)}catch{}})({_meta:{type:"start",run_id:g,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),w({_meta:{type:"payload",run_id:g,system_prompt:u,user_prompt:v}}),{line:e=>{try{(0,s.appendFileSync)(x,e+"\n")}catch{}},end:e=>w({_meta:{type:"end",run_id:g,ts:new Date().toISOString(),...e}})}),b=Date.now(),C=(0,t.spawn)("claude",_,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:y});m.kill=()=>{try{C.kill("SIGTERM")}catch{}},C.stdin.write(v),C.stdin.end();let E=!1,A="",N="",T=!1,q=new Set,O=new Map,j=t=>{let s;try{s=JSON.parse(t)}catch{return}if("stream_event"!==s.type&&k.line(t),"system"===s.type&&"init"===s.subtype){let t=s.mcp_servers,n=t?.find(e=>"fleetlens"===e.name);if(n&&"connected"!==n.status){E=!0,k.end({runtime:"detached",elapsed_ms:Date.now()-b,mcp_status:n.status,retried:e<3});try{C.kill("SIGTERM")}catch{}e<3?setTimeout(()=>S(e+1),750):(f({type:"error",message:`session tools failed to connect (mcp status: ${n.status}) — try again`}),R())}return}if("stream_event"===s.type){let e=s.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&q.add(e.index),f({type:"delta",text:t.text}))}return}if("assistant"===s.type){let e=s.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||q.has(t)||f({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var s;let t,n="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");O.set(n,r),f({type:"tool",id:n,name:r,input:(t=JSON.stringify(s=e.input)??"{}").length<=300?s:{_truncated:t.slice(0,300)+"…"}})}}),q=new Set;return}if("user"===s.type){let e=s.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",s=e.content,n=Array.isArray(s)?s.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof s?s:"";f({type:"tool_result",id:t,name:O.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(n),isError:!0===e.is_error})}return}"result"===s.type&&(T=!0,c=s.usage,f({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},U=new TextDecoder("utf-8");C.stdout.on("data",e=>{if(E)return;let t=(N+=U.decode(e,{stream:!0})).split("\n");for(let e of(N=t.pop()??"",t)){let t=e.trim();t&&!E&&j(t)}}),C.stderr.on("data",e=>{A.length<4e3&&(A+=e.toString("utf8"))}),C.on("close",e=>{E||(T||"running"!==d.status||f({type:"error",message:m.stoppedByUser?"stopped by user":A.trim().slice(0,400)||`claude exited with code ${e}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),R())}),C.on("error",e=>{E||(f({type:"error",message:`Failed to spawn claude: ${e.message}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:-1,error:e.message}),R())})};S(1)}],45092)},1766,e=>{"use strict";var t=e.i(47909),s=e.i(74017),n=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),m=e.i(74838),g=e.i(10372),f=e.i(93695);e.i(52474);var y=e.i(220),x=e.i(45092);async function _(e,{params:t}){let{id:s}=await t;return(0,x.killRun)(s),Response.json({ok:!0})}e.s(["POST",0,_,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],14733);var v=e.i(14733);let w=new t.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/agent/chats/[id]/stop/route",pathname:"/api/agent/chats/[id]/stop",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/[id]/stop/route.ts",nextConfigOutput:"standalone",userland:v,...{}}),{workAsyncStorage:R,workUnitAsyncStorage:S,serverHooks:k}=w;async function b(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),w.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/agent/chats/[id]/stop/route";x=x.replace(/\/index$/,"")||"/";let _=await w.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!_)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:v,params:R,nextConfig:S,parsedUrl:k,isDraftMode:b,prerenderManifest:C,routerServerContext:E,isOnDemandRevalidate:A,revalidateOnlyGenerated:N,resolvedPathname:T,clientReferenceManifest:q,serverActionsManifest:O}=_,j=(0,i.normalizeAppPath)(x),U=!!(C.dynamicRoutes[j]||C.routes[T]),D=async()=>((null==E?void 0:E.render404)?await E.render404(e,t,k,!1):t.end("This page could not be found"),null);if(U&&!b){let e=!!C.routes[T],t=C.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(S.adapterPath)return await D();throw new f.NoFallbackError}}let I=null;!U||w.isDev||b||(I="/index"===(I=T)?"/":I);let $=!0===w.isDev||!U,P=U&&!$;O&&q&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:q,serverActionsManifest:O});let M=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),B=!!(null==E?void 0:E.isWrappedByNextServer),L=!!(0,r.getRequestMeta)(e,"minimalMode"),J=(0,r.getRequestMeta)(e,"incrementalCache")||await w.getIncrementalCache(e,S,C,L);null==J||J.resetRequestCache(),globalThis.__incrementalCache=J;let K={params:R,previewProps:C.preview,renderOpts:{experimental:{authInterrupts:!!S.experimental.authInterrupts},cacheComponents:!!S.cacheComponents,supportsDynamicResponse:$,incrementalCache:J,cacheLifeProfiles:S.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>w.onRequestError(e,t,n,r,E)},sharedContext:{buildId:v}},G=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),Y=d.NextRequestAdapter.fromNodeNextRequest(G,(0,d.signalFromNodeResponse)(t));try{let r,o=async e=>w.handle(Y,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=F.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=s.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${M} ${x}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:s})=>{try{if(!L&&A&&N&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=K.renderOpts.fetchMetrics;let i=K.renderOpts.pendingWaitUntil;i&&n.waitUntil&&(n.waitUntil(i),i=void 0);let l=K.renderOpts.collectedTags;if(!U)return await (0,p.sendResponse)(G,W,a,K.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[g.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,n=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:n}}}}catch(t){throw(null==s?void 0:s.isStale)&&await w.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),t}},d=await w.handleResponse({req:e,nextConfig:S,cacheKey:I,routeKind:s.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:N,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:L});if(!U)return null;if((null==d||null==(a=d.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",A?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return L&&U||u.delete(g.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(G,W,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:a.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!B))}catch(t){if(t instanceof f.NoFallbackError||await w.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),U)throw t;return await (0,p.sendResponse)(G,W,new Response(null,{status:500})),null}}e.s(["handler",0,b,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:R,workUnitAsyncStorage:S})},"routeModule",0,w,"serverHooks",0,k,"workAsyncStorage",0,R,"workUnitAsyncStorage",0,S],1766)}];
|
|
27
27
|
|
|
28
28
|
//# sourceMappingURL=%5Broot-of-the-server%5D__0tk8p3d._.js.map
|
|
@@ -17,12 +17,12 @@ Rules:
|
|
|
17
17
|
- Cite sessions inline as markdown links using each hit's url, e.g. [fix daemon crash](/sessions/abc-123). Cite the sessions you actually drew from — not every hit. These session urls (and real web URLs from tool results) are the ONLY things you may link; never link file names, paths, or documents — mention them as plain text.
|
|
18
18
|
- When asked for a prompt / context pack / handoff, output it as a single fenced code block tagged \`prompt\` (\`\`\`prompt … \`\`\`). Make it self-contained: goal, relevant repo/file paths, decisions already made, known gotchas, and what to do next. No session links inside the block — the next agent can't open them.
|
|
19
19
|
- Be concise. Lead with the answer, then supporting detail. Don't narrate your tool use.
|
|
20
|
-
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,s.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,s.existsSync)(o()))return[];let e=[];for(let t of(0,s.readdirSync)(o())){if(!t.endsWith(".json"))continue;let s=d(t.slice(0,-5));s&&e.push({id:s.id,title:s.title,updated_at:s.updated_at,status:s.status,messageCount:s.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,d,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,u],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,d=e,u=0,m={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,m);let
|
|
20
|
+
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,s.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,s.existsSync)(o()))return[];let e=[];for(let t of(0,s.readdirSync)(o())){if(!t.endsWith(".json"))continue;let s=d(t.slice(0,-5));s&&e.push({id:s.id,title:s.title,updated_at:s.updated_at,status:s.status,messageCount:s.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,d,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,u],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,d=e,u=0,m={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,m);let g=e=>{if(m.discarded)return;let t=Date.now();if(e||!(t-u<750)){u=t;try{l(d)}catch{}}},f=e=>{let t={seq:++i,...e};for(let e of(m.events.push(t),d=c(d,t),g("delta"!==t.type),m.subscribers))try{e(t)}catch{}},y=(0,a.cclensPath)("agent-runtime");(0,s.mkdirSync)(y,{recursive:!0});let x=(0,n.join)(y,"settings.json");(0,s.writeFileSync)(x,JSON.stringify({hooks:{SessionStart:[{hooks:[{type:"command",command:'node -e "setTimeout(()=>{},2000)"'}]}]}}));let _=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--settings",x,"--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],v=function(e){let t=e.slice(-12).map(e=>({role:e.role,text:e.text.length>4e3?e.text.slice(0,4e3)+"…":e.text})),s=t.pop();if(!s)return"";if(0===t.length)return s.text;let n=t.map(e=>`${"user"===e.role?"User":"You (assistant)"}: ${e.text}`).join("\n\n");return`Conversation so far:
|
|
21
21
|
|
|
22
22
|
${n}
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
User's new message: ${s.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),v=setTimeout(()=>{g({type:"error",message:"timed out after 5 minutes"}),m.kill()},3e5),w=()=>{clearTimeout(v),f(!0),h.runs.delete(e.id)},R=e=>{var i,l,u;let c,h,f,v,k;if(m.stoppedByUser||"running"!==d.status){m.stoppedByUser&&"running"===d.status&&g({type:"error",message:"stopped by user"}),w();return}let S=(i=o.model,l=_.length,u=p(),h=(0,a.cclensPath)("llm-runs"),f=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,v=(0,n.join)(h,`${f}.jsonl`),(k=(e,t=!1)=>{try{let n=JSON.stringify(e)+"\n";t?((0,s.mkdirSync)(h,{recursive:!0}),(0,s.writeFileSync)(v,n)):(0,s.appendFileSync)(v,n)}catch{}})({_meta:{type:"start",run_id:f,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),k({_meta:{type:"payload",run_id:f,system_prompt:u,user_prompt:_}}),{line:e=>{try{(0,s.appendFileSync)(v,e+"\n")}catch{}},end:e=>k({_meta:{type:"end",run_id:f,ts:new Date().toISOString(),...e}})}),b=Date.now(),C=(0,t.spawn)("claude",y,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:x});m.kill=()=>{try{C.kill("SIGTERM")}catch{}},C.stdin.write(_),C.stdin.end();let E=!1,A="",T="",N=!1,q=new Set,O=new Map,j=t=>{let s;try{s=JSON.parse(t)}catch{return}if("stream_event"!==s.type&&S.line(t),"system"===s.type&&"init"===s.subtype){let t=s.mcp_servers,n=t?.find(e=>"fleetlens"===e.name);if(n&&"connected"!==n.status){E=!0,S.end({runtime:"detached",elapsed_ms:Date.now()-b,mcp_status:n.status,retried:e<3});try{C.kill("SIGTERM")}catch{}e<3?setTimeout(()=>R(e+1),750):(g({type:"error",message:`session tools failed to connect (mcp status: ${n.status}) — try again`}),w())}return}if("stream_event"===s.type){let e=s.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&q.add(e.index),g({type:"delta",text:t.text}))}return}if("assistant"===s.type){let e=s.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||q.has(t)||g({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var s;let t,n="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");O.set(n,r),g({type:"tool",id:n,name:r,input:(t=JSON.stringify(s=e.input)??"{}").length<=300?s:{_truncated:t.slice(0,300)+"…"}})}}),q=new Set;return}if("user"===s.type){let e=s.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",s=e.content,n=Array.isArray(s)?s.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof s?s:"";g({type:"tool_result",id:t,name:O.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(n),isError:!0===e.is_error})}return}"result"===s.type&&(N=!0,c=s.usage,g({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},D=new TextDecoder("utf-8");C.stdout.on("data",e=>{if(E)return;let t=(T+=D.decode(e,{stream:!0})).split("\n");for(let e of(T=t.pop()??"",t)){let t=e.trim();t&&!E&&j(t)}}),C.stderr.on("data",e=>{A.length<4e3&&(A+=e.toString("utf8"))}),C.on("close",e=>{E||(N||"running"!==d.status||g({type:"error",message:m.stoppedByUser?"stopped by user":A.trim().slice(0,400)||`claude exited with code ${e}`}),S.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),w())}),C.on("error",e=>{E||(g({type:"error",message:`Failed to spawn claude: ${e.message}`}),S.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:-1,error:e.message}),w())})};R(1)}],45092)},33689,e=>{"use strict";var t=e.i(47909),s=e.i(74017),n=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),m=e.i(74838),f=e.i(10372),g=e.i(93695);e.i(52474);var y=e.i(220),x=e.i(84497),_=e.i(45092);async function v(e,{params:t}){let{id:s}=await t,n=(0,x.readChat)(s);return n?Response.json((0,_.reconcileChat)(n)):Response.json({error:"not found"},{status:404})}async function w(e,{params:t}){let{id:s}=await t;return(0,_.discardRun)(s),(0,x.deleteChat)(s),new Response(null,{status:204})}e.s(["DELETE",0,w,"GET",0,v,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],46527);var R=e.i(46527);let k=new t.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/agent/chats/[id]/route",pathname:"/api/agent/chats/[id]",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/[id]/route.ts",nextConfigOutput:"standalone",userland:R,...{}}),{workAsyncStorage:S,workUnitAsyncStorage:b,serverHooks:C}=k;async function E(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),k.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/agent/chats/[id]/route";x=x.replace(/\/index$/,"")||"/";let _=await k.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!_)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:v,params:w,nextConfig:R,parsedUrl:S,isDraftMode:b,prerenderManifest:C,routerServerContext:E,isOnDemandRevalidate:A,revalidateOnlyGenerated:T,resolvedPathname:N,clientReferenceManifest:q,serverActionsManifest:O}=_,j=(0,i.normalizeAppPath)(x),D=!!(C.dynamicRoutes[j]||C.routes[N]),U=async()=>((null==E?void 0:E.render404)?await E.render404(e,t,S,!1):t.end("This page could not be found"),null);if(D&&!b){let e=!!C.routes[N],t=C.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(R.adapterPath)return await U();throw new g.NoFallbackError}}let I=null;!D||k.isDev||b||(I="/index"===(I=N)?"/":I);let $=!0===k.isDev||!D,P=D&&!$;O&&q&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:q,serverActionsManifest:O});let M=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),B=!!(null==E?void 0:E.isWrappedByNextServer),L=!!(0,r.getRequestMeta)(e,"minimalMode"),G=(0,r.getRequestMeta)(e,"incrementalCache")||await k.getIncrementalCache(e,R,C,L);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let K={params:w,previewProps:C.preview,renderOpts:{experimental:{authInterrupts:!!R.experimental.authInterrupts},cacheComponents:!!R.cacheComponents,supportsDynamicResponse:$,incrementalCache:G,cacheLifeProfiles:R.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>k.onRequestError(e,t,n,r,E)},sharedContext:{buildId:v}},J=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),Y=d.NextRequestAdapter.fromNodeNextRequest(J,(0,d.signalFromNodeResponse)(t));try{let r,o=async e=>k.handle(Y,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=F.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=s.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${M} ${x}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:s})=>{try{if(!L&&A&&T&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=K.renderOpts.fetchMetrics;let i=K.renderOpts.pendingWaitUntil;i&&n.waitUntil&&(n.waitUntil(i),i=void 0);let l=K.renderOpts.collectedTags;if(!D)return await (0,p.sendResponse)(J,W,a,K.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[f.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=f.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,n=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=f.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:n}}}}catch(t){throw(null==s?void 0:s.isStale)&&await k.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),t}},d=await k.handleResponse({req:e,nextConfig:R,cacheKey:I,routeKind:s.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:T,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:L});if(!D)return null;if((null==d||null==(a=d.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",A?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return L&&D||u.delete(f.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(J,W,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:a.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!B))}catch(t){if(t instanceof g.NoFallbackError||await k.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),D)throw t;return await (0,p.sendResponse)(J,W,new Response(null,{status:500})),null}}e.s(["handler",0,E,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:b})},"routeModule",0,k,"serverHooks",0,C,"workAsyncStorage",0,S,"workUnitAsyncStorage",0,b],33689)}];
|
|
26
|
+
User's new message: ${s.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),w=setTimeout(()=>{f({type:"error",message:"timed out after 5 minutes"}),m.kill()},3e5),R=()=>{clearTimeout(w),g(!0),h.runs.delete(e.id)},S=e=>{var i,l,u;let c,h,g,x,w;if(m.stoppedByUser||"running"!==d.status){m.stoppedByUser&&"running"===d.status&&f({type:"error",message:"stopped by user"}),R();return}let k=(i=o.model,l=v.length,u=p(),h=(0,a.cclensPath)("llm-runs"),g=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,x=(0,n.join)(h,`${g}.jsonl`),(w=(e,t=!1)=>{try{let n=JSON.stringify(e)+"\n";t?((0,s.mkdirSync)(h,{recursive:!0}),(0,s.writeFileSync)(x,n)):(0,s.appendFileSync)(x,n)}catch{}})({_meta:{type:"start",run_id:g,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),w({_meta:{type:"payload",run_id:g,system_prompt:u,user_prompt:v}}),{line:e=>{try{(0,s.appendFileSync)(x,e+"\n")}catch{}},end:e=>w({_meta:{type:"end",run_id:g,ts:new Date().toISOString(),...e}})}),b=Date.now(),C=(0,t.spawn)("claude",_,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:y});m.kill=()=>{try{C.kill("SIGTERM")}catch{}},C.stdin.write(v),C.stdin.end();let E=!1,A="",T="",N=!1,q=new Set,O=new Map,j=t=>{let s;try{s=JSON.parse(t)}catch{return}if("stream_event"!==s.type&&k.line(t),"system"===s.type&&"init"===s.subtype){let t=s.mcp_servers,n=t?.find(e=>"fleetlens"===e.name);if(n&&"connected"!==n.status){E=!0,k.end({runtime:"detached",elapsed_ms:Date.now()-b,mcp_status:n.status,retried:e<3});try{C.kill("SIGTERM")}catch{}e<3?setTimeout(()=>S(e+1),750):(f({type:"error",message:`session tools failed to connect (mcp status: ${n.status}) — try again`}),R())}return}if("stream_event"===s.type){let e=s.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&q.add(e.index),f({type:"delta",text:t.text}))}return}if("assistant"===s.type){let e=s.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||q.has(t)||f({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var s;let t,n="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");O.set(n,r),f({type:"tool",id:n,name:r,input:(t=JSON.stringify(s=e.input)??"{}").length<=300?s:{_truncated:t.slice(0,300)+"…"}})}}),q=new Set;return}if("user"===s.type){let e=s.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",s=e.content,n=Array.isArray(s)?s.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof s?s:"";f({type:"tool_result",id:t,name:O.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(n),isError:!0===e.is_error})}return}"result"===s.type&&(N=!0,c=s.usage,f({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},D=new TextDecoder("utf-8");C.stdout.on("data",e=>{if(E)return;let t=(T+=D.decode(e,{stream:!0})).split("\n");for(let e of(T=t.pop()??"",t)){let t=e.trim();t&&!E&&j(t)}}),C.stderr.on("data",e=>{A.length<4e3&&(A+=e.toString("utf8"))}),C.on("close",e=>{E||(N||"running"!==d.status||f({type:"error",message:m.stoppedByUser?"stopped by user":A.trim().slice(0,400)||`claude exited with code ${e}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),R())}),C.on("error",e=>{E||(f({type:"error",message:`Failed to spawn claude: ${e.message}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:-1,error:e.message}),R())})};S(1)}],45092)},33689,e=>{"use strict";var t=e.i(47909),s=e.i(74017),n=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),m=e.i(74838),g=e.i(10372),f=e.i(93695);e.i(52474);var y=e.i(220),x=e.i(84497),_=e.i(45092);async function v(e,{params:t}){let{id:s}=await t,n=(0,x.readChat)(s);return n?Response.json((0,_.reconcileChat)(n)):Response.json({error:"not found"},{status:404})}async function w(e,{params:t}){let{id:s}=await t;return(0,_.discardRun)(s),(0,x.deleteChat)(s),new Response(null,{status:204})}e.s(["DELETE",0,w,"GET",0,v,"dynamic",0,"force-dynamic","runtime",0,"nodejs"],46527);var R=e.i(46527);let S=new t.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/agent/chats/[id]/route",pathname:"/api/agent/chats/[id]",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/[id]/route.ts",nextConfigOutput:"standalone",userland:R,...{}}),{workAsyncStorage:k,workUnitAsyncStorage:b,serverHooks:C}=S;async function E(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),S.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/agent/chats/[id]/route";x=x.replace(/\/index$/,"")||"/";let _=await S.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!_)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:v,params:w,nextConfig:R,parsedUrl:k,isDraftMode:b,prerenderManifest:C,routerServerContext:E,isOnDemandRevalidate:A,revalidateOnlyGenerated:T,resolvedPathname:N,clientReferenceManifest:q,serverActionsManifest:O}=_,j=(0,i.normalizeAppPath)(x),D=!!(C.dynamicRoutes[j]||C.routes[N]),U=async()=>((null==E?void 0:E.render404)?await E.render404(e,t,k,!1):t.end("This page could not be found"),null);if(D&&!b){let e=!!C.routes[N],t=C.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(R.adapterPath)return await U();throw new f.NoFallbackError}}let I=null;!D||S.isDev||b||(I="/index"===(I=N)?"/":I);let $=!0===S.isDev||!D,P=D&&!$;O&&q&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:q,serverActionsManifest:O});let M=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),B=!!(null==E?void 0:E.isWrappedByNextServer),L=!!(0,r.getRequestMeta)(e,"minimalMode"),G=(0,r.getRequestMeta)(e,"incrementalCache")||await S.getIncrementalCache(e,R,C,L);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let J={params:w,previewProps:C.preview,renderOpts:{experimental:{authInterrupts:!!R.experimental.authInterrupts},cacheComponents:!!R.cacheComponents,supportsDynamicResponse:$,incrementalCache:G,cacheLifeProfiles:R.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>S.onRequestError(e,t,n,r,E)},sharedContext:{buildId:v}},K=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),Y=d.NextRequestAdapter.fromNodeNextRequest(K,(0,d.signalFromNodeResponse)(t));try{let r,o=async e=>S.handle(Y,J).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=F.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=s.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${M} ${x}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:s})=>{try{if(!L&&A&&T&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=J.renderOpts.fetchMetrics;let i=J.renderOpts.pendingWaitUntil;i&&n.waitUntil&&(n.waitUntil(i),i=void 0);let l=J.renderOpts.collectedTags;if(!D)return await (0,p.sendResponse)(K,W,a,J.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[g.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==J.renderOpts.collectedRevalidate&&!(J.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&J.renderOpts.collectedRevalidate,n=void 0===J.renderOpts.collectedExpire||J.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:J.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:n}}}}catch(t){throw(null==s?void 0:s.isStale)&&await S.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),t}},d=await S.handleResponse({req:e,nextConfig:R,cacheKey:I,routeKind:s.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:T,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:L});if(!D)return null;if((null==d||null==(a=d.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",A?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return L&&D||u.delete(g.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(K,W,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:a.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!B))}catch(t){if(t instanceof f.NoFallbackError||await S.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),D)throw t;return await (0,p.sendResponse)(K,W,new Response(null,{status:500})),null}}e.s(["handler",0,E,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:k,workUnitAsyncStorage:b})},"routeModule",0,S,"serverHooks",0,C,"workAsyncStorage",0,k,"workUnitAsyncStorage",0,b],33689)}];
|
|
27
27
|
|
|
28
28
|
//# sourceMappingURL=%5Broot-of-the-server%5D__0u6pamj._.js.map
|
|
@@ -17,12 +17,12 @@ Rules:
|
|
|
17
17
|
- Cite sessions inline as markdown links using each hit's url, e.g. [fix daemon crash](/sessions/abc-123). Cite the sessions you actually drew from — not every hit. These session urls (and real web URLs from tool results) are the ONLY things you may link; never link file names, paths, or documents — mention them as plain text.
|
|
18
18
|
- When asked for a prompt / context pack / handoff, output it as a single fenced code block tagged \`prompt\` (\`\`\`prompt … \`\`\`). Make it self-contained: goal, relevant repo/file paths, decisions already made, known gotchas, and what to do next. No session links inside the block — the next agent can't open them.
|
|
19
19
|
- Be concise. Lead with the answer, then supporting detail. Don't narrate your tool use.
|
|
20
|
-
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,s.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,s.existsSync)(o()))return[];let e=[];for(let t of(0,s.readdirSync)(o())){if(!t.endsWith(".json"))continue;let s=d(t.slice(0,-5));s&&e.push({id:s.id,title:s.title,updated_at:s.updated_at,status:s.status,messageCount:s.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,d,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,u],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,d=e,u=0,m={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,m);let g=e=>{if(m.discarded)return;let t=Date.now();if(e||!(t-u<750)){u=t;try{l(d)}catch{}}},f=e=>{let t={seq:++i,...e};for(let e of(m.events.push(t),d=c(d,t),g("delta"!==t.type),m.subscribers))try{e(t)}catch{}},y=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],
|
|
20
|
+
- If searches genuinely turn up nothing, say so plainly and suggest a better query.`}e.s(["deleteChat",0,function(e){/^[a-zA-Z0-9-]+$/.test(e)&&(0,s.rmSync)(i(e),{force:!0})},"listChats",0,function(){if(!(0,s.existsSync)(o()))return[];let e=[];for(let t of(0,s.readdirSync)(o())){if(!t.endsWith(".json"))continue;let s=d(t.slice(0,-5));s&&e.push({id:s.id,title:s.title,updated_at:s.updated_at,status:s.status,messageCount:s.messages.length})}return e.sort((e,t)=>t.updated_at.localeCompare(e.updated_at)),e},"readChat",0,d,"writeChat",0,l],84497),e.s(["applyRunEvent",0,c,"chatTitle",0,function(e){return e.replace(/\s+/g," ").trim().slice(0,80)},"createChat",0,function(){let e=new Date().toISOString();return{version:1,id:crypto.randomUUID(),title:"New conversation",created_at:e,updated_at:e,status:"idle",lastSeq:0,messages:[]}},"newAssistantMessage",0,u],84777);let h=globalThis.__fleetlensAgentRuns??={runs:new Map};e.s(["MAX_CONCURRENT_RUNS",0,3,"activeRunCount",0,function(){return h.runs.size},"discardRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.discarded=!0,h.runs.delete(e),t.kill())},"getRun",0,function(e){return h.runs.get(e)},"killRun",0,function(e){let t=h.runs.get(e);t&&(t.stoppedByUser=!0,t.kill())},"reconcileChat",0,function(e){if("running"!==e.status||h.runs.has(e.id))return e;let t=c(e,{seq:e.lastSeq+1,type:"error",message:"run interrupted — the server restarted while it was working"});try{l(t)}catch{}return t},"startRun",0,function(e,o){if(h.runs.has(e.id))throw Error("run already active for this chat");let i=e.lastSeq,d=e,u=0,m={chatId:e.id,events:[],subscribers:new Set,stoppedByUser:!1,discarded:!1,kill:()=>{}};h.runs.set(e.id,m);let g=e=>{if(m.discarded)return;let t=Date.now();if(e||!(t-u<750)){u=t;try{l(d)}catch{}}},f=e=>{let t={seq:++i,...e};for(let e of(m.events.push(t),d=c(d,t),g("delta"!==t.type),m.subscribers))try{e(t)}catch{}},y=(0,a.cclensPath)("agent-runtime");(0,s.mkdirSync)(y,{recursive:!0});let x=(0,n.join)(y,"settings.json");(0,s.writeFileSync)(x,JSON.stringify({hooks:{SessionStart:[{hooks:[{type:"command",command:'node -e "setTimeout(()=>{},2000)"'}]}]}}));let _=["-p","--output-format","stream-json","--verbose","--include-partial-messages","--model",o.model,"--tools","","--disable-slash-commands","--no-session-persistence","--setting-sources","","--settings",x,"--strict-mcp-config","--mcp-config",JSON.stringify({mcpServers:{fleetlens:{type:"http",url:o.mcpUrl}}}),"--allowedTools","mcp__fleetlens__search_sessions","mcp__fleetlens__get_session","mcp__fleetlens__list_sessions","mcp__fleetlens__list_projects","--effort","medium","--append-system-prompt",p()],v=function(e){let t=e.slice(-12).map(e=>({role:e.role,text:e.text.length>4e3?e.text.slice(0,4e3)+"…":e.text})),s=t.pop();if(!s)return"";if(0===t.length)return s.text;let n=t.map(e=>`${"user"===e.role?"User":"You (assistant)"}: ${e.text}`).join("\n\n");return`Conversation so far:
|
|
21
21
|
|
|
22
22
|
${n}
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
User's new message: ${s.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),v=setTimeout(()=>{f({type:"error",message:"timed out after 5 minutes"}),m.kill()},3e5),w=()=>{clearTimeout(v),g(!0),h.runs.delete(e.id)},R=e=>{var i,l,u;let c,h,g,v,S;if(m.stoppedByUser||"running"!==d.status){m.stoppedByUser&&"running"===d.status&&f({type:"error",message:"stopped by user"}),w();return}let k=(i=o.model,l=_.length,u=p(),h=(0,a.cclensPath)("llm-runs"),g=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,v=(0,n.join)(h,`${g}.jsonl`),(S=(e,t=!1)=>{try{let n=JSON.stringify(e)+"\n";t?((0,s.mkdirSync)(h,{recursive:!0}),(0,s.writeFileSync)(v,n)):(0,s.appendFileSync)(v,n)}catch{}})({_meta:{type:"start",run_id:g,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),S({_meta:{type:"payload",run_id:g,system_prompt:u,user_prompt:_}}),{line:e=>{try{(0,s.appendFileSync)(v,e+"\n")}catch{}},end:e=>S({_meta:{type:"end",run_id:g,ts:new Date().toISOString(),...e}})}),b=Date.now(),C=(0,t.spawn)("claude",y,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:x});m.kill=()=>{try{C.kill("SIGTERM")}catch{}},C.stdin.write(_),C.stdin.end();let E=!1,A="",T="",N=!1,q=new Set,O=new Map,j=t=>{let s;try{s=JSON.parse(t)}catch{return}if("stream_event"!==s.type&&k.line(t),"system"===s.type&&"init"===s.subtype){let t=s.mcp_servers,n=t?.find(e=>"fleetlens"===e.name);if(n&&"connected"!==n.status){E=!0,k.end({runtime:"detached",elapsed_ms:Date.now()-b,mcp_status:n.status,retried:e<3});try{C.kill("SIGTERM")}catch{}e<3?setTimeout(()=>R(e+1),750):(f({type:"error",message:`session tools failed to connect (mcp status: ${n.status}) — try again`}),w())}return}if("stream_event"===s.type){let e=s.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&q.add(e.index),f({type:"delta",text:t.text}))}return}if("assistant"===s.type){let e=s.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||q.has(t)||f({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var s;let t,n="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");O.set(n,r),f({type:"tool",id:n,name:r,input:(t=JSON.stringify(s=e.input)??"{}").length<=300?s:{_truncated:t.slice(0,300)+"…"}})}}),q=new Set;return}if("user"===s.type){let e=s.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",s=e.content,n=Array.isArray(s)?s.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof s?s:"";f({type:"tool_result",id:t,name:O.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(n),isError:!0===e.is_error})}return}"result"===s.type&&(N=!0,c=s.usage,f({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},U=new TextDecoder("utf-8");C.stdout.on("data",e=>{if(E)return;let t=(T+=U.decode(e,{stream:!0})).split("\n");for(let e of(T=t.pop()??"",t)){let t=e.trim();t&&!E&&j(t)}}),C.stderr.on("data",e=>{A.length<4e3&&(A+=e.toString("utf8"))}),C.on("close",e=>{E||(N||"running"!==d.status||f({type:"error",message:m.stoppedByUser?"stopped by user":A.trim().slice(0,400)||`claude exited with code ${e}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),w())}),C.on("error",e=>{E||(f({type:"error",message:`Failed to spawn claude: ${e.message}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:-1,error:e.message}),w())})};R(1)}],45092)},8043,e=>{"use strict";var t=e.i(47909),s=e.i(74017),n=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),m=e.i(74838),g=e.i(10372),f=e.i(93695);e.i(52474);var y=e.i(220),x=e.i(84497),_=e.i(84777),v=e.i(45092);e.s(["GET",0,function(){let e=(0,x.listChats)().map(e=>{if("running"===e.status&&!(0,v.getRun)(e.id)){let t=(0,x.readChat)(e.id);if(t){let s=(0,v.reconcileChat)(t);return{...e,status:s.status,updated_at:s.updated_at}}}return e});return Response.json({chats:e})},"POST",0,function(){let e=(0,_.createChat)();return(0,x.writeChat)(e),Response.json({id:e.id},{status:201})},"dynamic",0,"force-dynamic","runtime",0,"nodejs"],71415);var w=e.i(71415);let R=new t.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/agent/chats/route",pathname:"/api/agent/chats",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/route.ts",nextConfigOutput:"standalone",userland:w,...{}}),{workAsyncStorage:S,workUnitAsyncStorage:k,serverHooks:b}=R;async function C(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),R.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/agent/chats/route";x=x.replace(/\/index$/,"")||"/";let _=await R.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!_)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:v,params:w,nextConfig:S,parsedUrl:k,isDraftMode:b,prerenderManifest:C,routerServerContext:E,isOnDemandRevalidate:A,revalidateOnlyGenerated:T,resolvedPathname:N,clientReferenceManifest:q,serverActionsManifest:O}=_,j=(0,i.normalizeAppPath)(x),U=!!(C.dynamicRoutes[j]||C.routes[N]),D=async()=>((null==E?void 0:E.render404)?await E.render404(e,t,k,!1):t.end("This page could not be found"),null);if(U&&!b){let e=!!C.routes[N],t=C.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(S.adapterPath)return await D();throw new f.NoFallbackError}}let I=null;!U||R.isDev||b||(I="/index"===(I=N)?"/":I);let $=!0===R.isDev||!U,P=U&&!$;O&&q&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:q,serverActionsManifest:O});let M=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),B=!!(null==E?void 0:E.isWrappedByNextServer),L=!!(0,r.getRequestMeta)(e,"minimalMode"),G=(0,r.getRequestMeta)(e,"incrementalCache")||await R.getIncrementalCache(e,S,C,L);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let K={params:w,previewProps:C.preview,renderOpts:{experimental:{authInterrupts:!!S.experimental.authInterrupts},cacheComponents:!!S.cacheComponents,supportsDynamicResponse:$,incrementalCache:G,cacheLifeProfiles:S.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>R.onRequestError(e,t,n,r,E)},sharedContext:{buildId:v}},J=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),Y=d.NextRequestAdapter.fromNodeNextRequest(J,(0,d.signalFromNodeResponse)(t));try{let r,o=async e=>R.handle(Y,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=F.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=s.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${M} ${x}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:s})=>{try{if(!L&&A&&T&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=K.renderOpts.fetchMetrics;let i=K.renderOpts.pendingWaitUntil;i&&n.waitUntil&&(n.waitUntil(i),i=void 0);let l=K.renderOpts.collectedTags;if(!U)return await (0,p.sendResponse)(J,W,a,K.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[g.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,n=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:n}}}}catch(t){throw(null==s?void 0:s.isStale)&&await R.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),t}},d=await R.handleResponse({req:e,nextConfig:S,cacheKey:I,routeKind:s.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:T,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:L});if(!U)return null;if((null==d||null==(a=d.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",A?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return L&&U||u.delete(g.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(J,W,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:a.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!B))}catch(t){if(t instanceof f.NoFallbackError||await R.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),U)throw t;return await (0,p.sendResponse)(J,W,new Response(null,{status:500})),null}}e.s(["handler",0,C,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:k})},"routeModule",0,R,"serverHooks",0,b,"workAsyncStorage",0,S,"workUnitAsyncStorage",0,k],8043)}];
|
|
26
|
+
User's new message: ${s.text}`}(e.messages.map(e=>"user"===e.role?{role:"user",text:e.text}:{role:"assistant",text:e.segments.filter(e=>"text"===e.kind).map(e=>e.text).join("")}).filter(e=>e.text.trim())),w=setTimeout(()=>{f({type:"error",message:"timed out after 5 minutes"}),m.kill()},3e5),R=()=>{clearTimeout(w),g(!0),h.runs.delete(e.id)},S=e=>{var i,l,u;let c,h,g,x,w;if(m.stoppedByUser||"running"!==d.status){m.stoppedByUser&&"running"===d.status&&f({type:"error",message:"stopped by user"}),R();return}let k=(i=o.model,l=v.length,u=p(),h=(0,a.cclensPath)("llm-runs"),g=`${new Date().toISOString().replace(/[:.]/g,"-")}_agent_chat_${(0,r.randomUUID)().slice(0,8)}`,x=(0,n.join)(h,`${g}.jsonl`),(w=(e,t=!1)=>{try{let n=JSON.stringify(e)+"\n";t?((0,s.mkdirSync)(h,{recursive:!0}),(0,s.writeFileSync)(x,n)):(0,s.appendFileSync)(x,n)}catch{}})({_meta:{type:"start",run_id:g,kind:"agent_chat",model:i,ts:new Date().toISOString(),runtime:"detached",user_prompt_chars:l}},!0),w({_meta:{type:"payload",run_id:g,system_prompt:u,user_prompt:v}}),{line:e=>{try{(0,s.appendFileSync)(x,e+"\n")}catch{}},end:e=>w({_meta:{type:"end",run_id:g,ts:new Date().toISOString(),...e}})}),b=Date.now(),C=(0,t.spawn)("claude",_,{stdio:["pipe","pipe","pipe"],env:{...process.env},cwd:y});m.kill=()=>{try{C.kill("SIGTERM")}catch{}},C.stdin.write(v),C.stdin.end();let E=!1,A="",T="",N=!1,q=new Set,O=new Map,j=t=>{let s;try{s=JSON.parse(t)}catch{return}if("stream_event"!==s.type&&k.line(t),"system"===s.type&&"init"===s.subtype){let t=s.mcp_servers,n=t?.find(e=>"fleetlens"===e.name);if(n&&"connected"!==n.status){E=!0,k.end({runtime:"detached",elapsed_ms:Date.now()-b,mcp_status:n.status,retried:e<3});try{C.kill("SIGTERM")}catch{}e<3?setTimeout(()=>S(e+1),750):(f({type:"error",message:`session tools failed to connect (mcp status: ${n.status}) — try again`}),R())}return}if("stream_event"===s.type){let e=s.event;if(e?.type==="content_block_delta"){let t=e.delta;t?.type==="text_delta"&&"string"==typeof t.text&&("number"==typeof e.index&&q.add(e.index),f({type:"delta",text:t.text}))}return}if("assistant"===s.type){let e=s.message,t=e?.content;Array.isArray(t)&&t.forEach((e,t)=>{if("text"!==e.type||"string"!=typeof e.text||q.has(t)||f({type:"delta",text:e.text}),"tool_use"===e.type&&"string"==typeof e.name){var s;let t,n="string"==typeof e.id?e.id:"",r=e.name.replace(/^mcp__fleetlens__/,"");O.set(n,r),f({type:"tool",id:n,name:r,input:(t=JSON.stringify(s=e.input)??"{}").length<=300?s:{_truncated:t.slice(0,300)+"…"}})}}),q=new Set;return}if("user"===s.type){let e=s.message,t=e?.content;if(!Array.isArray(t))return;for(let e of t){if("tool_result"!==e.type)continue;let t="string"==typeof e.tool_use_id?e.tool_use_id:"",s=e.content,n=Array.isArray(s)?s.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text):"").join(""):"string"==typeof s?s:"";f({type:"tool_result",id:t,name:O.get(t)??"tool",brief:function(e){try{let t=JSON.parse(e);if("number"==typeof t.total_matches)return`${t.total_matches} matching sessions`;if(Array.isArray(t.sessions))return`${t.total??t.sessions.length} sessions`;if(Array.isArray(t.projects))return`${t.projects.length} projects`}catch{}return`${e.length.toLocaleString()} chars`}(n),isError:!0===e.is_error})}return}"result"===s.type&&(N=!0,c=s.usage,f({type:"done",totalTokens:"number"==typeof c?.input_tokens&&"number"==typeof c?.output_tokens?c.input_tokens+c.output_tokens:void 0}))},U=new TextDecoder("utf-8");C.stdout.on("data",e=>{if(E)return;let t=(T+=U.decode(e,{stream:!0})).split("\n");for(let e of(T=t.pop()??"",t)){let t=e.trim();t&&!E&&j(t)}}),C.stderr.on("data",e=>{A.length<4e3&&(A+=e.toString("utf8"))}),C.on("close",e=>{E||(N||"running"!==d.status||f({type:"error",message:m.stoppedByUser?"stopped by user":A.trim().slice(0,400)||`claude exited with code ${e}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:e??0,input_tokens:c?.input_tokens,output_tokens:c?.output_tokens}),R())}),C.on("error",e=>{E||(f({type:"error",message:`Failed to spawn claude: ${e.message}`}),k.end({runtime:"detached",elapsed_ms:Date.now()-b,exit_code:-1,error:e.message}),R())})};S(1)}],45092)},8043,e=>{"use strict";var t=e.i(47909),s=e.i(74017),n=e.i(96250),r=e.i(59756),a=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),h=e.i(70101),m=e.i(74838),g=e.i(10372),f=e.i(93695);e.i(52474);var y=e.i(220),x=e.i(84497),_=e.i(84777),v=e.i(45092);e.s(["GET",0,function(){let e=(0,x.listChats)().map(e=>{if("running"===e.status&&!(0,v.getRun)(e.id)){let t=(0,x.readChat)(e.id);if(t){let s=(0,v.reconcileChat)(t);return{...e,status:s.status,updated_at:s.updated_at}}}return e});return Response.json({chats:e})},"POST",0,function(){let e=(0,_.createChat)();return(0,x.writeChat)(e),Response.json({id:e.id},{status:201})},"dynamic",0,"force-dynamic","runtime",0,"nodejs"],71415);var w=e.i(71415);let R=new t.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/agent/chats/route",pathname:"/api/agent/chats",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/apps/web/app/api/agent/chats/route.ts",nextConfigOutput:"standalone",userland:w,...{}}),{workAsyncStorage:S,workUnitAsyncStorage:k,serverHooks:b}=R;async function C(e,t,n){n.requestMeta&&(0,r.setRequestMeta)(e,n.requestMeta),R.isDev&&(0,r.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/agent/chats/route";x=x.replace(/\/index$/,"")||"/";let _=await R.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!_)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:v,params:w,nextConfig:S,parsedUrl:k,isDraftMode:b,prerenderManifest:C,routerServerContext:E,isOnDemandRevalidate:A,revalidateOnlyGenerated:T,resolvedPathname:N,clientReferenceManifest:q,serverActionsManifest:O}=_,j=(0,i.normalizeAppPath)(x),U=!!(C.dynamicRoutes[j]||C.routes[N]),D=async()=>((null==E?void 0:E.render404)?await E.render404(e,t,k,!1):t.end("This page could not be found"),null);if(U&&!b){let e=!!C.routes[N],t=C.dynamicRoutes[j];if(t&&!1===t.fallback&&!e){if(S.adapterPath)return await D();throw new f.NoFallbackError}}let I=null;!U||R.isDev||b||(I="/index"===(I=N)?"/":I);let $=!0===R.isDev||!U,P=U&&!$;O&&q&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:q,serverActionsManifest:O});let M=e.method||"GET",F=(0,a.getTracer)(),H=F.getActiveScopeSpan(),B=!!(null==E?void 0:E.isWrappedByNextServer),L=!!(0,r.getRequestMeta)(e,"minimalMode"),G=(0,r.getRequestMeta)(e,"incrementalCache")||await R.getIncrementalCache(e,S,C,L);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let J={params:w,previewProps:C.preview,renderOpts:{experimental:{authInterrupts:!!S.experimental.authInterrupts},cacheComponents:!!S.cacheComponents,supportsDynamicResponse:$,incrementalCache:G,cacheLifeProfiles:S.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,s,n,r)=>R.onRequestError(e,t,n,r,E)},sharedContext:{buildId:v}},K=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),Y=d.NextRequestAdapter.fromNodeNextRequest(K,(0,d.signalFromNodeResponse)(t));try{let r,o=async e=>R.handle(Y,J).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let s=F.getRootSpanAttributes();if(!s)return;if(s.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${s.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let n=s.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t),r&&r!==e&&(r.setAttribute("http.route",n),r.updateName(t))}else e.updateName(`${M} ${x}`)}),i=async r=>{var a,i;let l=async({previousCacheEntry:s})=>{try{if(!L&&A&&T&&!s)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(r);e.fetchMetrics=J.renderOpts.fetchMetrics;let i=J.renderOpts.pendingWaitUntil;i&&n.waitUntil&&(n.waitUntil(i),i=void 0);let l=J.renderOpts.collectedTags;if(!U)return await (0,p.sendResponse)(K,W,a,J.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[g.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let s=void 0!==J.renderOpts.collectedRevalidate&&!(J.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&J.renderOpts.collectedRevalidate,n=void 0===J.renderOpts.collectedExpire||J.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:J.renderOpts.collectedExpire;return{value:{kind:y.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:s,expire:n}}}}catch(t){throw(null==s?void 0:s.isStale)&&await R.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),t}},d=await R.handleResponse({req:e,nextConfig:S,cacheKey:I,routeKind:s.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:T,responseGenerator:l,waitUntil:n.waitUntil,isMinimalMode:L});if(!U)return null;if((null==d||null==(a=d.value)?void 0:a.kind)!==y.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});L||t.setHeader("x-nextjs-cache",A?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return L&&U||u.delete(g.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,m.getCacheControlHeader)(d.cacheControl)),await (0,p.sendResponse)(K,W,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&H?await i(H):(r=F.getActiveScopeSpan(),await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${x}`,kind:a.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!B))}catch(t){if(t instanceof f.NoFallbackError||await R.onRequestError(e,t,{routerKind:"App Router",routePath:j,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:P,isOnDemandRevalidate:A})},!1,E),U)throw t;return await (0,p.sendResponse)(K,W,new Response(null,{status:500})),null}}e.s(["handler",0,C,"patchFetch",0,function(){return(0,n.patchFetch)({workAsyncStorage:S,workUnitAsyncStorage:k})},"routeModule",0,R,"serverHooks",0,b,"workAsyncStorage",0,S,"workUnitAsyncStorage",0,k],8043)}];
|
|
27
27
|
|
|
28
28
|
//# sourceMappingURL=%5Broot-of-the-server%5D__12jomao._.js.map
|