@codex-native/sdk 0.0.24 → 0.0.26
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/cli.cjs +10 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +10 -10
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +55 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +55 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -2505,6 +2505,11 @@ var CodexModel = class {
|
|
|
2505
2505
|
getThreadOptions() {
|
|
2506
2506
|
return {
|
|
2507
2507
|
model: this.modelName,
|
|
2508
|
+
// IMPORTANT: ModelProvider must be forwarded to thread options, otherwise
|
|
2509
|
+
// codex-rs will fall back to the default provider from ~/.codex/config.toml
|
|
2510
|
+
// (or another discovered config). This was causing Agents runs to ignore
|
|
2511
|
+
// `new CodexProvider({ modelProvider: "github" })` and hit the wrong backend.
|
|
2512
|
+
modelProvider: this.options.modelProvider,
|
|
2508
2513
|
// When a custom baseUrl is provided (e.g., test proxy), do not enable OSS mode,
|
|
2509
2514
|
// since the backend is not Ollama in that case.
|
|
2510
2515
|
oss: this.options.baseUrl ? false : this.options.oss,
|
|
@@ -2606,10 +2611,21 @@ var CodexModel = class {
|
|
|
2606
2611
|
};
|
|
2607
2612
|
this.codex.registerTool(nativeToolDef);
|
|
2608
2613
|
this.registeredTools.add(tool2.name);
|
|
2609
|
-
|
|
2614
|
+
const DEBUG = process.env.DEBUG === "1" || process.env.DEBUG === "true";
|
|
2615
|
+
if (DEBUG) {
|
|
2616
|
+
try {
|
|
2617
|
+
process.stderr.write(`[codex-native] Registered tool with Codex: ${tool2.name}
|
|
2618
|
+
`);
|
|
2619
|
+
} catch {
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2610
2622
|
} catch (error) {
|
|
2611
2623
|
const errorMessage = `Failed to register tool ${tool2.name}: ${error instanceof Error ? error.message : String(error)}`;
|
|
2612
|
-
|
|
2624
|
+
try {
|
|
2625
|
+
process.stderr.write(`[codex-native] ${errorMessage}
|
|
2626
|
+
`);
|
|
2627
|
+
} catch {
|
|
2628
|
+
}
|
|
2613
2629
|
}
|
|
2614
2630
|
}
|
|
2615
2631
|
}
|
|
@@ -2634,11 +2650,21 @@ var CodexModel = class {
|
|
|
2634
2650
|
* but the framework integration is not yet complete.
|
|
2635
2651
|
*/
|
|
2636
2652
|
async executeToolViaFramework(invocation) {
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2653
|
+
const DEBUG = process.env.DEBUG === "1" || process.env.DEBUG === "true";
|
|
2654
|
+
if (DEBUG) {
|
|
2655
|
+
try {
|
|
2656
|
+
process.stderr.write(
|
|
2657
|
+
`[codex-native] executeToolViaFramework invocation: ${JSON.stringify(invocation)}
|
|
2658
|
+
`
|
|
2659
|
+
);
|
|
2660
|
+
} catch {
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2640
2663
|
if (!invocation) {
|
|
2641
|
-
|
|
2664
|
+
try {
|
|
2665
|
+
process.stderr.write("[codex-native] Codex requested a tool execution without invocation data.\n");
|
|
2666
|
+
} catch {
|
|
2667
|
+
}
|
|
2642
2668
|
return {
|
|
2643
2669
|
output: JSON.stringify({
|
|
2644
2670
|
message: "Tool invocation payload missing",
|
|
@@ -2648,13 +2674,23 @@ var CodexModel = class {
|
|
|
2648
2674
|
error: "Missing tool invocation data from Codex"
|
|
2649
2675
|
};
|
|
2650
2676
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2677
|
+
if (DEBUG) {
|
|
2678
|
+
try {
|
|
2679
|
+
process.stderr.write(
|
|
2680
|
+
`[codex-native] Tool execution requested: ${invocation.toolName} (callId: ${invocation.callId})
|
|
2681
|
+
`
|
|
2682
|
+
);
|
|
2683
|
+
} catch {
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2654
2686
|
const executor = this.toolExecutors.get(invocation.toolName) ?? getCodexToolExecutor(invocation.toolName);
|
|
2655
2687
|
if (!executor) {
|
|
2656
2688
|
const message = `No Codex executor registered for tool '${invocation.toolName}'. Use codexTool() or provide a codexExecute handler.`;
|
|
2657
|
-
|
|
2689
|
+
try {
|
|
2690
|
+
process.stderr.write(`[codex-native] ${message}
|
|
2691
|
+
`);
|
|
2692
|
+
} catch {
|
|
2693
|
+
}
|
|
2658
2694
|
return {
|
|
2659
2695
|
success: false,
|
|
2660
2696
|
error: message,
|
|
@@ -2699,7 +2735,15 @@ var CodexModel = class {
|
|
|
2699
2735
|
if (typeof result === "string") {
|
|
2700
2736
|
return { success: true, output: result };
|
|
2701
2737
|
}
|
|
2702
|
-
|
|
2738
|
+
const isNativeToolResultLike = (value) => {
|
|
2739
|
+
if (!value || typeof value !== "object") return false;
|
|
2740
|
+
if (!("output" in value) && !("error" in value) && !("success" in value)) return false;
|
|
2741
|
+
if ("success" in value && value.success != null && typeof value.success !== "boolean") return false;
|
|
2742
|
+
if ("output" in value && value.output != null && typeof value.output !== "string") return false;
|
|
2743
|
+
if ("error" in value && value.error != null && typeof value.error !== "string") return false;
|
|
2744
|
+
return true;
|
|
2745
|
+
};
|
|
2746
|
+
if (isNativeToolResultLike(result)) {
|
|
2703
2747
|
return {
|
|
2704
2748
|
success: result.success ?? !result.error,
|
|
2705
2749
|
output: result.output,
|