codesesh 0.1.4 → 0.1.5

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/dist/index.js CHANGED
@@ -92,12 +92,12 @@ function createApiRoutes(scanResult) {
92
92
 
93
93
  // src/server.ts
94
94
  function findWebDistPath() {
95
- const __dirname = dirname(fileURLToPath(import.meta.url));
96
- const packagedPath = resolve(__dirname, "web");
95
+ const __dirname2 = dirname(fileURLToPath(import.meta.url));
96
+ const packagedPath = resolve(__dirname2, "web");
97
97
  if (existsSync(packagedPath)) {
98
98
  return packagedPath;
99
99
  }
100
- const devPath = resolve(__dirname, "../../../apps/web/dist");
100
+ const devPath = resolve(__dirname2, "../../../apps/web/dist");
101
101
  if (existsSync(devPath)) {
102
102
  return devPath;
103
103
  }
@@ -122,11 +122,21 @@ async function createServer(port, scanResult) {
122
122
 
123
123
  // src/output.ts
124
124
  import { consola } from "consola";
125
+
126
+ // src/version.ts
127
+ import { readFileSync } from "fs";
128
+ import { resolve as resolve2, dirname as dirname2 } from "path";
129
+ import { fileURLToPath as fileURLToPath2 } from "url";
130
+ var __dirname = dirname2(fileURLToPath2(import.meta.url));
131
+ var pkg = JSON.parse(readFileSync(resolve2(__dirname, "../package.json"), "utf-8"));
132
+ var VERSION = pkg.version;
133
+
134
+ // src/output.ts
125
135
  function printScanResults(agents, result) {
126
136
  consola.log("");
127
137
  consola.box({
128
138
  title: "CodeSesh",
129
- message: `v0.1.1 \u2022 ${result.sessions.length} sessions discovered`,
139
+ message: `v${VERSION} \u2022 ${result.sessions.length} sessions discovered`,
130
140
  style: {
131
141
  padding: 1,
132
142
  borderColor: "cyan"
@@ -161,7 +171,6 @@ function dim(text) {
161
171
  }
162
172
 
163
173
  // src/index.ts
164
- var VERSION = "0.1.1";
165
174
  function parseDateToTimestamp(dateStr) {
166
175
  const date = new Date(dateStr);
167
176
  if (Number.isNaN(date.getTime())) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/server.ts","../src/api/routes.ts","../src/api/handlers.ts","../src/output.ts"],"sourcesContent":["import { defineCommand, runMain } from \"citty\";\nimport { createServer } from \"./server.js\";\nimport { printScanResults } from \"./output.js\";\nimport {\n scanSessionsAsync,\n createRegisteredAgents,\n getAgentInfoMap,\n type ScanOptions,\n perf,\n} from \"@codesesh/core\";\n\nconst VERSION = \"0.1.1\";\n\nfunction parseDateToTimestamp(dateStr: string): number {\n const date = new Date(dateStr);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid date: ${dateStr}`);\n }\n return date.getTime();\n}\n\nfunction parseSessionUri(uri: string): { agent: string; sessionId: string } | null {\n const match = uri.match(/^([a-z]+):\\/\\/(.+)$/i);\n if (!match) return null;\n return { agent: match[1]!, sessionId: match[2]! };\n}\n\nconst main = defineCommand({\n meta: {\n name: \"codesesh\",\n description: \"Discover, aggregate, and visualize AI coding agent sessions\",\n version: VERSION,\n },\n args: {\n port: {\n type: \"string\",\n alias: \"p\",\n description: \"HTTP server port\",\n default: \"4321\",\n },\n agent: {\n type: \"string\",\n alias: \"a\",\n description: \"Filter to specific agent(s), comma-separated\",\n },\n days: {\n type: \"string\",\n alias: \"d\",\n description: \"Only include sessions from the last N days (0 = all time)\",\n default: \"7\",\n },\n cwd: {\n type: \"string\",\n description: \"Filter to sessions from a specific project directory (use '.' for current dir)\",\n },\n from: {\n type: \"string\",\n description: \"Sessions created after this date, YYYY-MM-DD (overrides --days)\",\n },\n to: {\n type: \"string\",\n description: \"Sessions created before this date (YYYY-MM-DD)\",\n },\n session: {\n type: \"string\",\n alias: \"s\",\n description: \"Directly open a specific session (agent://session-id)\",\n },\n json: {\n type: \"boolean\",\n alias: \"j\",\n description: \"Output session index as JSON to stdout (no server)\",\n default: false,\n },\n noOpen: {\n type: \"boolean\",\n description: \"Don't auto-open browser\",\n default: false,\n },\n trace: {\n type: \"boolean\",\n description: \"Show performance trace logs\",\n default: false,\n },\n cache: {\n type: \"boolean\",\n description: \"Use cached scan results if available\",\n default: true,\n },\n \"clear-cache\": {\n type: \"boolean\",\n description: \"Clear scan cache before starting\",\n default: false,\n },\n },\n async run({ args }) {\n const port = parseInt(args.port as string, 10) || 4321;\n const noOpen = args.noOpen as boolean;\n const jsonOnly = args.json as boolean;\n const trace = args.trace as boolean;\n const useCache = args.cache as boolean;\n const clearCache = args[\"clear-cache\"] as boolean;\n\n if (trace) {\n perf.enable();\n }\n\n if (clearCache) {\n const { clearCache: clear } = await import(\"@codesesh/core\");\n clear();\n console.log(\"Cache cleared.\");\n }\n\n // Parse session URI if provided\n let targetSession: { agent: string; sessionId: string } | null = null;\n if (args.session) {\n targetSession = parseSessionUri(args.session as string);\n if (!targetSession) {\n console.error(`Invalid session format: ${args.session}. Expected: agent://session-id`);\n process.exit(1);\n }\n }\n\n // Resolve cwd filter: '.' => process.cwd()\n let cwdFilter = args.cwd as string | undefined;\n if (cwdFilter === \".\") {\n cwdFilter = process.cwd();\n }\n\n // Resolve from timestamp: --from takes priority over --days\n let fromTimestamp: number | undefined;\n if (args.from) {\n fromTimestamp = parseDateToTimestamp(args.from as string);\n } else {\n const days = parseInt(args.days as string, 10);\n if (!Number.isNaN(days) && days > 0) {\n fromTimestamp = Date.now() - days * 24 * 60 * 60 * 1000;\n }\n }\n\n // Build scan options\n const scanOptions: ScanOptions = {\n agents: targetSession\n ? [targetSession.agent]\n : args.agent\n ? (args.agent as string).split(\",\").map((a) => a.trim())\n : undefined,\n cwd: cwdFilter,\n from: fromTimestamp,\n to: args.to ? parseDateToTimestamp(args.to as string) : undefined,\n useCache: useCache,\n };\n\n // Scan sessions (parallel)\n const result = await scanSessionsAsync(scanOptions);\n\n if (trace) {\n console.log(perf.getReport());\n }\n\n if (jsonOnly) {\n const info = getAgentInfoMap(\n Object.fromEntries(Object.entries(result.byAgent).map(([k, v]) => [k, v.length])),\n );\n const output = {\n agents: info.map(({ name, displayName, count }) => ({\n name,\n displayName,\n count,\n available: count > 0,\n })),\n sessions: result.sessions,\n };\n console.log(JSON.stringify(output, null, 2));\n return;\n }\n\n // Print console output\n const agents = createRegisteredAgents();\n printScanResults(agents, result);\n\n // Start server\n const { url } = await createServer(port, result);\n\n console.log(` http://localhost:${port}`);\n console.log(\"\");\n\n if (!noOpen) {\n const open = (await import(\"open\")).default;\n const targetUrl = targetSession\n ? `${url}/${targetSession.agent.toLowerCase()}/${targetSession.sessionId}`\n : url;\n await open(targetUrl);\n }\n },\n});\n\nif (process.argv.slice(2).includes(\"-v\")) {\n console.log(VERSION);\n process.exit(0);\n}\n\nrunMain(main);\n","import { Hono } from \"hono\";\nimport { serve } from \"@hono/node-server\";\nimport { serveStatic } from \"@hono/node-server/serve-static\";\nimport { logger } from \"hono/logger\";\nimport { existsSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ScanResult } from \"@codesesh/core\";\nimport { createApiRoutes } from \"./api/routes.js\";\n\nfunction findWebDistPath(): string | null {\n const __dirname = dirname(fileURLToPath(import.meta.url));\n\n // Priority 1: Packaged web dist (copied during build)\n const packagedPath = resolve(__dirname, \"web\");\n if (existsSync(packagedPath)) {\n return packagedPath;\n }\n\n // Priority 2: Development path (monorepo)\n const devPath = resolve(__dirname, \"../../../apps/web/dist\");\n if (existsSync(devPath)) {\n return devPath;\n }\n\n return null;\n}\n\nexport async function createServer(\n port: number,\n scanResult: ScanResult,\n): Promise<{ url: string; shutdown: () => void }> {\n const app = new Hono();\n\n app.use(\"*\", logger());\n\n // API routes\n app.route(\"/api\", createApiRoutes(scanResult));\n\n // Serve static files from web dist (if available)\n const webDistPath = findWebDistPath();\n\n if (webDistPath) {\n app.use(\"/*\", serveStatic({ root: webDistPath }));\n app.get(\"/*\", serveStatic({ root: webDistPath, path: \"index.html\" }));\n }\n\n const server = serve({ fetch: app.fetch, port });\n\n const url = `http://localhost:${port}`;\n\n return {\n url,\n shutdown: () => server.close(),\n };\n}\n","import { Hono } from \"hono\";\nimport type { ScanResult } from \"@codesesh/core\";\nimport { handleGetAgents, handleGetSessions, handleGetSessionData } from \"./handlers.js\";\n\nexport function createApiRoutes(scanResult: ScanResult): Hono {\n const api = new Hono();\n\n api.get(\"/agents\", (c) => handleGetAgents(c, scanResult));\n api.get(\"/sessions\", (c) => handleGetSessions(c, scanResult));\n api.get(\"/sessions/:agent/:id\", (c) => handleGetSessionData(c, scanResult));\n\n return api;\n}\n","import type { Context } from \"hono\";\nimport type { ScanResult, SessionData, SessionHead } from \"@codesesh/core\";\nimport { getAgentInfoMap } from \"@codesesh/core\";\n\nexport function handleGetAgents(c: Context, scanResult: ScanResult) {\n const counts: Record<string, number> = {};\n for (const agent of scanResult.agents) {\n counts[agent.name] = scanResult.byAgent[agent.name]?.length ?? 0;\n }\n const info = getAgentInfoMap(counts);\n return c.json(info);\n}\n\nexport function handleGetSessions(c: Context, scanResult: ScanResult) {\n const agent = c.req.query(\"agent\");\n const q = c.req.query(\"q\")?.toLowerCase();\n const cwd = c.req.query(\"cwd\")?.toLowerCase();\n const from = c.req.query(\"from\");\n const to = c.req.query(\"to\");\n\n let sessions: SessionHead[] = [];\n\n // If agent filter is specified, use byAgent directly\n if (agent && scanResult.byAgent[agent]) {\n sessions = [...scanResult.byAgent[agent]!];\n } else {\n sessions = [...scanResult.sessions];\n }\n\n if (cwd) {\n sessions = sessions.filter((s) => s.directory.toLowerCase().includes(cwd));\n }\n\n if (from) {\n const fromTs = new Date(from).getTime();\n if (!Number.isNaN(fromTs)) {\n sessions = sessions.filter((s) => s.time_created >= fromTs);\n }\n }\n\n if (to) {\n const toTs = new Date(to).getTime();\n if (!Number.isNaN(toTs)) {\n sessions = sessions.filter((s) => s.time_created <= toTs);\n }\n }\n\n if (q) {\n sessions = sessions.filter((s) => s.title.toLowerCase().includes(q));\n }\n\n return c.json({ sessions });\n}\n\nexport async function handleGetSessionData(c: Context, scanResult: ScanResult) {\n const agentName = c.req.param(\"agent\");\n const sessionId = c.req.param(\"id\");\n\n if (!sessionId) {\n return c.json({ error: \"Missing session ID\" }, 400);\n }\n\n const agent = scanResult.agents.find((a) => a.name === agentName);\n\n if (!agent) {\n return c.json({ error: `Unknown agent: ${agentName}` }, 404);\n }\n\n try {\n const data: SessionData = agent.getSessionData(sessionId);\n return c.json(data);\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to load session\";\n return c.json({ error: message }, 500);\n }\n}\n","import { consola } from \"consola\";\nimport type { BaseAgent } from \"@codesesh/core\";\nimport type { ScanResult } from \"@codesesh/core\";\n\nexport function printScanResults(agents: BaseAgent[], result: ScanResult): void {\n consola.log(\"\");\n consola.box({\n title: \"CodeSesh\",\n message: `v0.1.1 • ${result.sessions.length} sessions discovered`,\n style: {\n padding: 1,\n borderColor: \"cyan\",\n },\n });\n consola.log(\"\");\n\n const rows: string[] = [];\n let availableCount = 0;\n\n for (const agent of agents) {\n const sessions = result.byAgent[agent.name];\n const count = sessions?.length ?? 0;\n if (count > 0) {\n availableCount++;\n rows.push(` ${green(\"✔\")} ${pad(agent.displayName)} ${dim(`${count} sessions`)}`);\n } else {\n rows.push(` ${dim(\"✖\")} ${pad(agent.displayName)} ${dim(\"not found\")}`);\n }\n }\n\n consola.log(rows.join(\"\\n\"));\n consola.log(\"\");\n consola.info(`Active: ${availableCount}/${agents.length} agents`);\n consola.log(\"\");\n}\n\nfunction pad(text: string, length = 16): string {\n return text.padEnd(length);\n}\n\nfunction green(text: string): string {\n return `\\x1b[32m${text}\\x1b[0m`;\n}\n\nfunction dim(text: string): string {\n return `\\x1b[2m${text}\\x1b[0m`;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,eAAe,eAAe;;;ACAvC,SAAS,QAAAA,aAAY;AACrB,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;;;ACN9B,SAAS,YAAY;;;ACId,SAAS,gBAAgB,GAAY,YAAwB;AAClE,Q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Q,IAAI,EAAE;AAEd,QAAI,CAAC,QAAQ;AACX,YAAM,QAAQ,MAAM,OAAO,MAAM,GAAG;AACpC,YAAM,YAAY,gBACd,GAAG,GAAG,IAAI,cAAc,MAAM,YAAY,CAAC,IAAI,cAAc,SAAS,KACtE;AACJ,YAAM,KAAK,SAAS;AAAA,IACtB;AAAA,EACF;AACF,CAAC;AAED,IAAI,QAAQ,KAAK,MAAM,CAAC,EAAE,SAAS,IAAI,GAAG;AACxC,UAAQ,IAAI,OAAO;AACnB,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,IAAI;","names":["Hono","Hono"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/server.ts","../src/api/routes.ts","../src/api/handlers.ts","../src/output.ts","../src/version.ts"],"sourcesContent":["import { defineCommand, runMain } from \"citty\";\nimport { createServer } from \"./server.js\";\nimport { printScanResults } from \"./output.js\";\nimport { VERSION } from \"./version.js\";\nimport {\n scanSessionsAsync,\n createRegisteredAgents,\n getAgentInfoMap,\n type ScanOptions,\n perf,\n} from \"@codesesh/core\";\n\nfunction parseDateToTimestamp(dateStr: string): number {\n const date = new Date(dateStr);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid date: ${dateStr}`);\n }\n return date.getTime();\n}\n\nfunction parseSessionUri(uri: string): { agent: string; sessionId: string } | null {\n const match = uri.match(/^([a-z]+):\\/\\/(.+)$/i);\n if (!match) return null;\n return { agent: match[1]!, sessionId: match[2]! };\n}\n\nconst main = defineCommand({\n meta: {\n name: \"codesesh\",\n description: \"Discover, aggregate, and visualize AI coding agent sessions\",\n version: VERSION,\n },\n args: {\n port: {\n type: \"string\",\n alias: \"p\",\n description: \"HTTP server port\",\n default: \"4321\",\n },\n agent: {\n type: \"string\",\n alias: \"a\",\n description: \"Filter to specific agent(s), comma-separated\",\n },\n days: {\n type: \"string\",\n alias: \"d\",\n description: \"Only include sessions from the last N days (0 = all time)\",\n default: \"7\",\n },\n cwd: {\n type: \"string\",\n description: \"Filter to sessions from a specific project directory (use '.' for current dir)\",\n },\n from: {\n type: \"string\",\n description: \"Sessions created after this date, YYYY-MM-DD (overrides --days)\",\n },\n to: {\n type: \"string\",\n description: \"Sessions created before this date (YYYY-MM-DD)\",\n },\n session: {\n type: \"string\",\n alias: \"s\",\n description: \"Directly open a specific session (agent://session-id)\",\n },\n json: {\n type: \"boolean\",\n alias: \"j\",\n description: \"Output session index as JSON to stdout (no server)\",\n default: false,\n },\n noOpen: {\n type: \"boolean\",\n description: \"Don't auto-open browser\",\n default: false,\n },\n trace: {\n type: \"boolean\",\n description: \"Show performance trace logs\",\n default: false,\n },\n cache: {\n type: \"boolean\",\n description: \"Use cached scan results if available\",\n default: true,\n },\n \"clear-cache\": {\n type: \"boolean\",\n description: \"Clear scan cache before starting\",\n default: false,\n },\n },\n async run({ args }) {\n const port = parseInt(args.port as string, 10) || 4321;\n const noOpen = args.noOpen as boolean;\n const jsonOnly = args.json as boolean;\n const trace = args.trace as boolean;\n const useCache = args.cache as boolean;\n const clearCache = args[\"clear-cache\"] as boolean;\n\n if (trace) {\n perf.enable();\n }\n\n if (clearCache) {\n const { clearCache: clear } = await import(\"@codesesh/core\");\n clear();\n console.log(\"Cache cleared.\");\n }\n\n // Parse session URI if provided\n let targetSession: { agent: string; sessionId: string } | null = null;\n if (args.session) {\n targetSession = parseSessionUri(args.session as string);\n if (!targetSession) {\n console.error(`Invalid session format: ${args.session}. Expected: agent://session-id`);\n process.exit(1);\n }\n }\n\n // Resolve cwd filter: '.' => process.cwd()\n let cwdFilter = args.cwd as string | undefined;\n if (cwdFilter === \".\") {\n cwdFilter = process.cwd();\n }\n\n // Resolve from timestamp: --from takes priority over --days\n let fromTimestamp: number | undefined;\n if (args.from) {\n fromTimestamp = parseDateToTimestamp(args.from as string);\n } else {\n const days = parseInt(args.days as string, 10);\n if (!Number.isNaN(days) && days > 0) {\n fromTimestamp = Date.now() - days * 24 * 60 * 60 * 1000;\n }\n }\n\n // Build scan options\n const scanOptions: ScanOptions = {\n agents: targetSession\n ? [targetSession.agent]\n : args.agent\n ? (args.agent as string).split(\",\").map((a) => a.trim())\n : undefined,\n cwd: cwdFilter,\n from: fromTimestamp,\n to: args.to ? parseDateToTimestamp(args.to as string) : undefined,\n useCache: useCache,\n };\n\n // Scan sessions (parallel)\n const result = await scanSessionsAsync(scanOptions);\n\n if (trace) {\n console.log(perf.getReport());\n }\n\n if (jsonOnly) {\n const info = getAgentInfoMap(\n Object.fromEntries(Object.entries(result.byAgent).map(([k, v]) => [k, v.length])),\n );\n const output = {\n agents: info.map(({ name, displayName, count }) => ({\n name,\n displayName,\n count,\n available: count > 0,\n })),\n sessions: result.sessions,\n };\n console.log(JSON.stringify(output, null, 2));\n return;\n }\n\n // Print console output\n const agents = createRegisteredAgents();\n printScanResults(agents, result);\n\n // Start server\n const { url } = await createServer(port, result);\n\n console.log(` http://localhost:${port}`);\n console.log(\"\");\n\n if (!noOpen) {\n const open = (await import(\"open\")).default;\n const targetUrl = targetSession\n ? `${url}/${targetSession.agent.toLowerCase()}/${targetSession.sessionId}`\n : url;\n await open(targetUrl);\n }\n },\n});\n\nif (process.argv.slice(2).includes(\"-v\")) {\n console.log(VERSION);\n process.exit(0);\n}\n\nrunMain(main);\n","import { Hono } from \"hono\";\nimport { serve } from \"@hono/node-server\";\nimport { serveStatic } from \"@hono/node-server/serve-static\";\nimport { logger } from \"hono/logger\";\nimport { existsSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ScanResult } from \"@codesesh/core\";\nimport { createApiRoutes } from \"./api/routes.js\";\n\nfunction findWebDistPath(): string | null {\n const __dirname = dirname(fileURLToPath(import.meta.url));\n\n // Priority 1: Packaged web dist (copied during build)\n const packagedPath = resolve(__dirname, \"web\");\n if (existsSync(packagedPath)) {\n return packagedPath;\n }\n\n // Priority 2: Development path (monorepo)\n const devPath = resolve(__dirname, \"../../../apps/web/dist\");\n if (existsSync(devPath)) {\n return devPath;\n }\n\n return null;\n}\n\nexport async function createServer(\n port: number,\n scanResult: ScanResult,\n): Promise<{ url: string; shutdown: () => void }> {\n const app = new Hono();\n\n app.use(\"*\", logger());\n\n // API routes\n app.route(\"/api\", createApiRoutes(scanResult));\n\n // Serve static files from web dist (if available)\n const webDistPath = findWebDistPath();\n\n if (webDistPath) {\n app.use(\"/*\", serveStatic({ root: webDistPath }));\n app.get(\"/*\", serveStatic({ root: webDistPath, path: \"index.html\" }));\n }\n\n const server = serve({ fetch: app.fetch, port });\n\n const url = `http://localhost:${port}`;\n\n return {\n url,\n shutdown: () => server.close(),\n };\n}\n","import { Hono } from \"hono\";\nimport type { ScanResult } from \"@codesesh/core\";\nimport { handleGetAgents, handleGetSessions, handleGetSessionData } from \"./handlers.js\";\n\nexport function createApiRoutes(scanResult: ScanResult): Hono {\n const api = new Hono();\n\n api.get(\"/agents\", (c) => handleGetAgents(c, scanResult));\n api.get(\"/sessions\", (c) => handleGetSessions(c, scanResult));\n api.get(\"/sessions/:agent/:id\", (c) => handleGetSessionData(c, scanResult));\n\n return api;\n}\n","import type { Context } from \"hono\";\nimport type { ScanResult, SessionData, SessionHead } from \"@codesesh/core\";\nimport { getAgentInfoMap } from \"@codesesh/core\";\n\nexport function handleGetAgents(c: Context, scanResult: ScanResult) {\n const counts: Record<string, number> = {};\n for (const agent of scanResult.agents) {\n counts[agent.name] = scanResult.byAgent[agent.name]?.length ?? 0;\n }\n const info = getAgentInfoMap(counts);\n return c.json(info);\n}\n\nexport function handleGetSessions(c: Context, scanResult: ScanResult) {\n const agent = c.req.query(\"agent\");\n const q = c.req.query(\"q\")?.toLowerCase();\n const cwd = c.req.query(\"cwd\")?.toLowerCase();\n const from = c.req.query(\"from\");\n const to = c.req.query(\"to\");\n\n let sessions: SessionHead[] = [];\n\n // If agent filter is specified, use byAgent directly\n if (agent && scanResult.byAgent[agent]) {\n sessions = [...scanResult.byAgent[agent]!];\n } else {\n sessions = [...scanResult.sessions];\n }\n\n if (cwd) {\n sessions = sessions.filter((s) => s.directory.toLowerCase().includes(cwd));\n }\n\n if (from) {\n const fromTs = new Date(from).getTime();\n if (!Number.isNaN(fromTs)) {\n sessions = sessions.filter((s) => s.time_created >= fromTs);\n }\n }\n\n if (to) {\n const toTs = new Date(to).getTime();\n if (!Number.isNaN(toTs)) {\n sessions = sessions.filter((s) => s.time_created <= toTs);\n }\n }\n\n if (q) {\n sessions = sessions.filter((s) => s.title.toLowerCase().includes(q));\n }\n\n return c.json({ sessions });\n}\n\nexport async function handleGetSessionData(c: Context, scanResult: ScanResult) {\n const agentName = c.req.param(\"agent\");\n const sessionId = c.req.param(\"id\");\n\n if (!sessionId) {\n return c.json({ error: \"Missing session ID\" }, 400);\n }\n\n const agent = scanResult.agents.find((a) => a.name === agentName);\n\n if (!agent) {\n return c.json({ error: `Unknown agent: ${agentName}` }, 404);\n }\n\n try {\n const data: SessionData = agent.getSessionData(sessionId);\n return c.json(data);\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Failed to load session\";\n return c.json({ error: message }, 500);\n }\n}\n","import { consola } from \"consola\";\nimport type { BaseAgent } from \"@codesesh/core\";\nimport type { ScanResult } from \"@codesesh/core\";\nimport { VERSION } from \"./version.js\";\n\nexport function printScanResults(agents: BaseAgent[], result: ScanResult): void {\n consola.log(\"\");\n consola.box({\n title: \"CodeSesh\",\n message: `v${VERSION} • ${result.sessions.length} sessions discovered`,\n style: {\n padding: 1,\n borderColor: \"cyan\",\n },\n });\n consola.log(\"\");\n\n const rows: string[] = [];\n let availableCount = 0;\n\n for (const agent of agents) {\n const sessions = result.byAgent[agent.name];\n const count = sessions?.length ?? 0;\n if (count > 0) {\n availableCount++;\n rows.push(` ${green(\"✔\")} ${pad(agent.displayName)} ${dim(`${count} sessions`)}`);\n } else {\n rows.push(` ${dim(\"✖\")} ${pad(agent.displayName)} ${dim(\"not found\")}`);\n }\n }\n\n consola.log(rows.join(\"\\n\"));\n consola.log(\"\");\n consola.info(`Active: ${availableCount}/${agents.length} agents`);\n consola.log(\"\");\n}\n\nfunction pad(text: string, length = 16): string {\n return text.padEnd(length);\n}\n\nfunction green(text: string): string {\n return `\\x1b[32m${text}\\x1b[0m`;\n}\n\nfunction dim(text: string): string {\n return `\\x1b[2m${text}\\x1b[0m`;\n}\n","import { readFileSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(readFileSync(resolve(__dirname, \"../package.json\"), \"utf-8\"));\n\nexport const VERSION = pkg.version;\n"],"mappings":";;;;;;;;;AAAA,SAAS,eAAe,eAAe;;;ACAvC,SAAS,QAAAA,aAAY;AACrB,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;;;ACN9B,SAAS,YAAY;;;ACId,SAAS,gBAAgB,GAAY,YAAwB;AAClE,QAAM,SAAiC,CAAC;AACxC,aAAW,SAAS,WAAW,QAAQ;AACrC,WAAO,MAAM,IAAI,IAAI,WAAW,QAAQ,MAAM,IAAI,GAAG,UAAU;AAAA,EACjE;AACA,QAAM,OAAO,gBAAgB,MAAM;AACnC,SAAO,EAAE,KAAK,IAAI;AACpB;AAEO,SAAS,kBAAkB,GAAY,YAAwB;AACpE,QAAM,QAAQ,EAAE,IAAI,MAAM,OAAO;AACjC,QAAM,IAAI,EAAE,IAAI,MAAM,GAAG,GAAG,YAAY;AACxC,QAAM,MAAM,EAAE,IAAI,MAAM,KAAK,GAAG,YAAY;AAC5C,QAAM,OAAO,EAAE,IAAI,MAAM,MAAM;AAC/B,QAAM,KAAK,EAAE,IAAI,MAAM,IAAI;AAE3B,MAAI,WAA0B,CAAC;AAG/B,MAAI,SAAS,WAAW,QAAQ,KAAK,GAAG;AACtC,eAAW,CAAC,GAAG,WAAW,QAAQ,KAAK,CAAE;AAAA,EAC3C,OAAO;AACL,eAAW,C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dirname","Hono","resolve","dirname","fileURLToPath"]}
@@ -64,4 +64,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
64
64
 
65
65
  `);return n.trim()?n:wb(e)}function zb(e){let t=gb(e.inputValue);if(e.status===`completed`){let e=vb(t.content);if(e.trim())return bb(e)}return wb(e)}function Bb(e){let t=gb(gb(e.state).arguments),n=hb(t.agent_type),r=hb(e.nickname),i=[hb(t.model),hb(t.reasoning_effort)].filter(Boolean).join(`-`);return[[n,r].filter(Boolean).join(` - `),i].filter(Boolean).join(` `)}function Vb(e){let t=gb(e.state);return hb(t.prompt)||hb(gb(t.arguments).message)||``}function Hb(e){let t=hb(e.nickname);return e.role===`assistant`&&t?`AGENT (${t})`:e.role===`user`?`USER`:e.role===`tool`?`TOOL`:`AGENT`}function Ub(e,t){if(t.toLowerCase()!==`cursor`)return e;let n=[];for(let t of e){if(t.role!==`tool`){n.push({...t,parts:[...t.parts]});continue}let e=n.at(-1);if(e?.role===`assistant`){e.parts.push(...t.parts);continue}n.push({...t,parts:[...t.parts]})}return n}function Wb(e){let t=e.state||{},n=t.status,r=n===`running`||n===`error`||n===`completed`?n:`completed`,i=t.output??t.result??``,a=t.error??``,o=ub(t.input??t.arguments??{}),s=t.metadata??{};return{status:r,command:mb(o),inputValue:o,outputValue:i,errorValue:a,metadataValue:s,inputText:lb(o)}}function Gb(e,t){let n=(t.command||t.inputText||`{}`).replace(/\s+/g,` `).trim(),r=n.length>72?`${n.slice(0,72)}...`:n;return{Icon:Lr,title:Sb(e),secondaryText:r?`(${r})`:void 0,details:[],expandable:!0,showInputPreview:!0,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}function Kb(e,t,n){let r=_b(gb(t.inputValue).name);return{...n,Icon:zr,title:_b(e.tool)||`skill`,secondaryText:r||void 0,expandable:!1,showInputPreview:!1}}function qb(e,t){let n=Gb(e,t),r=(e.tool||``).toLowerCase(),i=gb(t.inputValue),a=Tb(t.inputValue);if(r===`read`)return{...n,Icon:xr,title:`read`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Ob(t.outputValue),language:qf(a),isCode:!0}};if(r===`edit`){let e=jb(a,vb(i.old_string),vb(i.new_string));return{...n,Icon:kr,title:`edit`,secondaryText:a||void 0,showInputPreview:!1,outputContent:e.length>0?{kind:`structured-diff`,blocks:e}:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}return r===`write`?{...n,Icon:Ir,title:`write`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:zb(t),language:qf(a),isCode:!0}}:{...n,title:Sb(e)}}function Jb(e,t){let n=Gb(e,t),r=(e.tool||``).toLowerCase(),i=gb(t.inputValue);if(r===`glob`){let r=_b(i.pattern);return{...n,Icon:Ar,title:e.tool||`glob`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}if(r===`grep`){let r=[_b(i.path),_b(i.pattern)].filter(Boolean).join(` · `);return{...n,Icon:Ar,title:e.tool||`grep`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}if(r===`bash`){let r=_b(i.description),a=_b(i.command),o=r?`${r}${a?` (${a})`:``}`:a?`(${a})`:void 0;return{...n,Icon:Lr,title:e.tool||`bash`,secondaryText:o,showInputPreview:!1,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}if(r===`read`){let r=Tb(t.inputValue);return{...n,Icon:xr,title:e.tool||`read`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Ob(t.outputValue),language:qf(r),isCode:!0}}}if(r===`edit`){let r=Tb(t.inputValue);return{...n,Icon:kr,title:e.tool||`edit`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Rb(t),language:`diff`,isCode:!0}}}if(r===`write`){let r=Tb(t.inputValue),i=t.status===`completed`;return{...n,Icon:Ir,title:e.tool||`write`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:zb(t),language:qf(r),isCode:i}}}return r===`skill`?Kb(e,t,n):n}function Yb(e,t){let n=Gb(e,t),r=(e.tool||``).toLowerCase(),i=gb(t.inputValue);if(r===`glob`){let r=_b(i.pattern);return{...n,Icon:Ar,title:e.title||`glob`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}if(r===`grep`){let r=[_b(i.path),_b(i.pattern)].filter(Boolean).join(` · `);return{...n,Icon:Ar,title:e.title||`grep`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}if(r===`shell`){let r=_b(i.command);return{...n,Icon:Lr,title:e.title||`bash`,secondaryText:r?`(${r})`:void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}if(r===`readfile`){let r=Tb(t.inputValue);return{...n,Icon:xr,title:e.title||`read`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:Ob(t.outputValue),language:qf(r),isCode:!0}}}if(r===`strreplacefile`){let r=Tb(t.inputValue),i=Lb(t,r);return{...n,Icon:kr,title:e.title||`edit`,secondaryText:r||void 0,showInputPreview:!1,outputContent:i.length>0?{kind:`structured-diff`,blocks:i}:{kind:`plain`,text:Rb(t),language:`diff`,isCode:!0}}}if(r===`writefile`){let r=Tb(t.inputValue);return{...n,Icon:Ir,title:e.title||`write`,secondaryText:r||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:zb(t),language:qf(r),isCode:t.status===`completed`}}}return n}function Xb(e,t){let n=Gb(e,t),r=(e.tool||``).toLowerCase();if(r===`skill`)return Kb(e,t,n);if(r===`exec_command`){let e=Pf(t.inputValue,wb(t),qf);return{...n,Icon:Lr,title:`bash`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:{kind:`plain`,text:e.outputAnalysis.text,language:e.outputAnalysis.language,isCode:e.outputAnalysis.isCode}}}if(r===`write_stdin`){let e=Ff(t.inputValue,wb(t),qf);return{...n,Icon:Lr,title:`bash`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:{kind:`plain`,text:e.outputAnalysis.text,language:e.outputAnalysis.language,isCode:e.outputAnalysis.isCode}}}if(r===`request_user_input`){let e=If(t.inputValue,wb(t));return{...n,Icon:Dr,title:`ask`,secondaryText:e.secondaryText,details:e.details,showInputPreview:!1,outputContent:e.outputContent}}if(r===`patch`){let r=af(t.inputValue),i=sf(r);return{...n,Icon:kr,title:Sb(e,`patch`),secondaryText:i||void 0,details:[],showInputPreview:!1,outputContent:uf(r,wb(t),qf)}}if(r===`subagent`){let r=Vb(e),i=wb(t);return{...n,Icon:Sr,title:Bb(e)||Sb(e,`subagent`),secondaryText:void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:r||i,language:`markdown`,isCode:!1}}}return n}function Zb(e,t){let n=Gb(e,t),r=(e.tool||``).toLowerCase(),i=gb(t.inputValue),a=Tb(t.inputValue);if(r===`read_file_v2`){let e=kb(t.outputValue);return{...n,Icon:xr,title:`read`,secondaryText:a||void 0,details:e===`No output captured.`?[{label:`Lines`,value:_b(Eb(t.outputValue).totalLinesInFile)}]:[],showInputPreview:!1,outputContent:{kind:`plain`,text:e,language:qf(a),isCode:e!==`No output captured.`}}}if(r===`edit_file_v2`){let e=bb(vb(i.streamingContent));return{...n,Icon:kr,title:`edit`,secondaryText:a||void 0,showInputPreview:!1,outputContent:{kind:`plain`,text:e||wb(t),language:e?`diff`:`text`,isCode:!!e}}}if(r===`ripgrep_raw_search`){let e=_b(i.pattern),r=[_b(i.path),e].filter(Boolean).join(` · `);return{...n,Icon:Ar,title:`grep`,secondaryText:r||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}if(r===`glob_file_search`){let e=_b(i.globPattern),r=[_b(i.targetDirectory),e].filter(Boolean).join(` · `);return{...n,Icon:Ar,title:`glob`,secondaryText:r||void 0,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:Ab(t.outputValue),language:`text`,isCode:!1}}}if(r===`run_terminal_command_v2`){let e=_b(i.command),r=_b(i.commandDescription),a=r?`${r}${e?` (${e})`:``}`:e?`(${e})`:void 0;return{...n,Icon:Lr,title:`bash`,secondaryText:a,details:[],showInputPreview:!1,outputContent:{kind:`plain`,text:wb(t),language:`text`,isCode:!1}}}return{...n,title:Sb(e)}}function Qb(e,t,n){let r=e.toLowerCase();return r===`opencode`?Jb(t,n):r===`codex`?Xb(t,n):r===`kimi`?Yb(t,n):r===`claudecode`?qb(t,n):r===`cursor`?Zb(t,n):Gb(t,n)}function $b(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ex(e){if(typeof e==`number`&&e<=0)return`Unknown time`;let t=null;if(typeof e==`number`){let n=e<10**12?e*1e3:e;t=new Date(n)}else if(typeof e==`string`&&e.trim()){let n=Number(e);t=!Number.isNaN(n)&&n>0?new Date(n<10**12?n*1e3:n):new Date(e)}return!t||Number.isNaN(t.getTime())?`Unknown time`:t.toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!0})}function tx({session:e}){let t=(e.slug||``).split(`/`)[0]||Bn.getDefaultAgentKey()||`claudecode`,n=(0,S.useMemo)(()=>Ub(e.messages,t),[e.messages,t]),r=(0,S.useMemo)(()=>n.filter(e=>Xd(e)),[n]),i=(0,S.useMemo)(()=>Bf(r),[r]),[a,o]=(0,S.useState)(()=>new Set(i.filterIds)),s=(0,S.useMemo)(()=>[...i.filterIds].toSorted().join(`|`),[i.filterIds]),c=(0,S.useMemo)(()=>Wf(r,a),[r,a]);return(0,S.useEffect)(()=>{o(new Set(i.filterIds))},[s,i.filterIds]),r.length===0?(0,Z.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`当前会话暂无可展示的消息内容。`}):(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl space-y-8 px-2 md:px-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:[(0,Z.jsx)(ix,{summary:typeof e.summary_files==`string`?e.summary_files:void 0}),(0,Z.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:items-start`,children:[(0,Z.jsx)(rx,{toc:i,selectedFilters:a,onToggle:e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}),(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:c.length>0?c.map(({msg:e,blocks:n},r)=>(0,Z.jsx)(ax,{msg:e,blocks:n,formatTokens:$b,sessionAgentKey:t},r)):(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-6 text-sm text-[var(--console-muted)]`,children:`当前筛选条件下暂无可展示的消息内容。`})})]})]})}var nx=[{id:`user`,label:`User`},{id:`agent_message`,label:`Agent Responses`},{id:`thinking`,label:`Thinking`},{id:`plan`,label:`Plans`},{id:`tools_all`,label:`Tools`}];function rx({toc:e,selectedFilters:t,onToggle:n}){let r=t.has(`tools_all`);return(0,Z.jsx)(`aside`,{className:`lg:sticky lg:top-4`,children:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--console-border)] px-4 py-3`,children:[(0,Z.jsx)(Mr,{className:`size-3.5 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`console-mono text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:`Session TOC`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1 p-3`,children:[nx.filter(({id:t})=>e.counts[t]>0).map(({id:r,label:i})=>(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-sm px-2 py-2 transition-colors hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t.has(r),onChange:()=>n(r),className:`size-3.5 rounded border-[var(--console-border-strong)] accent-[var(--console-accent-strong)]`}),(0,Z.jsx)(`span`,{className:`console-mono min-w-0 flex-1 text-xs text-[var(--console-text)]`,children:i}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.counts[r]})]},r)),e.tools.length>0?(0,Z.jsx)(`div`,{className:`space-y-1 border-t border-[var(--console-border)] pt-2`,children:e.tools.map(e=>(0,Z.jsxs)(`label`,{className:ua(`flex items-center gap-3 rounded-sm px-2 py-2 transition-colors`,r?`cursor-pointer hover:bg-[var(--console-surface-muted)]`:`cursor-not-allowed opacity-50`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:r&&t.has(e.id),disabled:!r,onChange:()=>n(e.id),className:`size-3.5 rounded border-[var(--console-border-strong)] accent-[var(--console-accent-strong)]`}),(0,Z.jsx)(`span`,{className:`console-mono min-w-0 flex-1 text-xs text-[var(--console-muted)]`,children:e.label}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]},e.id))}):null]})]})})}function ix({summary:e,defaultExpanded:t=!1}){let n=typeof e==`string`?e.trim():``,[r,i]=(0,S.useState)(t);return n?(0,Z.jsxs)(`section`,{className:`rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>i(e=>!e),children:[(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--console-text)]`,children:[(0,Z.jsx)(jr,{className:`size-3.5 text-[var(--console-accent)]`}),`Session Summary`]}),r?(0,Z.jsx)(Tr,{className:`size-3.5 text-[var(--console-muted)]`}):(0,Z.jsx)(wr,{className:`size-3.5 text-[var(--console-muted)]`})]}),r?(0,Z.jsx)(`div`,{className:`border-t border-[var(--console-border)] px-4 py-4`,children:(0,Z.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,Z.jsx)(Kd,{text:n})})}):null]}):null}function ax({msg:e,blocks:t,formatTokens:n,sessionAgentKey:r}){let i=e.role===`user`,a=$d(e,r),o=t||Yd(e.parts),s=()=>{let e=r.toLowerCase(),t=Bn.getAgentName(e),n=Bn.agents[e]?.icon;return(0,Z.jsx)(Z.Fragment,{children:n?(0,Z.jsx)(`img`,{src:n,alt:t,className:`size-4 rounded-sm object-cover`}):(0,Z.jsx)(Sr,{className:`size-4 text-[var(--console-muted)]`})})},c=e.mode?e.mode.toUpperCase():null,l=e.model||null,u=Hb(e),d=ex(e.time_created);return(0,Z.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,Z.jsxs)(`div`,{className:`flex gap-4`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:i?(0,Z.jsx)(Rr,{className:`size-4 text-[var(--console-muted)]`}):s()})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,Z.jsx)(`span`,{className:`console-mono text-sm font-bold tracking-wide text-[var(--console-text)]`,children:u}),(0,Z.jsx)(`time`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:d}),c&&(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:c}),l&&(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:l})]}),a?(0,Z.jsx)(ox,{}):o.map((e,t)=>e.type===`reasoning`?(0,Z.jsx)(sx,{parts:e.parts},t):e.type===`plan`?(0,Z.jsx)(lx,{parts:e.parts},t):e.type===`tool`?(0,Z.jsx)(cx,{parts:e.parts,sessionAgentKey:r},t):(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,Z.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:e.parts.map((e,t)=>(0,Z.jsx)(cb,{text:qd(e.text)},t))})},t)),!i&&(e.tokens||e.cost)&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.tokens?.input?(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`INPUT `,n(e.tokens.input)]}):null,e.tokens?.output?(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`OUTPUT `,n(e.tokens.output)]}):null,e.tokens?.reasoning?(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`REASONING `,n(e.tokens.reasoning)]}):null,e.cost?(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] text-[var(--console-muted)]`,children:[`COST $`,e.cost.toFixed(4)]}):null]})]})]})})}function ox(){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-start gap-2`,children:(0,Z.jsx)(`div`,{className:`w-full rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] md:w-[560px]`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Fr,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:`abort`})})]})})})})}function sx({parts:e}){let[t,n]=(0,S.useState)(!1),r=e.map(e=>qd(e.text)).filter(Boolean).join(`
