claude-threads 1.33.0 → 1.34.0
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 +16 -0
- package/README.md +9 -0
- package/dist/index.js +1314 -973
- package/dist/mcp/mcp-server.js +196 -153
- package/docs/CONFIGURATION.md +41 -0
- package/docs/audio-transcription-spec.md +151 -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 log16;
|
|
14703
14703
|
var init_quick_query = __esm(() => {
|
|
14704
14704
|
init_spawn();
|
|
14705
14705
|
init_version_check();
|
|
14706
14706
|
init_logger();
|
|
14707
|
-
|
|
14707
|
+
log16 = createLogger("query");
|
|
14708
14708
|
});
|
|
14709
14709
|
|
|
14710
14710
|
// node_modules/ws/lib/constants.js
|
|
@@ -52194,6 +52194,13 @@ function createMessageManagerEvents() {
|
|
|
52194
52194
|
return new TypedEventEmitter;
|
|
52195
52195
|
}
|
|
52196
52196
|
|
|
52197
|
+
// src/transcription/elevenlabs.ts
|
|
52198
|
+
init_logger();
|
|
52199
|
+
var log3 = createLogger("transcribe");
|
|
52200
|
+
|
|
52201
|
+
// src/transcription/types.ts
|
|
52202
|
+
var AUDIO_EXTENSIONS = new Set(["m4a", "mp3", "ogg", "opus", "wav", "aac", "flac", "webm"]);
|
|
52203
|
+
var GENERIC_MIME_TYPES = new Set(["", "application/octet-stream", "binary/octet-stream"]);
|
|
52197
52204
|
// src/operations/streaming/handler.ts
|
|
52198
52205
|
init_logger();
|
|
52199
52206
|
|
|
@@ -52218,7 +52225,19 @@ function formatBytes(bytes) {
|
|
|
52218
52225
|
}
|
|
52219
52226
|
|
|
52220
52227
|
// src/operations/streaming/handler.ts
|
|
52221
|
-
var
|
|
52228
|
+
var log4 = createLogger("streaming");
|
|
52229
|
+
async function postTranscriptFeedback(platform, threadId, transcripts) {
|
|
52230
|
+
if (!transcripts || transcripts.length === 0)
|
|
52231
|
+
return;
|
|
52232
|
+
const formatter = platform.getFormatter();
|
|
52233
|
+
for (const t of transcripts) {
|
|
52234
|
+
const quoted = t.text.split(`
|
|
52235
|
+
`).map((line) => formatter.formatBlockquote(line)).join(`
|
|
52236
|
+
`);
|
|
52237
|
+
await platform.createPost(`\uD83C\uDF99️ ${formatter.formatBold(`Transcript of ${t.name}:`)}
|
|
52238
|
+
${quoted}`, threadId);
|
|
52239
|
+
}
|
|
52240
|
+
}
|
|
52222
52241
|
async function postSkippedFilesFeedback(platform, threadId, skipped) {
|
|
52223
52242
|
if (skipped.length === 0)
|
|
52224
52243
|
return;
|
|
@@ -52286,7 +52305,7 @@ function formatRelativeTime(date8) {
|
|
|
52286
52305
|
return `${diffMin} min ago`;
|
|
52287
52306
|
}
|
|
52288
52307
|
// src/operations/message-manager.ts
|
|
52289
|
-
var
|
|
52308
|
+
var log5 = createLogger("msg-mgr");
|
|
52290
52309
|
|
|
52291
52310
|
class MessageManager {
|
|
52292
52311
|
platform;
|
|
@@ -52379,7 +52398,7 @@ class MessageManager {
|
|
|
52379
52398
|
});
|
|
52380
52399
|
}
|
|
52381
52400
|
async handleEvent(event) {
|
|
52382
|
-
const logger =
|
|
52401
|
+
const logger = log5.forSession(this.sessionId);
|
|
52383
52402
|
const transformCtx = {
|
|
52384
52403
|
sessionId: this.sessionId,
|
|
52385
52404
|
formatter: this.platform.getFormatter(),
|
|
@@ -52433,7 +52452,7 @@ class MessageManager {
|
|
|
52433
52452
|
}
|
|
52434
52453
|
}
|
|
52435
52454
|
async executeOperation(op) {
|
|
52436
|
-
const logger =
|
|
52455
|
+
const logger = log5.forSession(this.sessionId);
|
|
52437
52456
|
const ctx = this.getExecutorContext();
|
|
52438
52457
|
try {
|
|
52439
52458
|
if (isContentOp(op)) {
|
|
@@ -52501,7 +52520,7 @@ class MessageManager {
|
|
|
52501
52520
|
threadId: this.threadId,
|
|
52502
52521
|
platform: this.platform,
|
|
52503
52522
|
formatter: this.platform.getFormatter(),
|
|
52504
|
-
logger:
|
|
52523
|
+
logger: log5.forSession(this.sessionId),
|
|
52505
52524
|
postTracker: this.postTracker,
|
|
52506
52525
|
contentBreaker: this.contentBreaker,
|
|
52507
52526
|
threadLogger: this.session.threadLogger,
|
|
@@ -52730,13 +52749,13 @@ class MessageManager {
|
|
|
52730
52749
|
return this.systemExecutor.postSuccess(message, this.getExecutorContext());
|
|
52731
52750
|
}
|
|
52732
52751
|
async prepareForUserMessage() {
|
|
52733
|
-
const logger =
|
|
52752
|
+
const logger = log5.forSession(this.sessionId);
|
|
52734
52753
|
logger.debug("Preparing for new user message");
|
|
52735
52754
|
await this.closeCurrentPost();
|
|
52736
52755
|
await this.bumpTaskList();
|
|
52737
52756
|
}
|
|
52738
52757
|
async handleUserMessage(message, files, username, displayName) {
|
|
52739
|
-
const logger =
|
|
52758
|
+
const logger = log5.forSession(this.sessionId);
|
|
52740
52759
|
if (!this.session.claude.isRunning()) {
|
|
52741
52760
|
logger.debug("Claude not running, ignoring user message");
|
|
52742
52761
|
return false;
|
|
@@ -52751,13 +52770,16 @@ class MessageManager {
|
|
|
52751
52770
|
}
|
|
52752
52771
|
let content = outgoing;
|
|
52753
52772
|
let skippedFiles = [];
|
|
52773
|
+
let transcripts;
|
|
52754
52774
|
if (this.buildMessageContentCallback) {
|
|
52755
52775
|
const built = await this.buildMessageContentCallback(outgoing, this.platform, files);
|
|
52756
52776
|
content = built.content;
|
|
52757
52777
|
skippedFiles = built.skipped;
|
|
52778
|
+
transcripts = built.transcripts;
|
|
52758
52779
|
}
|
|
52759
52780
|
this.session.claude.sendMessage(content);
|
|
52760
52781
|
await postSkippedFilesFeedback(this.platform, this.threadId, skippedFiles);
|
|
52782
|
+
await postTranscriptFeedback(this.platform, this.threadId, transcripts);
|
|
52761
52783
|
this.session.lastActivityAt = new Date;
|
|
52762
52784
|
this.session.isProcessing = true;
|
|
52763
52785
|
this.emitSessionUpdateCallback?.({ status: "active", isTyping: true });
|
|
@@ -52779,7 +52801,7 @@ class MessageManager {
|
|
|
52779
52801
|
];
|
|
52780
52802
|
}
|
|
52781
52803
|
async handleReaction(postId, emoji4, user, action) {
|
|
52782
|
-
const logger =
|
|
52804
|
+
const logger = log5.forSession(this.sessionId);
|
|
52783
52805
|
const ctx = this.getExecutorContext();
|
|
52784
52806
|
logger.debug(`Routing reaction: postId=${postId}, emoji=${emoji4}, user=${user}, action=${action}`);
|
|
52785
52807
|
for (const { name, executor } of this.reactionDispatchList()) {
|
|
@@ -52877,7 +52899,7 @@ class MessageManager {
|
|
|
52877
52899
|
}
|
|
52878
52900
|
// src/session/lifecycle-fsm.ts
|
|
52879
52901
|
init_logger();
|
|
52880
|
-
var
|
|
52902
|
+
var log6 = createLogger("fsm");
|
|
52881
52903
|
var ALLOWED_TRANSITIONS = {
|
|
52882
52904
|
starting: new Set(["active", "paused", "interrupted", "cancelling", "restarting"]),
|
|
52883
52905
|
active: new Set([
|
|
@@ -52902,9 +52924,54 @@ var ALLOWED_TRANSITIONS = {
|
|
|
52902
52924
|
cancelling: new Set(["ending"]),
|
|
52903
52925
|
ending: new Set
|
|
52904
52926
|
};
|
|
52927
|
+
// src/persistence/atomic-file.ts
|
|
52928
|
+
import { chmodSync as chmodSync2, renameSync, writeFileSync } from "fs";
|
|
52929
|
+
|
|
52930
|
+
class SerialQueue {
|
|
52931
|
+
tail = Promise.resolve();
|
|
52932
|
+
run(fn) {
|
|
52933
|
+
const next = this.tail.then(fn, fn);
|
|
52934
|
+
this.tail = next.catch(() => {
|
|
52935
|
+
return;
|
|
52936
|
+
});
|
|
52937
|
+
return next;
|
|
52938
|
+
}
|
|
52939
|
+
}
|
|
52940
|
+
function writeFileAtomic(file2, content) {
|
|
52941
|
+
const tempFile = `${file2}.tmp`;
|
|
52942
|
+
writeFileSync(tempFile, content, { encoding: "utf-8", mode: 384 });
|
|
52943
|
+
renameSync(tempFile, file2);
|
|
52944
|
+
chmodSync2(file2, 384);
|
|
52945
|
+
}
|
|
52946
|
+
|
|
52947
|
+
// src/persistence/session-store.ts
|
|
52948
|
+
init_logger();
|
|
52949
|
+
import { homedir as homedir2 } from "os";
|
|
52950
|
+
import { join as join3 } from "path";
|
|
52951
|
+
|
|
52952
|
+
// src/sponsor.ts
|
|
52953
|
+
var SPONSOR_URL = "https://github.com/sponsors/axolotl-systems";
|
|
52954
|
+
var MILESTONE_VISIBLE_MS = 24 * 60 * 60 * 1000;
|
|
52955
|
+
function formatSponsorFooter(formatter) {
|
|
52956
|
+
return formatter.formatItalic(`♥ Support claude-threads: ${formatter.formatLink("github.com/sponsors/axolotl-systems", SPONSOR_URL)}`);
|
|
52957
|
+
}
|
|
52958
|
+
|
|
52959
|
+
// src/persistence/session-store.ts
|
|
52960
|
+
var log7 = createLogger("persist");
|
|
52961
|
+
function resolveEndReason(session) {
|
|
52962
|
+
if (!session.cleanedAt)
|
|
52963
|
+
return;
|
|
52964
|
+
return session.endReason ?? "stopped";
|
|
52965
|
+
}
|
|
52966
|
+
function isRevivable(session) {
|
|
52967
|
+
return resolveEndReason(session) !== "stopped";
|
|
52968
|
+
}
|
|
52969
|
+
var DEFAULT_CONFIG_DIR = join3(homedir2(), ".config", "claude-threads");
|
|
52970
|
+
var DEFAULT_SESSIONS_FILE = join3(DEFAULT_CONFIG_DIR, "sessions.json");
|
|
52971
|
+
|
|
52905
52972
|
// src/config/index.ts
|
|
52906
52973
|
import { resolve as resolve2, dirname as dirname2 } from "path";
|
|
52907
|
-
import { homedir as
|
|
52974
|
+
import { homedir as homedir3 } from "os";
|
|
52908
52975
|
|
|
52909
52976
|
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
52910
52977
|
function getDefaultExportFromCjs(x) {
|
|
@@ -56016,7 +56083,7 @@ var jsYamlExports = requireJsYaml();
|
|
|
56016
56083
|
var yaml = /* @__PURE__ */ getDefaultExportFromCjs(jsYamlExports);
|
|
56017
56084
|
|
|
56018
56085
|
// src/config/index.ts
|
|
56019
|
-
var CONFIG_PATH = resolve2(
|
|
56086
|
+
var CONFIG_PATH = resolve2(homedir3(), ".config", "claude-threads", "config.yaml");
|
|
56020
56087
|
|
|
56021
56088
|
// src/utils/battery.ts
|
|
56022
56089
|
import { exec } from "child_process";
|
|
@@ -56125,7 +56192,7 @@ init_logger();
|
|
|
56125
56192
|
// src/utils/keep-alive.ts
|
|
56126
56193
|
init_logger();
|
|
56127
56194
|
import { spawn } from "child_process";
|
|
56128
|
-
var
|
|
56195
|
+
var log8 = createLogger("keepalive");
|
|
56129
56196
|
function keepAliveSpawnSpec(platform, parentPid) {
|
|
56130
56197
|
switch (platform) {
|
|
56131
56198
|
case "darwin":
|
|
@@ -56181,7 +56248,7 @@ class KeepAliveManager {
|
|
|
56181
56248
|
if (!enabled && this.keepAliveProcess) {
|
|
56182
56249
|
this.stopKeepAlive();
|
|
56183
56250
|
}
|
|
56184
|
-
|
|
56251
|
+
log8.debug(`Keep-alive ${enabled ? "enabled" : "disabled"}`);
|
|
56185
56252
|
}
|
|
56186
56253
|
isEnabled() {
|
|
56187
56254
|
return this.enabled;
|
|
@@ -56191,7 +56258,7 @@ class KeepAliveManager {
|
|
|
56191
56258
|
}
|
|
56192
56259
|
sessionStarted() {
|
|
56193
56260
|
this.activeSessionCount++;
|
|
56194
|
-
|
|
56261
|
+
log8.debug(`Session started (${this.activeSessionCount} active)`);
|
|
56195
56262
|
if (this.activeSessionCount === 1) {
|
|
56196
56263
|
this.startKeepAlive();
|
|
56197
56264
|
}
|
|
@@ -56200,7 +56267,7 @@ class KeepAliveManager {
|
|
|
56200
56267
|
if (this.activeSessionCount > 0) {
|
|
56201
56268
|
this.activeSessionCount--;
|
|
56202
56269
|
}
|
|
56203
|
-
|
|
56270
|
+
log8.debug(`Session ended (${this.activeSessionCount} active)`);
|
|
56204
56271
|
if (this.activeSessionCount === 0) {
|
|
56205
56272
|
this.stopKeepAlive();
|
|
56206
56273
|
}
|
|
@@ -56214,11 +56281,11 @@ class KeepAliveManager {
|
|
|
56214
56281
|
}
|
|
56215
56282
|
startKeepAlive() {
|
|
56216
56283
|
if (!this.enabled) {
|
|
56217
|
-
|
|
56284
|
+
log8.debug("Keep-alive disabled, skipping");
|
|
56218
56285
|
return;
|
|
56219
56286
|
}
|
|
56220
56287
|
if (this.keepAliveProcess) {
|
|
56221
|
-
|
|
56288
|
+
log8.debug("Keep-alive already running");
|
|
56222
56289
|
return;
|
|
56223
56290
|
}
|
|
56224
56291
|
switch (this.platform) {
|
|
@@ -56232,12 +56299,12 @@ class KeepAliveManager {
|
|
|
56232
56299
|
this.startWindowsKeepAlive();
|
|
56233
56300
|
break;
|
|
56234
56301
|
default:
|
|
56235
|
-
|
|
56302
|
+
log8.warn(`Keep-alive not supported on ${this.platform}`);
|
|
56236
56303
|
}
|
|
56237
56304
|
}
|
|
56238
56305
|
stopKeepAlive() {
|
|
56239
56306
|
if (this.keepAliveProcess) {
|
|
56240
|
-
|
|
56307
|
+
log8.debug("Stopping keep-alive");
|
|
56241
56308
|
this.keepAliveProcess.kill();
|
|
56242
56309
|
this.keepAliveProcess = null;
|
|
56243
56310
|
}
|
|
@@ -56252,18 +56319,18 @@ class KeepAliveManager {
|
|
|
56252
56319
|
detached: false
|
|
56253
56320
|
});
|
|
56254
56321
|
this.keepAliveProcess.on("error", (err) => {
|
|
56255
|
-
|
|
56322
|
+
log8.error(`Failed to start caffeinate: ${err.message}`);
|
|
56256
56323
|
this.keepAliveProcess = null;
|
|
56257
56324
|
});
|
|
56258
56325
|
this.keepAliveProcess.on("exit", (code) => {
|
|
56259
56326
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
56260
|
-
|
|
56327
|
+
log8.debug(`caffeinate exited with code ${code}`);
|
|
56261
56328
|
}
|
|
56262
56329
|
this.keepAliveProcess = null;
|
|
56263
56330
|
});
|
|
56264
|
-
|
|
56331
|
+
log8.info("Sleep prevention active (caffeinate)");
|
|
56265
56332
|
} catch (err) {
|
|
56266
|
-
|
|
56333
|
+
log8.error(`Failed to start caffeinate: ${err}`);
|
|
56267
56334
|
}
|
|
56268
56335
|
}
|
|
56269
56336
|
startLinuxKeepAlive() {
|
|
@@ -56276,19 +56343,19 @@ class KeepAliveManager {
|
|
|
56276
56343
|
detached: false
|
|
56277
56344
|
});
|
|
56278
56345
|
this.keepAliveProcess.on("error", (err) => {
|
|
56279
|
-
|
|
56346
|
+
log8.debug(`systemd-inhibit not available: ${err.message}`);
|
|
56280
56347
|
this.keepAliveProcess = null;
|
|
56281
56348
|
this.startLinuxKeepAliveFallback();
|
|
56282
56349
|
});
|
|
56283
56350
|
this.keepAliveProcess.on("exit", (code) => {
|
|
56284
56351
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
56285
|
-
|
|
56352
|
+
log8.debug(`systemd-inhibit exited with code ${code}`);
|
|
56286
56353
|
}
|
|
56287
56354
|
this.keepAliveProcess = null;
|
|
56288
56355
|
});
|
|
56289
|
-
|
|
56356
|
+
log8.info("Sleep prevention active (systemd-inhibit)");
|
|
56290
56357
|
} catch (err) {
|
|
56291
|
-
|
|
56358
|
+
log8.debug(`Failed to start systemd-inhibit: ${err}`);
|
|
56292
56359
|
this.startLinuxKeepAliveFallback();
|
|
56293
56360
|
}
|
|
56294
56361
|
}
|
|
@@ -56299,15 +56366,15 @@ class KeepAliveManager {
|
|
|
56299
56366
|
detached: false
|
|
56300
56367
|
});
|
|
56301
56368
|
this.keepAliveProcess.on("error", (err) => {
|
|
56302
|
-
|
|
56369
|
+
log8.warn(`Linux keep-alive fallback not available: ${err.message}`);
|
|
56303
56370
|
this.keepAliveProcess = null;
|
|
56304
56371
|
});
|
|
56305
56372
|
this.keepAliveProcess.on("exit", () => {
|
|
56306
56373
|
this.keepAliveProcess = null;
|
|
56307
56374
|
});
|
|
56308
|
-
|
|
56375
|
+
log8.info("Sleep prevention active (xdg-screensaver)");
|
|
56309
56376
|
} catch (err) {
|
|
56310
|
-
|
|
56377
|
+
log8.warn(`Linux keep-alive not available: ${err}`);
|
|
56311
56378
|
}
|
|
56312
56379
|
}
|
|
56313
56380
|
startWindowsKeepAlive() {
|
|
@@ -56319,32 +56386,25 @@ class KeepAliveManager {
|
|
|
56319
56386
|
windowsHide: true
|
|
56320
56387
|
});
|
|
56321
56388
|
this.keepAliveProcess.on("error", (err) => {
|
|
56322
|
-
|
|
56389
|
+
log8.warn(`Windows keep-alive not available: ${err.message}`);
|
|
56323
56390
|
this.keepAliveProcess = null;
|
|
56324
56391
|
});
|
|
56325
56392
|
this.keepAliveProcess.on("exit", (code) => {
|
|
56326
56393
|
if (code !== null && code !== 0 && this.activeSessionCount > 0) {
|
|
56327
|
-
|
|
56394
|
+
log8.debug(`PowerShell keep-alive exited with code ${code}`);
|
|
56328
56395
|
}
|
|
56329
56396
|
this.keepAliveProcess = null;
|
|
56330
56397
|
});
|
|
56331
|
-
|
|
56398
|
+
log8.info("Sleep prevention active (SetThreadExecutionState)");
|
|
56332
56399
|
} catch (err) {
|
|
56333
|
-
|
|
56400
|
+
log8.warn(`Windows keep-alive not available: ${err}`);
|
|
56334
56401
|
}
|
|
56335
56402
|
}
|
|
56336
56403
|
}
|
|
56337
56404
|
var keepAlive = new KeepAliveManager;
|
|
56338
56405
|
|
|
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
56406
|
// src/operations/sticky-message/handler.ts
|
|
56347
|
-
var
|
|
56407
|
+
var log9 = createLogger("sticky");
|
|
56348
56408
|
var botStartedAt = new Date;
|
|
56349
56409
|
var stickyPostIds = new Map;
|
|
56350
56410
|
var needsBump = new Map;
|
|
@@ -56587,10 +56647,10 @@ init_version_check();
|
|
|
56587
56647
|
|
|
56588
56648
|
// src/persistence/thread-logger.ts
|
|
56589
56649
|
init_logger();
|
|
56590
|
-
import { homedir as
|
|
56591
|
-
import { join as
|
|
56592
|
-
var
|
|
56593
|
-
var LOGS_BASE_DIR =
|
|
56650
|
+
import { homedir as homedir4 } from "os";
|
|
56651
|
+
import { join as join4, dirname as dirname4 } from "path";
|
|
56652
|
+
var log10 = createLogger("thread-log");
|
|
56653
|
+
var LOGS_BASE_DIR = join4(homedir4(), ".claude-threads", "logs");
|
|
56594
56654
|
|
|
56595
56655
|
// src/operations/bug-report/handler.ts
|
|
56596
56656
|
var piiRedactor = new Redactor({ aggressive: true });
|
|
@@ -56613,7 +56673,7 @@ class UsernameAnonymizer {
|
|
|
56613
56673
|
// src/mcp/decision-bridge.ts
|
|
56614
56674
|
import { createServer, createConnection } from "node:net";
|
|
56615
56675
|
import { tmpdir } from "node:os";
|
|
56616
|
-
import { join as
|
|
56676
|
+
import { join as join5 } from "node:path";
|
|
56617
56677
|
import { randomUUID } from "node:crypto";
|
|
56618
56678
|
import { mkdtempSync } from "node:fs";
|
|
56619
56679
|
import { rm } from "node:fs/promises";
|
|
@@ -56624,8 +56684,8 @@ function bridgeSocketPath() {
|
|
|
56624
56684
|
if (process.platform === "win32") {
|
|
56625
56685
|
return `\\\\.\\pipe\\ctb-${randomUUID()}`;
|
|
56626
56686
|
}
|
|
56627
|
-
const dir = mkdtempSync(
|
|
56628
|
-
return
|
|
56687
|
+
const dir = mkdtempSync(join5(tmpdir(), "ctb-"));
|
|
56688
|
+
return join5(dir, "b.sock");
|
|
56629
56689
|
}
|
|
56630
56690
|
var MAX_BRIDGE_REQUEST_BYTES = 1024 * 1024;
|
|
56631
56691
|
|
|
@@ -56702,7 +56762,7 @@ class DecisionBridgeServer {
|
|
|
56702
56762
|
});
|
|
56703
56763
|
} catch (err) {
|
|
56704
56764
|
if (process.platform !== "win32") {
|
|
56705
|
-
await rm(
|
|
56765
|
+
await rm(join5(path, ".."), { recursive: true, force: true }).catch(() => {});
|
|
56706
56766
|
}
|
|
56707
56767
|
throw err;
|
|
56708
56768
|
}
|
|
@@ -56715,7 +56775,7 @@ class DecisionBridgeServer {
|
|
|
56715
56775
|
socket.destroy();
|
|
56716
56776
|
await new Promise((resolve4) => this.server.close(() => resolve4()));
|
|
56717
56777
|
if (process.platform !== "win32") {
|
|
56718
|
-
await rm(
|
|
56778
|
+
await rm(join5(this.path, ".."), { recursive: true, force: true }).catch(() => {});
|
|
56719
56779
|
}
|
|
56720
56780
|
}
|
|
56721
56781
|
}
|
|
@@ -56773,9 +56833,9 @@ init_version_check();
|
|
|
56773
56833
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
56774
56834
|
import { resolve as resolve4, dirname as dirname5 } from "path";
|
|
56775
56835
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
56776
|
-
import { existsSync as existsSync4, readFileSync as readFileSync3, watchFile, unwatchFile, unlinkSync, statSync, readdirSync, writeFileSync } from "fs";
|
|
56836
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, watchFile, unwatchFile, unlinkSync, statSync, readdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
56777
56837
|
import { tmpdir as tmpdir2 } from "os";
|
|
56778
|
-
import { join as
|
|
56838
|
+
import { join as join6 } from "path";
|
|
56779
56839
|
|
|
56780
56840
|
// src/mcp/outbound-env.ts
|
|
56781
56841
|
var OUTBOUND_ENV = {
|
|
@@ -56875,25 +56935,25 @@ function parseRateLimitEvent(event, now = Date.now()) {
|
|
|
56875
56935
|
}
|
|
56876
56936
|
|
|
56877
56937
|
// src/claude/cli.ts
|
|
56878
|
-
var
|
|
56938
|
+
var log11 = createLogger("claude");
|
|
56879
56939
|
function cleanupBrowserBridgeSockets() {
|
|
56880
56940
|
try {
|
|
56881
56941
|
const tempDir = tmpdir2();
|
|
56882
56942
|
const files = readdirSync(tempDir);
|
|
56883
56943
|
for (const file2 of files) {
|
|
56884
56944
|
if (file2.startsWith("claude-mcp-browser-bridge-")) {
|
|
56885
|
-
const filePath =
|
|
56945
|
+
const filePath = join6(tempDir, file2);
|
|
56886
56946
|
try {
|
|
56887
56947
|
const stats = statSync(filePath);
|
|
56888
56948
|
if (stats.isSocket()) {
|
|
56889
56949
|
unlinkSync(filePath);
|
|
56890
|
-
|
|
56950
|
+
log11.debug(`Removed stale browser bridge socket: ${file2}`);
|
|
56891
56951
|
}
|
|
56892
56952
|
} catch {}
|
|
56893
56953
|
}
|
|
56894
56954
|
}
|
|
56895
56955
|
} catch (err) {
|
|
56896
|
-
|
|
56956
|
+
log11.debug(`Browser bridge cleanup failed: ${err}`);
|
|
56897
56957
|
}
|
|
56898
56958
|
}
|
|
56899
56959
|
function buildClaudeChildEnv(parentEnv, account, opts) {
|
|
@@ -56915,9 +56975,13 @@ function buildClaudeChildEnv(parentEnv, account, opts) {
|
|
|
56915
56975
|
env.USERPROFILE = account.home;
|
|
56916
56976
|
delete env.ANTHROPIC_API_KEY;
|
|
56917
56977
|
delete env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
56978
|
+
delete env.ANTHROPIC_AUTH_TOKEN;
|
|
56979
|
+
delete env.CLAUDE_CONFIG_DIR;
|
|
56980
|
+
delete env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
|
|
56918
56981
|
} else if (account?.apiKey) {
|
|
56919
56982
|
env.ANTHROPIC_API_KEY = account.apiKey;
|
|
56920
56983
|
delete env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
56984
|
+
delete env.ANTHROPIC_AUTH_TOKEN;
|
|
56921
56985
|
}
|
|
56922
56986
|
return env;
|
|
56923
56987
|
}
|
|
@@ -56952,8 +57016,8 @@ function materializeMcpConfig(config3, sessionId, opts = {}) {
|
|
|
56952
57016
|
return { mode: "inline", value: JSON.stringify(config3) };
|
|
56953
57017
|
}
|
|
56954
57018
|
const dir = opts.tmpDirOverride ?? tmpdir2();
|
|
56955
|
-
const path =
|
|
56956
|
-
|
|
57019
|
+
const path = join6(dir, `claude-threads-mcp-${sessionId ?? process.pid}-${Date.now()}.json`);
|
|
57020
|
+
writeFileSync2(path, JSON.stringify(config3), { mode: 384 });
|
|
56957
57021
|
return { mode: "file", path };
|
|
56958
57022
|
}
|
|
56959
57023
|
function buildPermissionArgs(opts) {
|
|
@@ -57149,7 +57213,7 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
57149
57213
|
}
|
|
57150
57214
|
let statusLineCommand;
|
|
57151
57215
|
if (this.options.sessionId) {
|
|
57152
|
-
this.statusFilePath =
|
|
57216
|
+
this.statusFilePath = join6(tmpdir2(), `claude-threads-status-${this.options.sessionId}.json`);
|
|
57153
57217
|
const statusLineWriterPath = this.getStatusLineWriterPath();
|
|
57154
57218
|
const runtime = runtimeForScriptPath(statusLineWriterPath);
|
|
57155
57219
|
statusLineCommand = `${runtime} ${statusLineWriterPath} ${this.options.sessionId}`;
|
|
@@ -58119,7 +58183,7 @@ handlers.set("model", createPassthroughHandler("model"));
|
|
|
58119
58183
|
handlers.set("effort", createPassthroughHandler("effort"));
|
|
58120
58184
|
// src/commands/system-prompt-generator.ts
|
|
58121
58185
|
init_logger();
|
|
58122
|
-
var
|
|
58186
|
+
var log12 = createLogger("system-prompt");
|
|
58123
58187
|
function formatUserCommand(cmd) {
|
|
58124
58188
|
const cmdStr = cmd.args ? `\`!${cmd.command} ${cmd.args}\`` : `\`!${cmd.command}\``;
|
|
58125
58189
|
const description = cmd.description;
|
|
@@ -58211,7 +58275,7 @@ ${avoidCommands.map((c) => `- \`!${c.command}\` - ${c.reason}`).join(`
|
|
|
58211
58275
|
}
|
|
58212
58276
|
// src/utils/error-handler/index.ts
|
|
58213
58277
|
init_logger();
|
|
58214
|
-
var
|
|
58278
|
+
var log13 = createLogger("error");
|
|
58215
58279
|
|
|
58216
58280
|
// src/session/lifecycle.ts
|
|
58217
58281
|
init_logger();
|
|
@@ -58234,35 +58298,35 @@ init_emoji();
|
|
|
58234
58298
|
init_spawn();
|
|
58235
58299
|
import * as path from "path";
|
|
58236
58300
|
init_logger();
|
|
58237
|
-
import { homedir as
|
|
58238
|
-
var
|
|
58239
|
-
var WORKTREES_DIR = path.join(
|
|
58240
|
-
var METADATA_STORE_PATH = path.join(
|
|
58301
|
+
import { homedir as homedir5 } from "os";
|
|
58302
|
+
var log14 = createLogger("git-wt");
|
|
58303
|
+
var WORKTREES_DIR = path.join(homedir5(), ".claude-threads", "worktrees");
|
|
58304
|
+
var METADATA_STORE_PATH = path.join(homedir5(), ".claude-threads", "worktree-metadata.json");
|
|
58241
58305
|
|
|
58242
58306
|
// src/operations/post-helpers/index.ts
|
|
58243
|
-
var
|
|
58244
|
-
var sessionLog = createSessionLog(
|
|
58307
|
+
var log15 = createLogger("helpers");
|
|
58308
|
+
var sessionLog = createSessionLog(log15);
|
|
58245
58309
|
|
|
58246
58310
|
// src/operations/suggestions/title.ts
|
|
58247
58311
|
init_quick_query();
|
|
58248
58312
|
init_logger();
|
|
58249
|
-
var
|
|
58313
|
+
var log17 = createLogger("title");
|
|
58250
58314
|
|
|
58251
58315
|
// src/operations/suggestions/tag.ts
|
|
58252
58316
|
init_quick_query();
|
|
58253
58317
|
init_logger();
|
|
58254
|
-
var
|
|
58318
|
+
var log18 = createLogger("tags");
|
|
58255
58319
|
|
|
58256
58320
|
// src/session/metadata-suggestions.ts
|
|
58257
58321
|
init_logger();
|
|
58258
|
-
var
|
|
58259
|
-
var sessionLog2 = createSessionLog(
|
|
58322
|
+
var log19 = createLogger("session");
|
|
58323
|
+
var sessionLog2 = createSessionLog(log19);
|
|
58260
58324
|
|
|
58261
58325
|
// src/operations/context-prompt/handler.ts
|
|
58262
58326
|
init_emoji();
|
|
58263
58327
|
init_logger();
|
|
58264
|
-
var
|
|
58265
|
-
var sessionLog3 = createSessionLog(
|
|
58328
|
+
var log20 = createLogger("context");
|
|
58329
|
+
var sessionLog3 = createSessionLog(log20);
|
|
58266
58330
|
var contextPromptTimeouts = new Map;
|
|
58267
58331
|
var contextPromptFiles = new Map;
|
|
58268
58332
|
// src/memory/store.ts
|
|
@@ -58273,33 +58337,11 @@ import {
|
|
|
58273
58337
|
readFileSync as readFileSync4,
|
|
58274
58338
|
realpathSync
|
|
58275
58339
|
} 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
|
|
58340
|
+
import { homedir as homedir6 } from "os";
|
|
58341
|
+
import { basename as basename3, dirname as dirname7, join as join8, sep as sep2 } from "path";
|
|
58300
58342
|
init_logger();
|
|
58301
|
-
var
|
|
58302
|
-
var DEFAULT_ROOT =
|
|
58343
|
+
var log21 = createLogger("memory");
|
|
58344
|
+
var DEFAULT_ROOT = join8(homedir6(), ".config", "claude-threads", "memory");
|
|
58303
58345
|
var CHANNEL_BLOCK_MAX_LINES = 200;
|
|
58304
58346
|
var CHANNEL_BLOCK_MAX_BYTES = 25 * 1024;
|
|
58305
58347
|
var CHANNEL_FILE_MAX_ENTRIES = 400;
|
|
@@ -58344,10 +58386,10 @@ class MemoryStore {
|
|
|
58344
58386
|
return this.root;
|
|
58345
58387
|
}
|
|
58346
58388
|
channelMemoryPath(platformId) {
|
|
58347
|
-
return
|
|
58389
|
+
return join8(this.root, platformSegment(platformId), "channel", "MEMORY.md");
|
|
58348
58390
|
}
|
|
58349
58391
|
repoMemoryDir(platformId, repoKey) {
|
|
58350
|
-
const dir =
|
|
58392
|
+
const dir = join8(this.root, platformSegment(platformId), "repos", repoKey);
|
|
58351
58393
|
this.ensureDir(dir);
|
|
58352
58394
|
return dir;
|
|
58353
58395
|
}
|
|
@@ -58394,7 +58436,7 @@ class MemoryStore {
|
|
|
58394
58436
|
if (result.added.length > 0) {
|
|
58395
58437
|
this.enforceFileCap(lines);
|
|
58396
58438
|
this.writeLines(platformId, lines);
|
|
58397
|
-
|
|
58439
|
+
log21.debug(`Channel memory for ${platformId}: +${result.added.length} entries` + (result.duplicates.length ? ` (${result.duplicates.length} duplicates skipped)` : ""));
|
|
58398
58440
|
}
|
|
58399
58441
|
return result;
|
|
58400
58442
|
});
|
|
@@ -58433,14 +58475,14 @@ class MemoryStore {
|
|
|
58433
58475
|
}
|
|
58434
58476
|
lines.splice(target.lineIndex, 1);
|
|
58435
58477
|
this.writeLines(platformId, lines);
|
|
58436
|
-
|
|
58478
|
+
log21.debug(`Channel memory for ${platformId}: removed one entry`);
|
|
58437
58479
|
return { ok: true, removed: target.entry };
|
|
58438
58480
|
});
|
|
58439
58481
|
}
|
|
58440
58482
|
clearChannel(platformId) {
|
|
58441
58483
|
return this.runExclusive(platformId, () => {
|
|
58442
58484
|
this.writeLines(platformId, []);
|
|
58443
|
-
|
|
58485
|
+
log21.debug(`Channel memory for ${platformId}: cleared`);
|
|
58444
58486
|
});
|
|
58445
58487
|
}
|
|
58446
58488
|
buildChannelMemoryBlock(platformId) {
|
|
@@ -58448,7 +58490,7 @@ class MemoryStore {
|
|
|
58448
58490
|
try {
|
|
58449
58491
|
lines = this.loadLines(platformId);
|
|
58450
58492
|
} catch (err) {
|
|
58451
|
-
|
|
58493
|
+
log21.warn(`Failed to read channel memory for ${platformId}: ${err.message}`);
|
|
58452
58494
|
return null;
|
|
58453
58495
|
}
|
|
58454
58496
|
if (lines.length === 0)
|
|
@@ -58532,7 +58574,7 @@ _(older entries omitted — \`!memory\` shows all)_` : rendered;
|
|
|
58532
58574
|
// src/memory/distiller.ts
|
|
58533
58575
|
init_quick_query();
|
|
58534
58576
|
init_logger();
|
|
58535
|
-
var
|
|
58577
|
+
var log22 = createLogger("memory");
|
|
58536
58578
|
|
|
58537
58579
|
// src/session/registry.ts
|
|
58538
58580
|
function compositeSessionId(platformId, threadId) {
|
|
@@ -58625,7 +58667,8 @@ class SessionRegistry {
|
|
|
58625
58667
|
return this.sessionStore.findByThread(platformId, threadId);
|
|
58626
58668
|
}
|
|
58627
58669
|
getPersistedByThreadId(threadId, platformId) {
|
|
58628
|
-
|
|
58670
|
+
const persisted = this.sessionStore.findByThreadIdAnyState(threadId, platformId);
|
|
58671
|
+
return persisted && isRevivable(persisted) ? persisted : undefined;
|
|
58629
58672
|
}
|
|
58630
58673
|
getSessionStore() {
|
|
58631
58674
|
return this.sessionStore;
|
|
@@ -58651,14 +58694,14 @@ class SessionRegistry {
|
|
|
58651
58694
|
init_emoji();
|
|
58652
58695
|
|
|
58653
58696
|
// src/persistence/routines-store.ts
|
|
58654
|
-
import { join as
|
|
58697
|
+
import { join as join10 } from "path";
|
|
58655
58698
|
init_logger();
|
|
58656
58699
|
|
|
58657
58700
|
// src/persistence/platform-list-store.ts
|
|
58658
58701
|
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 =
|
|
58702
|
+
import { homedir as homedir7 } from "os";
|
|
58703
|
+
import { join as join9 } from "path";
|
|
58704
|
+
var STORES_CONFIG_DIR = join9(homedir7(), ".config", "claude-threads");
|
|
58662
58705
|
var STORE_VERSION = 1;
|
|
58663
58706
|
|
|
58664
58707
|
class PlatformListStore {
|
|
@@ -58671,7 +58714,7 @@ class PlatformListStore {
|
|
|
58671
58714
|
this.collectionKey = collectionKey;
|
|
58672
58715
|
if (filePath) {
|
|
58673
58716
|
this.file = filePath;
|
|
58674
|
-
this.configDir =
|
|
58717
|
+
this.configDir = join9(filePath, "..");
|
|
58675
58718
|
} else {
|
|
58676
58719
|
this.file = defaultFile;
|
|
58677
58720
|
this.configDir = STORES_CONFIG_DIR;
|
|
@@ -58795,41 +58838,41 @@ class PlatformListStore {
|
|
|
58795
58838
|
}
|
|
58796
58839
|
|
|
58797
58840
|
// src/persistence/routines-store.ts
|
|
58798
|
-
var
|
|
58799
|
-
var DEFAULT_FILE =
|
|
58841
|
+
var log23 = createLogger("routines");
|
|
58842
|
+
var DEFAULT_FILE = join10(STORES_CONFIG_DIR, "routines.yaml");
|
|
58800
58843
|
|
|
58801
58844
|
// src/routines/parser.ts
|
|
58802
58845
|
init_logger();
|
|
58803
|
-
var
|
|
58846
|
+
var log24 = createLogger("routines");
|
|
58804
58847
|
|
|
58805
58848
|
// src/persistence/watches-store.ts
|
|
58806
|
-
import { join as
|
|
58849
|
+
import { join as join11 } from "path";
|
|
58807
58850
|
init_logger();
|
|
58808
|
-
var
|
|
58809
|
-
var DEFAULT_FILE2 =
|
|
58851
|
+
var log25 = createLogger("watches");
|
|
58852
|
+
var DEFAULT_FILE2 = join11(STORES_CONFIG_DIR, "watches.yaml");
|
|
58810
58853
|
|
|
58811
58854
|
// src/watches/parser.ts
|
|
58812
58855
|
init_logger();
|
|
58813
|
-
var
|
|
58856
|
+
var log26 = createLogger("watches");
|
|
58814
58857
|
|
|
58815
58858
|
// src/operations/commands/guards.ts
|
|
58816
58859
|
init_logger();
|
|
58817
|
-
var
|
|
58818
|
-
var sessionLog4 = createSessionLog(
|
|
58860
|
+
var log27 = createLogger("commands");
|
|
58861
|
+
var sessionLog4 = createSessionLog(log27);
|
|
58819
58862
|
|
|
58820
58863
|
// src/operations/commands/automation.ts
|
|
58821
58864
|
init_logger();
|
|
58822
|
-
var
|
|
58823
|
-
var sessionLog5 = createSessionLog(
|
|
58865
|
+
var log28 = createLogger("commands");
|
|
58866
|
+
var sessionLog5 = createSessionLog(log28);
|
|
58824
58867
|
|
|
58825
58868
|
// src/operations/agent-actions/handler.ts
|
|
58826
58869
|
init_logger();
|
|
58827
|
-
var
|
|
58828
|
-
var sessionLog6 = createSessionLog(
|
|
58870
|
+
var log29 = createLogger("agent-actions");
|
|
58871
|
+
var sessionLog6 = createSessionLog(log29);
|
|
58829
58872
|
|
|
58830
58873
|
// src/session/lifecycle.ts
|
|
58831
|
-
var
|
|
58832
|
-
var sessionLog7 = createSessionLog(
|
|
58874
|
+
var log30 = createLogger("lifecycle");
|
|
58875
|
+
var sessionLog7 = createSessionLog(log30);
|
|
58833
58876
|
var _inFlightSessionStarts = new Map;
|
|
58834
58877
|
var CHAT_PLATFORM_PROMPT = generateChatPlatformPrompt();
|
|
58835
58878
|
|
|
@@ -58842,39 +58885,39 @@ init_logger();
|
|
|
58842
58885
|
init_quick_query();
|
|
58843
58886
|
|
|
58844
58887
|
// src/persistence/github-emails-store.ts
|
|
58845
|
-
import { homedir as
|
|
58846
|
-
import { join as
|
|
58888
|
+
import { homedir as homedir8 } from "os";
|
|
58889
|
+
import { join as join12 } from "path";
|
|
58847
58890
|
init_logger();
|
|
58848
|
-
var
|
|
58849
|
-
var
|
|
58850
|
-
var DEFAULT_FILE3 =
|
|
58891
|
+
var log31 = createLogger("gh-emails");
|
|
58892
|
+
var DEFAULT_CONFIG_DIR2 = join12(homedir8(), ".config", "claude-threads");
|
|
58893
|
+
var DEFAULT_FILE3 = join12(DEFAULT_CONFIG_DIR2, "github-emails.yaml");
|
|
58851
58894
|
|
|
58852
58895
|
// src/operations/commands/handler.ts
|
|
58853
|
-
var
|
|
58854
|
-
var sessionLog8 = createSessionLog(
|
|
58896
|
+
var log32 = createLogger("commands");
|
|
58897
|
+
var sessionLog8 = createSessionLog(log32);
|
|
58855
58898
|
// src/operations/commands/memory.ts
|
|
58856
58899
|
init_logger();
|
|
58857
|
-
var
|
|
58858
|
-
var sessionLog9 = createSessionLog(
|
|
58900
|
+
var log33 = createLogger("commands");
|
|
58901
|
+
var sessionLog9 = createSessionLog(log33);
|
|
58859
58902
|
// src/operations/suggestions/branch.ts
|
|
58860
58903
|
init_quick_query();
|
|
58861
58904
|
init_logger();
|
|
58862
58905
|
import { exec as exec2 } from "child_process";
|
|
58863
58906
|
import { promisify as promisify2 } from "util";
|
|
58864
58907
|
var execAsync2 = promisify2(exec2);
|
|
58865
|
-
var
|
|
58908
|
+
var log34 = createLogger("branch");
|
|
58866
58909
|
|
|
58867
58910
|
// src/operations/worktree/handler.ts
|
|
58868
58911
|
init_logger();
|
|
58869
|
-
var
|
|
58870
|
-
var sessionLog10 = createSessionLog(
|
|
58912
|
+
var log35 = createLogger("worktree");
|
|
58913
|
+
var sessionLog10 = createSessionLog(log35);
|
|
58871
58914
|
// src/operations/events/handler.ts
|
|
58872
58915
|
init_logger();
|
|
58873
|
-
var
|
|
58874
|
-
var sessionLog11 = createSessionLog(
|
|
58916
|
+
var log36 = createLogger("events");
|
|
58917
|
+
var sessionLog11 = createSessionLog(log36);
|
|
58875
58918
|
// src/operations/monitor/handler.ts
|
|
58876
58919
|
init_logger();
|
|
58877
|
-
var
|
|
58920
|
+
var log37 = createLogger("monitor");
|
|
58878
58921
|
var DEFAULT_INTERVAL_MS = 60 * 1000;
|
|
58879
58922
|
// src/mcp/mcp-server.ts
|
|
58880
58923
|
init_logger();
|
|
@@ -58963,7 +59006,7 @@ init_logger();
|
|
|
58963
59006
|
// src/platform/mattermost/upload.ts
|
|
58964
59007
|
init_logger();
|
|
58965
59008
|
import { readFile } from "fs/promises";
|
|
58966
|
-
var
|
|
59009
|
+
var log38 = createLogger("mm-upload");
|
|
58967
59010
|
async function uploadFileMattermost(args) {
|
|
58968
59011
|
const { url: url2, token, channelId, threadId, filePath, filename, caption } = args;
|
|
58969
59012
|
const buffer = await readFile(filePath);
|
|
@@ -58971,7 +59014,7 @@ async function uploadFileMattermost(args) {
|
|
|
58971
59014
|
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
58972
59015
|
const formData = new FormData;
|
|
58973
59016
|
formData.append("files", new Blob([arrayBuffer]), filename);
|
|
58974
|
-
|
|
59017
|
+
log38.debug(`POST /files (${buffer.length} bytes, ${filename})`);
|
|
58975
59018
|
const uploadResponse = await fetch(uploadUrl, {
|
|
58976
59019
|
method: "POST",
|
|
58977
59020
|
headers: {
|
|
@@ -58995,7 +59038,7 @@ async function uploadFileMattermost(args) {
|
|
|
58995
59038
|
root_id: resolvePostThreadId(threadId),
|
|
58996
59039
|
file_ids: [fileInfo.id]
|
|
58997
59040
|
};
|
|
58998
|
-
|
|
59041
|
+
log38.debug(`POST /posts (file_ids=[${fileInfo.id}])`);
|
|
58999
59042
|
const postResponse = await fetch(postUrl, {
|
|
59000
59043
|
method: "POST",
|
|
59001
59044
|
headers: {
|
|
@@ -59493,7 +59536,7 @@ ${code}
|
|
|
59493
59536
|
// src/platform/slack/upload.ts
|
|
59494
59537
|
init_logger();
|
|
59495
59538
|
import { readFile as readFile2 } from "fs/promises";
|
|
59496
|
-
var
|
|
59539
|
+
var log39 = createLogger("slack-upload");
|
|
59497
59540
|
var DEFAULT_API_URL = "https://slack.com/api";
|
|
59498
59541
|
async function uploadFileSlack(args) {
|
|
59499
59542
|
const { botToken, channelId, threadTs, filePath, filename, caption } = args;
|
|
@@ -59501,7 +59544,7 @@ async function uploadFileSlack(args) {
|
|
|
59501
59544
|
const buffer = await readFile2(filePath);
|
|
59502
59545
|
const params = new URLSearchParams({ filename, length: String(buffer.length) });
|
|
59503
59546
|
const step1Url = `${apiUrl}/files.getUploadURLExternal?${params.toString()}`;
|
|
59504
|
-
|
|
59547
|
+
log39.debug(`GET files.getUploadURLExternal (${buffer.length} bytes, ${filename})`);
|
|
59505
59548
|
const step1Response = await fetch(step1Url, {
|
|
59506
59549
|
method: "GET",
|
|
59507
59550
|
headers: {
|
|
@@ -59519,7 +59562,7 @@ async function uploadFileSlack(args) {
|
|
|
59519
59562
|
const uploadUrl = step1Data.upload_url;
|
|
59520
59563
|
const fileId = step1Data.file_id;
|
|
59521
59564
|
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
59522
|
-
|
|
59565
|
+
log39.debug(`POST <upload_url>`);
|
|
59523
59566
|
const step2Response = await fetch(uploadUrl, {
|
|
59524
59567
|
method: "POST",
|
|
59525
59568
|
headers: {
|
|
@@ -59539,7 +59582,7 @@ async function uploadFileSlack(args) {
|
|
|
59539
59582
|
if (caption !== undefined) {
|
|
59540
59583
|
step3Body.initial_comment = caption;
|
|
59541
59584
|
}
|
|
59542
|
-
|
|
59585
|
+
log39.debug(`POST files.completeUploadExternal (file_id=${fileId}, thread_ts=${threadTs})`);
|
|
59543
59586
|
const step3Response = await fetch(`${apiUrl}/files.completeUploadExternal`, {
|
|
59544
59587
|
method: "POST",
|
|
59545
59588
|
headers: {
|
|
@@ -59557,7 +59600,7 @@ async function uploadFileSlack(args) {
|
|
|
59557
59600
|
throw new Error(`Slack completeUploadExternal error: ${step3Data.error || "unknown"}`);
|
|
59558
59601
|
}
|
|
59559
59602
|
if (!step3Data.ts) {
|
|
59560
|
-
|
|
59603
|
+
log39.warn(`Slack completeUploadExternal returned no ts; using fileId ${fileId} as postId. ` + `Do not use this id for updatePost/addReaction.`);
|
|
59561
59604
|
}
|
|
59562
59605
|
return { fileId, postId: step3Data.ts ?? fileId };
|
|
59563
59606
|
}
|