@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CustomTool, M as ModelSelection, F as SDKUserMessage, H as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, T as StreamToCompletionResult, a as McpServerConfig } from './run-
|
|
1
|
+
import { C as CustomTool, M as ModelSelection, F as SDKUserMessage, H as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, T as StreamToCompletionResult, a as McpServerConfig } from './run-TMdc7gmo.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Fork primitive public type contracts (T1.2, ADRs D110-D114).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CustomTool, M as ModelSelection, F as SDKUserMessage, H as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, T as StreamToCompletionResult, a as McpServerConfig } from './run-
|
|
1
|
+
import { C as CustomTool, M as ModelSelection, F as SDKUserMessage, H as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, T as StreamToCompletionResult, a as McpServerConfig } from './run-TMdc7gmo.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Fork primitive public type contracts (T1.2, ADRs D110-D114).
|
package/dist/cron.cjs
CHANGED
|
@@ -8348,6 +8348,14 @@ function buildAssistantEvent(inputs, text) {
|
|
|
8348
8348
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
8349
8349
|
};
|
|
8350
8350
|
}
|
|
8351
|
+
function buildThinkingEvent(inputs, text) {
|
|
8352
|
+
return {
|
|
8353
|
+
type: "thinking",
|
|
8354
|
+
agent_id: inputs.agentId,
|
|
8355
|
+
run_id: inputs.runId,
|
|
8356
|
+
text
|
|
8357
|
+
};
|
|
8358
|
+
}
|
|
8351
8359
|
function buildAssistantTurn(text, toolCalls) {
|
|
8352
8360
|
const content = [];
|
|
8353
8361
|
if (text.length > 0) content.push({ type: "text", text });
|
|
@@ -8518,6 +8526,10 @@ ${additions}`;
|
|
|
8518
8526
|
function toLlmTool(tool) {
|
|
8519
8527
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
8520
8528
|
}
|
|
8529
|
+
function reasoningEffortFromParams(params) {
|
|
8530
|
+
const thinking = params?.find((p) => p.id === "thinking");
|
|
8531
|
+
return thinking !== void 0 && thinking.value.length > 0 ? thinking.value : void 0;
|
|
8532
|
+
}
|
|
8521
8533
|
async function streamLlmTurn(inputs, ctx) {
|
|
8522
8534
|
const llmSpan = inputs.telemetry?.startSpan("llm.call", {
|
|
8523
8535
|
"model.id": inputs.model.id ?? "auto",
|
|
@@ -8534,6 +8546,15 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
8534
8546
|
);
|
|
8535
8547
|
return effective !== void 0 ? { system: effective } : {};
|
|
8536
8548
|
})(),
|
|
8549
|
+
// issue #47: forward the reasoning effort from ModelSelection.params (the `thinking` param)
|
|
8550
|
+
// so the provider produces reasoning. Absent param ⇒ no `reasoning` field (bare request).
|
|
8551
|
+
...(() => {
|
|
8552
|
+
const effort = reasoningEffortFromParams(inputs.model.params);
|
|
8553
|
+
return effort !== void 0 ? { reasoning: { effort } } : {};
|
|
8554
|
+
})(),
|
|
8555
|
+
// Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
|
|
8556
|
+
// text close even though tools are advertised). Absent ⇒ provider default (auto).
|
|
8557
|
+
...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
|
|
8537
8558
|
messages: ctx.messages,
|
|
8538
8559
|
tools: ctx.tools.map(toLlmTool)
|
|
8539
8560
|
},
|
|
@@ -8602,6 +8623,7 @@ function registerLoopError(ctx, cause) {
|
|
|
8602
8623
|
}
|
|
8603
8624
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
8604
8625
|
let accumulatedText = "";
|
|
8626
|
+
let reasoningText = "";
|
|
8605
8627
|
let errored = false;
|
|
8606
8628
|
let finishValue;
|
|
8607
8629
|
while (true) {
|
|
@@ -8614,6 +8636,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8614
8636
|
accumulatedText += next.value.text;
|
|
8615
8637
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
8616
8638
|
}
|
|
8639
|
+
if (next.value.type === "reasoning_delta") {
|
|
8640
|
+
reasoningText += next.value.text;
|
|
8641
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
8642
|
+
}
|
|
8617
8643
|
if (next.value.type === "error") {
|
|
8618
8644
|
registerLoopError(ctx, next.value);
|
|
8619
8645
|
ctx.finalText = "";
|
|
@@ -8621,6 +8647,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8621
8647
|
break;
|
|
8622
8648
|
}
|
|
8623
8649
|
}
|
|
8650
|
+
if (reasoningText.length > 0) {
|
|
8651
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
8652
|
+
}
|
|
8624
8653
|
return { accumulatedText, errored, finishValue };
|
|
8625
8654
|
}
|
|
8626
8655
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -8632,6 +8661,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
8632
8661
|
"SendOptions.onDelta"
|
|
8633
8662
|
);
|
|
8634
8663
|
}
|
|
8664
|
+
async function emitReasoningDeltaCallback(inputs, text) {
|
|
8665
|
+
if (inputs.onDelta === void 0) return;
|
|
8666
|
+
const cb = inputs.onDelta;
|
|
8667
|
+
await safeCall(
|
|
8668
|
+
() => cb({ update: { type: "thinking-delta", text } }),
|
|
8669
|
+
void 0,
|
|
8670
|
+
"SendOptions.onDelta"
|
|
8671
|
+
);
|
|
8672
|
+
}
|
|
8635
8673
|
|
|
8636
8674
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
8637
8675
|
init_async_local_storage();
|
|
@@ -10945,7 +10983,7 @@ var OpenAIClient = class {
|
|
|
10945
10983
|
method: "POST",
|
|
10946
10984
|
signal,
|
|
10947
10985
|
headers,
|
|
10948
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
10986
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
10949
10987
|
});
|
|
10950
10988
|
} catch (fetchErr) {
|
|
10951
10989
|
const mapped = mapOllamaTransportError({
|
|
@@ -11007,6 +11045,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11007
11045
|
const events = [];
|
|
11008
11046
|
this.applyUsage(chunk.usage);
|
|
11009
11047
|
for (const choice of chunk.choices ?? []) {
|
|
11048
|
+
const reasoningEvent = this.applyReasoningDelta(
|
|
11049
|
+
choice.delta?.reasoning ?? choice.delta?.reasoning_content
|
|
11050
|
+
);
|
|
11051
|
+
if (reasoningEvent !== void 0) events.push(reasoningEvent);
|
|
11010
11052
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
11011
11053
|
if (textEvent !== void 0) events.push(textEvent);
|
|
11012
11054
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -11014,6 +11056,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11014
11056
|
}
|
|
11015
11057
|
return events;
|
|
11016
11058
|
}
|
|
11059
|
+
applyReasoningDelta(reasoning) {
|
|
11060
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
11061
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
11062
|
+
}
|
|
11017
11063
|
applyUsage(usage) {
|
|
11018
11064
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
11019
11065
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -11076,7 +11122,22 @@ function mapOpenAIFinish(reason) {
|
|
|
11076
11122
|
return "end_turn";
|
|
11077
11123
|
}
|
|
11078
11124
|
}
|
|
11079
|
-
function
|
|
11125
|
+
function applyReasoningRequest(body, effort, providerName) {
|
|
11126
|
+
if (providerName === "openai") {
|
|
11127
|
+
body.reasoning_effort = effort;
|
|
11128
|
+
return;
|
|
11129
|
+
}
|
|
11130
|
+
body.reasoning = { effort };
|
|
11131
|
+
}
|
|
11132
|
+
function applyToolsRequest(body, request) {
|
|
11133
|
+
if (request.tools === void 0 || request.tools.length === 0) return;
|
|
11134
|
+
body.tools = request.tools.map((tool) => ({
|
|
11135
|
+
type: "function",
|
|
11136
|
+
function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
|
|
11137
|
+
}));
|
|
11138
|
+
if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
|
|
11139
|
+
}
|
|
11140
|
+
function buildOpenAIBody(request, providerName) {
|
|
11080
11141
|
const messages = [];
|
|
11081
11142
|
const systemText = openAISystemText(request.system);
|
|
11082
11143
|
if (systemText.length > 0) {
|
|
@@ -11095,12 +11156,9 @@ function buildOpenAIBody(request) {
|
|
|
11095
11156
|
};
|
|
11096
11157
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
11097
11158
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
11098
|
-
if (request.
|
|
11099
|
-
body
|
|
11100
|
-
|
|
11101
|
-
function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
|
|
11102
|
-
}));
|
|
11103
|
-
}
|
|
11159
|
+
if (request.reasoning?.effort !== void 0)
|
|
11160
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
11161
|
+
applyToolsRequest(body, request);
|
|
11104
11162
|
const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
|
|
11105
11163
|
if (responseFormat !== void 0) body.response_format = responseFormat;
|
|
11106
11164
|
return body;
|
|
@@ -11928,7 +11986,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11928
11986
|
return {
|
|
11929
11987
|
agentId: options.agentId,
|
|
11930
11988
|
runId,
|
|
11931
|
-
|
|
11989
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
11990
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
11991
|
+
model: {
|
|
11992
|
+
id: effectiveModelId,
|
|
11993
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
11994
|
+
},
|
|
11932
11995
|
userMessage: userText,
|
|
11933
11996
|
llm,
|
|
11934
11997
|
mcp: buildMcpMap(options),
|
|
@@ -11938,6 +12001,7 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11938
12001
|
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
11939
12002
|
...options.onStep !== void 0 ? { onStep: options.onStep } : {},
|
|
11940
12003
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
12004
|
+
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
11941
12005
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
11942
12006
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
11943
12007
|
...buildCustomToolsInput(
|