happy-coder 0.1.10 → 0.1.11
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/README.md +2 -0
- package/dist/index-B2GqfEZV.cjs +1564 -0
- package/dist/index-QItBXhux.mjs +1540 -0
- package/dist/index.cjs +420 -258
- package/dist/index.mjs +410 -248
- package/dist/install-B0DnBGS_.mjs +29 -0
- package/dist/install-B2r_gX72.cjs +109 -0
- package/dist/install-C809w0Cj.cjs +31 -0
- package/dist/install-DEPy62QN.mjs +97 -0
- package/dist/install-GZIzyuIE.cjs +99 -0
- package/dist/install-HKe7dyS4.mjs +107 -0
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +8 -3
- package/dist/lib.d.mts +8 -3
- package/dist/lib.mjs +1 -1
- package/dist/run-BmEaINbl.cjs +250 -0
- package/dist/run-DMbKhYfb.mjs +247 -0
- package/dist/run-FBXkmmN7.mjs +32 -0
- package/dist/run-q2To6b-c.cjs +34 -0
- package/dist/types-BRICSarm.mjs +870 -0
- package/dist/types-BTQRfIr3.cjs +892 -0
- package/dist/types-CEvzGLMI.cjs +882 -0
- package/dist/{types-DnQGY77F.mjs → types-D39L8JSd.mjs} +55 -23
- package/dist/types-DYBiuNUQ.cjs +883 -0
- package/dist/types-Df5dlWLV.mjs +871 -0
- package/dist/types-fXgEaaqP.mjs +861 -0
- package/dist/{types-B2JzqUiU.cjs → types-hotUTaWz.cjs} +53 -21
- package/dist/types-mykDX2xe.cjs +872 -0
- package/dist/types-tLWMaptR.mjs +879 -0
- package/dist/uninstall-BGgl5V8F.mjs +29 -0
- package/dist/uninstall-BWHglipH.mjs +40 -0
- package/dist/uninstall-C42CoSCI.cjs +53 -0
- package/dist/uninstall-CLkTtlMv.mjs +51 -0
- package/dist/uninstall-CdHMb6wi.cjs +31 -0
- package/dist/uninstall-FXyyAuGU.cjs +42 -0
- package/package.json +8 -2
- package/ripgrep/COPYING +3 -0
- package/ripgrep/arm64-darwin/rg +0 -0
- package/ripgrep/arm64-darwin/ripgrep.node +0 -0
- package/ripgrep/arm64-linux/rg +0 -0
- package/ripgrep/arm64-linux/ripgrep.node +0 -0
- package/ripgrep/x64-darwin/rg +0 -0
- package/ripgrep/x64-darwin/ripgrep.node +0 -0
- package/ripgrep/x64-linux/rg +0 -0
- package/ripgrep/x64-linux/ripgrep.node +0 -0
- package/ripgrep/x64-win32/rg.exe +0 -0
- package/ripgrep/x64-win32/ripgrep.node +0 -0
- package/scripts/ripgrep_launcher.cjs +57 -0
|
@@ -21,16 +21,20 @@ class Configuration {
|
|
|
21
21
|
logsDir;
|
|
22
22
|
settingsFile;
|
|
23
23
|
privateKeyFile;
|
|
24
|
+
daemonPidFile;
|
|
24
25
|
constructor(location) {
|
|
25
26
|
this.serverUrl = process.env.HANDY_SERVER_URL || "https://handy-api.korshakov.org";
|
|
26
27
|
if (location === "local") {
|
|
27
28
|
this.happyDir = node_path.join(process.cwd(), ".happy");
|
|
28
|
-
} else {
|
|
29
|
+
} else if (location === "global") {
|
|
29
30
|
this.happyDir = node_path.join(os.homedir(), ".happy");
|
|
31
|
+
} else {
|
|
32
|
+
this.happyDir = node_path.join(location, ".happy");
|
|
30
33
|
}
|
|
31
34
|
this.logsDir = node_path.join(this.happyDir, "logs");
|
|
32
35
|
this.settingsFile = node_path.join(this.happyDir, "settings.json");
|
|
33
36
|
this.privateKeyFile = node_path.join(this.happyDir, "access.key");
|
|
37
|
+
this.daemonPidFile = node_path.join(this.happyDir, "daemon.pid");
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
exports.configuration = void 0;
|
|
@@ -390,28 +394,39 @@ class ApiSessionClient extends node_events.EventEmitter {
|
|
|
390
394
|
exports.logger.debug("[API] Socket connection error:", error);
|
|
391
395
|
});
|
|
392
396
|
this.socket.on("update", (data) => {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
397
|
+
try {
|
|
398
|
+
exports.logger.debugLargeJson("[SOCKET] [UPDATE] Received update:", data);
|
|
399
|
+
if (!data.body) {
|
|
400
|
+
exports.logger.debug("[SOCKET] [UPDATE] [ERROR] No body in update!");
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (data.body.t === "new-message" && data.body.message.content.t === "encrypted") {
|
|
404
|
+
const body = decrypt(decodeBase64(data.body.message.content.c), this.secret);
|
|
405
|
+
exports.logger.debugLargeJson("[SOCKET] [UPDATE] Received update:", body);
|
|
406
|
+
const userResult = UserMessageSchema.safeParse(body);
|
|
407
|
+
if (userResult.success) {
|
|
408
|
+
if (this.pendingMessageCallback) {
|
|
409
|
+
this.pendingMessageCallback(userResult.data);
|
|
410
|
+
} else {
|
|
411
|
+
this.pendingMessages.push(userResult.data);
|
|
412
|
+
}
|
|
400
413
|
} else {
|
|
401
|
-
this.
|
|
414
|
+
this.emit("message", body);
|
|
415
|
+
}
|
|
416
|
+
} else if (data.body.t === "update-session") {
|
|
417
|
+
if (data.body.metadata && data.body.metadata.version > this.metadataVersion) {
|
|
418
|
+
this.metadata = decrypt(decodeBase64(data.body.metadata.value), this.secret);
|
|
419
|
+
this.metadataVersion = data.body.metadata.version;
|
|
420
|
+
}
|
|
421
|
+
if (data.body.agentState && data.body.agentState.version > this.agentStateVersion) {
|
|
422
|
+
this.agentState = data.body.agentState.value ? decrypt(decodeBase64(data.body.agentState.value), this.secret) : null;
|
|
423
|
+
this.agentStateVersion = data.body.agentState.version;
|
|
402
424
|
}
|
|
403
425
|
} else {
|
|
404
|
-
this.emit("message", body);
|
|
405
|
-
}
|
|
406
|
-
} else if (data.body.t === "update-session") {
|
|
407
|
-
if (data.body.metadata && data.body.metadata.version > this.metadataVersion) {
|
|
408
|
-
this.metadata = decrypt(decodeBase64(data.body.metadata.value), this.secret);
|
|
409
|
-
this.metadataVersion = data.body.metadata.version;
|
|
410
|
-
}
|
|
411
|
-
if (data.body.agentState && data.body.agentState.version > this.agentStateVersion) {
|
|
412
|
-
this.agentState = data.body.agentState.value ? decrypt(decodeBase64(data.body.agentState.value), this.secret) : null;
|
|
413
|
-
this.agentStateVersion = data.body.agentState.version;
|
|
426
|
+
this.emit("message", data.body);
|
|
414
427
|
}
|
|
428
|
+
} catch (error) {
|
|
429
|
+
exports.logger.debug("[SOCKET] [UPDATE] [ERROR] Error handling update", { error });
|
|
415
430
|
}
|
|
416
431
|
});
|
|
417
432
|
this.socket.on("error", (error) => {
|
|
@@ -472,14 +487,31 @@ class ApiSessionClient extends node_events.EventEmitter {
|
|
|
472
487
|
}));
|
|
473
488
|
}
|
|
474
489
|
}
|
|
490
|
+
sendSessionEvent(event, id) {
|
|
491
|
+
let content = {
|
|
492
|
+
role: "agent",
|
|
493
|
+
content: {
|
|
494
|
+
id: id ?? node_crypto.randomUUID(),
|
|
495
|
+
type: "event",
|
|
496
|
+
data: event
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
const encrypted = encodeBase64(encrypt(content, this.secret));
|
|
500
|
+
this.socket.emit("message", {
|
|
501
|
+
sid: this.sessionId,
|
|
502
|
+
message: encrypted
|
|
503
|
+
});
|
|
504
|
+
}
|
|
475
505
|
/**
|
|
476
506
|
* Send a ping message to keep the connection alive
|
|
477
507
|
*/
|
|
478
|
-
keepAlive(thinking) {
|
|
508
|
+
keepAlive(thinking, mode) {
|
|
509
|
+
exports.logger.debug(`[API] Sending keep alive message: ${thinking}`);
|
|
479
510
|
this.socket.volatile.emit("session-alive", {
|
|
480
511
|
sid: this.sessionId,
|
|
481
512
|
time: Date.now(),
|
|
482
|
-
thinking
|
|
513
|
+
thinking,
|
|
514
|
+
mode
|
|
483
515
|
});
|
|
484
516
|
}
|
|
485
517
|
/**
|