replicas-engine 0.1.1034 → 0.1.1035
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.
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
getCodexAspHost,
|
|
6
6
|
restartCodexAspHost,
|
|
7
7
|
restartCodexAspHostIfRunning
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ST4ODIF2.js";
|
|
9
9
|
import "./chunk-WRAVQEOB.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-F52XMCMW.js";
|
|
11
11
|
import "./chunk-SEYXPQY7.js";
|
|
12
12
|
import "./chunk-UZSNFLDQ.js";
|
|
13
13
|
import "./chunk-MD2DJUY2.js";
|
|
@@ -240,7 +240,7 @@ function getCodexModelProvider(method) {
|
|
|
240
240
|
if (method === "foundry") return "azure";
|
|
241
241
|
return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
|
|
242
242
|
}
|
|
243
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
243
|
+
var ENGINE_PACKAGE_VERSION = "0.1.1035";
|
|
244
244
|
var INITIALIZE_METHOD = "initialize";
|
|
245
245
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
246
246
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
AppServerProcess,
|
|
11
11
|
buildCodexAgentEnv
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-F52XMCMW.js";
|
|
13
13
|
import {
|
|
14
14
|
SUBPROCESS_MAX_BUFFER,
|
|
15
15
|
execFileAsync
|
|
@@ -264,7 +264,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
264
264
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
265
265
|
await this.applyCredentialsResponse(data);
|
|
266
266
|
setAgentCredentialSnapshot("codex", data);
|
|
267
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
267
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-CRMYVVBY.js");
|
|
268
268
|
await restartCodexAspHostIfRunning2();
|
|
269
269
|
});
|
|
270
270
|
await this.start(true);
|
|
@@ -285,7 +285,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
285
285
|
const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
|
|
286
286
|
await this.applyCredentialsResponse(data);
|
|
287
287
|
if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
|
|
288
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
288
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-CRMYVVBY.js");
|
|
289
289
|
await restartCodexAspHostIfRunning2();
|
|
290
290
|
}
|
|
291
291
|
setAgentCredentialSnapshot("codex", data);
|
package/dist/src/index.js
CHANGED
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
refreshDelayMs,
|
|
72
72
|
restartCodexAspHost,
|
|
73
73
|
routineRefreshRequest
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-ST4ODIF2.js";
|
|
75
75
|
import {
|
|
76
76
|
ENGINE_ENV,
|
|
77
77
|
monolithRequest,
|
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
import {
|
|
84
84
|
AspClient,
|
|
85
85
|
getCodexModelProvider
|
|
86
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-F52XMCMW.js";
|
|
87
87
|
import {
|
|
88
88
|
SUBPROCESS_MAX_BUFFER,
|
|
89
89
|
execAsync,
|
|
@@ -11074,7 +11074,7 @@ async function registerDesktopPreview(signal) {
|
|
|
11074
11074
|
}
|
|
11075
11075
|
|
|
11076
11076
|
// src/services/chat/chat-service.ts
|
|
11077
|
-
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir20, readFile as readFile19, rename as rename4, rm as rm4 } from "fs/promises";
|
|
11077
|
+
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir20, readFile as readFile19, rename as rename4, rm as rm4, stat as stat7 } from "fs/promises";
|
|
11078
11078
|
import { join as join35 } from "path";
|
|
11079
11079
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
11080
11080
|
|
|
@@ -60325,7 +60325,7 @@ function shouldFlushChatTranscript(historyDir, chat, chatsById, sessionHistoryCa
|
|
|
60325
60325
|
if (!chat) return false;
|
|
60326
60326
|
return chat.parentChatId ? chatsById.has(chat.parentChatId) : sessionHistoryCapture;
|
|
60327
60327
|
}
|
|
60328
|
-
async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), capture) {
|
|
60328
|
+
async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), capture, onUploaded) {
|
|
60329
60329
|
let flushed = 0;
|
|
60330
60330
|
let failed = 0;
|
|
60331
60331
|
const revisions = [];
|
|
@@ -60343,9 +60343,12 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
|
|
|
60343
60343
|
const chat = chatsById.get(chatId);
|
|
60344
60344
|
if (!shouldFlushChatTranscript(dir, chat, chatsById, Boolean(capture))) continue;
|
|
60345
60345
|
tasks.push(
|
|
60346
|
-
uploadChatTranscript(chatId, join32(dir, entry), chat, capture).then((artifact) => {
|
|
60346
|
+
uploadChatTranscript(chatId, join32(dir, entry), chat, capture).then(async (artifact) => {
|
|
60347
60347
|
flushed++;
|
|
60348
60348
|
if (artifact && capture) revisions.push(artifact);
|
|
60349
|
+
await onUploaded?.(chatId, artifact).catch((err) => {
|
|
60350
|
+
console.error("[ChatTranscriptUploader] recording the uploaded history version failed:", { chatId, err });
|
|
60351
|
+
});
|
|
60349
60352
|
}).catch((err) => {
|
|
60350
60353
|
failed++;
|
|
60351
60354
|
console.error("[ChatTranscriptUploader] upload failed:", { chatId, err });
|
|
@@ -60368,8 +60371,10 @@ function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
|
60368
60371
|
return upload;
|
|
60369
60372
|
}
|
|
60370
60373
|
async function uploadChatTranscriptNow(chatId, filePath, chat, capture) {
|
|
60374
|
+
const versionBeforeStat = chat?.currentHistoryVersion?.();
|
|
60371
60375
|
const { size } = await stat5(filePath);
|
|
60372
60376
|
if (size === 0) return null;
|
|
60377
|
+
const historyVersion = versionBeforeStat === chat?.currentHistoryVersion?.() ? versionBeforeStat : void 0;
|
|
60373
60378
|
const metadata = chat ? {
|
|
60374
60379
|
provider: chat.provider,
|
|
60375
60380
|
// Chats with no turn since this engine version fall back to the auth live at upload.
|
|
@@ -60381,7 +60386,8 @@ async function uploadChatTranscriptNow(chatId, filePath, chat, capture) {
|
|
|
60381
60386
|
updatedAt: chat.updatedAt,
|
|
60382
60387
|
parentChatId: chat.parentChatId,
|
|
60383
60388
|
deletedAt: chat.deletedAt ?? null,
|
|
60384
|
-
fork: chat.fork ?? null
|
|
60389
|
+
fork: chat.fork ?? null,
|
|
60390
|
+
...historyVersion ? { historyVersion } : {}
|
|
60385
60391
|
} : {};
|
|
60386
60392
|
if (capture) {
|
|
60387
60393
|
const hash = createHash7("sha256");
|
|
@@ -60855,6 +60861,7 @@ function normalizePersistedChat(chat) {
|
|
|
60855
60861
|
...chat.chatCredential === "workspace" || agentCredentialSnapshotSchema.safeParse(chat.chatCredential).success ? { chatCredential: chat.chatCredential } : {},
|
|
60856
60862
|
transcriptAuth: normalizeTranscriptAuth(chat.transcriptAuth),
|
|
60857
60863
|
...typeof chat.lastSenderKey === "string" ? { lastSenderKey: chat.lastSenderKey } : {},
|
|
60864
|
+
...isRecord2(chat.uploadedHistory) && typeof chat.uploadedHistory.version === "string" && typeof chat.uploadedHistory.size === "number" ? { uploadedHistory: { version: chat.uploadedHistory.version, size: chat.uploadedHistory.size } } : {},
|
|
60858
60865
|
removedMessageIds: Array.isArray(chat.removedMessageIds) ? chat.removedMessageIds.filter((id) => typeof id === "string").slice(-MAX_REMOVED_MESSAGE_IDS) : [],
|
|
60859
60866
|
acceptedSendResponses: isRecord2(chat.acceptedSendResponses) ? Object.fromEntries(Object.entries(chat.acceptedSendResponses).filter((entry) => {
|
|
60860
60867
|
const response = entry[1];
|
|
@@ -60898,6 +60905,10 @@ var ChatService = class {
|
|
|
60898
60905
|
const persisted = await this.loadChats();
|
|
60899
60906
|
for (const chat of persisted) {
|
|
60900
60907
|
const runtime = this.createRuntimeChat(chat);
|
|
60908
|
+
if (chat.uploadedHistory) {
|
|
60909
|
+
const size = await stat7(this.historyPath(chat)).then(({ size: size2 }) => size2, () => null);
|
|
60910
|
+
if (size === chat.uploadedHistory.size) runtime.historyVersion = chat.uploadedHistory.version;
|
|
60911
|
+
}
|
|
60901
60912
|
this.chats.set(chat.id, runtime);
|
|
60902
60913
|
}
|
|
60903
60914
|
}
|
|
@@ -61515,7 +61526,7 @@ var ChatService = class {
|
|
|
61515
61526
|
return descendants;
|
|
61516
61527
|
}
|
|
61517
61528
|
async deleteHistoryFile(persisted) {
|
|
61518
|
-
const historyPath =
|
|
61529
|
+
const historyPath = this.historyPath(persisted);
|
|
61519
61530
|
await Promise.all([
|
|
61520
61531
|
historyPath,
|
|
61521
61532
|
`${historyPath}.pages.jsonl`,
|
|
@@ -61712,15 +61723,30 @@ var ChatService = class {
|
|
|
61712
61723
|
return count;
|
|
61713
61724
|
}
|
|
61714
61725
|
toTranscriptSource(chat) {
|
|
61715
|
-
return {
|
|
61726
|
+
return {
|
|
61727
|
+
...this.toSummary(chat),
|
|
61728
|
+
removedMessageIds: chat.persisted.removedMessageIds,
|
|
61729
|
+
transcriptAuth: chat.persisted.transcriptAuth,
|
|
61730
|
+
currentHistoryVersion: () => this.toSummary(chat).historyVersion
|
|
61731
|
+
};
|
|
61732
|
+
}
|
|
61733
|
+
historyPath(persisted) {
|
|
61734
|
+
return join35(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
|
|
61735
|
+
}
|
|
61736
|
+
async recordUploadedHistory(chatId, artifact) {
|
|
61737
|
+
const chat = this.getRuntimeChat(chatId);
|
|
61738
|
+
const version = artifact?.metadata.historyVersion;
|
|
61739
|
+
if (!chat || !artifact || !version || version !== this.toSummary(chat).historyVersion) return;
|
|
61740
|
+
chat.persisted.uploadedHistory = { version, size: artifact.size };
|
|
61741
|
+
await this.persistAllChats();
|
|
61716
61742
|
}
|
|
61717
61743
|
uploadChatTranscript(chat) {
|
|
61718
61744
|
const chatId = chat.persisted.id;
|
|
61719
61745
|
uploadChatTranscript(
|
|
61720
61746
|
chatId,
|
|
61721
|
-
|
|
61747
|
+
this.historyPath(chat.persisted),
|
|
61722
61748
|
this.toTranscriptSource(chat)
|
|
61723
|
-
).catch((err) => {
|
|
61749
|
+
).then((artifact) => this.recordUploadedHistory(chatId, artifact)).catch((err) => {
|
|
61724
61750
|
console.error("[ChatService] Failed to upload chat transcript:", { chatId, err });
|
|
61725
61751
|
});
|
|
61726
61752
|
}
|
|
@@ -61735,14 +61761,14 @@ var ChatService = class {
|
|
|
61735
61761
|
async flushAllChatTranscripts() {
|
|
61736
61762
|
return flushAllChatTranscripts(new Map(
|
|
61737
61763
|
[...this.chats.entries()].map(([chatId, chat]) => [chatId, this.toTranscriptSource(chat)])
|
|
61738
|
-
));
|
|
61764
|
+
), void 0, (chatId, artifact) => this.recordUploadedHistory(chatId, artifact));
|
|
61739
61765
|
}
|
|
61740
61766
|
async flushAllWorkspaceArtifacts(capture) {
|
|
61741
61767
|
const chatsById = new Map(
|
|
61742
61768
|
[...this.chats.entries()].map(([chatId, chat]) => [chatId, this.toTranscriptSource(chat)])
|
|
61743
61769
|
);
|
|
61744
61770
|
const [chatTranscripts, canvas, repoState, engineLogs, [chatActivity]] = await Promise.all([
|
|
61745
|
-
flushAllChatTranscripts(chatsById, capture),
|
|
61771
|
+
flushAllChatTranscripts(chatsById, capture, (chatId, artifact) => this.recordUploadedHistory(chatId, artifact)),
|
|
61746
61772
|
flushAllCanvasItems(),
|
|
61747
61773
|
flushRepoState(),
|
|
61748
61774
|
flushAllEngineLogs(),
|
|
@@ -62761,7 +62787,7 @@ var RepoFileService = class {
|
|
|
62761
62787
|
// src/v1-routes.ts
|
|
62762
62788
|
import { Hono } from "hono";
|
|
62763
62789
|
import { z as z5 } from "zod";
|
|
62764
|
-
import { readdir as readdir11, stat as
|
|
62790
|
+
import { readdir as readdir11, stat as stat8, readFile as readFile23 } from "fs/promises";
|
|
62765
62791
|
import { join as join40, resolve as resolve5 } from "path";
|
|
62766
62792
|
|
|
62767
62793
|
// src/services/warm-hooks-service.ts
|
|
@@ -64271,7 +64297,7 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
64271
64297
|
const sessions = await Promise.all(
|
|
64272
64298
|
logFiles.map(async (filename) => {
|
|
64273
64299
|
const filePath = join40(LOG_DIR, filename);
|
|
64274
|
-
const fileStat = await
|
|
64300
|
+
const fileStat = await stat8(filePath);
|
|
64275
64301
|
const sessionId = filename.replace(/\.log$/, "");
|
|
64276
64302
|
return {
|
|
64277
64303
|
sessionId,
|