replicas-engine 0.1.870 → 0.1.871
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-TGECCL6C.js";
|
|
9
9
|
import "./chunk-VXF4AHJU.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-GN43A3FI.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
12
|
import "./chunk-XHX6IRSG.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
@@ -241,7 +241,7 @@ var DEFAULT_CODEX_ARGS = [
|
|
|
241
241
|
var MIN_CODEX_CLI_VERSION = "0.153.3";
|
|
242
242
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
243
243
|
var codexCliVersionEnsured = null;
|
|
244
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
244
|
+
var ENGINE_PACKAGE_VERSION = "0.1.871";
|
|
245
245
|
var INITIALIZE_METHOD = "initialize";
|
|
246
246
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
247
247
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
SUBPROCESS_MAX_BUFFER,
|
|
12
12
|
buildCodexAgentEnv,
|
|
13
13
|
execFileAsync
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-GN43A3FI.js";
|
|
15
15
|
import {
|
|
16
16
|
isRecord
|
|
17
17
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -244,7 +244,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
244
244
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
245
245
|
await this.applyCredentialsResponse(data);
|
|
246
246
|
if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
|
|
247
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
247
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-YN7ECDD4.js");
|
|
248
248
|
await restartCodexAspHostIfRunning2();
|
|
249
249
|
});
|
|
250
250
|
await this.start(true);
|
|
@@ -264,7 +264,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
264
264
|
await this.applyCredentialUpdate(generation, async () => {
|
|
265
265
|
await this.applyCredentialsResponse(data);
|
|
266
266
|
if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
|
|
267
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
267
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-YN7ECDD4.js");
|
|
268
268
|
await restartCodexAspHostIfRunning2();
|
|
269
269
|
}
|
|
270
270
|
if (data.scope) {
|
package/dist/src/index.js
CHANGED
|
@@ -132,7 +132,7 @@ import {
|
|
|
132
132
|
recordCredentialFallback,
|
|
133
133
|
recordExhaustedCredential,
|
|
134
134
|
restartCodexAspHost
|
|
135
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-TGECCL6C.js";
|
|
136
136
|
import {
|
|
137
137
|
ENGINE_ENV,
|
|
138
138
|
IS_WARMING_MODE,
|
|
@@ -145,7 +145,7 @@ import {
|
|
|
145
145
|
SUBPROCESS_MAX_BUFFER,
|
|
146
146
|
execAsync,
|
|
147
147
|
execFileAsync
|
|
148
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-GN43A3FI.js";
|
|
149
149
|
import {
|
|
150
150
|
isRecord as isRecord2
|
|
151
151
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -61553,9 +61553,13 @@ var ChatService = class {
|
|
|
61553
61553
|
event: acceptedEvent,
|
|
61554
61554
|
...recordedSender ? { sender: recordedSender } : {}
|
|
61555
61555
|
}
|
|
61556
|
+
}).catch((error) => {
|
|
61557
|
+
console.error("[ChatService] Failed to publish accepted turn:", { chatId, messageId: result.messageId, error });
|
|
61556
61558
|
});
|
|
61557
61559
|
if (chat.persisted.model !== previousModel) {
|
|
61558
|
-
await this.publish({ type: "chat.updated", payload: { chat: this.toSummary(chat) } })
|
|
61560
|
+
await this.publish({ type: "chat.updated", payload: { chat: this.toSummary(chat) } }).catch((error) => {
|
|
61561
|
+
console.error("[ChatService] Failed to publish accepted chat update:", { chatId, error });
|
|
61562
|
+
});
|
|
61559
61563
|
}
|
|
61560
61564
|
}
|
|
61561
61565
|
async appendSender(chatId, sender) {
|
|
@@ -61830,6 +61834,13 @@ var ChatService = class {
|
|
|
61830
61834
|
}
|
|
61831
61835
|
/** Resolves once the target chat exists; the handoff and its first turn run in the background. */
|
|
61832
61836
|
async forkChat(sourceChatId, request, trigger = "manual", reason) {
|
|
61837
|
+
const target = await this.createForkTarget(sourceChatId, request, trigger, reason);
|
|
61838
|
+
this.runFork(target.id, request).catch((error) => {
|
|
61839
|
+
console.error("[ChatService] Fork failed:", { sourceChatId, targetChatId: target.id, error });
|
|
61840
|
+
});
|
|
61841
|
+
return target;
|
|
61842
|
+
}
|
|
61843
|
+
async createForkTarget(sourceChatId, request, trigger, reason) {
|
|
61833
61844
|
const source = this.requireChat(sourceChatId);
|
|
61834
61845
|
const relayBaseProvider = await resolveRelayBaseProvider(request.provider, request.relayBaseProvider);
|
|
61835
61846
|
const executionProvider = request.provider === "relay" ? relayBaseProvider : request.provider;
|
|
@@ -61843,7 +61854,7 @@ var ChatService = class {
|
|
|
61843
61854
|
state: "preparing",
|
|
61844
61855
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
61845
61856
|
};
|
|
61846
|
-
|
|
61857
|
+
return this.createChat({
|
|
61847
61858
|
id: request.id,
|
|
61848
61859
|
provider: request.provider,
|
|
61849
61860
|
...relayBaseProvider ? { relayBaseProvider } : {},
|
|
@@ -61851,10 +61862,6 @@ var ChatService = class {
|
|
|
61851
61862
|
clientRequestId: request.clientRequestId,
|
|
61852
61863
|
fork
|
|
61853
61864
|
});
|
|
61854
|
-
this.runFork(target.id, request).catch((error) => {
|
|
61855
|
-
console.error("[ChatService] Fork failed:", { sourceChatId, targetChatId: target.id, error });
|
|
61856
|
-
});
|
|
61857
|
-
return target;
|
|
61858
61865
|
}
|
|
61859
61866
|
async createForkHandoffMessage(targetChatId, options) {
|
|
61860
61867
|
const source = this.requireChat(options.source.chatId);
|
|
@@ -61869,10 +61876,10 @@ var ChatService = class {
|
|
|
61869
61876
|
});
|
|
61870
61877
|
return formatChatForkHandoffMessage({ ...handoff, ...options });
|
|
61871
61878
|
}
|
|
61872
|
-
async runFork(targetId, request) {
|
|
61879
|
+
async runFork(targetId, request, errorNotificationTarget) {
|
|
61873
61880
|
const target = this.chats.get(targetId);
|
|
61874
61881
|
const fork = target?.persisted.fork;
|
|
61875
|
-
if (!target || !fork) return;
|
|
61882
|
+
if (!target || !fork) return false;
|
|
61876
61883
|
try {
|
|
61877
61884
|
if (!isAgentAvailable(getChatExecutionProvider(target.persisted))) throw new ChatProviderUnavailableError(request.provider);
|
|
61878
61885
|
const message = await this.createForkHandoffMessage(targetId, {
|
|
@@ -61881,7 +61888,7 @@ var ChatService = class {
|
|
|
61881
61888
|
reason: fork.reason,
|
|
61882
61889
|
message: request.message
|
|
61883
61890
|
});
|
|
61884
|
-
if (target.persisted.deletedAt) return;
|
|
61891
|
+
if (target.persisted.deletedAt) return false;
|
|
61885
61892
|
await this.sendMessage(targetId, {
|
|
61886
61893
|
message,
|
|
61887
61894
|
model: request.model,
|
|
@@ -61891,15 +61898,19 @@ var ChatService = class {
|
|
|
61891
61898
|
senderEmail: request.senderEmail,
|
|
61892
61899
|
senderDisplayName: request.senderDisplayName,
|
|
61893
61900
|
senderAvatarUrl: request.senderAvatarUrl,
|
|
61901
|
+
errorNotificationTarget,
|
|
61894
61902
|
idempotencyKey: `chat-fork:${targetId}`
|
|
61895
61903
|
});
|
|
61896
|
-
await this.updateFork(target, { state: "ready", completedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
61897
61904
|
} catch (error) {
|
|
61898
|
-
if (target.persisted.deletedAt) return;
|
|
61905
|
+
if (target.persisted.deletedAt) return false;
|
|
61899
61906
|
const message = error instanceof Error ? error.message : String(error);
|
|
61900
61907
|
await this.updateFork(target, { state: "failed", error: message.slice(0, 500), completedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
61901
61908
|
throw error;
|
|
61902
61909
|
}
|
|
61910
|
+
await this.updateFork(target, { state: "ready", completedAt: (/* @__PURE__ */ new Date()).toISOString() }).catch((error) => {
|
|
61911
|
+
console.error("[ChatService] Failed to finalize accepted fork:", { targetId, error });
|
|
61912
|
+
});
|
|
61913
|
+
return true;
|
|
61903
61914
|
}
|
|
61904
61915
|
async updateFork(chat, patch) {
|
|
61905
61916
|
if (!chat.persisted.fork) return;
|
|
@@ -61923,11 +61934,11 @@ var ChatService = class {
|
|
|
61923
61934
|
}
|
|
61924
61935
|
async autoForkAfterQuota(chat, exhaustion) {
|
|
61925
61936
|
const target = exhaustion.forkTo;
|
|
61926
|
-
if (!target || chat.persisted.deletedAt) return;
|
|
61937
|
+
if (!target || chat.persisted.deletedAt) return false;
|
|
61927
61938
|
const alreadyForked = [...this.chats.values()].some((other) => other.persisted.fork?.trigger === "auto" && other.persisted.fork.source.chatId === chat.persisted.id && !other.persisted.deletedAt);
|
|
61928
|
-
if (alreadyForked) return;
|
|
61939
|
+
if (alreadyForked) return false;
|
|
61929
61940
|
const last = chat.lastSendRequest;
|
|
61930
|
-
|
|
61941
|
+
const request = {
|
|
61931
61942
|
provider: target.provider,
|
|
61932
61943
|
relayBaseProvider: target.relayBaseProvider,
|
|
61933
61944
|
model: target.model,
|
|
@@ -61937,7 +61948,13 @@ var ChatService = class {
|
|
|
61937
61948
|
senderEmail: last?.senderEmail,
|
|
61938
61949
|
senderDisplayName: last?.senderDisplayName,
|
|
61939
61950
|
senderAvatarUrl: last?.senderAvatarUrl
|
|
61940
|
-
}
|
|
61951
|
+
};
|
|
61952
|
+
const fallback = await this.createForkTarget(chat.persisted.id, request, "auto", exhaustion.reason);
|
|
61953
|
+
const accepted = await this.runFork(fallback.id, request, chat.activeErrorNotificationTarget ?? void 0);
|
|
61954
|
+
if (!accepted) return false;
|
|
61955
|
+
chat.lastTurnErrors = null;
|
|
61956
|
+
chat.activeErrorNotificationTarget = null;
|
|
61957
|
+
return true;
|
|
61941
61958
|
}
|
|
61942
61959
|
async getChatHistory(chatId, page2 = {}) {
|
|
61943
61960
|
const chat = this.requireChat(chatId);
|
|
@@ -62316,7 +62333,8 @@ var ChatService = class {
|
|
|
62316
62333
|
this.endTrackedTurn(chatId);
|
|
62317
62334
|
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
62318
62335
|
const processing = chat.provider.getQueue().length > 0 || (chat.provider.hasActiveBackgroundTasks?.() ?? false);
|
|
62319
|
-
|
|
62336
|
+
const exhaustion = chat.quotaExhaustion;
|
|
62337
|
+
chat.quotaExhaustion = null;
|
|
62320
62338
|
uploadChatTranscript(
|
|
62321
62339
|
chatId,
|
|
62322
62340
|
join36(HISTORY_DIR_BY_PROVIDER[chat.persisted.provider], `${chatId}.jsonl`),
|
|
@@ -62327,14 +62345,17 @@ var ChatService = class {
|
|
|
62327
62345
|
flushAllCanvasItems().catch((err) => {
|
|
62328
62346
|
console.error("[ChatService] Failed to upload canvas items:", { chatId, err });
|
|
62329
62347
|
});
|
|
62330
|
-
|
|
62331
|
-
const exhaustion = chat.quotaExhaustion;
|
|
62332
|
-
chat.quotaExhaustion = null;
|
|
62348
|
+
let forked = false;
|
|
62333
62349
|
if (exhaustion) {
|
|
62334
|
-
|
|
62350
|
+
try {
|
|
62351
|
+
forked = await this.autoForkAfterQuota(chat, exhaustion);
|
|
62352
|
+
} catch (error) {
|
|
62335
62353
|
console.error("[ChatService] Automatic fork after quota limit failed:", { chatId, error });
|
|
62336
|
-
}
|
|
62354
|
+
}
|
|
62337
62355
|
}
|
|
62356
|
+
const stillProcessing = processing || forked;
|
|
62357
|
+
this.publishTurnCompleted(chat, completedAt, stillProcessing);
|
|
62358
|
+
await this.publishAgentTurnCompleteWebhook(chat, completedAt, stillProcessing);
|
|
62338
62359
|
this.notifyWorkspaceAgentIdle();
|
|
62339
62360
|
}
|
|
62340
62361
|
publishTurnCompleted(chat, completedAt, processing) {
|