@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.js
CHANGED
|
@@ -10802,6 +10802,14 @@ function buildAssistantEvent(inputs, text) {
|
|
|
10802
10802
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
10803
10803
|
};
|
|
10804
10804
|
}
|
|
10805
|
+
function buildThinkingEvent(inputs, text) {
|
|
10806
|
+
return {
|
|
10807
|
+
type: "thinking",
|
|
10808
|
+
agent_id: inputs.agentId,
|
|
10809
|
+
run_id: inputs.runId,
|
|
10810
|
+
text
|
|
10811
|
+
};
|
|
10812
|
+
}
|
|
10805
10813
|
function buildAssistantTurn(text, toolCalls) {
|
|
10806
10814
|
const content = [];
|
|
10807
10815
|
if (text.length > 0) content.push({ type: "text", text });
|
|
@@ -10972,6 +10980,10 @@ ${additions}`;
|
|
|
10972
10980
|
function toLlmTool(tool) {
|
|
10973
10981
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
10974
10982
|
}
|
|
10983
|
+
function reasoningEffortFromParams(params) {
|
|
10984
|
+
const thinking = params?.find((p) => p.id === "thinking");
|
|
10985
|
+
return thinking !== void 0 && thinking.value.length > 0 ? thinking.value : void 0;
|
|
10986
|
+
}
|
|
10975
10987
|
async function streamLlmTurn(inputs, ctx) {
|
|
10976
10988
|
const llmSpan = inputs.telemetry?.startSpan("llm.call", {
|
|
10977
10989
|
"model.id": inputs.model.id ?? "auto",
|
|
@@ -10988,6 +11000,12 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
10988
11000
|
);
|
|
10989
11001
|
return effective !== void 0 ? { system: effective } : {};
|
|
10990
11002
|
})(),
|
|
11003
|
+
// issue #47: forward the reasoning effort from ModelSelection.params (the `thinking` param)
|
|
11004
|
+
// so the provider produces reasoning. Absent param ⇒ no `reasoning` field (bare request).
|
|
11005
|
+
...(() => {
|
|
11006
|
+
const effort = reasoningEffortFromParams(inputs.model.params);
|
|
11007
|
+
return effort !== void 0 ? { reasoning: { effort } } : {};
|
|
11008
|
+
})(),
|
|
10991
11009
|
messages: ctx.messages,
|
|
10992
11010
|
tools: ctx.tools.map(toLlmTool)
|
|
10993
11011
|
},
|
|
@@ -11056,6 +11074,7 @@ function registerLoopError(ctx, cause) {
|
|
|
11056
11074
|
}
|
|
11057
11075
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
11058
11076
|
let accumulatedText = "";
|
|
11077
|
+
let reasoningText = "";
|
|
11059
11078
|
let errored = false;
|
|
11060
11079
|
let finishValue;
|
|
11061
11080
|
while (true) {
|
|
@@ -11068,6 +11087,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
11068
11087
|
accumulatedText += next.value.text;
|
|
11069
11088
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
11070
11089
|
}
|
|
11090
|
+
if (next.value.type === "reasoning_delta") {
|
|
11091
|
+
reasoningText += next.value.text;
|
|
11092
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
11093
|
+
}
|
|
11071
11094
|
if (next.value.type === "error") {
|
|
11072
11095
|
registerLoopError(ctx, next.value);
|
|
11073
11096
|
ctx.finalText = "";
|
|
@@ -11075,6 +11098,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
11075
11098
|
break;
|
|
11076
11099
|
}
|
|
11077
11100
|
}
|
|
11101
|
+
if (reasoningText.length > 0) {
|
|
11102
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
11103
|
+
}
|
|
11078
11104
|
return { accumulatedText, errored, finishValue };
|
|
11079
11105
|
}
|
|
11080
11106
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -11086,6 +11112,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
11086
11112
|
"SendOptions.onDelta"
|
|
11087
11113
|
);
|
|
11088
11114
|
}
|
|
11115
|
+
async function emitReasoningDeltaCallback(inputs, text) {
|
|
11116
|
+
if (inputs.onDelta === void 0) return;
|
|
11117
|
+
const cb = inputs.onDelta;
|
|
11118
|
+
await safeCall(
|
|
11119
|
+
() => cb({ update: { type: "thinking-delta", text } }),
|
|
11120
|
+
void 0,
|
|
11121
|
+
"SendOptions.onDelta"
|
|
11122
|
+
);
|
|
11123
|
+
}
|
|
11089
11124
|
|
|
11090
11125
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
11091
11126
|
init_async_local_storage();
|
|
@@ -13414,7 +13449,7 @@ var OpenAIClient = class {
|
|
|
13414
13449
|
method: "POST",
|
|
13415
13450
|
signal,
|
|
13416
13451
|
headers,
|
|
13417
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
13452
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
13418
13453
|
});
|
|
13419
13454
|
} catch (fetchErr) {
|
|
13420
13455
|
const mapped = mapOllamaTransportError({
|
|
@@ -13476,6 +13511,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
13476
13511
|
const events = [];
|
|
13477
13512
|
this.applyUsage(chunk.usage);
|
|
13478
13513
|
for (const choice of chunk.choices ?? []) {
|
|
13514
|
+
const reasoningEvent = this.applyReasoningDelta(
|
|
13515
|
+
choice.delta?.reasoning ?? choice.delta?.reasoning_content
|
|
13516
|
+
);
|
|
13517
|
+
if (reasoningEvent !== void 0) events.push(reasoningEvent);
|
|
13479
13518
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
13480
13519
|
if (textEvent !== void 0) events.push(textEvent);
|
|
13481
13520
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -13483,6 +13522,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
13483
13522
|
}
|
|
13484
13523
|
return events;
|
|
13485
13524
|
}
|
|
13525
|
+
applyReasoningDelta(reasoning) {
|
|
13526
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
13527
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
13528
|
+
}
|
|
13486
13529
|
applyUsage(usage) {
|
|
13487
13530
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
13488
13531
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -13545,7 +13588,14 @@ function mapOpenAIFinish(reason) {
|
|
|
13545
13588
|
return "end_turn";
|
|
13546
13589
|
}
|
|
13547
13590
|
}
|
|
13548
|
-
function
|
|
13591
|
+
function applyReasoningRequest(body, effort, providerName) {
|
|
13592
|
+
if (providerName === "openai") {
|
|
13593
|
+
body.reasoning_effort = effort;
|
|
13594
|
+
return;
|
|
13595
|
+
}
|
|
13596
|
+
body.reasoning = { effort };
|
|
13597
|
+
}
|
|
13598
|
+
function buildOpenAIBody(request, providerName) {
|
|
13549
13599
|
const messages = [];
|
|
13550
13600
|
const systemText = openAISystemText(request.system);
|
|
13551
13601
|
if (systemText.length > 0) {
|
|
@@ -13564,6 +13614,8 @@ function buildOpenAIBody(request) {
|
|
|
13564
13614
|
};
|
|
13565
13615
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
13566
13616
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
13617
|
+
if (request.reasoning?.effort !== void 0)
|
|
13618
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
13567
13619
|
if (request.tools !== void 0 && request.tools.length > 0) {
|
|
13568
13620
|
body.tools = request.tools.map((tool) => ({
|
|
13569
13621
|
type: "function",
|
|
@@ -14398,7 +14450,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
14398
14450
|
return {
|
|
14399
14451
|
agentId: options.agentId,
|
|
14400
14452
|
runId,
|
|
14401
|
-
|
|
14453
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
14454
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
14455
|
+
model: {
|
|
14456
|
+
id: effectiveModelId,
|
|
14457
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
14458
|
+
},
|
|
14402
14459
|
userMessage: userText,
|
|
14403
14460
|
llm,
|
|
14404
14461
|
mcp: buildMcpMap(options),
|