replicas-engine 0.1.331 → 0.1.333
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/src/index.js +82 -93
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -287,7 +287,7 @@ var WORKSPACE_SIZES = ["small", "large"];
|
|
|
287
287
|
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
288
288
|
|
|
289
289
|
// ../shared/src/e2b.ts
|
|
290
|
-
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-21-
|
|
290
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-21-v3";
|
|
291
291
|
|
|
292
292
|
// ../shared/src/runtime-env.ts
|
|
293
293
|
function parsePosixEnvFile(content) {
|
|
@@ -5026,7 +5026,7 @@ async function registerDesktopPreview() {
|
|
|
5026
5026
|
|
|
5027
5027
|
// src/services/chat/chat-service.ts
|
|
5028
5028
|
import { existsSync as existsSync7 } from "fs";
|
|
5029
|
-
import { appendFile as
|
|
5029
|
+
import { appendFile as appendFile3, copyFile, mkdir as mkdir12, readFile as readFile12, rename as rename2, rm } from "fs/promises";
|
|
5030
5030
|
import { homedir as homedir14 } from "os";
|
|
5031
5031
|
import { join as join18 } from "path";
|
|
5032
5032
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
@@ -5036,21 +5036,10 @@ import {
|
|
|
5036
5036
|
query
|
|
5037
5037
|
} from "@anthropic-ai/claude-agent-sdk";
|
|
5038
5038
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
5039
|
-
import { join as join14 } from "path";
|
|
5040
|
-
import { mkdir as mkdir10
|
|
5039
|
+
import { dirname as dirname4, join as join14 } from "path";
|
|
5040
|
+
import { mkdir as mkdir10 } from "fs/promises";
|
|
5041
5041
|
import { homedir as homedir11 } from "os";
|
|
5042
5042
|
|
|
5043
|
-
// src/utils/jsonl-reader.ts
|
|
5044
|
-
import { readFile as readFile8 } from "fs/promises";
|
|
5045
|
-
async function readJSONL(filePath) {
|
|
5046
|
-
try {
|
|
5047
|
-
const content = await readFile8(filePath, "utf-8");
|
|
5048
|
-
return parseAgentEventJsonl(content);
|
|
5049
|
-
} catch (error) {
|
|
5050
|
-
return [];
|
|
5051
|
-
}
|
|
5052
|
-
}
|
|
5053
|
-
|
|
5054
5043
|
// src/utils/linear-converter.ts
|
|
5055
5044
|
function linearThoughtToResponse(thought) {
|
|
5056
5045
|
return {
|
|
@@ -5887,7 +5876,7 @@ function extractToolCommand(input) {
|
|
|
5887
5876
|
}
|
|
5888
5877
|
|
|
5889
5878
|
// src/services/skill-registry-service.ts
|
|
5890
|
-
import { readFile as
|
|
5879
|
+
import { readFile as readFile8, readdir as readdir3, stat as stat2 } from "fs/promises";
|
|
5891
5880
|
import { dirname as dirname3, isAbsolute, join as join13, relative, resolve } from "path";
|
|
5892
5881
|
var REGISTRY_ROOT_DIR = ".replicas/skill-registries";
|
|
5893
5882
|
var REGISTRY_MANIFEST = "manifest.json";
|
|
@@ -6035,7 +6024,7 @@ async function installCodexRegistryPlugins(client, inventory) {
|
|
|
6035
6024
|
}
|
|
6036
6025
|
async function readManifest(homeDir) {
|
|
6037
6026
|
try {
|
|
6038
|
-
const raw = await
|
|
6027
|
+
const raw = await readFile8(getManifestPath(homeDir), "utf8");
|
|
6039
6028
|
const parsed = JSON.parse(raw);
|
|
6040
6029
|
if (!isManifest(parsed)) {
|
|
6041
6030
|
console.warn("[SkillRegistry] Ignoring invalid skill registry manifest.");
|
|
@@ -6128,6 +6117,36 @@ function isNotFoundError(error) {
|
|
|
6128
6117
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
6129
6118
|
}
|
|
6130
6119
|
|
|
6120
|
+
// src/managers/codex-asp/codex-history-file.ts
|
|
6121
|
+
import { appendFile as appendFile2, readFile as readFile9 } from "fs/promises";
|
|
6122
|
+
var CodexHistoryFile = class {
|
|
6123
|
+
constructor(filePath) {
|
|
6124
|
+
this.filePath = filePath;
|
|
6125
|
+
}
|
|
6126
|
+
filePath;
|
|
6127
|
+
writeChain = Promise.resolve();
|
|
6128
|
+
/** Best-effort ordered append; failures must not disrupt the turn. */
|
|
6129
|
+
append(event) {
|
|
6130
|
+
this.writeChain = this.writeChain.then(() => appendFile2(this.filePath, JSON.stringify(event) + "\n", "utf-8")).catch((error) => {
|
|
6131
|
+
console.error("[CodexHistoryFile] Failed to append event:", error);
|
|
6132
|
+
});
|
|
6133
|
+
}
|
|
6134
|
+
async flush() {
|
|
6135
|
+
await this.writeChain;
|
|
6136
|
+
}
|
|
6137
|
+
async load() {
|
|
6138
|
+
try {
|
|
6139
|
+
const content = await readFile9(this.filePath, "utf-8");
|
|
6140
|
+
return parseAgentEventJsonlWithCodexAspTranscript(content);
|
|
6141
|
+
} catch (error) {
|
|
6142
|
+
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) {
|
|
6143
|
+
console.error("[CodexHistoryFile] Failed to load history file:", error);
|
|
6144
|
+
}
|
|
6145
|
+
return { events: [], transcript: null };
|
|
6146
|
+
}
|
|
6147
|
+
}
|
|
6148
|
+
};
|
|
6149
|
+
|
|
6131
6150
|
// src/managers/claude-manager.ts
|
|
6132
6151
|
var PromptStream = class {
|
|
6133
6152
|
queue = [];
|
|
@@ -6315,6 +6334,7 @@ var TRANSIENT_RETRY_DELAYS_MS = [1e3, 2500];
|
|
|
6315
6334
|
var CLAUDE_TRANSIENT_HTTP_STATUSES = [408, 500, 502, 503, 504, 529];
|
|
6316
6335
|
var CLAUDE_MIDTURN_CONTINUE_PROMPT = "Your previous turn was interrupted by a transient network error before it could finish. Continue from exactly where you left off. Do not repeat any tool calls, commits, messages, or other actions you have already completed \u2014 first check what is already done, then do only the remaining work.";
|
|
6317
6336
|
var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
6337
|
+
historyFilePath;
|
|
6318
6338
|
historyFile;
|
|
6319
6339
|
sessionId = null;
|
|
6320
6340
|
activeQuery = null;
|
|
@@ -6339,7 +6359,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6339
6359
|
authRetrying = false;
|
|
6340
6360
|
constructor(options) {
|
|
6341
6361
|
super(options);
|
|
6342
|
-
this.
|
|
6362
|
+
this.historyFilePath = options.historyFilePath ?? join14(homedir11(), ".replicas", "claude", "history.jsonl");
|
|
6363
|
+
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
6343
6364
|
this.systemPromptOverride = options.systemPromptOverride;
|
|
6344
6365
|
this.toolsOverride = options.tools;
|
|
6345
6366
|
this.mcpServersConfig = options.mcpServers;
|
|
@@ -6401,7 +6422,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6401
6422
|
type,
|
|
6402
6423
|
payload: { ...payload, parent_tool_use_id: null }
|
|
6403
6424
|
};
|
|
6404
|
-
|
|
6425
|
+
this.historyFile.append(event);
|
|
6405
6426
|
this.onEvent(event);
|
|
6406
6427
|
}
|
|
6407
6428
|
buildCanUseTool() {
|
|
@@ -6551,6 +6572,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6551
6572
|
await this.emitAuthRetryExhaustedEvent(lastError);
|
|
6552
6573
|
}
|
|
6553
6574
|
try {
|
|
6575
|
+
await this.historyFile.flush();
|
|
6554
6576
|
await this.onTurnComplete();
|
|
6555
6577
|
} catch (error) {
|
|
6556
6578
|
console.error("[ClaudeManager] onTurnComplete failed:", error);
|
|
@@ -6559,7 +6581,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6559
6581
|
}
|
|
6560
6582
|
// `errors` is the field the dashboard renders (see claude-parser); `result` is
|
|
6561
6583
|
// only retained on the raw event for debugging. The user-facing message goes in `errors`.
|
|
6562
|
-
async emitTerminalErrorResult(result, errors
|
|
6584
|
+
async emitTerminalErrorResult(result, errors) {
|
|
6563
6585
|
const event = {
|
|
6564
6586
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6565
6587
|
type: "claude-result",
|
|
@@ -6573,27 +6595,21 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6573
6595
|
parent_tool_use_id: null
|
|
6574
6596
|
}
|
|
6575
6597
|
};
|
|
6576
|
-
|
|
6577
|
-
await appendFile2(this.historyFile, JSON.stringify(event) + "\n", "utf-8");
|
|
6578
|
-
} catch (writeError) {
|
|
6579
|
-
console.error(`[ClaudeManager] Failed to record ${logLabel} event:`, writeError);
|
|
6580
|
-
}
|
|
6598
|
+
this.historyFile.append(event);
|
|
6581
6599
|
this.onEvent(event);
|
|
6582
6600
|
}
|
|
6583
6601
|
async emitAuthRetryExhaustedEvent(error) {
|
|
6584
6602
|
const detail = error instanceof Error ? error.message : String(error);
|
|
6585
6603
|
await this.emitTerminalErrorResult(
|
|
6586
6604
|
detail,
|
|
6587
|
-
["Couldn't authenticate with Claude after multiple attempts. Check your credentials in Settings \u2192 Agents and try again."]
|
|
6588
|
-
"auth-retry-exhausted"
|
|
6605
|
+
["Couldn't authenticate with Claude after multiple attempts. Check your credentials in Settings \u2192 Agents and try again."]
|
|
6589
6606
|
);
|
|
6590
6607
|
}
|
|
6591
6608
|
async emitMidTurnExhaustedEvent(error) {
|
|
6592
6609
|
const detail = error instanceof Error ? error.message : String(error);
|
|
6593
6610
|
await this.emitTerminalErrorResult(
|
|
6594
6611
|
detail,
|
|
6595
|
-
["The connection to Claude dropped mid-response and could not be resumed after multiple attempts."]
|
|
6596
|
-
"mid-turn-exhausted"
|
|
6612
|
+
["The connection to Claude dropped mid-response and could not be resumed after multiple attempts."]
|
|
6597
6613
|
);
|
|
6598
6614
|
}
|
|
6599
6615
|
async executeQuery(request, options = {}) {
|
|
@@ -6964,7 +6980,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
6964
6980
|
try {
|
|
6965
6981
|
const usage = await response.getContextUsage();
|
|
6966
6982
|
const event = this.emitContextUsage(this.buildContextUsagePayload(usage));
|
|
6967
|
-
|
|
6983
|
+
this.historyFile.append(event);
|
|
6968
6984
|
} catch (error) {
|
|
6969
6985
|
console.warn("[ClaudeManager] Failed to record context usage:", error instanceof Error ? error.message : error);
|
|
6970
6986
|
}
|
|
@@ -7019,10 +7035,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
7019
7035
|
}
|
|
7020
7036
|
async getHistory() {
|
|
7021
7037
|
await this.initialized;
|
|
7022
|
-
|
|
7038
|
+
await this.historyFile.flush();
|
|
7039
|
+
const history = await this.historyFile.load();
|
|
7023
7040
|
return {
|
|
7024
7041
|
thread_id: this.sessionId,
|
|
7025
|
-
events
|
|
7042
|
+
events: history.events
|
|
7026
7043
|
};
|
|
7027
7044
|
}
|
|
7028
7045
|
partialMessageStreamKey(message) {
|
|
@@ -7100,8 +7117,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
7100
7117
|
}
|
|
7101
7118
|
}
|
|
7102
7119
|
async initialize() {
|
|
7103
|
-
|
|
7104
|
-
await mkdir10(historyDir, { recursive: true });
|
|
7120
|
+
await mkdir10(dirname4(this.historyFilePath), { recursive: true });
|
|
7105
7121
|
if (this.initialSessionId) {
|
|
7106
7122
|
this.sessionId = this.initialSessionId;
|
|
7107
7123
|
console.log(`[ClaudeManager] Restored session ID from persisted state: ${this.sessionId}`);
|
|
@@ -7138,7 +7154,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
7138
7154
|
type: `claude-${event.type}`,
|
|
7139
7155
|
payload: event
|
|
7140
7156
|
};
|
|
7141
|
-
|
|
7157
|
+
this.historyFile.append(jsonEvent);
|
|
7142
7158
|
this.onEvent(jsonEvent);
|
|
7143
7159
|
}
|
|
7144
7160
|
};
|
|
@@ -7339,7 +7355,7 @@ var AspClient = class {
|
|
|
7339
7355
|
// src/managers/codex-asp/app-server-process.ts
|
|
7340
7356
|
var DEFAULT_CODEX_BINARY = "codex";
|
|
7341
7357
|
var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
7342
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
7358
|
+
var ENGINE_PACKAGE_VERSION = "0.1.333";
|
|
7343
7359
|
var INITIALIZE_METHOD = "initialize";
|
|
7344
7360
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
7345
7361
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -8146,36 +8162,6 @@ var TranscriptUpdateCoalescer = class {
|
|
|
8146
8162
|
}
|
|
8147
8163
|
};
|
|
8148
8164
|
|
|
8149
|
-
// src/managers/codex-asp/codex-history-file.ts
|
|
8150
|
-
import { appendFile as appendFile3, readFile as readFile10 } from "fs/promises";
|
|
8151
|
-
var CodexHistoryFile = class {
|
|
8152
|
-
constructor(filePath) {
|
|
8153
|
-
this.filePath = filePath;
|
|
8154
|
-
}
|
|
8155
|
-
filePath;
|
|
8156
|
-
writeChain = Promise.resolve();
|
|
8157
|
-
/** Best-effort ordered append; failures must not disrupt the turn. */
|
|
8158
|
-
append(event) {
|
|
8159
|
-
this.writeChain = this.writeChain.then(() => appendFile3(this.filePath, JSON.stringify(event) + "\n", "utf-8")).catch((error) => {
|
|
8160
|
-
console.error("[CodexHistoryFile] Failed to append event:", error);
|
|
8161
|
-
});
|
|
8162
|
-
}
|
|
8163
|
-
async flush() {
|
|
8164
|
-
await this.writeChain;
|
|
8165
|
-
}
|
|
8166
|
-
async load() {
|
|
8167
|
-
try {
|
|
8168
|
-
const content = await readFile10(this.filePath, "utf-8");
|
|
8169
|
-
return parseAgentEventJsonlWithCodexAspTranscript(content);
|
|
8170
|
-
} catch (error) {
|
|
8171
|
-
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) {
|
|
8172
|
-
console.error("[CodexHistoryFile] Failed to load history file:", error);
|
|
8173
|
-
}
|
|
8174
|
-
return { events: [], transcript: null };
|
|
8175
|
-
}
|
|
8176
|
-
}
|
|
8177
|
-
};
|
|
8178
|
-
|
|
8179
8165
|
// src/managers/codex-asp/codex-asp-manager.ts
|
|
8180
8166
|
var CodexAspManager = class extends CodingAgentManager {
|
|
8181
8167
|
currentThreadId = null;
|
|
@@ -9138,28 +9124,32 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
9138
9124
|
};
|
|
9139
9125
|
|
|
9140
9126
|
// src/managers/cursor-manager.ts
|
|
9141
|
-
import {
|
|
9142
|
-
import { dirname as
|
|
9127
|
+
import { mkdir as mkdir11 } from "fs/promises";
|
|
9128
|
+
import { dirname as dirname5, join as join15 } from "path";
|
|
9143
9129
|
import { Agent as CursorAgent } from "@cursor/sdk";
|
|
9144
9130
|
var CursorManager = class extends CodingAgentManager {
|
|
9145
9131
|
agent = null;
|
|
9146
9132
|
activeRun = null;
|
|
9133
|
+
historyFilePath;
|
|
9147
9134
|
historyFile;
|
|
9148
9135
|
constructor(options) {
|
|
9149
9136
|
super(options);
|
|
9150
|
-
this.
|
|
9137
|
+
this.historyFilePath = options.historyFilePath ?? join15(ENGINE_ENV.HOME_DIR, ".replicas", "cursor", "history.jsonl");
|
|
9138
|
+
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
9151
9139
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
9152
9140
|
}
|
|
9153
9141
|
async initialize() {
|
|
9154
|
-
await mkdir11(
|
|
9142
|
+
await mkdir11(dirname5(this.historyFilePath), { recursive: true });
|
|
9155
9143
|
}
|
|
9156
9144
|
async interruptActiveTurn() {
|
|
9157
9145
|
await this.activeRun?.cancel();
|
|
9158
9146
|
}
|
|
9159
9147
|
async getHistory() {
|
|
9148
|
+
await this.historyFile.flush();
|
|
9149
|
+
const history = await this.historyFile.load();
|
|
9160
9150
|
return {
|
|
9161
9151
|
thread_id: this.agent?.agentId ?? this.initialSessionId,
|
|
9162
|
-
events:
|
|
9152
|
+
events: history.events,
|
|
9163
9153
|
goal: null
|
|
9164
9154
|
};
|
|
9165
9155
|
}
|
|
@@ -9213,6 +9203,7 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
9213
9203
|
});
|
|
9214
9204
|
} finally {
|
|
9215
9205
|
this.activeRun = null;
|
|
9206
|
+
await this.historyFile.flush();
|
|
9216
9207
|
await this.onTurnComplete();
|
|
9217
9208
|
}
|
|
9218
9209
|
}
|
|
@@ -9245,9 +9236,7 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
9245
9236
|
payload: eventPayload
|
|
9246
9237
|
};
|
|
9247
9238
|
this.onEvent(event);
|
|
9248
|
-
|
|
9249
|
-
`, "utf-8").catch(() => {
|
|
9250
|
-
});
|
|
9239
|
+
this.historyFile.append(event);
|
|
9251
9240
|
}
|
|
9252
9241
|
};
|
|
9253
9242
|
|
|
@@ -9830,7 +9819,7 @@ var KeepAliveService = class _KeepAliveService {
|
|
|
9830
9819
|
var keepAliveService = new KeepAliveService();
|
|
9831
9820
|
|
|
9832
9821
|
// src/services/canvas-service.ts
|
|
9833
|
-
import { readdir as readdir4, readFile as
|
|
9822
|
+
import { readdir as readdir4, readFile as readFile10, stat as stat3 } from "fs/promises";
|
|
9834
9823
|
import { homedir as homedir12 } from "os";
|
|
9835
9824
|
import { join as join16 } from "path";
|
|
9836
9825
|
var CANVAS_DIRECTORIES = [
|
|
@@ -9890,7 +9879,7 @@ var CanvasService = class {
|
|
|
9890
9879
|
};
|
|
9891
9880
|
}
|
|
9892
9881
|
try {
|
|
9893
|
-
const bytes = await
|
|
9882
|
+
const bytes = await readFile10(filePath);
|
|
9894
9883
|
return { filename: safe, kind, sizeBytes, mimeType, updatedAt, bytes };
|
|
9895
9884
|
} catch {
|
|
9896
9885
|
continue;
|
|
@@ -10005,7 +9994,7 @@ async function reconcileCanvasItems(filenames) {
|
|
|
10005
9994
|
}
|
|
10006
9995
|
|
|
10007
9996
|
// src/services/upload-chat-transcripts.ts
|
|
10008
|
-
import { readdir as readdir5, readFile as
|
|
9997
|
+
import { readdir as readdir5, readFile as readFile11 } from "fs/promises";
|
|
10009
9998
|
import { basename, join as join17 } from "path";
|
|
10010
9999
|
import { homedir as homedir13 } from "os";
|
|
10011
10000
|
var ENGINE_DIR2 = join17(homedir13(), ".replicas", "engine");
|
|
@@ -10042,7 +10031,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map()) {
|
|
|
10042
10031
|
return { flushed, failed };
|
|
10043
10032
|
}
|
|
10044
10033
|
async function uploadChatTranscript(chatId, filePath, chat) {
|
|
10045
|
-
const bytes = await
|
|
10034
|
+
const bytes = await readFile11(filePath);
|
|
10046
10035
|
if (bytes.byteLength === 0) return;
|
|
10047
10036
|
const form = new FormData();
|
|
10048
10037
|
form.append("chat_id", chatId);
|
|
@@ -10324,14 +10313,14 @@ var ChatService = class {
|
|
|
10324
10313
|
}
|
|
10325
10314
|
async appendSender(chatId, sender) {
|
|
10326
10315
|
try {
|
|
10327
|
-
await
|
|
10316
|
+
await appendFile3(this.senderFilePath(chatId), JSON.stringify(sender) + "\n", "utf-8");
|
|
10328
10317
|
} catch (error) {
|
|
10329
10318
|
console.error("[ChatService] Failed to append sender record:", error);
|
|
10330
10319
|
}
|
|
10331
10320
|
}
|
|
10332
10321
|
async readSenders(chatId) {
|
|
10333
10322
|
try {
|
|
10334
|
-
const content = await
|
|
10323
|
+
const content = await readFile12(this.senderFilePath(chatId), "utf-8");
|
|
10335
10324
|
const lines = content.split("\n").filter((line) => line.trim().length > 0);
|
|
10336
10325
|
const senders = [];
|
|
10337
10326
|
for (const line of lines) {
|
|
@@ -10730,7 +10719,7 @@ var ChatService = class {
|
|
|
10730
10719
|
}
|
|
10731
10720
|
async loadChats() {
|
|
10732
10721
|
try {
|
|
10733
|
-
const content = await
|
|
10722
|
+
const content = await readFile12(CHATS_FILE, "utf-8");
|
|
10734
10723
|
return parsePersistedChatsContent(content);
|
|
10735
10724
|
} catch (error) {
|
|
10736
10725
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
@@ -10745,7 +10734,7 @@ var ChatService = class {
|
|
|
10745
10734
|
console.error("[ChatService] Failed to quarantine corrupt chats file:", renameError);
|
|
10746
10735
|
}
|
|
10747
10736
|
try {
|
|
10748
|
-
const backupContent = await
|
|
10737
|
+
const backupContent = await readFile12(CHATS_BACKUP_FILE, "utf-8");
|
|
10749
10738
|
return parsePersistedChatsContent(backupContent);
|
|
10750
10739
|
} catch (backupError) {
|
|
10751
10740
|
if (backupError && typeof backupError === "object" && "code" in backupError && backupError.code === "ENOENT") {
|
|
@@ -10830,7 +10819,7 @@ var ChatService = class {
|
|
|
10830
10819
|
|
|
10831
10820
|
// src/services/repo-file-service.ts
|
|
10832
10821
|
import { execFile as execFile2 } from "child_process";
|
|
10833
|
-
import { readFile as
|
|
10822
|
+
import { readFile as readFile13, realpath, stat as stat4 } from "fs/promises";
|
|
10834
10823
|
import { join as join19, resolve as resolve2, extname } from "path";
|
|
10835
10824
|
var CACHE_TTL_MS = 3e4;
|
|
10836
10825
|
var SEARCH_TIMEOUT_MS = 15e3;
|
|
@@ -11020,7 +11009,7 @@ var RepoFileService = class {
|
|
|
11020
11009
|
tooLarge: true
|
|
11021
11010
|
};
|
|
11022
11011
|
}
|
|
11023
|
-
const content = await
|
|
11012
|
+
const content = await readFile13(fullPath, "utf-8");
|
|
11024
11013
|
return {
|
|
11025
11014
|
repoName,
|
|
11026
11015
|
path: filePath,
|
|
@@ -11098,17 +11087,17 @@ var RepoFileService = class {
|
|
|
11098
11087
|
// src/v1-routes.ts
|
|
11099
11088
|
import { Hono } from "hono";
|
|
11100
11089
|
import { z as z2 } from "zod";
|
|
11101
|
-
import { readdir as readdir7, stat as stat5, readFile as
|
|
11090
|
+
import { readdir as readdir7, stat as stat5, readFile as readFile16 } from "fs/promises";
|
|
11102
11091
|
import { join as join22, resolve as resolve3 } from "path";
|
|
11103
11092
|
|
|
11104
11093
|
// src/services/warm-hooks-service.ts
|
|
11105
11094
|
import { spawn as spawn4 } from "child_process";
|
|
11106
|
-
import { readFile as
|
|
11095
|
+
import { readFile as readFile15 } from "fs/promises";
|
|
11107
11096
|
import { existsSync as existsSync8 } from "fs";
|
|
11108
11097
|
import { join as join21 } from "path";
|
|
11109
11098
|
|
|
11110
11099
|
// src/services/warm-hook-logs-service.ts
|
|
11111
|
-
import { mkdir as mkdir13, readFile as
|
|
11100
|
+
import { mkdir as mkdir13, readFile as readFile14, writeFile as writeFile6, readdir as readdir6, appendFile as appendFile4, unlink as unlink3 } from "fs/promises";
|
|
11112
11101
|
import { homedir as homedir15 } from "os";
|
|
11113
11102
|
import { join as join20 } from "path";
|
|
11114
11103
|
var LOGS_DIR2 = join20(homedir15(), ".replicas", "warm-hook-logs");
|
|
@@ -11168,7 +11157,7 @@ var WarmHookLogsService = class {
|
|
|
11168
11157
|
continue;
|
|
11169
11158
|
}
|
|
11170
11159
|
try {
|
|
11171
|
-
const raw = await
|
|
11160
|
+
const raw = await readFile14(join20(LOGS_DIR2, file), "utf-8");
|
|
11172
11161
|
const stored = JSON.parse(raw);
|
|
11173
11162
|
logs.push(withPreview2(stored));
|
|
11174
11163
|
} catch {
|
|
@@ -11193,11 +11182,11 @@ var WarmHookLogsService = class {
|
|
|
11193
11182
|
}
|
|
11194
11183
|
async appendCurrentRunLog(chunk) {
|
|
11195
11184
|
if (!chunk) return;
|
|
11196
|
-
await
|
|
11185
|
+
await appendFile4(CURRENT_RUN_LOG, chunk, "utf-8");
|
|
11197
11186
|
}
|
|
11198
11187
|
async getCurrentRunLog() {
|
|
11199
11188
|
try {
|
|
11200
|
-
return await
|
|
11189
|
+
return await readFile14(CURRENT_RUN_LOG, "utf-8");
|
|
11201
11190
|
} catch (err) {
|
|
11202
11191
|
if (err.code === "ENOENT") return null;
|
|
11203
11192
|
throw err;
|
|
@@ -11206,7 +11195,7 @@ var WarmHookLogsService = class {
|
|
|
11206
11195
|
async getFullOutput(hookType, hookName) {
|
|
11207
11196
|
const filename = hookType === "global" ? GLOBAL_FILENAME : hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
|
|
11208
11197
|
try {
|
|
11209
|
-
const raw = await
|
|
11198
|
+
const raw = await readFile14(join20(LOGS_DIR2, filename), "utf-8");
|
|
11210
11199
|
const stored = JSON.parse(raw);
|
|
11211
11200
|
if (stored.hookType !== hookType || stored.hookName !== hookName) {
|
|
11212
11201
|
return null;
|
|
@@ -11230,7 +11219,7 @@ async function readRepoWarmHook(repoPath) {
|
|
|
11230
11219
|
continue;
|
|
11231
11220
|
}
|
|
11232
11221
|
try {
|
|
11233
|
-
const raw = await
|
|
11222
|
+
const raw = await readFile15(configPath, "utf-8");
|
|
11234
11223
|
const config = parseReplicasConfigString(raw, filename);
|
|
11235
11224
|
if (!config.warmHook) {
|
|
11236
11225
|
return null;
|
|
@@ -12217,7 +12206,7 @@ function createV1Routes(deps) {
|
|
|
12217
12206
|
const limit = Math.min(parseInt(c.req.query("limit") || "500", 10), 5e3);
|
|
12218
12207
|
let content;
|
|
12219
12208
|
try {
|
|
12220
|
-
content = await
|
|
12209
|
+
content = await readFile16(filePath, "utf-8");
|
|
12221
12210
|
} catch {
|
|
12222
12211
|
return c.json(jsonError("Log session not found"), 404);
|
|
12223
12212
|
}
|