@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,6 +1,8 @@
|
|
|
1
|
-
import type { SDKAssistantMessage, SDKUserMessageEvent } from "../../types/messages.js";
|
|
1
|
+
import type { SDKAssistantMessage, SDKThinkingMessage, SDKUserMessageEvent } from "../../types/messages.js";
|
|
2
2
|
import type { LlmMessage, LlmToolCallPart } from "../llm/types.js";
|
|
3
3
|
import type { AgentLoopInputs } from "./loop-types.js";
|
|
4
4
|
export declare function buildUserEvent(inputs: AgentLoopInputs): SDKUserMessageEvent;
|
|
5
5
|
export declare function buildAssistantEvent(inputs: AgentLoopInputs, text: string): SDKAssistantMessage;
|
|
6
|
+
/** issue #47: the reasoning the model produced this turn, as a `thinking` SDKMessage. */
|
|
7
|
+
export declare function buildThinkingEvent(inputs: AgentLoopInputs, text: string): SDKThinkingMessage;
|
|
6
8
|
export declare function buildAssistantTurn(text: string, toolCalls: LlmToolCallPart[]): LlmMessage;
|
|
@@ -1,4 +1,48 @@
|
|
|
1
1
|
import type { LlmClient, LlmEvent, LlmFinish, LlmRequest } from "./types.js";
|
|
2
|
+
interface OpenAIDeltaChunk {
|
|
3
|
+
choices?: Array<{
|
|
4
|
+
index: number;
|
|
5
|
+
delta?: {
|
|
6
|
+
content?: string;
|
|
7
|
+
/** OpenRouter unified reasoning delta (issue #47) — streamed separately from `content`. */
|
|
8
|
+
reasoning?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Sibling reasoning field used by some OpenAI-compatible providers (DeepSeek's direct API,
|
|
11
|
+
* many vLLM / LMStudio reasoning parsers). Treated identically to `reasoning` (issue #47,
|
|
12
|
+
* F-domain-2). OpenRouter normalizes to `reasoning`; this is the fallback for non-OpenRouter
|
|
13
|
+
* compat endpoints reached via `baseUrl` override.
|
|
14
|
+
*/
|
|
15
|
+
reasoning_content?: string;
|
|
16
|
+
tool_calls?: Array<{
|
|
17
|
+
index: number;
|
|
18
|
+
id?: string;
|
|
19
|
+
function?: {
|
|
20
|
+
name?: string;
|
|
21
|
+
arguments?: string;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
finish_reason?: string | null;
|
|
26
|
+
}>;
|
|
27
|
+
usage?: {
|
|
28
|
+
prompt_tokens?: number;
|
|
29
|
+
completion_tokens?: number;
|
|
30
|
+
/**
|
|
31
|
+
* OpenAI + OpenRouter extended usage (D376). Anthropic prompt caching
|
|
32
|
+
* surfaces as `prompt_tokens_details.cached_tokens` on OpenRouter passthrough;
|
|
33
|
+
* native OpenAI exposes the same field on `chatcmpl-*` responses.
|
|
34
|
+
*/
|
|
35
|
+
prompt_tokens_details?: {
|
|
36
|
+
cached_tokens?: number;
|
|
37
|
+
};
|
|
38
|
+
completion_tokens_details?: {
|
|
39
|
+
reasoning_tokens?: number;
|
|
40
|
+
};
|
|
41
|
+
/** Anthropic-on-OpenRouter passes cache_creation_tokens top-level (cline#10266). */
|
|
42
|
+
cache_creation_input_tokens?: number;
|
|
43
|
+
cache_read_input_tokens?: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
2
46
|
export declare class OpenAIClient implements LlmClient {
|
|
3
47
|
private readonly options;
|
|
4
48
|
readonly name = "openai";
|
|
@@ -7,3 +51,23 @@ export declare class OpenAIClient implements LlmClient {
|
|
|
7
51
|
constructor(options: OpenAIClientOptions);
|
|
8
52
|
stream(request: LlmRequest, signal: AbortSignal): AsyncGenerator<LlmEvent, LlmFinish, void>;
|
|
9
53
|
}
|
|
54
|
+
declare class OpenAIStreamAccumulator {
|
|
55
|
+
private text;
|
|
56
|
+
private stopReason;
|
|
57
|
+
private inputTokens?;
|
|
58
|
+
private outputTokens?;
|
|
59
|
+
private cacheReadTokens?;
|
|
60
|
+
private cacheWriteTokens?;
|
|
61
|
+
private reasoningTokens?;
|
|
62
|
+
private readonly toolCalls;
|
|
63
|
+
consume(chunk: OpenAIDeltaChunk): LlmEvent[];
|
|
64
|
+
private applyReasoningDelta;
|
|
65
|
+
private applyUsage;
|
|
66
|
+
private applyContentDelta;
|
|
67
|
+
private mergeToolCallDeltas;
|
|
68
|
+
private applyFinishReason;
|
|
69
|
+
finish(): LlmFinish;
|
|
70
|
+
}
|
|
71
|
+
/** issue #47 test seam — exercise reasoning-delta parsing without a live stream. */
|
|
72
|
+
export declare const __testing__OpenAIStreamAccumulator: typeof OpenAIStreamAccumulator;
|
|
73
|
+
export {};
|
|
@@ -80,10 +80,33 @@ export interface LlmRequest {
|
|
|
80
80
|
temperature?: number;
|
|
81
81
|
/** T3.6 — opt into native structured outputs (OpenAI-compat providers). */
|
|
82
82
|
responseFormat?: LlmResponseFormat;
|
|
83
|
+
/**
|
|
84
|
+
* Reasoning / extended-thinking request (issue #47). Derived from `ModelSelection.params` (the
|
|
85
|
+
* `thinking` param). The wire encoding is provider-specific: OpenRouter (and OpenAI-compatible
|
|
86
|
+
* passthroughs) use the unified `reasoning: { effort }` object; native OpenAI Chat Completions uses
|
|
87
|
+
* the top-level `reasoning_effort` string (see `buildOpenAIBody`). The model streams reasoning back
|
|
88
|
+
* as `delta.reasoning` (or `delta.reasoning_content` on some compat providers), surfaced as
|
|
89
|
+
* `reasoning_delta` events. `effort` is required once the object is present — an empty object would
|
|
90
|
+
* request nothing.
|
|
91
|
+
*/
|
|
92
|
+
reasoning?: {
|
|
93
|
+
effort: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Step-cap force-close: per-request tool gating. `"none"` tells the provider to emit no tool
|
|
97
|
+
* calls even when `tools` are present (forcing a text answer); `"required"` forces a tool call;
|
|
98
|
+
* `"auto"` (or omitted) is the default. Maps to OpenAI/OpenRouter `tool_choice`. The agent loop
|
|
99
|
+
* sets `"none"` on a final/ceiling round so a cached agent (whose tools cannot be un-registered)
|
|
100
|
+
* is still forced to produce a closing summary.
|
|
101
|
+
*/
|
|
102
|
+
toolChoice?: "auto" | "none" | "required";
|
|
83
103
|
}
|
|
84
104
|
export type LlmEvent = {
|
|
85
105
|
type: "text_delta";
|
|
86
106
|
text: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: "reasoning_delta";
|
|
109
|
+
text: string;
|
|
87
110
|
} | {
|
|
88
111
|
type: "tool_use";
|
|
89
112
|
id: string;
|
|
@@ -827,6 +827,13 @@ interface SendOptions {
|
|
|
827
827
|
onDelta?: (args: {
|
|
828
828
|
update: InteractionUpdate;
|
|
829
829
|
}) => void | Promise<void>;
|
|
830
|
+
/**
|
|
831
|
+
* Per-call tool gate (OpenAI/OpenRouter `tool_choice`). `"none"` forces a text answer even when
|
|
832
|
+
* the agent has tools registered — used by an agent loop to force a closing summary at its step
|
|
833
|
+
* ceiling (a cached agent's tools cannot be un-registered, so the gate is per-send). `"required"`
|
|
834
|
+
* forces a tool call; `"auto"` (or omitted) is the default. Local runtime; OpenAI-compat providers.
|
|
835
|
+
*/
|
|
836
|
+
toolChoice?: "auto" | "none" | "required";
|
|
830
837
|
/** Local agents only. Expire a stuck active run before starting this message. */
|
|
831
838
|
local?: {
|
|
832
839
|
force?: boolean;
|
|
@@ -827,6 +827,13 @@ interface SendOptions {
|
|
|
827
827
|
onDelta?: (args: {
|
|
828
828
|
update: InteractionUpdate;
|
|
829
829
|
}) => void | Promise<void>;
|
|
830
|
+
/**
|
|
831
|
+
* Per-call tool gate (OpenAI/OpenRouter `tool_choice`). `"none"` forces a text answer even when
|
|
832
|
+
* the agent has tools registered — used by an agent loop to force a closing summary at its step
|
|
833
|
+
* ceiling (a cached agent's tools cannot be un-registered, so the gate is per-send). `"required"`
|
|
834
|
+
* forces a tool call; `"auto"` (or omitted) is the default. Local runtime; OpenAI-compat providers.
|
|
835
|
+
*/
|
|
836
|
+
toolChoice?: "auto" | "none" | "required";
|
|
830
837
|
/** Local agents only. Expire a stuck active run before starting this message. */
|
|
831
838
|
local?: {
|
|
832
839
|
force?: boolean;
|
package/dist/types/run.d.ts
CHANGED
|
@@ -221,6 +221,13 @@ export interface SendOptions {
|
|
|
221
221
|
onDelta?: (args: {
|
|
222
222
|
update: InteractionUpdate;
|
|
223
223
|
}) => void | Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Per-call tool gate (OpenAI/OpenRouter `tool_choice`). `"none"` forces a text answer even when
|
|
226
|
+
* the agent has tools registered — used by an agent loop to force a closing summary at its step
|
|
227
|
+
* ceiling (a cached agent's tools cannot be un-registered, so the gate is per-send). `"required"`
|
|
228
|
+
* forces a tool call; `"auto"` (or omitted) is the default. Local runtime; OpenAI-compat providers.
|
|
229
|
+
*/
|
|
230
|
+
toolChoice?: "auto" | "none" | "required";
|
|
224
231
|
/** Local agents only. Expire a stuck active run before starting this message. */
|
|
225
232
|
local?: {
|
|
226
233
|
force?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/sdk",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.2",
|
|
4
4
|
"description": "TypeScript SDK for the Theo agent harness — same surface, local or cloud.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/usetheo/theokit-sdk#readme",
|
|
@@ -298,15 +298,6 @@
|
|
|
298
298
|
"**/agent.js",
|
|
299
299
|
"**/agent.cjs"
|
|
300
300
|
],
|
|
301
|
-
"scripts": {
|
|
302
|
-
"build": "tsup && cp src/internal/providers/provider-catalog.json dist/provider-catalog.json",
|
|
303
|
-
"test": "vitest run --no-file-parallelism",
|
|
304
|
-
"test:watch": "vitest",
|
|
305
|
-
"typecheck": "tsc --noEmit",
|
|
306
|
-
"clean": "rm -rf dist",
|
|
307
|
-
"docs:json": "typedoc --options typedoc.json",
|
|
308
|
-
"docs:drift": "tsx scripts/check-docs-drift.ts"
|
|
309
|
-
},
|
|
310
301
|
"peerDependencies": {
|
|
311
302
|
"@lancedb/lancedb": "^0.30.0",
|
|
312
303
|
"@types/ws": ">=8.0.0",
|
|
@@ -363,8 +354,6 @@
|
|
|
363
354
|
"devDependencies": {
|
|
364
355
|
"@opentelemetry/api": "^1.9.1",
|
|
365
356
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
366
|
-
"@theokit/sdk-handoff": "workspace:*",
|
|
367
|
-
"@theokit/sdk-memory": "workspace:*",
|
|
368
357
|
"@types/better-sqlite3": "^7.6.13",
|
|
369
358
|
"@types/proper-lockfile": "^4.1.4",
|
|
370
359
|
"@types/ws": "^8.18.0",
|
|
@@ -374,6 +363,17 @@
|
|
|
374
363
|
"sqlite-vec": "^0.1.9",
|
|
375
364
|
"typedoc": "^0.28.19",
|
|
376
365
|
"ws": "^8.18.0",
|
|
377
|
-
"zod": "^4.0.0"
|
|
366
|
+
"zod": "^4.0.0",
|
|
367
|
+
"@theokit/sdk-handoff": "0.1.0",
|
|
368
|
+
"@theokit/sdk-memory": "0.2.0"
|
|
369
|
+
},
|
|
370
|
+
"scripts": {
|
|
371
|
+
"build": "tsup && cp src/internal/providers/provider-catalog.json dist/provider-catalog.json",
|
|
372
|
+
"test": "vitest run --no-file-parallelism",
|
|
373
|
+
"test:watch": "vitest",
|
|
374
|
+
"typecheck": "tsc --noEmit",
|
|
375
|
+
"clean": "rm -rf dist",
|
|
376
|
+
"docs:json": "typedoc --options typedoc.json",
|
|
377
|
+
"docs:drift": "tsx scripts/check-docs-drift.ts"
|
|
378
378
|
}
|
|
379
|
-
}
|
|
379
|
+
}
|