@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/index.cjs
CHANGED
|
@@ -10805,6 +10805,14 @@ function buildAssistantEvent(inputs, text) {
|
|
|
10805
10805
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
10806
10806
|
};
|
|
10807
10807
|
}
|
|
10808
|
+
function buildThinkingEvent(inputs, text) {
|
|
10809
|
+
return {
|
|
10810
|
+
type: "thinking",
|
|
10811
|
+
agent_id: inputs.agentId,
|
|
10812
|
+
run_id: inputs.runId,
|
|
10813
|
+
text
|
|
10814
|
+
};
|
|
10815
|
+
}
|
|
10808
10816
|
function buildAssistantTurn(text, toolCalls) {
|
|
10809
10817
|
const content = [];
|
|
10810
10818
|
if (text.length > 0) content.push({ type: "text", text });
|
|
@@ -10975,6 +10983,10 @@ ${additions}`;
|
|
|
10975
10983
|
function toLlmTool(tool) {
|
|
10976
10984
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
10977
10985
|
}
|
|
10986
|
+
function reasoningEffortFromParams(params) {
|
|
10987
|
+
const thinking = params?.find((p) => p.id === "thinking");
|
|
10988
|
+
return thinking !== void 0 && thinking.value.length > 0 ? thinking.value : void 0;
|
|
10989
|
+
}
|
|
10978
10990
|
async function streamLlmTurn(inputs, ctx) {
|
|
10979
10991
|
const llmSpan = inputs.telemetry?.startSpan("llm.call", {
|
|
10980
10992
|
"model.id": inputs.model.id ?? "auto",
|
|
@@ -10991,6 +11003,12 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
10991
11003
|
);
|
|
10992
11004
|
return effective !== void 0 ? { system: effective } : {};
|
|
10993
11005
|
})(),
|
|
11006
|
+
// issue #47: forward the reasoning effort from ModelSelection.params (the `thinking` param)
|
|
11007
|
+
// so the provider produces reasoning. Absent param ⇒ no `reasoning` field (bare request).
|
|
11008
|
+
...(() => {
|
|
11009
|
+
const effort = reasoningEffortFromParams(inputs.model.params);
|
|
11010
|
+
return effort !== void 0 ? { reasoning: { effort } } : {};
|
|
11011
|
+
})(),
|
|
10994
11012
|
messages: ctx.messages,
|
|
10995
11013
|
tools: ctx.tools.map(toLlmTool)
|
|
10996
11014
|
},
|
|
@@ -11059,6 +11077,7 @@ function registerLoopError(ctx, cause) {
|
|
|
11059
11077
|
}
|
|
11060
11078
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
11061
11079
|
let accumulatedText = "";
|
|
11080
|
+
let reasoningText = "";
|
|
11062
11081
|
let errored = false;
|
|
11063
11082
|
let finishValue;
|
|
11064
11083
|
while (true) {
|
|
@@ -11071,6 +11090,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
11071
11090
|
accumulatedText += next.value.text;
|
|
11072
11091
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
11073
11092
|
}
|
|
11093
|
+
if (next.value.type === "reasoning_delta") {
|
|
11094
|
+
reasoningText += next.value.text;
|
|
11095
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
11096
|
+
}
|
|
11074
11097
|
if (next.value.type === "error") {
|
|
11075
11098
|
registerLoopError(ctx, next.value);
|
|
11076
11099
|
ctx.finalText = "";
|
|
@@ -11078,6 +11101,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
11078
11101
|
break;
|
|
11079
11102
|
}
|
|
11080
11103
|
}
|
|
11104
|
+
if (reasoningText.length > 0) {
|
|
11105
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
11106
|
+
}
|
|
11081
11107
|
return { accumulatedText, errored, finishValue };
|
|
11082
11108
|
}
|
|
11083
11109
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -11089,6 +11115,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
11089
11115
|
"SendOptions.onDelta"
|
|
11090
11116
|
);
|
|
11091
11117
|
}
|
|
11118
|
+
async function emitReasoningDeltaCallback(inputs, text) {
|
|
11119
|
+
if (inputs.onDelta === void 0) return;
|
|
11120
|
+
const cb = inputs.onDelta;
|
|
11121
|
+
await safeCall(
|
|
11122
|
+
() => cb({ update: { type: "thinking-delta", text } }),
|
|
11123
|
+
void 0,
|
|
11124
|
+
"SendOptions.onDelta"
|
|
11125
|
+
);
|
|
11126
|
+
}
|
|
11092
11127
|
|
|
11093
11128
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
11094
11129
|
init_async_local_storage();
|
|
@@ -13417,7 +13452,7 @@ var OpenAIClient = class {
|
|
|
13417
13452
|
method: "POST",
|
|
13418
13453
|
signal,
|
|
13419
13454
|
headers,
|
|
13420
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
13455
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
13421
13456
|
});
|
|
13422
13457
|
} catch (fetchErr) {
|
|
13423
13458
|
const mapped = mapOllamaTransportError({
|
|
@@ -13479,6 +13514,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
13479
13514
|
const events = [];
|
|
13480
13515
|
this.applyUsage(chunk.usage);
|
|
13481
13516
|
for (const choice of chunk.choices ?? []) {
|
|
13517
|
+
const reasoningEvent = this.applyReasoningDelta(
|
|
13518
|
+
choice.delta?.reasoning ?? choice.delta?.reasoning_content
|
|
13519
|
+
);
|
|
13520
|
+
if (reasoningEvent !== void 0) events.push(reasoningEvent);
|
|
13482
13521
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
13483
13522
|
if (textEvent !== void 0) events.push(textEvent);
|
|
13484
13523
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -13486,6 +13525,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
13486
13525
|
}
|
|
13487
13526
|
return events;
|
|
13488
13527
|
}
|
|
13528
|
+
applyReasoningDelta(reasoning) {
|
|
13529
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
13530
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
13531
|
+
}
|
|
13489
13532
|
applyUsage(usage) {
|
|
13490
13533
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
13491
13534
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -13548,7 +13591,14 @@ function mapOpenAIFinish(reason) {
|
|
|
13548
13591
|
return "end_turn";
|
|
13549
13592
|
}
|
|
13550
13593
|
}
|
|
13551
|
-
function
|
|
13594
|
+
function applyReasoningRequest(body, effort, providerName) {
|
|
13595
|
+
if (providerName === "openai") {
|
|
13596
|
+
body.reasoning_effort = effort;
|
|
13597
|
+
return;
|
|
13598
|
+
}
|
|
13599
|
+
body.reasoning = { effort };
|
|
13600
|
+
}
|
|
13601
|
+
function buildOpenAIBody(request, providerName) {
|
|
13552
13602
|
const messages = [];
|
|
13553
13603
|
const systemText = openAISystemText(request.system);
|
|
13554
13604
|
if (systemText.length > 0) {
|
|
@@ -13567,6 +13617,8 @@ function buildOpenAIBody(request) {
|
|
|
13567
13617
|
};
|
|
13568
13618
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
13569
13619
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
13620
|
+
if (request.reasoning?.effort !== void 0)
|
|
13621
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
13570
13622
|
if (request.tools !== void 0 && request.tools.length > 0) {
|
|
13571
13623
|
body.tools = request.tools.map((tool) => ({
|
|
13572
13624
|
type: "function",
|
|
@@ -14401,7 +14453,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
14401
14453
|
return {
|
|
14402
14454
|
agentId: options.agentId,
|
|
14403
14455
|
runId,
|
|
14404
|
-
|
|
14456
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
14457
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
14458
|
+
model: {
|
|
14459
|
+
id: effectiveModelId,
|
|
14460
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
14461
|
+
},
|
|
14405
14462
|
userMessage: userText,
|
|
14406
14463
|
llm,
|
|
14407
14464
|
mcp: buildMcpMap(options),
|