fleetlens 1.0.2 → 1.0.4
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.js +2 -2
- 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.js +2 -2
- package/app/apps/web/.next/server/app/agent/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/api/agent/chats/[id]/events/route.js +3 -1
- package/app/apps/web/.next/server/app/api/agent/chats/[id]/events/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/agent/chats/[id]/messages/route.js +1 -1
- package/app/apps/web/.next/server/app/api/agent/chats/[id]/messages/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/agent/chats/[id]/route.js +3 -1
- package/app/apps/web/.next/server/app/api/agent/chats/[id]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/agent/chats/[id]/stop/route.js +3 -1
- package/app/apps/web/.next/server/app/api/agent/chats/[id]/stop/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/agent/chats/route.js +3 -1
- package/app/apps/web/.next/server/app/api/agent/chats/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/agent/index/route.js +1 -1
- package/app/apps/web/.next/server/app/api/agent/index/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/agent/mcp/route.js +1 -1
- package/app/apps/web/.next/server/app/api/agent/mcp/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/agent/suggestions/route.js +1 -1
- package/app/apps/web/.next/server/app/api/agent/suggestions/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/ask/route.js +1 -1
- package/app/apps/web/.next/server/app/api/ask/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js +1 -1
- package/app/apps/web/.next/server/app/api/digest/day/[date]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js +1 -1
- package/app/apps/web/.next/server/app/api/digest/month/[yearMonth]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/month-index/route.js +1 -1
- package/app/apps/web/.next/server/app/api/digest/month-index/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js +1 -1
- package/app/apps/web/.next/server/app/api/digest/week/[startDate]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/digest/week-index/route.js +1 -1
- package/app/apps/web/.next/server/app/api/digest/week-index/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/pdf/[key]/route.js +1 -1
- package/app/apps/web/.next/server/app/api/pdf/[key]/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/projects/open-folder/route.js +1 -1
- package/app/apps/web/.next/server/app/api/projects/open-folder/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/settings/credentials/route.js +1 -1
- package/app/apps/web/.next/server/app/api/settings/credentials/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/settings/route.js +1 -1
- package/app/apps/web/.next/server/app/api/settings/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/team/onboarding/start/route.js +1 -1
- package/app/apps/web/.next/server/app/api/team/onboarding/start/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/api/team/sync-projects/route.js +1 -1
- package/app/apps/web/.next/server/app/api/team/sync-projects/route.js.nft.json +1 -1
- package/app/apps/web/.next/server/app/changelog/page.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- package/app/apps/web/.next/server/app/insights/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/page.js +2 -2
- package/app/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/parallelism/page.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- package/app/apps/web/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/runs/page.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- package/app/apps/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/settings/page.js +2 -2
- 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.js +2 -2
- 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.js +2 -2
- package/app/apps/web/.next/server/app/team/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next/server/app/usage/page.js +2 -2
- 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]__038-.1r._.js → [root-of-the-server]__0-09rjv._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0_5tf-2._.js → [root-of-the-server]__01oercw._.js} +5 -5
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__02.51sr._.js +1 -1
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__057w7kr._.js +28 -0
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0pirsh0._.js → [root-of-the-server]__07b5796._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__02puo0u._.js → [root-of-the-server]__07xaqv3._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__06xto5z._.js → [root-of-the-server]__08c24et._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0mvl0qn._.js → [root-of-the-server]__08m2h38._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0mx_9mb._.js → [root-of-the-server]__0c7ght_._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__12iid50._.js → [root-of-the-server]__0l5i8nk._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__04g-b-m._.js → [root-of-the-server]__0mcer3z._.js} +2 -2
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0o9lsie._.js +30 -0
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0367vbv._.js → [root-of-the-server]__0ozooam._.js} +2 -2
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0uf_ch4._.js +28 -0
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0uiom2m._.js +28 -0
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__096_llw._.js → [root-of-the-server]__0usaajs._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__06irs4z._.js → [root-of-the-server]__0zyh554._.js} +2 -2
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__0gvw6dk._.js → [root-of-the-server]__0~4wgaf._.js} +2 -2
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0~~bpcw._.js +3 -0
- package/app/apps/web/.next/server/chunks/{[root-of-the-server]__01~cgp8._.js → [root-of-the-server]__10.g-w1._.js} +2 -2
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__12vjv4c._.js +28 -0
- package/app/apps/web/.next/server/chunks/packages_entries_dist_node_0bckr7-.js +19 -19
- 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_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/0c89~zhm.xoni.js +1 -0
- package/app/apps/web/.next/static/chunks/0szn9z03gip~_.js +14 -0
- package/app/apps/web/app/api/ask/route.ts +8 -2
- package/app/apps/web/lib/agent/run.ts +11 -2
- 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 +159 -55
- package/dist/index.js +229 -113
- package/menubar/Fleetlens.app/Contents/Info.plist +2 -2
- package/menubar/Fleetlens.app/Contents/MacOS/FleetlensMenubar +0 -0
- package/package.json +1 -1
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__02faosk._.js +0 -30
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__02petpy._.js +0 -3
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__09cgmam._.js +0 -28
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0tk8p3d._.js +0 -28
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__0u6pamj._.js +0 -28
- package/app/apps/web/.next/server/chunks/[root-of-the-server]__12jomao._.js +0 -28
- package/app/apps/web/.next/static/chunks/0dqhn7-3.038l.js +0 -14
- /package/app/apps/web/.next/static/{zyhoVMC9iNC5vofPFRY6z → Z2JhhQdyMdGTIYOOPolIJ}/_buildManifest.js +0 -0
- /package/app/apps/web/.next/static/{zyhoVMC9iNC5vofPFRY6z → Z2JhhQdyMdGTIYOOPolIJ}/_clientMiddlewareManifest.js +0 -0
- /package/app/apps/web/.next/static/{zyhoVMC9iNC5vofPFRY6z → Z2JhhQdyMdGTIYOOPolIJ}/_ssgManifest.js +0 -0
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
<key>CFBundleName</key><string>Fleetlens</string>
|
|
11
11
|
<key>CFBundleDisplayName</key><string>Fleetlens</string>
|
|
12
12
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
13
|
-
<key>CFBundleShortVersionString</key><string>1.0.
|
|
14
|
-
<key>CFBundleVersion</key><string>1.0.
|
|
13
|
+
<key>CFBundleShortVersionString</key><string>1.0.4</string>
|
|
14
|
+
<key>CFBundleVersion</key><string>1.0.4</string>
|
|
15
15
|
<key>LSApplicationCategoryType</key><string>public.app-category.developer-tools</string>
|
|
16
16
|
<key>LSMinimumSystemVersion</key><string>14.0</string>
|
|
17
17
|
<key>LSUIElement</key><true/>
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,n)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,n)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,n)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,n)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},70406,(e,t,n)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},50227,(e,t,n)=>{t.exports=e.x("node:path",()=>require("node:path"))},2157,(e,t,n)=>{t.exports=e.x("node:fs",()=>require("node:fs"))},60526,(e,t,n)=>{t.exports=e.x("node:os",()=>require("node:os"))},66680,(e,t,n)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},74533,(e,t,n)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},45092,84497,84777,e=>{"use strict";var t=e.i(74533),n=e.i(2157),s=e.i(50227),r=e.i(66680),a=e.i(43427);function o(){return(0,a.cclensPath)("agent-chats")}function i(e){return(0,s.join)(o(),`${e}.json`)}function l(e){(0,n.mkdirSync)(o(),{recursive:!0});let t=i(e.id),s=`${t}.tmp.${process.pid}`;(0,n.writeFileSync)(s,JSON.stringify(e),"utf8"),(0,n.renameSync)(s,t)}function d(e){if(!/^[a-zA-Z0-9-]+$/.test(e))return null;try{let t=JSON.parse((0,n.readFileSync)(i(e),"utf8"));return 1===t.version?t:null}catch{return null}}function u(){return{role:"assistant",segments:[]}}function c(e,t){if(t.seq<=e.lastSeq)return e;let n=[...e.messages],s=n[n.length-1];s&&"assistant"===s.role||(s=u(),n.push(s));let r={...s,segments:[...s.segments]};n[n.length-1]=r;let a=e.status;switch(t.type){case"delta":{let e=r.segments[r.segments.length-1];e?.kind==="text"?r.segments[r.segments.length-1]={kind:"text",text:e.text+t.text}:r.segments.push({kind:"text",text:t.text});break}case"tool":r.segments.push({kind:"tool",id:t.id,name:t.name,input:t.input,done:!1});break;case"tool_result":r.segments=r.segments.map(e=>"tool"===e.kind&&e.id===t.id?{...e,brief:t.brief,isError:t.isError,done:!0}:e);break;case"done":a="idle",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0});break;case"error":a="error",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0}),r.segments.push({kind:"text",text:`
|
|
2
|
-
|
|
3
|
-
**Error:** ${t.message}`})}return{...e,messages:n,status:a,lastSeq:t.seq,updated_at:new Date().toISOString()}}function p(){let e=new Date,t=e.toLocaleDateString("en-CA"),n=e.toLocaleDateString("en-US",{weekday:"long"});return`You are the Fleetlens Agent. Fleetlens is a local, privacy-first dashboard over the user's coding-agent history: every Claude Code, Codex, Gemini (and other) session recorded on this machine. You have tools that search and read those sessions.
|
|
4
|
-
|
|
5
|
-
Today is ${n}, ${t}. All session data is local; nothing you do leaves this machine.
|
|
6
|
-
|
|
7
|
-
What users come to you for:
|
|
8
|
-
1. **Find** — locate past sessions: "where did I fix the daemon crash?", "what did I do last Tuesday?"
|
|
9
|
-
2. **Synthesize** — explain what happened across sessions: decisions made, approaches tried, gotchas hit.
|
|
10
|
-
3. **Draft a prompt** — package findings into a self-contained prompt the user can paste into a fresh coding-agent session as context for their next task.
|
|
11
|
-
|
|
12
|
-
Rules:
|
|
13
|
-
- Your ONLY tools are the four fleetlens session tools (search_sessions, get_session, list_sessions, list_projects). You have no filesystem, Bash, memory directory, or web access — never attempt Write, Edit, Read, or any other tool, and never claim you'll "update memory".
|
|
14
|
-
- Invoke tools through real tool calls only — never write function-call syntax or XML tags into your text response, and never simulate or invent tool output. If a tool fails or returns nothing, say so.
|
|
15
|
-
- Ground every claim about past work in tool results. Search before answering; if the first query is inconclusive, retry with different wording (synonyms, file names, error text). Never invent sessions or details.
|
|
16
|
-
- Don't re-fetch a session you already read this conversation — its content won't change.
|
|
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
|
-
- 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
|
-
- 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=(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
|
-
|
|
22
|
-
${s}
|
|
23
|
-
|
|
24
|
-
---
|
|
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())),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
|
-
|
|
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
|
-
|
|
30
|
-
//# sourceMappingURL=%5Broot-of-the-server%5D__02faosk._.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},12057,(e,t,r)=>{t.exports=e.x("node:util",()=>require("node:util"))},50227,(e,t,r)=>{t.exports=e.x("node:path",()=>require("node:path"))},2157,(e,t,r)=>{t.exports=e.x("node:fs",()=>require("node:fs"))},60526,(e,t,r)=>{t.exports=e.x("node:os",()=>require("node:os"))},66680,(e,t,r)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},74533,(e,t,r)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},27174,e=>{"use strict";e.i(39587),e.s([])},30212,e=>{"use strict";var t=e.i(79357);function r(e){return(0,t.toLocalDay)(e.getTime())}function n(e=new Date){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=t.getDay(),a=new Date(t);a.setDate(t.getDate()-(r+6)%7);let o=new Date(a);return o.setDate(a.getDate()+6),{start:a,end:o}}e.s(["aggregateConcurrency",0,function(e,t){let n,a=function(e,t){let r=[],n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate());for(;n.getTime()<=a.getTime();)r.push(new Date(n)),n.setDate(n.getDate()+1);return r}(t.start,t.end),o=new Map;for(let e of a)o.set(r(e),{peak:0,has_cross_project:!1});for(let t of e){let e=r(new Date(t.startMs)),n=o.get(e);n&&(t.peak>n.peak&&(n.peak=t.peak),t.crossProject&&(n.has_cross_project=!0))}let s=a.map(e=>{let t=r(e),n=o.get(t);return{date:t,peak:n.peak,has_cross_project:n.has_cross_project}}),i=0,p=0,l=0;for(let e of s)e.peak>i&&(i=e.peak,n=e.date),e.peak>=3&&p++,e.has_cross_project&&l++;return{by_day:s,peak:i,peak_day:n,multi_agent_days:p,cross_project_days:l}},"calendarMonth",0,function(e=new Date){return{start:new Date(e.getFullYear(),e.getMonth(),1),end:new Date(e.getFullYear(),e.getMonth()+1,0)}},"calendarWeek",0,n,"priorCalendarMonth",0,function(e=new Date){return{start:new Date(e.getFullYear(),e.getMonth()-1,1),end:new Date(e.getFullYear(),e.getMonth(),0)}},"priorCalendarWeek",0,function(e=new Date){let t=n(e),r=new Date(t.start);r.setDate(t.start.getDate()-1);let a=new Date(r);return a.setDate(r.getDate()-6),{start:a,end:r}}])},75169,e=>{"use strict";function t(e){let t=new Date(e),r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${a}`}function r(e=Date.now()){return t(e)}e.i(5737);let n=/^\d{4}-\d{2}-\d{2}$/;function a(e){return n.test(e)}let o=/^\d{4}-\d{2}$/;e.s(["asMonday",0,function(e){return a(e)&&1===new Date(`${e}T00:00:00`).getDay()?e:null},"currentWeekMonday",0,function(e=Date.now()){var n;let a,o;return n=r(e),o=(a=new Date(`${n}T00:00:00`)).getDay(),a.setDate(a.getDate()+(0===o?-6:1-o)),t(a.getTime())},"currentYearMonth",0,function(e=Date.now()){return r(e).slice(0,7)},"isValidDate",0,a,"isValidYearMonth",0,function(e){return o.test(e)},"todayLocal",0,r])},59639,(e,t,r)=>{t.exports=e.x("node:process",()=>require("node:process"))}];
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=%5Broot-of-the-server%5D__02petpy._.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,s)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,s)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},70406,(e,t,s)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},50227,(e,t,s)=>{t.exports=e.x("node:path",()=>require("node:path"))},2157,(e,t,s)=>{t.exports=e.x("node:fs",()=>require("node:fs"))},60526,(e,t,s)=>{t.exports=e.x("node:os",()=>require("node:os"))},66680,(e,t,s)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},74533,(e,t,s)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},27174,e=>{"use strict";e.i(39587),e.s([])},30212,e=>{"use strict";var t=e.i(79357);function s(e){return(0,t.toLocalDay)(e.getTime())}function n(e=new Date){let t=new Date(e.getFullYear(),e.getMonth(),e.getDate()),s=t.getDay(),r=new Date(t);r.setDate(t.getDate()-(s+6)%7);let a=new Date(r);return a.setDate(r.getDate()+6),{start:r,end:a}}e.s(["aggregateConcurrency",0,function(e,t){let n,r=function(e,t){let s=[],n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.getFullYear(),t.getMonth(),t.getDate());for(;n.getTime()<=r.getTime();)s.push(new Date(n)),n.setDate(n.getDate()+1);return s}(t.start,t.end),a=new Map;for(let e of r)a.set(s(e),{peak:0,has_cross_project:!1});for(let t of e){let e=s(new Date(t.startMs)),n=a.get(e);n&&(t.peak>n.peak&&(n.peak=t.peak),t.crossProject&&(n.has_cross_project=!0))}let o=r.map(e=>{let t=s(e),n=a.get(t);return{date:t,peak:n.peak,has_cross_project:n.has_cross_project}}),i=0,l=0,u=0;for(let e of o)e.peak>i&&(i=e.peak,n=e.date),e.peak>=3&&l++,e.has_cross_project&&u++;return{by_day:o,peak:i,peak_day:n,multi_agent_days:l,cross_project_days:u}},"calendarMonth",0,function(e=new Date){return{start:new Date(e.getFullYear(),e.getMonth(),1),end:new Date(e.getFullYear(),e.getMonth()+1,0)}},"calendarWeek",0,n,"priorCalendarMonth",0,function(e=new Date){return{start:new Date(e.getFullYear(),e.getMonth()-1,1),end:new Date(e.getFullYear(),e.getMonth(),0)}},"priorCalendarWeek",0,function(e=new Date){let t=n(e),s=new Date(t.start);s.setDate(t.start.getDate()-1);let r=new Date(s);return r.setDate(s.getDate()-6),{start:r,end:s}}])},45092,84497,84777,e=>{"use strict";var t=e.i(74533),s=e.i(2157),n=e.i(50227),r=e.i(66680),a=e.i(43427);function o(){return(0,a.cclensPath)("agent-chats")}function i(e){return(0,n.join)(o(),`${e}.json`)}function l(e){(0,s.mkdirSync)(o(),{recursive:!0});let t=i(e.id),n=`${t}.tmp.${process.pid}`;(0,s.writeFileSync)(n,JSON.stringify(e),"utf8"),(0,s.renameSync)(n,t)}function u(e){if(!/^[a-zA-Z0-9-]+$/.test(e))return null;try{let t=JSON.parse((0,s.readFileSync)(i(e),"utf8"));return 1===t.version?t:null}catch{return null}}function d(){return{role:"assistant",segments:[]}}function c(e,t){if(t.seq<=e.lastSeq)return e;let s=[...e.messages],n=s[s.length-1];n&&"assistant"===n.role||(n=d(),s.push(n));let r={...n,segments:[...n.segments]};s[s.length-1]=r;let a=e.status;switch(t.type){case"delta":{let e=r.segments[r.segments.length-1];e?.kind==="text"?r.segments[r.segments.length-1]={kind:"text",text:e.text+t.text}:r.segments.push({kind:"text",text:t.text});break}case"tool":r.segments.push({kind:"tool",id:t.id,name:t.name,input:t.input,done:!1});break;case"tool_result":r.segments=r.segments.map(e=>"tool"===e.kind&&e.id===t.id?{...e,brief:t.brief,isError:t.isError,done:!0}:e);break;case"done":a="idle",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0});break;case"error":a="error",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0}),r.segments.push({kind:"text",text:`
|
|
2
|
-
|
|
3
|
-
**Error:** ${t.message}`})}return{...e,messages:s,status:a,lastSeq:t.seq,updated_at:new Date().toISOString()}}function p(){let e=new Date,t=e.toLocaleDateString("en-CA"),s=e.toLocaleDateString("en-US",{weekday:"long"});return`You are the Fleetlens Agent. Fleetlens is a local, privacy-first dashboard over the user's coding-agent history: every Claude Code, Codex, Gemini (and other) session recorded on this machine. You have tools that search and read those sessions.
|
|
4
|
-
|
|
5
|
-
Today is ${s}, ${t}. All session data is local; nothing you do leaves this machine.
|
|
6
|
-
|
|
7
|
-
What users come to you for:
|
|
8
|
-
1. **Find** — locate past sessions: "where did I fix the daemon crash?", "what did I do last Tuesday?"
|
|
9
|
-
2. **Synthesize** — explain what happened across sessions: decisions made, approaches tried, gotchas hit.
|
|
10
|
-
3. **Draft a prompt** — package findings into a self-contained prompt the user can paste into a fresh coding-agent session as context for their next task.
|
|
11
|
-
|
|
12
|
-
Rules:
|
|
13
|
-
- Your ONLY tools are the four fleetlens session tools (search_sessions, get_session, list_sessions, list_projects). You have no filesystem, Bash, memory directory, or web access — never attempt Write, Edit, Read, or any other tool, and never claim you'll "update memory".
|
|
14
|
-
- Invoke tools through real tool calls only — never write function-call syntax or XML tags into your text response, and never simulate or invent tool output. If a tool fails or returns nothing, say so.
|
|
15
|
-
- Ground every claim about past work in tool results. Search before answering; if the first query is inconclusive, retry with different wording (synonyms, file names, error text). Never invent sessions or details.
|
|
16
|
-
- Don't re-fetch a session you already read this conversation — its content won't change.
|
|
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
|
-
- 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
|
-
- 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=(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
|
-
|
|
22
|
-
${n}
|
|
23
|
-
|
|
24
|
-
---
|
|
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"}),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
|
-
|
|
28
|
-
//# sourceMappingURL=%5Broot-of-the-server%5D__09cgmam._.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,s)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,s)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},70406,(e,t,s)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},50227,(e,t,s)=>{t.exports=e.x("node:path",()=>require("node:path"))},2157,(e,t,s)=>{t.exports=e.x("node:fs",()=>require("node:fs"))},60526,(e,t,s)=>{t.exports=e.x("node:os",()=>require("node:os"))},66680,(e,t,s)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},74533,(e,t,s)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},45092,84497,84777,e=>{"use strict";var t=e.i(74533),s=e.i(2157),n=e.i(50227),r=e.i(66680),a=e.i(43427);function o(){return(0,a.cclensPath)("agent-chats")}function i(e){return(0,n.join)(o(),`${e}.json`)}function l(e){(0,s.mkdirSync)(o(),{recursive:!0});let t=i(e.id),n=`${t}.tmp.${process.pid}`;(0,s.writeFileSync)(n,JSON.stringify(e),"utf8"),(0,s.renameSync)(n,t)}function d(e){if(!/^[a-zA-Z0-9-]+$/.test(e))return null;try{let t=JSON.parse((0,s.readFileSync)(i(e),"utf8"));return 1===t.version?t:null}catch{return null}}function u(){return{role:"assistant",segments:[]}}function c(e,t){if(t.seq<=e.lastSeq)return e;let s=[...e.messages],n=s[s.length-1];n&&"assistant"===n.role||(n=u(),s.push(n));let r={...n,segments:[...n.segments]};s[s.length-1]=r;let a=e.status;switch(t.type){case"delta":{let e=r.segments[r.segments.length-1];e?.kind==="text"?r.segments[r.segments.length-1]={kind:"text",text:e.text+t.text}:r.segments.push({kind:"text",text:t.text});break}case"tool":r.segments.push({kind:"tool",id:t.id,name:t.name,input:t.input,done:!1});break;case"tool_result":r.segments=r.segments.map(e=>"tool"===e.kind&&e.id===t.id?{...e,brief:t.brief,isError:t.isError,done:!0}:e);break;case"done":a="idle",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0});break;case"error":a="error",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0}),r.segments.push({kind:"text",text:`
|
|
2
|
-
|
|
3
|
-
**Error:** ${t.message}`})}return{...e,messages:s,status:a,lastSeq:t.seq,updated_at:new Date().toISOString()}}function p(){let e=new Date,t=e.toLocaleDateString("en-CA"),s=e.toLocaleDateString("en-US",{weekday:"long"});return`You are the Fleetlens Agent. Fleetlens is a local, privacy-first dashboard over the user's coding-agent history: every Claude Code, Codex, Gemini (and other) session recorded on this machine. You have tools that search and read those sessions.
|
|
4
|
-
|
|
5
|
-
Today is ${s}, ${t}. All session data is local; nothing you do leaves this machine.
|
|
6
|
-
|
|
7
|
-
What users come to you for:
|
|
8
|
-
1. **Find** — locate past sessions: "where did I fix the daemon crash?", "what did I do last Tuesday?"
|
|
9
|
-
2. **Synthesize** — explain what happened across sessions: decisions made, approaches tried, gotchas hit.
|
|
10
|
-
3. **Draft a prompt** — package findings into a self-contained prompt the user can paste into a fresh coding-agent session as context for their next task.
|
|
11
|
-
|
|
12
|
-
Rules:
|
|
13
|
-
- Your ONLY tools are the four fleetlens session tools (search_sessions, get_session, list_sessions, list_projects). You have no filesystem, Bash, memory directory, or web access — never attempt Write, Edit, Read, or any other tool, and never claim you'll "update memory".
|
|
14
|
-
- Invoke tools through real tool calls only — never write function-call syntax or XML tags into your text response, and never simulate or invent tool output. If a tool fails or returns nothing, say so.
|
|
15
|
-
- Ground every claim about past work in tool results. Search before answering; if the first query is inconclusive, retry with different wording (synonyms, file names, error text). Never invent sessions or details.
|
|
16
|
-
- Don't re-fetch a session you already read this conversation — its content won't change.
|
|
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
|
-
- 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
|
-
- 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=(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
|
-
|
|
22
|
-
${n}
|
|
23
|
-
|
|
24
|
-
---
|
|
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"}),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
|
-
|
|
28
|
-
//# sourceMappingURL=%5Broot-of-the-server%5D__0tk8p3d._.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,s)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,s)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},70406,(e,t,s)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},50227,(e,t,s)=>{t.exports=e.x("node:path",()=>require("node:path"))},2157,(e,t,s)=>{t.exports=e.x("node:fs",()=>require("node:fs"))},60526,(e,t,s)=>{t.exports=e.x("node:os",()=>require("node:os"))},66680,(e,t,s)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},74533,(e,t,s)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},45092,84497,84777,e=>{"use strict";var t=e.i(74533),s=e.i(2157),n=e.i(50227),r=e.i(66680),a=e.i(43427);function o(){return(0,a.cclensPath)("agent-chats")}function i(e){return(0,n.join)(o(),`${e}.json`)}function l(e){(0,s.mkdirSync)(o(),{recursive:!0});let t=i(e.id),n=`${t}.tmp.${process.pid}`;(0,s.writeFileSync)(n,JSON.stringify(e),"utf8"),(0,s.renameSync)(n,t)}function d(e){if(!/^[a-zA-Z0-9-]+$/.test(e))return null;try{let t=JSON.parse((0,s.readFileSync)(i(e),"utf8"));return 1===t.version?t:null}catch{return null}}function u(){return{role:"assistant",segments:[]}}function c(e,t){if(t.seq<=e.lastSeq)return e;let s=[...e.messages],n=s[s.length-1];n&&"assistant"===n.role||(n=u(),s.push(n));let r={...n,segments:[...n.segments]};s[s.length-1]=r;let a=e.status;switch(t.type){case"delta":{let e=r.segments[r.segments.length-1];e?.kind==="text"?r.segments[r.segments.length-1]={kind:"text",text:e.text+t.text}:r.segments.push({kind:"text",text:t.text});break}case"tool":r.segments.push({kind:"tool",id:t.id,name:t.name,input:t.input,done:!1});break;case"tool_result":r.segments=r.segments.map(e=>"tool"===e.kind&&e.id===t.id?{...e,brief:t.brief,isError:t.isError,done:!0}:e);break;case"done":a="idle",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0});break;case"error":a="error",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0}),r.segments.push({kind:"text",text:`
|
|
2
|
-
|
|
3
|
-
**Error:** ${t.message}`})}return{...e,messages:s,status:a,lastSeq:t.seq,updated_at:new Date().toISOString()}}function p(){let e=new Date,t=e.toLocaleDateString("en-CA"),s=e.toLocaleDateString("en-US",{weekday:"long"});return`You are the Fleetlens Agent. Fleetlens is a local, privacy-first dashboard over the user's coding-agent history: every Claude Code, Codex, Gemini (and other) session recorded on this machine. You have tools that search and read those sessions.
|
|
4
|
-
|
|
5
|
-
Today is ${s}, ${t}. All session data is local; nothing you do leaves this machine.
|
|
6
|
-
|
|
7
|
-
What users come to you for:
|
|
8
|
-
1. **Find** — locate past sessions: "where did I fix the daemon crash?", "what did I do last Tuesday?"
|
|
9
|
-
2. **Synthesize** — explain what happened across sessions: decisions made, approaches tried, gotchas hit.
|
|
10
|
-
3. **Draft a prompt** — package findings into a self-contained prompt the user can paste into a fresh coding-agent session as context for their next task.
|
|
11
|
-
|
|
12
|
-
Rules:
|
|
13
|
-
- Your ONLY tools are the four fleetlens session tools (search_sessions, get_session, list_sessions, list_projects). You have no filesystem, Bash, memory directory, or web access — never attempt Write, Edit, Read, or any other tool, and never claim you'll "update memory".
|
|
14
|
-
- Invoke tools through real tool calls only — never write function-call syntax or XML tags into your text response, and never simulate or invent tool output. If a tool fails or returns nothing, say so.
|
|
15
|
-
- Ground every claim about past work in tool results. Search before answering; if the first query is inconclusive, retry with different wording (synonyms, file names, error text). Never invent sessions or details.
|
|
16
|
-
- Don't re-fetch a session you already read this conversation — its content won't change.
|
|
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
|
-
- 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
|
-
- 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=(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
|
-
|
|
22
|
-
${n}
|
|
23
|
-
|
|
24
|
-
---
|
|
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"}),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
|
-
|
|
28
|
-
//# sourceMappingURL=%5Broot-of-the-server%5D__0u6pamj._.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,s)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,s)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},70406,(e,t,s)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},50227,(e,t,s)=>{t.exports=e.x("node:path",()=>require("node:path"))},2157,(e,t,s)=>{t.exports=e.x("node:fs",()=>require("node:fs"))},60526,(e,t,s)=>{t.exports=e.x("node:os",()=>require("node:os"))},66680,(e,t,s)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},74533,(e,t,s)=>{t.exports=e.x("node:child_process",()=>require("node:child_process"))},45092,84497,84777,e=>{"use strict";var t=e.i(74533),s=e.i(2157),n=e.i(50227),r=e.i(66680),a=e.i(43427);function o(){return(0,a.cclensPath)("agent-chats")}function i(e){return(0,n.join)(o(),`${e}.json`)}function l(e){(0,s.mkdirSync)(o(),{recursive:!0});let t=i(e.id),n=`${t}.tmp.${process.pid}`;(0,s.writeFileSync)(n,JSON.stringify(e),"utf8"),(0,s.renameSync)(n,t)}function d(e){if(!/^[a-zA-Z0-9-]+$/.test(e))return null;try{let t=JSON.parse((0,s.readFileSync)(i(e),"utf8"));return 1===t.version?t:null}catch{return null}}function u(){return{role:"assistant",segments:[]}}function c(e,t){if(t.seq<=e.lastSeq)return e;let s=[...e.messages],n=s[s.length-1];n&&"assistant"===n.role||(n=u(),s.push(n));let r={...n,segments:[...n.segments]};s[s.length-1]=r;let a=e.status;switch(t.type){case"delta":{let e=r.segments[r.segments.length-1];e?.kind==="text"?r.segments[r.segments.length-1]={kind:"text",text:e.text+t.text}:r.segments.push({kind:"text",text:t.text});break}case"tool":r.segments.push({kind:"tool",id:t.id,name:t.name,input:t.input,done:!1});break;case"tool_result":r.segments=r.segments.map(e=>"tool"===e.kind&&e.id===t.id?{...e,brief:t.brief,isError:t.isError,done:!0}:e);break;case"done":a="idle",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0});break;case"error":a="error",r.segments=r.segments.map(e=>"tool"!==e.kind||e.done?e:{...e,done:!0}),r.segments.push({kind:"text",text:`
|
|
2
|
-
|
|
3
|
-
**Error:** ${t.message}`})}return{...e,messages:s,status:a,lastSeq:t.seq,updated_at:new Date().toISOString()}}function p(){let e=new Date,t=e.toLocaleDateString("en-CA"),s=e.toLocaleDateString("en-US",{weekday:"long"});return`You are the Fleetlens Agent. Fleetlens is a local, privacy-first dashboard over the user's coding-agent history: every Claude Code, Codex, Gemini (and other) session recorded on this machine. You have tools that search and read those sessions.
|
|
4
|
-
|
|
5
|
-
Today is ${s}, ${t}. All session data is local; nothing you do leaves this machine.
|
|
6
|
-
|
|
7
|
-
What users come to you for:
|
|
8
|
-
1. **Find** — locate past sessions: "where did I fix the daemon crash?", "what did I do last Tuesday?"
|
|
9
|
-
2. **Synthesize** — explain what happened across sessions: decisions made, approaches tried, gotchas hit.
|
|
10
|
-
3. **Draft a prompt** — package findings into a self-contained prompt the user can paste into a fresh coding-agent session as context for their next task.
|
|
11
|
-
|
|
12
|
-
Rules:
|
|
13
|
-
- Your ONLY tools are the four fleetlens session tools (search_sessions, get_session, list_sessions, list_projects). You have no filesystem, Bash, memory directory, or web access — never attempt Write, Edit, Read, or any other tool, and never claim you'll "update memory".
|
|
14
|
-
- Invoke tools through real tool calls only — never write function-call syntax or XML tags into your text response, and never simulate or invent tool output. If a tool fails or returns nothing, say so.
|
|
15
|
-
- Ground every claim about past work in tool results. Search before answering; if the first query is inconclusive, retry with different wording (synonyms, file names, error text). Never invent sessions or details.
|
|
16
|
-
- Don't re-fetch a session you already read this conversation — its content won't change.
|
|
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
|
-
- 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
|
-
- 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=(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
|
-
|
|
22
|
-
${n}
|
|
23
|
-
|
|
24
|
-
---
|
|
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"}),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
|
-
|
|
28
|
-
//# sourceMappingURL=%5Broot-of-the-server%5D__12jomao._.js.map
|