@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/index.cjs CHANGED
@@ -11009,6 +11009,9 @@ async function streamLlmTurn(inputs, ctx) {
11009
11009
  const effort = reasoningEffortFromParams(inputs.model.params);
11010
11010
  return effort !== void 0 ? { reasoning: { effort } } : {};
11011
11011
  })(),
11012
+ // Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
11013
+ // text close even though tools are advertised). Absent ⇒ provider default (auto).
11014
+ ...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
11012
11015
  messages: ctx.messages,
11013
11016
  tools: ctx.tools.map(toLlmTool)
11014
11017
  },
@@ -13495,6 +13498,16 @@ var OpenAIClient = class {
13495
13498
  } catch {
13496
13499
  continue;
13497
13500
  }
13501
+ if (chunk.error !== void 0 && chunk.error !== null) {
13502
+ const status = typeof chunk.error.code === "number" ? chunk.error.code : 502;
13503
+ throw mapOpenAICompatibleError({
13504
+ providerId,
13505
+ status,
13506
+ body: chunk,
13507
+ headers: response.headers,
13508
+ endpoint: "/v1/chat/completions"
13509
+ });
13510
+ }
13498
13511
  const events = accumulator.consume(chunk);
13499
13512
  for (const event of events) yield event;
13500
13513
  }
@@ -13598,6 +13611,14 @@ function applyReasoningRequest(body, effort, providerName) {
13598
13611
  }
13599
13612
  body.reasoning = { effort };
13600
13613
  }
13614
+ function applyToolsRequest(body, request) {
13615
+ if (request.tools === void 0 || request.tools.length === 0) return;
13616
+ body.tools = request.tools.map((tool) => ({
13617
+ type: "function",
13618
+ function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
13619
+ }));
13620
+ if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
13621
+ }
13601
13622
  function buildOpenAIBody(request, providerName) {
13602
13623
  const messages = [];
13603
13624
  const systemText = openAISystemText(request.system);
@@ -13619,12 +13640,7 @@ function buildOpenAIBody(request, providerName) {
13619
13640
  if (request.temperature !== void 0) body.temperature = request.temperature;
13620
13641
  if (request.reasoning?.effort !== void 0)
13621
13642
  applyReasoningRequest(body, request.reasoning.effort, providerName);
13622
- if (request.tools !== void 0 && request.tools.length > 0) {
13623
- body.tools = request.tools.map((tool) => ({
13624
- type: "function",
13625
- function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
13626
- }));
13627
- }
13643
+ applyToolsRequest(body, request);
13628
13644
  const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
13629
13645
  if (responseFormat !== void 0) body.response_format = responseFormat;
13630
13646
  return body;
@@ -14468,6 +14484,7 @@ function buildLoopInputs(options, runId, userText) {
14468
14484
  ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
14469
14485
  ...options.onStep !== void 0 ? { onStep: options.onStep } : {},
14470
14486
  ...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
14487
+ ...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
14471
14488
  ...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
14472
14489
  ...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
14473
14490
  ...buildCustomToolsInput(