claude-threads 1.33.0 → 1.33.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/CHANGELOG.md +7 -0
- package/dist/index.js +811 -755
- package/dist/mcp/mcp-server.js +165 -144
- package/docs/CONFIGURATION.md +8 -0
- package/package.json +1 -1
package/dist/mcp/mcp-server.js
CHANGED
|
@@ -14699,12 +14699,12 @@ var init_spawn = __esm(() => {
|
|
|
14699
14699
|
});
|
|
14700
14700
|
|
|
14701
14701
|
// src/claude/quick-query.ts
|
|
14702
|
-
var
|
|
14702
|
+
var log15;
|
|
14703
14703
|
var init_quick_query = __esm(() => {
|
|
14704
14704
|
init_spawn();
|
|
14705
14705
|
init_version_check();
|
|
14706
14706
|
init_logger();
|
|
14707
|
-
|
|
14707
|
+
log15 = createLogger("query");
|
|
14708
14708
|
});
|
|
14709
14709
|
|
|
14710
14710
|
// node_modules/ws/lib/constants.js
|
|
@@ -52902,9 +52902,54 @@ var ALLOWED_TRANSITIONS = {
|
|
|
52902
52902
|
cancelling: new Set(["ending"]),
|
|
52903
52903
|
ending: new Set
|
|
52904
52904
|
};
|
|
52905
|
+
// src/persistence/atomic-file.ts
|
|
52906
|
+
import { chmodSync as chmodSync2, renameSync, writeFileSync } from "fs";
|
|
52907
|
+
|
|
52908
|
+
class SerialQueue {
|
|
52909
|
+
tail = Promise.resolve();
|
|
52910
|
+
run(fn) {
|
|
52911
|
+
const next = this.tail.then(fn, fn);
|
|
52912
|
+
this.tail = next.catch(() => {
|
|
52913
|
+
return;
|
|
52914
|
+
});
|
|
52915
|
+
return next;
|
|
52916
|
+
}
|
|
52917
|
+
}
|
|
52918
|
+
function writeFileAtomic(file2, content) {
|
|
52919
|
+
const tempFile = `${file2}.tmp`;
|
|
52920
|
+
writeFileSync(tempFile, content, { encoding: "utf-8", mode: 384 });
|
|
52921
|
+
renameSync(tempFile, file2);
|
|
52922
|
+
chmodSync2(file2, 384);
|
|
52923
|
+
}
|
|
52924
|
+
|
|
52925
|
+
// src/persistence/session-store.ts
|
|
52926
|
+
init_logger();
|
|
52927
|
+
import { homedir as homedir2 } from "os";
|
|
52928
|
+
import { join as join3 } from "path";
|
|
52929
|
+
|
|
52930
|
+
// src/sponsor.ts
|
|
52931
|
+
var SPONSOR_URL = "https://github.com/sponsors/axolotl-systems";
|
|
52932
|
+
var MILESTONE_VISIBLE_MS = 24 * 60 * 60 * 1000;
|
|
52933
|
+
function formatSponsorFooter(formatter) {
|
|
52934
|
+
return formatter.formatItalic(`♥ Support claude-threads: ${formatter.formatLink("github.com/sponsors/axolotl-systems", SPONSOR_URL)}`);
|
|
52935
|
+
}
|
|
52936
|
+
|
|
52937
|
+
// src/persistence/session-store.ts
|
|
52938
|
+
var log6 = createLogger("persist");
|
|
52939
|
+
function resolveEndReason(session) {
|
|
52940
|
+
if (!session.cleanedAt)
|
|
52941
|
+
return;
|
|
52942
|
+
return session.endReason ?? "stopped";
|
|
52943
|
+
}
|
|
52944
|
+
function isRevivable(session) {
|
|
52945
|
+
return resolveEndReason(session) !== "stopped";
|
|
52946
|
+
}
|
|
52947
|
+
var DEFAULT_CONFIG_DIR = join3(homedir2(), ".config", "claude-threads");
|
|
52948
|
+
var DEFAULT_SESSIONS_FILE = join3(DEFAULT_CONFIG_DIR, "sessions.json");
|
|
52949
|
+
|
|
52905
52950
|
// src/config/index.ts
|
|
52906
52951
|
import { resolve as resolve2, dirname as dirname2 } from "path";
|
|
52907
|
-
import { homedir as
|
|
52952
|
+
import { homedir as homedir3 } from "os";
|
|
52908
52953
|
|
|
52909
52954
|
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
52910
52955
|
function getDefaultExportFromCjs(x) {
|
|
@@ -56016,7 +56061,7 @@ var jsYamlExports = requireJsYaml();
|
|
|
56016
56061
|
var yaml = /* @__PURE__ */ getDefaultExportFromCjs(jsYamlExports);
|
|
56017
56062
|
|
|
56018
56063
|
// src/config/index.ts
|
|
56019
|
-
var CONFIG_PATH = resolve2(
|
|
56064
|
+
var CONFIG_PATH = resolve2(homedir3(), ".config", "claude-threads", "config.yaml");
|
|
56020
56065
|
|
|
56021
56066
|
// src/utils/battery.ts
|
|
56022
56067
|
import { exec } from "child_process";
|
|
@@ -56125,7 +56170,7 @@ init_logger();
|
|
|
56125
56170
|
// src/utils/keep-alive.ts
|
|
56126
56171
|
init_logger();
|
|
56127
56172
|
import { spawn } from "child_process";
|
|
56128
|
-
var
|
|
56173
|
+
var log7 = createLogger("keepalive");
|
|
56129
56174
|
function keepAliveSpawnSpec(platform, parentPid) {
|
|
56130
56175
|
switch (platform) {
|
|
56131
56176
|
case "darwin":
|
|
@@ -56181,7 +56226,7 @@ class KeepAliveManager {
|
|
|
56181
56226
|
if (!enabled && this.keepAliveProcess) {
|
|
56182
56227
|
this.stopKeepAlive();
|
|
56183
56228
|
}
|
|
56184
|
-
|
|
56229
|
+
log7.debug(`Keep-alive ${enabled ? "enabled" : "disabled"}`);
|
|
56185
56230
|
}
|
|
56186
56231
|
isEnabled() {
|
|
56187
56232
|
return this.enabled;
|
|
@@ -56191,7 +56236,7 @@ class KeepAliveManager {
|
|
|
56191
56236
|
}
|
|
56192
56237
|
sessionStarted() {
|
|
56193
56238
|
this.activeSessionCount++;
|
|
56194
|
-
|
|
56239
|
+
log7.debug(`Session started (${this.activeSessionCount} active)`);
|
|
56195
56240
|
if (this.activeSessionCount === 1) {
|
|
56196
56241
|
this.startKeepAlive();
|
|
56197
56242
|
}
|
|
@@ -56200,7 +56245,7 @@ class KeepAliveManager {
|
|
|
56200
56245
|
if (this.activeSessionCount > 0) {
|
|
56201
56246
|
this.activeSessionCount--;
|
|
56202
56247
|
}
|
|
56203
|
-
|
|
56248
|
+
log7.debug(`Session ended (${this.activeSessionCount} active)`);
|
|
56204
56249
|
if (this.activeSessionCount === 0) {
|
|
56205
56250
|
this.stopKeepAlive();
|
|
56206
56251
|
}
|
|
@@ -56214,11 +56259,11 @@ class KeepAliveManager {
|
|
|
56214
56259
|
}
|
|
56215
56260
|
startKeepAlive() {
|
|
56216
56261
|
if (!this.enabled) {
|
|
56217
|
-
|
|
56262
|
+
log7.debug("Keep-alive disabled, skipping");
|
|
56218
56263
|
return;
|
|
56219
56264
|
}
|
|
56220
56265
|
if (this.keepAliveProcess) {
|
|
56221
|
-
|
|
56266
|
+
log7.debug("Keep-alive already running");
|
|
56222
56267
|
return;
|
|
56223
56268
|
}
|
|
56224
56269
|
switch (this.platform) {
|
|
@@ -56232,12 +56277,12 @@ class KeepAliveManager {
|
|
|
56232
56277
|
this.startWindowsKeepAlive();
|
|
56233
56278
|
break;
|
|
56234
56279
|
default:
|
|
56235
|
-
|
|
56280
|
+
log7.warn(`Keep-alive not supported on ${this.platform}`);
|
|
56236
56281
|
}
|
|
56237
56282
|
}
|
|
56238
56283
|
stopKeepAlive() {
|
|
56239
56284
|
if (this.keepAliveProcess) {
|
|
56240
|
-
|
|
56285
|
+
log7.debug("Stopping keep-alive");
|
|
56241
56286
|
this.keepAliveProcess.kill();
|
|
56242
56287
|
this.keepAliveProcess = null;
|
|
56243
56288
|
}
|
|
@@ -56252,18 +56297,18 @@ class KeepAliveManager {
|
|
|
56252
56297
|
detached: false
|
|
56253
56298
|
});
|
|
56254
56299
|
this.keepAliveProcess.on("error", (err) => {
|
|
56255
|
-
|
|
56300
|
+
log7.error(`Failed to start caffeinate: ${err.message}`);
|
|
56256
56301
|
this.keepAliveProcess = null;
|
|
56257
56302
|
});
|
|
56258
56303
|
this.keepAliveProcess.on("exit", (code) => {
|
|
56259
56304
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
56260
|
-
|
|
56305
|
+
log7.debug(`caffeinate exited with code ${code}`);
|
|
56261
56306
|
}
|
|
56262
56307
|
this.keepAliveProcess = null;
|
|
56263
56308
|
});
|
|
56264
|
-
|
|
56309
|
+
log7.info("Sleep prevention active (caffeinate)");
|
|
56265
56310
|
} catch (err) {
|
|
56266
|
-
|
|
56311
|
+
log7.error(`Failed to start caffeinate: ${err}`);
|
|
56267
56312
|
}
|
|
56268
56313
|
}
|
|
56269
56314
|
startLinuxKeepAlive() {
|
|
@@ -56276,19 +56321,19 @@ class KeepAliveManager {
|
|
|
56276
56321
|
detached: false
|
|
56277
56322
|
});
|
|
56278
56323
|
this.keepAliveProcess.on("error", (err) => {
|
|
56279
|
-
|
|
56324
|
+
log7.debug(`systemd-inhibit not available: ${err.message}`);
|
|
56280
56325
|
this.keepAliveProcess = null;
|
|
56281
56326
|
this.startLinuxKeepAliveFallback();
|
|
56282
56327
|
});
|
|
56283
56328
|
this.keepAliveProcess.on("exit", (code) => {
|
|
56284
56329
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
56285
|
-
|
|
56330
|
+
log7.debug(`systemd-inhibit exited with code ${code}`);
|
|
56286
56331
|
}
|
|
56287
56332
|
this.keepAliveProcess = null;
|
|
56288
56333
|
});
|
|
56289
|
-
|
|
56334
|
+
log7.info("Sleep prevention active (systemd-inhibit)");
|
|
56290
56335
|
} catch (err) {
|
|
56291
|
-
|
|
56336
|
+
log7.debug(`Failed to start systemd-inhibit: ${err}`);
|
|
56292
56337
|
this.startLinuxKeepAliveFallback();
|
|
56293
56338
|
}
|
|
56294
56339
|
}
|
|
@@ -56299,15 +56344,15 @@ class KeepAliveManager {
|
|
|
56299
56344
|
detached: false
|
|
56300
56345
|
});
|
|
56301
56346
|
this.keepAliveProcess.on("error", (err) => {
|
|
56302
|
-
|
|
56347
|
+
log7.warn(`Linux keep-alive fallback not available: ${err.message}`);
|
|
56303
56348
|
this.keepAliveProcess = null;
|
|
56304
56349
|
});
|
|
56305
56350
|
this.keepAliveProcess.on("exit", () => {
|
|
56306
56351
|
this.keepAliveProcess = null;
|
|
56307
56352
|
});
|
|
56308
|
-
|
|
56353
|
+
log7.info("Sleep prevention active (xdg-screensaver)");
|
|
56309
56354
|
} catch (err) {
|
|
56310
|
-
|
|
56355
|
+
log7.warn(`Linux keep-alive not available: ${err}`);
|
|
56311
56356
|
}
|
|
56312
56357
|
}
|
|
56313
56358
|
startWindowsKeepAlive() {
|
|
@@ -56319,32 +56364,25 @@ class KeepAliveManager {
|
|
|
56319
56364
|
windowsHide: true
|
|
56320
56365
|
});
|
|
56321
56366
|
this.keepAliveProcess.on("error", (err) => {
|
|
56322
|
-
|
|
56367
|
+
log7.warn(`Windows keep-alive not available: ${err.message}`);
|
|
56323
56368
|
this.keepAliveProcess = null;
|
|
56324
56369
|
});
|
|
56325
56370
|
this.keepAliveProcess.on("exit", (code) => {
|
|
56326
56371
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
56327
|
-
|
|
56372
|
+
log7.debug(`PowerShell keep-alive exited with code ${code}`);
|
|
56328
56373
|
}
|
|
56329
56374
|
this.keepAliveProcess = null;
|
|
56330
56375
|
});
|
|
56331
|
-
|
|
56376
|
+
log7.info("Sleep prevention active (SetThreadExecutionState)");
|
|
56332
56377
|
} catch (err) {
|
|
56333
|
-
|
|
56378
|
+
log7.warn(`Windows keep-alive not available: ${err}`);
|
|
56334
56379
|
}
|
|
56335
56380
|
}
|
|
56336
56381
|
}
|
|
56337
56382
|
var keepAlive = new KeepAliveManager;
|
|
56338
56383
|
|
|
56339
|
-
// src/sponsor.ts
|
|
56340
|
-
var SPONSOR_URL = "https://github.com/sponsors/axolotl-systems";
|
|
56341
|
-
var MILESTONE_VISIBLE_MS = 24 * 60 * 60 * 1000;
|
|
56342
|
-
function formatSponsorFooter(formatter) {
|
|
56343
|
-
return formatter.formatItalic(`♥ Support claude-threads: ${formatter.formatLink("github.com/sponsors/axolotl-systems", SPONSOR_URL)}`);
|
|
56344
|
-
}
|
|
56345
|
-
|
|
56346
56384
|
// src/operations/sticky-message/handler.ts
|
|
56347
|
-
var
|
|
56385
|
+
var log8 = createLogger("sticky");
|
|
56348
56386
|
var botStartedAt = new Date;
|
|
56349
56387
|
var stickyPostIds = new Map;
|
|
56350
56388
|
var needsBump = new Map;
|
|
@@ -56587,10 +56625,10 @@ init_version_check();
|
|
|
56587
56625
|
|
|
56588
56626
|
// src/persistence/thread-logger.ts
|
|
56589
56627
|
init_logger();
|
|
56590
|
-
import { homedir as
|
|
56591
|
-
import { join as
|
|
56592
|
-
var
|
|
56593
|
-
var LOGS_BASE_DIR =
|
|
56628
|
+
import { homedir as homedir4 } from "os";
|
|
56629
|
+
import { join as join4, dirname as dirname4 } from "path";
|
|
56630
|
+
var log9 = createLogger("thread-log");
|
|
56631
|
+
var LOGS_BASE_DIR = join4(homedir4(), ".claude-threads", "logs");
|
|
56594
56632
|
|
|
56595
56633
|
// src/operations/bug-report/handler.ts
|
|
56596
56634
|
var piiRedactor = new Redactor({ aggressive: true });
|
|
@@ -56613,7 +56651,7 @@ class UsernameAnonymizer {
|
|
|
56613
56651
|
// src/mcp/decision-bridge.ts
|
|
56614
56652
|
import { createServer, createConnection } from "node:net";
|
|
56615
56653
|
import { tmpdir } from "node:os";
|
|
56616
|
-
import { join as
|
|
56654
|
+
import { join as join5 } from "node:path";
|
|
56617
56655
|
import { randomUUID } from "node:crypto";
|
|
56618
56656
|
import { mkdtempSync } from "node:fs";
|
|
56619
56657
|
import { rm } from "node:fs/promises";
|
|
@@ -56624,8 +56662,8 @@ function bridgeSocketPath() {
|
|
|
56624
56662
|
if (process.platform === "win32") {
|
|
56625
56663
|
return `\\\\.\\pipe\\ctb-${randomUUID()}`;
|
|
56626
56664
|
}
|
|
56627
|
-
const dir = mkdtempSync(
|
|
56628
|
-
return
|
|
56665
|
+
const dir = mkdtempSync(join5(tmpdir(), "ctb-"));
|
|
56666
|
+
return join5(dir, "b.sock");
|
|
56629
56667
|
}
|
|
56630
56668
|
var MAX_BRIDGE_REQUEST_BYTES = 1024 * 1024;
|
|
56631
56669
|
|
|
@@ -56702,7 +56740,7 @@ class DecisionBridgeServer {
|
|
|
56702
56740
|
});
|
|
56703
56741
|
} catch (err) {
|
|
56704
56742
|
if (process.platform !== "win32") {
|
|
56705
|
-
await rm(
|
|
56743
|
+
await rm(join5(path, ".."), { recursive: true, force: true }).catch(() => {});
|
|
56706
56744
|
}
|
|
56707
56745
|
throw err;
|
|
56708
56746
|
}
|
|
@@ -56715,7 +56753,7 @@ class DecisionBridgeServer {
|
|
|
56715
56753
|
socket.destroy();
|
|
56716
56754
|
await new Promise((resolve4) => this.server.close(() => resolve4()));
|
|
56717
56755
|
if (process.platform !== "win32") {
|
|
56718
|
-
await rm(
|
|
56756
|
+
await rm(join5(this.path, ".."), { recursive: true, force: true }).catch(() => {});
|
|
56719
56757
|
}
|
|
56720
56758
|
}
|
|
56721
56759
|
}
|
|
@@ -56773,9 +56811,9 @@ init_version_check();
|
|
|
56773
56811
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
56774
56812
|
import { resolve as resolve4, dirname as dirname5 } from "path";
|
|
56775
56813
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
56776
|
-
import { existsSync as existsSync4, readFileSync as readFileSync3, watchFile, unwatchFile, unlinkSync, statSync, readdirSync, writeFileSync } from "fs";
|
|
56814
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, watchFile, unwatchFile, unlinkSync, statSync, readdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
56777
56815
|
import { tmpdir as tmpdir2 } from "os";
|
|
56778
|
-
import { join as
|
|
56816
|
+
import { join as join6 } from "path";
|
|
56779
56817
|
|
|
56780
56818
|
// src/mcp/outbound-env.ts
|
|
56781
56819
|
var OUTBOUND_ENV = {
|
|
@@ -56875,25 +56913,25 @@ function parseRateLimitEvent(event, now = Date.now()) {
|
|
|
56875
56913
|
}
|
|
56876
56914
|
|
|
56877
56915
|
// src/claude/cli.ts
|
|
56878
|
-
var
|
|
56916
|
+
var log10 = createLogger("claude");
|
|
56879
56917
|
function cleanupBrowserBridgeSockets() {
|
|
56880
56918
|
try {
|
|
56881
56919
|
const tempDir = tmpdir2();
|
|
56882
56920
|
const files = readdirSync(tempDir);
|
|
56883
56921
|
for (const file2 of files) {
|
|
56884
56922
|
if (file2.startsWith("claude-mcp-browser-bridge-")) {
|
|
56885
|
-
const filePath =
|
|
56923
|
+
const filePath = join6(tempDir, file2);
|
|
56886
56924
|
try {
|
|
56887
56925
|
const stats = statSync(filePath);
|
|
56888
56926
|
if (stats.isSocket()) {
|
|
56889
56927
|
unlinkSync(filePath);
|
|
56890
|
-
|
|
56928
|
+
log10.debug(`Removed stale browser bridge socket: ${file2}`);
|
|
56891
56929
|
}
|
|
56892
56930
|
} catch {}
|
|
56893
56931
|
}
|
|
56894
56932
|
}
|
|
56895
56933
|
} catch (err) {
|
|
56896
|
-
|
|
56934
|
+
log10.debug(`Browser bridge cleanup failed: ${err}`);
|
|
56897
56935
|
}
|
|
56898
56936
|
}
|
|
56899
56937
|
function buildClaudeChildEnv(parentEnv, account, opts) {
|
|
@@ -56915,9 +56953,13 @@ function buildClaudeChildEnv(parentEnv, account, opts) {
|
|
|
56915
56953
|
env.USERPROFILE = account.home;
|
|
56916
56954
|
delete env.ANTHROPIC_API_KEY;
|
|
56917
56955
|
delete env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
56956
|
+
delete env.ANTHROPIC_AUTH_TOKEN;
|
|
56957
|
+
delete env.CLAUDE_CONFIG_DIR;
|
|
56958
|
+
delete env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
|
|
56918
56959
|
} else if (account?.apiKey) {
|
|
56919
56960
|
env.ANTHROPIC_API_KEY = account.apiKey;
|
|
56920
56961
|
delete env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
56962
|
+
delete env.ANTHROPIC_AUTH_TOKEN;
|
|
56921
56963
|
}
|
|
56922
56964
|
return env;
|
|
56923
56965
|
}
|
|
@@ -56952,8 +56994,8 @@ function materializeMcpConfig(config3, sessionId, opts = {}) {
|
|
|
56952
56994
|
return { mode: "inline", value: JSON.stringify(config3) };
|
|
56953
56995
|
}
|
|
56954
56996
|
const dir = opts.tmpDirOverride ?? tmpdir2();
|
|
56955
|
-
const path =
|
|
56956
|
-
|
|
56997
|
+
const path = join6(dir, `claude-threads-mcp-${sessionId ?? process.pid}-${Date.now()}.json`);
|
|
56998
|
+
writeFileSync2(path, JSON.stringify(config3), { mode: 384 });
|
|
56957
56999
|
return { mode: "file", path };
|
|
56958
57000
|
}
|
|
56959
57001
|
function buildPermissionArgs(opts) {
|
|
@@ -57149,7 +57191,7 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
57149
57191
|
}
|
|
57150
57192
|
let statusLineCommand;
|
|
57151
57193
|
if (this.options.sessionId) {
|
|
57152
|
-
this.statusFilePath =
|
|
57194
|
+
this.statusFilePath = join6(tmpdir2(), `claude-threads-status-${this.options.sessionId}.json`);
|
|
57153
57195
|
const statusLineWriterPath = this.getStatusLineWriterPath();
|
|
57154
57196
|
const runtime = runtimeForScriptPath(statusLineWriterPath);
|
|
57155
57197
|
statusLineCommand = `${runtime} ${statusLineWriterPath} ${this.options.sessionId}`;
|
|
@@ -58119,7 +58161,7 @@ handlers.set("model", createPassthroughHandler("model"));
|
|
|
58119
58161
|
handlers.set("effort", createPassthroughHandler("effort"));
|
|
58120
58162
|
// src/commands/system-prompt-generator.ts
|
|
58121
58163
|
init_logger();
|
|
58122
|
-
var
|
|
58164
|
+
var log11 = createLogger("system-prompt");
|
|
58123
58165
|
function formatUserCommand(cmd) {
|
|
58124
58166
|
const cmdStr = cmd.args ? `\`!${cmd.command} ${cmd.args}\`` : `\`!${cmd.command}\``;
|
|
58125
58167
|
const description = cmd.description;
|
|
@@ -58211,7 +58253,7 @@ ${avoidCommands.map((c) => `- \`!${c.command}\` - ${c.reason}`).join(`
|
|
|
58211
58253
|
}
|
|
58212
58254
|
// src/utils/error-handler/index.ts
|
|
58213
58255
|
init_logger();
|
|
58214
|
-
var
|
|
58256
|
+
var log12 = createLogger("error");
|
|
58215
58257
|
|
|
58216
58258
|
// src/session/lifecycle.ts
|
|
58217
58259
|
init_logger();
|
|
@@ -58234,35 +58276,35 @@ init_emoji();
|
|
|
58234
58276
|
init_spawn();
|
|
58235
58277
|
import * as path from "path";
|
|
58236
58278
|
init_logger();
|
|
58237
|
-
import { homedir as
|
|
58238
|
-
var
|
|
58239
|
-
var WORKTREES_DIR = path.join(
|
|
58240
|
-
var METADATA_STORE_PATH = path.join(
|
|
58279
|
+
import { homedir as homedir5 } from "os";
|
|
58280
|
+
var log13 = createLogger("git-wt");
|
|
58281
|
+
var WORKTREES_DIR = path.join(homedir5(), ".claude-threads", "worktrees");
|
|
58282
|
+
var METADATA_STORE_PATH = path.join(homedir5(), ".claude-threads", "worktree-metadata.json");
|
|
58241
58283
|
|
|
58242
58284
|
// src/operations/post-helpers/index.ts
|
|
58243
|
-
var
|
|
58244
|
-
var sessionLog = createSessionLog(
|
|
58285
|
+
var log14 = createLogger("helpers");
|
|
58286
|
+
var sessionLog = createSessionLog(log14);
|
|
58245
58287
|
|
|
58246
58288
|
// src/operations/suggestions/title.ts
|
|
58247
58289
|
init_quick_query();
|
|
58248
58290
|
init_logger();
|
|
58249
|
-
var
|
|
58291
|
+
var log16 = createLogger("title");
|
|
58250
58292
|
|
|
58251
58293
|
// src/operations/suggestions/tag.ts
|
|
58252
58294
|
init_quick_query();
|
|
58253
58295
|
init_logger();
|
|
58254
|
-
var
|
|
58296
|
+
var log17 = createLogger("tags");
|
|
58255
58297
|
|
|
58256
58298
|
// src/session/metadata-suggestions.ts
|
|
58257
58299
|
init_logger();
|
|
58258
|
-
var
|
|
58259
|
-
var sessionLog2 = createSessionLog(
|
|
58300
|
+
var log18 = createLogger("session");
|
|
58301
|
+
var sessionLog2 = createSessionLog(log18);
|
|
58260
58302
|
|
|
58261
58303
|
// src/operations/context-prompt/handler.ts
|
|
58262
58304
|
init_emoji();
|
|
58263
58305
|
init_logger();
|
|
58264
|
-
var
|
|
58265
|
-
var sessionLog3 = createSessionLog(
|
|
58306
|
+
var log19 = createLogger("context");
|
|
58307
|
+
var sessionLog3 = createSessionLog(log19);
|
|
58266
58308
|
var contextPromptTimeouts = new Map;
|
|
58267
58309
|
var contextPromptFiles = new Map;
|
|
58268
58310
|
// src/memory/store.ts
|
|
@@ -58273,33 +58315,11 @@ import {
|
|
|
58273
58315
|
readFileSync as readFileSync4,
|
|
58274
58316
|
realpathSync
|
|
58275
58317
|
} from "fs";
|
|
58276
|
-
import { homedir as
|
|
58277
|
-
import { basename as basename3, dirname as dirname7, join as
|
|
58278
|
-
|
|
58279
|
-
// src/persistence/atomic-file.ts
|
|
58280
|
-
import { chmodSync as chmodSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
|
|
58281
|
-
|
|
58282
|
-
class SerialQueue {
|
|
58283
|
-
tail = Promise.resolve();
|
|
58284
|
-
run(fn) {
|
|
58285
|
-
const next = this.tail.then(fn, fn);
|
|
58286
|
-
this.tail = next.catch(() => {
|
|
58287
|
-
return;
|
|
58288
|
-
});
|
|
58289
|
-
return next;
|
|
58290
|
-
}
|
|
58291
|
-
}
|
|
58292
|
-
function writeFileAtomic(file2, content) {
|
|
58293
|
-
const tempFile = `${file2}.tmp`;
|
|
58294
|
-
writeFileSync2(tempFile, content, { encoding: "utf-8", mode: 384 });
|
|
58295
|
-
renameSync(tempFile, file2);
|
|
58296
|
-
chmodSync2(file2, 384);
|
|
58297
|
-
}
|
|
58298
|
-
|
|
58299
|
-
// src/memory/store.ts
|
|
58318
|
+
import { homedir as homedir6 } from "os";
|
|
58319
|
+
import { basename as basename3, dirname as dirname7, join as join8, sep as sep2 } from "path";
|
|
58300
58320
|
init_logger();
|
|
58301
|
-
var
|
|
58302
|
-
var DEFAULT_ROOT =
|
|
58321
|
+
var log20 = createLogger("memory");
|
|
58322
|
+
var DEFAULT_ROOT = join8(homedir6(), ".config", "claude-threads", "memory");
|
|
58303
58323
|
var CHANNEL_BLOCK_MAX_LINES = 200;
|
|
58304
58324
|
var CHANNEL_BLOCK_MAX_BYTES = 25 * 1024;
|
|
58305
58325
|
var CHANNEL_FILE_MAX_ENTRIES = 400;
|
|
@@ -58344,10 +58364,10 @@ class MemoryStore {
|
|
|
58344
58364
|
return this.root;
|
|
58345
58365
|
}
|
|
58346
58366
|
channelMemoryPath(platformId) {
|
|
58347
|
-
return
|
|
58367
|
+
return join8(this.root, platformSegment(platformId), "channel", "MEMORY.md");
|
|
58348
58368
|
}
|
|
58349
58369
|
repoMemoryDir(platformId, repoKey) {
|
|
58350
|
-
const dir =
|
|
58370
|
+
const dir = join8(this.root, platformSegment(platformId), "repos", repoKey);
|
|
58351
58371
|
this.ensureDir(dir);
|
|
58352
58372
|
return dir;
|
|
58353
58373
|
}
|
|
@@ -58394,7 +58414,7 @@ class MemoryStore {
|
|
|
58394
58414
|
if (result.added.length > 0) {
|
|
58395
58415
|
this.enforceFileCap(lines);
|
|
58396
58416
|
this.writeLines(platformId, lines);
|
|
58397
|
-
|
|
58417
|
+
log20.debug(`Channel memory for ${platformId}: +${result.added.length} entries` + (result.duplicates.length ? ` (${result.duplicates.length} duplicates skipped)` : ""));
|
|
58398
58418
|
}
|
|
58399
58419
|
return result;
|
|
58400
58420
|
});
|
|
@@ -58433,14 +58453,14 @@ class MemoryStore {
|
|
|
58433
58453
|
}
|
|
58434
58454
|
lines.splice(target.lineIndex, 1);
|
|
58435
58455
|
this.writeLines(platformId, lines);
|
|
58436
|
-
|
|
58456
|
+
log20.debug(`Channel memory for ${platformId}: removed one entry`);
|
|
58437
58457
|
return { ok: true, removed: target.entry };
|
|
58438
58458
|
});
|
|
58439
58459
|
}
|
|
58440
58460
|
clearChannel(platformId) {
|
|
58441
58461
|
return this.runExclusive(platformId, () => {
|
|
58442
58462
|
this.writeLines(platformId, []);
|
|
58443
|
-
|
|
58463
|
+
log20.debug(`Channel memory for ${platformId}: cleared`);
|
|
58444
58464
|
});
|
|
58445
58465
|
}
|
|
58446
58466
|
buildChannelMemoryBlock(platformId) {
|
|
@@ -58448,7 +58468,7 @@ class MemoryStore {
|
|
|
58448
58468
|
try {
|
|
58449
58469
|
lines = this.loadLines(platformId);
|
|
58450
58470
|
} catch (err) {
|
|
58451
|
-
|
|
58471
|
+
log20.warn(`Failed to read channel memory for ${platformId}: ${err.message}`);
|
|
58452
58472
|
return null;
|
|
58453
58473
|
}
|
|
58454
58474
|
if (lines.length === 0)
|
|
@@ -58532,7 +58552,7 @@ _(older entries omitted — \`!memory\` shows all)_` : rendered;
|
|
|
58532
58552
|
// src/memory/distiller.ts
|
|
58533
58553
|
init_quick_query();
|
|
58534
58554
|
init_logger();
|
|
58535
|
-
var
|
|
58555
|
+
var log21 = createLogger("memory");
|
|
58536
58556
|
|
|
58537
58557
|
// src/session/registry.ts
|
|
58538
58558
|
function compositeSessionId(platformId, threadId) {
|
|
@@ -58625,7 +58645,8 @@ class SessionRegistry {
|
|
|
58625
58645
|
return this.sessionStore.findByThread(platformId, threadId);
|
|
58626
58646
|
}
|
|
58627
58647
|
getPersistedByThreadId(threadId, platformId) {
|
|
58628
|
-
|
|
58648
|
+
const persisted = this.sessionStore.findByThreadIdAnyState(threadId, platformId);
|
|
58649
|
+
return persisted && isRevivable(persisted) ? persisted : undefined;
|
|
58629
58650
|
}
|
|
58630
58651
|
getSessionStore() {
|
|
58631
58652
|
return this.sessionStore;
|
|
@@ -58651,14 +58672,14 @@ class SessionRegistry {
|
|
|
58651
58672
|
init_emoji();
|
|
58652
58673
|
|
|
58653
58674
|
// src/persistence/routines-store.ts
|
|
58654
|
-
import { join as
|
|
58675
|
+
import { join as join10 } from "path";
|
|
58655
58676
|
init_logger();
|
|
58656
58677
|
|
|
58657
58678
|
// src/persistence/platform-list-store.ts
|
|
58658
58679
|
import { existsSync as existsSync6, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
|
|
58659
|
-
import { homedir as
|
|
58660
|
-
import { join as
|
|
58661
|
-
var STORES_CONFIG_DIR =
|
|
58680
|
+
import { homedir as homedir7 } from "os";
|
|
58681
|
+
import { join as join9 } from "path";
|
|
58682
|
+
var STORES_CONFIG_DIR = join9(homedir7(), ".config", "claude-threads");
|
|
58662
58683
|
var STORE_VERSION = 1;
|
|
58663
58684
|
|
|
58664
58685
|
class PlatformListStore {
|
|
@@ -58671,7 +58692,7 @@ class PlatformListStore {
|
|
|
58671
58692
|
this.collectionKey = collectionKey;
|
|
58672
58693
|
if (filePath) {
|
|
58673
58694
|
this.file = filePath;
|
|
58674
|
-
this.configDir =
|
|
58695
|
+
this.configDir = join9(filePath, "..");
|
|
58675
58696
|
} else {
|
|
58676
58697
|
this.file = defaultFile;
|
|
58677
58698
|
this.configDir = STORES_CONFIG_DIR;
|
|
@@ -58795,41 +58816,41 @@ class PlatformListStore {
|
|
|
58795
58816
|
}
|
|
58796
58817
|
|
|
58797
58818
|
// src/persistence/routines-store.ts
|
|
58798
|
-
var
|
|
58799
|
-
var DEFAULT_FILE =
|
|
58819
|
+
var log22 = createLogger("routines");
|
|
58820
|
+
var DEFAULT_FILE = join10(STORES_CONFIG_DIR, "routines.yaml");
|
|
58800
58821
|
|
|
58801
58822
|
// src/routines/parser.ts
|
|
58802
58823
|
init_logger();
|
|
58803
|
-
var
|
|
58824
|
+
var log23 = createLogger("routines");
|
|
58804
58825
|
|
|
58805
58826
|
// src/persistence/watches-store.ts
|
|
58806
|
-
import { join as
|
|
58827
|
+
import { join as join11 } from "path";
|
|
58807
58828
|
init_logger();
|
|
58808
|
-
var
|
|
58809
|
-
var DEFAULT_FILE2 =
|
|
58829
|
+
var log24 = createLogger("watches");
|
|
58830
|
+
var DEFAULT_FILE2 = join11(STORES_CONFIG_DIR, "watches.yaml");
|
|
58810
58831
|
|
|
58811
58832
|
// src/watches/parser.ts
|
|
58812
58833
|
init_logger();
|
|
58813
|
-
var
|
|
58834
|
+
var log25 = createLogger("watches");
|
|
58814
58835
|
|
|
58815
58836
|
// src/operations/commands/guards.ts
|
|
58816
58837
|
init_logger();
|
|
58817
|
-
var
|
|
58818
|
-
var sessionLog4 = createSessionLog(
|
|
58838
|
+
var log26 = createLogger("commands");
|
|
58839
|
+
var sessionLog4 = createSessionLog(log26);
|
|
58819
58840
|
|
|
58820
58841
|
// src/operations/commands/automation.ts
|
|
58821
58842
|
init_logger();
|
|
58822
|
-
var
|
|
58823
|
-
var sessionLog5 = createSessionLog(
|
|
58843
|
+
var log27 = createLogger("commands");
|
|
58844
|
+
var sessionLog5 = createSessionLog(log27);
|
|
58824
58845
|
|
|
58825
58846
|
// src/operations/agent-actions/handler.ts
|
|
58826
58847
|
init_logger();
|
|
58827
|
-
var
|
|
58828
|
-
var sessionLog6 = createSessionLog(
|
|
58848
|
+
var log28 = createLogger("agent-actions");
|
|
58849
|
+
var sessionLog6 = createSessionLog(log28);
|
|
58829
58850
|
|
|
58830
58851
|
// src/session/lifecycle.ts
|
|
58831
|
-
var
|
|
58832
|
-
var sessionLog7 = createSessionLog(
|
|
58852
|
+
var log29 = createLogger("lifecycle");
|
|
58853
|
+
var sessionLog7 = createSessionLog(log29);
|
|
58833
58854
|
var _inFlightSessionStarts = new Map;
|
|
58834
58855
|
var CHAT_PLATFORM_PROMPT = generateChatPlatformPrompt();
|
|
58835
58856
|
|
|
@@ -58842,39 +58863,39 @@ init_logger();
|
|
|
58842
58863
|
init_quick_query();
|
|
58843
58864
|
|
|
58844
58865
|
// src/persistence/github-emails-store.ts
|
|
58845
|
-
import { homedir as
|
|
58846
|
-
import { join as
|
|
58866
|
+
import { homedir as homedir8 } from "os";
|
|
58867
|
+
import { join as join12 } from "path";
|
|
58847
58868
|
init_logger();
|
|
58848
|
-
var
|
|
58849
|
-
var
|
|
58850
|
-
var DEFAULT_FILE3 =
|
|
58869
|
+
var log30 = createLogger("gh-emails");
|
|
58870
|
+
var DEFAULT_CONFIG_DIR2 = join12(homedir8(), ".config", "claude-threads");
|
|
58871
|
+
var DEFAULT_FILE3 = join12(DEFAULT_CONFIG_DIR2, "github-emails.yaml");
|
|
58851
58872
|
|
|
58852
58873
|
// src/operations/commands/handler.ts
|
|
58853
|
-
var
|
|
58854
|
-
var sessionLog8 = createSessionLog(
|
|
58874
|
+
var log31 = createLogger("commands");
|
|
58875
|
+
var sessionLog8 = createSessionLog(log31);
|
|
58855
58876
|
// src/operations/commands/memory.ts
|
|
58856
58877
|
init_logger();
|
|
58857
|
-
var
|
|
58858
|
-
var sessionLog9 = createSessionLog(
|
|
58878
|
+
var log32 = createLogger("commands");
|
|
58879
|
+
var sessionLog9 = createSessionLog(log32);
|
|
58859
58880
|
// src/operations/suggestions/branch.ts
|
|
58860
58881
|
init_quick_query();
|
|
58861
58882
|
init_logger();
|
|
58862
58883
|
import { exec as exec2 } from "child_process";
|
|
58863
58884
|
import { promisify as promisify2 } from "util";
|
|
58864
58885
|
var execAsync2 = promisify2(exec2);
|
|
58865
|
-
var
|
|
58886
|
+
var log33 = createLogger("branch");
|
|
58866
58887
|
|
|
58867
58888
|
// src/operations/worktree/handler.ts
|
|
58868
58889
|
init_logger();
|
|
58869
|
-
var
|
|
58870
|
-
var sessionLog10 = createSessionLog(
|
|
58890
|
+
var log34 = createLogger("worktree");
|
|
58891
|
+
var sessionLog10 = createSessionLog(log34);
|
|
58871
58892
|
// src/operations/events/handler.ts
|
|
58872
58893
|
init_logger();
|
|
58873
|
-
var
|
|
58874
|
-
var sessionLog11 = createSessionLog(
|
|
58894
|
+
var log35 = createLogger("events");
|
|
58895
|
+
var sessionLog11 = createSessionLog(log35);
|
|
58875
58896
|
// src/operations/monitor/handler.ts
|
|
58876
58897
|
init_logger();
|
|
58877
|
-
var
|
|
58898
|
+
var log36 = createLogger("monitor");
|
|
58878
58899
|
var DEFAULT_INTERVAL_MS = 60 * 1000;
|
|
58879
58900
|
// src/mcp/mcp-server.ts
|
|
58880
58901
|
init_logger();
|
|
@@ -58963,7 +58984,7 @@ init_logger();
|
|
|
58963
58984
|
// src/platform/mattermost/upload.ts
|
|
58964
58985
|
init_logger();
|
|
58965
58986
|
import { readFile } from "fs/promises";
|
|
58966
|
-
var
|
|
58987
|
+
var log37 = createLogger("mm-upload");
|
|
58967
58988
|
async function uploadFileMattermost(args) {
|
|
58968
58989
|
const { url: url2, token, channelId, threadId, filePath, filename, caption } = args;
|
|
58969
58990
|
const buffer = await readFile(filePath);
|
|
@@ -58971,7 +58992,7 @@ async function uploadFileMattermost(args) {
|
|
|
58971
58992
|
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
58972
58993
|
const formData = new FormData;
|
|
58973
58994
|
formData.append("files", new Blob([arrayBuffer]), filename);
|
|
58974
|
-
|
|
58995
|
+
log37.debug(`POST /files (${buffer.length} bytes, ${filename})`);
|
|
58975
58996
|
const uploadResponse = await fetch(uploadUrl, {
|
|
58976
58997
|
method: "POST",
|
|
58977
58998
|
headers: {
|
|
@@ -58995,7 +59016,7 @@ async function uploadFileMattermost(args) {
|
|
|
58995
59016
|
root_id: resolvePostThreadId(threadId),
|
|
58996
59017
|
file_ids: [fileInfo.id]
|
|
58997
59018
|
};
|
|
58998
|
-
|
|
59019
|
+
log37.debug(`POST /posts (file_ids=[${fileInfo.id}])`);
|
|
58999
59020
|
const postResponse = await fetch(postUrl, {
|
|
59000
59021
|
method: "POST",
|
|
59001
59022
|
headers: {
|
|
@@ -59493,7 +59514,7 @@ ${code}
|
|
|
59493
59514
|
// src/platform/slack/upload.ts
|
|
59494
59515
|
init_logger();
|
|
59495
59516
|
import { readFile as readFile2 } from "fs/promises";
|
|
59496
|
-
var
|
|
59517
|
+
var log38 = createLogger("slack-upload");
|
|
59497
59518
|
var DEFAULT_API_URL = "https://slack.com/api";
|
|
59498
59519
|
async function uploadFileSlack(args) {
|
|
59499
59520
|
const { botToken, channelId, threadTs, filePath, filename, caption } = args;
|
|
@@ -59501,7 +59522,7 @@ async function uploadFileSlack(args) {
|
|
|
59501
59522
|
const buffer = await readFile2(filePath);
|
|
59502
59523
|
const params = new URLSearchParams({ filename, length: String(buffer.length) });
|
|
59503
59524
|
const step1Url = `${apiUrl}/files.getUploadURLExternal?${params.toString()}`;
|
|
59504
|
-
|
|
59525
|
+
log38.debug(`GET files.getUploadURLExternal (${buffer.length} bytes, ${filename})`);
|
|
59505
59526
|
const step1Response = await fetch(step1Url, {
|
|
59506
59527
|
method: "GET",
|
|
59507
59528
|
headers: {
|
|
@@ -59519,7 +59540,7 @@ async function uploadFileSlack(args) {
|
|
|
59519
59540
|
const uploadUrl = step1Data.upload_url;
|
|
59520
59541
|
const fileId = step1Data.file_id;
|
|
59521
59542
|
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
59522
|
-
|
|
59543
|
+
log38.debug(`POST <upload_url>`);
|
|
59523
59544
|
const step2Response = await fetch(uploadUrl, {
|
|
59524
59545
|
method: "POST",
|
|
59525
59546
|
headers: {
|
|
@@ -59539,7 +59560,7 @@ async function uploadFileSlack(args) {
|
|
|
59539
59560
|
if (caption !== undefined) {
|
|
59540
59561
|
step3Body.initial_comment = caption;
|
|
59541
59562
|
}
|
|
59542
|
-
|
|
59563
|
+
log38.debug(`POST files.completeUploadExternal (file_id=${fileId}, thread_ts=${threadTs})`);
|
|
59543
59564
|
const step3Response = await fetch(`${apiUrl}/files.completeUploadExternal`, {
|
|
59544
59565
|
method: "POST",
|
|
59545
59566
|
headers: {
|
|
@@ -59557,7 +59578,7 @@ async function uploadFileSlack(args) {
|
|
|
59557
59578
|
throw new Error(`Slack completeUploadExternal error: ${step3Data.error || "unknown"}`);
|
|
59558
59579
|
}
|
|
59559
59580
|
if (!step3Data.ts) {
|
|
59560
|
-
|
|
59581
|
+
log38.warn(`Slack completeUploadExternal returned no ts; using fileId ${fileId} as postId. ` + `Do not use this id for updatePost/addReaction.`);
|
|
59561
59582
|
}
|
|
59562
59583
|
return { fileId, postId: step3Data.ts ?? fileId };
|
|
59563
59584
|
}
|