@theokit/sdk 2.11.0 → 2.11.2

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/cron.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import './run-D22b53SU.cjs';
2
- export { K as Cron } from './cron-BNI8pyn_.cjs';
1
+ import './run-TMdc7gmo.cjs';
2
+ export { K as Cron } from './cron-DOw-Hqol.cjs';
package/dist/cron.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import './run-D22b53SU.js';
2
- export { K as Cron } from './cron-CZlMLA1K.js';
1
+ import './run-TMdc7gmo.js';
2
+ export { K as Cron } from './cron-BRfFPEKY.js';
package/dist/cron.js CHANGED
@@ -8345,6 +8345,14 @@ function buildAssistantEvent(inputs, text) {
8345
8345
  message: { role: "assistant", content: [{ type: "text", text }] }
8346
8346
  };
8347
8347
  }
8348
+ function buildThinkingEvent(inputs, text) {
8349
+ return {
8350
+ type: "thinking",
8351
+ agent_id: inputs.agentId,
8352
+ run_id: inputs.runId,
8353
+ text
8354
+ };
8355
+ }
8348
8356
  function buildAssistantTurn(text, toolCalls) {
8349
8357
  const content = [];
8350
8358
  if (text.length > 0) content.push({ type: "text", text });
@@ -8515,6 +8523,10 @@ ${additions}`;
8515
8523
  function toLlmTool(tool) {
8516
8524
  return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
8517
8525
  }
8526
+ function reasoningEffortFromParams(params) {
8527
+ const thinking = params?.find((p) => p.id === "thinking");
8528
+ return thinking !== void 0 && thinking.value.length > 0 ? thinking.value : void 0;
8529
+ }
8518
8530
  async function streamLlmTurn(inputs, ctx) {
8519
8531
  const llmSpan = inputs.telemetry?.startSpan("llm.call", {
8520
8532
  "model.id": inputs.model.id ?? "auto",
@@ -8531,6 +8543,15 @@ async function streamLlmTurn(inputs, ctx) {
8531
8543
  );
8532
8544
  return effective !== void 0 ? { system: effective } : {};
8533
8545
  })(),
8546
+ // issue #47: forward the reasoning effort from ModelSelection.params (the `thinking` param)
8547
+ // so the provider produces reasoning. Absent param ⇒ no `reasoning` field (bare request).
8548
+ ...(() => {
8549
+ const effort = reasoningEffortFromParams(inputs.model.params);
8550
+ return effort !== void 0 ? { reasoning: { effort } } : {};
8551
+ })(),
8552
+ // Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
8553
+ // text close even though tools are advertised). Absent ⇒ provider default (auto).
8554
+ ...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
8534
8555
  messages: ctx.messages,
8535
8556
  tools: ctx.tools.map(toLlmTool)
8536
8557
  },
@@ -8599,6 +8620,7 @@ function registerLoopError(ctx, cause) {
8599
8620
  }
8600
8621
  async function runCollectorLoop(generator, inputs, ctx) {
8601
8622
  let accumulatedText = "";
8623
+ let reasoningText = "";
8602
8624
  let errored = false;
8603
8625
  let finishValue;
8604
8626
  while (true) {
@@ -8611,6 +8633,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
8611
8633
  accumulatedText += next.value.text;
8612
8634
  await emitTextDeltaCallback(inputs, next.value.text);
8613
8635
  }
8636
+ if (next.value.type === "reasoning_delta") {
8637
+ reasoningText += next.value.text;
8638
+ await emitReasoningDeltaCallback(inputs, next.value.text);
8639
+ }
8614
8640
  if (next.value.type === "error") {
8615
8641
  registerLoopError(ctx, next.value);
8616
8642
  ctx.finalText = "";
@@ -8618,6 +8644,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
8618
8644
  break;
8619
8645
  }
8620
8646
  }
8647
+ if (reasoningText.length > 0) {
8648
+ ctx.events.push(buildThinkingEvent(inputs, reasoningText));
8649
+ }
8621
8650
  return { accumulatedText, errored, finishValue };
8622
8651
  }
8623
8652
  async function emitTextDeltaCallback(inputs, text) {
@@ -8629,6 +8658,15 @@ async function emitTextDeltaCallback(inputs, text) {
8629
8658
  "SendOptions.onDelta"
8630
8659
  );
8631
8660
  }
8661
+ async function emitReasoningDeltaCallback(inputs, text) {
8662
+ if (inputs.onDelta === void 0) return;
8663
+ const cb = inputs.onDelta;
8664
+ await safeCall(
8665
+ () => cb({ update: { type: "thinking-delta", text } }),
8666
+ void 0,
8667
+ "SendOptions.onDelta"
8668
+ );
8669
+ }
8632
8670
 
8633
8671
  // src/internal/agent-loop/tool-dispatch.ts
8634
8672
  init_async_local_storage();
@@ -10942,7 +10980,7 @@ var OpenAIClient = class {
10942
10980
  method: "POST",
10943
10981
  signal,
10944
10982
  headers,
10945
- body: JSON.stringify(buildOpenAIBody(request))
10983
+ body: JSON.stringify(buildOpenAIBody(request, providerId))
10946
10984
  });
10947
10985
  } catch (fetchErr) {
10948
10986
  const mapped = mapOllamaTransportError({
@@ -11004,6 +11042,10 @@ var OpenAIStreamAccumulator = class {
11004
11042
  const events = [];
11005
11043
  this.applyUsage(chunk.usage);
11006
11044
  for (const choice of chunk.choices ?? []) {
11045
+ const reasoningEvent = this.applyReasoningDelta(
11046
+ choice.delta?.reasoning ?? choice.delta?.reasoning_content
11047
+ );
11048
+ if (reasoningEvent !== void 0) events.push(reasoningEvent);
11007
11049
  const textEvent = this.applyContentDelta(choice.delta?.content);
11008
11050
  if (textEvent !== void 0) events.push(textEvent);
11009
11051
  this.mergeToolCallDeltas(choice.delta?.tool_calls);
@@ -11011,6 +11053,10 @@ var OpenAIStreamAccumulator = class {
11011
11053
  }
11012
11054
  return events;
11013
11055
  }
11056
+ applyReasoningDelta(reasoning) {
11057
+ if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
11058
+ return { type: "reasoning_delta", text: reasoning };
11059
+ }
11014
11060
  applyUsage(usage) {
11015
11061
  if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
11016
11062
  if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
@@ -11073,7 +11119,22 @@ function mapOpenAIFinish(reason) {
11073
11119
  return "end_turn";
11074
11120
  }
11075
11121
  }
11076
- function buildOpenAIBody(request) {
11122
+ function applyReasoningRequest(body, effort, providerName) {
11123
+ if (providerName === "openai") {
11124
+ body.reasoning_effort = effort;
11125
+ return;
11126
+ }
11127
+ body.reasoning = { effort };
11128
+ }
11129
+ function applyToolsRequest(body, request) {
11130
+ if (request.tools === void 0 || request.tools.length === 0) return;
11131
+ body.tools = request.tools.map((tool) => ({
11132
+ type: "function",
11133
+ function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
11134
+ }));
11135
+ if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
11136
+ }
11137
+ function buildOpenAIBody(request, providerName) {
11077
11138
  const messages = [];
11078
11139
  const systemText = openAISystemText(request.system);
11079
11140
  if (systemText.length > 0) {
@@ -11092,12 +11153,9 @@ function buildOpenAIBody(request) {
11092
11153
  };
11093
11154
  if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
11094
11155
  if (request.temperature !== void 0) body.temperature = request.temperature;
11095
- if (request.tools !== void 0 && request.tools.length > 0) {
11096
- body.tools = request.tools.map((tool) => ({
11097
- type: "function",
11098
- function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
11099
- }));
11100
- }
11156
+ if (request.reasoning?.effort !== void 0)
11157
+ applyReasoningRequest(body, request.reasoning.effort, providerName);
11158
+ applyToolsRequest(body, request);
11101
11159
  const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
11102
11160
  if (responseFormat !== void 0) body.response_format = responseFormat;
11103
11161
  return body;
@@ -11925,7 +11983,12 @@ function buildLoopInputs(options, runId, userText) {
11925
11983
  return {
11926
11984
  agentId: options.agentId,
11927
11985
  runId,
11928
- model: { id: effectiveModelId },
11986
+ // issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
11987
+ // request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
11988
+ model: {
11989
+ id: effectiveModelId,
11990
+ ...options.model?.params !== void 0 ? { params: options.model.params } : {}
11991
+ },
11929
11992
  userMessage: userText,
11930
11993
  llm,
11931
11994
  mcp: buildMcpMap(options),
@@ -11935,6 +11998,7 @@ function buildLoopInputs(options, runId, userText) {
11935
11998
  ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
11936
11999
  ...options.onStep !== void 0 ? { onStep: options.onStep } : {},
11937
12000
  ...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
12001
+ ...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
11938
12002
  ...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
11939
12003
  ...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
11940
12004
  ...buildCustomToolsInput(