replicas-engine 0.1.288 → 0.1.290
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 +106 -36
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -286,7 +286,7 @@ var WORKSPACE_SIZES = ["small", "large"];
|
|
|
286
286
|
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
287
287
|
|
|
288
288
|
// ../shared/src/e2b.ts
|
|
289
|
-
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-09-
|
|
289
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-09-v4";
|
|
290
290
|
|
|
291
291
|
// ../shared/src/runtime-env.ts
|
|
292
292
|
function parsePosixEnvFile(content) {
|
|
@@ -1991,6 +1991,7 @@ var DEFAULT_CHAT_TITLES = {
|
|
|
1991
1991
|
};
|
|
1992
1992
|
var CLAUDE_OPUS_1M_MODEL = "opus[1m]";
|
|
1993
1993
|
var LEGACY_CLAUDE_OPUS_1M_MODEL = "opus-1m";
|
|
1994
|
+
var CLAUDE_FABLE_5_MODEL = "claude-fable-5";
|
|
1994
1995
|
var DEFAULT_CODEX_MODEL = "gpt-5.5";
|
|
1995
1996
|
function normalizeClaudeModel(model) {
|
|
1996
1997
|
if (model === LEGACY_CLAUDE_OPUS_1M_MODEL) {
|
|
@@ -1998,11 +1999,17 @@ function normalizeClaudeModel(model) {
|
|
|
1998
1999
|
}
|
|
1999
2000
|
return model;
|
|
2000
2001
|
}
|
|
2002
|
+
var AGENT_MODELS = {
|
|
2003
|
+
claude: [CLAUDE_OPUS_1M_MODEL, CLAUDE_FABLE_5_MODEL, "sonnet", "haiku"],
|
|
2004
|
+
codex: [DEFAULT_CODEX_MODEL, "gpt-5.4", "gpt-5.4-mini", "gpt-5.3-codex", "gpt-5.3-codex-spark", "gpt-5.2-codex", "gpt-5.2", "gpt-5.1-codex-max", "gpt-5.1-codex", "gpt-5.1", "gpt-5-codex", "gpt-5"],
|
|
2005
|
+
relay: [CLAUDE_OPUS_1M_MODEL, CLAUDE_FABLE_5_MODEL, "sonnet"]
|
|
2006
|
+
};
|
|
2001
2007
|
var MODEL_LABELS = {
|
|
2002
2008
|
sonnet: "Sonnet 4.5",
|
|
2003
2009
|
opus: "Opus 4.8",
|
|
2004
2010
|
[CLAUDE_OPUS_1M_MODEL]: "Opus 4.8 (1M)",
|
|
2005
2011
|
[LEGACY_CLAUDE_OPUS_1M_MODEL]: "Opus 4.8 (1M)",
|
|
2012
|
+
[CLAUDE_FABLE_5_MODEL]: "Fable 5",
|
|
2006
2013
|
haiku: "Haiku 4.5",
|
|
2007
2014
|
[DEFAULT_CODEX_MODEL]: "GPT-5.5",
|
|
2008
2015
|
"gpt-5.4": "GPT-5.4",
|
|
@@ -4740,7 +4747,7 @@ async function registerDesktopPreview() {
|
|
|
4740
4747
|
|
|
4741
4748
|
// src/services/chat/chat-service.ts
|
|
4742
4749
|
import { existsSync as existsSync7 } from "fs";
|
|
4743
|
-
import { appendFile as
|
|
4750
|
+
import { appendFile as appendFile4, copyFile, mkdir as mkdir11, readFile as readFile9, rename as rename2, rm } from "fs/promises";
|
|
4744
4751
|
import { homedir as homedir12 } from "os";
|
|
4745
4752
|
import { join as join14 } from "path";
|
|
4746
4753
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
@@ -6587,7 +6594,7 @@ var AspClient = class {
|
|
|
6587
6594
|
// src/managers/codex-asp/app-server-process.ts
|
|
6588
6595
|
var DEFAULT_CODEX_BINARY = "codex";
|
|
6589
6596
|
var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
6590
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
6597
|
+
var ENGINE_PACKAGE_VERSION = "0.1.290";
|
|
6591
6598
|
var INITIALIZE_METHOD = "initialize";
|
|
6592
6599
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
6593
6600
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -7389,11 +7396,56 @@ var TranscriptUpdateCoalescer = class {
|
|
|
7389
7396
|
}
|
|
7390
7397
|
};
|
|
7391
7398
|
|
|
7399
|
+
// src/managers/codex-asp/codex-history-file.ts
|
|
7400
|
+
import { appendFile as appendFile3, readFile as readFile8 } from "fs/promises";
|
|
7401
|
+
function parseCodexHistoryJsonl(content) {
|
|
7402
|
+
const events = [];
|
|
7403
|
+
let transcript = null;
|
|
7404
|
+
for (const event of parseAgentEventJsonl(content)) {
|
|
7405
|
+
if (event.type !== CODEX_ASP_TRANSCRIPT_UPDATED_EVENT_TYPE) {
|
|
7406
|
+
events.push(event);
|
|
7407
|
+
continue;
|
|
7408
|
+
}
|
|
7409
|
+
const delta = event.payload.transcriptDelta;
|
|
7410
|
+
if (isCodexAspTranscriptDelta(delta)) {
|
|
7411
|
+
transcript = applyCodexAspTranscriptDelta(transcript, delta);
|
|
7412
|
+
} else if (isCodexAspTranscript(event.payload.transcript)) {
|
|
7413
|
+
transcript = event.payload.transcript;
|
|
7414
|
+
}
|
|
7415
|
+
}
|
|
7416
|
+
return { events, transcript };
|
|
7417
|
+
}
|
|
7418
|
+
var CodexHistoryFile = class {
|
|
7419
|
+
constructor(filePath) {
|
|
7420
|
+
this.filePath = filePath;
|
|
7421
|
+
}
|
|
7422
|
+
filePath;
|
|
7423
|
+
writeChain = Promise.resolve();
|
|
7424
|
+
/** Best-effort ordered append; failures must not disrupt the turn. */
|
|
7425
|
+
append(event) {
|
|
7426
|
+
this.writeChain = this.writeChain.then(() => appendFile3(this.filePath, JSON.stringify(event) + "\n", "utf-8")).catch((error) => {
|
|
7427
|
+
console.error("[CodexHistoryFile] Failed to append event:", error);
|
|
7428
|
+
});
|
|
7429
|
+
}
|
|
7430
|
+
async load() {
|
|
7431
|
+
try {
|
|
7432
|
+
const content = await readFile8(this.filePath, "utf-8");
|
|
7433
|
+
return parseCodexHistoryJsonl(content);
|
|
7434
|
+
} catch (error) {
|
|
7435
|
+
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) {
|
|
7436
|
+
console.error("[CodexHistoryFile] Failed to load history file:", error);
|
|
7437
|
+
}
|
|
7438
|
+
return { events: [], transcript: null };
|
|
7439
|
+
}
|
|
7440
|
+
}
|
|
7441
|
+
};
|
|
7442
|
+
|
|
7392
7443
|
// src/managers/codex-asp/codex-asp-manager.ts
|
|
7393
7444
|
var CodexAspManager = class extends CodingAgentManager {
|
|
7394
7445
|
currentThreadId = null;
|
|
7395
7446
|
activeTurnId = null;
|
|
7396
7447
|
threadAttached = false;
|
|
7448
|
+
historyFile;
|
|
7397
7449
|
historyEvents = [];
|
|
7398
7450
|
codexAspTranscript = null;
|
|
7399
7451
|
lastEmittedTranscripts = /* @__PURE__ */ new Map();
|
|
@@ -7405,12 +7457,18 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
7405
7457
|
});
|
|
7406
7458
|
constructor(options) {
|
|
7407
7459
|
super(options);
|
|
7460
|
+
this.historyFile = options.historyFilePath ? new CodexHistoryFile(options.historyFilePath) : null;
|
|
7408
7461
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
7409
7462
|
}
|
|
7410
7463
|
async initialize() {
|
|
7411
|
-
|
|
7412
|
-
|
|
7464
|
+
const replayed = await this.historyFile?.load();
|
|
7465
|
+
if (replayed) {
|
|
7466
|
+
this.historyEvents.push(...replayed.events);
|
|
7467
|
+
if (replayed.transcript) {
|
|
7468
|
+
this.mergeTranscriptSnapshot(replayed.transcript);
|
|
7469
|
+
}
|
|
7413
7470
|
}
|
|
7471
|
+
this.currentThreadId = this.initialSessionId ?? replayed?.transcript?.threadId ?? null;
|
|
7414
7472
|
}
|
|
7415
7473
|
async interruptActiveTurn() {
|
|
7416
7474
|
if (!this.currentThreadId || !this.activeTurnId) {
|
|
@@ -8124,9 +8182,13 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
8124
8182
|
type,
|
|
8125
8183
|
payload
|
|
8126
8184
|
};
|
|
8127
|
-
this.
|
|
8185
|
+
this.trackHistoryEvent(event);
|
|
8128
8186
|
return event;
|
|
8129
8187
|
}
|
|
8188
|
+
trackHistoryEvent(event) {
|
|
8189
|
+
this.historyEvents.push(event);
|
|
8190
|
+
this.historyFile?.append(event);
|
|
8191
|
+
}
|
|
8130
8192
|
emitTranscriptUpdated(threadId, options = {}) {
|
|
8131
8193
|
this.transcriptUpdateCoalescer.schedule(threadId, options);
|
|
8132
8194
|
}
|
|
@@ -8219,11 +8281,13 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
8219
8281
|
this.lastEmittedTranscripts.delete(emittedThreadId);
|
|
8220
8282
|
}
|
|
8221
8283
|
}
|
|
8222
|
-
|
|
8284
|
+
const event = {
|
|
8223
8285
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8224
8286
|
type: CODEX_ASP_TRANSCRIPT_UPDATED_EVENT_TYPE,
|
|
8225
8287
|
payload: updatePayload
|
|
8226
|
-
}
|
|
8288
|
+
};
|
|
8289
|
+
this.historyFile?.append(event);
|
|
8290
|
+
this.onEvent(event);
|
|
8227
8291
|
}
|
|
8228
8292
|
handleRateLimits(rateLimits) {
|
|
8229
8293
|
const snapshot = extractRateLimitsSnapshot(rateLimits);
|
|
@@ -8244,7 +8308,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
8244
8308
|
emitQuotaStatus(snapshot, force = false) {
|
|
8245
8309
|
const event = this.quotaStatus.apply(snapshot, force);
|
|
8246
8310
|
if (!event) return;
|
|
8247
|
-
this.
|
|
8311
|
+
this.trackHistoryEvent(event);
|
|
8248
8312
|
this.onEvent(event);
|
|
8249
8313
|
}
|
|
8250
8314
|
emitCodexTokenUsage(tokenUsage, model) {
|
|
@@ -8264,7 +8328,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
8264
8328
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8265
8329
|
});
|
|
8266
8330
|
const event = this.emitContextUsage(payload);
|
|
8267
|
-
this.
|
|
8331
|
+
this.trackHistoryEvent(event);
|
|
8268
8332
|
}
|
|
8269
8333
|
};
|
|
8270
8334
|
|
|
@@ -8370,7 +8434,7 @@ You will also receive the chatId so you can send follow-up messages or clean up
|
|
|
8370
8434
|
{
|
|
8371
8435
|
provider: providerEnum.describe(providerDesc),
|
|
8372
8436
|
prompt: z.string().describe("The full prompt/instructions for the subagent. Be detailed - it has no context from your conversation."),
|
|
8373
|
-
model: z.string().optional().describe(codexAvailable ?
|
|
8437
|
+
model: z.string().optional().describe(codexAvailable ? `Model override. Claude: ${AGENT_MODELS.claude.join(", ")} (opus[1m] is the default, 1M context, use for very large codebases or huge context tasks). Codex: gpt-5.5, gpt-5.4, gpt-5.3-codex, etc.` : `Model override. Claude: ${AGENT_MODELS.claude.join(", ")} (opus[1m] is the default, 1M context, use for very large codebases or huge context tasks).`),
|
|
8374
8438
|
thinking_level: z.enum(["low", "medium", "high", "max"]).optional().describe(
|
|
8375
8439
|
"Controls how much thinking/reasoning the subagent applies. low = light thinking, medium = moderate, high = deep reasoning, max = maximum effort. Defaults: Claude = high, Codex = medium."
|
|
8376
8440
|
),
|
|
@@ -8607,9 +8671,10 @@ function getUsingToolsSection() {
|
|
|
8607
8671
|
function getDelegationSection(codexAvailable) {
|
|
8608
8672
|
const providerList = codexAvailable ? "claude, codex, or relay" : "claude or relay";
|
|
8609
8673
|
const spawnDesc = `Create a new subagent with a specific provider (${providerList}), send it a prompt, and wait for its response. Returns the chatId and the agent's final response. You can set a custom timeout via the timeout_minutes parameter (default: 10 minutes).`;
|
|
8674
|
+
const claudeModelList = AGENT_MODELS.claude.join(", ");
|
|
8610
8675
|
const agentSelectionLines = codexAvailable ? `Use provider 'codex' for heavy code writing, implementation, and large refactors. Suggested models: gpt-5.5 (default), gpt-5.4, gpt-5.3-codex.
|
|
8611
8676
|
|
|
8612
|
-
Use provider 'claude' for codebase exploration, code review, planning, complex debugging, and tasks requiring nuanced architectural understanding. Suggested models: opus[1m]
|
|
8677
|
+
Use provider 'claude' for codebase exploration, code review, planning, complex debugging, and tasks requiring nuanced architectural understanding. Suggested models: ${claudeModelList} (opus[1m] is the default, 1M context window, use for very large codebases; sonnet is faster).` : `Use provider 'claude' for all tasks including code writing, codebase exploration, code review, planning, complex debugging, and tasks requiring nuanced architectural understanding. Suggested models: ${claudeModelList} (opus[1m] is the default, 1M context window, use for very large codebases; sonnet is faster).`;
|
|
8613
8678
|
return `# Delegation
|
|
8614
8679
|
|
|
8615
8680
|
You have three subagent tools for spawning and managing agents that run in separate context windows:
|
|
@@ -8873,6 +8938,12 @@ var ENGINE_DIR2 = join14(homedir12(), ".replicas", "engine");
|
|
|
8873
8938
|
var CHATS_FILE = join14(ENGINE_DIR2, "chats.json");
|
|
8874
8939
|
var CLAUDE_HISTORY_DIR = join14(ENGINE_DIR2, "claude-histories");
|
|
8875
8940
|
var RELAY_HISTORY_DIR = join14(ENGINE_DIR2, "relay-histories");
|
|
8941
|
+
var CODEX_HISTORY_DIR = join14(ENGINE_DIR2, "codex-histories");
|
|
8942
|
+
var HISTORY_DIR_BY_PROVIDER = {
|
|
8943
|
+
claude: CLAUDE_HISTORY_DIR,
|
|
8944
|
+
relay: RELAY_HISTORY_DIR,
|
|
8945
|
+
codex: CODEX_HISTORY_DIR
|
|
8946
|
+
};
|
|
8876
8947
|
var CHAT_SENDERS_DIR = join14(ENGINE_DIR2, "chat-senders");
|
|
8877
8948
|
var CODEX_AUTH_PATH2 = join14(homedir12(), ".codex", "auth.json");
|
|
8878
8949
|
var CHATS_BACKUP_FILE = `${CHATS_FILE}.bak`;
|
|
@@ -8973,6 +9044,7 @@ var ChatService = class {
|
|
|
8973
9044
|
await mkdir11(ENGINE_DIR2, { recursive: true });
|
|
8974
9045
|
await mkdir11(CLAUDE_HISTORY_DIR, { recursive: true });
|
|
8975
9046
|
await mkdir11(RELAY_HISTORY_DIR, { recursive: true });
|
|
9047
|
+
await mkdir11(CODEX_HISTORY_DIR, { recursive: true });
|
|
8976
9048
|
await mkdir11(CHAT_SENDERS_DIR, { recursive: true });
|
|
8977
9049
|
const persisted = await this.loadChats();
|
|
8978
9050
|
for (const chat of persisted) {
|
|
@@ -9075,14 +9147,14 @@ var ChatService = class {
|
|
|
9075
9147
|
}
|
|
9076
9148
|
async appendSender(chatId, sender) {
|
|
9077
9149
|
try {
|
|
9078
|
-
await
|
|
9150
|
+
await appendFile4(this.senderFilePath(chatId), JSON.stringify(sender) + "\n", "utf-8");
|
|
9079
9151
|
} catch (error) {
|
|
9080
9152
|
console.error("[ChatService] Failed to append sender record:", error);
|
|
9081
9153
|
}
|
|
9082
9154
|
}
|
|
9083
9155
|
async readSenders(chatId) {
|
|
9084
9156
|
try {
|
|
9085
|
-
const content = await
|
|
9157
|
+
const content = await readFile9(this.senderFilePath(chatId), "utf-8");
|
|
9086
9158
|
const lines = content.split("\n").filter((line) => line.trim().length > 0);
|
|
9087
9159
|
const senders = [];
|
|
9088
9160
|
for (const line of lines) {
|
|
@@ -9219,10 +9291,7 @@ var ChatService = class {
|
|
|
9219
9291
|
return descendants;
|
|
9220
9292
|
}
|
|
9221
9293
|
async deleteHistoryFile(persisted) {
|
|
9222
|
-
|
|
9223
|
-
const dir = persisted.provider === "claude" ? CLAUDE_HISTORY_DIR : RELAY_HISTORY_DIR;
|
|
9224
|
-
await rm(join14(dir, `${persisted.id}.jsonl`), { force: true });
|
|
9225
|
-
}
|
|
9294
|
+
await rm(join14(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`), { force: true });
|
|
9226
9295
|
await rm(this.senderFilePath(persisted.id), { force: true });
|
|
9227
9296
|
}
|
|
9228
9297
|
async getChatHistory(chatId) {
|
|
@@ -9298,6 +9367,7 @@ var ChatService = class {
|
|
|
9298
9367
|
} else {
|
|
9299
9368
|
provider = new CodexAspManager({
|
|
9300
9369
|
workingDirectory: this.workingDirectory,
|
|
9370
|
+
historyFilePath: join14(CODEX_HISTORY_DIR, `${persisted.id}.jsonl`),
|
|
9301
9371
|
initialSessionId: persisted.providerSessionId,
|
|
9302
9372
|
onSaveSessionId: saveSession,
|
|
9303
9373
|
onTurnComplete: onProviderTurnComplete,
|
|
@@ -9438,7 +9508,7 @@ var ChatService = class {
|
|
|
9438
9508
|
}
|
|
9439
9509
|
async loadChats() {
|
|
9440
9510
|
try {
|
|
9441
|
-
const content = await
|
|
9511
|
+
const content = await readFile9(CHATS_FILE, "utf-8");
|
|
9442
9512
|
return parsePersistedChatsContent(content);
|
|
9443
9513
|
} catch (error) {
|
|
9444
9514
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
@@ -9453,7 +9523,7 @@ var ChatService = class {
|
|
|
9453
9523
|
console.error("[ChatService] Failed to quarantine corrupt chats file:", renameError);
|
|
9454
9524
|
}
|
|
9455
9525
|
try {
|
|
9456
|
-
const backupContent = await
|
|
9526
|
+
const backupContent = await readFile9(CHATS_BACKUP_FILE, "utf-8");
|
|
9457
9527
|
return parsePersistedChatsContent(backupContent);
|
|
9458
9528
|
} catch (backupError) {
|
|
9459
9529
|
if (backupError && typeof backupError === "object" && "code" in backupError && backupError.code === "ENOENT") {
|
|
@@ -9538,7 +9608,7 @@ var ChatService = class {
|
|
|
9538
9608
|
|
|
9539
9609
|
// src/services/repo-file-service.ts
|
|
9540
9610
|
import { execFile as execFile2 } from "child_process";
|
|
9541
|
-
import { readFile as
|
|
9611
|
+
import { readFile as readFile10, realpath, stat as stat2 } from "fs/promises";
|
|
9542
9612
|
import { join as join15, resolve, extname } from "path";
|
|
9543
9613
|
var CACHE_TTL_MS = 3e4;
|
|
9544
9614
|
var SEARCH_TIMEOUT_MS = 15e3;
|
|
@@ -9728,7 +9798,7 @@ var RepoFileService = class {
|
|
|
9728
9798
|
tooLarge: true
|
|
9729
9799
|
};
|
|
9730
9800
|
}
|
|
9731
|
-
const content = await
|
|
9801
|
+
const content = await readFile10(fullPath, "utf-8");
|
|
9732
9802
|
return {
|
|
9733
9803
|
repoName,
|
|
9734
9804
|
path: filePath,
|
|
@@ -9806,11 +9876,11 @@ var RepoFileService = class {
|
|
|
9806
9876
|
// src/v1-routes.ts
|
|
9807
9877
|
import { Hono } from "hono";
|
|
9808
9878
|
import { z as z2 } from "zod";
|
|
9809
|
-
import { readdir as readdir6, stat as stat4, readFile as
|
|
9879
|
+
import { readdir as readdir6, stat as stat4, readFile as readFile15 } from "fs/promises";
|
|
9810
9880
|
import { join as join20, resolve as resolve2 } from "path";
|
|
9811
9881
|
|
|
9812
9882
|
// src/services/upload-chat-transcripts.ts
|
|
9813
|
-
import { readdir as readdir3, readFile as
|
|
9883
|
+
import { readdir as readdir3, readFile as readFile11 } from "fs/promises";
|
|
9814
9884
|
import { basename, join as join16 } from "path";
|
|
9815
9885
|
import { homedir as homedir13 } from "os";
|
|
9816
9886
|
var ENGINE_DIR3 = join16(homedir13(), ".replicas", "engine");
|
|
@@ -9846,7 +9916,7 @@ async function flushAllChatTranscripts() {
|
|
|
9846
9916
|
return { flushed, failed };
|
|
9847
9917
|
}
|
|
9848
9918
|
async function uploadOne(chatId, filePath) {
|
|
9849
|
-
const bytes = await
|
|
9919
|
+
const bytes = await readFile11(filePath);
|
|
9850
9920
|
if (bytes.byteLength === 0) return;
|
|
9851
9921
|
const form = new FormData();
|
|
9852
9922
|
form.append("chat_id", chatId);
|
|
@@ -9863,7 +9933,7 @@ async function uploadOne(chatId, filePath) {
|
|
|
9863
9933
|
}
|
|
9864
9934
|
|
|
9865
9935
|
// src/services/canvas-service.ts
|
|
9866
|
-
import { readdir as readdir4, readFile as
|
|
9936
|
+
import { readdir as readdir4, readFile as readFile12, stat as stat3 } from "fs/promises";
|
|
9867
9937
|
import { homedir as homedir14 } from "os";
|
|
9868
9938
|
import { basename as basename2, join as join17 } from "path";
|
|
9869
9939
|
var CANVAS_DIRECTORIES = [
|
|
@@ -9928,10 +9998,10 @@ var CanvasService = class {
|
|
|
9928
9998
|
}
|
|
9929
9999
|
try {
|
|
9930
10000
|
if (isTextKind(kind)) {
|
|
9931
|
-
const content = await
|
|
10001
|
+
const content = await readFile12(filePath, "utf-8");
|
|
9932
10002
|
return { filename: safe, kind, sizeBytes, mimeType, content };
|
|
9933
10003
|
}
|
|
9934
|
-
const buf = await
|
|
10004
|
+
const buf = await readFile12(filePath);
|
|
9935
10005
|
return { filename: safe, kind, sizeBytes, mimeType, base64: buf.toString("base64") };
|
|
9936
10006
|
} catch {
|
|
9937
10007
|
continue;
|
|
@@ -9944,12 +10014,12 @@ var canvasService = new CanvasService();
|
|
|
9944
10014
|
|
|
9945
10015
|
// src/services/warm-hooks-service.ts
|
|
9946
10016
|
import { spawn as spawn4 } from "child_process";
|
|
9947
|
-
import { readFile as
|
|
10017
|
+
import { readFile as readFile14 } from "fs/promises";
|
|
9948
10018
|
import { existsSync as existsSync8 } from "fs";
|
|
9949
10019
|
import { join as join19 } from "path";
|
|
9950
10020
|
|
|
9951
10021
|
// src/services/warm-hook-logs-service.ts
|
|
9952
|
-
import { mkdir as mkdir12, readFile as
|
|
10022
|
+
import { mkdir as mkdir12, readFile as readFile13, writeFile as writeFile6, readdir as readdir5, appendFile as appendFile5, unlink as unlink3 } from "fs/promises";
|
|
9953
10023
|
import { homedir as homedir15 } from "os";
|
|
9954
10024
|
import { join as join18 } from "path";
|
|
9955
10025
|
var LOGS_DIR2 = join18(homedir15(), ".replicas", "warm-hook-logs");
|
|
@@ -10009,7 +10079,7 @@ var WarmHookLogsService = class {
|
|
|
10009
10079
|
continue;
|
|
10010
10080
|
}
|
|
10011
10081
|
try {
|
|
10012
|
-
const raw = await
|
|
10082
|
+
const raw = await readFile13(join18(LOGS_DIR2, file), "utf-8");
|
|
10013
10083
|
const stored = JSON.parse(raw);
|
|
10014
10084
|
logs.push(withPreview2(stored));
|
|
10015
10085
|
} catch {
|
|
@@ -10034,11 +10104,11 @@ var WarmHookLogsService = class {
|
|
|
10034
10104
|
}
|
|
10035
10105
|
async appendCurrentRunLog(chunk) {
|
|
10036
10106
|
if (!chunk) return;
|
|
10037
|
-
await
|
|
10107
|
+
await appendFile5(CURRENT_RUN_LOG, chunk, "utf-8");
|
|
10038
10108
|
}
|
|
10039
10109
|
async getCurrentRunLog() {
|
|
10040
10110
|
try {
|
|
10041
|
-
return await
|
|
10111
|
+
return await readFile13(CURRENT_RUN_LOG, "utf-8");
|
|
10042
10112
|
} catch (err) {
|
|
10043
10113
|
if (err.code === "ENOENT") return null;
|
|
10044
10114
|
throw err;
|
|
@@ -10047,7 +10117,7 @@ var WarmHookLogsService = class {
|
|
|
10047
10117
|
async getFullOutput(hookType, hookName) {
|
|
10048
10118
|
const filename = hookType === "global" ? GLOBAL_FILENAME : hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
|
|
10049
10119
|
try {
|
|
10050
|
-
const raw = await
|
|
10120
|
+
const raw = await readFile13(join18(LOGS_DIR2, filename), "utf-8");
|
|
10051
10121
|
const stored = JSON.parse(raw);
|
|
10052
10122
|
if (stored.hookType !== hookType || stored.hookName !== hookName) {
|
|
10053
10123
|
return null;
|
|
@@ -10071,7 +10141,7 @@ async function readRepoWarmHook(repoPath) {
|
|
|
10071
10141
|
continue;
|
|
10072
10142
|
}
|
|
10073
10143
|
try {
|
|
10074
|
-
const raw = await
|
|
10144
|
+
const raw = await readFile14(configPath, "utf-8");
|
|
10075
10145
|
const config = parseReplicasConfigString(raw, filename);
|
|
10076
10146
|
if (!config.warmHook) {
|
|
10077
10147
|
return null;
|
|
@@ -11034,7 +11104,7 @@ function createV1Routes(deps) {
|
|
|
11034
11104
|
const limit = Math.min(parseInt(c.req.query("limit") || "500", 10), 5e3);
|
|
11035
11105
|
let content;
|
|
11036
11106
|
try {
|
|
11037
|
-
content = await
|
|
11107
|
+
content = await readFile15(filePath, "utf-8");
|
|
11038
11108
|
} catch {
|
|
11039
11109
|
return c.json(jsonError("Log session not found"), 404);
|
|
11040
11110
|
}
|