teleportation-cli 1.1.4 → 1.2.0

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 (48) hide show
  1. package/.claude/hooks/config-loader.mjs +88 -34
  2. package/.claude/hooks/permission_request.mjs +392 -82
  3. package/.claude/hooks/post_tool_use.mjs +90 -0
  4. package/.claude/hooks/pre_tool_use.mjs +247 -305
  5. package/.claude/hooks/session-register.mjs +94 -105
  6. package/.claude/hooks/session_end.mjs +41 -42
  7. package/.claude/hooks/session_start.mjs +45 -60
  8. package/.claude/hooks/stop.mjs +752 -99
  9. package/.claude/hooks/user_prompt_submit.mjs +26 -3
  10. package/README.md +7 -0
  11. package/lib/auth/api-key.js +12 -0
  12. package/lib/auth/token-refresh.js +286 -0
  13. package/lib/cli/daemon-commands.js +1 -1
  14. package/lib/cli/teleport-commands.js +469 -0
  15. package/lib/daemon/daemon-v2.js +104 -0
  16. package/lib/daemon/lifecycle.js +56 -171
  17. package/lib/daemon/response-classifier.js +15 -1
  18. package/lib/daemon/services/index.js +3 -0
  19. package/lib/daemon/services/polling-service.js +173 -0
  20. package/lib/daemon/services/queue-service.js +318 -0
  21. package/lib/daemon/services/session-service.js +115 -0
  22. package/lib/daemon/state.js +35 -0
  23. package/lib/daemon/task-executor-v2.js +413 -0
  24. package/lib/daemon/task-executor.js +1235 -0
  25. package/lib/daemon/teleportation-daemon.js +770 -25
  26. package/lib/daemon/timeline-analyzer.js +215 -0
  27. package/lib/daemon/transcript-ingestion.js +696 -0
  28. package/lib/daemon/utils.js +91 -0
  29. package/lib/install/installer.js +184 -20
  30. package/lib/install/uhr-installer.js +136 -0
  31. package/lib/remote/providers/base-provider.js +46 -0
  32. package/lib/remote/providers/daytona-provider.js +58 -0
  33. package/lib/remote/providers/provider-factory.js +90 -19
  34. package/lib/remote/providers/sprites-provider.js +711 -0
  35. package/lib/teleport/exporters/claude-exporter.js +302 -0
  36. package/lib/teleport/exporters/gemini-exporter.js +307 -0
  37. package/lib/teleport/exporters/index.js +93 -0
  38. package/lib/teleport/exporters/interface.js +153 -0
  39. package/lib/teleport/fork-tracker.js +415 -0
  40. package/lib/teleport/git-committer.js +337 -0
  41. package/lib/teleport/index.js +48 -0
  42. package/lib/teleport/manager.js +620 -0
  43. package/lib/teleport/session-capture.js +282 -0
  44. package/package.json +11 -5
  45. package/teleportation-cli.cjs +632 -451
  46. package/.claude/hooks/heartbeat.mjs +0 -396
  47. package/lib/daemon/agentic-executor.js +0 -803
  48. package/lib/daemon/pid-manager.js +0 -160
