episoda 0.2.3 → 0.2.7

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 (113) hide show
  1. package/dist/index.d.ts +0 -7
  2. package/dist/index.js +3736 -80
  3. package/dist/index.js.map +1 -1
  4. package/package.json +5 -3
  5. package/dist/commands/auth.d.ts +0 -22
  6. package/dist/commands/auth.d.ts.map +0 -1
  7. package/dist/commands/auth.js +0 -384
  8. package/dist/commands/auth.js.map +0 -1
  9. package/dist/commands/dev.d.ts +0 -20
  10. package/dist/commands/dev.d.ts.map +0 -1
  11. package/dist/commands/dev.js +0 -305
  12. package/dist/commands/dev.js.map +0 -1
  13. package/dist/commands/status.d.ts +0 -9
  14. package/dist/commands/status.d.ts.map +0 -1
  15. package/dist/commands/status.js +0 -75
  16. package/dist/commands/status.js.map +0 -1
  17. package/dist/commands/stop.d.ts +0 -17
  18. package/dist/commands/stop.d.ts.map +0 -1
  19. package/dist/commands/stop.js +0 -81
  20. package/dist/commands/stop.js.map +0 -1
  21. package/dist/core/auth.d.ts +0 -26
  22. package/dist/core/auth.d.ts.map +0 -1
  23. package/dist/core/auth.js +0 -113
  24. package/dist/core/auth.js.map +0 -1
  25. package/dist/core/command-protocol.d.ts +0 -262
  26. package/dist/core/command-protocol.d.ts.map +0 -1
  27. package/dist/core/command-protocol.js +0 -13
  28. package/dist/core/command-protocol.js.map +0 -1
  29. package/dist/core/connection-manager.d.ts +0 -58
  30. package/dist/core/connection-manager.d.ts.map +0 -1
  31. package/dist/core/connection-manager.js +0 -215
  32. package/dist/core/connection-manager.js.map +0 -1
  33. package/dist/core/errors.d.ts +0 -18
  34. package/dist/core/errors.d.ts.map +0 -1
  35. package/dist/core/errors.js +0 -55
  36. package/dist/core/errors.js.map +0 -1
  37. package/dist/core/git-executor.d.ts +0 -157
  38. package/dist/core/git-executor.d.ts.map +0 -1
  39. package/dist/core/git-executor.js +0 -1605
  40. package/dist/core/git-executor.js.map +0 -1
  41. package/dist/core/git-parser.d.ts +0 -40
  42. package/dist/core/git-parser.d.ts.map +0 -1
  43. package/dist/core/git-parser.js +0 -194
  44. package/dist/core/git-parser.js.map +0 -1
  45. package/dist/core/git-validator.d.ts +0 -42
  46. package/dist/core/git-validator.d.ts.map +0 -1
  47. package/dist/core/git-validator.js +0 -102
  48. package/dist/core/git-validator.js.map +0 -1
  49. package/dist/core/index.d.ts +0 -17
  50. package/dist/core/index.d.ts.map +0 -1
  51. package/dist/core/index.js +0 -41
  52. package/dist/core/index.js.map +0 -1
  53. package/dist/core/version.d.ts +0 -9
  54. package/dist/core/version.d.ts.map +0 -1
  55. package/dist/core/version.js +0 -19
  56. package/dist/core/version.js.map +0 -1
  57. package/dist/core/websocket-client.d.ts +0 -122
  58. package/dist/core/websocket-client.d.ts.map +0 -1
  59. package/dist/core/websocket-client.js +0 -438
  60. package/dist/core/websocket-client.js.map +0 -1
  61. package/dist/daemon/daemon-manager.d.ts +0 -71
  62. package/dist/daemon/daemon-manager.d.ts.map +0 -1
  63. package/dist/daemon/daemon-manager.js +0 -289
  64. package/dist/daemon/daemon-manager.js.map +0 -1
  65. package/dist/daemon/daemon-process.d.ts +0 -13
  66. package/dist/daemon/daemon-process.d.ts.map +0 -1
  67. package/dist/daemon/daemon-process.js +0 -624
  68. package/dist/daemon/daemon-process.js.map +0 -1
  69. package/dist/daemon/identity-server.d.ts +0 -51
  70. package/dist/daemon/identity-server.d.ts.map +0 -1
  71. package/dist/daemon/identity-server.js +0 -158
  72. package/dist/daemon/identity-server.js.map +0 -1
  73. package/dist/daemon/machine-id.d.ts +0 -36
  74. package/dist/daemon/machine-id.d.ts.map +0 -1
  75. package/dist/daemon/machine-id.js +0 -195
  76. package/dist/daemon/machine-id.js.map +0 -1
  77. package/dist/daemon/project-tracker.d.ts +0 -92
  78. package/dist/daemon/project-tracker.d.ts.map +0 -1
  79. package/dist/daemon/project-tracker.js +0 -259
  80. package/dist/daemon/project-tracker.js.map +0 -1
  81. package/dist/dev-wrapper.d.ts +0 -88
  82. package/dist/dev-wrapper.d.ts.map +0 -1
  83. package/dist/dev-wrapper.js +0 -288
  84. package/dist/dev-wrapper.js.map +0 -1
  85. package/dist/framework-detector.d.ts +0 -29
  86. package/dist/framework-detector.d.ts.map +0 -1
  87. package/dist/framework-detector.js +0 -276
  88. package/dist/framework-detector.js.map +0 -1
  89. package/dist/git-helpers/git-credential-helper.d.ts +0 -29
  90. package/dist/git-helpers/git-credential-helper.d.ts.map +0 -1
  91. package/dist/git-helpers/git-credential-helper.js +0 -349
  92. package/dist/git-helpers/git-credential-helper.js.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/ipc/ipc-client.d.ts +0 -95
  95. package/dist/ipc/ipc-client.d.ts.map +0 -1
  96. package/dist/ipc/ipc-client.js +0 -204
  97. package/dist/ipc/ipc-client.js.map +0 -1
  98. package/dist/ipc/ipc-server.d.ts +0 -55
  99. package/dist/ipc/ipc-server.d.ts.map +0 -1
  100. package/dist/ipc/ipc-server.js +0 -177
  101. package/dist/ipc/ipc-server.js.map +0 -1
  102. package/dist/output.d.ts +0 -48
  103. package/dist/output.d.ts.map +0 -1
  104. package/dist/output.js +0 -129
  105. package/dist/output.js.map +0 -1
  106. package/dist/utils/port-check.d.ts +0 -15
  107. package/dist/utils/port-check.d.ts.map +0 -1
  108. package/dist/utils/port-check.js +0 -79
  109. package/dist/utils/port-check.js.map +0 -1
  110. package/dist/utils/update-checker.d.ts +0 -23
  111. package/dist/utils/update-checker.d.ts.map +0 -1
  112. package/dist/utils/update-checker.js +0 -95
  113. package/dist/utils/update-checker.js.map +0 -1
