codex-relay 1.4.10 → 1.4.12
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 +20 -5
- package/package.json +1 -1
package/dist/src.js
CHANGED
|
@@ -192,7 +192,6 @@ var CodexAppServerClient = class {
|
|
|
192
192
|
do {
|
|
193
193
|
const response = await this.request("thread/list", {
|
|
194
194
|
archived: false,
|
|
195
|
-
cursor,
|
|
196
195
|
limit,
|
|
197
196
|
sortDirection: "desc",
|
|
198
197
|
sortKey: "recency_at",
|
|
@@ -201,7 +200,11 @@ var CodexAppServerClient = class {
|
|
|
201
200
|
"vscode",
|
|
202
201
|
"exec",
|
|
203
202
|
"appServer"
|
|
204
|
-
]
|
|
203
|
+
],
|
|
204
|
+
...cursor ? {
|
|
205
|
+
cursor,
|
|
206
|
+
useStateDbOnly: true
|
|
207
|
+
} : {}
|
|
205
208
|
});
|
|
206
209
|
threads.push(...response.data);
|
|
207
210
|
const nextCursor = response.nextCursor ?? void 0;
|
|
@@ -4633,7 +4636,7 @@ function appServerUserMessageText(item) {
|
|
|
4633
4636
|
const skills = appServerUserMessageSkills(item);
|
|
4634
4637
|
return promptMarkdownWithSkills(promptWithAppServerImageReferences(item.content.map((content) => {
|
|
4635
4638
|
switch (content.type) {
|
|
4636
|
-
case "text": return content.text;
|
|
4639
|
+
case "text": return isCodexInjectedContextBlock(content.text) ? "" : content.text;
|
|
4637
4640
|
case "image":
|
|
4638
4641
|
case "localImage":
|
|
4639
4642
|
case "document":
|
|
@@ -4644,6 +4647,15 @@ function appServerUserMessageText(item) {
|
|
|
4644
4647
|
}
|
|
4645
4648
|
}).filter(Boolean).join("\n\n"), item.content), skills);
|
|
4646
4649
|
}
|
|
4650
|
+
function isAppServerInjectedContextMessage(item) {
|
|
4651
|
+
if (item.type !== "userMessage" || !("content" in item) || !Array.isArray(item.content)) return false;
|
|
4652
|
+
const content = item.content;
|
|
4653
|
+
return content.length > 0 && content.every((input) => input.type === "text" && isCodexInjectedContextBlock(input.text));
|
|
4654
|
+
}
|
|
4655
|
+
function isCodexInjectedContextBlock(value) {
|
|
4656
|
+
const text = value.trim();
|
|
4657
|
+
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>");
|
|
4658
|
+
}
|
|
4647
4659
|
function appServerUserMessageDetails(item) {
|
|
4648
4660
|
const attachments = item.content.flatMap((content) => {
|
|
4649
4661
|
switch (content.type) {
|
|
@@ -5693,7 +5705,9 @@ function rolloutResponseItemMessageContent(payload, role) {
|
|
|
5693
5705
|
const text = payload.content.flatMap((item) => {
|
|
5694
5706
|
if (!item || typeof item !== "object") return [];
|
|
5695
5707
|
const contentItem = item;
|
|
5696
|
-
|
|
5708
|
+
if (contentItem.type !== expectedType || typeof contentItem.text !== "string") return [];
|
|
5709
|
+
if (role === "user" && isCodexInjectedContextBlock(contentItem.text)) return [];
|
|
5710
|
+
return [contentItem.text];
|
|
5697
5711
|
});
|
|
5698
5712
|
return text.length > 0 ? text.join("\n\n") : void 0;
|
|
5699
5713
|
}
|
|
@@ -5910,6 +5924,7 @@ function mapAppServerItem(threadId, turn, item) {
|
|
|
5910
5924
|
};
|
|
5911
5925
|
switch (item.type) {
|
|
5912
5926
|
case "userMessage": {
|
|
5927
|
+
if (isAppServerInjectedContextMessage(item)) return;
|
|
5913
5928
|
const userItem = item;
|
|
5914
5929
|
return ChatMessageSchema.parse({
|
|
5915
5930
|
...base,
|
|
@@ -6245,7 +6260,7 @@ function normalizeAppServerStatus(status) {
|
|
|
6245
6260
|
return status.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
6246
6261
|
}
|
|
6247
6262
|
function countThreadMessages(thread) {
|
|
6248
|
-
return thread.turns?.reduce((count, turn) => count + turn.items.filter((item) => item.type === "
|
|
6263
|
+
return thread.turns?.reduce((count, turn) => count + turn.items.filter((item) => item.type === "agentMessage" || item.type === "userMessage" && !isAppServerInjectedContextMessage(item)).length, 0) ?? 0;
|
|
6249
6264
|
}
|
|
6250
6265
|
function fromUnixSeconds(value) {
|
|
6251
6266
|
return (/* @__PURE__ */ new Date(value * 1e3)).toISOString();
|