@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
|
@@ -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,25 @@ 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
|
+
};
|
|
83
95
|
}
|
|
84
96
|
export type LlmEvent = {
|
|
85
97
|
type: "text_delta";
|
|
86
98
|
text: string;
|
|
99
|
+
} | {
|
|
100
|
+
type: "reasoning_delta";
|
|
101
|
+
text: string;
|
|
87
102
|
} | {
|
|
88
103
|
type: "tool_use";
|
|
89
104
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/sdk",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.1",
|
|
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
|
+
}
|