replicas-engine 0.1.765 → 0.1.766
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-X3XQGPRO.js → asp-host-QO7E55G6.js} +4 -4
- package/dist/src/{chunk-CWSZPPD6.js → chunk-2ZDB6AIE.js} +2 -2
- package/dist/src/{chunk-WFWT2YFN.js → chunk-5R2WQ34N.js} +1 -1
- package/dist/src/{chunk-4OLXBASZ.js → chunk-AL25Z6UZ.js} +4 -4
- package/dist/src/{chunk-UQETFAOK.js → chunk-DC6RPXQZ.js} +30 -1
- package/dist/src/{chunk-SQX57KJM.js → chunk-FFNEC4SD.js} +2 -2
- package/dist/src/{chunk-L2BNNGQB.js → chunk-ZXZ2COVG.js} +1 -1
- package/dist/src/command-protection-hook.js +3 -3
- package/dist/src/deepseek-command-protection-plugin.js +4 -4
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +106 -58
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/relay-mcp.js +1 -1
- package/package.json +1 -1
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
getCodexAspHost,
|
|
6
6
|
restartCodexAspHost,
|
|
7
7
|
restartCodexAspHostIfRunning
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-AL25Z6UZ.js";
|
|
9
|
+
import "./chunk-5R2WQ34N.js";
|
|
10
|
+
import "./chunk-FFNEC4SD.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-DC6RPXQZ.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
export {
|
|
15
15
|
getCodexAspHost,
|
|
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
monolithRequest
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5R2WQ34N.js";
|
|
7
7
|
import {
|
|
8
8
|
extractCommandProtectionCommandText,
|
|
9
9
|
findGitCommitSignals,
|
|
10
10
|
findPrMergeSignals
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DC6RPXQZ.js";
|
|
12
12
|
|
|
13
13
|
// src/services/command-protection-service.ts
|
|
14
14
|
var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
|
|
@@ -5,18 +5,18 @@ import {
|
|
|
5
5
|
ENGINE_ENV,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
setAgentCredentialSnapshot
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5R2WQ34N.js";
|
|
9
9
|
import {
|
|
10
10
|
AppServerProcess,
|
|
11
11
|
buildCodexAgentEnv
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FFNEC4SD.js";
|
|
13
13
|
import {
|
|
14
14
|
CODEX_AUTH_ENV_KEYS,
|
|
15
15
|
CODEX_AUTH_ENV_KEYS_BY_METHOD,
|
|
16
16
|
codexAuthEnvFromResponse,
|
|
17
17
|
createErrorResult,
|
|
18
18
|
createSuccessResult
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-DC6RPXQZ.js";
|
|
20
20
|
|
|
21
21
|
// src/managers/codex-token-manager.ts
|
|
22
22
|
import { promises as fs } from "fs";
|
|
@@ -232,7 +232,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
232
232
|
const data = await response.json();
|
|
233
233
|
await this.applyCredentialsResponse(data);
|
|
234
234
|
if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
|
|
235
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
235
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-QO7E55G6.js");
|
|
236
236
|
await restartCodexAspHostIfRunning2();
|
|
237
237
|
}
|
|
238
238
|
if (data.scope) {
|
|
@@ -646,6 +646,8 @@ function getClaudePartialMessageStreamId(event) {
|
|
|
646
646
|
return typeof event.payload.streamId === "string" && event.payload.streamId ? event.payload.streamId : null;
|
|
647
647
|
}
|
|
648
648
|
var ACCEPTED_USER_MESSAGE_SOURCE = "replicas-chat-turn-accepted";
|
|
649
|
+
var QUEUED_MESSAGE_REMOVED_EVENT_TYPE = "replicas-queued-message-removed";
|
|
650
|
+
var REMOVED_MESSAGE_IDS_PAYLOAD_KEY = "removedMessageIds";
|
|
649
651
|
var USER_MESSAGE_ID_PAYLOAD_KEY = "replicasMessageId";
|
|
650
652
|
var CODEX_ASP_ITEM_ID_PAYLOAD_KEY = "codexAspItemId";
|
|
651
653
|
var CODEX_ASP_TRANSCRIPT_UPDATED_EVENT_TYPE = "codex-asp-transcript-updated";
|
|
@@ -5585,6 +5587,7 @@ function parseCodexAspTranscript(transcript) {
|
|
|
5585
5587
|
// ../shared/src/display-message/parsers/index.ts
|
|
5586
5588
|
var INTERRUPTION_DEDUP_WINDOW_MS = 15e3;
|
|
5587
5589
|
function parseAgentEvents(events, agentType) {
|
|
5590
|
+
events = excludeQueuedAcceptedEvents(events, []);
|
|
5588
5591
|
if (agentType === "codex") {
|
|
5589
5592
|
return parseCodexEvents(events);
|
|
5590
5593
|
}
|
|
@@ -5612,6 +5615,7 @@ function parseAgentEvents(events, agentType) {
|
|
|
5612
5615
|
return parseClaudeEvents(events);
|
|
5613
5616
|
}
|
|
5614
5617
|
function parseDisplayMessages(events, agentType, codexAspTranscript, options = {}) {
|
|
5618
|
+
events = excludeQueuedAcceptedEvents(events, []);
|
|
5615
5619
|
const shouldFilter = options.filter ?? true;
|
|
5616
5620
|
const parsedEvents = agentType === "claude" || agentType === "relay" ? parseClaudeEvents(events, options.parentToolUseId) : parseAgentEvents(events, agentType);
|
|
5617
5621
|
const reconciledEvents = [];
|
|
@@ -5762,10 +5766,24 @@ function getUserMessageId(event) {
|
|
|
5762
5766
|
const messageId = event.payload[USER_MESSAGE_ID_PAYLOAD_KEY];
|
|
5763
5767
|
return typeof messageId === "string" ? messageId : null;
|
|
5764
5768
|
}
|
|
5769
|
+
function getRemovedMessageIds(event) {
|
|
5770
|
+
if (event.type !== QUEUED_MESSAGE_REMOVED_EVENT_TYPE) return [];
|
|
5771
|
+
const messageIds = event.payload[REMOVED_MESSAGE_IDS_PAYLOAD_KEY];
|
|
5772
|
+
if (Array.isArray(messageIds)) return messageIds.filter((id) => typeof id === "string");
|
|
5773
|
+
const messageId = getUserMessageId(event);
|
|
5774
|
+
return messageId ? [messageId] : [];
|
|
5775
|
+
}
|
|
5765
5776
|
function getUserMessageItemId(event) {
|
|
5766
5777
|
const itemId = event.payload[CODEX_ASP_ITEM_ID_PAYLOAD_KEY];
|
|
5767
5778
|
return typeof itemId === "string" ? itemId : null;
|
|
5768
5779
|
}
|
|
5780
|
+
function excludeQueuedAcceptedEvents(events, queue, removedMessageIds = []) {
|
|
5781
|
+
const queuedMessageIds = /* @__PURE__ */ new Set([...queue.map((message) => message.id), ...removedMessageIds]);
|
|
5782
|
+
for (const event of events) {
|
|
5783
|
+
for (const messageId of getRemovedMessageIds(event)) queuedMessageIds.add(messageId);
|
|
5784
|
+
}
|
|
5785
|
+
return events.filter((event) => event.payload.source !== ACCEPTED_USER_MESSAGE_SOURCE || !queuedMessageIds.has(getUserMessageId(event) ?? ""));
|
|
5786
|
+
}
|
|
5769
5787
|
function getEventTimestampMs(event) {
|
|
5770
5788
|
return parseTimestampMs(event.timestamp);
|
|
5771
5789
|
}
|
|
@@ -7287,13 +7305,15 @@ async function readJsonlPage(args) {
|
|
|
7287
7305
|
}
|
|
7288
7306
|
function parseChatTranscriptHistoryIndex(value) {
|
|
7289
7307
|
if (!isRecord(value) || value.version !== 2 || !isNonNegativeInteger(value.sourceSize)) return void 0;
|
|
7308
|
+
const removedMessageIds = Array.isArray(value.removedMessageIds) ? value.removedMessageIds.filter((id) => typeof id === "string") : [];
|
|
7290
7309
|
if (value.codexAspTranscript === void 0) {
|
|
7291
|
-
return { version: 2, sourceSize: value.sourceSize };
|
|
7310
|
+
return { version: 2, sourceSize: value.sourceSize, ...removedMessageIds.length ? { removedMessageIds } : {} };
|
|
7292
7311
|
}
|
|
7293
7312
|
if (!isRecord(value.codexAspTranscript) || typeof value.codexAspTranscript.threadId !== "string" || typeof value.codexAspTranscript.updatedAt !== "string" || !isNonNegativeInteger(value.codexAspTranscript.size)) return void 0;
|
|
7294
7313
|
return {
|
|
7295
7314
|
version: 2,
|
|
7296
7315
|
sourceSize: value.sourceSize,
|
|
7316
|
+
...removedMessageIds.length ? { removedMessageIds } : {},
|
|
7297
7317
|
codexAspTranscript: {
|
|
7298
7318
|
threadId: value.codexAspTranscript.threadId,
|
|
7299
7319
|
updatedAt: value.codexAspTranscript.updatedAt,
|
|
@@ -7306,6 +7326,10 @@ function getChatTranscriptHistorySize(index) {
|
|
|
7306
7326
|
}
|
|
7307
7327
|
function createChatTranscriptPages(sourceBytes) {
|
|
7308
7328
|
const history = parseAgentEventJsonlWithCodexAspTranscript(new TextDecoder("utf-8", { fatal: true }).decode(sourceBytes));
|
|
7329
|
+
const removedMessageIds = /* @__PURE__ */ new Set();
|
|
7330
|
+
for (const event of history.events) {
|
|
7331
|
+
for (const messageId of getRemovedMessageIds(event)) removedMessageIds.add(messageId);
|
|
7332
|
+
}
|
|
7309
7333
|
const bytes = new TextEncoder().encode(history.transcript?.turns.length ? `${history.transcript.turns.map((turn) => JSON.stringify(turn)).join("\n")}
|
|
7310
7334
|
` : "");
|
|
7311
7335
|
return {
|
|
@@ -7313,6 +7337,7 @@ function createChatTranscriptPages(sourceBytes) {
|
|
|
7313
7337
|
index: {
|
|
7314
7338
|
version: 2,
|
|
7315
7339
|
sourceSize: sourceBytes.byteLength,
|
|
7340
|
+
...removedMessageIds.size ? { removedMessageIds: [...removedMessageIds] } : {},
|
|
7316
7341
|
...history.transcript ? {
|
|
7317
7342
|
codexAspTranscript: {
|
|
7318
7343
|
threadId: history.transcript.threadId,
|
|
@@ -7528,6 +7553,8 @@ export {
|
|
|
7528
7553
|
CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE,
|
|
7529
7554
|
getClaudePartialMessageStreamId,
|
|
7530
7555
|
ACCEPTED_USER_MESSAGE_SOURCE,
|
|
7556
|
+
QUEUED_MESSAGE_REMOVED_EVENT_TYPE,
|
|
7557
|
+
REMOVED_MESSAGE_IDS_PAYLOAD_KEY,
|
|
7531
7558
|
USER_MESSAGE_ID_PAYLOAD_KEY,
|
|
7532
7559
|
CODEX_ASP_TRANSCRIPT_UPDATED_EVENT_TYPE,
|
|
7533
7560
|
CODEX_QUOTA_STATUS_EVENT_TYPE,
|
|
@@ -7584,6 +7611,8 @@ export {
|
|
|
7584
7611
|
isAgentBackendEvent,
|
|
7585
7612
|
getUserMessage,
|
|
7586
7613
|
getUserMessageId,
|
|
7614
|
+
getRemovedMessageIds,
|
|
7615
|
+
excludeQueuedAcceptedEvents,
|
|
7587
7616
|
getEventTimestampMs,
|
|
7588
7617
|
areSameUserMessageEvents,
|
|
7589
7618
|
parseAgentEventJsonlWithCodexAspTranscript,
|
|
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
HOOK_EXEC_MAX_BUFFER_BYTES,
|
|
6
6
|
isVersionBelow
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DC6RPXQZ.js";
|
|
8
8
|
|
|
9
9
|
// src/utils/codex-agent-env.ts
|
|
10
10
|
function buildCodexAgentEnv(source = process.env) {
|
|
@@ -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.766";
|
|
245
245
|
var INITIALIZE_METHOD = "initialize";
|
|
246
246
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
247
247
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
findCodeHostPullRequestUrls,
|
|
6
6
|
mayCreatePullRequest
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DC6RPXQZ.js";
|
|
8
8
|
|
|
9
9
|
// src/services/post-tool-pr-notifier.ts
|
|
10
10
|
async function notifyPostToolUse(toolName, toolInput, toolResult) {
|
|
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
evaluateCommandProtection
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-2ZDB6AIE.js";
|
|
7
|
+
import "./chunk-5R2WQ34N.js";
|
|
8
8
|
import {
|
|
9
9
|
isRecord
|
|
10
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-DC6RPXQZ.js";
|
|
12
12
|
import "./chunk-VEQXQN22.js";
|
|
13
13
|
|
|
14
14
|
// src/command-protection-hook.ts
|
|
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
evaluateCommandProtection
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2ZDB6AIE.js";
|
|
7
7
|
import {
|
|
8
8
|
notifyPostToolUse
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-ZXZ2COVG.js";
|
|
10
|
+
import "./chunk-5R2WQ34N.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-DC6RPXQZ.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/deepseek-command-protection-plugin.ts
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
AppServerProcess,
|
|
10
10
|
buildCodexAgentEnv
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FFNEC4SD.js";
|
|
12
12
|
import {
|
|
13
13
|
AGENT,
|
|
14
14
|
getMemoryOutputSafetyViolation,
|
|
15
15
|
headlessAgentRequestSchema
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-DC6RPXQZ.js";
|
|
17
17
|
import "./chunk-VEQXQN22.js";
|
|
18
18
|
|
|
19
19
|
// src/headless-agent.ts
|
package/dist/src/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
evaluateCommandProtection,
|
|
92
92
|
extractToolCommand,
|
|
93
93
|
reportCommandProtectionBlock
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-2ZDB6AIE.js";
|
|
95
95
|
import {
|
|
96
96
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
97
97
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -124,20 +124,20 @@ import {
|
|
|
124
124
|
recordCredentialFallback,
|
|
125
125
|
recordExhaustedCredential,
|
|
126
126
|
restartCodexAspHost
|
|
127
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-AL25Z6UZ.js";
|
|
128
128
|
import {
|
|
129
129
|
ENGINE_ENV,
|
|
130
130
|
IS_WARMING_MODE,
|
|
131
131
|
monolithRequest,
|
|
132
132
|
monolithService,
|
|
133
133
|
setAgentCredentialSnapshot
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-5R2WQ34N.js";
|
|
135
135
|
import {
|
|
136
136
|
AspClient,
|
|
137
137
|
SUBPROCESS_MAX_BUFFER,
|
|
138
138
|
execAsync,
|
|
139
139
|
execFileAsync
|
|
140
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-FFNEC4SD.js";
|
|
141
141
|
import {
|
|
142
142
|
isRecord as isRecord2
|
|
143
143
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -207,6 +207,8 @@ import {
|
|
|
207
207
|
MEMORY_INDEX_FILENAME,
|
|
208
208
|
MEMORY_ROOT,
|
|
209
209
|
MERGED_MESSAGE_SEPARATOR,
|
|
210
|
+
QUEUED_MESSAGE_REMOVED_EVENT_TYPE,
|
|
211
|
+
REMOVED_MESSAGE_IDS_PAYLOAD_KEY,
|
|
210
212
|
REPLICAS_CONFIG_FILENAMES,
|
|
211
213
|
SANDBOX_PATHS,
|
|
212
214
|
TIMEOUT,
|
|
@@ -248,6 +250,7 @@ import {
|
|
|
248
250
|
describeQuotaLimit,
|
|
249
251
|
detectAgentQuotaLimit,
|
|
250
252
|
detectLanguageByPath,
|
|
253
|
+
excludeQueuedAcceptedEvents,
|
|
251
254
|
extractErrorText,
|
|
252
255
|
extractToolResultText,
|
|
253
256
|
fetchAiGatewayModels,
|
|
@@ -268,6 +271,7 @@ import {
|
|
|
268
271
|
getGoalCommand,
|
|
269
272
|
getGoalCommandObjectiveValidationError,
|
|
270
273
|
getProviderDisplayName,
|
|
274
|
+
getRemovedMessageIds,
|
|
271
275
|
getSlashCommandsForProvider,
|
|
272
276
|
getUserMessage,
|
|
273
277
|
getUserMessageId,
|
|
@@ -333,7 +337,7 @@ import {
|
|
|
333
337
|
spawnRelaySubagentRequestSchema,
|
|
334
338
|
stripAgentDiagnosticErrors,
|
|
335
339
|
withTimeout
|
|
336
|
-
} from "./chunk-
|
|
340
|
+
} from "./chunk-DC6RPXQZ.js";
|
|
337
341
|
import {
|
|
338
342
|
__commonJS,
|
|
339
343
|
__export,
|
|
@@ -10684,7 +10688,7 @@ function workspaceChatEventSignals(event) {
|
|
|
10684
10688
|
streamId: getClaudePartialMessageStreamId(event),
|
|
10685
10689
|
json,
|
|
10686
10690
|
userMessage: getComparableUserMessage(event),
|
|
10687
|
-
userMessageId: getUserMessageId(event)
|
|
10691
|
+
userMessageId: event.type === QUEUED_MESSAGE_REMOVED_EVENT_TYPE ? null : getUserMessageId(event)
|
|
10688
10692
|
};
|
|
10689
10693
|
}
|
|
10690
10694
|
var emptyIndex = () => ({
|
|
@@ -10749,7 +10753,17 @@ function findDuplicatePosition(index, event) {
|
|
|
10749
10753
|
}
|
|
10750
10754
|
return match;
|
|
10751
10755
|
}
|
|
10752
|
-
function mergeWorkspaceChatHistoryEvents(primary, supplemental) {
|
|
10756
|
+
function mergeWorkspaceChatHistoryEvents(primary, supplemental, removedMessageIds = []) {
|
|
10757
|
+
const removed = new Set(removedMessageIds);
|
|
10758
|
+
for (const events of [primary, supplemental]) {
|
|
10759
|
+
for (const event of events) {
|
|
10760
|
+
for (const messageId of getRemovedMessageIds(event)) removed.add(messageId);
|
|
10761
|
+
}
|
|
10762
|
+
}
|
|
10763
|
+
if (removed.size > 0) {
|
|
10764
|
+
primary = excludeQueuedAcceptedEvents(primary, [], [...removed]);
|
|
10765
|
+
supplemental = excludeQueuedAcceptedEvents(supplemental, [], [...removed]);
|
|
10766
|
+
}
|
|
10753
10767
|
if (supplemental.length === 0) return [...primary];
|
|
10754
10768
|
const merged = [...primary];
|
|
10755
10769
|
const index = emptyIndex();
|
|
@@ -11573,22 +11587,6 @@ var MessageQueueService = class {
|
|
|
11573
11587
|
getQueue() {
|
|
11574
11588
|
return [...this.queue];
|
|
11575
11589
|
}
|
|
11576
|
-
/**
|
|
11577
|
-
* Remove a message from the queue by its ID
|
|
11578
|
-
* @returns true if the message was found and removed
|
|
11579
|
-
*/
|
|
11580
|
-
removeFromQueue(messageId) {
|
|
11581
|
-
const index = this.queue.findIndex((m) => m.id === messageId);
|
|
11582
|
-
if (index === -1) return false;
|
|
11583
|
-
this.queue.splice(index, 1);
|
|
11584
|
-
return true;
|
|
11585
|
-
}
|
|
11586
|
-
clearQueue() {
|
|
11587
|
-
const hadMessages = this.queue.length > 0;
|
|
11588
|
-
this.queueCancellationVersion++;
|
|
11589
|
-
this.queue = [];
|
|
11590
|
-
return hadMessages;
|
|
11591
|
-
}
|
|
11592
11590
|
updateQueuedMessage(messageId, message) {
|
|
11593
11591
|
const queuedMessage = this.queue.find((item) => item.id === messageId);
|
|
11594
11592
|
if (!queuedMessage) return false;
|
|
@@ -11742,7 +11740,7 @@ var CodingAgentManager = class {
|
|
|
11742
11740
|
);
|
|
11743
11741
|
this.initialized = this.initialize();
|
|
11744
11742
|
}
|
|
11745
|
-
async
|
|
11743
|
+
async persistHistoryEvent(event) {
|
|
11746
11744
|
const history = this.getHistorySink();
|
|
11747
11745
|
if (!history?.appendDurably) throw new Error("Chat history is unavailable");
|
|
11748
11746
|
await history.appendDurably(event);
|
|
@@ -11782,11 +11780,32 @@ var CodingAgentManager = class {
|
|
|
11782
11780
|
...m.senderDisplayName ? { senderDisplayName: m.senderDisplayName } : {}
|
|
11783
11781
|
}));
|
|
11784
11782
|
}
|
|
11785
|
-
removeFromQueue(messageId) {
|
|
11786
|
-
return this.
|
|
11783
|
+
async removeFromQueue(messageId, persistRemoval) {
|
|
11784
|
+
return this.removeQueuedMessages([messageId], persistRemoval);
|
|
11785
|
+
}
|
|
11786
|
+
async clearQueue(persistRemoval) {
|
|
11787
|
+
const messageIds = this.messageQueue.getQueue().map(({ id }) => id);
|
|
11788
|
+
return this.removeQueuedMessages(messageIds, () => persistRemoval(messageIds));
|
|
11787
11789
|
}
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
+
async removeQueuedMessages(messageIds, persistRemoval) {
|
|
11791
|
+
const taken = messageIds.flatMap((messageId) => {
|
|
11792
|
+
const item = this.messageQueue.takeFromQueue(messageId);
|
|
11793
|
+
return item ? [item] : [];
|
|
11794
|
+
});
|
|
11795
|
+
if (taken.length === 0) return false;
|
|
11796
|
+
try {
|
|
11797
|
+
await persistRemoval();
|
|
11798
|
+
return true;
|
|
11799
|
+
} catch (error) {
|
|
11800
|
+
this.restoreQueuedMessages(taken);
|
|
11801
|
+
throw error;
|
|
11802
|
+
}
|
|
11803
|
+
}
|
|
11804
|
+
restoreQueuedMessages(taken) {
|
|
11805
|
+
for (let index = taken.length - 1; index >= 0; index--) {
|
|
11806
|
+
this.messageQueue.restoreToQueue(taken[index].message, taken[index].index);
|
|
11807
|
+
}
|
|
11808
|
+
this.messageQueue.resumeIfIdle();
|
|
11790
11809
|
}
|
|
11791
11810
|
updateQueuedMessage(messageId, message) {
|
|
11792
11811
|
return this.messageQueue.updateQueuedMessage(messageId, message);
|
|
@@ -11818,11 +11837,10 @@ var CodingAgentManager = class {
|
|
|
11818
11837
|
if (!steered) {
|
|
11819
11838
|
if (keepQueued) {
|
|
11820
11839
|
const prioritized = this.messageQueue.takeFromQueue(messageId);
|
|
11821
|
-
if (prioritized) this.
|
|
11840
|
+
if (prioritized) this.restoreQueuedMessages([{ message: prioritized.message, index: taken.index }]);
|
|
11822
11841
|
} else {
|
|
11823
|
-
this.
|
|
11842
|
+
this.restoreQueuedMessages([taken]);
|
|
11824
11843
|
}
|
|
11825
|
-
this.messageQueue.resumeIfIdle();
|
|
11826
11844
|
}
|
|
11827
11845
|
return {
|
|
11828
11846
|
success: steered,
|
|
@@ -61003,7 +61021,9 @@ async function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
|
61003
61021
|
} catch (error) {
|
|
61004
61022
|
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
|
|
61005
61023
|
}
|
|
61006
|
-
if (historyPages.index.codexAspTranscript
|
|
61024
|
+
if (historyPages.index.codexAspTranscript || historyPages.index.removedMessageIds?.length) {
|
|
61025
|
+
metadata.historyIndex = historyPages.index;
|
|
61026
|
+
}
|
|
61007
61027
|
const uploadRequest = { chatId, size, metadata };
|
|
61008
61028
|
const prepareResponse = await monolithRequest("/v1/engine/chat-transcripts/upload-url", {
|
|
61009
61029
|
body: uploadRequest
|
|
@@ -61310,6 +61330,7 @@ function acceptedEventInCodexTranscript(acceptedEvent, transcript) {
|
|
|
61310
61330
|
}
|
|
61311
61331
|
var LAST_MESSAGE_PREVIEW_MAX = 200;
|
|
61312
61332
|
var MAX_ACCEPTED_SEND_RESPONSES = 50;
|
|
61333
|
+
var MAX_REMOVED_MESSAGE_IDS = 6e3;
|
|
61313
61334
|
var RELAY_SUBAGENT_POLL_INTERVAL_MS = 2e3;
|
|
61314
61335
|
var DEFAULT_RELAY_SUBAGENT_TIMEOUT_MS = 6e5;
|
|
61315
61336
|
async function resolveRelayBaseProvider(provider, requested) {
|
|
@@ -61346,6 +61367,7 @@ function normalizePersistedChat(chat) {
|
|
|
61346
61367
|
lastMessageText: chat.lastMessageText ?? null,
|
|
61347
61368
|
deletedAt: chat.deletedAt ?? null,
|
|
61348
61369
|
fork: coerceChatForkInfo(chat.fork),
|
|
61370
|
+
removedMessageIds: Array.isArray(chat.removedMessageIds) ? chat.removedMessageIds.filter((id) => typeof id === "string").slice(-MAX_REMOVED_MESSAGE_IDS) : [],
|
|
61349
61371
|
acceptedSendResponses: isRecord2(chat.acceptedSendResponses) ? Object.fromEntries(Object.entries(chat.acceptedSendResponses).filter((entry) => {
|
|
61350
61372
|
const response = entry[1];
|
|
61351
61373
|
return isRecord2(response) && typeof response.messageId === "string" && typeof response.queued === "boolean" && typeof response.position === "number";
|
|
@@ -61608,7 +61630,7 @@ var ChatService = class {
|
|
|
61608
61630
|
submittedAt
|
|
61609
61631
|
);
|
|
61610
61632
|
try {
|
|
61611
|
-
await chat.provider.
|
|
61633
|
+
await chat.provider.persistHistoryEvent(acceptedEvent);
|
|
61612
61634
|
} catch (error) {
|
|
61613
61635
|
throw new ChatMessagePersistenceError(error);
|
|
61614
61636
|
}
|
|
@@ -61627,10 +61649,12 @@ var ChatService = class {
|
|
|
61627
61649
|
}
|
|
61628
61650
|
chat.persisted.acceptedSendResponses = Object.fromEntries(chat.acceptedSendResponses);
|
|
61629
61651
|
}
|
|
61630
|
-
if (!chat.
|
|
61631
|
-
chat.pendingMessageIds.
|
|
61652
|
+
if (!chat.persisted.removedMessageIds?.includes(result.messageId)) {
|
|
61653
|
+
if (!chat.pendingMessageIds.includes(result.messageId)) {
|
|
61654
|
+
chat.pendingMessageIds.push(result.messageId);
|
|
61655
|
+
}
|
|
61656
|
+
chat.acceptedUserEvents.set(result.messageId, acceptedEvent);
|
|
61632
61657
|
}
|
|
61633
|
-
chat.acceptedUserEvents.set(result.messageId, acceptedEvent);
|
|
61634
61658
|
chat.persisted.lastMessageText = request.message.trim().slice(0, LAST_MESSAGE_PREVIEW_MAX) || null;
|
|
61635
61659
|
chat.persisted.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
61636
61660
|
try {
|
|
@@ -61750,43 +61774,56 @@ var ChatService = class {
|
|
|
61750
61774
|
queue: chat.provider.getQueue()
|
|
61751
61775
|
};
|
|
61752
61776
|
}
|
|
61753
|
-
|
|
61754
|
-
// bookkeeping must go with it or hasActiveChatTurn stays true forever.
|
|
61755
|
-
forgetPendingMessages(chat, messageIds) {
|
|
61777
|
+
async forgetPendingMessages(chat, messageIds) {
|
|
61756
61778
|
if (messageIds.length === 0) return;
|
|
61757
61779
|
const removed = new Set(messageIds);
|
|
61780
|
+
const event = {
|
|
61781
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
61782
|
+
type: QUEUED_MESSAGE_REMOVED_EVENT_TYPE,
|
|
61783
|
+
payload: { [REMOVED_MESSAGE_IDS_PAYLOAD_KEY]: [...removed] }
|
|
61784
|
+
};
|
|
61785
|
+
await chat.provider.persistHistoryEvent(event);
|
|
61786
|
+
chat.persisted.removedMessageIds = [.../* @__PURE__ */ new Set([...chat.persisted.removedMessageIds ?? [], ...removed])].slice(-MAX_REMOVED_MESSAGE_IDS);
|
|
61758
61787
|
chat.pendingMessageIds = chat.pendingMessageIds.filter((messageId) => !removed.has(messageId));
|
|
61759
61788
|
for (const messageId of removed) {
|
|
61760
61789
|
chat.acceptedUserEvents.delete(messageId);
|
|
61761
61790
|
chat.errorNotificationTargets.delete(messageId);
|
|
61762
61791
|
}
|
|
61792
|
+
await this.persistAllChats().catch((error) => {
|
|
61793
|
+
console.error("[ChatService] Failed to persist queued-message removals:", error);
|
|
61794
|
+
});
|
|
61795
|
+
await this.publish({
|
|
61796
|
+
type: "chat.turn.delta",
|
|
61797
|
+
payload: { chatId: chat.persisted.id, event }
|
|
61798
|
+
}).catch((error) => {
|
|
61799
|
+
console.error("[ChatService] Failed to publish queued-message removals:", error);
|
|
61800
|
+
});
|
|
61763
61801
|
this.publish({
|
|
61764
61802
|
type: "chat.updated",
|
|
61765
61803
|
payload: { chat: this.toSummary(chat) }
|
|
61766
61804
|
}).catch(() => {
|
|
61767
61805
|
});
|
|
61768
61806
|
}
|
|
61769
|
-
removeFromQueue(chatId, messageId) {
|
|
61807
|
+
async removeFromQueue(chatId, messageId) {
|
|
61770
61808
|
const chat = this.requireChat(chatId);
|
|
61771
|
-
const success = chat.provider.removeFromQueue(messageId);
|
|
61772
|
-
if (success) {
|
|
61773
|
-
this.forgetPendingMessages(chat, [messageId]);
|
|
61774
|
-
}
|
|
61809
|
+
const success = await chat.provider.removeFromQueue(messageId, () => this.forgetPendingMessages(chat, [messageId]));
|
|
61775
61810
|
return {
|
|
61776
61811
|
success,
|
|
61777
|
-
queue: chat.provider.getQueue()
|
|
61812
|
+
queue: chat.provider.getQueue(),
|
|
61813
|
+
removedMessageIds: success ? [messageId] : []
|
|
61778
61814
|
};
|
|
61779
61815
|
}
|
|
61780
|
-
clearQueue(chatId) {
|
|
61816
|
+
async clearQueue(chatId) {
|
|
61781
61817
|
const chat = this.requireChat(chatId);
|
|
61782
|
-
|
|
61783
|
-
const success = chat.provider.clearQueue()
|
|
61784
|
-
|
|
61785
|
-
this.forgetPendingMessages(chat,
|
|
61786
|
-
}
|
|
61818
|
+
let queuedIds = [];
|
|
61819
|
+
const success = await chat.provider.clearQueue(async (messageIds) => {
|
|
61820
|
+
queuedIds = messageIds;
|
|
61821
|
+
await this.forgetPendingMessages(chat, messageIds);
|
|
61822
|
+
});
|
|
61787
61823
|
return {
|
|
61788
61824
|
success,
|
|
61789
|
-
queue: chat.provider.getQueue()
|
|
61825
|
+
queue: chat.provider.getQueue(),
|
|
61826
|
+
removedMessageIds: success ? queuedIds : []
|
|
61790
61827
|
};
|
|
61791
61828
|
}
|
|
61792
61829
|
updateQueuedMessage(chatId, messageId, message) {
|
|
@@ -62038,7 +62075,11 @@ var ChatService = class {
|
|
|
62038
62075
|
chat.provider.getHistory(page2),
|
|
62039
62076
|
this.readSenders(chatId)
|
|
62040
62077
|
]);
|
|
62041
|
-
const historyEvents =
|
|
62078
|
+
const historyEvents = excludeQueuedAcceptedEvents(
|
|
62079
|
+
mergeWorkspaceChatHistoryEvents([], history.events),
|
|
62080
|
+
chat.provider.getQueue(),
|
|
62081
|
+
chat.persisted.removedMessageIds
|
|
62082
|
+
);
|
|
62042
62083
|
for (const [messageId, acceptedEvent] of chat.acceptedUserEvents) {
|
|
62043
62084
|
if (acceptedEventInCodexTranscript(acceptedEvent, history.codexAspTranscript) || historyEvents.some((event) => isSameAcceptedUserEvent(event, acceptedEvent))) {
|
|
62044
62085
|
chat.acceptedUserEvents.delete(messageId);
|
|
@@ -62047,12 +62088,17 @@ var ChatService = class {
|
|
|
62047
62088
|
const isLatestPage = isLatestChatHistoryPage(page2);
|
|
62048
62089
|
const queuedMessageIds = new Set(chat.provider.getQueue().map((message) => message.id));
|
|
62049
62090
|
const acceptedEvents = (isLatestPage ? [...chat.acceptedUserEvents.entries()] : []).filter(([messageId]) => messageId === chat.activeMessageId || !chat.hasActiveTurn && chat.pendingMessageIds[0] === messageId && !queuedMessageIds.has(messageId)).map(([, acceptedEvent]) => acceptedEvent).filter((acceptedEvent) => !acceptedEventInCodexTranscript(acceptedEvent, history.codexAspTranscript) && !historyEvents.some((event) => isSameAcceptedUserEvent(event, acceptedEvent)));
|
|
62050
|
-
const events =
|
|
62091
|
+
const events = excludeQueuedAcceptedEvents(
|
|
62092
|
+
[...historyEvents, ...acceptedEvents].sort((a, b) => getEventTimestampMs(a) - getEventTimestampMs(b)),
|
|
62093
|
+
[],
|
|
62094
|
+
chat.persisted.removedMessageIds
|
|
62095
|
+
);
|
|
62051
62096
|
if (page2.limit !== void 0 && "beforeCursor" in history) {
|
|
62052
62097
|
const cursor = parseChatHistoryCursor(history.beforeCursor ?? void 0);
|
|
62053
62098
|
return {
|
|
62054
62099
|
...history,
|
|
62055
62100
|
events,
|
|
62101
|
+
removedMessageIds: chat.persisted.removedMessageIds,
|
|
62056
62102
|
goal: history.goal ?? chat.provider.getGoal?.() ?? null,
|
|
62057
62103
|
senders: getChatHistoryPageSenders(senders, page2),
|
|
62058
62104
|
beforeCursor: createChatHistoryCursor({
|
|
@@ -62065,6 +62111,7 @@ var ChatService = class {
|
|
|
62065
62111
|
return {
|
|
62066
62112
|
...history,
|
|
62067
62113
|
events,
|
|
62114
|
+
removedMessageIds: chat.persisted.removedMessageIds,
|
|
62068
62115
|
totalEvents: (history.totalEvents ?? history.eventsStartIndex + history.events.length) - (history.events.length - historyEvents.length) + acceptedEvents.length,
|
|
62069
62116
|
goal: history.goal ?? chat.provider.getGoal?.() ?? null,
|
|
62070
62117
|
senders
|
|
@@ -62073,6 +62120,7 @@ var ChatService = class {
|
|
|
62073
62120
|
return paginateChatHistory({
|
|
62074
62121
|
thread_id: history.thread_id,
|
|
62075
62122
|
events,
|
|
62123
|
+
removedMessageIds: chat.persisted.removedMessageIds,
|
|
62076
62124
|
codexAspTranscript: history.codexAspTranscript ?? null,
|
|
62077
62125
|
goal: history.goal ?? chat.provider.getGoal?.() ?? null,
|
|
62078
62126
|
senders
|
|
@@ -63918,9 +63966,9 @@ function createV1Routes(deps) {
|
|
|
63918
63966
|
return c.json(jsonError("Failed to get queue", error instanceof Error ? error.message : "Unknown error"), 500);
|
|
63919
63967
|
}
|
|
63920
63968
|
});
|
|
63921
|
-
app2.delete("/chats/:chatId/queue", (c) => {
|
|
63969
|
+
app2.delete("/chats/:chatId/queue", async (c) => {
|
|
63922
63970
|
try {
|
|
63923
|
-
const result = deps.chatService.clearQueue(c.req.param("chatId"));
|
|
63971
|
+
const result = await deps.chatService.clearQueue(c.req.param("chatId"));
|
|
63924
63972
|
return c.json(result);
|
|
63925
63973
|
} catch (error) {
|
|
63926
63974
|
if (error instanceof ChatNotFoundError) {
|
|
@@ -63929,9 +63977,9 @@ function createV1Routes(deps) {
|
|
|
63929
63977
|
return c.json(jsonError("Failed to clear queue", error instanceof Error ? error.message : "Unknown error"), 500);
|
|
63930
63978
|
}
|
|
63931
63979
|
});
|
|
63932
|
-
app2.delete("/chats/:chatId/queue/:messageId", (c) => {
|
|
63980
|
+
app2.delete("/chats/:chatId/queue/:messageId", async (c) => {
|
|
63933
63981
|
try {
|
|
63934
|
-
const result = deps.chatService.removeFromQueue(c.req.param("chatId"), c.req.param("messageId"));
|
|
63982
|
+
const result = await deps.chatService.removeFromQueue(c.req.param("chatId"), c.req.param("messageId"));
|
|
63935
63983
|
return c.json(result);
|
|
63936
63984
|
} catch (error) {
|
|
63937
63985
|
if (error instanceof ChatNotFoundError) {
|
|
@@ -3,11 +3,11 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
notifyPostToolUse
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZXZ2COVG.js";
|
|
7
7
|
import {
|
|
8
8
|
isRecord
|
|
9
9
|
} from "./chunk-UZSNFLDQ.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-DC6RPXQZ.js";
|
|
11
11
|
import "./chunk-VEQXQN22.js";
|
|
12
12
|
|
|
13
13
|
// src/post-tool-pr-hook.ts
|
package/dist/src/relay-mcp.js
CHANGED