@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/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,15 @@ 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
|
+
})(),
|
|
7108
|
+
// Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
|
|
7109
|
+
// text close even though tools are advertised). Absent ⇒ provider default (auto).
|
|
7110
|
+
...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
|
|
7090
7111
|
messages: ctx.messages,
|
|
7091
7112
|
tools: ctx.tools.map(toLlmTool)
|
|
7092
7113
|
},
|
|
@@ -7155,6 +7176,7 @@ function registerLoopError(ctx, cause) {
|
|
|
7155
7176
|
}
|
|
7156
7177
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
7157
7178
|
let accumulatedText = "";
|
|
7179
|
+
let reasoningText = "";
|
|
7158
7180
|
let errored = false;
|
|
7159
7181
|
let finishValue;
|
|
7160
7182
|
while (true) {
|
|
@@ -7167,6 +7189,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
7167
7189
|
accumulatedText += next.value.text;
|
|
7168
7190
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
7169
7191
|
}
|
|
7192
|
+
if (next.value.type === "reasoning_delta") {
|
|
7193
|
+
reasoningText += next.value.text;
|
|
7194
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
7195
|
+
}
|
|
7170
7196
|
if (next.value.type === "error") {
|
|
7171
7197
|
registerLoopError(ctx, next.value);
|
|
7172
7198
|
ctx.finalText = "";
|
|
@@ -7174,6 +7200,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
7174
7200
|
break;
|
|
7175
7201
|
}
|
|
7176
7202
|
}
|
|
7203
|
+
if (reasoningText.length > 0) {
|
|
7204
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
7205
|
+
}
|
|
7177
7206
|
return { accumulatedText, errored, finishValue };
|
|
7178
7207
|
}
|
|
7179
7208
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -7185,6 +7214,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
7185
7214
|
"SendOptions.onDelta"
|
|
7186
7215
|
);
|
|
7187
7216
|
}
|
|
7217
|
+
async function emitReasoningDeltaCallback(inputs, text) {
|
|
7218
|
+
if (inputs.onDelta === void 0) return;
|
|
7219
|
+
const cb = inputs.onDelta;
|
|
7220
|
+
await safeCall(
|
|
7221
|
+
() => cb({ update: { type: "thinking-delta", text } }),
|
|
7222
|
+
void 0,
|
|
7223
|
+
"SendOptions.onDelta"
|
|
7224
|
+
);
|
|
7225
|
+
}
|
|
7188
7226
|
var init_loop_llm_stream = __esm({
|
|
7189
7227
|
"src/internal/agent-loop/loop-llm-stream.ts"() {
|
|
7190
7228
|
init_safe_call();
|
|
@@ -10069,7 +10107,22 @@ function mapOpenAIFinish(reason) {
|
|
|
10069
10107
|
return "end_turn";
|
|
10070
10108
|
}
|
|
10071
10109
|
}
|
|
10072
|
-
function
|
|
10110
|
+
function applyReasoningRequest(body, effort, providerName) {
|
|
10111
|
+
if (providerName === "openai") {
|
|
10112
|
+
body.reasoning_effort = effort;
|
|
10113
|
+
return;
|
|
10114
|
+
}
|
|
10115
|
+
body.reasoning = { effort };
|
|
10116
|
+
}
|
|
10117
|
+
function applyToolsRequest(body, request) {
|
|
10118
|
+
if (request.tools === void 0 || request.tools.length === 0) return;
|
|
10119
|
+
body.tools = request.tools.map((tool) => ({
|
|
10120
|
+
type: "function",
|
|
10121
|
+
function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
|
|
10122
|
+
}));
|
|
10123
|
+
if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
|
|
10124
|
+
}
|
|
10125
|
+
function buildOpenAIBody(request, providerName) {
|
|
10073
10126
|
const messages = [];
|
|
10074
10127
|
const systemText = openAISystemText(request.system);
|
|
10075
10128
|
if (systemText.length > 0) {
|
|
@@ -10088,12 +10141,9 @@ function buildOpenAIBody(request) {
|
|
|
10088
10141
|
};
|
|
10089
10142
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
10090
10143
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
10091
|
-
if (request.
|
|
10092
|
-
body
|
|
10093
|
-
|
|
10094
|
-
function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
|
|
10095
|
-
}));
|
|
10096
|
-
}
|
|
10144
|
+
if (request.reasoning?.effort !== void 0)
|
|
10145
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
10146
|
+
applyToolsRequest(body, request);
|
|
10097
10147
|
const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
|
|
10098
10148
|
if (responseFormat !== void 0) body.response_format = responseFormat;
|
|
10099
10149
|
return body;
|
|
@@ -10183,7 +10233,7 @@ var init_openai2 = __esm({
|
|
|
10183
10233
|
method: "POST",
|
|
10184
10234
|
signal,
|
|
10185
10235
|
headers,
|
|
10186
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
10236
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
10187
10237
|
});
|
|
10188
10238
|
} catch (fetchErr) {
|
|
10189
10239
|
const mapped = mapOllamaTransportError({
|
|
@@ -10245,6 +10295,10 @@ var init_openai2 = __esm({
|
|
|
10245
10295
|
const events = [];
|
|
10246
10296
|
this.applyUsage(chunk.usage);
|
|
10247
10297
|
for (const choice of chunk.choices ?? []) {
|
|
10298
|
+
const reasoningEvent = this.applyReasoningDelta(
|
|
10299
|
+
choice.delta?.reasoning ?? choice.delta?.reasoning_content
|
|
10300
|
+
);
|
|
10301
|
+
if (reasoningEvent !== void 0) events.push(reasoningEvent);
|
|
10248
10302
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
10249
10303
|
if (textEvent !== void 0) events.push(textEvent);
|
|
10250
10304
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -10252,6 +10306,10 @@ var init_openai2 = __esm({
|
|
|
10252
10306
|
}
|
|
10253
10307
|
return events;
|
|
10254
10308
|
}
|
|
10309
|
+
applyReasoningDelta(reasoning) {
|
|
10310
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
10311
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
10312
|
+
}
|
|
10255
10313
|
applyUsage(usage) {
|
|
10256
10314
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
10257
10315
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -11141,7 +11199,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11141
11199
|
return {
|
|
11142
11200
|
agentId: options.agentId,
|
|
11143
11201
|
runId,
|
|
11144
|
-
|
|
11202
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
11203
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
11204
|
+
model: {
|
|
11205
|
+
id: effectiveModelId,
|
|
11206
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
11207
|
+
},
|
|
11145
11208
|
userMessage: userText,
|
|
11146
11209
|
llm,
|
|
11147
11210
|
mcp: buildMcpMap(options),
|
|
@@ -11151,6 +11214,7 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11151
11214
|
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
11152
11215
|
...options.onStep !== void 0 ? { onStep: options.onStep } : {},
|
|
11153
11216
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
11217
|
+
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
11154
11218
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
11155
11219
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
11156
11220
|
...buildCustomToolsInput(
|