replicas-engine 0.1.879 → 0.1.881
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-VLMY3PUD.js";
|
|
9
9
|
import "./chunk-4CF465DO.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-AKHJBXSS.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
12
|
import "./chunk-PYQVWR2X.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
@@ -245,7 +245,7 @@ function getCodexModelProvider(method) {
|
|
|
245
245
|
if (method === "foundry") return "azure";
|
|
246
246
|
return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
|
|
247
247
|
}
|
|
248
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
248
|
+
var ENGINE_PACKAGE_VERSION = "0.1.881";
|
|
249
249
|
var INITIALIZE_METHOD = "initialize";
|
|
250
250
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
251
251
|
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-AKHJBXSS.js";
|
|
15
15
|
import {
|
|
16
16
|
isRecord
|
|
17
17
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -246,7 +246,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
246
246
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
247
247
|
await this.applyCredentialsResponse(data);
|
|
248
248
|
if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
|
|
249
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
249
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ITDUH7G3.js");
|
|
250
250
|
await restartCodexAspHostIfRunning2();
|
|
251
251
|
});
|
|
252
252
|
await this.start(true);
|
|
@@ -266,7 +266,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
266
266
|
await this.applyCredentialUpdate(generation, async () => {
|
|
267
267
|
await this.applyCredentialsResponse(data);
|
|
268
268
|
if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
|
|
269
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
269
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ITDUH7G3.js");
|
|
270
270
|
await restartCodexAspHostIfRunning2();
|
|
271
271
|
}
|
|
272
272
|
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-VLMY3PUD.js";
|
|
136
136
|
import {
|
|
137
137
|
ENGINE_ENV,
|
|
138
138
|
IS_WARMING_MODE,
|
|
@@ -146,7 +146,7 @@ import {
|
|
|
146
146
|
execAsync,
|
|
147
147
|
execFileAsync,
|
|
148
148
|
getCodexModelProvider
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-AKHJBXSS.js";
|
|
150
150
|
import {
|
|
151
151
|
isRecord as isRecord2
|
|
152
152
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -14749,7 +14749,6 @@ var CodexQuotaError = class extends Error {
|
|
|
14749
14749
|
this.name = "CodexQuotaError";
|
|
14750
14750
|
}
|
|
14751
14751
|
};
|
|
14752
|
-
var GOAL_TURN_CONTINUATION_GRACE_MS = 5e3;
|
|
14753
14752
|
var CODEX_SLASH_COMMANDS_CACHE_MS = 3e4;
|
|
14754
14753
|
var POLICY_REASON_INJECTION_TIMEOUT_MS = 5e3;
|
|
14755
14754
|
function formatBlockedCommandReason(reason) {
|
|
@@ -14796,6 +14795,8 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
14796
14795
|
quotaStatus = new CodexQuotaStatusTracker();
|
|
14797
14796
|
currentGoal = null;
|
|
14798
14797
|
goalHistoryKnown = false;
|
|
14798
|
+
goalRevision = 0;
|
|
14799
|
+
onGoalChanged = null;
|
|
14799
14800
|
itemUpdateCoalescer = new ItemUpdateCoalescer((itemId) => {
|
|
14800
14801
|
const item = this.liveTurn?.items.get(itemId);
|
|
14801
14802
|
if (this.liveTurn && item) this.onEvent(codexItemEvent(this.liveTurn.id, item, true));
|
|
@@ -14839,6 +14840,9 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
14839
14840
|
};
|
|
14840
14841
|
}
|
|
14841
14842
|
async interruptActiveTurn() {
|
|
14843
|
+
if (this.currentGoal?.status === "active") {
|
|
14844
|
+
await this.updateGoal({ status: "paused" });
|
|
14845
|
+
}
|
|
14842
14846
|
if (!this.currentThreadId || !this.activeTurnId) {
|
|
14843
14847
|
return;
|
|
14844
14848
|
}
|
|
@@ -15291,9 +15295,9 @@ ${text.slice(-24e3)}`
|
|
|
15291
15295
|
);
|
|
15292
15296
|
this.recordGoalChange(response.goal, true);
|
|
15293
15297
|
return { turn: null, tempImagePaths: [] };
|
|
15294
|
-
}
|
|
15298
|
+
});
|
|
15295
15299
|
}
|
|
15296
|
-
async observeTurn(host, threadId, request, startTurn
|
|
15300
|
+
async observeTurn(host, threadId, request, startTurn) {
|
|
15297
15301
|
let resolveCompleted;
|
|
15298
15302
|
const completed = new Promise((resolve7) => {
|
|
15299
15303
|
resolveCompleted = resolve7;
|
|
@@ -15309,7 +15313,6 @@ ${text.slice(-24e3)}`
|
|
|
15309
15313
|
const observedTurnIds = /* @__PURE__ */ new Set();
|
|
15310
15314
|
let lastCompletedTurn = null;
|
|
15311
15315
|
let completedResolved = false;
|
|
15312
|
-
let goalContinuationTimer = null;
|
|
15313
15316
|
const completedItems = [];
|
|
15314
15317
|
const agentMessageDeltas = /* @__PURE__ */ new Map();
|
|
15315
15318
|
const linearSessionId = this.linearSessionId;
|
|
@@ -15319,24 +15322,11 @@ ${text.slice(-24e3)}`
|
|
|
15319
15322
|
const matchesTurn = (notificationThreadId, notificationTurnId) => notificationThreadId === threadId && (!observedTurnId || notificationTurnId === null || notificationTurnId === observedTurnId || notificationTurnId === this.activeTurnId);
|
|
15320
15323
|
const resolveIfGoalIdle = () => {
|
|
15321
15324
|
if (!lastCompletedTurn || completedResolved) return;
|
|
15322
|
-
if (
|
|
15323
|
-
if (goalContinuationTimer) {
|
|
15324
|
-
clearTimeout(goalContinuationTimer);
|
|
15325
|
-
goalContinuationTimer = null;
|
|
15326
|
-
}
|
|
15325
|
+
if (lastCompletedTurn.status !== "completed" || this.currentGoal?.status !== "active") {
|
|
15327
15326
|
completedResolved = true;
|
|
15328
15327
|
resolveCompleted(lastCompletedTurn);
|
|
15329
15328
|
}
|
|
15330
15329
|
};
|
|
15331
|
-
const scheduleGoalContinuationFallback = () => {
|
|
15332
|
-
if (!options.waitForActiveGoal || completedResolved || goalContinuationTimer) return;
|
|
15333
|
-
goalContinuationTimer = setTimeout(() => {
|
|
15334
|
-
goalContinuationTimer = null;
|
|
15335
|
-
if (!lastCompletedTurn || completedResolved) return;
|
|
15336
|
-
completedResolved = true;
|
|
15337
|
-
resolveCompleted(lastCompletedTurn);
|
|
15338
|
-
}, GOAL_TURN_CONTINUATION_GRACE_MS);
|
|
15339
|
-
};
|
|
15340
15330
|
const handlers = {
|
|
15341
15331
|
[ACCOUNT_RATE_LIMITS_UPDATED_METHOD]: (notification) => {
|
|
15342
15332
|
this.handleRateLimits(notification.params.rateLimits);
|
|
@@ -15354,12 +15344,10 @@ ${text.slice(-24e3)}`
|
|
|
15354
15344
|
[THREAD_GOAL_UPDATED_METHOD]: (notification) => {
|
|
15355
15345
|
if (notification.params.threadId !== threadId) return;
|
|
15356
15346
|
this.recordGoalChange(notification.params.goal);
|
|
15357
|
-
resolveIfGoalIdle();
|
|
15358
15347
|
},
|
|
15359
15348
|
[THREAD_GOAL_CLEARED_METHOD]: (notification) => {
|
|
15360
15349
|
if (notification.params.threadId !== threadId) return;
|
|
15361
15350
|
this.recordGoalChange(null);
|
|
15362
|
-
resolveIfGoalIdle();
|
|
15363
15351
|
},
|
|
15364
15352
|
[THREAD_COMPACTED_METHOD]: (notification) => {
|
|
15365
15353
|
if (!matchesTurn(notification.params.threadId, notification.params.turnId)) return;
|
|
@@ -15371,10 +15359,6 @@ ${text.slice(-24e3)}`
|
|
|
15371
15359
|
observedTurnIds.add(notification.params.turn.id);
|
|
15372
15360
|
this.activeTurnId = notification.params.turn.id;
|
|
15373
15361
|
this.onCodexTurnStarted?.(threadId, notification.params.turn.id);
|
|
15374
|
-
if (goalContinuationTimer) {
|
|
15375
|
-
clearTimeout(goalContinuationTimer);
|
|
15376
|
-
goalContinuationTimer = null;
|
|
15377
|
-
}
|
|
15378
15362
|
lastCompletedTurn = null;
|
|
15379
15363
|
completedItems.length = 0;
|
|
15380
15364
|
agentMessageDeltas.clear();
|
|
@@ -15452,11 +15436,11 @@ ${text.slice(-24e3)}`
|
|
|
15452
15436
|
this.onCodexTurnCompleted?.(threadId, notification.params.turn.id);
|
|
15453
15437
|
const completedTurn = recoverCompletedTurn(notification.params.turn, completedItems, agentMessageDeltas);
|
|
15454
15438
|
this.completeTurn(completedTurn);
|
|
15439
|
+
if (this.activeTurnId === completedTurn.id) this.activeTurnId = null;
|
|
15455
15440
|
lastCompletedTurn = completedTurn;
|
|
15456
15441
|
resolveIfGoalIdle();
|
|
15457
|
-
if (
|
|
15458
|
-
void this.refreshThreadGoal(host, threadId)
|
|
15459
|
-
}).finally(scheduleGoalContinuationFallback);
|
|
15442
|
+
if (!completedResolved && this.currentGoal?.status === "active") {
|
|
15443
|
+
void this.refreshThreadGoal(host, threadId);
|
|
15460
15444
|
}
|
|
15461
15445
|
}
|
|
15462
15446
|
};
|
|
@@ -15483,16 +15467,16 @@ ${text.slice(-24e3)}`
|
|
|
15483
15467
|
host.client.on("notification", onNotification);
|
|
15484
15468
|
host.client.on("serverRequest", onServerRequest);
|
|
15485
15469
|
host.client.on("dispose", onDispose);
|
|
15470
|
+
this.onGoalChanged = resolveIfGoalIdle;
|
|
15486
15471
|
try {
|
|
15487
15472
|
const started = await startTurn();
|
|
15488
15473
|
tempImagePaths = started.tempImagePaths;
|
|
15489
|
-
if (started.turn) {
|
|
15490
|
-
const alreadyObserved = observedTurnIds.has(started.turn.id);
|
|
15474
|
+
if (started.turn && !observedTurnIds.has(started.turn.id)) {
|
|
15491
15475
|
observedTurnId = started.turn.id;
|
|
15492
15476
|
observedTurnIds.add(started.turn.id);
|
|
15493
15477
|
this.activeTurnId = started.turn.id;
|
|
15494
|
-
|
|
15495
|
-
|
|
15478
|
+
this.onCodexTurnStarted?.(threadId, started.turn.id);
|
|
15479
|
+
this.startTurn(started.turn);
|
|
15496
15480
|
}
|
|
15497
15481
|
const turn = await Promise.race([completed, disposed]);
|
|
15498
15482
|
linearForwarder.flushThoughtAsResponse();
|
|
@@ -15501,9 +15485,7 @@ ${text.slice(-24e3)}`
|
|
|
15501
15485
|
host.client.off("notification", onNotification);
|
|
15502
15486
|
host.client.off("serverRequest", onServerRequest);
|
|
15503
15487
|
host.client.off("dispose", onDispose);
|
|
15504
|
-
|
|
15505
|
-
clearTimeout(goalContinuationTimer);
|
|
15506
|
-
}
|
|
15488
|
+
this.onGoalChanged = null;
|
|
15507
15489
|
this.itemUpdateCoalescer.flushPending();
|
|
15508
15490
|
await removeTempImageFiles(tempImagePaths);
|
|
15509
15491
|
if (host.client.isDisposed) {
|
|
@@ -15745,29 +15727,33 @@ ${text.slice(-24e3)}`
|
|
|
15745
15727
|
this.itemUpdateCoalescer.schedule(itemId);
|
|
15746
15728
|
}
|
|
15747
15729
|
async refreshThreadGoal(host, threadId) {
|
|
15730
|
+
const revision = this.goalRevision;
|
|
15731
|
+
const currentThreadId = this.currentThreadId;
|
|
15732
|
+
const attachedClient = this.attachedClient;
|
|
15748
15733
|
try {
|
|
15749
15734
|
const response = await host.client.request(
|
|
15750
15735
|
THREAD_GOAL_GET_METHOD,
|
|
15751
15736
|
{ threadId }
|
|
15752
15737
|
);
|
|
15753
|
-
this.
|
|
15754
|
-
this.
|
|
15738
|
+
if (this.goalRevision !== revision || this.currentThreadId !== currentThreadId || this.attachedClient !== attachedClient || host.client.isDisposed) return;
|
|
15739
|
+
this.recordGoalChange(response.goal);
|
|
15755
15740
|
} catch (error) {
|
|
15756
15741
|
console.warn("[CodexAspManager] Failed to read ASP thread goal:", error);
|
|
15757
15742
|
}
|
|
15758
15743
|
}
|
|
15759
15744
|
recordGoalChange(goal, force = false) {
|
|
15745
|
+
this.goalRevision += 1;
|
|
15746
|
+
this.goalHistoryKnown = true;
|
|
15760
15747
|
const nextGoal = goal ? aspGoalToChatGoal(goal) : null;
|
|
15761
|
-
if (
|
|
15762
|
-
|
|
15748
|
+
if (force || JSON.stringify(this.currentGoal) !== JSON.stringify(nextGoal)) {
|
|
15749
|
+
this.currentGoal = nextGoal;
|
|
15750
|
+
const event = this.recordCodexHistoryEvent(
|
|
15751
|
+
CHAT_GOAL_EVENT_TYPE,
|
|
15752
|
+
{ goal: nextGoal }
|
|
15753
|
+
);
|
|
15754
|
+
this.onEvent(event);
|
|
15763
15755
|
}
|
|
15764
|
-
this.
|
|
15765
|
-
this.goalHistoryKnown = true;
|
|
15766
|
-
const event = this.recordCodexHistoryEvent(
|
|
15767
|
-
CHAT_GOAL_EVENT_TYPE,
|
|
15768
|
-
{ goal: nextGoal }
|
|
15769
|
-
);
|
|
15770
|
-
this.onEvent(event);
|
|
15756
|
+
this.onGoalChanged?.();
|
|
15771
15757
|
}
|
|
15772
15758
|
recordCodexHistoryEvent(type, payload) {
|
|
15773
15759
|
const event = {
|