@theokit/sdk 2.11.1 → 2.11.3

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/eval.js CHANGED
@@ -8544,6 +8544,9 @@ async function streamLlmTurn(inputs, ctx) {
8544
8544
  const effort = reasoningEffortFromParams(inputs.model.params);
8545
8545
  return effort !== void 0 ? { reasoning: { effort } } : {};
8546
8546
  })(),
8547
+ // Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
8548
+ // text close even though tools are advertised). Absent ⇒ provider default (auto).
8549
+ ...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
8547
8550
  messages: ctx.messages,
8548
8551
  tools: ctx.tools.map(toLlmTool)
8549
8552
  },
@@ -11015,6 +11018,16 @@ var OpenAIClient = class {
11015
11018
  } catch {
11016
11019
  continue;
11017
11020
  }
11021
+ if (chunk.error !== void 0 && chunk.error !== null) {
11022
+ const status = typeof chunk.error.code === "number" ? chunk.error.code : 502;
11023
+ throw mapOpenAICompatibleError({
11024
+ providerId,
11025
+ status,
11026
+ body: chunk,
11027
+ headers: response.headers,
11028
+ endpoint: "/v1/chat/completions"
11029
+ });
11030
+ }
11018
11031
  const events = accumulator.consume(chunk);
11019
11032
  for (const event of events) yield event;
11020
11033
  }
@@ -11118,6 +11131,14 @@ function applyReasoningRequest(body, effort, providerName) {
11118
11131
  }
11119
11132
  body.reasoning = { effort };
11120
11133
  }
11134
+ function applyToolsRequest(body, request) {
11135
+ if (request.tools === void 0 || request.tools.length === 0) return;
11136
+ body.tools = request.tools.map((tool) => ({
11137
+ type: "function",
11138
+ function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
11139
+ }));
11140
+ if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
11141
+ }
11121
11142
  function buildOpenAIBody(request, providerName) {
11122
11143
  const messages = [];
11123
11144
  const systemText = openAISystemText(request.system);
@@ -11139,12 +11160,7 @@ function buildOpenAIBody(request, providerName) {
11139
11160
  if (request.temperature !== void 0) body.temperature = request.temperature;
11140
11161
  if (request.reasoning?.effort !== void 0)
11141
11162
  applyReasoningRequest(body, request.reasoning.effort, providerName);
11142
- if (request.tools !== void 0 && request.tools.length > 0) {
11143
- body.tools = request.tools.map((tool) => ({
11144
- type: "function",
11145
- function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
11146
- }));
11147
- }
11163
+ applyToolsRequest(body, request);
11148
11164
  const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
11149
11165
  if (responseFormat !== void 0) body.response_format = responseFormat;
11150
11166
  return body;
@@ -11987,6 +12003,7 @@ function buildLoopInputs(options, runId, userText) {
11987
12003
  ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
11988
12004
  ...options.onStep !== void 0 ? { onStep: options.onStep } : {},
11989
12005
  ...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
12006
+ ...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
11990
12007
  ...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
11991
12008
  ...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
11992
12009
  ...buildCustomToolsInput(