claude-threads 1.9.1 → 1.9.3
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/CHANGELOG.md +15 -0
- package/dist/index.js +517 -440
- package/dist/mcp/permission-server.js +93 -50
- package/package.json +1 -1
|
@@ -50456,6 +50456,23 @@ class BaseExecutor {
|
|
|
50456
50456
|
}
|
|
50457
50457
|
}
|
|
50458
50458
|
// src/platform/utils.ts
|
|
50459
|
+
function formatWebSocketError(err) {
|
|
50460
|
+
if (err instanceof Error)
|
|
50461
|
+
return err.message;
|
|
50462
|
+
if (err && typeof err === "object") {
|
|
50463
|
+
const e = err;
|
|
50464
|
+
if (typeof e.message === "string" && e.message)
|
|
50465
|
+
return e.message;
|
|
50466
|
+
if (e.error instanceof Error)
|
|
50467
|
+
return e.error.message;
|
|
50468
|
+
if (typeof e.error === "string" && e.error)
|
|
50469
|
+
return e.error;
|
|
50470
|
+
if (typeof e.type === "string" && e.type) {
|
|
50471
|
+
return typeof e.code === "string" || typeof e.code === "number" ? `${e.type} (code: ${e.code})` : e.type;
|
|
50472
|
+
}
|
|
50473
|
+
}
|
|
50474
|
+
return String(err);
|
|
50475
|
+
}
|
|
50459
50476
|
function truncateMessageSafely(message, maxLength, truncationIndicator = "... (truncated)") {
|
|
50460
50477
|
if (message.length <= maxLength)
|
|
50461
50478
|
return message;
|
|
@@ -52885,6 +52902,32 @@ class MessageManager {
|
|
|
52885
52902
|
this.reset();
|
|
52886
52903
|
}
|
|
52887
52904
|
}
|
|
52905
|
+
// src/session/lifecycle-fsm.ts
|
|
52906
|
+
var log4 = createLogger("fsm");
|
|
52907
|
+
var ALLOWED_TRANSITIONS = {
|
|
52908
|
+
starting: new Set(["active", "paused", "interrupted", "cancelling", "restarting"]),
|
|
52909
|
+
active: new Set([
|
|
52910
|
+
"active",
|
|
52911
|
+
"processing",
|
|
52912
|
+
"paused",
|
|
52913
|
+
"interrupted",
|
|
52914
|
+
"restarting",
|
|
52915
|
+
"cancelling",
|
|
52916
|
+
"ending"
|
|
52917
|
+
]),
|
|
52918
|
+
processing: new Set([
|
|
52919
|
+
"active",
|
|
52920
|
+
"paused",
|
|
52921
|
+
"interrupted",
|
|
52922
|
+
"restarting",
|
|
52923
|
+
"cancelling"
|
|
52924
|
+
]),
|
|
52925
|
+
paused: new Set(["active", "cancelling", "restarting"]),
|
|
52926
|
+
interrupted: new Set(["active", "cancelling", "restarting", "paused"]),
|
|
52927
|
+
restarting: new Set(["active", "paused", "cancelling"]),
|
|
52928
|
+
cancelling: new Set(["ending"]),
|
|
52929
|
+
ending: new Set
|
|
52930
|
+
};
|
|
52888
52931
|
// src/config/index.ts
|
|
52889
52932
|
import { resolve as resolve2, dirname as dirname2 } from "path";
|
|
52890
52933
|
import { homedir } from "os";
|
|
@@ -55642,7 +55685,7 @@ function formatReleaseNotes(notes, formatter) {
|
|
|
55642
55685
|
|
|
55643
55686
|
// src/utils/keep-alive.ts
|
|
55644
55687
|
import { spawn } from "child_process";
|
|
55645
|
-
var
|
|
55688
|
+
var log5 = createLogger("keepalive");
|
|
55646
55689
|
|
|
55647
55690
|
class KeepAliveManager {
|
|
55648
55691
|
activeSessionCount = 0;
|
|
@@ -55657,7 +55700,7 @@ class KeepAliveManager {
|
|
|
55657
55700
|
if (!enabled && this.keepAliveProcess) {
|
|
55658
55701
|
this.stopKeepAlive();
|
|
55659
55702
|
}
|
|
55660
|
-
|
|
55703
|
+
log5.debug(`Keep-alive ${enabled ? "enabled" : "disabled"}`);
|
|
55661
55704
|
}
|
|
55662
55705
|
isEnabled() {
|
|
55663
55706
|
return this.enabled;
|
|
@@ -55667,7 +55710,7 @@ class KeepAliveManager {
|
|
|
55667
55710
|
}
|
|
55668
55711
|
sessionStarted() {
|
|
55669
55712
|
this.activeSessionCount++;
|
|
55670
|
-
|
|
55713
|
+
log5.debug(`Session started (${this.activeSessionCount} active)`);
|
|
55671
55714
|
if (this.activeSessionCount === 1) {
|
|
55672
55715
|
this.startKeepAlive();
|
|
55673
55716
|
}
|
|
@@ -55676,7 +55719,7 @@ class KeepAliveManager {
|
|
|
55676
55719
|
if (this.activeSessionCount > 0) {
|
|
55677
55720
|
this.activeSessionCount--;
|
|
55678
55721
|
}
|
|
55679
|
-
|
|
55722
|
+
log5.debug(`Session ended (${this.activeSessionCount} active)`);
|
|
55680
55723
|
if (this.activeSessionCount === 0) {
|
|
55681
55724
|
this.stopKeepAlive();
|
|
55682
55725
|
}
|
|
@@ -55690,11 +55733,11 @@ class KeepAliveManager {
|
|
|
55690
55733
|
}
|
|
55691
55734
|
startKeepAlive() {
|
|
55692
55735
|
if (!this.enabled) {
|
|
55693
|
-
|
|
55736
|
+
log5.debug("Keep-alive disabled, skipping");
|
|
55694
55737
|
return;
|
|
55695
55738
|
}
|
|
55696
55739
|
if (this.keepAliveProcess) {
|
|
55697
|
-
|
|
55740
|
+
log5.debug("Keep-alive already running");
|
|
55698
55741
|
return;
|
|
55699
55742
|
}
|
|
55700
55743
|
switch (this.platform) {
|
|
@@ -55708,12 +55751,12 @@ class KeepAliveManager {
|
|
|
55708
55751
|
this.startWindowsKeepAlive();
|
|
55709
55752
|
break;
|
|
55710
55753
|
default:
|
|
55711
|
-
|
|
55754
|
+
log5.warn(`Keep-alive not supported on ${this.platform}`);
|
|
55712
55755
|
}
|
|
55713
55756
|
}
|
|
55714
55757
|
stopKeepAlive() {
|
|
55715
55758
|
if (this.keepAliveProcess) {
|
|
55716
|
-
|
|
55759
|
+
log5.debug("Stopping keep-alive");
|
|
55717
55760
|
this.keepAliveProcess.kill();
|
|
55718
55761
|
this.keepAliveProcess = null;
|
|
55719
55762
|
}
|
|
@@ -55725,18 +55768,18 @@ class KeepAliveManager {
|
|
|
55725
55768
|
detached: false
|
|
55726
55769
|
});
|
|
55727
55770
|
this.keepAliveProcess.on("error", (err) => {
|
|
55728
|
-
|
|
55771
|
+
log5.error(`Failed to start caffeinate: ${err.message}`);
|
|
55729
55772
|
this.keepAliveProcess = null;
|
|
55730
55773
|
});
|
|
55731
55774
|
this.keepAliveProcess.on("exit", (code) => {
|
|
55732
55775
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
55733
|
-
|
|
55776
|
+
log5.debug(`caffeinate exited with code ${code}`);
|
|
55734
55777
|
}
|
|
55735
55778
|
this.keepAliveProcess = null;
|
|
55736
55779
|
});
|
|
55737
|
-
|
|
55780
|
+
log5.info("Sleep prevention active (caffeinate)");
|
|
55738
55781
|
} catch (err) {
|
|
55739
|
-
|
|
55782
|
+
log5.error(`Failed to start caffeinate: ${err}`);
|
|
55740
55783
|
}
|
|
55741
55784
|
}
|
|
55742
55785
|
startLinuxKeepAlive() {
|
|
@@ -55752,19 +55795,19 @@ class KeepAliveManager {
|
|
|
55752
55795
|
detached: false
|
|
55753
55796
|
});
|
|
55754
55797
|
this.keepAliveProcess.on("error", (err) => {
|
|
55755
|
-
|
|
55798
|
+
log5.debug(`systemd-inhibit not available: ${err.message}`);
|
|
55756
55799
|
this.keepAliveProcess = null;
|
|
55757
55800
|
this.startLinuxKeepAliveFallback();
|
|
55758
55801
|
});
|
|
55759
55802
|
this.keepAliveProcess.on("exit", (code) => {
|
|
55760
55803
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
55761
|
-
|
|
55804
|
+
log5.debug(`systemd-inhibit exited with code ${code}`);
|
|
55762
55805
|
}
|
|
55763
55806
|
this.keepAliveProcess = null;
|
|
55764
55807
|
});
|
|
55765
|
-
|
|
55808
|
+
log5.info("Sleep prevention active (systemd-inhibit)");
|
|
55766
55809
|
} catch (err) {
|
|
55767
|
-
|
|
55810
|
+
log5.debug(`Failed to start systemd-inhibit: ${err}`);
|
|
55768
55811
|
this.startLinuxKeepAliveFallback();
|
|
55769
55812
|
}
|
|
55770
55813
|
}
|
|
@@ -55778,15 +55821,15 @@ class KeepAliveManager {
|
|
|
55778
55821
|
detached: false
|
|
55779
55822
|
});
|
|
55780
55823
|
this.keepAliveProcess.on("error", (err) => {
|
|
55781
|
-
|
|
55824
|
+
log5.warn(`Linux keep-alive fallback not available: ${err.message}`);
|
|
55782
55825
|
this.keepAliveProcess = null;
|
|
55783
55826
|
});
|
|
55784
55827
|
this.keepAliveProcess.on("exit", () => {
|
|
55785
55828
|
this.keepAliveProcess = null;
|
|
55786
55829
|
});
|
|
55787
|
-
|
|
55830
|
+
log5.info("Sleep prevention active (xdg-screensaver)");
|
|
55788
55831
|
} catch (err) {
|
|
55789
|
-
|
|
55832
|
+
log5.warn(`Linux keep-alive not available: ${err}`);
|
|
55790
55833
|
}
|
|
55791
55834
|
}
|
|
55792
55835
|
startWindowsKeepAlive() {
|
|
@@ -55811,25 +55854,25 @@ class KeepAliveManager {
|
|
|
55811
55854
|
windowsHide: true
|
|
55812
55855
|
});
|
|
55813
55856
|
this.keepAliveProcess.on("error", (err) => {
|
|
55814
|
-
|
|
55857
|
+
log5.warn(`Windows keep-alive not available: ${err.message}`);
|
|
55815
55858
|
this.keepAliveProcess = null;
|
|
55816
55859
|
});
|
|
55817
55860
|
this.keepAliveProcess.on("exit", (code) => {
|
|
55818
55861
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
55819
|
-
|
|
55862
|
+
log5.debug(`PowerShell keep-alive exited with code ${code}`);
|
|
55820
55863
|
}
|
|
55821
55864
|
this.keepAliveProcess = null;
|
|
55822
55865
|
});
|
|
55823
|
-
|
|
55866
|
+
log5.info("Sleep prevention active (SetThreadExecutionState)");
|
|
55824
55867
|
} catch (err) {
|
|
55825
|
-
|
|
55868
|
+
log5.warn(`Windows keep-alive not available: ${err}`);
|
|
55826
55869
|
}
|
|
55827
55870
|
}
|
|
55828
55871
|
}
|
|
55829
55872
|
var keepAlive = new KeepAliveManager;
|
|
55830
55873
|
|
|
55831
55874
|
// src/operations/sticky-message/handler.ts
|
|
55832
|
-
var
|
|
55875
|
+
var log6 = createLogger("sticky");
|
|
55833
55876
|
var botStartedAt = new Date;
|
|
55834
55877
|
var stickyPostIds = new Map;
|
|
55835
55878
|
var needsBump = new Map;
|
|
@@ -56069,7 +56112,7 @@ class Redactor {
|
|
|
56069
56112
|
// src/persistence/thread-logger.ts
|
|
56070
56113
|
import { homedir as homedir2 } from "os";
|
|
56071
56114
|
import { join as join2, dirname as dirname4 } from "path";
|
|
56072
|
-
var
|
|
56115
|
+
var log7 = createLogger("thread-log");
|
|
56073
56116
|
var LOGS_BASE_DIR = join2(homedir2(), ".claude-threads", "logs");
|
|
56074
56117
|
|
|
56075
56118
|
// src/operations/bug-report/handler.ts
|
|
@@ -56173,7 +56216,7 @@ function extractResetAt(text, now) {
|
|
|
56173
56216
|
}
|
|
56174
56217
|
|
|
56175
56218
|
// src/claude/cli.ts
|
|
56176
|
-
var
|
|
56219
|
+
var log8 = createLogger("claude");
|
|
56177
56220
|
function cleanupBrowserBridgeSockets() {
|
|
56178
56221
|
try {
|
|
56179
56222
|
const tempDir = tmpdir();
|
|
@@ -56185,13 +56228,13 @@ function cleanupBrowserBridgeSockets() {
|
|
|
56185
56228
|
const stats = statSync(filePath);
|
|
56186
56229
|
if (stats.isSocket()) {
|
|
56187
56230
|
unlinkSync(filePath);
|
|
56188
|
-
|
|
56231
|
+
log8.debug(`Removed stale browser bridge socket: ${file2}`);
|
|
56189
56232
|
}
|
|
56190
56233
|
} catch {}
|
|
56191
56234
|
}
|
|
56192
56235
|
}
|
|
56193
56236
|
} catch (err) {
|
|
56194
|
-
|
|
56237
|
+
log8.debug(`Browser bridge cleanup failed: ${err}`);
|
|
56195
56238
|
}
|
|
56196
56239
|
}
|
|
56197
56240
|
function buildClaudeChildEnv(parentEnv, account) {
|
|
@@ -56222,7 +56265,7 @@ function isErrorResultEvent(event) {
|
|
|
56222
56265
|
return false;
|
|
56223
56266
|
}
|
|
56224
56267
|
function materializeMcpConfig(config3, sessionId, opts = {}) {
|
|
56225
|
-
if (opts.inline
|
|
56268
|
+
if (opts.inline) {
|
|
56226
56269
|
return { mode: "inline", value: JSON.stringify(config3) };
|
|
56227
56270
|
}
|
|
56228
56271
|
const dir = opts.tmpDirOverride ?? tmpdir();
|
|
@@ -57164,7 +57207,7 @@ ${avoidCommands.map((c) => `- \`!${c.command}\` - ${c.reason}`).join(`
|
|
|
57164
57207
|
`.trim();
|
|
57165
57208
|
}
|
|
57166
57209
|
// src/utils/error-handler/index.ts
|
|
57167
|
-
var
|
|
57210
|
+
var log9 = createLogger("error");
|
|
57168
57211
|
|
|
57169
57212
|
// src/utils/session-log.ts
|
|
57170
57213
|
function createSessionLog(baseLog) {
|
|
@@ -57182,32 +57225,32 @@ init_emoji();
|
|
|
57182
57225
|
// src/git/worktree.ts
|
|
57183
57226
|
import * as path from "path";
|
|
57184
57227
|
import { homedir as homedir3 } from "os";
|
|
57185
|
-
var
|
|
57228
|
+
var log10 = createLogger("git-wt");
|
|
57186
57229
|
var WORKTREES_DIR = path.join(homedir3(), ".claude-threads", "worktrees");
|
|
57187
57230
|
var METADATA_STORE_PATH = path.join(homedir3(), ".claude-threads", "worktree-metadata.json");
|
|
57188
57231
|
|
|
57189
57232
|
// src/operations/post-helpers/index.ts
|
|
57190
|
-
var
|
|
57191
|
-
var sessionLog = createSessionLog(
|
|
57233
|
+
var log11 = createLogger("helpers");
|
|
57234
|
+
var sessionLog = createSessionLog(log11);
|
|
57192
57235
|
|
|
57193
57236
|
// src/claude/quick-query.ts
|
|
57194
|
-
var
|
|
57237
|
+
var log12 = createLogger("query");
|
|
57195
57238
|
|
|
57196
57239
|
// src/operations/suggestions/title.ts
|
|
57197
|
-
var
|
|
57240
|
+
var log13 = createLogger("title");
|
|
57198
57241
|
|
|
57199
57242
|
// src/operations/suggestions/tag.ts
|
|
57200
|
-
var
|
|
57243
|
+
var log14 = createLogger("tags");
|
|
57201
57244
|
|
|
57202
57245
|
// src/operations/context-prompt/handler.ts
|
|
57203
57246
|
init_emoji();
|
|
57204
|
-
var
|
|
57205
|
-
var sessionLog2 = createSessionLog(
|
|
57247
|
+
var log15 = createLogger("context");
|
|
57248
|
+
var sessionLog2 = createSessionLog(log15);
|
|
57206
57249
|
var contextPromptTimeouts = new Map;
|
|
57207
57250
|
var contextPromptFiles = new Map;
|
|
57208
57251
|
// src/session/lifecycle.ts
|
|
57209
|
-
var
|
|
57210
|
-
var sessionLog3 = createSessionLog(
|
|
57252
|
+
var log16 = createLogger("lifecycle");
|
|
57253
|
+
var sessionLog3 = createSessionLog(log16);
|
|
57211
57254
|
var CHAT_PLATFORM_PROMPT = generateChatPlatformPrompt();
|
|
57212
57255
|
|
|
57213
57256
|
// src/update-notifier.ts
|
|
@@ -57215,22 +57258,22 @@ var import_semver2 = __toESM(require_semver2(), 1);
|
|
|
57215
57258
|
|
|
57216
57259
|
// src/operations/commands/handler.ts
|
|
57217
57260
|
init_emoji();
|
|
57218
|
-
var
|
|
57219
|
-
var sessionLog4 = createSessionLog(
|
|
57261
|
+
var log17 = createLogger("commands");
|
|
57262
|
+
var sessionLog4 = createSessionLog(log17);
|
|
57220
57263
|
// src/operations/suggestions/branch.ts
|
|
57221
57264
|
import { exec as exec2 } from "child_process";
|
|
57222
57265
|
import { promisify as promisify2 } from "util";
|
|
57223
57266
|
var execAsync2 = promisify2(exec2);
|
|
57224
|
-
var
|
|
57267
|
+
var log18 = createLogger("branch");
|
|
57225
57268
|
|
|
57226
57269
|
// src/operations/worktree/handler.ts
|
|
57227
|
-
var
|
|
57228
|
-
var sessionLog5 = createSessionLog(
|
|
57270
|
+
var log19 = createLogger("worktree");
|
|
57271
|
+
var sessionLog5 = createSessionLog(log19);
|
|
57229
57272
|
// src/operations/events/handler.ts
|
|
57230
|
-
var
|
|
57231
|
-
var sessionLog6 = createSessionLog(
|
|
57273
|
+
var log20 = createLogger("events");
|
|
57274
|
+
var sessionLog6 = createSessionLog(log20);
|
|
57232
57275
|
// src/operations/monitor/handler.ts
|
|
57233
|
-
var
|
|
57276
|
+
var log21 = createLogger("monitor");
|
|
57234
57277
|
var DEFAULT_INTERVAL_MS = 60 * 1000;
|
|
57235
57278
|
// src/utils/websocket.ts
|
|
57236
57279
|
var WS;
|
|
@@ -57487,7 +57530,7 @@ class MattermostPermissionApi {
|
|
|
57487
57530
|
}
|
|
57488
57531
|
};
|
|
57489
57532
|
ws.onerror = (event) => {
|
|
57490
|
-
mcpLogger.error(`WebSocket error: ${event}`);
|
|
57533
|
+
mcpLogger.error(`WebSocket error: ${formatWebSocketError(event)}`);
|
|
57491
57534
|
if (!resolved) {
|
|
57492
57535
|
resolved = true;
|
|
57493
57536
|
clearTimeout(timeout);
|
|
@@ -57754,7 +57797,7 @@ class SlackPermissionApi {
|
|
|
57754
57797
|
}
|
|
57755
57798
|
};
|
|
57756
57799
|
ws.onerror = (event) => {
|
|
57757
|
-
mcpLogger.error(`Socket Mode WebSocket error: ${event}`);
|
|
57800
|
+
mcpLogger.error(`Socket Mode WebSocket error: ${formatWebSocketError(event)}`);
|
|
57758
57801
|
if (!resolved) {
|
|
57759
57802
|
resolved = true;
|
|
57760
57803
|
clearTimeout(timeout);
|