@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/errors.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, g as BudgetExceededError, C as ConfigurationError, u as CredentialPoolExhaustedError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, K as KnownAgentRunErrorCode, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, T as TheokitAgentError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-
|
|
2
|
-
import './run-
|
|
1
|
+
export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, g as BudgetExceededError, C as ConfigurationError, u as CredentialPoolExhaustedError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, K as KnownAgentRunErrorCode, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, T as TheokitAgentError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-9yw4UQwX.cjs';
|
|
2
|
+
import './run-TMdc7gmo.cjs';
|
package/dist/eval.cjs
CHANGED
|
@@ -8343,6 +8343,14 @@ function buildAssistantEvent(inputs, text) {
|
|
|
8343
8343
|
message: { role: "assistant", content: [{ type: "text", text }] }
|
|
8344
8344
|
};
|
|
8345
8345
|
}
|
|
8346
|
+
function buildThinkingEvent(inputs, text) {
|
|
8347
|
+
return {
|
|
8348
|
+
type: "thinking",
|
|
8349
|
+
agent_id: inputs.agentId,
|
|
8350
|
+
run_id: inputs.runId,
|
|
8351
|
+
text
|
|
8352
|
+
};
|
|
8353
|
+
}
|
|
8346
8354
|
function buildAssistantTurn(text, toolCalls) {
|
|
8347
8355
|
const content = [];
|
|
8348
8356
|
if (text.length > 0) content.push({ type: "text", text });
|
|
@@ -8513,6 +8521,10 @@ ${additions}`;
|
|
|
8513
8521
|
function toLlmTool(tool) {
|
|
8514
8522
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
8515
8523
|
}
|
|
8524
|
+
function reasoningEffortFromParams(params) {
|
|
8525
|
+
const thinking = params?.find((p) => p.id === "thinking");
|
|
8526
|
+
return thinking !== void 0 && thinking.value.length > 0 ? thinking.value : void 0;
|
|
8527
|
+
}
|
|
8516
8528
|
async function streamLlmTurn(inputs, ctx) {
|
|
8517
8529
|
const llmSpan = inputs.telemetry?.startSpan("llm.call", {
|
|
8518
8530
|
"model.id": inputs.model.id ?? "auto",
|
|
@@ -8529,6 +8541,15 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
8529
8541
|
);
|
|
8530
8542
|
return effective !== void 0 ? { system: effective } : {};
|
|
8531
8543
|
})(),
|
|
8544
|
+
// issue #47: forward the reasoning effort from ModelSelection.params (the `thinking` param)
|
|
8545
|
+
// so the provider produces reasoning. Absent param ⇒ no `reasoning` field (bare request).
|
|
8546
|
+
...(() => {
|
|
8547
|
+
const effort = reasoningEffortFromParams(inputs.model.params);
|
|
8548
|
+
return effort !== void 0 ? { reasoning: { effort } } : {};
|
|
8549
|
+
})(),
|
|
8550
|
+
// Step-cap force-close: forward the per-run tool gate (`"none"` on a ceiling round forces a
|
|
8551
|
+
// text close even though tools are advertised). Absent ⇒ provider default (auto).
|
|
8552
|
+
...inputs.toolChoice !== void 0 ? { toolChoice: inputs.toolChoice } : {},
|
|
8532
8553
|
messages: ctx.messages,
|
|
8533
8554
|
tools: ctx.tools.map(toLlmTool)
|
|
8534
8555
|
},
|
|
@@ -8597,6 +8618,7 @@ function registerLoopError(ctx, cause) {
|
|
|
8597
8618
|
}
|
|
8598
8619
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
8599
8620
|
let accumulatedText = "";
|
|
8621
|
+
let reasoningText = "";
|
|
8600
8622
|
let errored = false;
|
|
8601
8623
|
let finishValue;
|
|
8602
8624
|
while (true) {
|
|
@@ -8609,6 +8631,10 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8609
8631
|
accumulatedText += next.value.text;
|
|
8610
8632
|
await emitTextDeltaCallback(inputs, next.value.text);
|
|
8611
8633
|
}
|
|
8634
|
+
if (next.value.type === "reasoning_delta") {
|
|
8635
|
+
reasoningText += next.value.text;
|
|
8636
|
+
await emitReasoningDeltaCallback(inputs, next.value.text);
|
|
8637
|
+
}
|
|
8612
8638
|
if (next.value.type === "error") {
|
|
8613
8639
|
registerLoopError(ctx, next.value);
|
|
8614
8640
|
ctx.finalText = "";
|
|
@@ -8616,6 +8642,9 @@ async function runCollectorLoop(generator, inputs, ctx) {
|
|
|
8616
8642
|
break;
|
|
8617
8643
|
}
|
|
8618
8644
|
}
|
|
8645
|
+
if (reasoningText.length > 0) {
|
|
8646
|
+
ctx.events.push(buildThinkingEvent(inputs, reasoningText));
|
|
8647
|
+
}
|
|
8619
8648
|
return { accumulatedText, errored, finishValue };
|
|
8620
8649
|
}
|
|
8621
8650
|
async function emitTextDeltaCallback(inputs, text) {
|
|
@@ -8627,6 +8656,15 @@ async function emitTextDeltaCallback(inputs, text) {
|
|
|
8627
8656
|
"SendOptions.onDelta"
|
|
8628
8657
|
);
|
|
8629
8658
|
}
|
|
8659
|
+
async function emitReasoningDeltaCallback(inputs, text) {
|
|
8660
|
+
if (inputs.onDelta === void 0) return;
|
|
8661
|
+
const cb = inputs.onDelta;
|
|
8662
|
+
await safeCall(
|
|
8663
|
+
() => cb({ update: { type: "thinking-delta", text } }),
|
|
8664
|
+
void 0,
|
|
8665
|
+
"SendOptions.onDelta"
|
|
8666
|
+
);
|
|
8667
|
+
}
|
|
8630
8668
|
|
|
8631
8669
|
// src/internal/agent-loop/tool-dispatch.ts
|
|
8632
8670
|
init_async_local_storage();
|
|
@@ -10940,7 +10978,7 @@ var OpenAIClient = class {
|
|
|
10940
10978
|
method: "POST",
|
|
10941
10979
|
signal,
|
|
10942
10980
|
headers,
|
|
10943
|
-
body: JSON.stringify(buildOpenAIBody(request))
|
|
10981
|
+
body: JSON.stringify(buildOpenAIBody(request, providerId))
|
|
10944
10982
|
});
|
|
10945
10983
|
} catch (fetchErr) {
|
|
10946
10984
|
const mapped = mapOllamaTransportError({
|
|
@@ -11002,6 +11040,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11002
11040
|
const events = [];
|
|
11003
11041
|
this.applyUsage(chunk.usage);
|
|
11004
11042
|
for (const choice of chunk.choices ?? []) {
|
|
11043
|
+
const reasoningEvent = this.applyReasoningDelta(
|
|
11044
|
+
choice.delta?.reasoning ?? choice.delta?.reasoning_content
|
|
11045
|
+
);
|
|
11046
|
+
if (reasoningEvent !== void 0) events.push(reasoningEvent);
|
|
11005
11047
|
const textEvent = this.applyContentDelta(choice.delta?.content);
|
|
11006
11048
|
if (textEvent !== void 0) events.push(textEvent);
|
|
11007
11049
|
this.mergeToolCallDeltas(choice.delta?.tool_calls);
|
|
@@ -11009,6 +11051,10 @@ var OpenAIStreamAccumulator = class {
|
|
|
11009
11051
|
}
|
|
11010
11052
|
return events;
|
|
11011
11053
|
}
|
|
11054
|
+
applyReasoningDelta(reasoning) {
|
|
11055
|
+
if (typeof reasoning !== "string" || reasoning.length === 0) return void 0;
|
|
11056
|
+
return { type: "reasoning_delta", text: reasoning };
|
|
11057
|
+
}
|
|
11012
11058
|
applyUsage(usage) {
|
|
11013
11059
|
if (usage?.prompt_tokens !== void 0) this.inputTokens = usage.prompt_tokens;
|
|
11014
11060
|
if (usage?.completion_tokens !== void 0) this.outputTokens = usage.completion_tokens;
|
|
@@ -11071,7 +11117,22 @@ function mapOpenAIFinish(reason) {
|
|
|
11071
11117
|
return "end_turn";
|
|
11072
11118
|
}
|
|
11073
11119
|
}
|
|
11074
|
-
function
|
|
11120
|
+
function applyReasoningRequest(body, effort, providerName) {
|
|
11121
|
+
if (providerName === "openai") {
|
|
11122
|
+
body.reasoning_effort = effort;
|
|
11123
|
+
return;
|
|
11124
|
+
}
|
|
11125
|
+
body.reasoning = { effort };
|
|
11126
|
+
}
|
|
11127
|
+
function applyToolsRequest(body, request) {
|
|
11128
|
+
if (request.tools === void 0 || request.tools.length === 0) return;
|
|
11129
|
+
body.tools = request.tools.map((tool) => ({
|
|
11130
|
+
type: "function",
|
|
11131
|
+
function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
|
|
11132
|
+
}));
|
|
11133
|
+
if (request.toolChoice !== void 0) body.tool_choice = request.toolChoice;
|
|
11134
|
+
}
|
|
11135
|
+
function buildOpenAIBody(request, providerName) {
|
|
11075
11136
|
const messages = [];
|
|
11076
11137
|
const systemText = openAISystemText(request.system);
|
|
11077
11138
|
if (systemText.length > 0) {
|
|
@@ -11090,12 +11151,9 @@ function buildOpenAIBody(request) {
|
|
|
11090
11151
|
};
|
|
11091
11152
|
if (request.maxTokens !== void 0) body.max_tokens = request.maxTokens;
|
|
11092
11153
|
if (request.temperature !== void 0) body.temperature = request.temperature;
|
|
11093
|
-
if (request.
|
|
11094
|
-
body
|
|
11095
|
-
|
|
11096
|
-
function: { name: tool.name, description: tool.description, parameters: tool.inputSchema }
|
|
11097
|
-
}));
|
|
11098
|
-
}
|
|
11154
|
+
if (request.reasoning?.effort !== void 0)
|
|
11155
|
+
applyReasoningRequest(body, request.reasoning.effort, providerName);
|
|
11156
|
+
applyToolsRequest(body, request);
|
|
11099
11157
|
const responseFormat = encodeOpenAIResponseFormat(request.responseFormat);
|
|
11100
11158
|
if (responseFormat !== void 0) body.response_format = responseFormat;
|
|
11101
11159
|
return body;
|
|
@@ -11923,7 +11981,12 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11923
11981
|
return {
|
|
11924
11982
|
agentId: options.agentId,
|
|
11925
11983
|
runId,
|
|
11926
|
-
|
|
11984
|
+
// issue #47: carry ModelSelection.params (the reasoning `thinking` param) into the loop so the
|
|
11985
|
+
// request can forward reasoning. The id is stripped/normalized above; params pass through as-is.
|
|
11986
|
+
model: {
|
|
11987
|
+
id: effectiveModelId,
|
|
11988
|
+
...options.model?.params !== void 0 ? { params: options.model.params } : {}
|
|
11989
|
+
},
|
|
11927
11990
|
userMessage: userText,
|
|
11928
11991
|
llm,
|
|
11929
11992
|
mcp: buildMcpMap(options),
|
|
@@ -11933,6 +11996,7 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
11933
11996
|
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
11934
11997
|
...options.onStep !== void 0 ? { onStep: options.onStep } : {},
|
|
11935
11998
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
11999
|
+
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
11936
12000
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
11937
12001
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
11938
12002
|
...buildCustomToolsInput(
|