@nextclaw/nextclaw-ncp-runtime-codex-sdk 0.1.5 → 0.1.7
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/codex-cli-env.d.ts +7 -0
- package/dist/codex-cli-env.js +36 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -13
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function readString(value) {
|
|
2
|
+
if (typeof value !== "string") {
|
|
3
|
+
return void 0;
|
|
4
|
+
}
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
function copyProcessEnv() {
|
|
8
|
+
const env = {};
|
|
9
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
10
|
+
const normalized = readString(value);
|
|
11
|
+
if (normalized === void 0) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
env[key] = normalized;
|
|
15
|
+
}
|
|
16
|
+
return env;
|
|
17
|
+
}
|
|
18
|
+
function buildCodexCliEnv(config) {
|
|
19
|
+
const env = copyProcessEnv();
|
|
20
|
+
for (const [key, value] of Object.entries(config.env ?? {})) {
|
|
21
|
+
if (typeof value !== "string") {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
env[key] = value;
|
|
25
|
+
}
|
|
26
|
+
if (config.apiKey.trim()) {
|
|
27
|
+
env.OPENAI_API_KEY = config.apiKey;
|
|
28
|
+
}
|
|
29
|
+
if (config.apiBase?.trim()) {
|
|
30
|
+
env.OPENAI_BASE_URL = config.apiBase.trim();
|
|
31
|
+
}
|
|
32
|
+
return Object.keys(env).length > 0 ? env : void 0;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
buildCodexCliEnv
|
|
36
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CodexOptions, ThreadOptions } from '@openai/codex-sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { NcpAgentRunInput, NcpAgentConversationStateManager, NcpAgentRuntime, NcpAgentRunOptions, NcpEndpointEvent } from '@nextclaw/ncp';
|
|
3
3
|
|
|
4
4
|
type CodexSdkNcpAgentRuntimeConfig = {
|
|
5
5
|
sessionId: string;
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
mapCodexItemEvent
|
|
7
7
|
} from "./codex-sdk-ncp-event-mapper.js";
|
|
8
|
+
import { buildCodexCliEnv } from "./codex-cli-env.js";
|
|
8
9
|
const require2 = createRequire(import.meta.url);
|
|
9
10
|
const codexLoader = require2("../codex-sdk-loader.cjs");
|
|
10
11
|
function createId(prefix) {
|
|
@@ -32,18 +33,6 @@ function toAbortError(reason) {
|
|
|
32
33
|
error.name = "AbortError";
|
|
33
34
|
return error;
|
|
34
35
|
}
|
|
35
|
-
function buildCliEnv(config) {
|
|
36
|
-
const env = {
|
|
37
|
-
...config.env ?? {}
|
|
38
|
-
};
|
|
39
|
-
if (config.apiKey.trim()) {
|
|
40
|
-
env.OPENAI_API_KEY = config.apiKey;
|
|
41
|
-
}
|
|
42
|
-
if (config.apiBase?.trim()) {
|
|
43
|
-
env.OPENAI_BASE_URL = config.apiBase.trim();
|
|
44
|
-
}
|
|
45
|
-
return Object.keys(env).length > 0 ? env : void 0;
|
|
46
|
-
}
|
|
47
36
|
function normalizeThreadOptions(options, model) {
|
|
48
37
|
return {
|
|
49
38
|
...options,
|
|
@@ -199,7 +188,7 @@ class CodexSdkNcpAgentRuntime {
|
|
|
199
188
|
}
|
|
200
189
|
async getCodex() {
|
|
201
190
|
if (!this.codexPromise) {
|
|
202
|
-
const env =
|
|
191
|
+
const env = buildCodexCliEnv(this.config);
|
|
203
192
|
this.codexPromise = codexLoader.loadCodexConstructor().then(
|
|
204
193
|
(Ctor) => new Ctor({
|
|
205
194
|
apiKey: this.config.apiKey,
|