@theokit/sdk 2.10.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 +12 -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/dist/models.cjs +117 -0
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +117 -0
- package/dist/models.js.map +1 -1
- package/package.json +14 -14
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,12 @@ 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
|
+
})(),
|
|
8534
8552
|
messages: ctx.messages,
|
|
8535
8553
|
tools: ctx.tools.map(toLlmTool)
|
|
8536
8554
|
},
|
|
@@ -8599,6 +8617,7 @@ function registerLoopError(ctx, cause) {
|
|
|
8599
8617
|
}
|
|
8600
8618
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
8601
8619
|
let accumulatedText = "";
|
|
8620
|
+
let reasoningText = "";
|
|
8602
8621
|
let errored = false;
|
|
8603
8622
|
let finishValue;
|
|
8604
8623
|
while (true) {
|
|
@@ -8611,6 +8630,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8611
8630
|
accumulatedText += next.value.text;
|
|
8612
8631
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
8613
8632
|
}
|
|
8633
|
+
if (next.value.type === "reasoning_delta") {
|
|
8634
|
+
reasoningText += next.value.text;
|
|
8635
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
8636
|
+
}
|
|
8614
8637
|
if (next.value.type === "error") {
|
|
8615
8638
|
registerLoopError(ctx, next.value);
|
|
8616
8639
|
ctx.finalText = "";
|
|
@@ -8618,6 +8641,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8618
8641
|
break;
|
|
8619
8642
|
}
|
|
8620
8643
|
}
|
|
8644
|
+
if (reasoningText.length > 0) {
|
|
8645
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
8646
|
+
}
|
|
8621
8647
|
return { accumulatedText, errored, finishValue };
|
|
8622
8648
|
}
|
|
8623
8649
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -8629,6 +8655,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
8629
8655
|
"SendOptions.onDelta"
|
|
8630
8656
|
);
|
|
8631
8657
|
}
|
|
8658
|
+
async function emitReasoningDeltaCallback(inputs, text) {
|
|
8659
|
+
if (inputs.onDelta === void 0) return;
|
|
8660
|
+
const cb = inputs.onDelta;
|
|
8661
|
+
await safeCall(
|
|
8662
|
+
() => cb({ update: { type: "thinking-delta", text } }),
|
|
8663
|
+
void 0,
|
|
8664
|
+
"SendOptions.onDelta"
|
|
8665
|
+
);
|
|
8666
|
+
}
|
|
8632
8667
|
|
|
8633
8668
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
8634
8669
|
init_async_local_storage();
|
|
@@ -10942,7 +10977,7 @@ var OpenAIClient = class {
|
|
|
10942
10977
|
method: "POST",
|
|
10943
10978
|
signal,
|
|
10944
10979
|
headers,
|
|
10945
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
10980
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
10946
10981
|
});
|
|
10947
10982
|
} catch (fetchErr) {
|
|
10948
10983
|
const mapped = mapOllamaTransportError({
|
|
@@ -11004,6 +11039,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11004
11039
|
const events = [];
|
|
11005
11040
|
this.applyUsage(chunk.usage);
|
|
11006
11041
|
for (const choice of chunk.choices ?? []) {
|
|
11042
|
+
const reasoningEvent = this.applyReasoningDelta(
|
|
11043
|
+
choice.delta?.reasoning ?? choice.delta?.reasoning_content
|
|
11044
|
+
);
|
|
11045
|
+
if (reasoningEvent !== void 0) events.push(reasoningEvent);
|
|
11007
11046
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
11008
11047
|
if (textEvent !== void 0) events.push(textEvent);
|
|
11009
11048
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -11011,6 +11050,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11011
11050
|
}
|
|
11012
11051
|
return events;
|
|
11013
11052
|
}
|
|
11053
|
+
applyReasoningDelta(reasoning) {
|
|
11054
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
11055
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
11056
|
+
}
|
|
11014
11057
|
applyUsage(usage) {
|
|
11015
11058
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
11016
11059
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -11073,7 +11116,14 @@ function mapOpenAIFinish(reason) {
|
|
|
11073
11116
|
return "end_turn";
|
|
11074
11117
|
}
|
|
11075
11118
|
}
|
|
11076
|
-
function
|
|
11119
|
+
function applyReasoningRequest(body, effort, providerName) {
|
|
11120
|
+
if (providerName === "openai") {
|
|
11121
|
+
body.reasoning_effort = effort;
|
|
11122
|
+
return;
|
|
11123
|
+
}
|
|
11124
|
+
body.reasoning = { effort };
|
|
11125
|
+
}
|
|
11126
|
+
function buildOpenAIBody(request, providerName) {
|
|
11077
11127
|
const messages = [];
|
|
11078
11128
|
const systemText = openAISystemText(request.system);
|
|
11079
11129
|
if (systemText.length > 0) {
|
|
@@ -11092,6 +11142,8 @@ function buildOpenAIBody(request) {
|
|
|
11092
11142
|
};
|
|
11093
11143
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
11094
11144
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
11145
|
+
if (request.reasoning?.effort !== void 0)
|
|
11146
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
11095
11147
|
if (request.tools !== void 0 && request.tools.length > 0) {
|
|
11096
11148
|
body.tools = request.tools.map((tool) => ({
|
|
11097
11149
|
type: "function",
|
|
@@ -11925,7 +11977,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11925
11977
|
return {
|
|
11926
11978
|
agentId: options.agentId,
|
|
11927
11979
|
runId,
|
|
11928
|
-
|
|
11980
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
11981
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
11982
|
+
model: {
|
|
11983
|
+
id: effectiveModelId,
|
|
11984
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
11985
|
+
},
|
|
11929
11986
|
userMessage: userText,
|
|
11930
11987
|
llm,
|
|
11931
11988
|
mcp: buildMcpMap(options),
|