@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/a2a/index.js CHANGED
@@ -7105,6 +7105,9 @@ async function streamLlmTurn(inputs, ctx) {
7105
7105
  const effort = reasoningEffortFromParams(inputs.model.params);
7106
7106
  return effort !== void 0 ? { reasoning: { effort } } : {};
7107
7107
  })(),
7108
+ // Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
7109
+ // text close even though tools are advertised). Absent ⇒ provider default (auto).
7110
+ ...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
7108
7111
  messages: ctx.messages,
7109
7112
  tools: ctx.tools.map(toLlmTool)
7110
7113
  },
@@ -10111,6 +10114,14 @@ function applyReasoningRequest(body, effort, providerName) {
10111
10114
  }
10112
10115
  body.reasoning = { effort };
10113
10116
  }
10117
+ function applyToolsRequest(body, request) {
10118
+ if (request.tools === void 0 || request.tools.length === 0) return;
10119
+ body.tools = request.tools.map((tool) => ({
10120
+ type: "function",
10121
+ function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
10122
+ }));
10123
+ if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
10124
+ }
10114
10125
  function buildOpenAIBody(request, providerName) {
10115
10126
  const messages = [];
10116
10127
  const systemText = openAISystemText(request.system);
@@ -10132,12 +10143,7 @@ function buildOpenAIBody(request, providerName) {
10132
10143
  if (request.temperature !== void 0) body.temperature = request.temperature;
10133
10144
  if (request.reasoning?.effort !== void 0)
10134
10145
  applyReasoningRequest(body, request.reasoning.effort, providerName);
10135
- if (request.tools !== void 0 && request.tools.length > 0) {
10136
- body.tools = request.tools.map((tool) => ({
10137
- type: "function",
10138
- function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
10139
- }));
10140
- }
10146
+ applyToolsRequest(body, request);
10141
10147
  const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
10142
10148
  if (responseFormat !== void 0) body.response_format = responseFormat;
10143
10149
  return body;
@@ -10270,6 +10276,16 @@ var init_openai2 = __esm({
10270
10276
  } catch {
10271
10277
  continue;
10272
10278
  }
10279
+ if (chunk.error !== void 0 && chunk.error !== null) {
10280
+ const status = typeof chunk.error.code === "number" ? chunk.error.code : 502;
10281
+ throw mapOpenAICompatibleError({
10282
+ providerId,
10283
+ status,
10284
+ body: chunk,
10285
+ headers: response.headers,
10286
+ endpoint: "/v1/chat/completions"
10287
+ });
10288
+ }
10273
10289
  const events = accumulator.consume(chunk);
10274
10290
  for (const event of events) yield event;
10275
10291
  }
@@ -11208,6 +11224,7 @@ function buildLoopInputs(options, runId, userText) {
11208
11224
  ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
11209
11225
  ...options.onStep !== void 0 ? { onStep: options.onStep } : {},
11210
11226
  ...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
11227
+ ...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
11211
11228
  ...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
11212
11229
  ...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
11213
11230
  ...buildCustomToolsInput(