@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.d.mts
CHANGED
|
@@ -1190,7 +1190,7 @@ type ToolExecutorResult = string | NativeToolResult | {
|
|
|
1190
1190
|
output?: string;
|
|
1191
1191
|
error?: string;
|
|
1192
1192
|
success?: boolean;
|
|
1193
|
-
} | void;
|
|
1193
|
+
} | Record<string, unknown> | unknown[] | number | boolean | null | void;
|
|
1194
1194
|
type ToolExecutor = (context: ToolExecutionContext) => Promise<ToolExecutorResult> | ToolExecutorResult;
|
|
1195
1195
|
declare function registerCodexToolExecutor(name: string, executor: ToolExecutor): void;
|
|
1196
1196
|
declare function getCodexToolExecutor(name: string): ToolExecutor | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -1190,7 +1190,7 @@ type ToolExecutorResult = string | NativeToolResult | {
|
|
|
1190
1190
|
output?: string;
|
|
1191
1191
|
error?: string;
|
|
1192
1192
|
success?: boolean;
|
|
1193
|
-
} | void;
|
|
1193
|
+
} | Record<string, unknown> | unknown[] | number | boolean | null | void;
|
|
1194
1194
|
type ToolExecutor = (context: ToolExecutionContext) => Promise<ToolExecutorResult> | ToolExecutorResult;
|
|
1195
1195
|
declare function registerCodexToolExecutor(name: string, executor: ToolExecutor): void;
|
|
1196
1196
|
declare function getCodexToolExecutor(name: string): ToolExecutor | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -163,6 +163,11 @@ var CodexModel = class {
|
|
|
163
163
|
getThreadOptions() {
|
|
164
164
|
return {
|
|
165
165
|
model: this.modelName,
|
|
166
|
+
// IMPORTANT: ModelProvider must be forwarded to thread options, otherwise
|
|
167
|
+
// codex-rs will fall back to the default provider from ~/.codex/config.toml
|
|
168
|
+
// (or another discovered config). This was causing Agents runs to ignore
|
|
169
|
+
// `new CodexProvider({ modelProvider: "github" })` and hit the wrong backend.
|
|
170
|
+
modelProvider: this.options.modelProvider,
|
|
166
171
|
// When a custom baseUrl is provided (e.g., test proxy), do not enable OSS mode,
|
|
167
172
|
// since the backend is not Ollama in that case.
|
|
168
173
|
oss: this.options.baseUrl ? false : this.options.oss,
|
|
@@ -264,10 +269,21 @@ var CodexModel = class {
|
|
|
264
269
|
};
|
|
265
270
|
this.codex.registerTool(nativeToolDef);
|
|
266
271
|
this.registeredTools.add(tool2.name);
|
|
267
|
-
|
|
272
|
+
const DEBUG = process.env.DEBUG === "1" || process.env.DEBUG === "true";
|
|
273
|
+
if (DEBUG) {
|
|
274
|
+
try {
|
|
275
|
+
process.stderr.write(`[codex-native] Registered tool with Codex: ${tool2.name}
|
|
276
|
+
`);
|
|
277
|
+
} catch {
|
|
278
|
+
}
|
|
279
|
+
}
|
|
268
280
|
} catch (error) {
|
|
269
281
|
const errorMessage = `Failed to register tool ${tool2.name}: ${error instanceof Error ? error.message : String(error)}`;
|
|
270
|
-
|
|
282
|
+
try {
|
|
283
|
+
process.stderr.write(`[codex-native] ${errorMessage}
|
|
284
|
+
`);
|
|
285
|
+
} catch {
|
|
286
|
+
}
|
|
271
287
|
}
|
|
272
288
|
}
|
|
273
289
|
}
|
|
@@ -292,11 +308,21 @@ var CodexModel = class {
|
|
|
292
308
|
* but the framework integration is not yet complete.
|
|
293
309
|
*/
|
|
294
310
|
async executeToolViaFramework(invocation) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
311
|
+
const DEBUG = process.env.DEBUG === "1" || process.env.DEBUG === "true";
|
|
312
|
+
if (DEBUG) {
|
|
313
|
+
try {
|
|
314
|
+
process.stderr.write(
|
|
315
|
+
`[codex-native] executeToolViaFramework invocation: ${JSON.stringify(invocation)}
|
|
316
|
+
`
|
|
317
|
+
);
|
|
318
|
+
} catch {
|
|
319
|
+
}
|
|
320
|
+
}
|
|
298
321
|
if (!invocation) {
|
|
299
|
-
|
|
322
|
+
try {
|
|
323
|
+
process.stderr.write("[codex-native] Codex requested a tool execution without invocation data.\n");
|
|
324
|
+
} catch {
|
|
325
|
+
}
|
|
300
326
|
return {
|
|
301
327
|
output: JSON.stringify({
|
|
302
328
|
message: "Tool invocation payload missing",
|
|
@@ -306,13 +332,23 @@ var CodexModel = class {
|
|
|
306
332
|
error: "Missing tool invocation data from Codex"
|
|
307
333
|
};
|
|
308
334
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
335
|
+
if (DEBUG) {
|
|
336
|
+
try {
|
|
337
|
+
process.stderr.write(
|
|
338
|
+
`[codex-native] Tool execution requested: ${invocation.toolName} (callId: ${invocation.callId})
|
|
339
|
+
`
|
|
340
|
+
);
|
|
341
|
+
} catch {
|
|
342
|
+
}
|
|
343
|
+
}
|
|
312
344
|
const executor = this.toolExecutors.get(invocation.toolName) ?? getCodexToolExecutor(invocation.toolName);
|
|
313
345
|
if (!executor) {
|
|
314
346
|
const message = `No Codex executor registered for tool '${invocation.toolName}'. Use codexTool() or provide a codexExecute handler.`;
|
|
315
|
-
|
|
347
|
+
try {
|
|
348
|
+
process.stderr.write(`[codex-native] ${message}
|
|
349
|
+
`);
|
|
350
|
+
} catch {
|
|
351
|
+
}
|
|
316
352
|
return {
|
|
317
353
|
success: false,
|
|
318
354
|
error: message,
|
|
@@ -357,7 +393,15 @@ var CodexModel = class {
|
|
|
357
393
|
if (typeof result === "string") {
|
|
358
394
|
return { success: true, output: result };
|
|
359
395
|
}
|
|
360
|
-
|
|
396
|
+
const isNativeToolResultLike = (value) => {
|
|
397
|
+
if (!value || typeof value !== "object") return false;
|
|
398
|
+
if (!("output" in value) && !("error" in value) && !("success" in value)) return false;
|
|
399
|
+
if ("success" in value && value.success != null && typeof value.success !== "boolean") return false;
|
|
400
|
+
if ("output" in value && value.output != null && typeof value.output !== "string") return false;
|
|
401
|
+
if ("error" in value && value.error != null && typeof value.error !== "string") return false;
|
|
402
|
+
return true;
|
|
403
|
+
};
|
|
404
|
+
if (isNativeToolResultLike(result)) {
|
|
361
405
|
return {
|
|
362
406
|
success: result.success ?? !result.error,
|
|
363
407
|
output: result.output,
|