@codex-native/sdk 0.0.35 → 0.0.37

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.mjs CHANGED
@@ -95,6 +95,23 @@ var CodexProvider = class {
95
95
  this.getCodex().setApprovalCallback(callback);
96
96
  }
97
97
  };
98
+ var normalizeToolChoice = (toolChoice) => {
99
+ if (toolChoice === void 0) {
100
+ return void 0;
101
+ }
102
+ if (toolChoice === "auto" || toolChoice === "none" || toolChoice === "required") {
103
+ return toolChoice;
104
+ }
105
+ if (typeof toolChoice === "string") {
106
+ return {
107
+ type: "function",
108
+ function: {
109
+ name: toolChoice
110
+ }
111
+ };
112
+ }
113
+ return toolChoice;
114
+ };
98
115
  var CodexModel = class {
99
116
  codex;
100
117
  modelName;
@@ -186,7 +203,7 @@ var CodexModel = class {
186
203
  this.registerRequestTools(request.tools);
187
204
  }
188
205
  const input = await this.convertRequestToInput(request);
189
- const toolChoice = request.modelSettings?.toolChoice ?? void 0;
206
+ const toolChoice = normalizeToolChoice(request.modelSettings?.toolChoice);
190
207
  const turn = await thread.run(input, {
191
208
  outputSchema: normalizeAgentsOutputType(request.outputType),
192
209
  oss: this.options.oss,
@@ -214,7 +231,7 @@ var CodexModel = class {
214
231
  this.registerRequestTools(request.tools);
215
232
  }
216
233
  const input = await this.convertRequestToInput(request);
217
- const toolChoice = request.modelSettings?.toolChoice ?? void 0;
234
+ const toolChoice = normalizeToolChoice(request.modelSettings?.toolChoice);
218
235
  const { events } = await thread.runStreamed(input, {
219
236
  outputSchema: normalizeAgentsOutputType(request.outputType),
220
237
  oss: this.options.oss,
@@ -762,10 +779,6 @@ ${request.systemInstructions}
762
779
  type: "output_text_delta",
763
780
  delta
764
781
  });
765
- events.push({
766
- type: "response.output_text.delta",
767
- delta
768
- });
769
782
  }
770
783
  } else if (event.item.type === "reasoning") {
771
784
  const itemKey = "reasoning";
@@ -882,7 +895,11 @@ ${request.systemInstructions}
882
895
  default:
883
896
  break;
884
897
  }
885
- if (event?.type !== "raw_event") {
898
+ const eventType = event?.type;
899
+ const itemType = event?.item?.type;
900
+ const skipRawEvent = eventType === "raw_event" || eventType === "turn.completed" || // Already emits response.completed + response_done
901
+ eventType === "item.started" && (itemType === "agent_message" || itemType === "reasoning") || eventType === "item.updated" && (itemType === "agent_message" || itemType === "reasoning") || eventType === "item.completed" && (itemType === "agent_message" || itemType === "reasoning");
902
+ if (!skipRawEvent) {
886
903
  const rawEvent = {
887
904
  type: "raw_event",
888
905
  raw: event