agent-recorder 0.0.1 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/package.json +2 -2
  2. package/vendor/node_modules/@agent-recorder/core/db/migrations.d.ts +2 -2
  3. package/vendor/node_modules/@agent-recorder/core/db/migrations.d.ts.map +1 -1
  4. package/vendor/node_modules/@agent-recorder/core/db/migrations.js +14 -6
  5. package/vendor/node_modules/@agent-recorder/core/db/migrations.js.map +1 -1
  6. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics 2.js +0 -205
  7. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.d 2.ts +0 -50
  8. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.d.ts 2.map +0 -1
  9. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.js 2.map +0 -1
  10. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test 2.js +0 -253
  11. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.d 2.ts +0 -5
  12. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.d.ts 2.map +0 -1
  13. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.js 2.map +0 -1
  14. package/vendor/node_modules/@agent-recorder/cli/commands/configure 2.js +0 -144
  15. package/vendor/node_modules/@agent-recorder/cli/commands/configure.d 2.ts +0 -17
  16. package/vendor/node_modules/@agent-recorder/cli/commands/configure.d.ts 2.map +0 -1
  17. package/vendor/node_modules/@agent-recorder/cli/commands/configure.js 2.map +0 -1
  18. package/vendor/node_modules/@agent-recorder/cli/commands/diagnose 2.js +0 -141
  19. package/vendor/node_modules/@agent-recorder/cli/commands/diagnose.d 2.ts +0 -5
  20. package/vendor/node_modules/@agent-recorder/cli/commands/diagnose.d.ts 2.map +0 -1
  21. package/vendor/node_modules/@agent-recorder/cli/commands/diagnose.js 2.map +0 -1
  22. package/vendor/node_modules/@agent-recorder/cli/commands/doctor 2.js +0 -253
  23. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.d 2.ts +0 -5
  24. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.d.ts 2.map +0 -1
  25. package/vendor/node_modules/@agent-recorder/cli/commands/doctor.js 2.map +0 -1
  26. package/vendor/node_modules/@agent-recorder/cli/commands/export 2.js +0 -56
  27. package/vendor/node_modules/@agent-recorder/cli/commands/export.d 2.ts +0 -12
  28. package/vendor/node_modules/@agent-recorder/cli/commands/export.d.ts 2.map +0 -1
  29. package/vendor/node_modules/@agent-recorder/cli/commands/export.js 2.map +0 -1
  30. package/vendor/node_modules/@agent-recorder/cli/commands/install 2.js +0 -77
  31. package/vendor/node_modules/@agent-recorder/cli/commands/install.d 2.ts +0 -13
  32. package/vendor/node_modules/@agent-recorder/cli/commands/install.d.ts 2.map +0 -1
  33. package/vendor/node_modules/@agent-recorder/cli/commands/install.js 2.map +0 -1
  34. package/vendor/node_modules/@agent-recorder/cli/commands/logs 2.js +0 -40
  35. package/vendor/node_modules/@agent-recorder/cli/commands/logs.d 2.ts +0 -8
  36. package/vendor/node_modules/@agent-recorder/cli/commands/logs.d.ts 2.map +0 -1
  37. package/vendor/node_modules/@agent-recorder/cli/commands/logs.js 2.map +0 -1
  38. package/vendor/node_modules/@agent-recorder/cli/commands/mock-mcp 2.js +0 -188
  39. package/vendor/node_modules/@agent-recorder/cli/commands/mock-mcp.d 2.ts +0 -10
  40. package/vendor/node_modules/@agent-recorder/cli/commands/mock-mcp.d.ts 2.map +0 -1
  41. package/vendor/node_modules/@agent-recorder/cli/commands/mock-mcp.js 2.map +0 -1
  42. package/vendor/node_modules/@agent-recorder/cli/commands/restart 2.js +0 -67
  43. package/vendor/node_modules/@agent-recorder/cli/commands/restart.d 2.ts +0 -9
  44. package/vendor/node_modules/@agent-recorder/cli/commands/restart.d.ts 2.map +0 -1
  45. package/vendor/node_modules/@agent-recorder/cli/commands/restart.js 2.map +0 -1
  46. package/vendor/node_modules/@agent-recorder/cli/commands/sessions 2.js +0 -333
  47. package/vendor/node_modules/@agent-recorder/cli/commands/sessions.d 2.ts +0 -52
  48. package/vendor/node_modules/@agent-recorder/cli/commands/sessions.d.ts 2.map +0 -1
  49. package/vendor/node_modules/@agent-recorder/cli/commands/sessions.js 2.map +0 -1
  50. package/vendor/node_modules/@agent-recorder/cli/commands/start 2.js +0 -174
  51. package/vendor/node_modules/@agent-recorder/cli/commands/start.d 2.ts +0 -10
  52. package/vendor/node_modules/@agent-recorder/cli/commands/start.d.ts 2.map +0 -1
  53. package/vendor/node_modules/@agent-recorder/cli/commands/start.js 2.map +0 -1
  54. package/vendor/node_modules/@agent-recorder/cli/commands/status 2.js +0 -104
  55. package/vendor/node_modules/@agent-recorder/cli/commands/status.d 2.ts +0 -5
  56. package/vendor/node_modules/@agent-recorder/cli/commands/status.d.ts 2.map +0 -1
  57. package/vendor/node_modules/@agent-recorder/cli/commands/status.js 2.map +0 -1
  58. package/vendor/node_modules/@agent-recorder/cli/commands/stop 2.js +0 -89
  59. package/vendor/node_modules/@agent-recorder/cli/commands/stop.d 2.ts +0 -8
  60. package/vendor/node_modules/@agent-recorder/cli/commands/stop.d.ts 2.map +0 -1
  61. package/vendor/node_modules/@agent-recorder/cli/commands/stop.js 2.map +0 -1
  62. package/vendor/node_modules/@agent-recorder/cli/commands/tui 2.js +0 -14
  63. package/vendor/node_modules/@agent-recorder/cli/commands/tui.d 2.ts +0 -5
  64. package/vendor/node_modules/@agent-recorder/cli/commands/tui.d.ts 2.map +0 -1
  65. package/vendor/node_modules/@agent-recorder/cli/commands/tui.js 2.map +0 -1
  66. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths 2.js +0 -117
  67. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.d 2.ts +0 -55
  68. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.d.ts 2.map +0 -1
  69. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.js 2.map +0 -1
  70. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test 2.js +0 -152
  71. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test.d 2.ts +0 -5
  72. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test.d.ts 2.map +0 -1
  73. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test.js 2.map +0 -1
  74. package/vendor/node_modules/@agent-recorder/cli/index 2.js +0 -194
  75. package/vendor/node_modules/@agent-recorder/cli/index.d 2.ts +0 -10
  76. package/vendor/node_modules/@agent-recorder/cli/index.d.ts 2.map +0 -1
  77. package/vendor/node_modules/@agent-recorder/cli/index.js 2.map +0 -1
  78. package/vendor/node_modules/@agent-recorder/cli/package 2.json +0 -17
  79. package/vendor/node_modules/@agent-recorder/cli/tui/App 2.js +0 -84
  80. package/vendor/node_modules/@agent-recorder/cli/tui/App.d 2.ts +0 -6
  81. package/vendor/node_modules/@agent-recorder/cli/tui/App.d.ts 2.map +0 -1
  82. package/vendor/node_modules/@agent-recorder/cli/tui/App.js 2.map +0 -1
  83. package/vendor/node_modules/@agent-recorder/cli/tui/api 2.js +0 -105
  84. package/vendor/node_modules/@agent-recorder/cli/tui/api.d 2.ts +0 -31
  85. package/vendor/node_modules/@agent-recorder/cli/tui/api.d.ts 2.map +0 -1
  86. package/vendor/node_modules/@agent-recorder/cli/tui/api.js 2.map +0 -1
  87. package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel 2.js +0 -45
  88. package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.d 2.ts +0 -11
  89. package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.d.ts 2.map +0 -1
  90. package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.js 2.map +0 -1
  91. package/vendor/node_modules/@agent-recorder/cli/tui/components/Header 2.js +0 -13
  92. package/vendor/node_modules/@agent-recorder/cli/tui/components/Header.d 2.ts +0 -17
  93. package/vendor/node_modules/@agent-recorder/cli/tui/components/Header.d.ts 2.map +0 -1
  94. package/vendor/node_modules/@agent-recorder/cli/tui/components/Header.js 2.map +0 -1
  95. package/vendor/node_modules/@agent-recorder/cli/tui/components/Spinner 2.js +0 -21
  96. package/vendor/node_modules/@agent-recorder/cli/tui/components/Spinner.d 2.ts +0 -12
  97. package/vendor/node_modules/@agent-recorder/cli/tui/components/Spinner.d.ts 2.map +0 -1
  98. package/vendor/node_modules/@agent-recorder/cli/tui/components/Spinner.js 2.map +0 -1
  99. package/vendor/node_modules/@agent-recorder/cli/tui/components/StatusBadge 2.js +0 -50
  100. package/vendor/node_modules/@agent-recorder/cli/tui/components/StatusBadge.d 2.ts +0 -16
  101. package/vendor/node_modules/@agent-recorder/cli/tui/components/StatusBadge.d.ts 2.map +0 -1
  102. package/vendor/node_modules/@agent-recorder/cli/tui/components/StatusBadge.js 2.map +0 -1
  103. package/vendor/node_modules/@agent-recorder/cli/tui/components/Table 2.js +0 -20
  104. package/vendor/node_modules/@agent-recorder/cli/tui/components/Table.d 2.ts +0 -21
  105. package/vendor/node_modules/@agent-recorder/cli/tui/components/Table.d.ts 2.map +0 -1
  106. package/vendor/node_modules/@agent-recorder/cli/tui/components/Table.js 2.map +0 -1
  107. package/vendor/node_modules/@agent-recorder/cli/tui/components/index 2.js +0 -8
  108. package/vendor/node_modules/@agent-recorder/cli/tui/components/index.d 2.ts +0 -8
  109. package/vendor/node_modules/@agent-recorder/cli/tui/components/index.d.ts 2.map +0 -1
  110. package/vendor/node_modules/@agent-recorder/cli/tui/components/index.js 2.map +0 -1
  111. package/vendor/node_modules/@agent-recorder/cli/tui/hooks/useEventStream 2.js +0 -75
  112. package/vendor/node_modules/@agent-recorder/cli/tui/hooks/useEventStream.d 2.ts +0 -22
  113. package/vendor/node_modules/@agent-recorder/cli/tui/hooks/useEventStream.d.ts 2.map +0 -1
  114. package/vendor/node_modules/@agent-recorder/cli/tui/hooks/useEventStream.js 2.map +0 -1
  115. package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionDetailScreen 2.js +0 -190
  116. package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionDetailScreen.d 2.ts +0 -13
  117. package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionDetailScreen.d.ts 2.map +0 -1
  118. package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionDetailScreen.js 2.map +0 -1
  119. package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionsScreen 2.js +0 -166
  120. package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionsScreen.d 2.ts +0 -10
  121. package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionsScreen.d.ts 2.map +0 -1
  122. package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionsScreen.js 2.map +0 -1
  123. package/vendor/node_modules/@agent-recorder/cli/tui/screens/index 2.js +0 -6
  124. package/vendor/node_modules/@agent-recorder/cli/tui/screens/index.d 2.ts +0 -6
  125. package/vendor/node_modules/@agent-recorder/cli/tui/screens/index.d.ts 2.map +0 -1
  126. package/vendor/node_modules/@agent-recorder/cli/tui/screens/index.js 2.map +0 -1
  127. package/vendor/node_modules/@agent-recorder/core/config 2.js +0 -44
  128. package/vendor/node_modules/@agent-recorder/core/config.d 2.ts +0 -25
  129. package/vendor/node_modules/@agent-recorder/core/config.d.ts 2.map +0 -1
  130. package/vendor/node_modules/@agent-recorder/core/db/connection.d 2.ts +0 -15
  131. package/vendor/node_modules/@agent-recorder/core/migrations/001_initial 2.sql +0 -40
  132. package/vendor/node_modules/@agent-recorder/core/migrations/002_session_sequences 2.sql +0 -8
  133. package/vendor/node_modules/@agent-recorder/core/migrations/003_add_tool_columns 2.sql +0 -9
  134. package/vendor/node_modules/@agent-recorder/core/migrations/004_add_cancelled_status 2.sql +0 -23
  135. package/vendor/node_modules/@agent-recorder/core/migrations/005_add_error_category 2.sql +0 -6
  136. package/vendor/node_modules/@agent-recorder/core/package 2.json +0 -18
  137. package/vendor/node_modules/@agent-recorder/core/types/events.d 2.ts +0 -69
  138. package/vendor/node_modules/@agent-recorder/core/types/index 2.js +0 -2
  139. package/vendor/node_modules/@agent-recorder/core/types/index.js 2.map +0 -1
  140. package/vendor/node_modules/@agent-recorder/core/types/session 2.js +0 -6
  141. package/vendor/node_modules/@agent-recorder/core/types/session.d 2.ts +0 -22
  142. package/vendor/node_modules/@agent-recorder/core/types/session.d.ts 2.map +0 -1
  143. package/vendor/node_modules/@agent-recorder/core/types/session.js 2.map +0 -1
  144. package/vendor/node_modules/@agent-recorder/core/utils/error-category 2.js +0 -58
  145. package/vendor/node_modules/@agent-recorder/core/utils/error-category.d 2.ts +0 -22
  146. package/vendor/node_modules/@agent-recorder/core/utils/error-category.d.ts 2.map +0 -1
  147. package/vendor/node_modules/@agent-recorder/core/utils/error-category.js 2.map +0 -1
  148. package/vendor/node_modules/@agent-recorder/core/utils/error-category.test.d 2.ts +0 -5
  149. package/vendor/node_modules/@agent-recorder/core/utils/error-category.test.d.ts 2.map +0 -1
  150. package/vendor/node_modules/@agent-recorder/core/utils/error-category.test.js 2.map +0 -1
  151. package/vendor/node_modules/@agent-recorder/core/utils/index 2.js +0 -6
  152. package/vendor/node_modules/@agent-recorder/core/utils/index.d 2.ts +0 -6
  153. package/vendor/node_modules/@agent-recorder/core/utils/index.d.ts 2.map +0 -1
  154. package/vendor/node_modules/@agent-recorder/core/utils/index.js 2.map +0 -1
  155. package/vendor/node_modules/@agent-recorder/core/utils/redact.d 2.ts +0 -19
  156. package/vendor/node_modules/@agent-recorder/core/utils/redact.d.ts 2.map +0 -1
  157. package/vendor/node_modules/@agent-recorder/core/utils/redact.js 2.map +0 -1
  158. package/vendor/node_modules/@agent-recorder/service/index 2.js +0 -128
  159. package/vendor/node_modules/@agent-recorder/service/index.d 2.ts +0 -36
  160. package/vendor/node_modules/@agent-recorder/service/index.d.ts 2.map +0 -1
  161. package/vendor/node_modules/@agent-recorder/service/index.js 2.map +0 -1
  162. package/vendor/node_modules/@agent-recorder/service/mcp/index 2.js +0 -7
  163. package/vendor/node_modules/@agent-recorder/service/mcp/index.d 2.ts +0 -7
  164. package/vendor/node_modules/@agent-recorder/service/mcp/index.d.ts 2.map +0 -1
  165. package/vendor/node_modules/@agent-recorder/service/mcp/index.js 2.map +0 -1
  166. package/vendor/node_modules/@agent-recorder/service/mcp/proxy 2.js +0 -223
  167. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d 2.ts +0 -26
  168. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d.ts 2.map +0 -1
  169. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.js 2.map +0 -1
  170. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.test.d 2.ts +0 -5
  171. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.test.d.ts 2.map +0 -1
  172. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.test.js 2.map +0 -1
  173. package/vendor/node_modules/@agent-recorder/service/mcp/recorder 2.js +0 -62
  174. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.d 2.ts +0 -31
  175. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.d.ts 2.map +0 -1
  176. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.js 2.map +0 -1
  177. package/vendor/node_modules/@agent-recorder/service/mcp/types 2.js +0 -15
  178. package/vendor/node_modules/@agent-recorder/service/mcp/types.d 2.ts +0 -40
  179. package/vendor/node_modules/@agent-recorder/service/mcp/types.d.ts 2.map +0 -1
  180. package/vendor/node_modules/@agent-recorder/service/mcp/types.js 2.map +0 -1
  181. package/vendor/node_modules/@agent-recorder/service/package 2.json +0 -15
  182. package/vendor/node_modules/@agent-recorder/service/routes/events 2.js +0 -71
  183. package/vendor/node_modules/@agent-recorder/service/routes/events.d 2.ts +0 -11
  184. package/vendor/node_modules/@agent-recorder/service/routes/events.d.ts 2.map +0 -1
  185. package/vendor/node_modules/@agent-recorder/service/routes/events.js 2.map +0 -1
  186. package/vendor/node_modules/@agent-recorder/service/routes/health 2.js +0 -18
  187. package/vendor/node_modules/@agent-recorder/service/routes/health.d 2.ts +0 -6
  188. package/vendor/node_modules/@agent-recorder/service/routes/health.d.ts 2.map +0 -1
  189. package/vendor/node_modules/@agent-recorder/service/routes/health.js 2.map +0 -1
  190. package/vendor/node_modules/@agent-recorder/service/routes/sessions 2.js +0 -80
  191. package/vendor/node_modules/@agent-recorder/service/routes/sessions.d 2.ts +0 -12
  192. package/vendor/node_modules/@agent-recorder/service/routes/sessions.d.ts 2.map +0 -1
  193. package/vendor/node_modules/@agent-recorder/service/routes/sessions.js 2.map +0 -1
  194. package/vendor/node_modules/@agent-recorder/service/server 2.js +0 -36
  195. package/vendor/node_modules/@agent-recorder/service/server.d 2.ts +0 -19
  196. package/vendor/node_modules/@agent-recorder/service/server.d.ts 2.map +0 -1
  197. package/vendor/node_modules/@agent-recorder/service/server.js 2.map +0 -1
  198. package/vendor/node_modules/@agent-recorder/service/server.test 2.js +0 -296
  199. package/vendor/node_modules/@agent-recorder/service/server.test.d 2.ts +0 -5
  200. package/vendor/node_modules/@agent-recorder/service/server.test.d.ts 2.map +0 -1
  201. package/vendor/node_modules/@agent-recorder/service/session-manager 2.js +0 -22
  202. package/vendor/node_modules/@agent-recorder/service/session-manager.d 2.ts +0 -16
  203. package/vendor/node_modules/@agent-recorder/service/session-manager.d.ts 2.map +0 -1
  204. package/vendor/node_modules/@agent-recorder/service/session-manager.js 2.map +0 -1
  205. package/vendor/node_modules/@agent-recorder/service/session-manager.test 2.js +0 -61
  206. package/vendor/node_modules/@agent-recorder/service/session-manager.test.d 2.ts +0 -5
  207. package/vendor/node_modules/@agent-recorder/service/session-manager.test.d.ts 2.map +0 -1
  208. package/vendor/node_modules/@agent-recorder/service/session-manager.test.js 2.map +0 -1
