happy-coder 0.3.1-beta.0 → 0.3.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -9,6 +9,8 @@ var node_readline = require('node:readline');
9
9
  var node_url = require('node:url');
10
10
  var node_fs = require('node:fs');
11
11
  var os = require('node:os');
12
+ var path = require('path');
13
+ var url = require('url');
12
14
  var promises$1 = require('node:fs/promises');
13
15
  var promises = require('fs/promises');
14
16
  var ink = require('ink');
@@ -25,8 +27,6 @@ var z = require('zod');
25
27
  var child_process = require('child_process');
26
28
  var util = require('util');
27
29
  var crypto = require('crypto');
28
- var path = require('path');
29
- var url = require('url');
30
30
  var qrcode = require('qrcode-terminal');
31
31
  var fs = require('fs');
32
32
  var os$1 = require('os');
@@ -118,7 +118,13 @@ function claudeCheckSession(sessionId, path) {
118
118
  return hasGoodMessage;
119
119
  }
120
120
 
121
- const __dirname$3 = node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
121
+ const __dirname$2 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
122
+ function projectPath() {
123
+ const path$1 = path.resolve(__dirname$2, "..");
124
+ return path$1;
125
+ }
126
+
127
+ node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
122
128
  async function claudeLocal(opts) {
123
129
  const projectDir = getProjectPath(opts.path);
124
130
  node_fs.mkdirSync(projectDir, { recursive: true });
@@ -168,7 +174,10 @@ async function claudeLocal(opts) {
168
174
  if (opts.claudeArgs) {
169
175
  args.push(...opts.claudeArgs);
170
176
  }
171
- const claudeCliPath = process.env.HAPPY_CLAUDE_CLI_PATH || node_path.resolve(node_path.join(__dirname$3, "..", "scripts", "claudeInteractiveLaunch.cjs"));
177
+ const claudeCliPath = node_path.resolve(node_path.join(projectPath(), "scripts", "claude_local_launcher.cjs"));
178
+ if (!claudeCliPath || !node_fs.existsSync(claudeCliPath)) {
179
+ throw new Error("Claude local launcher not found. Please ensure HAPPY_PROJECT_ROOT is set correctly for development.");
180
+ }
172
181
  const env = {
173
182
  ...process.env,
174
183
  ...opts.claudeEnvVars
@@ -845,9 +854,9 @@ class AbortError extends Error {
845
854
  }
846
855
 
847
856
  const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
848
- const __dirname$2 = node_path.join(__filename$1, "..");
857
+ const __dirname$1 = node_path.join(__filename$1, "..");
849
858
  function getDefaultClaudeCodePath() {
850
- return node_path.join(__dirname$2, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
859
+ return node_path.join(__dirname$1, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
851
860
  }
852
861
  function logDebug(message) {
853
862
  if (process.env.DEBUG) {
@@ -909,16 +918,20 @@ class Query {
909
918
  try {
910
919
  for await (const line of rl) {
911
920
  if (line.trim()) {
912
- const message = JSON.parse(line);
913
- if (message.type === "control_response") {
914
- const controlResponse = message;
915
- const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
916
- if (handler) {
917
- handler(controlResponse.response);
921
+ try {
922
+ const message = JSON.parse(line);
923
+ if (message.type === "control_response") {
924
+ const controlResponse = message;
925
+ const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
926
+ if (handler) {
927
+ handler(controlResponse.response);
928
+ }
929
+ continue;
918
930
  }
919
- continue;
931
+ this.inputStream.enqueue(message);
932
+ } catch (e) {
933
+ types$1.logger.debug(line);
920
934
  }
921
- this.inputStream.enqueue(message);
922
935
  }
923
936
  }
924
937
  await this.processExitPromise;
@@ -1240,7 +1253,10 @@ async function claudeRemote(opts) {
1240
1253
  permissionPromptToolName: opts.permissionPromptToolName,
1241
1254
  permissionMode: opts.permissionMode,
1242
1255
  executable: "node",
1243
- abort: opts.signal
1256
+ abort: opts.signal,
1257
+ pathToClaudeCodeExecutable: (() => {
1258
+ return node_path.resolve(node_path.join(projectPath(), "scripts", "claude_remote_launcher.cjs"));
1259
+ })()
1244
1260
  };
1245
1261
  if (opts.claudeArgs && opts.claudeArgs.length > 0) {
1246
1262
  sdkOptions.executableArgs = [...sdkOptions.executableArgs || [], ...opts.claudeArgs];
@@ -2232,7 +2248,7 @@ async function loop(opts) {
2232
2248
  }
2233
2249
 
2234
2250
  var name = "happy-coder";
2235
- var version = "0.3.1-beta.0";
2251
+ var version = "0.3.1-beta.1";
2236
2252
  var description = "Claude Code session sharing CLI";
2237
2253
  var author = "Kirill Dubovitskiy";
2238
2254
  var license = "MIT";
@@ -2343,9 +2359,8 @@ var packageJson = {
2343
2359
  overrides: overrides
2344
2360
  };
2345
2361
 
2346
- const __dirname$1 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
2347
- const RUNNER_PATH = process.env.HAPPY_RIPGREP_LAUNCHER_PATH || path.resolve(path.join(__dirname$1, "..", "..", "scripts", "ripgrep_launcher.cjs"));
2348
2362
  function run(args, options) {
2363
+ const RUNNER_PATH = path.resolve(path.join(projectPath(), "scripts", "ripgrep_launcher.cjs"));
2349
2364
  return new Promise((resolve2, reject) => {
2350
2365
  const child = child_process.spawn("node", [RUNNER_PATH, JSON.stringify(args)], {
2351
2366
  stdio: ["pipe", "pipe", "pipe"],
package/dist/index.mjs CHANGED
@@ -2,11 +2,13 @@ import chalk from 'chalk';
2
2
  import { l as logger, d as backoff, e as delay, R as RawJSONLinesSchema, c as configuration, f as encodeBase64, A as ApiClient, g as encodeBase64Url, h as decodeBase64, b as initializeConfiguration, i as initLoggerWithGlobalConfiguration } from './types-BX4xv8Ty.mjs';
3
3
  import { randomUUID, randomBytes } from 'node:crypto';
4
4
  import { spawn, execSync } from 'node:child_process';
5
- import { resolve, join, dirname } from 'node:path';
5
+ import { resolve, join, dirname as dirname$1 } from 'node:path';
6
6
  import { createInterface } from 'node:readline';
7
- import { fileURLToPath } from 'node:url';
7
+ import { fileURLToPath as fileURLToPath$1 } from 'node:url';
8
8
  import { existsSync, readFileSync, mkdirSync, watch, rmSync } from 'node:fs';
9
9
  import os, { homedir } from 'node:os';
10
+ import { dirname, resolve as resolve$1, join as join$1 } from 'path';
11
+ import { fileURLToPath } from 'url';
10
12
  import { readFile, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
11
13
  import { watch as watch$1, access, readFile as readFile$1, stat, writeFile, readdir } from 'fs/promises';
12
14
  import { useStdout, useInput, Box, Text, render } from 'ink';
@@ -24,8 +26,6 @@ import { z as z$1 } from 'zod';
24
26
  import { spawn as spawn$1, exec, execSync as execSync$1 } from 'child_process';
25
27
  import { promisify } from 'util';
26
28
  import crypto, { createHash } from 'crypto';
27
- import { dirname as dirname$1, resolve as resolve$1, join as join$1 } from 'path';
28
- import { fileURLToPath as fileURLToPath$1 } from 'url';
29
29
  import qrcode from 'qrcode-terminal';
30
30
  import { existsSync as existsSync$1, readFileSync as readFileSync$1, writeFileSync, unlinkSync, mkdirSync as mkdirSync$1, chmodSync } from 'fs';
31
31
  import { hostname, homedir as homedir$1 } from 'os';
@@ -97,7 +97,13 @@ function claudeCheckSession(sessionId, path) {
97
97
  return hasGoodMessage;
98
98
  }
99
99
 
100
- const __dirname$2 = dirname(fileURLToPath(import.meta.url));
100
+ const __dirname$1 = dirname(fileURLToPath(import.meta.url));
101
+ function projectPath() {
102
+ const path = resolve$1(__dirname$1, "..");
103
+ return path;
104
+ }
105
+
106
+ dirname$1(fileURLToPath$1(import.meta.url));
101
107
  async function claudeLocal(opts) {
102
108
  const projectDir = getProjectPath(opts.path);
103
109
  mkdirSync(projectDir, { recursive: true });
@@ -147,7 +153,10 @@ async function claudeLocal(opts) {
147
153
  if (opts.claudeArgs) {
148
154
  args.push(...opts.claudeArgs);
149
155
  }
150
- const claudeCliPath = process.env.HAPPY_CLAUDE_CLI_PATH || resolve(join(__dirname$2, "..", "scripts", "claudeInteractiveLaunch.cjs"));
156
+ const claudeCliPath = resolve(join(projectPath(), "scripts", "claude_local_launcher.cjs"));
157
+ if (!claudeCliPath || !existsSync(claudeCliPath)) {
158
+ throw new Error("Claude local launcher not found. Please ensure HAPPY_PROJECT_ROOT is set correctly for development.");
159
+ }
151
160
  const env = {
152
161
  ...process.env,
153
162
  ...opts.claudeEnvVars
@@ -823,10 +832,10 @@ class AbortError extends Error {
823
832
  }
824
833
  }
825
834
 
826
- const __filename = fileURLToPath(import.meta.url);
827
- const __dirname$1 = join(__filename, "..");
835
+ const __filename = fileURLToPath$1(import.meta.url);
836
+ const __dirname = join(__filename, "..");
828
837
  function getDefaultClaudeCodePath() {
829
- return join(__dirname$1, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
838
+ return join(__dirname, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
830
839
  }
831
840
  function logDebug(message) {
832
841
  if (process.env.DEBUG) {
@@ -888,16 +897,20 @@ class Query {
888
897
  try {
889
898
  for await (const line of rl) {
890
899
  if (line.trim()) {
891
- const message = JSON.parse(line);
892
- if (message.type === "control_response") {
893
- const controlResponse = message;
894
- const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
895
- if (handler) {
896
- handler(controlResponse.response);
900
+ try {
901
+ const message = JSON.parse(line);
902
+ if (message.type === "control_response") {
903
+ const controlResponse = message;
904
+ const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
905
+ if (handler) {
906
+ handler(controlResponse.response);
907
+ }
908
+ continue;
897
909
  }
898
- continue;
910
+ this.inputStream.enqueue(message);
911
+ } catch (e) {
912
+ logger.debug(line);
899
913
  }
900
- this.inputStream.enqueue(message);
901
914
  }
902
915
  }
903
916
  await this.processExitPromise;
@@ -1219,7 +1232,10 @@ async function claudeRemote(opts) {
1219
1232
  permissionPromptToolName: opts.permissionPromptToolName,
1220
1233
  permissionMode: opts.permissionMode,
1221
1234
  executable: "node",
1222
- abort: opts.signal
1235
+ abort: opts.signal,
1236
+ pathToClaudeCodeExecutable: (() => {
1237
+ return resolve(join(projectPath(), "scripts", "claude_remote_launcher.cjs"));
1238
+ })()
1223
1239
  };
1224
1240
  if (opts.claudeArgs && opts.claudeArgs.length > 0) {
1225
1241
  sdkOptions.executableArgs = [...sdkOptions.executableArgs || [], ...opts.claudeArgs];
@@ -2211,7 +2227,7 @@ async function loop(opts) {
2211
2227
  }
2212
2228
 
2213
2229
  var name = "happy-coder";
2214
- var version = "0.3.1-beta.0";
2230
+ var version = "0.3.1-beta.1";
2215
2231
  var description = "Claude Code session sharing CLI";
2216
2232
  var author = "Kirill Dubovitskiy";
2217
2233
  var license = "MIT";
@@ -2322,9 +2338,8 @@ var packageJson = {
2322
2338
  overrides: overrides
2323
2339
  };
2324
2340
 
2325
- const __dirname = dirname$1(fileURLToPath$1(import.meta.url));
2326
- const RUNNER_PATH = process.env.HAPPY_RIPGREP_LAUNCHER_PATH || resolve$1(join$1(__dirname, "..", "..", "scripts", "ripgrep_launcher.cjs"));
2327
2341
  function run(args, options) {
2342
+ const RUNNER_PATH = resolve$1(join$1(projectPath(), "scripts", "ripgrep_launcher.cjs"));
2328
2343
  return new Promise((resolve2, reject) => {
2329
2344
  const child = spawn$1("node", [RUNNER_PATH, JSON.stringify(args)], {
2330
2345
  stdio: ["pipe", "pipe", "pipe"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-coder",
3
- "version": "0.3.1-beta.0",
3
+ "version": "0.3.1-beta.1",
4
4
  "description": "Claude Code session sharing CLI",
5
5
  "author": "Kirill Dubovitskiy",
6
6
  "license": "MIT",
@@ -0,0 +1,13 @@
1
+ // Intercept setTimeout for the Claude Code SDK
2
+ const originalSetTimeout = global.setTimeout;
3
+
4
+ global.setTimeout = function(callback, delay, ...args) {
5
+ // Just wrap and call the original setTimeout
6
+ return originalSetTimeout(callback, delay, ...args);
7
+ };
8
+
9
+ // Preserve setTimeout properties
10
+ Object.defineProperty(global.setTimeout, 'name', { value: 'setTimeout' });
11
+ Object.defineProperty(global.setTimeout, 'length', { value: originalSetTimeout.length });
12
+
13
+ import('@anthropic-ai/claude-code/cli.js')