agent-recorder 0.0.1 → 0.0.9
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/package.json +2 -2
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.js +1 -0
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/configure-wrap.d.ts +15 -0
- package/vendor/node_modules/@agent-recorder/cli/commands/configure-wrap.d.ts.map +1 -0
- package/vendor/node_modules/@agent-recorder/cli/commands/configure-wrap.js +233 -0
- package/vendor/node_modules/@agent-recorder/cli/commands/configure-wrap.js.map +1 -0
- package/vendor/node_modules/@agent-recorder/cli/commands/install.d.ts.map +1 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/install.js +9 -0
- package/vendor/node_modules/@agent-recorder/cli/commands/install.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/cli/index.js +11 -0
- package/vendor/node_modules/@agent-recorder/cli/index.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/config.d.ts +4 -0
- package/vendor/node_modules/@agent-recorder/core/config.d.ts.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/config.js +6 -0
- package/vendor/node_modules/@agent-recorder/core/config.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/db/events.d.ts +3 -0
- package/vendor/node_modules/@agent-recorder/core/db/events.d.ts.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/db/events.js +8 -3
- package/vendor/node_modules/@agent-recorder/core/db/events.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/db/events.test.js +34 -0
- package/vendor/node_modules/@agent-recorder/core/db/events.test.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/db/migrations.d.ts +2 -2
- package/vendor/node_modules/@agent-recorder/core/db/migrations.d.ts.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/db/migrations.js +14 -6
- package/vendor/node_modules/@agent-recorder/core/db/migrations.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/index.d.ts +1 -1
- package/vendor/node_modules/@agent-recorder/core/index.d.ts.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/index.js +1 -1
- package/vendor/node_modules/@agent-recorder/core/index.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/core/migrations/006_add_upstream_key.sql +7 -0
- package/vendor/node_modules/@agent-recorder/core/types/events.d.ts +2 -0
- package/vendor/node_modules/@agent-recorder/core/types/events.d.ts.map +1 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d.ts.map +1 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.js +49 -4
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.test.js +165 -0
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.test.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/recorder.d.ts +1 -0
- package/vendor/node_modules/@agent-recorder/service/mcp/recorder.d.ts.map +1 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/recorder.js +5 -2
- package/vendor/node_modules/@agent-recorder/service/mcp/recorder.js.map +1 -1
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics 2.js +0 -205
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.d 2.ts +0 -50
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test 2.js +0 -253
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/configure 2.js +0 -144
- package/vendor/node_modules/@agent-recorder/cli/commands/configure.d 2.ts +0 -17
- package/vendor/node_modules/@agent-recorder/cli/commands/configure.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/configure.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/diagnose 2.js +0 -141
- package/vendor/node_modules/@agent-recorder/cli/commands/diagnose.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/cli/commands/diagnose.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/diagnose.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/doctor 2.js +0 -253
- package/vendor/node_modules/@agent-recorder/cli/commands/doctor.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/cli/commands/doctor.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/doctor.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/export 2.js +0 -56
- package/vendor/node_modules/@agent-recorder/cli/commands/export.d 2.ts +0 -12
- package/vendor/node_modules/@agent-recorder/cli/commands/export.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/export.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/install 2.js +0 -77
- package/vendor/node_modules/@agent-recorder/cli/commands/install.d 2.ts +0 -13
- package/vendor/node_modules/@agent-recorder/cli/commands/install.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/install.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/logs 2.js +0 -40
- package/vendor/node_modules/@agent-recorder/cli/commands/logs.d 2.ts +0 -8
- package/vendor/node_modules/@agent-recorder/cli/commands/logs.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/logs.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/mock-mcp 2.js +0 -188
- package/vendor/node_modules/@agent-recorder/cli/commands/mock-mcp.d 2.ts +0 -10
- package/vendor/node_modules/@agent-recorder/cli/commands/mock-mcp.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/mock-mcp.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/restart 2.js +0 -67
- package/vendor/node_modules/@agent-recorder/cli/commands/restart.d 2.ts +0 -9
- package/vendor/node_modules/@agent-recorder/cli/commands/restart.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/restart.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/sessions 2.js +0 -333
- package/vendor/node_modules/@agent-recorder/cli/commands/sessions.d 2.ts +0 -52
- package/vendor/node_modules/@agent-recorder/cli/commands/sessions.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/sessions.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/start 2.js +0 -174
- package/vendor/node_modules/@agent-recorder/cli/commands/start.d 2.ts +0 -10
- package/vendor/node_modules/@agent-recorder/cli/commands/start.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/start.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/status 2.js +0 -104
- package/vendor/node_modules/@agent-recorder/cli/commands/status.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/cli/commands/status.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/status.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/stop 2.js +0 -89
- package/vendor/node_modules/@agent-recorder/cli/commands/stop.d 2.ts +0 -8
- package/vendor/node_modules/@agent-recorder/cli/commands/stop.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/stop.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/tui 2.js +0 -14
- package/vendor/node_modules/@agent-recorder/cli/commands/tui.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/cli/commands/tui.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/commands/tui.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/config/claude-paths 2.js +0 -117
- package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.d 2.ts +0 -55
- package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test 2.js +0 -152
- package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/index 2.js +0 -194
- package/vendor/node_modules/@agent-recorder/cli/index.d 2.ts +0 -10
- package/vendor/node_modules/@agent-recorder/cli/index.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/index.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/package 2.json +0 -17
- package/vendor/node_modules/@agent-recorder/cli/tui/App 2.js +0 -84
- package/vendor/node_modules/@agent-recorder/cli/tui/App.d 2.ts +0 -6
- package/vendor/node_modules/@agent-recorder/cli/tui/App.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/App.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/api 2.js +0 -105
- package/vendor/node_modules/@agent-recorder/cli/tui/api.d 2.ts +0 -31
- package/vendor/node_modules/@agent-recorder/cli/tui/api.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/api.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel 2.js +0 -45
- package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.d 2.ts +0 -11
- package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Header 2.js +0 -13
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Header.d 2.ts +0 -17
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Header.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Header.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Spinner 2.js +0 -21
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Spinner.d 2.ts +0 -12
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Spinner.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Spinner.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/StatusBadge 2.js +0 -50
- package/vendor/node_modules/@agent-recorder/cli/tui/components/StatusBadge.d 2.ts +0 -16
- package/vendor/node_modules/@agent-recorder/cli/tui/components/StatusBadge.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/StatusBadge.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Table 2.js +0 -20
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Table.d 2.ts +0 -21
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Table.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/Table.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/index 2.js +0 -8
- package/vendor/node_modules/@agent-recorder/cli/tui/components/index.d 2.ts +0 -8
- package/vendor/node_modules/@agent-recorder/cli/tui/components/index.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/components/index.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/hooks/useEventStream 2.js +0 -75
- package/vendor/node_modules/@agent-recorder/cli/tui/hooks/useEventStream.d 2.ts +0 -22
- package/vendor/node_modules/@agent-recorder/cli/tui/hooks/useEventStream.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/hooks/useEventStream.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionDetailScreen 2.js +0 -190
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionDetailScreen.d 2.ts +0 -13
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionDetailScreen.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionDetailScreen.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionsScreen 2.js +0 -166
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionsScreen.d 2.ts +0 -10
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionsScreen.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/SessionsScreen.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/index 2.js +0 -6
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/index.d 2.ts +0 -6
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/index.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/cli/tui/screens/index.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/config 2.js +0 -44
- package/vendor/node_modules/@agent-recorder/core/config.d 2.ts +0 -25
- package/vendor/node_modules/@agent-recorder/core/config.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/db/connection.d 2.ts +0 -15
- package/vendor/node_modules/@agent-recorder/core/migrations/001_initial 2.sql +0 -40
- package/vendor/node_modules/@agent-recorder/core/migrations/002_session_sequences 2.sql +0 -8
- package/vendor/node_modules/@agent-recorder/core/migrations/003_add_tool_columns 2.sql +0 -9
- package/vendor/node_modules/@agent-recorder/core/migrations/004_add_cancelled_status 2.sql +0 -23
- package/vendor/node_modules/@agent-recorder/core/migrations/005_add_error_category 2.sql +0 -6
- package/vendor/node_modules/@agent-recorder/core/package 2.json +0 -18
- package/vendor/node_modules/@agent-recorder/core/types/events.d 2.ts +0 -69
- package/vendor/node_modules/@agent-recorder/core/types/index 2.js +0 -2
- package/vendor/node_modules/@agent-recorder/core/types/index.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/types/session 2.js +0 -6
- package/vendor/node_modules/@agent-recorder/core/types/session.d 2.ts +0 -22
- package/vendor/node_modules/@agent-recorder/core/types/session.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/types/session.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/utils/error-category 2.js +0 -58
- package/vendor/node_modules/@agent-recorder/core/utils/error-category.d 2.ts +0 -22
- package/vendor/node_modules/@agent-recorder/core/utils/error-category.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/utils/error-category.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/utils/error-category.test.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/core/utils/error-category.test.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/utils/error-category.test.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/utils/index 2.js +0 -6
- package/vendor/node_modules/@agent-recorder/core/utils/index.d 2.ts +0 -6
- package/vendor/node_modules/@agent-recorder/core/utils/index.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/utils/index.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/utils/redact.d 2.ts +0 -19
- package/vendor/node_modules/@agent-recorder/core/utils/redact.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/core/utils/redact.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/index 2.js +0 -128
- package/vendor/node_modules/@agent-recorder/service/index.d 2.ts +0 -36
- package/vendor/node_modules/@agent-recorder/service/index.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/index.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/index 2.js +0 -7
- package/vendor/node_modules/@agent-recorder/service/mcp/index.d 2.ts +0 -7
- package/vendor/node_modules/@agent-recorder/service/mcp/index.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/index.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy 2.js +0 -223
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d 2.ts +0 -26
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.test.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.test.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/proxy.test.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/recorder 2.js +0 -62
- package/vendor/node_modules/@agent-recorder/service/mcp/recorder.d 2.ts +0 -31
- package/vendor/node_modules/@agent-recorder/service/mcp/recorder.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/recorder.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/types 2.js +0 -15
- package/vendor/node_modules/@agent-recorder/service/mcp/types.d 2.ts +0 -40
- package/vendor/node_modules/@agent-recorder/service/mcp/types.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/mcp/types.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/package 2.json +0 -15
- package/vendor/node_modules/@agent-recorder/service/routes/events 2.js +0 -71
- package/vendor/node_modules/@agent-recorder/service/routes/events.d 2.ts +0 -11
- package/vendor/node_modules/@agent-recorder/service/routes/events.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/routes/events.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/routes/health 2.js +0 -18
- package/vendor/node_modules/@agent-recorder/service/routes/health.d 2.ts +0 -6
- package/vendor/node_modules/@agent-recorder/service/routes/health.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/routes/health.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/routes/sessions 2.js +0 -80
- package/vendor/node_modules/@agent-recorder/service/routes/sessions.d 2.ts +0 -12
- package/vendor/node_modules/@agent-recorder/service/routes/sessions.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/routes/sessions.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/server 2.js +0 -36
- package/vendor/node_modules/@agent-recorder/service/server.d 2.ts +0 -19
- package/vendor/node_modules/@agent-recorder/service/server.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/server.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/server.test 2.js +0 -296
- package/vendor/node_modules/@agent-recorder/service/server.test.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/service/server.test.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/session-manager 2.js +0 -22
- package/vendor/node_modules/@agent-recorder/service/session-manager.d 2.ts +0 -16
- package/vendor/node_modules/@agent-recorder/service/session-manager.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/session-manager.js 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/session-manager.test 2.js +0 -61
- package/vendor/node_modules/@agent-recorder/service/session-manager.test.d 2.ts +0 -5
- package/vendor/node_modules/@agent-recorder/service/session-manager.test.d.ts 2.map +0 -1
- package/vendor/node_modules/@agent-recorder/service/session-manager.test.js 2.map +0 -1
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Status command - comprehensive daemon status display.
|
|
3
|
-
*/
|
|
4
|
-
import { loadConfig, getDaemonPaths, readPidFile, isProcessRunning, } from "@agent-recorder/core";
|
|
5
|
-
/**
|
|
6
|
-
* Format uptime in human-readable form.
|
|
7
|
-
*/
|
|
8
|
-
function formatUptime(seconds) {
|
|
9
|
-
if (seconds < 60) {
|
|
10
|
-
return `${Math.floor(seconds)}s`;
|
|
11
|
-
}
|
|
12
|
-
if (seconds < 3600) {
|
|
13
|
-
const minutes = Math.floor(seconds / 60);
|
|
14
|
-
const secs = Math.floor(seconds % 60);
|
|
15
|
-
return `${minutes}m ${secs}s`;
|
|
16
|
-
}
|
|
17
|
-
const hours = Math.floor(seconds / 3600);
|
|
18
|
-
const minutes = Math.floor((seconds % 3600) / 60);
|
|
19
|
-
return `${hours}h ${minutes}m`;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Check if a port is reachable via HTTP.
|
|
23
|
-
* For MCP proxy, we accept any response (including 404/503) as "reachable".
|
|
24
|
-
*/
|
|
25
|
-
async function checkPort(port, path, acceptAnyResponse = false) {
|
|
26
|
-
try {
|
|
27
|
-
const response = await fetch(`http://127.0.0.1:${port}${path}`, {
|
|
28
|
-
method: "GET",
|
|
29
|
-
signal: AbortSignal.timeout(2000),
|
|
30
|
-
});
|
|
31
|
-
// For REST API, require 2xx. For MCP proxy, any response means reachable.
|
|
32
|
-
return acceptAnyResponse || response.ok;
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export async function statusCommand() {
|
|
39
|
-
const config = loadConfig();
|
|
40
|
-
const paths = getDaemonPaths();
|
|
41
|
-
console.log("Agent Recorder Status");
|
|
42
|
-
console.log("=====================");
|
|
43
|
-
// Check PID file
|
|
44
|
-
const pid = readPidFile();
|
|
45
|
-
const processRunning = pid !== null && isProcessRunning(pid);
|
|
46
|
-
if (!processRunning) {
|
|
47
|
-
// Determine why not running
|
|
48
|
-
if (pid === null) {
|
|
49
|
-
console.log("State: stopped");
|
|
50
|
-
console.log("Reason: No PID file found");
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
console.log("State: stopped");
|
|
54
|
-
console.log(`Reason: Stale PID file (${pid} not running)`);
|
|
55
|
-
}
|
|
56
|
-
console.log("");
|
|
57
|
-
console.log(`DB Path: ${paths.dbFile}`);
|
|
58
|
-
console.log("");
|
|
59
|
-
console.log("Run 'agent-recorder start --daemon' to start.");
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
// Process is running, try to get health info
|
|
63
|
-
let health = null;
|
|
64
|
-
try {
|
|
65
|
-
const response = await fetch(`http://127.0.0.1:${config.listenPort}/api/health`, { signal: AbortSignal.timeout(2000) });
|
|
66
|
-
if (response.ok) {
|
|
67
|
-
health = (await response.json());
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
// Health endpoint not reachable
|
|
72
|
-
}
|
|
73
|
-
// Check port availability
|
|
74
|
-
const restApiReachable = await checkPort(config.listenPort, "/api/health");
|
|
75
|
-
const mcpProxyReachable = await checkPort(config.mcpProxyPort, "/", true);
|
|
76
|
-
// Display status
|
|
77
|
-
console.log("State: running");
|
|
78
|
-
console.log(`Mode: ${health?.mode ?? "unknown"}`);
|
|
79
|
-
console.log(`PID: ${pid}`);
|
|
80
|
-
if (health?.uptime !== undefined) {
|
|
81
|
-
console.log(`Uptime: ${formatUptime(health.uptime)}`);
|
|
82
|
-
}
|
|
83
|
-
console.log(`REST API: http://127.0.0.1:${config.listenPort} ${restApiReachable ? "(✓)" : "(✗)"}`);
|
|
84
|
-
console.log(`MCP Proxy: http://127.0.0.1:${config.mcpProxyPort} ${mcpProxyReachable ? "(✓)" : "(✗)"}`);
|
|
85
|
-
if (health?.sessionId) {
|
|
86
|
-
console.log(`Session: active (id: ${health.sessionId.slice(0, 8)}...)`);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
console.log("Session: unknown");
|
|
90
|
-
}
|
|
91
|
-
console.log(`DB Path: ${paths.dbFile}`);
|
|
92
|
-
// Show warnings
|
|
93
|
-
if (!restApiReachable) {
|
|
94
|
-
console.log("");
|
|
95
|
-
console.log("⚠ REST API is not reachable. Check the log file:");
|
|
96
|
-
console.log(` ${paths.logFile}`);
|
|
97
|
-
}
|
|
98
|
-
if (!mcpProxyReachable) {
|
|
99
|
-
console.log("");
|
|
100
|
-
console.log("⚠ MCP Proxy is not reachable. Check the log file:");
|
|
101
|
-
console.log(` ${paths.logFile}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=status.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwDH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAkFnD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,EACX,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAW9B;;GAEG;AACH,SAAS,YAAY,CAAC,OAAe;IACnC,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;QACjB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,GAAG,IAAI,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QACtC,OAAO,GAAG,OAAO,KAAK,IAAI,GAAG,CAAC;IAChC,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAClD,OAAO,GAAG,KAAK,KAAK,OAAO,GAAG,CAAC;AACjC,CAAC;A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,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAC1F,CAAC;IACF,OAAO,CAAC,GAAG,CACT,kCAAkC,MAAM,CAAC,YAAY,IAAI,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAC7F,CAAC;IAEF,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CACT,6BAA6B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAChE,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7C,gBAAgB;IAChB,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAChE,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACpC,CAAC;AACH,CAAC"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stop command - stops a running daemon.
|
|
3
|
-
*/
|
|
4
|
-
import { getDaemonPaths, readPidFile, removePidFile, isProcessRunning, releaseLock, } from "@agent-recorder/core";
|
|
5
|
-
/**
|
|
6
|
-
* Wait for a process to exit.
|
|
7
|
-
*/
|
|
8
|
-
async function waitForExit(pid, timeoutMs) {
|
|
9
|
-
const startTime = Date.now();
|
|
10
|
-
while (Date.now() - startTime < timeoutMs) {
|
|
11
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
12
|
-
if (!isProcessRunning(pid)) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
export async function stopCommand(options = {}) {
|
|
19
|
-
const paths = getDaemonPaths();
|
|
20
|
-
// Read PID file
|
|
21
|
-
const pid = readPidFile();
|
|
22
|
-
if (pid === null) {
|
|
23
|
-
console.log("Daemon is not running (no PID file).");
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// Check if process is running
|
|
27
|
-
if (!isProcessRunning(pid)) {
|
|
28
|
-
console.log(`Daemon is not running (stale PID ${pid}).`);
|
|
29
|
-
// Clean up stale files
|
|
30
|
-
removePidFile();
|
|
31
|
-
releaseLock(paths.lockFile);
|
|
32
|
-
console.log("Cleaned up stale files.");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
// Send SIGTERM
|
|
36
|
-
console.log(`Stopping daemon (PID ${pid})...`);
|
|
37
|
-
try {
|
|
38
|
-
process.kill(pid, "SIGTERM");
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
const err = error;
|
|
42
|
-
if (err.code === "ESRCH") {
|
|
43
|
-
console.log("Process already exited.");
|
|
44
|
-
removePidFile();
|
|
45
|
-
releaseLock(paths.lockFile);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (err.code === "EPERM") {
|
|
49
|
-
console.error("Permission denied. Cannot stop the daemon.");
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
// Wait for process to exit (5 seconds)
|
|
55
|
-
const exited = await waitForExit(pid, 5000);
|
|
56
|
-
if (exited) {
|
|
57
|
-
console.log("Daemon stopped successfully.");
|
|
58
|
-
// Clean up (daemon should clean up on exit, but ensure cleanup)
|
|
59
|
-
removePidFile();
|
|
60
|
-
releaseLock(paths.lockFile);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
// Process didn't exit in time
|
|
64
|
-
if (options.force) {
|
|
65
|
-
console.log("Process did not exit, sending SIGKILL...");
|
|
66
|
-
try {
|
|
67
|
-
process.kill(pid, "SIGKILL");
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// Process may have exited between check and kill
|
|
71
|
-
}
|
|
72
|
-
// Wait a bit more
|
|
73
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
74
|
-
if (!isProcessRunning(pid)) {
|
|
75
|
-
console.log("Daemon killed.");
|
|
76
|
-
removePidFile();
|
|
77
|
-
releaseLock(paths.lockFile);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
console.error("Failed to kill daemon.");
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
console.error("Daemon did not stop within 5 seconds.\n" + "Use --force to send SIGKILL.");
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=stop.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../src/commands/stop.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAgBD,wBAAsB,WAAW,CAC/B,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CA4Ef"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../../src/commands/stop.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,MAAM,sB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AAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;YACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CACX,yCAAyC,GAAG,8BAA8B,CAC3E,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TUI command - interactive session explorer.
|
|
3
|
-
*/
|
|
4
|
-
export async function tuiCommand() {
|
|
5
|
-
// Dynamic imports to avoid loading React unless needed
|
|
6
|
-
const { render } = await import("ink");
|
|
7
|
-
const React = await import("react");
|
|
8
|
-
const { App } = await import("../tui/App.js");
|
|
9
|
-
// Render the TUI app
|
|
10
|
-
const { waitUntilExit } = render(React.createElement(App));
|
|
11
|
-
// Wait for the app to exit
|
|
12
|
-
await waitUntilExit();
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=tui.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/commands/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAWhD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../../src/commands/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,uDAAuD;IACvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IAE9C,qBAAqB;IACrB,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3D,2BAA2B;IAC3B,MAAM,aAAa,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Code configuration detection and management.
|
|
3
|
-
* Supports both v2 (~/.claude/settings.json) and legacy (~/.config/claude/mcp.json) paths.
|
|
4
|
-
*/
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import * as path from "node:path";
|
|
7
|
-
import * as os from "node:os";
|
|
8
|
-
/**
|
|
9
|
-
* Get the v2 Claude config path (~/.claude/settings.json)
|
|
10
|
-
*/
|
|
11
|
-
export function getV2ConfigPath() {
|
|
12
|
-
return path.join(os.homedir(), ".claude", "settings.json");
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get the legacy Claude config path (~/.config/claude/mcp.json)
|
|
16
|
-
*/
|
|
17
|
-
export function getLegacyConfigPath() {
|
|
18
|
-
return path.join(os.homedir(), ".config", "claude", "mcp.json");
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Detect which Claude config file exists.
|
|
22
|
-
* Checks v2 first, then legacy. Returns 'none' if neither exists.
|
|
23
|
-
*/
|
|
24
|
-
export function detectClaudeConfig() {
|
|
25
|
-
const v2Path = getV2ConfigPath();
|
|
26
|
-
const legacyPath = getLegacyConfigPath();
|
|
27
|
-
if (fs.existsSync(v2Path)) {
|
|
28
|
-
return { kind: "v2", path: v2Path };
|
|
29
|
-
}
|
|
30
|
-
if (fs.existsSync(legacyPath)) {
|
|
31
|
-
return { kind: "legacy", path: legacyPath };
|
|
32
|
-
}
|
|
33
|
-
return { kind: "none", path: null };
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Safely read and parse a JSON file.
|
|
37
|
-
* Returns null if file doesn't exist or is invalid JSON.
|
|
38
|
-
*/
|
|
39
|
-
export function readJsonFile(filePath) {
|
|
40
|
-
try {
|
|
41
|
-
if (!fs.existsSync(filePath)) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
45
|
-
return JSON.parse(content);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Write JSON to file atomically (write to temp, then rename).
|
|
53
|
-
* Creates parent directories if needed.
|
|
54
|
-
*/
|
|
55
|
-
export function writeJsonFileAtomic(filePath, data) {
|
|
56
|
-
const dir = path.dirname(filePath);
|
|
57
|
-
if (!fs.existsSync(dir)) {
|
|
58
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
59
|
-
}
|
|
60
|
-
const content = JSON.stringify(data, null, 2) + "\n";
|
|
61
|
-
const tempPath = `${filePath}.tmp.${Date.now()}`;
|
|
62
|
-
fs.writeFileSync(tempPath, content, "utf-8");
|
|
63
|
-
fs.renameSync(tempPath, filePath);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Create a backup of a file with timestamp.
|
|
67
|
-
* Returns the backup path.
|
|
68
|
-
*/
|
|
69
|
-
export function createBackup(filePath) {
|
|
70
|
-
const now = new Date();
|
|
71
|
-
// Format: YYYYMMDDHHMMSS (14 chars)
|
|
72
|
-
const timestamp = now.toISOString().replace(/[-:T]/g, "").slice(0, 14);
|
|
73
|
-
const backupPath = `${filePath}.bak-${timestamp}`;
|
|
74
|
-
if (fs.existsSync(filePath)) {
|
|
75
|
-
fs.copyFileSync(filePath, backupPath);
|
|
76
|
-
}
|
|
77
|
-
return backupPath;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get the agent-recorder MCP server entry from a config object.
|
|
81
|
-
*/
|
|
82
|
-
export function getMcpServerEntry(config) {
|
|
83
|
-
const mcpServers = config.mcpServers;
|
|
84
|
-
if (!mcpServers || typeof mcpServers !== "object") {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
const entry = mcpServers["agent-recorder"];
|
|
88
|
-
if (!entry || typeof entry !== "object") {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
return entry;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Set the agent-recorder MCP server entry in a config object.
|
|
95
|
-
* Returns a new config object (does not mutate input).
|
|
96
|
-
*/
|
|
97
|
-
export function setMcpServerEntry(config, url) {
|
|
98
|
-
const newConfig = { ...config };
|
|
99
|
-
// Ensure mcpServers exists
|
|
100
|
-
const mcpServers = newConfig.mcpServers || {};
|
|
101
|
-
newConfig.mcpServers = {
|
|
102
|
-
...mcpServers,
|
|
103
|
-
"agent-recorder": { url },
|
|
104
|
-
};
|
|
105
|
-
return newConfig;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Format a path for display, replacing home directory with ~
|
|
109
|
-
*/
|
|
110
|
-
export function formatPath(filePath) {
|
|
111
|
-
const home = os.homedir();
|
|
112
|
-
if (filePath.startsWith(home)) {
|
|
113
|
-
return "~" + filePath.slice(home.length);
|
|
114
|
-
}
|
|
115
|
-
return filePath;
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=claude-paths.js.map
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Code configuration detection and management.
|
|
3
|
-
* Supports both v2 (~/.claude/settings.json) and legacy (~/.config/claude/mcp.json) paths.
|
|
4
|
-
*/
|
|
5
|
-
export interface ClaudeConfigInfo {
|
|
6
|
-
kind: "v2" | "legacy" | "none";
|
|
7
|
-
path: string | null;
|
|
8
|
-
}
|
|
9
|
-
export interface McpServerEntry {
|
|
10
|
-
url?: string;
|
|
11
|
-
command?: string;
|
|
12
|
-
args?: string[];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get the v2 Claude config path (~/.claude/settings.json)
|
|
16
|
-
*/
|
|
17
|
-
export declare function getV2ConfigPath(): string;
|
|
18
|
-
/**
|
|
19
|
-
* Get the legacy Claude config path (~/.config/claude/mcp.json)
|
|
20
|
-
*/
|
|
21
|
-
export declare function getLegacyConfigPath(): string;
|
|
22
|
-
/**
|
|
23
|
-
* Detect which Claude config file exists.
|
|
24
|
-
* Checks v2 first, then legacy. Returns 'none' if neither exists.
|
|
25
|
-
*/
|
|
26
|
-
export declare function detectClaudeConfig(): ClaudeConfigInfo;
|
|
27
|
-
/**
|
|
28
|
-
* Safely read and parse a JSON file.
|
|
29
|
-
* Returns null if file doesn't exist or is invalid JSON.
|
|
30
|
-
*/
|
|
31
|
-
export declare function readJsonFile(filePath: string): Record<string, unknown> | null;
|
|
32
|
-
/**
|
|
33
|
-
* Write JSON to file atomically (write to temp, then rename).
|
|
34
|
-
* Creates parent directories if needed.
|
|
35
|
-
*/
|
|
36
|
-
export declare function writeJsonFileAtomic(filePath: string, data: Record<string, unknown>): void;
|
|
37
|
-
/**
|
|
38
|
-
* Create a backup of a file with timestamp.
|
|
39
|
-
* Returns the backup path.
|
|
40
|
-
*/
|
|
41
|
-
export declare function createBackup(filePath: string): string;
|
|
42
|
-
/**
|
|
43
|
-
* Get the agent-recorder MCP server entry from a config object.
|
|
44
|
-
*/
|
|
45
|
-
export declare function getMcpServerEntry(config: Record<string, unknown>): McpServerEntry | null;
|
|
46
|
-
/**
|
|
47
|
-
* Set the agent-recorder MCP server entry in a config object.
|
|
48
|
-
* Returns a new config object (does not mutate input).
|
|
49
|
-
*/
|
|
50
|
-
export declare function setMcpServerEntry(config: Record<string, unknown>, url: string): Record<string, unknown>;
|
|
51
|
-
/**
|
|
52
|
-
* Format a path for display, replacing home directory with ~
|
|
53
|
-
*/
|
|
54
|
-
export declare function formatPath(filePath: string): string;
|
|
55
|
-
//# sourceMappingURL=claude-paths.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude-paths.d.ts","sourceRoot":"","sources":["../../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,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAA+B;IAE/B,MAAM,UAAU,GAAG,MAAM,CAAC,UAAiD,CAAC;IAC5E,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB,CAA+B,CAAC;IACzE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAA+B,EAC/B,GAAW;IAEX,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAEhC,2BAA2B;IAC3B,MAAM,UAAU,GAAI,SAAS,CAAC,UAAsC,IAAI,EAAE,CAAC;IAC3E,SAAS,CAAC,UAAU,GAAG;QACrB,GAAG,UAAU;QACb,gBAAgB,EAAE,EAAE,GAAG,EAAE;KAC1B,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1B,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Claude config detection module.
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import * as path from "node:path";
|
|
7
|
-
import * as os from "node:os";
|
|
8
|
-
import { readJsonFile, writeJsonFileAtomic, createBackup, getMcpServerEntry, setMcpServerEntry, formatPath, } from "./claude-paths.js";
|
|
9
|
-
describe("claude-paths", () => {
|
|
10
|
-
let tempDir;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-paths-test-"));
|
|
13
|
-
});
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
16
|
-
});
|
|
17
|
-
describe("readJsonFile", () => {
|
|
18
|
-
it("returns null for non-existent file", () => {
|
|
19
|
-
const result = readJsonFile(path.join(tempDir, "nonexistent.json"));
|
|
20
|
-
expect(result).toBeNull();
|
|
21
|
-
});
|
|
22
|
-
it("reads and parses valid JSON", () => {
|
|
23
|
-
const filePath = path.join(tempDir, "test.json");
|
|
24
|
-
fs.writeFileSync(filePath, '{"key": "value"}');
|
|
25
|
-
const result = readJsonFile(filePath);
|
|
26
|
-
expect(result).toEqual({ key: "value" });
|
|
27
|
-
});
|
|
28
|
-
it("returns null for invalid JSON", () => {
|
|
29
|
-
const filePath = path.join(tempDir, "invalid.json");
|
|
30
|
-
fs.writeFileSync(filePath, "not valid json");
|
|
31
|
-
const result = readJsonFile(filePath);
|
|
32
|
-
expect(result).toBeNull();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe("writeJsonFileAtomic", () => {
|
|
36
|
-
it("writes JSON file with proper formatting", () => {
|
|
37
|
-
const filePath = path.join(tempDir, "output.json");
|
|
38
|
-
writeJsonFileAtomic(filePath, { key: "value", nested: { a: 1 } });
|
|
39
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
40
|
-
expect(content).toContain('"key": "value"');
|
|
41
|
-
expect(content).toContain('"nested"');
|
|
42
|
-
expect(content.endsWith("\n")).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
it("creates parent directories if needed", () => {
|
|
45
|
-
const filePath = path.join(tempDir, "nested", "deep", "config.json");
|
|
46
|
-
writeJsonFileAtomic(filePath, { test: true });
|
|
47
|
-
expect(fs.existsSync(filePath)).toBe(true);
|
|
48
|
-
const result = readJsonFile(filePath);
|
|
49
|
-
expect(result).toEqual({ test: true });
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe("createBackup", () => {
|
|
53
|
-
it("creates backup with timestamp", () => {
|
|
54
|
-
const filePath = path.join(tempDir, "config.json");
|
|
55
|
-
fs.writeFileSync(filePath, '{"original": true}');
|
|
56
|
-
const backupPath = createBackup(filePath);
|
|
57
|
-
expect(backupPath).toMatch(/config\.json\.bak-\d{14}$/);
|
|
58
|
-
expect(fs.existsSync(backupPath)).toBe(true);
|
|
59
|
-
const backupContent = fs.readFileSync(backupPath, "utf-8");
|
|
60
|
-
expect(backupContent).toBe('{"original": true}');
|
|
61
|
-
});
|
|
62
|
-
it("returns path even if source doesn't exist", () => {
|
|
63
|
-
const filePath = path.join(tempDir, "nonexistent.json");
|
|
64
|
-
const backupPath = createBackup(filePath);
|
|
65
|
-
expect(backupPath).toMatch(/\.bak-\d{14}$/);
|
|
66
|
-
expect(fs.existsSync(backupPath)).toBe(false);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe("getMcpServerEntry", () => {
|
|
70
|
-
it("returns null when mcpServers not present", () => {
|
|
71
|
-
const config = { someOther: "config" };
|
|
72
|
-
expect(getMcpServerEntry(config)).toBeNull();
|
|
73
|
-
});
|
|
74
|
-
it("returns null when agent-recorder entry not present", () => {
|
|
75
|
-
const config = { mcpServers: { other: { url: "http://other" } } };
|
|
76
|
-
expect(getMcpServerEntry(config)).toBeNull();
|
|
77
|
-
});
|
|
78
|
-
it("returns entry when present", () => {
|
|
79
|
-
const config = {
|
|
80
|
-
mcpServers: {
|
|
81
|
-
"agent-recorder": { url: "http://127.0.0.1:8788/" },
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
const entry = getMcpServerEntry(config);
|
|
85
|
-
expect(entry).toEqual({ url: "http://127.0.0.1:8788/" });
|
|
86
|
-
});
|
|
87
|
-
it("returns entry with command config", () => {
|
|
88
|
-
const config = {
|
|
89
|
-
mcpServers: {
|
|
90
|
-
"agent-recorder": {
|
|
91
|
-
command: "node",
|
|
92
|
-
args: ["server.js"],
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
const entry = getMcpServerEntry(config);
|
|
97
|
-
expect(entry).toEqual({ command: "node", args: ["server.js"] });
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe("setMcpServerEntry", () => {
|
|
101
|
-
it("adds mcpServers when not present", () => {
|
|
102
|
-
const config = { existing: "value" };
|
|
103
|
-
const result = setMcpServerEntry(config, "http://127.0.0.1:8788/");
|
|
104
|
-
expect(result).toEqual({
|
|
105
|
-
existing: "value",
|
|
106
|
-
mcpServers: {
|
|
107
|
-
"agent-recorder": { url: "http://127.0.0.1:8788/" },
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
it("preserves existing mcpServers entries", () => {
|
|
112
|
-
const config = {
|
|
113
|
-
mcpServers: {
|
|
114
|
-
other: { url: "http://other" },
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
const result = setMcpServerEntry(config, "http://127.0.0.1:8788/");
|
|
118
|
-
expect(result.mcpServers).toEqual({
|
|
119
|
-
other: { url: "http://other" },
|
|
120
|
-
"agent-recorder": { url: "http://127.0.0.1:8788/" },
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
it("updates existing agent-recorder entry", () => {
|
|
124
|
-
const config = {
|
|
125
|
-
mcpServers: {
|
|
126
|
-
"agent-recorder": { url: "http://old-url/" },
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
const result = setMcpServerEntry(config, "http://127.0.0.1:8788/");
|
|
130
|
-
expect(result.mcpServers).toEqual({
|
|
131
|
-
"agent-recorder": { url: "http://127.0.0.1:8788/" },
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
it("does not mutate original config", () => {
|
|
135
|
-
const config = { existing: "value" };
|
|
136
|
-
setMcpServerEntry(config, "http://127.0.0.1:8788/");
|
|
137
|
-
expect(config).toEqual({ existing: "value" });
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe("formatPath", () => {
|
|
141
|
-
it("replaces home directory with ~", () => {
|
|
142
|
-
const home = os.homedir();
|
|
143
|
-
const result = formatPath(`${home}/some/path`);
|
|
144
|
-
expect(result).toBe("~/some/path");
|
|
145
|
-
});
|
|
146
|
-
it("leaves other paths unchanged", () => {
|
|
147
|
-
const result = formatPath("/usr/local/bin");
|
|
148
|
-
expect(result).toBe("/usr/local/bin");
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
//# sourceMappingURL=claude-paths.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude-paths.test.d.ts","sourceRoot":"","sources":["../../src/config/claude-paths.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude-paths.test.js","sourceRoot":"","sources":["../../src/config/claude-paths.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,GAA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