@@ -1,333 +0,0 @@
1
- /**
2
- * Sessions commands - list, show, current, tail, view, stats, grep, summarize.
3
- */
4
- import { loadConfig } from "@agent-recorder/core";
5
- import { computeSessionSummary, formatStatsText, formatConciseSummary, } from "../analytics/session-analytics.js";
6
- async function fetchJson(url) {
7
- const response = await fetch(url);
8
- if (!response.ok) {
9
- throw new Error(`HTTP ${response.status}`);
10
- }
11
- return response.json();
12
- }
13
- async function getEventCount(baseUrl, sessionId) {
14
- try {
15
- const result = await fetchJson(`${baseUrl}/api/sessions/${sessionId}/events/count`);
16
- return result.count;
17
- }
18
- catch {
19
- return 0;
20
- }
21
- }
22
- function formatTable(sessions) {
23
- if (sessions.length === 0) {
24
- console.log("No sessions found.");
25
- return;
26
- }
27
- // Header
28
- console.log("ID".padEnd(38) + "STATUS".padEnd(12) + "STARTED".padEnd(25) + "EVENTS");
29
- console.log("-".repeat(80));
30
- // Rows
31
- for (const session of sessions) {
32
- const id = session.id.padEnd(38);
33
- const status = session.status.padEnd(12);
34
- const started = session.startedAt.padEnd(25);
35
- const events = String(session.eventCount);
36
- console.log(`${id}${status}${started}${events}`);
37
- }
38
- }
39
- export async function sessionsListCommand(options) {
40
- const config = loadConfig();
41
- const baseUrl = `http://127.0.0.1:${config.listenPort}`;
42
- try {
43
- // Fetch sessions
44
- let url = `${baseUrl}/api/sessions`;
45
- if (options.status) {
46
- url += `?status=${options.status}`;
47
- }
48
- const sessions = await fetchJson(url);
49
- // Fetch event counts for each session
50
- const sessionsWithCounts = await Promise.all(sessions.map(async (session) => ({
51
- ...session,
52
- eventCount: await getEventCount(baseUrl, session.id),
53
- })));
54
- formatTable(sessionsWithCounts);
55
- }
56
- catch {
57
- console.error("Failed to fetch sessions. Is the daemon running?");
58
- process.exit(1);
59
- }
60
- }
61
- export async function sessionsShowCommand(id) {
62
- const config = loadConfig();
63
- const baseUrl = `http://127.0.0.1:${config.listenPort}`;
64
- try {
65
- // Fetch session details
66
- const session = await fetchJson(`${baseUrl}/api/sessions/${id}`);
67
- // Fetch event count
68
- const eventCount = await getEventCount(baseUrl, id);
69
- console.log("Session Details");
70
- console.log("===============");
71
- console.log(`ID: ${session.id}`);
72
- console.log(`Status: ${session.status}`);
73
- console.log(`Started: ${session.startedAt}`);
74
- console.log(`Ended: ${session.endedAt ?? "N/A"}`);
75
- console.log(`Events: ${eventCount}`);
76
- }
77
- catch {
78
- console.error(`Session not found: ${id}`);
79
- process.exit(1);
80
- }
81
- }
82
- /**
83
- * Get the current active session ID.
84
- */
85
- export async function sessionsCurrentCommand() {
86
- const config = loadConfig();
87
- const baseUrl = `http://127.0.0.1:${config.listenPort}`;
88
- try {
89
- const current = await fetchJson(`${baseUrl}/api/sessions/current`);
90
- console.log(current.id);
91
- }
92
- catch {
93
- console.error("No active session (daemon may not be running)");
94
- process.exit(1);
95
- }
96
- }
97
- /**
98
- * Format and print a single event for tail output.
99
- */
100
- function printEvent(event) {
101
- const duration = event.endedAt && event.startedAt
102
- ? new Date(event.endedAt).getTime() - new Date(event.startedAt).getTime()
103
- : null;
104
- const durationStr = duration !== null ? `${duration}ms` : "...";
105
- const name = event.toolName ?? event.skillName ?? "-";
106
- console.log(`[${event.sequence}] ${event.eventType} ${name} ${event.status} ${durationStr}`);
107
- }
108
- /**
109
- * Tail session events (like tail -f).
110
- * Runs indefinitely until Ctrl+C.
111
- */
112
- export async function sessionsTailCommand(id, options) {
113
- const config = loadConfig();
114
- const baseUrl = `http://127.0.0.1:${config.listenPort}`;
115
- const intervalMs = parseInt(options.interval ?? "1000", 10);
116
- const initialLimit = parseInt(options.n ?? "50", 10);
117
- let lastSequence = 0;
118
- console.log(`Tailing session ${id} (Ctrl+C to stop)...\n`);
119
- /**
120
- * Fetch events after lastSequence.
121
- * For initial fetch, we get last N events by fetching all and slicing.
122
- */
123
- const fetchEvents = async (after, limit) => {
124
- const url = `${baseUrl}/api/sessions/${id}/events?after=${after}&limit=${limit}`;
125
- try {
126
- return await fetchJson(url);
127
- }
128
- catch {
129
- return [];
130
- }
131
- };
132
- // Initial fetch: get last N events
133
- const initialEvents = await fetchEvents(0, 1000); // Get up to 1000 events
134
- const startIndex = Math.max(0, initialEvents.length - initialLimit);
135
- const recentEvents = initialEvents.slice(startIndex);
136
- for (const event of recentEvents) {
137
- printEvent(event);
138
- lastSequence = Math.max(lastSequence, event.sequence);
139
- }
140
- // Poll for new events
141
- const poll = async () => {
142
- const events = await fetchEvents(lastSequence, 200);
143
- for (const event of events) {
144
- printEvent(event);
145
- lastSequence = Math.max(lastSequence, event.sequence);
146
- }
147
- };
148
- const timer = setInterval(poll, intervalMs);
149
- // Handle Ctrl+C
150
- process.on("SIGINT", () => {
151
- clearInterval(timer);
152
- console.log("\nStopped tailing.");
153
- process.exit(0);
154
- });
155
- // Keep process alive
156
- await new Promise(() => {
157
- // Never resolves - runs until SIGINT
158
- });
159
- }
160
- /**
161
- * Print a detailed event row for view/grep output.
162
- */
163
- function printEventDetailed(event) {
164
- const duration = event.endedAt && event.startedAt
165
- ? new Date(event.endedAt).getTime() - new Date(event.startedAt).getTime()
166
- : null;
167
- const durationStr = duration !== null ? `${duration}ms` : "...";
168
- const name = event.toolName ?? event.skillName ?? "-";
169
- const errorInfo = event.errorCategory ? ` [${event.errorCategory}]` : "";
170
- console.log(`[${String(event.sequence).padStart(4)}] ${event.eventType.padEnd(12)} ${name.padEnd(30)} ${event.status.padEnd(8)} ${durationStr.padEnd(10)}${errorInfo}`);
171
- }
172
- /**
173
- * View session events with optional tail and follow mode.
174
- */
175
- export async function sessionsViewCommand(id, options) {
176
- const config = loadConfig();
177
- const baseUrl = `http://127.0.0.1:${config.listenPort}`;
178
- const tailCount = options.tail ? parseInt(options.tail, 10) : 200;
179
- const intervalMs = parseInt(options.interval ?? "1000", 10);
180
- try {
181
- // Fetch session info
182
- const session = await fetchJson(`${baseUrl}/api/sessions/${id}`);
183
- // Fetch all events
184
- const events = await fetchJson(`${baseUrl}/api/sessions/${id}/events`);
185
- // Compute summary for header
186
- const summary = computeSessionSummary(events);
187
- // Print header
188
- console.log("Session View");
189
- console.log("=".repeat(80));
190
- console.log(`ID: ${session.id}`);
191
- console.log(`Status: ${session.status}`);
192
- console.log(`Started: ${session.startedAt}`);
193
- console.log(`Ended: ${session.endedAt ?? "N/A"}`);
194
- console.log("");
195
- console.log(`Events: ${summary.totalEvents} | Success: ${summary.successCount} | Error: ${summary.errorCount} | Timeout: ${summary.timeoutCount}`);
196
- console.log(`Top Tools: ${summary.topTools.map((t) => `${t.name}(${t.count})`).join(", ") || "none"}`);
197
- console.log("=".repeat(80));
198
- console.log("");
199
- // Print column header
200
- console.log(`${"SEQ".padStart(6)} ${"TYPE".padEnd(12)} ${"NAME".padEnd(30)} ${"STATUS".padEnd(8)} ${"DURATION".padEnd(10)} ERROR`);
201
- console.log("-".repeat(80));
202
- // Show tail events
203
- const startIndex = Math.max(0, events.length - tailCount);
204
- const displayEvents = events.slice(startIndex);
205
- for (const event of displayEvents) {
206
- printEventDetailed(event);
207
- }
208
- // If follow mode, poll for new events
209
- if (options.follow) {
210
- let lastSequence = events.length > 0 ? events[events.length - 1].sequence : 0;
211
- console.log("\n-- Following new events (Ctrl+C to stop) --\n");
212
- const poll = async () => {
213
- try {
214
- const newEvents = await fetchJson(`${baseUrl}/api/sessions/${id}/events?after=${lastSequence}&limit=200`);
215
- for (const event of newEvents) {
216
- printEventDetailed(event);
217
- lastSequence = Math.max(lastSequence, event.sequence);
218
- }
219
- }
220
- catch {
221
- // Silently ignore polling errors
222
- }
223
- };
224
- const timer = setInterval(poll, intervalMs);
225
- process.on("SIGINT", () => {
226
- clearInterval(timer);
227
- console.log("\nStopped following.");
228
- process.exit(0);
229
- });
230
- await new Promise(() => { });
231
- }
232
- }
233
- catch {
234
- console.error(`Failed to view session: ${id}`);
235
- process.exit(1);
236
- }
237
- }
238
- /**
239
- * Show session statistics.
240
- */
241
- export async function sessionsStatsCommand(id) {
242
- const config = loadConfig();
243
- const baseUrl = `http://127.0.0.1:${config.listenPort}`;
244
- try {
245
- const events = await fetchJson(`${baseUrl}/api/sessions/${id}/events`);
246
- if (events.length === 0) {
247
- console.log("No events in this session.");
248
- return;
249
- }
250
- const summary = computeSessionSummary(events);
251
- console.log(formatStatsText(summary));
252
- }
253
- catch {
254
- console.error(`Failed to get stats for session: ${id}`);
255
- process.exit(1);
256
- }
257
- }
258
- /**
259
- * Search/filter session events.
260
- */
261
- export async function sessionsGrepCommand(id, options) {
262
- const config = loadConfig();
263
- const baseUrl = `http://127.0.0.1:${config.listenPort}`;
264
- try {
265
- // Fetch all events
266
- const events = await fetchJson(`${baseUrl}/api/sessions/${id}/events`);
267
- // Filter client-side (per spec: no new REST endpoints for grep)
268
- let filtered = events;
269
- if (options.tool) {
270
- filtered = filtered.filter((e) => e.toolName === options.tool);
271
- }
272
- if (options.status) {
273
- filtered = filtered.filter((e) => e.status === options.status);
274
- }
275
- if (options.error) {
276
- filtered = filtered.filter((e) => e.errorCategory === options.error);
277
- }
278
- if (options.sinceSeq) {
279
- const sinceSeq = parseInt(options.sinceSeq, 10);
280
- filtered = filtered.filter((e) => e.sequence > sinceSeq);
281
- }
282
- if (options.json) {
283
- console.log(JSON.stringify(filtered, null, 2));
284
- }
285
- else {
286
- if (filtered.length === 0) {
287
- console.log("No matching events found.");
288
- return;
289
- }
290
- // Print header
291
- console.log(`${"SEQ".padStart(6)} ${"TYPE".padEnd(12)} ${"NAME".padEnd(30)} ${"STATUS".padEnd(8)} ${"DURATION".padEnd(10)} ERROR`);
292
- console.log("-".repeat(80));
293
- for (const event of filtered) {
294
- printEventDetailed(event);
295
- }
296
- console.log("");
297
- console.log(`Found ${filtered.length} matching event(s).`);
298
- }
299
- }
300
- catch {
301
- console.error(`Failed to search session: ${id}`);
302
- process.exit(1);
303
- }
304
- }
305
- /**
306
- * Summarize session with safe metadata-only summary.
307
- */
308
- export async function sessionsSummarizeCommand(id, options) {
309
- const config = loadConfig();
310
- const baseUrl = `http://127.0.0.1:${config.listenPort}`;
311
- const format = options.format ?? "text";
312
- try {
313
- const session = await fetchJson(`${baseUrl}/api/sessions/${id}`);
314
- const events = await fetchJson(`${baseUrl}/api/sessions/${id}/events`);
315
- const summary = computeSessionSummary(events);
316
- if (format === "json") {
317
- console.log(JSON.stringify({ session, summary }, null, 2));
318
- }
319
- else {
320
- console.log(`Session: ${session.id}`);
321
- console.log(`Status: ${session.status}`);
322
- console.log(`Started: ${session.startedAt}`);
323
- console.log(`Ended: ${session.endedAt ?? "N/A"}`);
324
- console.log("");
325
- console.log(formatConciseSummary(events, summary));
326
- }
327
- }
328
- catch {
329
- console.error(`Failed to summarize session: ${id}`);
330
- process.exit(1);
331
- }
332
- }
333
- //# sourceMappingURL=sessions.js.map
@@ -1,52 +0,0 @@
1
- /**
2
- * Sessions commands - list, show, current, tail, view, stats, grep, summarize.
3
- */
4
- export declare function sessionsListCommand(options: {
5
- status?: string;
6
- }): Promise<void>;
7
- export declare function sessionsShowCommand(id: string): Promise<void>;
8
- /**
9
- * Get the current active session ID.
10
- */
11
- export declare function sessionsCurrentCommand(): Promise<void>;
12
- export interface SessionsTailOptions {
13
- interval?: string;
14
- n?: string;
15
- }
16
- /**
17
- * Tail session events (like tail -f).
18
- * Runs indefinitely until Ctrl+C.
19
- */
20
- export declare function sessionsTailCommand(id: string, options: SessionsTailOptions): Promise<void>;
21
- export interface SessionsViewOptions {
22
- tail?: string;
23
- follow?: boolean;
24
- interval?: string;
25
- }
26
- /**
27
- * View session events with optional tail and follow mode.
28
- */
29
- export declare function sessionsViewCommand(id: string, options: SessionsViewOptions): Promise<void>;
30
- /**
31
- * Show session statistics.
32
- */
33
- export declare function sessionsStatsCommand(id: string): Promise<void>;
34
- export interface SessionsGrepOptions {
35
- tool?: string;
36
- status?: string;
37
- error?: string;
38
- sinceSeq?: string;
39
- json?: boolean;
40
- }
41
- /**
42
- * Search/filter session events.
43
- */
44
- export declare function sessionsGrepCommand(id: string, options: SessionsGrepOptions): Promise<void>;
45
- export interface SessionsSummarizeOptions {
46
- format?: string;
47
- }
48
- /**
49
- * Summarize session with safe metadata-only summary.
50
- */
51
- export declare function sessionsSummarizeCommand(id: string, options: SessionsSummarizeOptions): Promise<void>;
52
- //# sourceMappingURL=sessions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/commands/sessions.ts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AO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACzC,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;YAClD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -1,174 +0,0 @@
1
- /**
2
- * Start command - runs the daemon in foreground or background.
3
- */
4
- import { existsSync, readFileSync, openSync, constants } from "node:fs";
5
- import { spawn } from "node:child_process";
6
- import { fileURLToPath } from "node:url";
7
- import { dirname, join } from "node:path";
8
- import { loadConfig, getDaemonPaths, acquireLockWithCleanup, isProcessRunning, readPidFile, } from "@agent-recorder/core";
9
- import { startDaemon } from "@agent-recorder/service";
10
- /**
11
- * Load environment variables from a file.
12
- * Parses KEY=VALUE lines, ignoring comments and empty lines.
13
- */
14
- function loadEnvFile(filePath) {
15
- if (!existsSync(filePath)) {
16
- console.error(`Env file not found: ${filePath}`);
17
- process.exit(1);
18
- }
19
- const content = readFileSync(filePath, "utf-8");
20
- const lines = content.split("\n");
21
- for (const line of lines) {
22
- const trimmed = line.trim();
23
- // Skip empty lines and comments
24
- if (!trimmed || trimmed.startsWith("#")) {
25
- continue;
26
- }
27
- const eqIndex = trimmed.indexOf("=");
28
- if (eqIndex > 0) {
29
- const key = trimmed.slice(0, eqIndex).trim();
30
- let value = trimmed.slice(eqIndex + 1).trim();
31
- // Remove surrounding quotes if present
32
- if ((value.startsWith('"') && value.endsWith('"')) ||
33
- (value.startsWith("'") && value.endsWith("'"))) {
34
- value = value.slice(1, -1);
35
- }
36
- // Only set if not already defined (preserve existing env)
37
- if (process.env[key] === undefined) {
38
- process.env[key] = value;
39
- }
40
- }
41
- }
42
- }
43
- function printStartupBanner(mcpProxyPort) {
44
- console.log(`
45
- Agent Recorder
46
- ==============
47
-
48
- Claude Code v2 (recommended):
49
- Add to ~/.claude/settings.json:
50
-
51
- {
52
- "mcpServers": {
53
- "agent-recorder": {
54
- "url": "http://127.0.0.1:${mcpProxyPort}/"
55
- }
56
- }
57
- }
58
-
59
- Legacy clients (~/.config/claude/mcp.json):
60
- Same JSON structure, different location.
61
-
62
- Then restart Claude Code.
63
- `);
64
- }
65
- /**
66
- * Send SIGTERM to a process and wait for it to exit.
67
- */
68
- async function stopProcess(pid, timeoutMs = 5000) {
69
- try {
70
- process.kill(pid, "SIGTERM");
71
- }
72
- catch {
73
- // Process already dead
74
- return true;
75
- }
76
- const startTime = Date.now();
77
- while (Date.now() - startTime < timeoutMs) {
78
- await new Promise((resolve) => setTimeout(resolve, 100));
79
- if (!isProcessRunning(pid)) {
80
- return true;
81
- }
82
- }
83
- return false;
84
- }
85
- export async function startCommand(options = {}) {
86
- // Load env file before anything else if specified
87
- if (options.envFile) {
88
- loadEnvFile(options.envFile);
89
- }
90
- const config = loadConfig();
91
- const paths = getDaemonPaths();
92
- // Check for existing daemon
93
- const existingPid = readPidFile();
94
- if (existingPid && isProcessRunning(existingPid)) {
95
- if (options.force) {
96
- console.log(`Stopping existing daemon (PID ${existingPid})...`);
97
- const stopped = await stopProcess(existingPid);
98
- if (!stopped) {
99
- console.error("Failed to stop existing daemon. Try: agent-recorder stop --force");
100
- process.exit(1);
101
- }
102
- console.log("Existing daemon stopped.");
103
- }
104
- else {
105
- console.error(`Daemon is already running (PID ${existingPid}).\n` +
106
- "Use --force to restart, or run: agent-recorder stop");
107
- process.exit(1);
108
- }
109
- }
110
- // Try to acquire lock
111
- const lockResult = acquireLockWithCleanup(paths.lockFile, paths.pidFile);
112
- if (!lockResult.acquired) {
113
- if (lockResult.existingPid) {
114
- console.error(`Another instance is running (PID ${lockResult.existingPid}).\n` +
115
- "Use --force to restart, or run: agent-recorder stop");
116
- }
117
- else {
118
- console.error(`Failed to acquire lock: ${lockResult.error}`);
119
- }
120
- process.exit(1);
121
- }
122
- if (options.daemon) {
123
- // Daemon mode: fork and exit parent
124
- console.log("Starting daemon in background...");
125
- // Find the service entry point
126
- const __filename = fileURLToPath(import.meta.url);
127
- const __dirname = dirname(__filename);
128
- const serviceEntry = join(__dirname, "..", "..", "..", "service", "dist", "index.js");
129
- // Open log file for daemon output
130
- const logFd = openSync(paths.logFile, constants.O_WRONLY | constants.O_CREAT | constants.O_APPEND);
131
- // Build args for child process
132
- const args = [serviceEntry, "--daemon"];
133
- if (options.envFile) {
134
- args.push("--env-file", options.envFile);
135
- }
136
- // Spawn detached child process
137
- const child = spawn(process.execPath, args, {
138
- detached: true,
139
- stdio: ["ignore", logFd, logFd],
140
- env: {
141
- ...process.env,
142
- AR_DAEMON_MODE: "1",
143
- },
144
- });
145
- child.unref();
146
- // Wait for daemon to start (poll for PID file up to 5 seconds)
147
- let newPid = null;
148
- const maxAttempts = 10;
149
- for (let i = 0; i < maxAttempts; i++) {
150
- await new Promise((resolve) => setTimeout(resolve, 500));
151
- newPid = readPidFile();
152
- if (newPid && isProcessRunning(newPid)) {
153
- break;
154
- }
155
- }
156
- // Check if daemon started successfully
157
- if (newPid && isProcessRunning(newPid)) {
158
- console.log(`Daemon started (PID ${newPid})`);
159
- console.log(`Log file: ${paths.logFile}`);
160
- console.log(`\nRun 'agent-recorder status' to check status.`);
161
- }
162
- else {
163
- console.error("Failed to start daemon. Check log file for details:");
164
- console.error(` ${paths.logFile}`);
165
- process.exit(1);
166
- }
167
- }
168
- else {
169
- // Foreground mode: run directly
170
- printStartupBanner(config.mcpProxyPort);
171
- await startDaemon({ daemon: false });
172
- }
173
- }
174
- //# sourceMappingURL=start.js.map
@@ -1,10 +0,0 @@
1
- /**
2
- * Start command - runs the daemon in foreground or background.
3
- */
4
- export interface StartCommandOptions {
5
- envFile?: string;
6
- daemon?: boolean;
7
- force?: boolean;
8
- }
9
- export declare function startCommand(options?: StartCommandOptions): Promise<void>;
10
- //# sourceMappingURL=start.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6EH,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAuBD,wBAAsB,YAAY,CAChC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAgHf"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;GAGG;AACH,SAAS,WAA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