@@ -1,349 +0,0 @@
1
- "use strict";
2
- /**
3
- * EP548/EP612: Git Credential Helper Script Generator
4
- *
5
- * This module generates the git credential helper script that is installed
6
- * during `episoda auth`. The script is called by git when credentials are needed.
7
- *
8
- * The generated script:
9
- * 1. Detects the environment (local vs cloud)
10
- * 2. Calls GET /api/git/credentials with appropriate auth
11
- * 3. Returns credentials in git credential protocol format
12
- * 4. Caches tokens locally (5 min TTL) to avoid API calls on every git operation
13
- *
14
- * EP612: Removed jq dependency - uses pure bash JSON parsing
15
- */
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.CREDENTIAL_HELPER_SCRIPT = void 0;
18
- exports.generateCredentialHelperScript = generateCredentialHelperScript;
19
- /**
20
- * Generate the credential helper script content
21
- *
22
- * The script needs to:
23
- * - Be standalone (no external dependencies - just bash and curl)
24
- * - Work with curl (available on all platforms)
25
- * - Handle both local (OAuth) and cloud (machine ID) auth
26
- * - Cache tokens to avoid hitting API on every git operation
27
- */
28
- function generateCredentialHelperScript(apiUrl) {
29
- // The script uses bash because it's universally available
30
- // No jq dependency - uses pure bash for JSON parsing
31
- return `#!/bin/bash
32
- #
33
- # Episoda Git Credential Helper
34
- # EP548/EP612: Unified git authentication for all environments
35
- #
36
- # This script is called by git when credentials are needed.
37
- # It calls the Episoda API to get a fresh GitHub token.
38
- #
39
- # Installation: episoda auth
40
- # Location: ~/.episoda/bin/git-credential-episoda (local)
41
- # /usr/local/bin/git-credential-episoda (cloud VM)
42
- #
43
- # Git credential protocol:
44
- # - git calls: git-credential-episoda get
45
- # - input on stdin: protocol=https\\nhost=github.com\\n
46
- # - output on stdout: username=x-access-token\\npassword=TOKEN\\n
47
- #
48
- # Dependencies: bash, curl (no jq required)
49
- #
50
-
51
- set -euo pipefail
52
-
53
- EPISODA_DIR="\${HOME}/.episoda"
54
- CONFIG_FILE="\${EPISODA_DIR}/config.json"
55
- CACHE_FILE="\${EPISODA_DIR}/git-token-cache.json"
56
- API_URL="${apiUrl}"
57
-
58
- # Cache TTL in seconds (5 minutes)
59
- CACHE_TTL=300
60
-
61
- # Log function (to stderr so git doesn't see it)
62
- log() {
63
- if [[ "\${GIT_CREDENTIAL_EPISODA_DEBUG:-}" == "1" ]]; then
64
- echo "[episoda-git] \$(date '+%H:%M:%S') \$*" >&2
65
- fi
66
- }
67
-
68
- # Error log (always shown)
69
- error() {
70
- echo "[episoda-git] ERROR: \$*" >&2
71
- }
72
-
73
- # Pure bash JSON value extraction (no jq needed)
74
- # Usage: json_get '{"foo":"bar"}' "foo" -> "bar"
75
- # Handles simple flat JSON and nested paths like "credentials.username"
76
- json_get() {
77
- local json="\$1"
78
- local key="\$2"
79
- local value=""
80
-
81
- # Handle nested keys (e.g., "credentials.username")
82
- if [[ "\$key" == *.* ]]; then
83
- local outer="\${key%%.*}"
84
- local inner="\${key#*.}"
85
- # Extract outer object first, then inner key
86
- # Match "outer":{...} and extract the {...} part
87
- local nested
88
- nested=\$(echo "\$json" | sed -n 's/.*"'\$outer'"[[:space:]]*:[[:space:]]*{\\([^}]*\\)}.*/\\1/p')
89
- if [[ -n "\$nested" ]]; then
90
- json_get "{\$nested}" "\$inner"
91
- return
92
- fi
93
- return
94
- fi
95
-
96
- # Simple key extraction: "key":"value" or "key": "value"
97
- # Handle both quoted strings and unquoted values
98
- value=\$(echo "\$json" | sed -n 's/.*"'\$key'"[[:space:]]*:[[:space:]]*"\\([^"]*\\)".*/\\1/p')
99
-
100
- if [[ -n "\$value" ]]; then
101
- echo "\$value"
102
- fi
103
- }
104
-
105
- # Check for required dependencies
106
- check_dependencies() {
107
- if ! command -v curl >/dev/null 2>&1; then
108
- error "curl is required but not installed"
109
- return 1
110
- fi
111
- return 0
112
- }
113
-
114
- # Parse git credential input from stdin
115
- parse_input() {
116
- while IFS= read -r line; do
117
- [[ -z "\$line" ]] && break
118
- case "\$line" in
119
- protocol=*) PROTOCOL="\${line#protocol=}" ;;
120
- host=*) HOST="\${line#host=}" ;;
121
- path=*) PATH_="\${line#path=}" ;;
122
- esac
123
- done
124
- }
125
-
126
- # Parse ISO 8601 date to unix timestamp (cross-platform)
127
- parse_iso_date() {
128
- local iso_date="\$1"
129
- # Try GNU date first (Linux)
130
- if date -d "\$iso_date" +%s 2>/dev/null; then
131
- return
132
- fi
133
- # Try BSD date (macOS) - strip timezone for parsing
134
- local clean_date="\${iso_date%+*}" # Remove +00:00
135
- clean_date="\${clean_date%Z}" # Remove Z
136
- clean_date="\${clean_date%.*}" # Remove .milliseconds
137
- if date -jf "%Y-%m-%dT%H:%M:%S" "\$clean_date" +%s 2>/dev/null; then
138
- return
139
- fi
140
- # Fallback: return 0 (expired)
141
- echo "0"
142
- }
143
-
144
- # Check if cached token is still valid
145
- get_cached_token() {
146
- if [[ ! -f "\$CACHE_FILE" ]]; then
147
- log "No cache file"
148
- return 1
149
- fi
150
-
151
- # Read cache file
152
- local cache_content
153
- cache_content=\$(cat "\$CACHE_FILE" 2>/dev/null) || return 1
154
-
155
- # Parse cache file using pure bash
156
- local expires_at
157
- expires_at=\$(json_get "\$cache_content" "expires_at")
158
-
159
- if [[ -z "\$expires_at" ]]; then
160
- log "No expires_at in cache"
161
- return 1
162
- fi
163
-
164
- # Check if expired (with 60 second buffer)
165
- local now expires_ts buffer
166
- now=\$(date +%s)
167
- expires_ts=\$(parse_iso_date "\$expires_at")
168
- buffer=60
169
-
170
- if [[ \$((expires_ts - buffer)) -le \$now ]]; then
171
- log "Cache expired (expires: \$expires_at)"
172
- return 1
173
- fi
174
-
175
- # Return cached token
176
- CACHED_TOKEN=\$(json_get "\$cache_content" "password")
177
- CACHED_USER=\$(json_get "\$cache_content" "username")
178
-
179
- if [[ -n "\$CACHED_TOKEN" && -n "\$CACHED_USER" ]]; then
180
- log "Using cached token (expires: \$expires_at)"
181
- return 0
182
- fi
183
-
184
- log "Invalid cache content"
185
- return 1
186
- }
187
-
188
- # Save token to cache
189
- save_to_cache() {
190
- local username="\$1"
191
- local password="\$2"
192
- local expires_at="\$3"
193
-
194
- mkdir -p "\$EPISODA_DIR"
195
- cat > "\$CACHE_FILE" <<CACHE_EOF
196
- {"username":"\$username","password":"\$password","expires_at":"\$expires_at","cached_at":"\$(date -u +"%Y-%m-%dT%H:%M:%SZ")"}
197
- CACHE_EOF
198
- chmod 600 "\$CACHE_FILE"
199
- log "Token cached until \$expires_at"
200
- }
201
-
202
- # Get credentials from Episoda API
203
- fetch_credentials() {
204
- local api_url="\${EPISODA_API_URL:-\${API_URL}}"
205
- local response=""
206
- local http_code=""
207
-
208
- # Detect environment - check multiple ways to identify a cloud VM
209
- local machine_id=""
210
-
211
- # Check FLY_MACHINE_ID (set by Fly.io on all machines)
212
- if [[ -n "\${FLY_MACHINE_ID:-}" ]]; then
213
- machine_id="\$FLY_MACHINE_ID"
214
- log "Cloud environment detected via FLY_MACHINE_ID: \$machine_id"
215
- # Legacy: check /app/.machine_id file
216
- elif [[ -f "/app/.machine_id" ]]; then
217
- machine_id=\$(cat /app/.machine_id)
218
- log "Cloud environment detected via /app/.machine_id: \$machine_id"
219
- fi
220
-
221
- if [[ -n "\$machine_id" ]]; then
222
- # Cloud VM: use machine ID header
223
- log "Fetching credentials for machine: \$machine_id"
224
- response=\$(curl -s -w "\\n%{http_code}" --max-time 10 "\${api_url}/api/git/credentials" \\
225
- -H "X-Machine-ID: \$machine_id" \\
226
- -H "Content-Type: application/json" 2>&1) || {
227
- error "curl failed: \$response"
228
- return 1
229
- }
230
- else
231
- # Local: use OAuth token from config
232
- if [[ ! -f "\$CONFIG_FILE" ]]; then
233
- error "No config found at \$CONFIG_FILE. Run 'episoda auth' first."
234
- return 1
235
- fi
236
-
237
- # Parse config using pure bash
238
- local config_content
239
- config_content=\$(cat "\$CONFIG_FILE" 2>/dev/null) || {
240
- error "Cannot read config file"
241
- return 1
242
- }
243
-
244
- local access_token project_id
245
- access_token=\$(json_get "\$config_content" "access_token")
246
- project_id=\$(json_get "\$config_content" "project_id")
247
-
248
- if [[ -z "\$access_token" ]]; then
249
- error "No access token in config. Run 'episoda auth' to authenticate."
250
- return 1
251
- fi
252
-
253
- log "Local environment (project: \$project_id)"
254
- response=\$(curl -s -w "\\n%{http_code}" --max-time 10 "\${api_url}/api/git/credentials" \\
255
- -H "Authorization: Bearer \$access_token" \\
256
- -H "X-Project-ID: \$project_id" \\
257
- -H "Content-Type: application/json" 2>&1) || {
258
- error "curl failed: \$response"
259
- return 1
260
- }
261
- fi
262
-
263
- # Split response and HTTP code
264
- http_code=\$(echo "\$response" | tail -n1)
265
- response=\$(echo "\$response" | sed '\$d')
266
-
267
- # Check HTTP status
268
- if [[ "\$http_code" != "200" ]]; then
269
- error "API returned HTTP \$http_code"
270
- log "Response: \$response"
271
- return 1
272
- fi
273
-
274
- # Parse response using pure bash
275
- CRED_USERNAME=\$(json_get "\$response" "credentials.username")
276
- CRED_PASSWORD=\$(json_get "\$response" "credentials.password")
277
- CRED_EXPIRES=\$(json_get "\$response" "credentials.expires_at")
278
-
279
- if [[ -z "\$CRED_USERNAME" || -z "\$CRED_PASSWORD" ]]; then
280
- error "Invalid credentials in response"
281
- log "Response: \$response"
282
- return 1
283
- fi
284
-
285
- # Cache the token
286
- save_to_cache "\$CRED_USERNAME" "\$CRED_PASSWORD" "\$CRED_EXPIRES"
287
-
288
- log "Credentials fetched successfully"
289
- return 0
290
- }
291
-
292
- # Main
293
- main() {
294
- local command="\${1:-}"
295
-
296
- # Check dependencies before processing
297
- if ! check_dependencies; then
298
- exit 0 # Exit gracefully so git tries other helpers
299
- fi
300
-
301
- case "\$command" in
302
- get)
303
- parse_input
304
-
305
- # Only handle github.com
306
- if [[ "\${HOST:-}" != "github.com" ]]; then
307
- log "Not handling host: \${HOST:-unknown}"
308
- exit 0
309
- fi
310
-
311
- # Try cache first
312
- if get_cached_token; then
313
- echo "username=\$CACHED_USER"
314
- echo "password=\$CACHED_TOKEN"
315
- exit 0
316
- fi
317
-
318
- # Fetch fresh credentials
319
- if fetch_credentials; then
320
- echo "username=\$CRED_USERNAME"
321
- echo "password=\$CRED_PASSWORD"
322
- exit 0
323
- fi
324
-
325
- # Failed - let git try other credential helpers
326
- log "Failed to get credentials, falling back to other helpers"
327
- exit 0
328
- ;;
329
-
330
- store|erase)
331
- # We don't store or erase credentials
332
- exit 0
333
- ;;
334
-
335
- *)
336
- # Unknown command
337
- exit 0
338
- ;;
339
- esac
340
- }
341
-
342
- main "\$@"
343
- `;
344
- }
345
- /**
346
- * Get the content of the credential helper for embedding in the CLI
347
- */
348
- exports.CREDENTIAL_HELPER_SCRIPT = generateCredentialHelperScript('https://episoda.dev');
349
- //# sourceMappingURL=git-credential-helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-credential-helper.js","sourceRoot":"","sources":["../../src/git-helpers/git-credential-helper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAWH,wEA4TC;AArUD;;;;;;;;GAQG;AACH,SAAgB,8BAA8B,CAAC,MAAc;IAC3D,0DAA0D;IAC1D,qDAAqD;IACrD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;WAyBE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+RhB,CAAA;AACD,CAAC;AAED;;GAEG;AACU,QAAA,wBAAwB,GAAG,8BAA8B,CAAC,qBAAqB,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG"}
@@ -1,95 +0,0 @@
1
- /**
2
- * IPC Client - Used by CLI commands
3
- *
4
- * Sends commands to daemon via Unix domain socket.
5
- * Handles request/response communication.
6
- *
7
- * Socket location: ~/.episoda/daemon.sock
8
- */
9
- export interface IPCRequest {
10
- id: string;
11
- command: string;
12
- params?: any;
13
- }
14
- export interface IPCResponse {
15
- id: string;
16
- success: boolean;
17
- data?: any;
18
- error?: string;
19
- }
20
- /**
21
- * Send command to daemon
22
- *
23
- * Connects to daemon socket, sends command, waits for response.
24
- *
25
- * @param command Command name
26
- * @param params Command parameters
27
- * @param timeout Timeout in milliseconds (default: 15000)
28
- * @returns Response data
29
- * @throws Error if daemon not running or command fails
30
- */
31
- export declare function sendCommand(command: string, params?: any, timeout?: number): Promise<any>;
32
- /**
33
- * Check if daemon is reachable via IPC
34
- *
35
- * @returns true if daemon is running and responding
36
- */
37
- export declare function isDaemonReachable(): Promise<boolean>;
38
- /**
39
- * Add project to daemon
40
- *
41
- * EP734: Now blocking - waits for WebSocket connection to complete
42
- *
43
- * @param projectId Supabase project ID
44
- * @param projectPath Absolute path to project
45
- * @returns Connection result with success/error info
46
- */
47
- export declare function addProject(projectId: string, projectPath: string): Promise<{
48
- success: boolean;
49
- connected: boolean;
50
- error?: string;
51
- }>;
52
- /**
53
- * Remove project from daemon
54
- *
55
- * @param projectPath Absolute path to project
56
- */
57
- export declare function removeProject(projectPath: string): Promise<void>;
58
- /**
59
- * Get daemon status
60
- *
61
- * EP738: Added hostname, platform, arch for status command (HTTP server removed)
62
- *
63
- * @returns Status information including connected projects and device info
64
- */
65
- export declare function getStatus(): Promise<{
66
- running: boolean;
67
- machineId: string;
68
- deviceId?: string;
69
- hostname: string;
70
- platform: string;
71
- arch: string;
72
- projects: Array<{
73
- id: string;
74
- path: string;
75
- name: string;
76
- connected: boolean;
77
- }>;
78
- }>;
79
- /**
80
- * Request daemon to connect to a project's WebSocket
81
- *
82
- * @param projectPath Absolute path to project
83
- */
84
- export declare function connectProject(projectPath: string): Promise<void>;
85
- /**
86
- * Request daemon to disconnect from a project's WebSocket
87
- *
88
- * @param projectPath Absolute path to project
89
- */
90
- export declare function disconnectProject(projectPath: string): Promise<void>;
91
- /**
92
- * Request daemon shutdown
93
- */
94
- export declare function shutdownDaemon(): Promise<void>;
95
- //# sourceMappingURL=ipc-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ipc-client.d.ts","sourceRoot":"","sources":["../../src/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,CAAA;QACZ,SAAS,EAAE,OAAO,CAAA;KACnB,CAAC,CAAA;CACH,CAAC,CAED;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD"}
@@ -1,204 +0,0 @@
1
- "use strict";
2
- /**
3
- * IPC Client - Used by CLI commands
4
- *
5
- * Sends commands to daemon via Unix domain socket.
6
- * Handles request/response communication.
7
- *
8
- * Socket location: ~/.episoda/daemon.sock
9
- */
10
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- var desc = Object.getOwnPropertyDescriptor(m, k);
13
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
- desc = { enumerable: true, get: function() { return m[k]; } };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }) : (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- o[k2] = m[k];
20
- }));
21
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22
- Object.defineProperty(o, "default", { enumerable: true, value: v });
23
- }) : function(o, v) {
24
- o["default"] = v;
25
- });
26
- var __importStar = (this && this.__importStar) || (function () {
27
- var ownKeys = function(o) {
28
- ownKeys = Object.getOwnPropertyNames || function (o) {
29
- var ar = [];
30
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
31
- return ar;
32
- };
33
- return ownKeys(o);
34
- };
35
- return function (mod) {
36
- if (mod && mod.__esModule) return mod;
37
- var result = {};
38
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
39
- __setModuleDefault(result, mod);
40
- return result;
41
- };
42
- })();
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.sendCommand = sendCommand;
45
- exports.isDaemonReachable = isDaemonReachable;
46
- exports.addProject = addProject;
47
- exports.removeProject = removeProject;
48
- exports.getStatus = getStatus;
49
- exports.connectProject = connectProject;
50
- exports.disconnectProject = disconnectProject;
51
- exports.shutdownDaemon = shutdownDaemon;
52
- const net = __importStar(require("net"));
53
- const path = __importStar(require("path"));
54
- const crypto = __importStar(require("crypto"));
55
- const core_1 = require("../core");
56
- const getSocketPath = () => path.join((0, core_1.getConfigDir)(), 'daemon.sock');
57
- const DEFAULT_TIMEOUT = 15000; // 15 seconds (EP606: increased for device registration)
58
- /**
59
- * Send command to daemon
60
- *
61
- * Connects to daemon socket, sends command, waits for response.
62
- *
63
- * @param command Command name
64
- * @param params Command parameters
65
- * @param timeout Timeout in milliseconds (default: 15000)
66
- * @returns Response data
67
- * @throws Error if daemon not running or command fails
68
- */
69
- async function sendCommand(command, params, timeout = DEFAULT_TIMEOUT) {
70
- return new Promise((resolve, reject) => {
71
- const socket = net.createConnection(getSocketPath());
72
- const requestId = crypto.randomUUID();
73
- let buffer = '';
74
- let timeoutHandle;
75
- // Set timeout
76
- timeoutHandle = setTimeout(() => {
77
- socket.destroy();
78
- reject(new Error(`Command timed out after ${timeout}ms`));
79
- }, timeout);
80
- socket.on('connect', () => {
81
- // Send request
82
- const request = {
83
- id: requestId,
84
- command,
85
- params,
86
- };
87
- socket.write(JSON.stringify(request) + '\n');
88
- });
89
- socket.on('data', (chunk) => {
90
- buffer += chunk.toString();
91
- // Check for complete response (delimited by newline)
92
- const newlineIndex = buffer.indexOf('\n');
93
- if (newlineIndex === -1)
94
- return;
95
- // Extract response
96
- const message = buffer.slice(0, newlineIndex);
97
- try {
98
- const response = JSON.parse(message);
99
- // Verify response ID matches
100
- if (response.id !== requestId) {
101
- reject(new Error('Response ID mismatch'));
102
- return;
103
- }
104
- clearTimeout(timeoutHandle);
105
- socket.end();
106
- if (response.success) {
107
- resolve(response.data);
108
- }
109
- else {
110
- reject(new Error(response.error || 'Command failed'));
111
- }
112
- }
113
- catch (error) {
114
- clearTimeout(timeoutHandle);
115
- socket.end();
116
- reject(new Error('Invalid response from daemon'));
117
- }
118
- });
119
- socket.on('error', (error) => {
120
- clearTimeout(timeoutHandle);
121
- // Check for common errors
122
- if (error.code === 'ENOENT' || error.code === 'ECONNREFUSED') {
123
- reject(new Error('Daemon is not running. Start it with: episoda dev'));
124
- }
125
- else {
126
- reject(error);
127
- }
128
- });
129
- socket.on('timeout', () => {
130
- clearTimeout(timeoutHandle);
131
- socket.destroy();
132
- reject(new Error('Connection timeout'));
133
- });
134
- });
135
- }
136
- /**
137
- * Check if daemon is reachable via IPC
138
- *
139
- * @returns true if daemon is running and responding
140
- */
141
- async function isDaemonReachable() {
142
- try {
143
- await sendCommand('ping', {}, 1000);
144
- return true;
145
- }
146
- catch (error) {
147
- return false;
148
- }
149
- }
150
- /**
151
- * Add project to daemon
152
- *
153
- * EP734: Now blocking - waits for WebSocket connection to complete
154
- *
155
- * @param projectId Supabase project ID
156
- * @param projectPath Absolute path to project
157
- * @returns Connection result with success/error info
158
- */
159
- async function addProject(projectId, projectPath) {
160
- // EP734: Increased timeout to 30s to allow for WebSocket connection
161
- return await sendCommand('add-project', { projectId, projectPath }, 30000);
162
- }
163
- /**
164
- * Remove project from daemon
165
- *
166
- * @param projectPath Absolute path to project
167
- */
168
- async function removeProject(projectPath) {
169
- await sendCommand('remove-project', { projectPath });
170
- }
171
- /**
172
- * Get daemon status
173
- *
174
- * EP738: Added hostname, platform, arch for status command (HTTP server removed)
175
- *
176
- * @returns Status information including connected projects and device info
177
- */
178
- async function getStatus() {
179
- return await sendCommand('status');
180
- }
181
- /**
182
- * Request daemon to connect to a project's WebSocket
183
- *
184
- * @param projectPath Absolute path to project
185
- */
186
- async function connectProject(projectPath) {
187
- await sendCommand('connect-project', { projectPath });
188
- }
189
- /**
190
- * Request daemon to disconnect from a project's WebSocket
191
- *
192
- * @param projectPath Absolute path to project
193
- */
194
- async function disconnectProject(projectPath) {
195
- await sendCommand('disconnect-project', { projectPath });
196
- }
197
- /**
198
- * Request daemon shutdown
199
- */
200
- async function shutdownDaemon() {
201
- await sendCommand('shutdown', {}, 2000);
202
- }
203
- // EP734: Removed getConnectionStatus - no longer needed with blocking add-project
204
- //# sourceMappingURL=ipc-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ipc-client.js","sourceRoot":"","sources":["../../src/ipc/ipc-client.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,kCA+EC;AAOD,8CAOC;AAWD,gCAOC;AAOD,sCAEC;AASD,8BAeC;AAOD,wCAEC;AAOD,8CAEC;AAKD,wCAEC;AAzMD,yCAA0B;AAC1B,2CAA4B;AAC5B,+CAAgC;AAChC,kCAAsC;AAEtC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAA,mBAAY,GAAE,EAAE,aAAa,CAAC,CAAA;AACpE,MAAM,eAAe,GAAG,KAAK,CAAA,CAAC,wDAAwD;AAetF;;;;;;;;;;GAUG;AACI,KAAK,UAAU,WAAW,CAC/B,OAAe,EACf,MAAY,EACZ,UAAkB,eAAe;IAEjC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,GAAG,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;QACrC,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,IAAI,aAA6B,CAAA;QAEjC,cAAc;QACd,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,MAAM,CAAC,OAAO,EAAE,CAAA;YAChB,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,O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