remote-codex 0.11.39 → 0.11.41
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/apps/supervisor-api/dist/index.js +148 -10
- package/apps/supervisor-web/dist/assets/{index-CUhMNGXI.js → index-B-qj7e8G.js} +4 -4
- package/apps/supervisor-web/dist/index.html +1 -1
- package/package.json +1 -1
- package/packages/claude/src/runtimeAdapter.test.ts +235 -1
- package/packages/claude/src/runtimeAdapter.ts +214 -12
|
@@ -11717,6 +11717,54 @@ import { pathToFileURL } from "url";
|
|
|
11717
11717
|
import { promisify } from "util";
|
|
11718
11718
|
var execFileAsync = promisify(execFile);
|
|
11719
11719
|
var promptPhotoTokenPattern2 = /\[PHOTO\s+([^\]]+)\]/g;
|
|
11720
|
+
var claudeCompactSummaryPrefix = "This session is being continued from a previous conversation that ran out of context.";
|
|
11721
|
+
var activeTranscriptMatchWindowMs = 12e4;
|
|
11722
|
+
function isClaudeCompactBoundaryMessage(message) {
|
|
11723
|
+
if (message.type !== "system") {
|
|
11724
|
+
return false;
|
|
11725
|
+
}
|
|
11726
|
+
if (message.subtype === "compact_boundary" || message.compact_metadata) {
|
|
11727
|
+
return true;
|
|
11728
|
+
}
|
|
11729
|
+
return isRecord8(message.message) && (message.message.subtype === "compact_boundary" || isRecord8(message.message.compact_metadata));
|
|
11730
|
+
}
|
|
11731
|
+
function isClaudeCompactSummaryMessage(message) {
|
|
11732
|
+
if (message.type !== "user" || message.parent_tool_use_id) {
|
|
11733
|
+
return false;
|
|
11734
|
+
}
|
|
11735
|
+
const payload = isRecord8(message.message) ? message.message : null;
|
|
11736
|
+
if (message.isCompactSummary || message.is_compact_summary || payload?.isCompactSummary === true || payload?.is_compact_summary === true) {
|
|
11737
|
+
return true;
|
|
11738
|
+
}
|
|
11739
|
+
return messageContentText(message.message).trim().startsWith(claudeCompactSummaryPrefix);
|
|
11740
|
+
}
|
|
11741
|
+
function claudeContextCompactionItem(id, status, error = null) {
|
|
11742
|
+
const completed = status === "completed";
|
|
11743
|
+
const failed = status === "failed";
|
|
11744
|
+
const text2 = failed ? "Context compaction failed" : completed ? "Context compacted" : "Compacting context";
|
|
11745
|
+
return {
|
|
11746
|
+
id,
|
|
11747
|
+
kind: "contextCompaction",
|
|
11748
|
+
text: text2,
|
|
11749
|
+
previewText: text2,
|
|
11750
|
+
detailText: failed ? error : null,
|
|
11751
|
+
status
|
|
11752
|
+
};
|
|
11753
|
+
}
|
|
11754
|
+
function normalizePromptForTurnReconciliation(value) {
|
|
11755
|
+
return value.replace(/\[PHOTO\s+[^\]]+\]/g, " ").replace(/\s+/g, " ").trim();
|
|
11756
|
+
}
|
|
11757
|
+
function userPromptForTurn(turn) {
|
|
11758
|
+
return turn.items.find((item) => item.kind === "userMessage")?.text ?? null;
|
|
11759
|
+
}
|
|
11760
|
+
function isRecentActiveTranscriptTurn(turn, activeStartedAt) {
|
|
11761
|
+
if (!turn.startedAt) {
|
|
11762
|
+
return true;
|
|
11763
|
+
}
|
|
11764
|
+
const transcriptStartedAt = Date.parse(turn.startedAt);
|
|
11765
|
+
const activeStartedAtMs = Date.parse(activeStartedAt);
|
|
11766
|
+
return !Number.isFinite(transcriptStartedAt) || !Number.isFinite(activeStartedAtMs) || Math.abs(transcriptStartedAt - activeStartedAtMs) <= activeTranscriptMatchWindowMs;
|
|
11767
|
+
}
|
|
11720
11768
|
function mimeTypeForImagePath(filePath) {
|
|
11721
11769
|
const extension = path10.extname(filePath).toLowerCase();
|
|
11722
11770
|
switch (extension) {
|
|
@@ -12908,7 +12956,8 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
12908
12956
|
suppressedToolUseIds: /* @__PURE__ */ new Set(),
|
|
12909
12957
|
assistantUsage: null,
|
|
12910
12958
|
resultUsage: null,
|
|
12911
|
-
modelContextWindow: null
|
|
12959
|
+
modelContextWindow: null,
|
|
12960
|
+
currentCompactionItemId: null
|
|
12912
12961
|
};
|
|
12913
12962
|
this.knownSessionIds.add(input.providerSessionId);
|
|
12914
12963
|
let sessionPrompts = this.liveUserPrompts.get(input.providerSessionId);
|
|
@@ -12993,9 +13042,11 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
12993
13042
|
}
|
|
12994
13043
|
const activeUserItem = userMessageHistoryItem(`${activeTurn.providerTurnId}:user`, prompt);
|
|
12995
13044
|
const activeItems = [...activeTurn.itemOrder].map((itemId) => activeTurn.items.get(itemId)).filter((item) => Boolean(item));
|
|
12996
|
-
const
|
|
12997
|
-
|
|
12998
|
-
|
|
13045
|
+
const normalizedPrompt = normalizePromptForTurnReconciliation(prompt);
|
|
13046
|
+
const transcriptTurnIndex = turns.findLastIndex((turn) => {
|
|
13047
|
+
const transcriptPrompt = userPromptForTurn(turn);
|
|
13048
|
+
return turn.status === "completed" && transcriptPrompt !== null && normalizePromptForTurnReconciliation(transcriptPrompt) === normalizedPrompt && !turn.items.some((item) => item.kind === "agentMessage") && isRecentActiveTranscriptTurn(turn, activeTurn.startedAt);
|
|
13049
|
+
});
|
|
12999
13050
|
if (transcriptTurnIndex < 0) {
|
|
13000
13051
|
return turns;
|
|
13001
13052
|
}
|
|
@@ -13006,6 +13057,11 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
13006
13057
|
aliases = /* @__PURE__ */ new Map();
|
|
13007
13058
|
this.historicalTurnIdAliases.set(providerSessionId, aliases);
|
|
13008
13059
|
}
|
|
13060
|
+
for (const [historicalTurnId, displayTurnId] of aliases) {
|
|
13061
|
+
if (displayTurnId === activeTurn.providerTurnId && historicalTurnId !== transcriptTurn.providerTurnId) {
|
|
13062
|
+
aliases.delete(historicalTurnId);
|
|
13063
|
+
}
|
|
13064
|
+
}
|
|
13009
13065
|
aliases.set(transcriptTurn.providerTurnId, activeTurn.providerTurnId);
|
|
13010
13066
|
}
|
|
13011
13067
|
return turns.map((turn, index) => {
|
|
@@ -13028,9 +13084,16 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
13028
13084
|
if (!aliases || aliases.size === 0) {
|
|
13029
13085
|
return turns;
|
|
13030
13086
|
}
|
|
13087
|
+
const rawTurnIds = new Set(turns.map((turn) => turn.providerTurnId));
|
|
13088
|
+
const usedTurnIds = /* @__PURE__ */ new Set();
|
|
13031
13089
|
return turns.map((turn) => {
|
|
13032
13090
|
const providerTurnId = aliases.get(turn.providerTurnId);
|
|
13033
|
-
|
|
13091
|
+
if (!providerTurnId || usedTurnIds.has(providerTurnId) || providerTurnId !== turn.providerTurnId && rawTurnIds.has(providerTurnId)) {
|
|
13092
|
+
usedTurnIds.add(turn.providerTurnId);
|
|
13093
|
+
return turn;
|
|
13094
|
+
}
|
|
13095
|
+
usedTurnIds.add(providerTurnId);
|
|
13096
|
+
return { ...turn, providerTurnId };
|
|
13034
13097
|
});
|
|
13035
13098
|
}
|
|
13036
13099
|
async listMcpServers() {
|
|
@@ -13118,6 +13181,53 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
13118
13181
|
}
|
|
13119
13182
|
return;
|
|
13120
13183
|
}
|
|
13184
|
+
if (message.type === "system" && message.subtype === "status") {
|
|
13185
|
+
if (message.status === "compacting") {
|
|
13186
|
+
const existing = state.currentCompactionItemId ? state.items.get(state.currentCompactionItemId) : null;
|
|
13187
|
+
const itemId = existing?.status === "running" ? existing.id : `claude-compaction-${messageUuid(message, randomUUID2())}`;
|
|
13188
|
+
state.currentCompactionItemId = itemId;
|
|
13189
|
+
const item = withHistoryItemCreatedAt(
|
|
13190
|
+
claudeContextCompactionItem(itemId, "running"),
|
|
13191
|
+
messageCreatedAt
|
|
13192
|
+
);
|
|
13193
|
+
addOrUpdateItem(state, item);
|
|
13194
|
+
this.emitItem(state, item, "item.started", { force: Boolean(existing) });
|
|
13195
|
+
return;
|
|
13196
|
+
}
|
|
13197
|
+
if (message.compact_result) {
|
|
13198
|
+
const itemId = state.currentCompactionItemId ?? `claude-compaction-${messageUuid(message, randomUUID2())}`;
|
|
13199
|
+
const status = message.compact_result === "success" ? "completed" : "failed";
|
|
13200
|
+
const item = withHistoryItemCreatedAt(
|
|
13201
|
+
claudeContextCompactionItem(itemId, status, message.compact_error ?? null),
|
|
13202
|
+
messageCreatedAt
|
|
13203
|
+
);
|
|
13204
|
+
addOrUpdateItem(state, item);
|
|
13205
|
+
this.emitItem(state, item, "item.completed");
|
|
13206
|
+
state.currentCompactionItemId = status === "failed" ? null : itemId;
|
|
13207
|
+
return;
|
|
13208
|
+
}
|
|
13209
|
+
return;
|
|
13210
|
+
}
|
|
13211
|
+
if (isClaudeCompactBoundaryMessage(message)) {
|
|
13212
|
+
const itemId = state.currentCompactionItemId ?? `claude-compaction-${messageUuid(message, randomUUID2())}`;
|
|
13213
|
+
const previous = state.items.get(itemId);
|
|
13214
|
+
const item = withHistoryItemCreatedAt(
|
|
13215
|
+
claudeContextCompactionItem(itemId, "completed"),
|
|
13216
|
+
previous?.createdAt ?? messageCreatedAt
|
|
13217
|
+
);
|
|
13218
|
+
addOrUpdateItem(state, item);
|
|
13219
|
+
if (!previous) {
|
|
13220
|
+
this.emitItem(state, item, "item.started");
|
|
13221
|
+
}
|
|
13222
|
+
if (previous?.status !== "completed") {
|
|
13223
|
+
this.emitItem(state, item, "item.completed");
|
|
13224
|
+
}
|
|
13225
|
+
state.currentCompactionItemId = null;
|
|
13226
|
+
return;
|
|
13227
|
+
}
|
|
13228
|
+
if (isClaudeCompactSummaryMessage(message)) {
|
|
13229
|
+
return;
|
|
13230
|
+
}
|
|
13121
13231
|
if (message.type === "stream_event") {
|
|
13122
13232
|
const nextStreamMessageId = streamMessageId(message.event);
|
|
13123
13233
|
if (nextStreamMessageId) {
|
|
@@ -13469,6 +13579,8 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
13469
13579
|
const turns = [];
|
|
13470
13580
|
let current = null;
|
|
13471
13581
|
let skippingHiddenInit = false;
|
|
13582
|
+
let pendingCompactSummaryItemId = null;
|
|
13583
|
+
let pendingCompactBoundaryItemId = null;
|
|
13472
13584
|
const suppressedToolUseIds = /* @__PURE__ */ new Set();
|
|
13473
13585
|
const upsertCurrentItem = (item) => {
|
|
13474
13586
|
if (!current) {
|
|
@@ -13500,6 +13612,18 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
13500
13612
|
current.itemsById.set(item.id, item);
|
|
13501
13613
|
};
|
|
13502
13614
|
for (const message of messages) {
|
|
13615
|
+
if (isClaudeCompactBoundaryMessage(message)) {
|
|
13616
|
+
const itemId = pendingCompactSummaryItemId ?? `claude-compaction-${messageUuid(message, randomUUID2())}`;
|
|
13617
|
+
pendingCompactSummaryItemId = null;
|
|
13618
|
+
pendingCompactBoundaryItemId = itemId;
|
|
13619
|
+
upsertCurrentItem(
|
|
13620
|
+
withHistoryItemCreatedAt(
|
|
13621
|
+
claudeContextCompactionItem(itemId, "completed"),
|
|
13622
|
+
sessionMessageTimestamp(message) ?? current?.startedAt
|
|
13623
|
+
)
|
|
13624
|
+
);
|
|
13625
|
+
continue;
|
|
13626
|
+
}
|
|
13503
13627
|
if (message.type === "user") {
|
|
13504
13628
|
const taskNotification = taskNotificationToolResult(message.message);
|
|
13505
13629
|
if (taskNotification) {
|
|
@@ -13544,6 +13668,20 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
13544
13668
|
}
|
|
13545
13669
|
}
|
|
13546
13670
|
if (message.type === "user" && !message.parent_tool_use_id) {
|
|
13671
|
+
if (isClaudeCompactSummaryMessage(message)) {
|
|
13672
|
+
const itemId = pendingCompactBoundaryItemId ?? `claude-compaction-${messageUuid(message, randomUUID2())}`;
|
|
13673
|
+
if (!pendingCompactBoundaryItemId) {
|
|
13674
|
+
pendingCompactSummaryItemId = itemId;
|
|
13675
|
+
}
|
|
13676
|
+
pendingCompactBoundaryItemId = null;
|
|
13677
|
+
upsertCurrentItem(
|
|
13678
|
+
withHistoryItemCreatedAt(
|
|
13679
|
+
claudeContextCompactionItem(itemId, "completed"),
|
|
13680
|
+
sessionMessageTimestamp(message) ?? current?.startedAt
|
|
13681
|
+
)
|
|
13682
|
+
);
|
|
13683
|
+
continue;
|
|
13684
|
+
}
|
|
13547
13685
|
if (isHiddenInitMessage(message.message)) {
|
|
13548
13686
|
skippingHiddenInit = true;
|
|
13549
13687
|
current = null;
|
|
@@ -13563,19 +13701,19 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
|
|
|
13563
13701
|
items: current.items
|
|
13564
13702
|
}));
|
|
13565
13703
|
}
|
|
13566
|
-
const
|
|
13567
|
-
const userStartedAt = isoFromUuidV7(
|
|
13704
|
+
const userMessageUuid = message.uuid ?? randomUUID2();
|
|
13705
|
+
const userStartedAt = isoFromUuidV7(userMessageUuid);
|
|
13568
13706
|
const userItem = await this.userMessageToHistoryItem(
|
|
13569
|
-
|
|
13707
|
+
userMessageUuid,
|
|
13570
13708
|
message.message,
|
|
13571
13709
|
context
|
|
13572
13710
|
);
|
|
13573
13711
|
const stampedUserItem = withHistoryItemCreatedAt(userItem, userStartedAt);
|
|
13574
13712
|
current = {
|
|
13575
|
-
providerTurnId: `claude-turn-${
|
|
13713
|
+
providerTurnId: `claude-turn-${userMessageUuid}`,
|
|
13576
13714
|
startedAt: userStartedAt,
|
|
13577
13715
|
items: [stampedUserItem],
|
|
13578
|
-
itemsById: /* @__PURE__ */ new Map([[
|
|
13716
|
+
itemsById: /* @__PURE__ */ new Map([[userMessageUuid, stampedUserItem]])
|
|
13579
13717
|
};
|
|
13580
13718
|
continue;
|
|
13581
13719
|
}
|