@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/CHANGELOG.md +12 -0
- package/dist/a2a/index.cjs +73 -9
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +73 -9
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-CZlMLA1K.d.ts → cron-BRfFPEKY.d.ts} +1 -1
- package/dist/{cron-BNI8pyn_.d.cts → cron-DOw-Hqol.d.cts} +1 -1
- package/dist/cron.cjs +73 -9
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +73 -9
- package/dist/cron.js.map +1 -1
- package/dist/{errors-FKoM44Mj.d.cts → errors-9yw4UQwX.d.cts} +1 -1
- package/dist/{errors-C8EVGqje.d.ts → errors-DFiY-NHK.d.ts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +73 -9
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +73 -9
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +73 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +73 -9
- 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 +23 -0
- package/dist/{run-D22b53SU.d.cts → run-TMdc7gmo.d.cts} +7 -0
- package/dist/{run-D22b53SU.d.ts → run-TMdc7gmo.d.ts} +7 -0
- package/dist/types/run.d.ts +7 -0
- package/package.json +14 -14
package/dist/eval.js
CHANGED
|
@@ -8340,6 +8340,14 @@ function buildAssistantEvent(inputs, text) {
|
|
|
8340
8340
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
8341
8341
|
};
|
|
8342
8342
|
}
|
|
8343
|
+
function buildThinkingEvent(inputs, text) {
|
|
8344
|
+
return {
|
|
8345
|
+
type: "thinking",
|
|
8346
|
+
agent_id: inputs.agentId,
|
|
8347
|
+
run_id: inputs.runId,
|
|
8348
|
+
text
|
|
8349
|
+
};
|
|
8350
|
+
}
|
|
8343
8351
|
function buildAssistantTurn(text, toolCalls) {
|
|
8344
8352
|
const content = [];
|
|
8345
8353
|
if (text.length > 0) content.push({ type: "text", text });
|
|
@@ -8510,6 +8518,10 @@ ${additions}`;
|
|
|
8510
8518
|
function toLlmTool(tool) {
|
|
8511
8519
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
8512
8520
|
}
|
|
8521
|
+
function reasoningEffortFromParams(params) {
|
|
8522
|
+
const thinking = params?.find((p) => p.id === "thinking");
|
|
8523
|
+
return thinking !== void 0 && thinking.value.length > 0 ? thinking.value : void 0;
|
|
8524
|
+
}
|
|
8513
8525
|
async function streamLlmTurn(inputs, ctx) {
|
|
8514
8526
|
const llmSpan = inputs.telemetry?.startSpan("llm.call", {
|
|
8515
8527
|
"model.id": inputs.model.id ?? "auto",
|
|
@@ -8526,6 +8538,15 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
8526
8538
|
);
|
|
8527
8539
|
return effective !== void 0 ? { system: effective } : {};
|
|
8528
8540
|
})(),
|
|
8541
|
+
// issue #47: forward the reasoning effort from ModelSelection.params (the `thinking` param)
|
|
8542
|
+
// so the provider produces reasoning. Absent param ⇒ no `reasoning` field (bare request).
|
|
8543
|
+
...(() => {
|
|
8544
|
+
const effort = reasoningEffortFromParams(inputs.model.params);
|
|
8545
|
+
return effort !== void 0 ? { reasoning: { effort } } : {};
|
|
8546
|
+
})(),
|
|
8547
|
+
// Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
|
|
8548
|
+
// text close even though tools are advertised). Absent ⇒ provider default (auto).
|
|
8549
|
+
...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
|
|
8529
8550
|
messages: ctx.messages,
|
|
8530
8551
|
tools: ctx.tools.map(toLlmTool)
|
|
8531
8552
|
},
|
|
@@ -8594,6 +8615,7 @@ function registerLoopError(ctx, cause) {
|
|
|
8594
8615
|
}
|
|
8595
8616
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
8596
8617
|
let accumulatedText = "";
|
|
8618
|
+
let reasoningText = "";
|
|
8597
8619
|
let errored = false;
|
|
8598
8620
|
let finishValue;
|
|
8599
8621
|
while (true) {
|
|
@@ -8606,6 +8628,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8606
8628
|
accumulatedText += next.value.text;
|
|
8607
8629
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
8608
8630
|
}
|
|
8631
|
+
if (next.value.type === "reasoning_delta") {
|
|
8632
|
+
reasoningText += next.value.text;
|
|
8633
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
8634
|
+
}
|
|
8609
8635
|
if (next.value.type === "error") {
|
|
8610
8636
|
registerLoopError(ctx, next.value);
|
|
8611
8637
|
ctx.finalText = "";
|
|
@@ -8613,6 +8639,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8613
8639
|
break;
|
|
8614
8640
|
}
|
|
8615
8641
|
}
|
|
8642
|
+
if (reasoningText.length > 0) {
|
|
8643
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
8644
|
+
}
|
|
8616
8645
|
return { accumulatedText, errored, finishValue };
|
|
8617
8646
|
}
|
|
8618
8647
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -8624,6 +8653,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
8624
8653
|
"SendOptions.onDelta"
|
|
8625
8654
|
);
|
|
8626
8655
|
}
|
|
8656
|
+
async function emitReasoningDeltaCallback(inputs, text) {
|
|
8657
|
+
if (inputs.onDelta === void 0) return;
|
|
8658
|
+
const cb = inputs.onDelta;
|
|
8659
|
+
await safeCall(
|
|
8660
|
+
() => cb({ update: { type: "thinking-delta", text } }),
|
|
8661
|
+
void 0,
|
|
8662
|
+
"SendOptions.onDelta"
|
|
8663
|
+
);
|
|
8664
|
+
}
|
|
8627
8665
|
|
|
8628
8666
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
8629
8667
|
init_async_local_storage();
|
|
@@ -10937,7 +10975,7 @@ var OpenAIClient = class {
|
|
|
10937
10975
|
method: "POST",
|
|
10938
10976
|
signal,
|
|
10939
10977
|
headers,
|
|
10940
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
10978
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
10941
10979
|
});
|
|
10942
10980
|
} catch (fetchErr) {
|
|
10943
10981
|
const mapped = mapOllamaTransportError({
|
|
@@ -10999,6 +11037,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
10999
11037
|
const events = [];
|
|
11000
11038
|
this.applyUsage(chunk.usage);
|
|
11001
11039
|
for (const choice of chunk.choices ?? []) {
|
|
11040
|
+
const reasoningEvent = this.applyReasoningDelta(
|
|
11041
|
+
choice.delta?.reasoning ?? choice.delta?.reasoning_content
|
|
11042
|
+
);
|
|
11043
|
+
if (reasoningEvent !== void 0) events.push(reasoningEvent);
|
|
11002
11044
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
11003
11045
|
if (textEvent !== void 0) events.push(textEvent);
|
|
11004
11046
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -11006,6 +11048,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11006
11048
|
}
|
|
11007
11049
|
return events;
|
|
11008
11050
|
}
|
|
11051
|
+
applyReasoningDelta(reasoning) {
|
|
11052
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
11053
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
11054
|
+
}
|
|
11009
11055
|
applyUsage(usage) {
|
|
11010
11056
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
11011
11057
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -11068,7 +11114,22 @@ function mapOpenAIFinish(reason) {
|
|
|
11068
11114
|
return "end_turn";
|
|
11069
11115
|
}
|
|
11070
11116
|
}
|
|
11071
|
-
function
|
|
11117
|
+
function applyReasoningRequest(body, effort, providerName) {
|
|
11118
|
+
if (providerName === "openai") {
|
|
11119
|
+
body.reasoning_effort = effort;
|
|
11120
|
+
return;
|
|
11121
|
+
}
|
|
11122
|
+
body.reasoning = { effort };
|
|
11123
|
+
}
|
|
11124
|
+
function applyToolsRequest(body, request) {
|
|
11125
|
+
if (request.tools === void 0 || request.tools.length === 0) return;
|
|
11126
|
+
body.tools = request.tools.map((tool) => ({
|
|
11127
|
+
type: "function",
|
|
11128
|
+
function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
|
|
11129
|
+
}));
|
|
11130
|
+
if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
|
|
11131
|
+
}
|
|
11132
|
+
function buildOpenAIBody(request, providerName) {
|
|
11072
11133
|
const messages = [];
|
|
11073
11134
|
const systemText = openAISystemText(request.system);
|
|
11074
11135
|
if (systemText.length > 0) {
|
|
@@ -11087,12 +11148,9 @@ function buildOpenAIBody(request) {
|
|
|
11087
11148
|
};
|
|
11088
11149
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
11089
11150
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
11090
|
-
if (request.
|
|
11091
|
-
body
|
|
11092
|
-
|
|
11093
|
-
function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
|
|
11094
|
-
}));
|
|
11095
|
-
}
|
|
11151
|
+
if (request.reasoning?.effort !== void 0)
|
|
11152
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
11153
|
+
applyToolsRequest(body, request);
|
|
11096
11154
|
const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
|
|
11097
11155
|
if (responseFormat !== void 0) body.response_format = responseFormat;
|
|
11098
11156
|
return body;
|
|
@@ -11920,7 +11978,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11920
11978
|
return {
|
|
11921
11979
|
agentId: options.agentId,
|
|
11922
11980
|
runId,
|
|
11923
|
-
|
|
11981
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
11982
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
11983
|
+
model: {
|
|
11984
|
+
id: effectiveModelId,
|
|
11985
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
11986
|
+
},
|
|
11924
11987
|
userMessage: userText,
|
|
11925
11988
|
llm,
|
|
11926
11989
|
mcp: buildMcpMap(options),
|
|
@@ -11930,6 +11993,7 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11930
11993
|
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
11931
11994
|
...options.onStep !== void 0 ? { onStep: options.onStep } : {},
|
|
11932
11995
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
11996
|
+
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
11933
11997
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
11934
11998
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
11935
11999
|
...buildCustomToolsInput(
|