@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/a2a/index.js
CHANGED
|
@@ -6886,6 +6886,14 @@ function buildAssistantEvent(inputs, text) {
|
|
|
6886
6886
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
6887
6887
|
};
|
|
6888
6888
|
}
|
|
6889
|
+
function buildThinkingEvent(inputs, text) {
|
|
6890
|
+
return {
|
|
6891
|
+
type: "thinking",
|
|
6892
|
+
agent_id: inputs.agentId,
|
|
6893
|
+
run_id: inputs.runId,
|
|
6894
|
+
text
|
|
6895
|
+
};
|
|
6896
|
+
}
|
|
6889
6897
|
function buildAssistantTurn(text, toolCalls) {
|
|
6890
6898
|
const content = [];
|
|
6891
6899
|
if (text.length > 0) content.push({ type: "text", text });
|
|
@@ -7071,6 +7079,10 @@ ${additions}`;
|
|
|
7071
7079
|
function toLlmTool(tool) {
|
|
7072
7080
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
7073
7081
|
}
|
|
7082
|
+
function reasoningEffortFromParams(params) {
|
|
7083
|
+
const thinking = params?.find((p) => p.id === "thinking");
|
|
7084
|
+
return thinking !== void 0 && thinking.value.length > 0 ? thinking.value : void 0;
|
|
7085
|
+
}
|
|
7074
7086
|
async function streamLlmTurn(inputs, ctx) {
|
|
7075
7087
|
const llmSpan = inputs.telemetry?.startSpan("llm.call", {
|
|
7076
7088
|
"model.id": inputs.model.id ?? "auto",
|
|
@@ -7087,6 +7099,12 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
7087
7099
|
);
|
|
7088
7100
|
return effective !== void 0 ? { system: effective } : {};
|
|
7089
7101
|
})(),
|
|
7102
|
+
// issue #47: forward the reasoning effort from ModelSelection.params (the `thinking` param)
|
|
7103
|
+
// so the provider produces reasoning. Absent param ⇒ no `reasoning` field (bare request).
|
|
7104
|
+
...(() => {
|
|
7105
|
+
const effort = reasoningEffortFromParams(inputs.model.params);
|
|
7106
|
+
return effort !== void 0 ? { reasoning: { effort } } : {};
|
|
7107
|
+
})(),
|
|
7090
7108
|
messages: ctx.messages,
|
|
7091
7109
|
tools: ctx.tools.map(toLlmTool)
|
|
7092
7110
|
},
|
|
@@ -7155,6 +7173,7 @@ function registerLoopError(ctx, cause) {
|
|
|
7155
7173
|
}
|
|
7156
7174
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
7157
7175
|
let accumulatedText = "";
|
|
7176
|
+
let reasoningText = "";
|
|
7158
7177
|
let errored = false;
|
|
7159
7178
|
let finishValue;
|
|
7160
7179
|
while (true) {
|
|
@@ -7167,6 +7186,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
7167
7186
|
accumulatedText += next.value.text;
|
|
7168
7187
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
7169
7188
|
}
|
|
7189
|
+
if (next.value.type === "reasoning_delta") {
|
|
7190
|
+
reasoningText += next.value.text;
|
|
7191
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
7192
|
+
}
|
|
7170
7193
|
if (next.value.type === "error") {
|
|
7171
7194
|
registerLoopError(ctx, next.value);
|
|
7172
7195
|
ctx.finalText = "";
|
|
@@ -7174,6 +7197,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
7174
7197
|
break;
|
|
7175
7198
|
}
|
|
7176
7199
|
}
|
|
7200
|
+
if (reasoningText.length > 0) {
|
|
7201
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
7202
|
+
}
|
|
7177
7203
|
return { accumulatedText, errored, finishValue };
|
|
7178
7204
|
}
|
|
7179
7205
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -7185,6 +7211,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
7185
7211
|
"SendOptions.onDelta"
|
|
7186
7212
|
);
|
|
7187
7213
|
}
|
|
7214
|
+
async function emitReasoningDeltaCallback(inputs, text) {
|
|
7215
|
+
if (inputs.onDelta === void 0) return;
|
|
7216
|
+
const cb = inputs.onDelta;
|
|
7217
|
+
await safeCall(
|
|
7218
|
+
() => cb({ update: { type: "thinking-delta", text } }),
|
|
7219
|
+
void 0,
|
|
7220
|
+
"SendOptions.onDelta"
|
|
7221
|
+
);
|
|
7222
|
+
}
|
|
7188
7223
|
var init_loop_llm_stream = __esm({
|
|
7189
7224
|
"src/internal/agent-loop/loop-llm-stream.ts"() {
|
|
7190
7225
|
init_safe_call();
|
|
@@ -10069,7 +10104,14 @@ function mapOpenAIFinish(reason) {
|
|
|
10069
10104
|
return "end_turn";
|
|
10070
10105
|
}
|
|
10071
10106
|
}
|
|
10072
|
-
function
|
|
10107
|
+
function applyReasoningRequest(body, effort, providerName) {
|
|
10108
|
+
if (providerName === "openai") {
|
|
10109
|
+
body.reasoning_effort = effort;
|
|
10110
|
+
return;
|
|
10111
|
+
}
|
|
10112
|
+
body.reasoning = { effort };
|
|
10113
|
+
}
|
|
10114
|
+
function buildOpenAIBody(request, providerName) {
|
|
10073
10115
|
const messages = [];
|
|
10074
10116
|
const systemText = openAISystemText(request.system);
|
|
10075
10117
|
if (systemText.length > 0) {
|
|
@@ -10088,6 +10130,8 @@ function buildOpenAIBody(request) {
|
|
|
10088
10130
|
};
|
|
10089
10131
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
10090
10132
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
10133
|
+
if (request.reasoning?.effort !== void 0)
|
|
10134
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
10091
10135
|
if (request.tools !== void 0 && request.tools.length > 0) {
|
|
10092
10136
|
body.tools = request.tools.map((tool) => ({
|
|
10093
10137
|
type: "function",
|
|
@@ -10183,7 +10227,7 @@ var init_openai2 = __esm({
|
|
|
10183
10227
|
method: "POST",
|
|
10184
10228
|
signal,
|
|
10185
10229
|
headers,
|
|
10186
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
10230
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
10187
10231
|
});
|
|
10188
10232
|
} catch (fetchErr) {
|
|
10189
10233
|
const mapped = mapOllamaTransportError({
|
|
@@ -10245,6 +10289,10 @@ var init_openai2 = __esm({
|
|
|
10245
10289
|
const events = [];
|
|
10246
10290
|
this.applyUsage(chunk.usage);
|
|
10247
10291
|
for (const choice of chunk.choices ?? []) {
|
|
10292
|
+
const reasoningEvent = this.applyReasoningDelta(
|
|
10293
|
+
choice.delta?.reasoning ?? choice.delta?.reasoning_content
|
|
10294
|
+
);
|
|
10295
|
+
if (reasoningEvent !== void 0) events.push(reasoningEvent);
|
|
10248
10296
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
10249
10297
|
if (textEvent !== void 0) events.push(textEvent);
|
|
10250
10298
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -10252,6 +10300,10 @@ var init_openai2 = __esm({
|
|
|
10252
10300
|
}
|
|
10253
10301
|
return events;
|
|
10254
10302
|
}
|
|
10303
|
+
applyReasoningDelta(reasoning) {
|
|
10304
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
10305
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
10306
|
+
}
|
|
10255
10307
|
applyUsage(usage) {
|
|
10256
10308
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
10257
10309
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -11141,7 +11193,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11141
11193
|
return {
|
|
11142
11194
|
agentId: options.agentId,
|
|
11143
11195
|
runId,
|
|
11144
|
-
|
|
11196
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
11197
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
11198
|
+
model: {
|
|
11199
|
+
id: effectiveModelId,
|
|
11200
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
11201
|
+
},
|
|
11145
11202
|
userMessage: userText,
|
|
11146
11203
|
llm,
|
|
11147
11204
|
mcp: buildMcpMap(options),
|