66
66
 
67
- `);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-thinking-border)] bg-[var(--console-thinking-bg)]`,children:[(0,Z.jsxs)(`div`,{className:`flex cursor-pointer items-center justify-between bg-[var(--console-surface-muted)] px-3 py-2`,onClick:()=>n(!t),children:[(0,Z.jsxs)(`span`,{className:`console-mono flex items-center gap-2 text-xs font-medium text-[var(--console-muted)]`,children:[(0,Z.jsx)(Nr,{className:`size-3.5`}),`Thinking`]}),(0,Z.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:t?(0,Z.jsx)(Tr,{className:`w-4 h-4`}):(0,Z.jsx)(wr,{className:`w-4 h-4`})})]}),t&&(0,Z.jsx)(`div`,{className:`border-t border-dashed border-[var(--console-thinking-border)] px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`console-mono whitespace-pre-wrap text-xs leading-relaxed text-[var(--console-muted)]`,children:r})})]})}function cx({parts:e,sessionAgentKey:t}){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,n)=>(0,Z.jsx)(dx,{tool:e,sessionAgentKey:t},n))})})}function lx({parts:e}){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,t)=>(0,Z.jsx)(ux,{part:e},t))})}function ux({part:e}){let[t,n]=(0,S.useState)(!1),r=ff(e),i=r.approvalStatus===`fail`?sb.error:sb.completed,a=i.icon;return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${r.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:r.expandable?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>n(!t),children:[(0,Z.jsx)(Cr,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:r.title})}),(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:t?(0,Z.jsx)(Tr,{className:`size-3.5`}):(0,Z.jsx)(wr,{className:`size-3.5`})})]}):(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Cr,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:r.title})})]})}),(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${i.className}`,children:[(0,Z.jsx)(a,{className:`size-3`}),i.label]})]}),r.expandable&&t?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,Z.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:r.contentLabel})}),(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,Z.jsx)(cb,{text:r.contentMarkdown})})})]}):null]})}function dx({tool:e,sessionAgentKey:t}){let[n,r]=(0,S.useState)(!1),i=Wb(e),a=Qb(t,e,i),o=sb[i.status],s=o.icon,c=a.Icon;return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${a.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:a.expandable?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>r(!n),children:[(0,Z.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:a.title}),a.secondaryText?(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:a.secondaryText}):null]}),(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:n?(0,Z.jsx)(Tr,{className:`size-3.5`}):(0,Z.jsx)(wr,{className:`size-3.5`})})]}):(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:a.title}),a.secondaryText?(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:a.secondaryText}):null]})]})}),(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${o.className}`,children:[(0,Z.jsx)(s,{className:`size-3 ${i.status===`running`?`animate-spin`:``}`}),o.label]})]}),a.expandable&&n?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,Z.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Output`})}),(0,Z.jsxs)(`div`,{className:`space-y-3 p-3`,children:[a.details.length>0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.details.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,Z.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] font-semibold uppercase tracking-wide text-[var(--console-muted)] md:w-24`,children:e.label}),(0,Z.jsx)(`span`,{className:`console-mono whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-text)]`,children:e.value})]},`${e.label}:${e.value}`))})}):null,(0,Z.jsx)(ob,{outputContent:a.outputContent})]}),a.showInputPreview?(0,Z.jsxs)(`div`,{className:`border-t border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Input Preview`}),(0,Z.jsx)(`pre`,{className:`console-mono mt-1 max-h-[200px] overflow-x-auto whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-muted)]`,children:i.inputText||`{}`})]}):null]}):null]})}var fx=[{id:`1`,roleWidth:`w-14`,timeWidth:`w-20`,bodyWidths:[`w-full`,`w-10/12`,`w-7/12`]},{id:`2`,roleWidth:`w-16`,timeWidth:`w-24`,bodyWidths:[`w-9/12`,`w-7/12`]},{id:`3`,roleWidth:`w-14`,timeWidth:`w-16`,bodyWidths:[`w-full`,`w-11/12`,`w-8/12`,`w-5/12`]},{id:`4`,roleWidth:`w-16`,timeWidth:`w-20`,bodyWidths:[`w-10/12`,`w-8/12`]},{id:`5`,roleWidth:`w-14`,timeWidth:`w-24`,bodyWidths:[`w-full`,`w-10/12`,`w-9/12`]}];function px({className:e}){return(0,Z.jsx)(`div`,{className:`rounded-sm bg-[var(--console-border)] ${e}`})}function mx(){return(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-8 px-2 md:px-4`,children:[(0,Z.jsx)(`div`,{className:`flex flex-1 flex-col gap-8`,children:fx.map(e=>(0,Z.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,Z.jsxs)(`div`,{className:`flex gap-4`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,Z.jsx)(`div`,{className:`size-3.5 rounded-sm bg-[var(--console-border-strong)] animate-pulse`})})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(px,{className:`${e.roleWidth} h-3 animate-pulse`}),(0,Z.jsx)(px,{className:`${e.timeWidth} h-2.5 animate-pulse`})]}),(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.bodyWidths.map(t=>(0,Z.jsx)(px,{className:`${t} h-3 animate-pulse`},`${e.id}-${t}`))})})]})]})},e.id))}),(0,Z.jsx)(`div`,{className:`min-h-24 flex-1 rounded-sm border border-[var(--console-border)] bg-white/60 animate-pulse`})]})}function hx(e){return e.toLocaleString(`en-US`)}function gx(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function _x(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function vx({label:e,value:t,hint:n}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function yx({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function bx({code:e,title:t,description:n,aside:r,iconSrc:i,iconAlt:a}){return(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border-strong)] bg-white p-5 md:p-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Z.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:e}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:a||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,Z.jsx)(`h2`,{className:`console-mono text-2xl leading-tight font-semibold tracking-tight text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-sm border border-dashed border-[var(--console-border)] bg-[var(--console-surface-muted)] px-4 py-3 md:max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`STATUS NOTE`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function xx({agentItems:e}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Known Agents`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(xn,{to:`/${e.key}`,className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 transition-colors duration-200 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--console-accent)]`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function Sx({sessions:e}){return e.length===0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Sessions`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(xn,{to:`/${e.fullPath}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,Z.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` ·`,` `,_x(e.time_updated||e.time_created)]})]})},e.id))})]})}function Cx({type:e,sessions:t,agentItems:n,activeAgentKey:r,attemptedAgentKey:i,attemptedSessionSlug:a}){let o=t.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),s=o.slice(0,5),c=t.reduce((e,t)=>e+t.stats.message_count,0),l=t.reduce((e,t)=>e+gx(t.stats),0),u=o[0]?.time_updated||o[0]?.time_created;if(e===`missing-agent`){let e=`/${i||`unknown`}${a?`/${a}`:``}`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(bx,{code:`404 / AGENT`,title:`This agent isn't on the roster.`,description:`The path you requested is valid in shape, but there is no matching agent in the current registry. It may not be connected yet, or its name may not match what the system recognizes.`,aside:`Choose one of the available agents to continue.`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(yx,{label:`Requested Agent`,value:i||`unknown`}),(0,Z.jsx)(yx,{label:`Requested Path`,value:e}),a?(0,Z.jsx)(yx,{label:`Requested Session`,value:a}):null]}),(0,Z.jsx)(xx,{agentItems:n})]})}if(e===`missing-session`){let e=r||Bn.getDefaultAgentKey()||`claudecode`,t=Bn.agents[e],n=t?.name||e,i=t?.icon,o=a||`unknown-session`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(bx,{code:`404 / SESSION`,title:`This session isn't in the index.`,description:`${n} is available, but the session you're looking for does not exist in the current index. The slug may be incorrect, or the record may never have been part of this dataset.`,aside:`We checked the current path, but nothing matched. The session list on the left is still available.`,iconSrc:i,iconAlt:n}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:`Agent`}),(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,Z.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,Z.jsx)(yx,{label:`Session`,value:o})]}),(0,Z.jsx)(Sx,{sessions:s})]})}if(e===`global`)return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(vx,{label:`Total Sessions`,value:hx(t.length)}),(0,Z.jsx)(vx,{label:`Total Messages`,value:hx(c)}),(0,Z.jsx)(vx,{label:`Latest Activity`,value:_x(u),hint:u?new Date(u).toLocaleString(`zh-CN`):void 0})]}),(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agents`}),(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:n.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(xn,{to:`/${e.key}`,className:`flex items-center gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]}),(0,Z.jsx)(Sx,{sessions:s})]});let d=r?Bn.agents[r]:null,f=d?d.name:`Unknown Agent`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[d?(0,Z.jsx)(`img`,{src:d.icon,alt:f,className:`size-6 object-contain`}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:f}),(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Select a session from the left to view details`})]})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(vx,{label:`Sessions`,value:hx(t.length)}),(0,Z.jsx)(vx,{label:`Messages`,value:hx(c)}),(0,Z.jsx)(vx,{label:`Tokens`,value:hx(l)})]}),(0,Z.jsx)(Sx,{sessions:s})]})}var wx=class extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-2 text-sm font-semibold text-[var(--console-error)]`,children:`Something went wrong`}),(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function Tx(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?n.split(`/`).map(e=>e.trim()).filter(Boolean):[];if(r.length===0)return{mode:`root`,activeAgentKey:null,activeSessionSlug:null};if(r.length===1){let e=r[0].toLowerCase();return t.has(e)?{mode:`agent`,activeAgentKey:e,activeSessionSlug:null}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}if(r.length===2){let e=r[0].toLowerCase(),n=r[1];return t.has(e)&&n?{mode:`session`,activeAgentKey:e,activeSessionSlug:n}:t.has(e)?{mode:`missingSession`,activeAgentKey:e,activeSessionSlug:n,attemptedSessionSlug:n}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}function Ex(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Dx(){let[e,t]=(0,S.useState)([]),[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(!1),[f,p]=(0,S.useState)(null);(0,S.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let[e,n]=await Promise.all([Vn(),Hn()]);t(e),r(n.sessions)}catch(e){console.error(`Failed to load data:`,e),s(`Failed to load data. Is the CLI server running?`)}finally{a(!1)}})(),()=>e.abort()},[]);let m=it(),h=(0,S.useMemo)(()=>new Set(e.map(e=>e.name.toLowerCase())),[e]),g=(0,S.useMemo)(()=>Tx(m.pathname,h),[m.pathname,h]),_=(0,S.useMemo)(()=>{let t={};for(let n of e)t[n.name]=[];for(let e of n){let n=e.slug.split(`/`)[0]?.toLowerCase();n&&t[n]&&t[n].push(e)}for(let e of Object.keys(t))t[e].sort((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created));return t},[n,e]),v=g.activeAgentKey,y=(0,S.useMemo)(()=>v?_[v]??[]:[],[v,_]),b=(0,S.useMemo)(()=>{let e=new Map;for(let t of y){let n=t.directory??``,r=n?n.replace(/\/+$/,``).split(`/`).at(-1)??n:`(unknown)`,i=r===`(unknown)`?`__unknown__`:r;e.has(i)||e.set(i,{key:i,label:r,sessions:[]}),e.get(i).sessions.push(t)}return[...e.values()].sort((e,t)=>{if(e.key===`__unknown__`)return 1;if(t.key===`__unknown__`)return-1;let n=Math.max(...e.sessions.map(e=>e.time_updated??e.time_created));return Math.max(...t.sessions.map(e=>e.time_updated??e.time_created))-n})},[y]),[x,C]=(0,S.useState)(new Set);(0,S.useEffect)(()=>{C(new Set)},[v]);function w(e){C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}(0,S.useEffect)(()=>{if(g.mode!==`session`){l(null),p(null);return}let e=new AbortController;return d(!0),p(null),(async()=>{try{l(await Un(g.activeAgentKey,g.activeSessionSlug))}catch{p(`Session not found`),l(null)}finally{d(!1)}})(),()=>e.abort()},[g.mode===`session`?`${g.activeAgentKey}/${g.activeSessionSlug}`:``,g.activeAgentKey,g.activeSessionSlug,g.mode]);let T=(0,S.useMemo)(()=>n.map(e=>{let t=e.slug.split(`/`)[0]?.toLowerCase()||`unknown`;return{...e,agentKey:t,sessionSlug:e.id,fullPath:e.slug}}),[n]),E=(0,S.useMemo)(()=>e.filter(e=>e.count>0).map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,count:e.count})),[e]),D=`CodeSesh`,O=`Select an agent to browse sessions`;if(g.mode===`agent`&&v&&(D=e.find(e=>e.name.toLowerCase()===v)?.displayName??v,O=`${y.length} sessions`),g.mode===`session`){if(f)D=`Session Not Found`,O=`Requested /${v}/${g.activeSessionSlug}`;else if(c){D=c.title||`Conversation`;let e=c.time_updated??c.time_created;O=`ID: #${c.id.slice(0,8)} · Updated ${Ex(e)}`}}g.mode===`missingAgent`&&(D=`Agent Not Found`,O=`Requested /${g.attemptedKey}`),g.mode===`missingSession`&&(D=`Session Not Found`,O=`Session not found in /${v}`);let ee;return ee=i?(0,Z.jsx)(mx,{}):o?(0,Z.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:o}):g.mode===`root`?(0,Z.jsx)(Cx,{type:`global`,sessions:T,agentItems:E}):g.mode===`agent`&&v?(0,Z.jsx)(Cx,{type:`agent`,sessions:T.filter(e=>e.agentKey===v),agentItems:E,activeAgentKey:v}):g.mode===`session`?u?(0,Z.jsx)(mx,{}):f||!c?(0,Z.jsx)(Cx,{type:`missing-session`,sessions:T.filter(e=>e.agentKey===g.activeAgentKey),agentItems:E,activeAgentKey:g.activeAgentKey,attemptedSessionSlug:g.activeSessionSlug}):(0,Z.jsx)(tx,{session:c}):g.mode===`missingAgent`?(0,Z.jsx)(Cx,{type:`missing-agent`,sessions:T,agentItems:E,attemptedAgentKey:g.attemptedKey}):(0,Z.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`}),(0,Z.jsxs)(`div`,{className:`console-ui h-screen overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,Z.jsx)(`header`,{className:`h-14 shrink-0 border-b border-[var(--console-border)] bg-white/85 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`flex h-full items-center justify-between px-4`,children:[(0,Z.jsxs)(xn,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,Z.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,Z.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]}),(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-muted)]`,children:[`v`,`0.1.4`]})]})}),(0,Z.jsxs)(`div`,{className:`flex h-[calc(100vh-56px)] min-h-0`,children:[(0,Z.jsx)(`aside`,{className:`hidden w-64 shrink-0 flex-col border-r border-[var(--console-border)] bg-[var(--console-sidebar-bg)] lg:flex`,children:(0,Z.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`AGENT`}),(0,Z.jsxs)(`ul`,{className:`space-y-1`,children:[e.map(e=>{let t=e.name.toLowerCase(),n=t===v,r=Bn.agents[t];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(xn,{to:`/${t}`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[r?.icon&&(0,Z.jsx)(`img`,{src:r.icon,alt:e.displayName,className:`size-3.5 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.name)}),e.length===0&&!i&&(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No agents found`})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`SESSIONS`}),v?y.length===0?(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>{let t=x.has(e.key);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`button`,{onClick:()=>w(e.key),className:`console-mono flex w-full items-center gap-1.5 rounded-sm px-2 py-1 text-left text-xs text-[var(--console-muted)] hover:bg-[var(--console-surface-muted)]`,title:e.key===`__unknown__`?void 0:e.key,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px]`,children:t?`▼`:`▶`}),(0,Z.jsx)(`span`,{className:`line-clamp-1 font-semibold`,children:e.label}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px]`,children:e.sessions.length})]}),t&&(0,Z.jsx)(`ul`,{className:`mt-0.5 space-y-0.5 pl-3`,children:e.sessions.map(e=>{let t=g.mode===`session`&&g.activeSessionSlug===e.id;return(0,Z.jsx)(`li`,{children:(0,Z.jsx)(xn,{to:`/${v}/${e.id}`,className:`console-mono relative block rounded-sm border px-2 py-1.5 text-xs transition-colors ${t?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)] before:absolute before:bottom-0 before:left-0 before:top-0 before:w-0.5 before:bg-[var(--console-accent)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,title:e.title,children:(0,Z.jsx)(`span`,{className:`line-clamp-1`,children:e.title})})},e.id)})})]},e.key)})}):(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select an agent`})]})]})}),(0,Z.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] font-bold uppercase text-[var(--console-muted)]`,children:g.mode===`session`?`Session`:`Landing`}),(0,Z.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:D})]}),(0,Z.jsx)(`p`,{className:`console-mono mt-1 text-xs text-[var(--console-muted)]`,children:O})]})}),(0,Z.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,Z.jsx)(wx,{children:ee})})]})]})]})}zn.createRoot(document.getElementById(`root`)).render((0,Z.jsx)(S.StrictMode,{children:(0,Z.jsx)(vn,{children:(0,Z.jsx)(Dx,{})})}));
67
+ `);return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-thinking-border)] bg-[var(--console-thinking-bg)]`,children:[(0,Z.jsxs)(`div`,{className:`flex cursor-pointer items-center justify-between bg-[var(--console-surface-muted)] px-3 py-2`,onClick:()=>n(!t),children:[(0,Z.jsxs)(`span`,{className:`console-mono flex items-center gap-2 text-xs font-medium text-[var(--console-muted)]`,children:[(0,Z.jsx)(Nr,{className:`size-3.5`}),`Thinking`]}),(0,Z.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:t?(0,Z.jsx)(Tr,{className:`w-4 h-4`}):(0,Z.jsx)(wr,{className:`w-4 h-4`})})]}),t&&(0,Z.jsx)(`div`,{className:`border-t border-dashed border-[var(--console-thinking-border)] px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`console-mono whitespace-pre-wrap text-xs leading-relaxed text-[var(--console-muted)]`,children:r})})]})}function cx({parts:e,sessionAgentKey:t}){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,n)=>(0,Z.jsx)(dx,{tool:e,sessionAgentKey:t},n))})})}function lx({parts:e}){return(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,t)=>(0,Z.jsx)(ux,{part:e},t))})}function ux({part:e}){let[t,n]=(0,S.useState)(!1),r=ff(e),i=r.approvalStatus===`fail`?sb.error:sb.completed,a=i.icon;return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${r.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:r.expandable?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>n(!t),children:[(0,Z.jsx)(Cr,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:r.title})}),(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:t?(0,Z.jsx)(Tr,{className:`size-3.5`}):(0,Z.jsx)(wr,{className:`size-3.5`})})]}):(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(Cr,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:r.title})})]})}),(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${i.className}`,children:[(0,Z.jsx)(a,{className:`size-3`}),i.label]})]}),r.expandable&&t?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,Z.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:r.contentLabel})}),(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(`div`,{className:`console-markdown text-sm leading-relaxed text-[var(--console-text)]`,children:(0,Z.jsx)(cb,{text:r.contentMarkdown})})})]}):null]})}function dx({tool:e,sessionAgentKey:t}){let[n,r]=(0,S.useState)(!1),i=Wb(e),a=Qb(t,e,i),o=sb[i.status],s=o.icon,c=a.Icon;return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,Z.jsx)(`div`,{className:`w-full md:w-[560px] rounded-sm border border-[var(--console-border-strong)] bg-white px-3 py-2 text-left shadow-[2px_2px_0_0_rgba(15,23,42,0.05)] ${a.expandable?`transition-colors hover:bg-[var(--console-surface-muted)]`:``}`,children:a.expandable?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 text-left`,onClick:()=>r(!n),children:[(0,Z.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:a.title}),a.secondaryText?(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:a.secondaryText}):null]}),(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[var(--console-muted)]`,children:n?(0,Z.jsx)(Tr,{className:`size-3.5`}):(0,Z.jsx)(wr,{className:`size-3.5`})})]}):(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-[var(--console-accent)]`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`console-mono block text-xs font-semibold text-[var(--console-text)]`,children:a.title}),a.secondaryText?(0,Z.jsx)(`span`,{className:`console-mono mt-0.5 block whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--console-muted)]`,children:a.secondaryText}):null]})]})}),(0,Z.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider ${o.className}`,children:[(0,Z.jsx)(s,{className:`size-3 ${i.status===`running`?`animate-spin`:``}`}),o.label]})]}),a.expandable&&n?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-[var(--console-border)] bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:[(0,Z.jsx)(`div`,{className:`border-b border-[var(--console-border)] bg-[var(--console-surface-muted)] px-3 py-1.5`,children:(0,Z.jsx)(`span`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Output`})}),(0,Z.jsxs)(`div`,{className:`space-y-3 p-3`,children:[a.details.length>0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.details.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-start md:gap-3`,children:[(0,Z.jsx)(`span`,{className:`console-mono shrink-0 text-[11px] font-semibold uppercase tracking-wide text-[var(--console-muted)] md:w-24`,children:e.label}),(0,Z.jsx)(`span`,{className:`console-mono whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-text)]`,children:e.value})]},`${e.label}:${e.value}`))})}):null,(0,Z.jsx)(ob,{outputContent:a.outputContent})]}),a.showInputPreview?(0,Z.jsxs)(`div`,{className:`border-t border-[var(--console-border)] bg-[#fafafa] px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Input Preview`}),(0,Z.jsx)(`pre`,{className:`console-mono mt-1 max-h-[200px] overflow-x-auto whitespace-pre-wrap break-all text-xs leading-relaxed text-[var(--console-muted)]`,children:i.inputText||`{}`})]}):null]}):null]})}var fx=[{id:`1`,roleWidth:`w-14`,timeWidth:`w-20`,bodyWidths:[`w-full`,`w-10/12`,`w-7/12`]},{id:`2`,roleWidth:`w-16`,timeWidth:`w-24`,bodyWidths:[`w-9/12`,`w-7/12`]},{id:`3`,roleWidth:`w-14`,timeWidth:`w-16`,bodyWidths:[`w-full`,`w-11/12`,`w-8/12`,`w-5/12`]},{id:`4`,roleWidth:`w-16`,timeWidth:`w-20`,bodyWidths:[`w-10/12`,`w-8/12`]},{id:`5`,roleWidth:`w-14`,timeWidth:`w-24`,bodyWidths:[`w-full`,`w-10/12`,`w-9/12`]}];function px({className:e}){return(0,Z.jsx)(`div`,{className:`rounded-sm bg-[var(--console-border)] ${e}`})}function mx(){return(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-8 px-2 md:px-4`,children:[(0,Z.jsx)(`div`,{className:`flex flex-1 flex-col gap-8`,children:fx.map(e=>(0,Z.jsx)(`article`,{className:`w-full border-l-2 border-[var(--console-thread)] pl-4 pr-3 md:pr-5`,children:(0,Z.jsxs)(`div`,{className:`flex gap-4`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,Z.jsx)(`div`,{className:`size-3.5 rounded-sm bg-[var(--console-border-strong)] animate-pulse`})})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(px,{className:`${e.roleWidth} h-3 animate-pulse`}),(0,Z.jsx)(px,{className:`${e.timeWidth} h-2.5 animate-pulse`})]}),(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.bodyWidths.map(t=>(0,Z.jsx)(px,{className:`${t} h-3 animate-pulse`},`${e.id}-${t}`))})})]})]})},e.id))}),(0,Z.jsx)(`div`,{className:`min-h-24 flex-1 rounded-sm border border-[var(--console-border)] bg-white/60 animate-pulse`})]})}function hx(e){return e.toLocaleString(`en-US`)}function gx(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function _x(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function vx({label:e,value:t,hint:n}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function yx({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:e}),(0,Z.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function bx({code:e,title:t,description:n,aside:r,iconSrc:i,iconAlt:a}){return(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border-strong)] bg-white p-5 md:p-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Z.jsx)(`span`,{className:`console-mono inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:e}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:a||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,Z.jsx)(`h2`,{className:`console-mono text-2xl leading-tight font-semibold tracking-tight text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-sm border border-dashed border-[var(--console-border)] bg-[var(--console-surface-muted)] px-4 py-3 md:max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-[0.16em] text-[var(--console-muted)]`,children:`STATUS NOTE`}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function xx({agentItems:e}){return(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Known Agents`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(xn,{to:`/${e.key}`,className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 transition-colors duration-200 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--console-accent)]`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function Sx({sessions:e}){return e.length===0?(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4 text-sm text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`console-mono text-xs font-bold uppercase text-[var(--console-text)]`,children:`Recent Sessions`}),(0,Z.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[e.length,` items`]})]}),(0,Z.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(xn,{to:`/${e.fullPath}`,className:`block rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:e.title}),(0,Z.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,e.fullPath,` ·`,` `,_x(e.time_updated||e.time_created)]})]})},e.id))})]})}function Cx({type:e,sessions:t,agentItems:n,activeAgentKey:r,attemptedAgentKey:i,attemptedSessionSlug:a}){let o=t.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),s=o.slice(0,5),c=t.reduce((e,t)=>e+t.stats.message_count,0),l=t.reduce((e,t)=>e+gx(t.stats),0),u=o[0]?.time_updated||o[0]?.time_created;if(e===`missing-agent`){let e=`/${i||`unknown`}${a?`/${a}`:``}`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(bx,{code:`404 / AGENT`,title:`This agent isn't on the roster.`,description:`The path you requested is valid in shape, but there is no matching agent in the current registry. It may not be connected yet, or its name may not match what the system recognizes.`,aside:`Choose one of the available agents to continue.`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(yx,{label:`Requested Agent`,value:i||`unknown`}),(0,Z.jsx)(yx,{label:`Requested Path`,value:e}),a?(0,Z.jsx)(yx,{label:`Requested Session`,value:a}):null]}),(0,Z.jsx)(xx,{agentItems:n})]})}if(e===`missing-session`){let e=r||Bn.getDefaultAgentKey()||`claudecode`,t=Bn.agents[e],n=t?.name||e,i=t?.icon,o=a||`unknown-session`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(bx,{code:`404 / SESSION`,title:`This session isn't in the index.`,description:`${n} is available, but the session you're looking for does not exist in the current index. The slug may be incorrect, or the record may never have been part of this dataset.`,aside:`We checked the current path, but nothing matched. The session list on the left is still available.`,iconSrc:i,iconAlt:n}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,Z.jsx)(`p`,{className:`console-mono text-[11px] uppercase tracking-wider text-[var(--console-muted)]`,children:`Agent`}),(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,Z.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,Z.jsx)(yx,{label:`Session`,value:o})]}),(0,Z.jsx)(Sx,{sessions:s})]})}if(e===`global`)return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(vx,{label:`Total Sessions`,value:hx(t.length)}),(0,Z.jsx)(vx,{label:`Total Messages`,value:hx(c)}),(0,Z.jsx)(vx,{label:`Latest Activity`,value:_x(u),hint:u?new Date(u).toLocaleString(`zh-CN`):void 0})]}),(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`Agents`}),(0,Z.jsx)(`ul`,{className:`grid gap-2 sm:grid-cols-2`,children:n.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(xn,{to:`/${e.key}`,className:`flex items-center gap-2 rounded-sm border border-transparent px-2 py-1.5 transition-colors hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,Z.jsx)(`img`,{src:e.icon,alt:e.name,className:`size-4 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]}),(0,Z.jsx)(Sx,{sessions:s})]});let d=r?Bn.agents[r]:null,f=d?d.name:`Unknown Agent`;return(0,Z.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,Z.jsx)(`div`,{className:`rounded-sm border border-[var(--console-border)] bg-white p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[d?(0,Z.jsx)(`img`,{src:d.icon,alt:f,className:`size-6 object-contain`}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:f}),(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:`Select a session from the left to view details`})]})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,Z.jsx)(vx,{label:`Sessions`,value:hx(t.length)}),(0,Z.jsx)(vx,{label:`Messages`,value:hx(c)}),(0,Z.jsx)(vx,{label:`Tokens`,value:hx(l)})]}),(0,Z.jsx)(Sx,{sessions:s})]})}var wx=class extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,Z.jsxs)(`div`,{className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-2 text-sm font-semibold text-[var(--console-error)]`,children:`Something went wrong`}),(0,Z.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function Tx(e,t){let n=e.replace(/^\/+|\/+$/g,``),r=n?n.split(`/`).map(e=>e.trim()).filter(Boolean):[];if(r.length===0)return{mode:`root`,activeAgentKey:null,activeSessionSlug:null};if(r.length===1){let e=r[0].toLowerCase();return t.has(e)?{mode:`agent`,activeAgentKey:e,activeSessionSlug:null}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}if(r.length===2){let e=r[0].toLowerCase(),n=r[1];return t.has(e)&&n?{mode:`session`,activeAgentKey:e,activeSessionSlug:n}:t.has(e)?{mode:`missingSession`,activeAgentKey:e,activeSessionSlug:n,attemptedSessionSlug:n}:{mode:`missingAgent`,activeAgentKey:null,activeSessionSlug:null,attemptedKey:e}}return{mode:`invalidRoute`,activeAgentKey:null,activeSessionSlug:null}}function Ex(e){if(!e)return`unknown`;let t=Date.now()-e;if(Number.isNaN(t)||t<0)return`just now`;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Dx(){let[e,t]=(0,S.useState)([]),[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(!1),[f,p]=(0,S.useState)(null);(0,S.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let[e,n]=await Promise.all([Vn(),Hn()]);t(e),r(n.sessions)}catch(e){console.error(`Failed to load data:`,e),s(`Failed to load data. Is the CLI server running?`)}finally{a(!1)}})(),()=>e.abort()},[]);let m=it(),h=(0,S.useMemo)(()=>new Set(e.map(e=>e.name.toLowerCase())),[e]),g=(0,S.useMemo)(()=>Tx(m.pathname,h),[m.pathname,h]),_=(0,S.useMemo)(()=>{let t={};for(let n of e)t[n.name]=[];for(let e of n){let n=e.slug.split(`/`)[0]?.toLowerCase();n&&t[n]&&t[n].push(e)}for(let e of Object.keys(t))t[e].sort((e,t)=>(t.time_updated??t.time_created)-(e.time_updated??e.time_created));return t},[n,e]),v=g.activeAgentKey,y=(0,S.useMemo)(()=>v?_[v]??[]:[],[v,_]),b=(0,S.useMemo)(()=>{let e=new Map;for(let t of y){let n=t.directory??``,r=n?n.replace(/\/+$/,``).split(`/`).at(-1)??n:`(unknown)`,i=r===`(unknown)`?`__unknown__`:r;e.has(i)||e.set(i,{key:i,label:r,sessions:[]}),e.get(i).sessions.push(t)}return[...e.values()].sort((e,t)=>{if(e.key===`__unknown__`)return 1;if(t.key===`__unknown__`)return-1;let n=Math.max(...e.sessions.map(e=>e.time_updated??e.time_created));return Math.max(...t.sessions.map(e=>e.time_updated??e.time_created))-n})},[y]),[x,C]=(0,S.useState)(new Set);(0,S.useEffect)(()=>{C(new Set)},[v]);function w(e){C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}(0,S.useEffect)(()=>{if(g.mode!==`session`){l(null),p(null);return}let e=new AbortController;return d(!0),p(null),(async()=>{try{l(await Un(g.activeAgentKey,g.activeSessionSlug))}catch{p(`Session not found`),l(null)}finally{d(!1)}})(),()=>e.abort()},[g.mode===`session`?`${g.activeAgentKey}/${g.activeSessionSlug}`:``,g.activeAgentKey,g.activeSessionSlug,g.mode]);let T=(0,S.useMemo)(()=>n.map(e=>{let t=e.slug.split(`/`)[0]?.toLowerCase()||`unknown`;return{...e,agentKey:t,sessionSlug:e.id,fullPath:e.slug}}),[n]),E=(0,S.useMemo)(()=>e.filter(e=>e.count>0).map(e=>({key:e.name.toLowerCase(),name:e.displayName,icon:e.icon,count:e.count})),[e]),D=`CodeSesh`,O=`Select an agent to browse sessions`;if(g.mode===`agent`&&v&&(D=e.find(e=>e.name.toLowerCase()===v)?.displayName??v,O=`${y.length} sessions`),g.mode===`session`){if(f)D=`Session Not Found`,O=`Requested /${v}/${g.activeSessionSlug}`;else if(c){D=c.title||`Conversation`;let e=c.time_updated??c.time_created;O=`ID: #${c.id.slice(0,8)} · Updated ${Ex(e)}`}}g.mode===`missingAgent`&&(D=`Agent Not Found`,O=`Requested /${g.attemptedKey}`),g.mode===`missingSession`&&(D=`Session Not Found`,O=`Session not found in /${v}`);let ee;return ee=i?(0,Z.jsx)(mx,{}):o?(0,Z.jsx)(`div`,{className:`mx-auto max-w-4xl rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6 text-sm text-[var(--console-error)]`,children:o}):g.mode===`root`?(0,Z.jsx)(Cx,{type:`global`,sessions:T,agentItems:E}):g.mode===`agent`&&v?(0,Z.jsx)(Cx,{type:`agent`,sessions:T.filter(e=>e.agentKey===v),agentItems:E,activeAgentKey:v}):g.mode===`session`?u?(0,Z.jsx)(mx,{}):f||!c?(0,Z.jsx)(Cx,{type:`missing-session`,sessions:T.filter(e=>e.agentKey===g.activeAgentKey),agentItems:E,activeAgentKey:g.activeAgentKey,attemptedSessionSlug:g.activeSessionSlug}):(0,Z.jsx)(tx,{session:c}):g.mode===`missingAgent`?(0,Z.jsx)(Cx,{type:`missing-agent`,sessions:T,agentItems:E,attemptedAgentKey:g.attemptedKey}):(0,Z.jsx)(`div`,{className:`text-sm text-[var(--console-muted)]`,children:`Invalid route.`}),(0,Z.jsxs)(`div`,{className:`console-ui h-screen overflow-hidden bg-[var(--console-bg)] text-[var(--console-text)]`,children:[(0,Z.jsx)(`header`,{className:`h-14 shrink-0 border-b border-[var(--console-border)] bg-white/85 backdrop-blur-sm`,children:(0,Z.jsxs)(`div`,{className:`flex h-full items-center justify-between px-4`,children:[(0,Z.jsxs)(xn,{to:`/`,className:`flex items-center gap-2 text-[var(--console-text)]`,children:[(0,Z.jsx)(`img`,{src:`/logo.svg?v=3`,alt:`CodeSesh`,className:`h-6 w-6 rounded-sm`}),(0,Z.jsx)(`span`,{className:`console-mono text-sm font-semibold uppercase tracking-[0.05em]`,children:`CodeSesh`})]}),(0,Z.jsxs)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-muted)]`,children:[`v`,`0.1.5`]})]})}),(0,Z.jsxs)(`div`,{className:`flex h-[calc(100vh-56px)] min-h-0`,children:[(0,Z.jsx)(`aside`,{className:`hidden w-64 shrink-0 flex-col border-r border-[var(--console-border)] bg-[var(--console-sidebar-bg)] lg:flex`,children:(0,Z.jsxs)(`div`,{className:`console-scrollbar flex-1 space-y-8 overflow-y-auto px-4 py-6`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`AGENT`}),(0,Z.jsxs)(`ul`,{className:`space-y-1`,children:[e.map(e=>{let t=e.name.toLowerCase(),n=t===v,r=Bn.agents[t];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(xn,{to:`/${t}`,className:`flex items-center gap-2 rounded-sm border px-3 py-1.5 text-left transition-colors ${n?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,children:[r?.icon&&(0,Z.jsx)(`img`,{src:r.icon,alt:e.displayName,className:`size-3.5 object-contain`}),(0,Z.jsx)(`span`,{className:`console-mono line-clamp-1 flex-1 text-xs`,children:e.displayName}),(0,Z.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.name)}),e.length===0&&!i&&(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No agents found`})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`console-mono mb-3 text-xs font-bold uppercase text-[var(--console-text)]`,children:`SESSIONS`}),v?y.length===0?(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`No sessions yet`}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>{let t=x.has(e.key);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`button`,{onClick:()=>w(e.key),className:`console-mono flex w-full items-center gap-1.5 rounded-sm px-2 py-1 text-left text-xs text-[var(--console-muted)] hover:bg-[var(--console-surface-muted)]`,title:e.key===`__unknown__`?void 0:e.key,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px]`,children:t?`▼`:`▶`}),(0,Z.jsx)(`span`,{className:`line-clamp-1 font-semibold`,children:e.label}),(0,Z.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px]`,children:e.sessions.length})]}),t&&(0,Z.jsx)(`ul`,{className:`mt-0.5 space-y-0.5 pl-3`,children:e.sessions.map(e=>{let t=g.mode===`session`&&g.activeSessionSlug===e.id;return(0,Z.jsx)(`li`,{children:(0,Z.jsx)(xn,{to:`/${v}/${e.id}`,className:`console-mono relative block rounded-sm border px-2 py-1.5 text-xs transition-colors ${t?`border-[var(--console-border-strong)] bg-white text-[var(--console-text)] before:absolute before:bottom-0 before:left-0 before:top-0 before:w-0.5 before:bg-[var(--console-accent)]`:`border-transparent text-[var(--console-muted)] hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`}`,title:e.title,children:(0,Z.jsx)(`span`,{className:`line-clamp-1`,children:e.title})})},e.id)})})]},e.key)})}):(0,Z.jsx)(`span`,{className:`console-mono block rounded-sm px-3 py-1.5 text-xs text-[var(--console-muted)]`,children:`Select an agent`})]})]})}),(0,Z.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`section`,{className:`shrink-0 border-b border-[var(--console-border)] bg-white/70 px-4 py-4 backdrop-blur-sm md:px-8`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] font-bold uppercase text-[var(--console-muted)]`,children:g.mode===`session`?`Session`:`Landing`}),(0,Z.jsx)(`h1`,{className:`console-mono text-xl font-semibold tracking-tight text-[var(--console-text)]`,children:D})]}),(0,Z.jsx)(`p`,{className:`console-mono mt-1 text-xs text-[var(--console-muted)]`,children:O})]})}),(0,Z.jsx)(`section`,{className:`console-scrollbar bg-grid min-h-0 flex-1 overflow-y-auto px-4 py-6 md:px-8`,children:(0,Z.jsx)(wx,{children:ee})})]})]})]})}zn.createRoot(document.getElementById(`root`)).render((0,Z.jsx)(S.StrictMode,{children:(0,Z.jsx)(vn,{children:(0,Z.jsx)(Dx,{})})}));
@@ -9,7 +9,7 @@
9
9
  />
10
10
  <link rel="icon" type="image/svg+xml" href="/logo.svg?v=3" />
11
11
  <title>CodeSesh</title>
12
- <script type="module" crossorigin src="/assets/index-B5ae_tcH.js"></script>
12
+ <script type="module" crossorigin src="/assets/index-Bz2gXVMS.js"></script>
13
13
  <link rel="stylesheet" crossorigin href="/assets/index-vSqmWltx.css">
14
14
  </head>
15
15
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codesesh",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "One place to see every AI coding session you've ever had. Unify Claude Code, Cursor, Kimi, Codex, and OpenCode sessions in a single, beautiful Web UI.",
5
5
  "keywords": [
6
6
  "ai",