replicas-engine 0.1.1218 → 0.1.1219
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/{asp-host-75VEUAF4.js → asp-host-Z3U5ZZHN.js} +2 -2
- package/dist/src/{chunk-DKXST643.js → chunk-3H5ASTAE.js} +1 -1
- package/dist/src/{chunk-ZDL63XNA.js → chunk-CLX52DRG.js} +3 -3
- package/dist/src/{chunk-EY4Q5K6P.js → chunk-OBWOTCX4.js} +1 -1
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +40 -14
- package/package.json +1 -1
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
listRunningCodexModels,
|
|
9
9
|
restartCodexAspHost,
|
|
10
10
|
restartCodexAspHostIfRunning
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-CLX52DRG.js";
|
|
12
12
|
import "./chunk-PS53BWCZ.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-3H5ASTAE.js";
|
|
14
14
|
import "./chunk-WOQM2PPJ.js";
|
|
15
15
|
import "./chunk-UZSNFLDQ.js";
|
|
16
16
|
import "./chunk-ATDZVO6Z.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.1219";
|
|
244
244
|
var INITIALIZE_METHOD = "initialize";
|
|
245
245
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
246
246
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
AppServerProcess,
|
|
16
16
|
buildCodexAgentEnv
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3H5ASTAE.js";
|
|
18
18
|
import {
|
|
19
19
|
SUBPROCESS_MAX_BUFFER,
|
|
20
20
|
execFileAsync
|
|
@@ -291,7 +291,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
291
291
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
292
292
|
await this.applyCredentialsResponse(data);
|
|
293
293
|
setAgentCredentialSnapshot("codex", data);
|
|
294
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
294
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-Z3U5ZZHN.js");
|
|
295
295
|
await restartCodexAspHostIfRunning2();
|
|
296
296
|
});
|
|
297
297
|
await this.start(true);
|
|
@@ -313,7 +313,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
313
313
|
const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
|
|
314
314
|
await this.applyCredentialsResponse(data);
|
|
315
315
|
if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
|
|
316
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
316
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-Z3U5ZZHN.js");
|
|
317
317
|
await restartCodexAspHostIfRunning2();
|
|
318
318
|
}
|
|
319
319
|
setAgentCredentialSnapshot("codex", data);
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
recoverCompletedTurn,
|
|
14
14
|
spawnMuseMsp,
|
|
15
15
|
startMuseSession
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-OBWOTCX4.js";
|
|
17
17
|
import {
|
|
18
18
|
AppServerProcess,
|
|
19
19
|
buildCodexAgentEnv
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-3H5ASTAE.js";
|
|
21
21
|
import "./chunk-WOQM2PPJ.js";
|
|
22
22
|
import {
|
|
23
23
|
AGENT,
|
package/dist/src/index.js
CHANGED
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
spawnMuseMsp,
|
|
65
65
|
startMuseSession,
|
|
66
66
|
uuidV7
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-OBWOTCX4.js";
|
|
68
68
|
import {
|
|
69
69
|
publishedPullRequestUrls
|
|
70
70
|
} from "./chunk-43FGSQ6T.js";
|
|
@@ -140,7 +140,7 @@ import {
|
|
|
140
140
|
timestampFromSeconds,
|
|
141
141
|
upsertCredentialFileLines,
|
|
142
142
|
writeSecureCredentialFile
|
|
143
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-CLX52DRG.js";
|
|
144
144
|
import {
|
|
145
145
|
ENGINE_ENV,
|
|
146
146
|
monolithRequest,
|
|
@@ -152,7 +152,7 @@ import {
|
|
|
152
152
|
} from "./chunk-PS53BWCZ.js";
|
|
153
153
|
import {
|
|
154
154
|
getCodexModelProvider
|
|
155
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-3H5ASTAE.js";
|
|
156
156
|
import {
|
|
157
157
|
SUBPROCESS_MAX_BUFFER,
|
|
158
158
|
execAsync,
|
|
@@ -11190,6 +11190,8 @@ var MessageQueueService = class {
|
|
|
11190
11190
|
acceptanceWithdrawals = /* @__PURE__ */ new WeakSet();
|
|
11191
11191
|
queueCancellationVersion = 0;
|
|
11192
11192
|
activeTurn = null;
|
|
11193
|
+
// Held while an idle-path acceptance persists, so nothing else can start a turn before it.
|
|
11194
|
+
starting = false;
|
|
11193
11195
|
constructor(processMessage, onProcessingChanged = () => {
|
|
11194
11196
|
}, onMessageStarted = async () => {
|
|
11195
11197
|
}, onQueueChanged = () => {
|
|
@@ -11243,14 +11245,17 @@ var MessageQueueService = class {
|
|
|
11243
11245
|
}
|
|
11244
11246
|
const messageId = request.messageId ?? this.generateMessageId();
|
|
11245
11247
|
const queuedMessage = {
|
|
11246
|
-
id: messageId,
|
|
11247
11248
|
...request,
|
|
11249
|
+
id: messageId,
|
|
11248
11250
|
// Providers stamp this id onto the transcript user event so history
|
|
11249
11251
|
// rendering can pair it with the accepted snapshot by identity.
|
|
11250
11252
|
messageId,
|
|
11251
11253
|
queuedAt: request.submittedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
11252
11254
|
};
|
|
11253
|
-
if (this.processing) {
|
|
11255
|
+
if (queuedMessage.engineTurn && (this.processing || this.starting)) {
|
|
11256
|
+
return { queued: false, messageId, position: 0 };
|
|
11257
|
+
}
|
|
11258
|
+
if (this.processing || this.starting) {
|
|
11254
11259
|
this.queue.push(queuedMessage);
|
|
11255
11260
|
this.onQueueChanged();
|
|
11256
11261
|
const response2 = {
|
|
@@ -11276,7 +11281,15 @@ var MessageQueueService = class {
|
|
|
11276
11281
|
messageId,
|
|
11277
11282
|
position: 0
|
|
11278
11283
|
};
|
|
11279
|
-
|
|
11284
|
+
this.starting = true;
|
|
11285
|
+
try {
|
|
11286
|
+
await onAccepted(response, queuedMessage);
|
|
11287
|
+
} catch (error) {
|
|
11288
|
+
this.starting = false;
|
|
11289
|
+
this.resumeIfIdle();
|
|
11290
|
+
throw error;
|
|
11291
|
+
}
|
|
11292
|
+
this.starting = false;
|
|
11280
11293
|
this.startProcessing(queuedMessage).catch((error) => {
|
|
11281
11294
|
console.error("[MessageQueue] Unhandled error in startProcessing:", error);
|
|
11282
11295
|
});
|
|
@@ -11304,7 +11317,7 @@ var MessageQueueService = class {
|
|
|
11304
11317
|
break;
|
|
11305
11318
|
}
|
|
11306
11319
|
if (!turn.signal.aborted) {
|
|
11307
|
-
await this.onMessageStarted(queuedMessage);
|
|
11320
|
+
if (!queuedMessage.engineTurn) await this.onMessageStarted(queuedMessage);
|
|
11308
11321
|
await this.processMessage(queuedMessage, turn.signal);
|
|
11309
11322
|
}
|
|
11310
11323
|
} catch (error) {
|
|
@@ -11367,7 +11380,7 @@ var MessageQueueService = class {
|
|
|
11367
11380
|
this.onQueueChanged();
|
|
11368
11381
|
}
|
|
11369
11382
|
resumeIfIdle() {
|
|
11370
|
-
if (this.processing || this.queue.length === 0) return;
|
|
11383
|
+
if (this.processing || this.starting || this.queue.length === 0) return;
|
|
11371
11384
|
void this.processNextInQueue().catch((error) => {
|
|
11372
11385
|
console.error("[MessageQueue] Error resuming idle queue:", error);
|
|
11373
11386
|
});
|
|
@@ -11532,7 +11545,7 @@ var CodingAgentManager = class {
|
|
|
11532
11545
|
await Promise.all([this.refreshSubagentMcp(), this.refreshAutoCompactTokens()]);
|
|
11533
11546
|
const { request: delivered, senderKey } = this.withSenderLine(request);
|
|
11534
11547
|
const stopped = signal.aborted;
|
|
11535
|
-
if (stopped && !await this.keepStoppedRequest(delivered)) return;
|
|
11548
|
+
if (stopped && (request.engineTurn || !await this.keepStoppedRequest(delivered))) return;
|
|
11536
11549
|
await this.saveLastSenderKey(senderKey);
|
|
11537
11550
|
if (stopped) return;
|
|
11538
11551
|
const instructionsChanged = this.sentTurn && this.lastCustomInstructions !== request.customInstructions && !request.goalMode && !request.message.trimStart().startsWith("/");
|
|
@@ -12683,6 +12696,7 @@ var MAX_MIDTURN_CONTINUE_RETRIES = 2;
|
|
|
12683
12696
|
var TRANSIENT_RETRY_DELAYS_MS = [1e3, 2500];
|
|
12684
12697
|
var CLAUDE_TRANSIENT_HTTP_STATUSES = [408, 500, 502, 503, 504, 529];
|
|
12685
12698
|
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.";
|
|
12699
|
+
var CLAUDE_BACKGROUND_TURN_CONTINUE_PROMPT = "Your previous turn was cut off by an error before it could finish, and the session was restarted, which stopped any background tasks or agents that were still running. Continue from where you left off: first check what is already done, rerun only the background work whose results you still need, and do not repeat tool calls, commits, or messages you have already completed.";
|
|
12686
12700
|
var CLAUDE_RETRY_PROMPT = "Your previous attempt to respond to the message above failed before producing a response. Respond to it now.";
|
|
12687
12701
|
function appendUserContent(earlier, later) {
|
|
12688
12702
|
const last = earlier.at(-1);
|
|
@@ -13085,7 +13099,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13085
13099
|
const steers = carriedSteers;
|
|
13086
13100
|
carriedSteers = /* @__PURE__ */ new Map();
|
|
13087
13101
|
try {
|
|
13088
|
-
await this.executeQuery(currentRequest, { skipUserMessageRecord: attempt > 0, signal, steers });
|
|
13102
|
+
await this.executeQuery(currentRequest, { skipUserMessageRecord: attempt > 0 || request.engineTurn, engineTurn: request.engineTurn, signal, steers });
|
|
13089
13103
|
return;
|
|
13090
13104
|
} catch (error) {
|
|
13091
13105
|
lastError = error;
|
|
@@ -13306,7 +13320,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13306
13320
|
const content = appendUserContent(this.unreadPrompt?.content ?? [], prompt);
|
|
13307
13321
|
if (this.pendingInterrupt || options.signal?.aborted) {
|
|
13308
13322
|
this.pendingInterrupt = false;
|
|
13309
|
-
this.unreadPrompt = { uuid: userMessage.uuid, content };
|
|
13323
|
+
if (!options.engineTurn) this.unreadPrompt = { uuid: userMessage.uuid, content };
|
|
13310
13324
|
return;
|
|
13311
13325
|
}
|
|
13312
13326
|
this.turnPromptRecorded = false;
|
|
@@ -13325,7 +13339,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13325
13339
|
});
|
|
13326
13340
|
} finally {
|
|
13327
13341
|
if (this.turnPromptRecorded) this.unreadPrompt = null;
|
|
13328
|
-
else if (options.signal?.aborted) this.unreadPrompt = { uuid: userMessage.uuid, content };
|
|
13342
|
+
else if (options.signal?.aborted && !options.engineTurn) this.unreadPrompt = { uuid: userMessage.uuid, content };
|
|
13329
13343
|
}
|
|
13330
13344
|
}
|
|
13331
13345
|
async buildUserMessage({ message, images }) {
|
|
@@ -13532,6 +13546,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13532
13546
|
let loopError = null;
|
|
13533
13547
|
let suppressLinearResponseFlush = false;
|
|
13534
13548
|
let creditsRequired = false;
|
|
13549
|
+
let turnFailed = false;
|
|
13535
13550
|
try {
|
|
13536
13551
|
while (true) {
|
|
13537
13552
|
const next = await iterator.next();
|
|
@@ -13544,6 +13559,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13544
13559
|
const turnError = authErrorMessage ? new ClaudeAuthError(authErrorMessage) : msg.type === "result" && msg.subtype !== "success" && msg.num_turns === 0 && msg.errors.some((err) => err.startsWith("No conversation found with session ID")) ? new ClaudeMissingSessionError(msg.errors.join("\n")) : _ClaudeManager.detectQuotaErrorInMessage(msg, creditsRequired) ?? (transientErrorMessage ? new ClaudeTransientTurnError(transientErrorMessage, this.pendingTurn?.sawActivity ?? false) : null);
|
|
13545
13560
|
if (turnError) {
|
|
13546
13561
|
suppressLinearResponseFlush = true;
|
|
13562
|
+
turnFailed = true;
|
|
13547
13563
|
this.failPendingTurn(turnError);
|
|
13548
13564
|
try {
|
|
13549
13565
|
response.close();
|
|
@@ -13598,6 +13614,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13598
13614
|
}
|
|
13599
13615
|
} catch (error) {
|
|
13600
13616
|
loopError = error;
|
|
13617
|
+
turnFailed = _ClaudeManager.isTransientTurnError(error) || _ClaudeManager.isAuthError(error) || _ClaudeManager.quotaLimitKind(error) !== null;
|
|
13601
13618
|
if (_ClaudeManager.isTransientTurnError(error) || _ClaudeManager.isAuthError(error)) {
|
|
13602
13619
|
suppressLinearResponseFlush = true;
|
|
13603
13620
|
}
|
|
@@ -13622,7 +13639,16 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13622
13639
|
response.close();
|
|
13623
13640
|
} catch {
|
|
13624
13641
|
}
|
|
13625
|
-
if (orphanedBackgroundCompletion) {
|
|
13642
|
+
if (orphanedBackgroundCompletion && turnFailed && this.lastRequest) {
|
|
13643
|
+
void this.messageQueue.enqueue({
|
|
13644
|
+
...this.lastRequest,
|
|
13645
|
+
messageId: void 0,
|
|
13646
|
+
message: CLAUDE_BACKGROUND_TURN_CONTINUE_PROMPT,
|
|
13647
|
+
images: [],
|
|
13648
|
+
goalMode: false,
|
|
13649
|
+
engineTurn: true
|
|
13650
|
+
});
|
|
13651
|
+
} else if (orphanedBackgroundCompletion) {
|
|
13626
13652
|
this.notifyBackgroundTurnComplete();
|
|
13627
13653
|
}
|
|
13628
13654
|
}
|
|
@@ -60886,7 +60912,7 @@ ${note}`;
|
|
|
60886
60912
|
return;
|
|
60887
60913
|
}
|
|
60888
60914
|
keepAliveService.noteActivity();
|
|
60889
|
-
if (!chat.hasActiveTurn && chat.pendingMessageIds.length > 0) {
|
|
60915
|
+
if (!chat.hasActiveTurn && chat.pendingMessageIds.length > 0 && !chat.provider.getQueue().some((message) => message.id === chat.pendingMessageIds[0])) {
|
|
60890
60916
|
const messageId = chat.pendingMessageIds.shift();
|
|
60891
60917
|
if (!messageId) {
|
|
60892
60918
|
return;
|