codex-relay 1.4.11 → 1.4.13
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.js +22 -3
- package/package.json +1 -1
package/dist/src.js
CHANGED
|
@@ -182,6 +182,9 @@ var CodexAppServerClient = class {
|
|
|
182
182
|
get appServerMode() {
|
|
183
183
|
return this.activeMode;
|
|
184
184
|
}
|
|
185
|
+
isThreadSubscribed(threadId) {
|
|
186
|
+
return this.subscribedThreadIds.has(threadId);
|
|
187
|
+
}
|
|
185
188
|
initialize() {
|
|
186
189
|
return this.ensureInitialized();
|
|
187
190
|
}
|
|
@@ -3437,6 +3440,10 @@ async function startAppServerTurn(appServer, threadId, input) {
|
|
|
3437
3440
|
}
|
|
3438
3441
|
}
|
|
3439
3442
|
async function resumeAppServerThreadIfNeeded(appServer, threadId, input, runtime) {
|
|
3443
|
+
if (appServer.isThreadSubscribed?.(threadId) === false) {
|
|
3444
|
+
await resumeAppServerThread(appServer, threadId, input, runtime);
|
|
3445
|
+
return;
|
|
3446
|
+
}
|
|
3440
3447
|
if (typeof appServer.readThread !== "function") return;
|
|
3441
3448
|
let thread;
|
|
3442
3449
|
try {
|
|
@@ -4636,7 +4643,7 @@ function appServerUserMessageText(item) {
|
|
|
4636
4643
|
const skills = appServerUserMessageSkills(item);
|
|
4637
4644
|
return promptMarkdownWithSkills(promptWithAppServerImageReferences(item.content.map((content) => {
|
|
4638
4645
|
switch (content.type) {
|
|
4639
|
-
case "text": return content.text;
|
|
4646
|
+
case "text": return isCodexInjectedContextBlock(content.text) ? "" : content.text;
|
|
4640
4647
|
case "image":
|
|
4641
4648
|
case "localImage":
|
|
4642
4649
|
case "document":
|
|
@@ -4647,6 +4654,15 @@ function appServerUserMessageText(item) {
|
|
|
4647
4654
|
}
|
|
4648
4655
|
}).filter(Boolean).join("\n\n"), item.content), skills);
|
|
4649
4656
|
}
|
|
4657
|
+
function isAppServerInjectedContextMessage(item) {
|
|
4658
|
+
if (item.type !== "userMessage" || !("content" in item) || !Array.isArray(item.content)) return false;
|
|
4659
|
+
const content = item.content;
|
|
4660
|
+
return content.length > 0 && content.every((input) => input.type === "text" && isCodexInjectedContextBlock(input.text));
|
|
4661
|
+
}
|
|
4662
|
+
function isCodexInjectedContextBlock(value) {
|
|
4663
|
+
const text = value.trim();
|
|
4664
|
+
return text.startsWith("<recommended_plugins>") && text.endsWith("</recommended_plugins>") || text.startsWith("# AGENTS.md instructions for ") && text.includes("\n\n<INSTRUCTIONS>") && text.endsWith("</INSTRUCTIONS>") || text.startsWith("<environment_context>") && text.endsWith("</environment_context>");
|
|
4665
|
+
}
|
|
4650
4666
|
function appServerUserMessageDetails(item) {
|
|
4651
4667
|
const attachments = item.content.flatMap((content) => {
|
|
4652
4668
|
switch (content.type) {
|
|
@@ -5696,7 +5712,9 @@ function rolloutResponseItemMessageContent(payload, role) {
|
|
|
5696
5712
|
const text = payload.content.flatMap((item) => {
|
|
5697
5713
|
if (!item || typeof item !== "object") return [];
|
|
5698
5714
|
const contentItem = item;
|
|
5699
|
-
|
|
5715
|
+
if (contentItem.type !== expectedType || typeof contentItem.text !== "string") return [];
|
|
5716
|
+
if (role === "user" && isCodexInjectedContextBlock(contentItem.text)) return [];
|
|
5717
|
+
return [contentItem.text];
|
|
5700
5718
|
});
|
|
5701
5719
|
return text.length > 0 ? text.join("\n\n") : void 0;
|
|
5702
5720
|
}
|
|
@@ -5913,6 +5931,7 @@ function mapAppServerItem(threadId, turn, item) {
|
|
|
5913
5931
|
};
|
|
5914
5932
|
switch (item.type) {
|
|
5915
5933
|
case "userMessage": {
|
|
5934
|
+
if (isAppServerInjectedContextMessage(item)) return;
|
|
5916
5935
|
const userItem = item;
|
|
5917
5936
|
return ChatMessageSchema.parse({
|
|
5918
5937
|
...base,
|
|
@@ -6248,7 +6267,7 @@ function normalizeAppServerStatus(status) {
|
|
|
6248
6267
|
return status.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
6249
6268
|
}
|
|
6250
6269
|
function countThreadMessages(thread) {
|
|
6251
|
-
return thread.turns?.reduce((count, turn) => count + turn.items.filter((item) => item.type === "
|
|
6270
|
+
return thread.turns?.reduce((count, turn) => count + turn.items.filter((item) => item.type === "agentMessage" || item.type === "userMessage" && !isAppServerInjectedContextMessage(item)).length, 0) ?? 0;
|
|
6252
6271
|
}
|
|
6253
6272
|
function fromUnixSeconds(value) {
|
|
6254
6273
|
return (/* @__PURE__ */ new Date(value * 1e3)).toISOString();
|