@zhigang1992/happy-cli 0.13.8 → 0.13.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/dist/{index-CfnMIBxL.cjs → index-BpSLeHcW.cjs} +24 -104
- package/dist/{index-jDGb6HV8.mjs → index-GQ9EasMu.mjs} +26 -106
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/lib.cjs +1 -1
- package/dist/lib.mjs +1 -1
- package/dist/{list-CnFDoVXs.mjs → list-Lp972nwz.mjs} +1 -1
- package/dist/{list-CkMjnW2p.cjs → list-RgcDN0C0.cjs} +1 -1
- package/dist/{prompt-BbGwX_Nf.mjs → prompt-BPehYWlE.mjs} +1 -1
- package/dist/{prompt-DoInQDd4.cjs → prompt-Bb5xD1Xl.cjs} +1 -1
- package/dist/{runCodex-Ch_mWn45.cjs → runCodex-BXOAacnj.cjs} +2 -2
- package/dist/{runCodex-DRSD6qZo.mjs → runCodex-CgW9cBS9.mjs} +2 -2
- package/dist/{types-DyS63_MQ.mjs → types-CPYxEUyu.mjs} +2 -2
- package/dist/{types-Bop9J_T5.cjs → types-DysMExRA.cjs} +3 -3
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
4
|
var os = require('node:os');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
|
-
var types = require('./types-
|
|
6
|
+
var types = require('./types-DysMExRA.cjs');
|
|
7
7
|
var node_child_process = require('node:child_process');
|
|
8
8
|
var node_path = require('node:path');
|
|
9
9
|
var node_readline = require('node:readline');
|
|
@@ -648,11 +648,8 @@ async function createSessionScanner(opts) {
|
|
|
648
648
|
let currentSessionId = null;
|
|
649
649
|
let watchers = /* @__PURE__ */ new Map();
|
|
650
650
|
let processedMessageKeys = /* @__PURE__ */ new Set();
|
|
651
|
-
let sessionOffsets = /* @__PURE__ */ new Map();
|
|
652
|
-
let failedLineHashes = /* @__PURE__ */ new Set();
|
|
653
651
|
if (opts.sessionId) {
|
|
654
|
-
let
|
|
655
|
-
sessionOffsets.set(opts.sessionId, newOffset);
|
|
652
|
+
let messages = await readSessionLog(projectDir, opts.sessionId);
|
|
656
653
|
for (let m of messages) {
|
|
657
654
|
processedMessageKeys.add(messageKey(m));
|
|
658
655
|
}
|
|
@@ -666,16 +663,13 @@ async function createSessionScanner(opts) {
|
|
|
666
663
|
sessions.push(currentSessionId);
|
|
667
664
|
}
|
|
668
665
|
for (let session of sessions) {
|
|
669
|
-
let
|
|
670
|
-
|
|
671
|
-
sessionOffsets.set(session, newOffset);
|
|
672
|
-
for (let msg of messages) {
|
|
673
|
-
let key = messageKey(msg);
|
|
666
|
+
for (let file of await readSessionLog(projectDir, session)) {
|
|
667
|
+
let key = messageKey(file);
|
|
674
668
|
if (processedMessageKeys.has(key)) {
|
|
675
669
|
continue;
|
|
676
670
|
}
|
|
677
671
|
processedMessageKeys.add(key);
|
|
678
|
-
opts.onMessage(
|
|
672
|
+
opts.onMessage(file);
|
|
679
673
|
}
|
|
680
674
|
}
|
|
681
675
|
for (let p of sessions) {
|
|
@@ -741,60 +735,36 @@ function messageKey(message) {
|
|
|
741
735
|
throw Error();
|
|
742
736
|
}
|
|
743
737
|
}
|
|
744
|
-
async function
|
|
738
|
+
async function readSessionLog(projectDir, sessionId) {
|
|
745
739
|
const expectedSessionFile = node_path.join(projectDir, `${sessionId}.jsonl`);
|
|
746
|
-
|
|
740
|
+
types.logger.debug(`[SESSION_SCANNER] Reading session file: ${expectedSessionFile}`);
|
|
741
|
+
let file;
|
|
747
742
|
try {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
return
|
|
752
|
-
}
|
|
753
|
-
if (fileSize <= fromOffset) {
|
|
754
|
-
return { messages: [], newOffset: fromOffset };
|
|
755
|
-
}
|
|
756
|
-
let newContent;
|
|
757
|
-
try {
|
|
758
|
-
const fh = await promises.open(expectedSessionFile, "r");
|
|
759
|
-
try {
|
|
760
|
-
const buf = Buffer.alloc(fileSize - fromOffset);
|
|
761
|
-
await fh.read(buf, 0, buf.length, fromOffset);
|
|
762
|
-
newContent = buf.toString("utf-8");
|
|
763
|
-
} finally {
|
|
764
|
-
await fh.close();
|
|
765
|
-
}
|
|
766
|
-
} catch {
|
|
767
|
-
return { messages: [], newOffset: fromOffset };
|
|
743
|
+
file = await promises.readFile(expectedSessionFile, "utf-8");
|
|
744
|
+
} catch (error) {
|
|
745
|
+
types.logger.debug(`[SESSION_SCANNER] Session file not found: ${expectedSessionFile}`);
|
|
746
|
+
return [];
|
|
768
747
|
}
|
|
748
|
+
let lines = file.split("\n");
|
|
769
749
|
let messages = [];
|
|
770
|
-
let lines = newContent.split("\n");
|
|
771
750
|
for (let l of lines) {
|
|
772
|
-
let trimmed = l.trim();
|
|
773
|
-
if (trimmed === "") {
|
|
774
|
-
continue;
|
|
775
|
-
}
|
|
776
751
|
try {
|
|
777
|
-
|
|
752
|
+
if (l.trim() === "") {
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
let message = JSON.parse(l);
|
|
778
756
|
let parsed = types.RawJSONLinesSchema.safeParse(message);
|
|
779
757
|
if (!parsed.success) {
|
|
780
|
-
|
|
781
|
-
if (!failedLineHashes.has(lineHash)) {
|
|
782
|
-
failedLineHashes.add(lineHash);
|
|
783
|
-
types.logger.debugLargeJson(`[SESSION_SCANNER] Failed to parse message`, message);
|
|
784
|
-
}
|
|
758
|
+
types.logger.debugLargeJson(`[SESSION_SCANNER] Failed to parse message`, message);
|
|
785
759
|
continue;
|
|
786
760
|
}
|
|
787
761
|
messages.push(parsed.data);
|
|
788
762
|
} catch (e) {
|
|
789
|
-
|
|
790
|
-
if (!failedLineHashes.has(lineHash)) {
|
|
791
|
-
failedLineHashes.add(lineHash);
|
|
792
|
-
types.logger.debug(`[SESSION_SCANNER] Error processing message: ${e}`);
|
|
793
|
-
}
|
|
763
|
+
types.logger.debug(`[SESSION_SCANNER] Error processing message: ${e}`);
|
|
794
764
|
continue;
|
|
795
765
|
}
|
|
796
766
|
}
|
|
797
|
-
return
|
|
767
|
+
return messages;
|
|
798
768
|
}
|
|
799
769
|
|
|
800
770
|
async function claudeLocalLauncher(session) {
|
|
@@ -1214,7 +1184,7 @@ class AbortError extends Error {
|
|
|
1214
1184
|
}
|
|
1215
1185
|
}
|
|
1216
1186
|
|
|
1217
|
-
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-
|
|
1187
|
+
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-BpSLeHcW.cjs', document.baseURI).href)));
|
|
1218
1188
|
const __dirname$1 = node_path.join(__filename$1, "..");
|
|
1219
1189
|
function getGlobalClaudeVersion() {
|
|
1220
1190
|
try {
|
|
@@ -3166,38 +3136,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3166
3136
|
cwd: session.path,
|
|
3167
3137
|
version: process.env.npm_package_version
|
|
3168
3138
|
}, permissionHandler.getResponses());
|
|
3169
|
-
const sentMessageUuids = /* @__PURE__ */ new Set();
|
|
3170
|
-
function getMessageDedupeKey(msg) {
|
|
3171
|
-
if (msg.type === "summary") {
|
|
3172
|
-
return `summary:${msg.leafUuid}:${msg.summary}`;
|
|
3173
|
-
}
|
|
3174
|
-
if (msg.type === "system") {
|
|
3175
|
-
return `system:${msg.uuid}`;
|
|
3176
|
-
}
|
|
3177
|
-
try {
|
|
3178
|
-
const content = JSON.stringify(msg.message?.content ?? "");
|
|
3179
|
-
const contentKey = content.slice(0, 100) + ":" + content.length;
|
|
3180
|
-
return `${msg.type}:${contentKey}`;
|
|
3181
|
-
} catch {
|
|
3182
|
-
return msg.uuid ?? null;
|
|
3183
|
-
}
|
|
3184
|
-
}
|
|
3185
|
-
const sessionScanner = await createSessionScanner({
|
|
3186
|
-
sessionId: session.sessionId,
|
|
3187
|
-
workingDirectory: session.path,
|
|
3188
|
-
onMessage: (logMessage) => {
|
|
3189
|
-
const dedupeKey = getMessageDedupeKey(logMessage);
|
|
3190
|
-
if (dedupeKey && sentMessageUuids.has(dedupeKey)) {
|
|
3191
|
-
types.logger.debug(`[remote]: Scanner skipping (already sent): ${logMessage.type}`);
|
|
3192
|
-
return;
|
|
3193
|
-
}
|
|
3194
|
-
if (dedupeKey) {
|
|
3195
|
-
sentMessageUuids.add(dedupeKey);
|
|
3196
|
-
}
|
|
3197
|
-
types.logger.debug(`[remote]: Scanner forwarding message: ${logMessage.type}`);
|
|
3198
|
-
messageQueue.enqueue(logMessage);
|
|
3199
|
-
}
|
|
3200
|
-
});
|
|
3201
3139
|
let ongoingToolCalls = /* @__PURE__ */ new Map();
|
|
3202
3140
|
function onMessage(message) {
|
|
3203
3141
|
formatClaudeMessageForInk(message, messageBuffer);
|
|
@@ -3226,10 +3164,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3226
3164
|
}
|
|
3227
3165
|
const logMessage = sdkToLogConverter.convert(message);
|
|
3228
3166
|
if (logMessage) {
|
|
3229
|
-
const dedupeKey = getMessageDedupeKey(logMessage);
|
|
3230
|
-
if (dedupeKey) {
|
|
3231
|
-
sentMessageUuids.add(dedupeKey);
|
|
3232
|
-
}
|
|
3233
3167
|
if (logMessage.type === "user" && logMessage.message?.content) {
|
|
3234
3168
|
const content = Array.isArray(logMessage.message.content) ? logMessage.message.content : [];
|
|
3235
3169
|
for (let i = 0; i < content.length; i++) {
|
|
@@ -3256,14 +3190,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3256
3190
|
}
|
|
3257
3191
|
}
|
|
3258
3192
|
}
|
|
3259
|
-
if (logMessage.type === "user") {
|
|
3260
|
-
const content = logMessage.message?.content;
|
|
3261
|
-
const hasToolResult = Array.isArray(content) && content.some((c) => c.type === "tool_result");
|
|
3262
|
-
if (!hasToolResult) {
|
|
3263
|
-
types.logger.debug("[remote]: Skipping user text message (scanner will handle)");
|
|
3264
|
-
return;
|
|
3265
|
-
}
|
|
3266
|
-
}
|
|
3267
3193
|
if (logMessage.type === "assistant" && message.type === "assistant") {
|
|
3268
3194
|
const assistantMsg = message;
|
|
3269
3195
|
const toolCallIds = [];
|
|
@@ -3294,10 +3220,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3294
3220
|
if (c.type === "tool_use" && c.name === "Task" && c.input && typeof c.input.prompt === "string") {
|
|
3295
3221
|
const logMessage2 = sdkToLogConverter.convertSidechainUserMessage(c.id, c.input.prompt);
|
|
3296
3222
|
if (logMessage2) {
|
|
3297
|
-
const dedupeKey2 = getMessageDedupeKey(logMessage2);
|
|
3298
|
-
if (dedupeKey2) {
|
|
3299
|
-
sentMessageUuids.add(dedupeKey2);
|
|
3300
|
-
}
|
|
3301
3223
|
messageQueue.enqueue(logMessage2);
|
|
3302
3224
|
}
|
|
3303
3225
|
}
|
|
@@ -3377,7 +3299,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3377
3299
|
onSessionFound: (sessionId) => {
|
|
3378
3300
|
sdkToLogConverter.updateSessionId(sessionId);
|
|
3379
3301
|
session.onSessionFound(sessionId);
|
|
3380
|
-
sessionScanner.onNewSession(sessionId);
|
|
3381
3302
|
},
|
|
3382
3303
|
onThinkingChange: session.onThinkingChange,
|
|
3383
3304
|
claudeEnvVars: session.claudeEnvVars,
|
|
@@ -3473,7 +3394,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3473
3394
|
}
|
|
3474
3395
|
}
|
|
3475
3396
|
} finally {
|
|
3476
|
-
await sessionScanner.cleanup();
|
|
3477
3397
|
permissionHandler.reset();
|
|
3478
3398
|
process.stdin.off("data", abort);
|
|
3479
3399
|
if (process.stdin.isTTY) {
|
|
@@ -7128,7 +7048,7 @@ async function handleConnectVendor(vendor, displayName) {
|
|
|
7128
7048
|
return;
|
|
7129
7049
|
} else if (subcommand === "codex") {
|
|
7130
7050
|
try {
|
|
7131
|
-
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-
|
|
7051
|
+
const { runCodex } = await Promise.resolve().then(function () { return require('./runCodex-BXOAacnj.cjs'); });
|
|
7132
7052
|
let startedBy = void 0;
|
|
7133
7053
|
for (let i = 1; i < args.length; i++) {
|
|
7134
7054
|
if (args[i] === "--started-by") {
|
|
@@ -7173,7 +7093,7 @@ async function handleConnectVendor(vendor, displayName) {
|
|
|
7173
7093
|
} else if (subcommand === "list") {
|
|
7174
7094
|
try {
|
|
7175
7095
|
const { credentials } = await authAndSetupMachineIfNeeded();
|
|
7176
|
-
const { listSessions } = await Promise.resolve().then(function () { return require('./list-
|
|
7096
|
+
const { listSessions } = await Promise.resolve().then(function () { return require('./list-RgcDN0C0.cjs'); });
|
|
7177
7097
|
let sessionId;
|
|
7178
7098
|
let titleFilter;
|
|
7179
7099
|
let recentMsgs;
|
|
@@ -7275,7 +7195,7 @@ Examples:
|
|
|
7275
7195
|
process.exit(1);
|
|
7276
7196
|
}
|
|
7277
7197
|
const { credentials } = await authAndSetupMachineIfNeeded();
|
|
7278
|
-
const { promptSession } = await Promise.resolve().then(function () { return require('./prompt-
|
|
7198
|
+
const { promptSession } = await Promise.resolve().then(function () { return require('./prompt-Bb5xD1Xl.cjs'); });
|
|
7279
7199
|
await promptSession(credentials, sessionId, promptText, timeoutMinutes ?? void 0);
|
|
7280
7200
|
} catch (error) {
|
|
7281
7201
|
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import os$1, { homedir } from 'node:os';
|
|
3
3
|
import { randomUUID, randomBytes, createHmac } from 'node:crypto';
|
|
4
|
-
import { l as logger, p as projectPath, j as backoff, k as delay, R as RawJSONLinesSchema, m as AsyncLock, c as configuration, n as readDaemonState, o as clearDaemonState, i as packageJson, r as readSettings, q as readCredentials, g as encodeBase64, u as updateSettings, s as encodeBase64Url, d as decodeBase64, w as writeCredentialsLegacy, t as writeCredentialsDataKey, v as acquireDaemonLock, x as writeDaemonState, A as ApiClient, y as releaseDaemonLock, z as authChallenge, B as clearCredentials, C as clearMachineId, D as getLatestDaemonLog } from './types-
|
|
4
|
+
import { l as logger, p as projectPath, j as backoff, k as delay, R as RawJSONLinesSchema, m as AsyncLock, c as configuration, n as readDaemonState, o as clearDaemonState, i as packageJson, r as readSettings, q as readCredentials, g as encodeBase64, u as updateSettings, s as encodeBase64Url, d as decodeBase64, w as writeCredentialsLegacy, t as writeCredentialsDataKey, v as acquireDaemonLock, x as writeDaemonState, A as ApiClient, y as releaseDaemonLock, z as authChallenge, B as clearCredentials, C as clearMachineId, D as getLatestDaemonLog } from './types-CPYxEUyu.mjs';
|
|
5
5
|
import { spawn, execSync, exec as exec$1, execFileSync } from 'node:child_process';
|
|
6
6
|
import { resolve, join, extname, basename as basename$1 } from 'node:path';
|
|
7
7
|
import { createInterface } from 'node:readline';
|
|
@@ -10,7 +10,7 @@ import { exec, spawn as spawn$1, execSync as execSync$1 } from 'child_process';
|
|
|
10
10
|
import { promisify } from 'util';
|
|
11
11
|
import { existsSync as existsSync$1, readFileSync as readFileSync$1, writeFileSync as writeFileSync$1, chmodSync, unlinkSync as unlinkSync$1 } from 'fs';
|
|
12
12
|
import { join as join$1, dirname, basename } from 'path';
|
|
13
|
-
import {
|
|
13
|
+
import { readFile } from 'node:fs/promises';
|
|
14
14
|
import fs, { watch, access } from 'fs/promises';
|
|
15
15
|
import { useStdout, useInput, Box, Text, render } from 'ink';
|
|
16
16
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
@@ -28,7 +28,7 @@ import psList from 'ps-list';
|
|
|
28
28
|
import spawn$2 from 'cross-spawn';
|
|
29
29
|
import * as tmp from 'tmp';
|
|
30
30
|
import qrcode from 'qrcode-terminal';
|
|
31
|
-
import open
|
|
31
|
+
import open from 'open';
|
|
32
32
|
import fastify from 'fastify';
|
|
33
33
|
import { z } from 'zod';
|
|
34
34
|
import { validatorCompiler, serializerCompiler } from 'fastify-type-provider-zod';
|
|
@@ -625,11 +625,8 @@ async function createSessionScanner(opts) {
|
|
|
625
625
|
let currentSessionId = null;
|
|
626
626
|
let watchers = /* @__PURE__ */ new Map();
|
|
627
627
|
let processedMessageKeys = /* @__PURE__ */ new Set();
|
|
628
|
-
let sessionOffsets = /* @__PURE__ */ new Map();
|
|
629
|
-
let failedLineHashes = /* @__PURE__ */ new Set();
|
|
630
628
|
if (opts.sessionId) {
|
|
631
|
-
let
|
|
632
|
-
sessionOffsets.set(opts.sessionId, newOffset);
|
|
629
|
+
let messages = await readSessionLog(projectDir, opts.sessionId);
|
|
633
630
|
for (let m of messages) {
|
|
634
631
|
processedMessageKeys.add(messageKey(m));
|
|
635
632
|
}
|
|
@@ -643,16 +640,13 @@ async function createSessionScanner(opts) {
|
|
|
643
640
|
sessions.push(currentSessionId);
|
|
644
641
|
}
|
|
645
642
|
for (let session of sessions) {
|
|
646
|
-
let
|
|
647
|
-
|
|
648
|
-
sessionOffsets.set(session, newOffset);
|
|
649
|
-
for (let msg of messages) {
|
|
650
|
-
let key = messageKey(msg);
|
|
643
|
+
for (let file of await readSessionLog(projectDir, session)) {
|
|
644
|
+
let key = messageKey(file);
|
|
651
645
|
if (processedMessageKeys.has(key)) {
|
|
652
646
|
continue;
|
|
653
647
|
}
|
|
654
648
|
processedMessageKeys.add(key);
|
|
655
|
-
opts.onMessage(
|
|
649
|
+
opts.onMessage(file);
|
|
656
650
|
}
|
|
657
651
|
}
|
|
658
652
|
for (let p of sessions) {
|
|
@@ -718,60 +712,36 @@ function messageKey(message) {
|
|
|
718
712
|
throw Error();
|
|
719
713
|
}
|
|
720
714
|
}
|
|
721
|
-
async function
|
|
715
|
+
async function readSessionLog(projectDir, sessionId) {
|
|
722
716
|
const expectedSessionFile = join(projectDir, `${sessionId}.jsonl`);
|
|
723
|
-
|
|
717
|
+
logger.debug(`[SESSION_SCANNER] Reading session file: ${expectedSessionFile}`);
|
|
718
|
+
let file;
|
|
724
719
|
try {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
return
|
|
729
|
-
}
|
|
730
|
-
if (fileSize <= fromOffset) {
|
|
731
|
-
return { messages: [], newOffset: fromOffset };
|
|
732
|
-
}
|
|
733
|
-
let newContent;
|
|
734
|
-
try {
|
|
735
|
-
const fh = await open(expectedSessionFile, "r");
|
|
736
|
-
try {
|
|
737
|
-
const buf = Buffer.alloc(fileSize - fromOffset);
|
|
738
|
-
await fh.read(buf, 0, buf.length, fromOffset);
|
|
739
|
-
newContent = buf.toString("utf-8");
|
|
740
|
-
} finally {
|
|
741
|
-
await fh.close();
|
|
742
|
-
}
|
|
743
|
-
} catch {
|
|
744
|
-
return { messages: [], newOffset: fromOffset };
|
|
720
|
+
file = await readFile(expectedSessionFile, "utf-8");
|
|
721
|
+
} catch (error) {
|
|
722
|
+
logger.debug(`[SESSION_SCANNER] Session file not found: ${expectedSessionFile}`);
|
|
723
|
+
return [];
|
|
745
724
|
}
|
|
725
|
+
let lines = file.split("\n");
|
|
746
726
|
let messages = [];
|
|
747
|
-
let lines = newContent.split("\n");
|
|
748
727
|
for (let l of lines) {
|
|
749
|
-
let trimmed = l.trim();
|
|
750
|
-
if (trimmed === "") {
|
|
751
|
-
continue;
|
|
752
|
-
}
|
|
753
728
|
try {
|
|
754
|
-
|
|
729
|
+
if (l.trim() === "") {
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
let message = JSON.parse(l);
|
|
755
733
|
let parsed = RawJSONLinesSchema.safeParse(message);
|
|
756
734
|
if (!parsed.success) {
|
|
757
|
-
|
|
758
|
-
if (!failedLineHashes.has(lineHash)) {
|
|
759
|
-
failedLineHashes.add(lineHash);
|
|
760
|
-
logger.debugLargeJson(`[SESSION_SCANNER] Failed to parse message`, message);
|
|
761
|
-
}
|
|
735
|
+
logger.debugLargeJson(`[SESSION_SCANNER] Failed to parse message`, message);
|
|
762
736
|
continue;
|
|
763
737
|
}
|
|
764
738
|
messages.push(parsed.data);
|
|
765
739
|
} catch (e) {
|
|
766
|
-
|
|
767
|
-
if (!failedLineHashes.has(lineHash)) {
|
|
768
|
-
failedLineHashes.add(lineHash);
|
|
769
|
-
logger.debug(`[SESSION_SCANNER] Error processing message: ${e}`);
|
|
770
|
-
}
|
|
740
|
+
logger.debug(`[SESSION_SCANNER] Error processing message: ${e}`);
|
|
771
741
|
continue;
|
|
772
742
|
}
|
|
773
743
|
}
|
|
774
|
-
return
|
|
744
|
+
return messages;
|
|
775
745
|
}
|
|
776
746
|
|
|
777
747
|
async function claudeLocalLauncher(session) {
|
|
@@ -3143,38 +3113,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3143
3113
|
cwd: session.path,
|
|
3144
3114
|
version: process.env.npm_package_version
|
|
3145
3115
|
}, permissionHandler.getResponses());
|
|
3146
|
-
const sentMessageUuids = /* @__PURE__ */ new Set();
|
|
3147
|
-
function getMessageDedupeKey(msg) {
|
|
3148
|
-
if (msg.type === "summary") {
|
|
3149
|
-
return `summary:${msg.leafUuid}:${msg.summary}`;
|
|
3150
|
-
}
|
|
3151
|
-
if (msg.type === "system") {
|
|
3152
|
-
return `system:${msg.uuid}`;
|
|
3153
|
-
}
|
|
3154
|
-
try {
|
|
3155
|
-
const content = JSON.stringify(msg.message?.content ?? "");
|
|
3156
|
-
const contentKey = content.slice(0, 100) + ":" + content.length;
|
|
3157
|
-
return `${msg.type}:${contentKey}`;
|
|
3158
|
-
} catch {
|
|
3159
|
-
return msg.uuid ?? null;
|
|
3160
|
-
}
|
|
3161
|
-
}
|
|
3162
|
-
const sessionScanner = await createSessionScanner({
|
|
3163
|
-
sessionId: session.sessionId,
|
|
3164
|
-
workingDirectory: session.path,
|
|
3165
|
-
onMessage: (logMessage) => {
|
|
3166
|
-
const dedupeKey = getMessageDedupeKey(logMessage);
|
|
3167
|
-
if (dedupeKey && sentMessageUuids.has(dedupeKey)) {
|
|
3168
|
-
logger.debug(`[remote]: Scanner skipping (already sent): ${logMessage.type}`);
|
|
3169
|
-
return;
|
|
3170
|
-
}
|
|
3171
|
-
if (dedupeKey) {
|
|
3172
|
-
sentMessageUuids.add(dedupeKey);
|
|
3173
|
-
}
|
|
3174
|
-
logger.debug(`[remote]: Scanner forwarding message: ${logMessage.type}`);
|
|
3175
|
-
messageQueue.enqueue(logMessage);
|
|
3176
|
-
}
|
|
3177
|
-
});
|
|
3178
3116
|
let ongoingToolCalls = /* @__PURE__ */ new Map();
|
|
3179
3117
|
function onMessage(message) {
|
|
3180
3118
|
formatClaudeMessageForInk(message, messageBuffer);
|
|
@@ -3203,10 +3141,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3203
3141
|
}
|
|
3204
3142
|
const logMessage = sdkToLogConverter.convert(message);
|
|
3205
3143
|
if (logMessage) {
|
|
3206
|
-
const dedupeKey = getMessageDedupeKey(logMessage);
|
|
3207
|
-
if (dedupeKey) {
|
|
3208
|
-
sentMessageUuids.add(dedupeKey);
|
|
3209
|
-
}
|
|
3210
3144
|
if (logMessage.type === "user" && logMessage.message?.content) {
|
|
3211
3145
|
const content = Array.isArray(logMessage.message.content) ? logMessage.message.content : [];
|
|
3212
3146
|
for (let i = 0; i < content.length; i++) {
|
|
@@ -3233,14 +3167,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3233
3167
|
}
|
|
3234
3168
|
}
|
|
3235
3169
|
}
|
|
3236
|
-
if (logMessage.type === "user") {
|
|
3237
|
-
const content = logMessage.message?.content;
|
|
3238
|
-
const hasToolResult = Array.isArray(content) && content.some((c) => c.type === "tool_result");
|
|
3239
|
-
if (!hasToolResult) {
|
|
3240
|
-
logger.debug("[remote]: Skipping user text message (scanner will handle)");
|
|
3241
|
-
return;
|
|
3242
|
-
}
|
|
3243
|
-
}
|
|
3244
3170
|
if (logMessage.type === "assistant" && message.type === "assistant") {
|
|
3245
3171
|
const assistantMsg = message;
|
|
3246
3172
|
const toolCallIds = [];
|
|
@@ -3271,10 +3197,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3271
3197
|
if (c.type === "tool_use" && c.name === "Task" && c.input && typeof c.input.prompt === "string") {
|
|
3272
3198
|
const logMessage2 = sdkToLogConverter.convertSidechainUserMessage(c.id, c.input.prompt);
|
|
3273
3199
|
if (logMessage2) {
|
|
3274
|
-
const dedupeKey2 = getMessageDedupeKey(logMessage2);
|
|
3275
|
-
if (dedupeKey2) {
|
|
3276
|
-
sentMessageUuids.add(dedupeKey2);
|
|
3277
|
-
}
|
|
3278
3200
|
messageQueue.enqueue(logMessage2);
|
|
3279
3201
|
}
|
|
3280
3202
|
}
|
|
@@ -3354,7 +3276,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3354
3276
|
onSessionFound: (sessionId) => {
|
|
3355
3277
|
sdkToLogConverter.updateSessionId(sessionId);
|
|
3356
3278
|
session.onSessionFound(sessionId);
|
|
3357
|
-
sessionScanner.onNewSession(sessionId);
|
|
3358
3279
|
},
|
|
3359
3280
|
onThinkingChange: session.onThinkingChange,
|
|
3360
3281
|
claudeEnvVars: session.claudeEnvVars,
|
|
@@ -3450,7 +3371,6 @@ async function claudeRemoteLauncher(session) {
|
|
|
3450
3371
|
}
|
|
3451
3372
|
}
|
|
3452
3373
|
} finally {
|
|
3453
|
-
await sessionScanner.cleanup();
|
|
3454
3374
|
permissionHandler.reset();
|
|
3455
3375
|
process.stdin.off("data", abort);
|
|
3456
3376
|
if (process.stdin.isTTY) {
|
|
@@ -4616,7 +4536,7 @@ async function openBrowser(url) {
|
|
|
4616
4536
|
return false;
|
|
4617
4537
|
}
|
|
4618
4538
|
logger.debug(`[browser] Attempting to open URL: ${url}`);
|
|
4619
|
-
await open
|
|
4539
|
+
await open(url);
|
|
4620
4540
|
logger.debug("[browser] Browser opened successfully");
|
|
4621
4541
|
return true;
|
|
4622
4542
|
} catch (error) {
|
|
@@ -7105,7 +7025,7 @@ async function handleConnectVendor(vendor, displayName) {
|
|
|
7105
7025
|
return;
|
|
7106
7026
|
} else if (subcommand === "codex") {
|
|
7107
7027
|
try {
|
|
7108
|
-
const { runCodex } = await import('./runCodex-
|
|
7028
|
+
const { runCodex } = await import('./runCodex-CgW9cBS9.mjs');
|
|
7109
7029
|
let startedBy = void 0;
|
|
7110
7030
|
for (let i = 1; i < args.length; i++) {
|
|
7111
7031
|
if (args[i] === "--started-by") {
|
|
@@ -7150,7 +7070,7 @@ async function handleConnectVendor(vendor, displayName) {
|
|
|
7150
7070
|
} else if (subcommand === "list") {
|
|
7151
7071
|
try {
|
|
7152
7072
|
const { credentials } = await authAndSetupMachineIfNeeded();
|
|
7153
|
-
const { listSessions } = await import('./list-
|
|
7073
|
+
const { listSessions } = await import('./list-Lp972nwz.mjs');
|
|
7154
7074
|
let sessionId;
|
|
7155
7075
|
let titleFilter;
|
|
7156
7076
|
let recentMsgs;
|
|
@@ -7252,7 +7172,7 @@ Examples:
|
|
|
7252
7172
|
process.exit(1);
|
|
7253
7173
|
}
|
|
7254
7174
|
const { credentials } = await authAndSetupMachineIfNeeded();
|
|
7255
|
-
const { promptSession } = await import('./prompt-
|
|
7175
|
+
const { promptSession } = await import('./prompt-BPehYWlE.mjs');
|
|
7256
7176
|
await promptSession(credentials, sessionId, promptText, timeoutMinutes ?? void 0);
|
|
7257
7177
|
} catch (error) {
|
|
7258
7178
|
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
package/dist/lib.cjs
CHANGED
package/dist/lib.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-
|
|
1
|
+
export { A as ApiClient, a as ApiSessionClient, R as RawJSONLinesSchema, c as configuration, l as logger } from './types-CPYxEUyu.mjs';
|
|
2
2
|
import 'axios';
|
|
3
3
|
import 'chalk';
|
|
4
4
|
import 'fs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as configuration, l as logger, d as decodeBase64, b as decrypt, f as formatTimeAgo, e as libsodiumDecryptFromPublicKey } from './types-
|
|
1
|
+
import { c as configuration, l as logger, d as decodeBase64, b as decrypt, f as formatTimeAgo, e as libsodiumDecryptFromPublicKey } from './types-CPYxEUyu.mjs';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { existsSync, readdirSync, statSync, readFileSync } from 'fs';
|
|
4
4
|
import { join } from 'path';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as configuration, b as decrypt, d as decodeBase64, l as logger, g as encodeBase64, h as encrypt } from './types-
|
|
1
|
+
import { c as configuration, b as decrypt, d as decodeBase64, l as logger, g as encodeBase64, h as encrypt } from './types-CPYxEUyu.mjs';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { io } from 'socket.io-client';
|
|
4
4
|
import 'chalk';
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var ink = require('ink');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var types = require('./types-
|
|
5
|
+
var types = require('./types-DysMExRA.cjs');
|
|
6
6
|
var index_js = require('@modelcontextprotocol/sdk/client/index.js');
|
|
7
7
|
var stdio_js = require('@modelcontextprotocol/sdk/client/stdio.js');
|
|
8
8
|
var z = require('zod');
|
|
9
9
|
var types_js = require('@modelcontextprotocol/sdk/types.js');
|
|
10
10
|
var child_process = require('child_process');
|
|
11
11
|
var node_crypto = require('node:crypto');
|
|
12
|
-
var index = require('./index-
|
|
12
|
+
var index = require('./index-BpSLeHcW.cjs');
|
|
13
13
|
var os = require('node:os');
|
|
14
14
|
var node_path = require('node:path');
|
|
15
15
|
var fs = require('node:fs');
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useStdout, useInput, Box, Text, render } from 'ink';
|
|
2
2
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
|
-
import { l as logger, A as ApiClient, r as readSettings, p as projectPath, c as configuration, i as packageJson } from './types-
|
|
3
|
+
import { l as logger, A as ApiClient, r as readSettings, p as projectPath, c as configuration, i as packageJson } from './types-CPYxEUyu.mjs';
|
|
4
4
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
5
5
|
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { ElicitRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import { execSync } from 'child_process';
|
|
9
9
|
import { randomUUID } from 'node:crypto';
|
|
10
|
-
import { i as initialMachineMetadata, n as notifyDaemonSessionStarted, M as MessageQueue2, h as hashObject, r as registerKillSessionHandler, a as MessageBuffer, s as startHappyServer, t as trimIdent, b as stopCaffeinate } from './index-
|
|
10
|
+
import { i as initialMachineMetadata, n as notifyDaemonSessionStarted, M as MessageQueue2, h as hashObject, r as registerKillSessionHandler, a as MessageBuffer, s as startHappyServer, t as trimIdent, b as stopCaffeinate } from './index-GQ9EasMu.mjs';
|
|
11
11
|
import os from 'node:os';
|
|
12
12
|
import { resolve, join } from 'node:path';
|
|
13
13
|
import fs from 'node:fs';
|
|
@@ -20,7 +20,7 @@ import { fileURLToPath } from 'url';
|
|
|
20
20
|
import { Expo } from 'expo-server-sdk';
|
|
21
21
|
|
|
22
22
|
var name = "@zhigang1992/happy-cli";
|
|
23
|
-
var version = "0.13.
|
|
23
|
+
var version = "0.13.9";
|
|
24
24
|
var description = "Mobile and Web client for Claude Code and Codex";
|
|
25
25
|
var author = "Kirill Dubovitskiy";
|
|
26
26
|
var license = "MIT";
|
|
@@ -629,7 +629,7 @@ class Logger {
|
|
|
629
629
|
}
|
|
630
630
|
debugLargeJson(message, object, maxStringLength = 100, maxArrayLength = 10) {
|
|
631
631
|
if (!process.env.DEBUG) {
|
|
632
|
-
|
|
632
|
+
this.debug(`In production, skipping message inspection`);
|
|
633
633
|
}
|
|
634
634
|
const truncateStrings = (obj) => {
|
|
635
635
|
if (typeof obj === "string") {
|
|
@@ -41,7 +41,7 @@ function _interopNamespaceDefault(e) {
|
|
|
41
41
|
var z__namespace = /*#__PURE__*/_interopNamespaceDefault(z);
|
|
42
42
|
|
|
43
43
|
var name = "@zhigang1992/happy-cli";
|
|
44
|
-
var version = "0.13.
|
|
44
|
+
var version = "0.13.9";
|
|
45
45
|
var description = "Mobile and Web client for Claude Code and Codex";
|
|
46
46
|
var author = "Kirill Dubovitskiy";
|
|
47
47
|
var license = "MIT";
|
|
@@ -650,7 +650,7 @@ class Logger {
|
|
|
650
650
|
}
|
|
651
651
|
debugLargeJson(message, object, maxStringLength = 100, maxArrayLength = 10) {
|
|
652
652
|
if (!process.env.DEBUG) {
|
|
653
|
-
|
|
653
|
+
this.debug(`In production, skipping message inspection`);
|
|
654
654
|
}
|
|
655
655
|
const truncateStrings = (obj) => {
|
|
656
656
|
if (typeof obj === "string") {
|
|
@@ -1150,7 +1150,7 @@ class RpcHandlerManager {
|
|
|
1150
1150
|
}
|
|
1151
1151
|
}
|
|
1152
1152
|
|
|
1153
|
-
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('types-
|
|
1153
|
+
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('types-DysMExRA.cjs', document.baseURI).href))));
|
|
1154
1154
|
function projectPath() {
|
|
1155
1155
|
const path$1 = path.resolve(__dirname$1, "..");
|
|
1156
1156
|
return path$1;
|