@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.
@@ -1,4 +1,4 @@
1
- import { C as CustomTool, M as ModelSelection, F as SDKUserMessage, H as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, T as StreamToCompletionResult, a as McpServerConfig } from './run-D22b53SU.js';
1
+ import { C as CustomTool, M as ModelSelection, F as SDKUserMessage, H as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, T as StreamToCompletionResult, a as McpServerConfig } from './run-TMdc7gmo.js';
2
2
 
3
3
  /**
4
4
  * Fork primitive public type contracts (T1.2, ADRs D110-D114).
@@ -1,4 +1,4 @@
1
- import { C as CustomTool, M as ModelSelection, F as SDKUserMessage, H as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, T as StreamToCompletionResult, a as McpServerConfig } from './run-D22b53SU.cjs';
1
+ import { C as CustomTool, M as ModelSelection, F as SDKUserMessage, H as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, T as StreamToCompletionResult, a as McpServerConfig } from './run-TMdc7gmo.cjs';
2
2
 
3
3
  /**
4
4
  * Fork primitive public type contracts (T1.2, ADRs D110-D114).
package/dist/cron.cjs CHANGED
@@ -8552,6 +8552,9 @@ async function streamLlmTurn(inputs, ctx) {
8552
8552
  const effort = reasoningEffortFromParams(inputs.model.params);
8553
8553
  return effort !== void 0 ? { reasoning: { effort } } : {};
8554
8554
  })(),
8555
+ // Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
8556
+ // text close even though tools are advertised). Absent ⇒ provider default (auto).
8557
+ ...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
8555
8558
  messages: ctx.messages,
8556
8559
  tools: ctx.tools.map(toLlmTool)
8557
8560
  },
@@ -11023,6 +11026,16 @@ var OpenAIClient = class {
11023
11026
  } catch {
11024
11027
  continue;
11025
11028
  }
11029
+ if (chunk.error !== void 0 && chunk.error !== null) {
11030
+ const status = typeof chunk.error.code === "number" ? chunk.error.code : 502;
11031
+ throw mapOpenAICompatibleError({
11032
+ providerId,
11033
+ status,
11034
+ body: chunk,
11035
+ headers: response.headers,
11036
+ endpoint: "/v1/chat/completions"
11037
+ });
11038
+ }
11026
11039
  const events = accumulator.consume(chunk);
11027
11040
  for (const event of events) yield event;
11028
11041
  }
@@ -11126,6 +11139,14 @@ function applyReasoningRequest(body, effort, providerName) {
11126
11139
  }
11127
11140
  body.reasoning = { effort };
11128
11141
  }
11142
+ function applyToolsRequest(body, request) {
11143
+ if (request.tools === void 0 || request.tools.length === 0) return;
11144
+ body.tools = request.tools.map((tool) => ({
11145
+ type: "function",
11146
+ function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
11147
+ }));
11148
+ if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
11149
+ }
11129
11150
  function buildOpenAIBody(request, providerName) {
11130
11151
  const messages = [];
11131
11152
  const systemText = openAISystemText(request.system);
@@ -11147,12 +11168,7 @@ function buildOpenAIBody(request, providerName) {
11147
11168
  if (request.temperature !== void 0) body.temperature = request.temperature;
11148
11169
  if (request.reasoning?.effort !== void 0)
11149
11170
  applyReasoningRequest(body, request.reasoning.effort, providerName);
11150
- if (request.tools !== void 0 && request.tools.length > 0) {
11151
- body.tools = request.tools.map((tool) => ({
11152
- type: "function",
11153
- function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
11154
- }));
11155
- }
11171
+ applyToolsRequest(body, request);
11156
11172
  const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
11157
11173
  if (responseFormat !== void 0) body.response_format = responseFormat;
11158
11174
  return body;
@@ -11995,6 +12011,7 @@ function buildLoopInputs(options, runId, userText) {
11995
12011
  ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
11996
12012
  ...options.onStep !== void 0 ? { onStep: options.onStep } : {},
11997
12013
  ...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
12014
+ ...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
11998
12015
  ...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
11999
12016
  ...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
12000
12017
  ...buildCustomToolsInput(