@@ -1,160 +0,0 @@
1
- import { promises as fs } from 'fs';
2
- import { join } from 'path';
3
- import { homedir } from 'os';
4
-
5
- /**
6
- * PID Manager
7
- * Manages daemon process ID file for ensuring single daemon instance
8
- */
9
-
10
- const TELEPORTATION_DIR = join(homedir(), '.teleportation');
11
- const PID_FILE = join(TELEPORTATION_DIR, 'daemon.pid');
12
-
13
- /**
14
- * Check if a process with given PID is running
15
- */
16
- export function isProcessRunning(pid) {
17
- console.log(`[pid-manager] Checking if process ${pid} is running...`);
18
- // Handle invalid PIDs
19
- if (typeof pid !== 'number' || pid <= 0) {
20
- return false;
21
- }
22
-
23
- try {
24
- // Signal 0 checks if process exists without actually sending a signal
25
- process.kill(pid, 0);
26
- return true;
27
- } catch (err) {
28
- return false;
29
- }
30
- }
31
-
32
- /**
33
- * Read PID from file
34
- * @returns {Promise<number|null>} PID or null if file doesn't exist or is invalid
35
- */
36
- export async function readPid() {
37
- console.log(`[pid-manager] Reading PID from ${PID_FILE}...`);
38
- try {
39
- const content = await fs.readFile(PID_FILE, 'utf-8');
40
- const pid = parseInt(content.trim(), 10);
41
- if (isNaN(pid) || pid <= 0) {
42
- return null;
43
- }
44
- return pid;
45
- } catch (err) {
46
- if (err.code === 'ENOENT') {
47
- return null;
48
- }
49
- throw err;
50
- }
51
- }
52
-
53
- /**
54
- * Write PID to file with 600 permissions
55
- * @param {number} pid - Process ID to write
56
- */
57
- export async function writePid(pid) {
58
- console.log(`[pid-manager] Writing PID ${pid} to ${PID_FILE}...`);
59
- // Ensure .teleportation directory exists
60
- await fs.mkdir(TELEPORTATION_DIR, { recursive: true, mode: 0o700 });
61
-
62
- // Write PID file with 600 permissions (owner read/write only)
63
- await fs.writeFile(PID_FILE, String(pid), { mode: 0o600 });
64
- }
65
-
66
- /**
67
- * Remove PID file
68
- */
69
- export async function removePid() {
70
- console.log(`[pid-manager] Removing PID file ${PID_FILE}...`);
71
- try {
72
- await fs.unlink(PID_FILE);
73
- } catch (err) {
74
- if (err.code !== 'ENOENT') {
75
- throw err;
76
- }
77
- }
78
- }
79
-
80
- /**
81
- * Check if daemon is already running
82
- * @returns {Promise<{running: boolean, pid: number|null, stale: boolean}>}
83
- */
84
- export async function checkDaemonStatus() {
85
- const pid = await readPid();
86
-
87
- if (pid === null) {
88
- return { running: false, pid: null, stale: false };
89
- }
90
-
91
- const running = isProcessRunning(pid);
92
-
93
- return {
94
- running,
95
- pid,
96
- stale: !running // PID file exists but process is dead
97
- };
98
- }
99
-
100
- /**
101
- * Clean up stale PID file (when process doesn't exist)
102
- * @returns {Promise<boolean>} true if stale PID was removed
103
- */
104
- export async function cleanupStalePid() {
105
- const status = await checkDaemonStatus();
106
-
107
- if (status.stale) {
108
- await removePid();
109
- return true;
110
- }
111
-
112
- return false;
113
- }
114
-
115
- /**
116
- * Acquire PID lock (write PID file, ensuring no other daemon is running)
117
- * @param {number} pid - Process ID to write
118
- * @throws {Error} if another daemon is already running
119
- */
120
- export async function acquirePidLock(pid) {
121
- console.log(`[pid-manager] Acquiring PID lock for PID ${pid}...`);
122
- // Clean up any stale PID files first
123
- await cleanupStalePid();
124
-
125
- // Check if daemon is running
126
- const status = await checkDaemonStatus();
127
-
128
- if (status.running) {
129
- throw new Error(`Daemon already running with PID ${status.pid}`);
130
- }
131
-
132
- // Write our PID
133
- await writePid(pid);
134
- }
135
-
136
- /**
137
- * Release PID lock (remove PID file if it matches our PID)
138
- * @param {number} pid - Our process ID
139
- */
140
- export async function releasePidLock(pid) {
141
- console.log(`[pid-manager] Releasing PID lock for PID ${pid}...`);
142
- const currentPid = await readPid();
143
-
144
- // Only remove if PID file matches our process
145
- if (currentPid === pid) {
146
- await removePid();
147
- }
148
- }
149
-
150
- export default {
151
- isProcessRunning,
152
- readPid,
153
- writePid,
154
- removePid,
155
- checkDaemonStatus,
156
- cleanupStalePid,
157
- acquirePidLock,
158
- releasePidLock,
159
- PID_FILE
160
- };