@theokit/sdk 2.11.0 → 2.11.1
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/CHANGELOG.md +6 -0
- package/dist/a2a/index.cjs +60 -3
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +60 -3
- package/dist/a2a/index.js.map +1 -1
- package/dist/cron.cjs +60 -3
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.js +60 -3
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +60 -3
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +60 -3
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +60 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/message-builders.d.ts +3 -1
- package/dist/internal/llm/openai.d.ts +64 -0
- package/dist/internal/llm/types.d.ts +15 -0
- package/package.json +14 -14
package/dist/cron.cjs
CHANGED
|
@@ -8348,6 +8348,14 @@ function buildAssistantEvent(inputs, text) {
|
|
|
8348
8348
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
8349
8349
|
};
|
|
8350
8350
|
}
|
|
8351
|
+
function buildThinkingEvent(inputs, text) {
|
|
8352
|
+
return {
|
|
8353
|
+
type: "thinking",
|
|
8354
|
+
agent_id: inputs.agentId,
|
|
8355
|
+
run_id: inputs.runId,
|
|
8356
|
+
text
|
|
8357
|
+
};
|
|
8358
|
+
}
|
|
8351
8359
|
function buildAssistantTurn(text, toolCalls) {
|
|
8352
8360
|
const content = [];
|
|
8353
8361
|
if (text.length > 0) content.push({ type: "text", text });
|
|
@@ -8518,6 +8526,10 @@ ${additions}`;
|
|
|
8518
8526
|
function toLlmTool(tool) {
|
|
8519
8527
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
8520
8528
|
}
|
|
8529
|
+
function reasoningEffortFromParams(params) {
|
|
8530
|
+
const thinking = params?.find((p) => p.id === "thinking");
|
|
8531
|
+
return thinking !== void 0 && thinking.value.length > 0 ? thinking.value : void 0;
|
|
8532
|
+
}
|
|
8521
8533
|
async function streamLlmTurn(inputs, ctx) {
|
|
8522
8534
|
const llmSpan = inputs.telemetry?.startSpan("llm.call", {
|
|
8523
8535
|
"model.id": inputs.model.id ?? "auto",
|
|
@@ -8534,6 +8546,12 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
8534
8546
|
);
|
|
8535
8547
|
return effective !== void 0 ? { system: effective } : {};
|
|
8536
8548
|
})(),
|
|
8549
|
+
// issue #47: forward the reasoning effort from ModelSelection.params (the `thinking` param)
|
|
8550
|
+
// so the provider produces reasoning. Absent param ⇒ no `reasoning` field (bare request).
|
|
8551
|
+
...(() => {
|
|
8552
|
+
const effort = reasoningEffortFromParams(inputs.model.params);
|
|
8553
|
+
return effort !== void 0 ? { reasoning: { effort } } : {};
|
|
8554
|
+
})(),
|
|
8537
8555
|
messages: ctx.messages,
|
|
8538
8556
|
tools: ctx.tools.map(toLlmTool)
|
|
8539
8557
|
},
|
|
@@ -8602,6 +8620,7 @@ function registerLoopError(ctx, cause) {
|
|
|
8602
8620
|
}
|
|
8603
8621
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
8604
8622
|
let accumulatedText = "";
|
|
8623
|
+
let reasoningText = "";
|
|
8605
8624
|
let errored = false;
|
|
8606
8625
|
let finishValue;
|
|
8607
8626
|
while (true) {
|
|
@@ -8614,6 +8633,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8614
8633
|
accumulatedText += next.value.text;
|
|
8615
8634
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
8616
8635
|
}
|
|
8636
|
+
if (next.value.type === "reasoning_delta") {
|
|
8637
|
+
reasoningText += next.value.text;
|
|
8638
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
8639
|
+
}
|
|
8617
8640
|
if (next.value.type === "error") {
|
|
8618
8641
|
registerLoopError(ctx, next.value);
|
|
8619
8642
|
ctx.finalText = "";
|
|
@@ -8621,6 +8644,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8621
8644
|
break;
|
|
8622
8645
|
}
|
|
8623
8646
|
}
|
|
8647
|
+
if (reasoningText.length > 0) {
|
|
8648
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
8649
|
+
}
|
|
8624
8650
|
return { accumulatedText, errored, finishValue };
|
|
8625
8651
|
}
|
|
8626
8652
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -8632,6 +8658,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
8632
8658
|
"SendOptions.onDelta"
|
|
8633
8659
|
);
|
|
8634
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
|
+
}
|
|
8635
8670
|
|
|
8636
8671
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
8637
8672
|
init_async_local_storage();
|
|
@@ -10945,7 +10980,7 @@ var OpenAIClient = class {
|
|
|
10945
10980
|
method: "POST",
|
|
10946
10981
|
signal,
|
|
10947
10982
|
headers,
|
|
10948
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
10983
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
10949
10984
|
});
|
|
10950
10985
|
} catch (fetchErr) {
|
|
10951
10986
|
const mapped = mapOllamaTransportError({
|
|
@@ -11007,6 +11042,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11007
11042
|
const events = [];
|
|
11008
11043
|
this.applyUsage(chunk.usage);
|
|
11009
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);
|
|
11010
11049
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
11011
11050
|
if (textEvent !== void 0) events.push(textEvent);
|
|
11012
11051
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -11014,6 +11053,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11014
11053
|
}
|
|
11015
11054
|
return events;
|
|
11016
11055
|
}
|
|
11056
|
+
applyReasoningDelta(reasoning) {
|
|
11057
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
11058
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
11059
|
+
}
|
|
11017
11060
|
applyUsage(usage) {
|
|
11018
11061
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
11019
11062
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -11076,7 +11119,14 @@ function mapOpenAIFinish(reason) {
|
|
|
11076
11119
|
return "end_turn";
|
|
11077
11120
|
}
|
|
11078
11121
|
}
|
|
11079
|
-
function
|
|
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 buildOpenAIBody(request, providerName) {
|
|
11080
11130
|
const messages = [];
|
|
11081
11131
|
const systemText = openAISystemText(request.system);
|
|
11082
11132
|
if (systemText.length > 0) {
|
|
@@ -11095,6 +11145,8 @@ function buildOpenAIBody(request) {
|
|
|
11095
11145
|
};
|
|
11096
11146
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
11097
11147
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
11148
|
+
if (request.reasoning?.effort !== void 0)
|
|
11149
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
11098
11150
|
if (request.tools !== void 0 && request.tools.length > 0) {
|
|
11099
11151
|
body.tools = request.tools.map((tool) => ({
|
|
11100
11152
|
type: "function",
|
|
@@ -11928,7 +11980,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11928
11980
|
return {
|
|
11929
11981
|
agentId: options.agentId,
|
|
11930
11982
|
runId,
|
|
11931
|
-
|
|
11983
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
11984
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
11985
|
+
model: {
|
|
11986
|
+
id: effectiveModelId,
|
|
11987
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
11988
|
+
},
|
|
11932
11989
|
userMessage: userText,
|
|
11933
11990
|
llm,
|
|
11934
11991
|
mcp: buildMcpMap(options),
|