@nextclaw/nextclaw-engine-codex-sdk 0.2.0 → 0.2.2
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 +16 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -89,6 +89,15 @@ function readSandboxMode(input, key) {
|
|
|
89
89
|
}
|
|
90
90
|
return void 0;
|
|
91
91
|
}
|
|
92
|
+
function toAbortError(reason) {
|
|
93
|
+
if (reason instanceof Error) {
|
|
94
|
+
return reason;
|
|
95
|
+
}
|
|
96
|
+
const message = typeof reason === "string" && reason.trim() ? reason.trim() : "operation aborted";
|
|
97
|
+
const error = new Error(message);
|
|
98
|
+
error.name = "AbortError";
|
|
99
|
+
return error;
|
|
100
|
+
}
|
|
92
101
|
function readApprovalPolicy(input, key) {
|
|
93
102
|
const value = readString(input, key);
|
|
94
103
|
if (value === "never" || value === "on-request" || value === "on-failure" || value === "untrusted") {
|
|
@@ -119,6 +128,7 @@ class PluginCodexSdkEngine {
|
|
|
119
128
|
this.skillsLoader = new SkillsLoader(options.workspace);
|
|
120
129
|
}
|
|
121
130
|
kind = "codex-sdk";
|
|
131
|
+
supportsAbort = true;
|
|
122
132
|
codexPromise = null;
|
|
123
133
|
threads = /* @__PURE__ */ new Map();
|
|
124
134
|
defaultModel;
|
|
@@ -169,7 +179,9 @@ class PluginCodexSdkEngine {
|
|
|
169
179
|
params.content
|
|
170
180
|
].join("\n\n") : params.content;
|
|
171
181
|
const thread = await this.resolveThread(sessionKey, model);
|
|
172
|
-
const streamed = await thread.runStreamed(prompt
|
|
182
|
+
const streamed = await thread.runStreamed(prompt, {
|
|
183
|
+
...params.abortSignal ? { signal: params.abortSignal } : {}
|
|
184
|
+
});
|
|
173
185
|
const itemTextById = /* @__PURE__ */ new Map();
|
|
174
186
|
const completedAgentMessages = [];
|
|
175
187
|
for await (const event of streamed.events) {
|
|
@@ -193,6 +205,9 @@ class PluginCodexSdkEngine {
|
|
|
193
205
|
throw new Error(event.message);
|
|
194
206
|
}
|
|
195
207
|
}
|
|
208
|
+
if (params.abortSignal?.aborted) {
|
|
209
|
+
throw toAbortError(params.abortSignal.reason);
|
|
210
|
+
}
|
|
196
211
|
const reply = completedAgentMessages.join("\n").trim();
|
|
197
212
|
const assistantEvent = this.options.sessionManager.addMessage(session, "assistant", reply, {
|
|
198
213
|
channel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/nextclaw-engine-codex-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NextClaw Codex engine plugin backed by OpenAI Codex SDK.",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
]
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@nextclaw/core": "^0.7.
|
|
25
|
+
"@nextclaw/core": "^0.7.5",
|
|
26
26
|
"@openai/codex-sdk": "^0.107.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|