@nextclaw/nextclaw-ncp-runtime-plugin-codex-sdk 0.1.28 → 0.1.30
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/index.js +22 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ function resolveExternalModelProvider(params) {
|
|
|
20
20
|
return explicitModelProvider;
|
|
21
21
|
}
|
|
22
22
|
const providerName = readOptionalString(params.providerName);
|
|
23
|
-
if (providerName
|
|
23
|
+
if (providerName) {
|
|
24
24
|
return providerName;
|
|
25
25
|
}
|
|
26
26
|
const providerDisplayName = readOptionalString(params.providerDisplayName);
|
|
@@ -108,12 +108,13 @@ function buildCodexInputBuilder(runtimeAgent, workspace) {
|
|
|
108
108
|
return async (input) => {
|
|
109
109
|
const userText = readUserText(input);
|
|
110
110
|
const metadata = input.metadata && typeof input.metadata === "object" && !Array.isArray(input.metadata) ? input.metadata : {};
|
|
111
|
-
|
|
111
|
+
const prompt = runtimeAgent.buildRuntimeUserPrompt({
|
|
112
112
|
workspace,
|
|
113
113
|
sessionKey: input.sessionId,
|
|
114
114
|
metadata,
|
|
115
115
|
userMessage: userText
|
|
116
116
|
});
|
|
117
|
+
return prompt;
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
120
|
|
|
@@ -1056,6 +1057,19 @@ function readErrorMessage(value) {
|
|
|
1056
1057
|
const record = value;
|
|
1057
1058
|
return readString(record.message) ?? readString(record.error) ?? "";
|
|
1058
1059
|
}
|
|
1060
|
+
function didReceiveResponseCompleted(rawText) {
|
|
1061
|
+
for (const block of rawText.split(/\r?\n\r?\n/g)) {
|
|
1062
|
+
const trimmedBlock = block.trim();
|
|
1063
|
+
if (!trimmedBlock) {
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1066
|
+
const eventLine = trimmedBlock.split(/\r?\n/g).find((line) => line.startsWith("event:"));
|
|
1067
|
+
if (eventLine?.slice("event:".length).trim() === "response.completed") {
|
|
1068
|
+
return true;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return false;
|
|
1072
|
+
}
|
|
1059
1073
|
function shouldTreatResponsesProbeFailureAsUnsupported(params) {
|
|
1060
1074
|
const normalizedMessage = params.message.trim().toLowerCase();
|
|
1061
1075
|
if (params.status === 404 || params.status === 405 || params.status === 501) {
|
|
@@ -1097,7 +1111,7 @@ async function probeCodexResponsesApiSupport(params) {
|
|
|
1097
1111
|
model: params.model,
|
|
1098
1112
|
input: "ping",
|
|
1099
1113
|
max_output_tokens: 1,
|
|
1100
|
-
stream:
|
|
1114
|
+
stream: true
|
|
1101
1115
|
})
|
|
1102
1116
|
});
|
|
1103
1117
|
const rawText = await response.text();
|
|
@@ -1110,8 +1124,11 @@ async function probeCodexResponsesApiSupport(params) {
|
|
|
1110
1124
|
const parsedRecord = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
1111
1125
|
const message = readErrorMessage(parsedRecord?.error) || readErrorMessage(parsed) || rawText.slice(0, 240);
|
|
1112
1126
|
const responseFailed = readString(parsedRecord?.status)?.toLowerCase() === "failed" || Boolean(parsedRecord?.error);
|
|
1113
|
-
if (response.ok
|
|
1114
|
-
return
|
|
1127
|
+
if (!response.ok || responseFailed) {
|
|
1128
|
+
return false;
|
|
1129
|
+
}
|
|
1130
|
+
if (!didReceiveResponseCompleted(rawText)) {
|
|
1131
|
+
return false;
|
|
1115
1132
|
}
|
|
1116
1133
|
return !shouldTreatResponsesProbeFailureAsUnsupported({
|
|
1117
1134
|
status: response.status,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/nextclaw-ncp-runtime-plugin-codex-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NextClaw plugin that registers Codex SDK as an optional NCP runtime.",
|
|
6
6
|
"type": "module",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@nextclaw/ncp-toolkit": "0.4.4",
|
|
25
24
|
"@nextclaw/ncp": "0.4.0",
|
|
26
|
-
"@nextclaw/
|
|
25
|
+
"@nextclaw/ncp-toolkit": "0.4.4",
|
|
26
|
+
"@nextclaw/nextclaw-ncp-runtime-codex-sdk": "0.1.7"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^20.17.6",
|