@theokit/sdk 5.10.0 → 5.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 +82 -0
- package/dist/{agent-XTLAVVYC.js → agent-DFV52V6E.js} +8 -7
- package/dist/{agent-XTLAVVYC.js.map → agent-DFV52V6E.js.map} +1 -1
- package/dist/{agent-TLRURB7W.cjs → agent-OKP4LHG2.cjs} +9 -8
- package/dist/{agent-TLRURB7W.cjs.map → agent-OKP4LHG2.cjs.map} +1 -1
- package/dist/{chunk-CVEQ5366.cjs → chunk-35KBC4BX.cjs} +177 -119
- package/dist/chunk-35KBC4BX.cjs.map +1 -0
- package/dist/{chunk-FR6COQXZ.cjs → chunk-3JANYJYS.cjs} +3 -3
- package/dist/{chunk-FR6COQXZ.cjs.map → chunk-3JANYJYS.cjs.map} +1 -1
- package/dist/{chunk-523O5UYB.js → chunk-6G4IRQUD.js} +3 -3
- package/dist/{chunk-523O5UYB.js.map → chunk-6G4IRQUD.js.map} +1 -1
- package/dist/{chunk-EVH3OUMY.js → chunk-BBJ77S62.js} +190 -44
- package/dist/chunk-BBJ77S62.js.map +1 -0
- package/dist/{chunk-PCLRIQPX.cjs → chunk-EQ5NCH2Y.cjs} +4 -4
- package/dist/{chunk-PCLRIQPX.cjs.map → chunk-EQ5NCH2Y.cjs.map} +1 -1
- package/dist/{chunk-TE6XVTOA.js → chunk-JLIRFWUG.js} +47 -17
- package/dist/chunk-JLIRFWUG.js.map +1 -0
- package/dist/{chunk-YEHQ3SIC.cjs → chunk-JV7JA7BM.cjs} +5 -5
- package/dist/{chunk-YEHQ3SIC.cjs.map → chunk-JV7JA7BM.cjs.map} +1 -1
- package/dist/chunk-LZJXEPEQ.js +58 -0
- package/dist/chunk-LZJXEPEQ.js.map +1 -0
- package/dist/{chunk-RTE2DD4S.js → chunk-MHIBYKWA.js} +127 -69
- package/dist/chunk-MHIBYKWA.js.map +1 -0
- package/dist/{chunk-WPO3VCY4.cjs → chunk-N7KS3TIR.cjs} +47 -17
- package/dist/chunk-N7KS3TIR.cjs.map +1 -0
- package/dist/chunk-NWS2CS3Y.cjs +61 -0
- package/dist/chunk-NWS2CS3Y.cjs.map +1 -0
- package/dist/{chunk-QY3CIMUV.cjs → chunk-P5N3Q2NH.cjs} +210 -62
- package/dist/chunk-P5N3Q2NH.cjs.map +1 -0
- package/dist/{chunk-EXI7EHDN.js → chunk-Q34EBNYG.js} +3 -3
- package/dist/{chunk-EXI7EHDN.js.map → chunk-Q34EBNYG.js.map} +1 -1
- package/dist/{chunk-HI3W37FY.js → chunk-U27XHOEF.js} +3 -3
- package/dist/{chunk-HI3W37FY.js.map → chunk-U27XHOEF.js.map} +1 -1
- package/dist/{compact-session-PVAWTKKL.js → compact-session-4HAUP3HK.js} +4 -4
- package/dist/{compact-session-PVAWTKKL.js.map → compact-session-4HAUP3HK.js.map} +1 -1
- package/dist/{compact-session-4QHBBGEY.cjs → compact-session-Y56D3S57.cjs} +13 -13
- package/dist/{compact-session-4QHBBGEY.cjs.map → compact-session-Y56D3S57.cjs.map} +1 -1
- package/dist/cron.cjs +8 -7
- package/dist/cron.js +7 -6
- package/dist/eval.cjs +7 -6
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +6 -5
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +40 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -106
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-O24XGRR6.js → inject-session-LJX5JGV5.js} +3 -3
- package/dist/{inject-session-O24XGRR6.js.map → inject-session-LJX5JGV5.js.map} +1 -1
- package/dist/{inject-session-OMLFL2V3.cjs → inject-session-R73PRM7B.cjs} +4 -4
- package/dist/{inject-session-OMLFL2V3.cjs.map → inject-session-R73PRM7B.cjs.map} +1 -1
- package/dist/internal/budget/normalize-usage.d.ts +81 -0
- package/dist/internal/error-mappers/openai-compatible.d.ts +3 -1
- package/dist/internal/llm/anthropic-shared.d.ts +6 -0
- package/dist/internal/llm/openai.d.ts +3 -5
- package/dist/internal/llm/openrouter-system.d.ts +1 -0
- package/dist/internal/llm/types.d.ts +10 -5
- package/dist/internal/memory/adapters/index.cjs +3 -3
- package/dist/internal/memory/adapters/index.js +2 -2
- package/dist/models.cjs +5 -50
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +3 -51
- package/dist/models.js.map +1 -1
- package/docs/error-codes.md +8 -4
- package/package.json +1 -1
- package/dist/chunk-CVEQ5366.cjs.map +0 -1
- package/dist/chunk-EVH3OUMY.js.map +0 -1
- package/dist/chunk-QY3CIMUV.cjs.map +0 -1
- package/dist/chunk-RTE2DD4S.js.map +0 -1
- package/dist/chunk-TE6XVTOA.js.map +0 -1
- package/dist/chunk-WPO3VCY4.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#740](https://github.com/usetheokit/theokit-sdk/pull/740) [`f5ee221`](https://github.com/usetheokit/theokit-sdk/commit/f5ee2218c3fc7dfba0b87de64c7472b8fd7184e8) Thanks [@usetheodev](https://github.com/usetheodev)! - `run.cancel()` on a local run now aborts the provider request. Until now it only set the status to `cancelled`: the LLM request kept streaming, `onDelta` kept receiving updates, and the provider billed the whole generation. The run now aborts the request, stops waiting for in-flight tool calls and passes the abort to custom tool handlers through `ctx.signal`, and delivers no update to `onDelta` once it is terminal. Shell commands and MCP tool calls receive no abort and keep running until they finish. A run cancelled while its MCP servers start up runs no turn, and still closes the MCP clients it owns. A cancelled turn reports no `usage` or `cost`: its result resolves when you cancel, before the turn's usage is collected. A `BudgetTracker` receives no tokens for a cancelled turn either, although the provider bills what it generated before the abort. A failed `close()` of a run-owned MCP client is now reported as a diagnostic naming the server, where it used to be dropped. Once a run is cancelled, `stream()`, `events()` and `conversation()` stop growing: the `[aborted]` message and the conversation the turn returns while it winds down are no longer added after `wait()` has resolved.
|
|
8
|
+
|
|
9
|
+
- [#744](https://github.com/usetheokit/theokit-sdk/pull/744) [`afb44b1`](https://github.com/usetheokit/theokit-sdk/commit/afb44b14153b15ddf482e78b89b4541f7c99836f) Thanks [@usetheodev](https://github.com/usetheodev)! - A provider that answers HTTP 404 because it does not serve the requested model now fails the run with a `ConfigurationError` whose message names the model. Until now OpenRouter's 404 for a retired model id (`No endpoints found for deepseek/deepseek-r1.`) became an `UnknownAgentError` with code `openrouter_unknown`, and neither the error nor `result.error.message` said which model was refused. The run now reports `result.error.code` `model_unavailable`, the error's `code` is `<provider>_model_unavailable`, and the message ends with the provider's own text when the provider sends one. OpenAI's 404 with code `model_not_found` gets the same class, at every OpenAI-compatible call site. OpenRouter's other "No endpoints found" 404s, for a request your data policy or the model's tool support rules out, report the same `model_unavailable` code; the provider's text in the message tells them apart. Any other 404, such as a wrong path, is still an `UnknownAgentError` with its old message.
|
|
10
|
+
|
|
11
|
+
- [#743](https://github.com/usetheokit/theokit-sdk/pull/743) [`a87a239`](https://github.com/usetheokit/theokit-sdk/commit/a87a23961f2804e37575b12a8f7a5bb59f0b8bd7) Thanks [@usetheodev](https://github.com/usetheodev)! - The `thinking-completed` update now arrives when the reasoning ends: before the first `text-delta`
|
|
12
|
+
of a turn that reasons and then answers. It used to arrive after the whole turn's stream, so a UI
|
|
13
|
+
that closed its reasoning block on it kept the block open until the answer had finished.
|
|
14
|
+
|
|
15
|
+
`thinkingDurationMs` on that update, and `thinking_duration_ms` on the replayed `thinking` message,
|
|
16
|
+
are now the reasoning span: the time of the last reasoning delta minus the time of the first. They
|
|
17
|
+
used to run until the end of the stream and so included the answer. In a live OpenRouter recording
|
|
18
|
+
the reported value was 19076 ms for 8282 ms of reasoning. Reasoning that arrives in a single delta,
|
|
19
|
+
with no delta after it, reports 0.
|
|
20
|
+
|
|
21
|
+
A turn that reasons and then calls a tool, or that ends without text, still sends the update at the
|
|
22
|
+
end of the stream, with the same duration rule. Each turn with reasoning still sends exactly one
|
|
23
|
+
`thinking-completed`; reasoning that arrives after the answer started is shown and replayed but
|
|
24
|
+
sends no second one.
|
|
25
|
+
|
|
26
|
+
## 5.11.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- [#734](https://github.com/usetheokit/theokit-sdk/pull/734) [`1f04344`](https://github.com/usetheokit/theokit-sdk/commit/1f0434491b706f7ea97f53d998fc33b300af1c33) Thanks [@usetheodev](https://github.com/usetheodev)! - Prompt caching now turns on for Anthropic models, and the cache counters they report reach the
|
|
31
|
+
turn's usage.
|
|
32
|
+
|
|
33
|
+
For a model id that starts with `anthropic/` or `claude` (after an optional `openrouter/`,
|
|
34
|
+
`vertex/` or `bedrock/` prefix),
|
|
35
|
+
the agent loop sends the system prompt as text blocks: the configured prompt first, marked with
|
|
36
|
+
`cache_control: { type: "ephemeral" }`, then the `<active-memory>` block when memory adds one. The
|
|
37
|
+
Anthropic client sends the blocks as they are, and the OpenRouter client sends them as `content`
|
|
38
|
+
parts of the `system` message, with `cache_control` on the cacheable part. Every other provider
|
|
39
|
+
still receives one string. Bedrock ids (`anthropic.claude-…`) are not matched,
|
|
40
|
+
and their bodies do not change. Vertex Anthropic ids (`vertex/anthropic/claude-…`) are matched
|
|
41
|
+
and get the same blocks; no live Vertex response was measured for this change.
|
|
42
|
+
|
|
43
|
+
Things a caller can observe:
|
|
44
|
+
|
|
45
|
+
- **Billing.** Anthropic charges cache writes at 1.25 times the input price and cache reads at 0.1
|
|
46
|
+
times. A run with a single turn whose system prompt is above the model's caching minimum pays
|
|
47
|
+
the write premium and never reads the prefix back.
|
|
48
|
+
- **Order.** For these models the memory block now comes after the configured prompt instead of
|
|
49
|
+
before it. On a client that joins the blocks into one string, the text is the same and the order
|
|
50
|
+
is reversed.
|
|
51
|
+
- **What still misses the cache.** The cached prefix is the whole assembled prompt, so `<memory>`
|
|
52
|
+
facts, resolved skills or context that change between turns change block 1 and miss.
|
|
53
|
+
- **Counters.** The Anthropic streaming client reads `cache_read_input_tokens` and
|
|
54
|
+
`cache_creation_input_tokens` from `message_start`, where Anthropic reports them; a value in
|
|
55
|
+
`message_delta` still wins when it is above zero, and a zero there leaves the `message_start`
|
|
56
|
+
value in place. The non-streaming parser shared by the Bedrock and Vertex Anthropic clients now
|
|
57
|
+
returns both counters too.
|
|
58
|
+
- **Cost on the chat-completions client.** `prompt_tokens` there already includes the cached
|
|
59
|
+
slice, and the client used to report it whole as `inputTokens` beside `cacheReadTokens`, so the
|
|
60
|
+
estimated cost charged every cached token twice (about 8 times too high on a cached
|
|
61
|
+
OpenRouter Anthropic turn). `inputTokens` is now the uncached portion, as on the Anthropic
|
|
62
|
+
client, and `prompt_tokens_details.cache_write_tokens` is read into `cacheWriteTokens`. A
|
|
63
|
+
native OpenAI chat-completions run with a cache hit reports a lower `inputTokens` and a lower
|
|
64
|
+
cost than before. When a usage object carries both the nested `prompt_tokens_details` counts and the
|
|
65
|
+
Anthropic-style top-level ones, the nested count wins and a top-level count fills a nested
|
|
66
|
+
zero, the rule `normalizeUsage` already applied; the stream client used to let the top-level
|
|
67
|
+
field win.
|
|
68
|
+
- **Budget trackers.** A `BudgetTracker`'s `input` event now carries the whole prompt:
|
|
69
|
+
`inputTokens` plus `cacheReadTokens` and `cacheWriteTokens`. On the chat-completions client this
|
|
70
|
+
keeps the count a tracker saw before `inputTokens` became the uncached portion. On the Anthropic
|
|
71
|
+
clients, which always reported the uncached portion, a cached turn now counts its cached tokens
|
|
72
|
+
against `maxTokens`, and `createUsdBudgetTracker` prices them at the input rate, so a cost cap
|
|
73
|
+
trips earlier than the provider's bill would.
|
|
74
|
+
- **Input tokens on the Anthropic stream.** `input_tokens` is read from `message_start` too, so a
|
|
75
|
+
stream whose `message_delta` carries only `output_tokens` reports its uncached input instead of
|
|
76
|
+
none. A value above zero in `message_delta` still replaces it; a `null` or a zero there leaves
|
|
77
|
+
the `message_start` count.
|
|
78
|
+
- **Malformed Anthropic frames.** A `content_block_start`, `content_block_delta` or
|
|
79
|
+
`message_delta` frame that is not valid JSON now fails the turn with a retryable `NetworkError`
|
|
80
|
+
(`code: "stream_malformed_frame"`) instead of being skipped, which finished the turn with text
|
|
81
|
+
or tool input missing. Any other malformed frame is still skipped and reported on the
|
|
82
|
+
diagnostics channel. The error message and the diagnostic line name the event and the frame's
|
|
83
|
+
length, never its body, which can hold model output or tool input.
|
|
84
|
+
|
|
3
85
|
## 5.10.0
|
|
4
86
|
|
|
5
87
|
### Minor Changes
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { Agent } from './chunk-
|
|
1
|
+
export { Agent } from './chunk-MHIBYKWA.js';
|
|
2
2
|
import './chunk-XKMVJ443.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-Q34EBNYG.js';
|
|
4
4
|
import './chunk-K2BQQ445.js';
|
|
5
5
|
import './chunk-DPY2M74T.js';
|
|
6
6
|
import './chunk-ZHWKT2NI.js';
|
|
7
7
|
import './chunk-2SFBB54R.js';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-U27XHOEF.js';
|
|
9
9
|
import './chunk-H73MEMQB.js';
|
|
10
10
|
import './chunk-OR6XIWLB.js';
|
|
11
11
|
import './chunk-X3LOJJMO.js';
|
|
12
12
|
import './chunk-IZDDSLL2.js';
|
|
13
|
-
import './chunk-
|
|
13
|
+
import './chunk-BBJ77S62.js';
|
|
14
14
|
import './chunk-SUVCHX4L.js';
|
|
15
15
|
import './chunk-2XC6KDJM.js';
|
|
16
|
-
import './chunk-
|
|
16
|
+
import './chunk-JLIRFWUG.js';
|
|
17
17
|
import './chunk-24MGQDK3.js';
|
|
18
18
|
import './chunk-XERM7PDQ.js';
|
|
19
19
|
import './chunk-HKCKOAIO.js';
|
|
@@ -47,6 +47,7 @@ import './chunk-ZDYDBXSD.js';
|
|
|
47
47
|
import './chunk-X7EUUHXU.js';
|
|
48
48
|
import './chunk-MQGSOKR3.js';
|
|
49
49
|
import './chunk-GMRFAX4I.js';
|
|
50
|
+
import './chunk-LZJXEPEQ.js';
|
|
50
51
|
import './chunk-R7WIIPUR.js';
|
|
51
52
|
import './chunk-I2ORT6QD.js';
|
|
52
53
|
import './chunk-SVCPJRUB.js';
|
|
@@ -57,5 +58,5 @@ import './chunk-H3CVJSFC.js';
|
|
|
57
58
|
import './chunk-Q7GYMXVC.js';
|
|
58
59
|
import './chunk-B5MHRQJZ.js';
|
|
59
60
|
import './chunk-CZJ6Q7CW.js';
|
|
60
|
-
//# sourceMappingURL=agent-
|
|
61
|
-
//# sourceMappingURL=agent-
|
|
61
|
+
//# sourceMappingURL=agent-DFV52V6E.js.map
|
|
62
|
+
//# sourceMappingURL=agent-DFV52V6E.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"agent-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"agent-DFV52V6E.js"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk35KBC4BX_cjs = require('./chunk-35KBC4BX.cjs');
|
|
4
4
|
require('./chunk-J6GXS5A2.cjs');
|
|
5
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-3JANYJYS.cjs');
|
|
6
6
|
require('./chunk-BUUUWQMB.cjs');
|
|
7
7
|
require('./chunk-L3C6CCBG.cjs');
|
|
8
8
|
require('./chunk-KIKKTW5O.cjs');
|
|
9
9
|
require('./chunk-BV2MWEMV.cjs');
|
|
10
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-JV7JA7BM.cjs');
|
|
11
11
|
require('./chunk-GHX4P3V2.cjs');
|
|
12
12
|
require('./chunk-TMKTSYDS.cjs');
|
|
13
13
|
require('./chunk-ZD66GFH5.cjs');
|
|
14
14
|
require('./chunk-NQVWSSX2.cjs');
|
|
15
|
-
require('./chunk-
|
|
15
|
+
require('./chunk-P5N3Q2NH.cjs');
|
|
16
16
|
require('./chunk-CQYBJOB2.cjs');
|
|
17
17
|
require('./chunk-YJNYDJ2T.cjs');
|
|
18
|
-
require('./chunk-
|
|
18
|
+
require('./chunk-N7KS3TIR.cjs');
|
|
19
19
|
require('./chunk-QOGNZMHD.cjs');
|
|
20
20
|
require('./chunk-ZAM7BJXJ.cjs');
|
|
21
21
|
require('./chunk-2ZPEDVLM.cjs');
|
|
@@ -49,6 +49,7 @@ require('./chunk-C7GKRGKN.cjs');
|
|
|
49
49
|
require('./chunk-TY56BKSK.cjs');
|
|
50
50
|
require('./chunk-MPR2ISL2.cjs');
|
|
51
51
|
require('./chunk-J5623RIV.cjs');
|
|
52
|
+
require('./chunk-NWS2CS3Y.cjs');
|
|
52
53
|
require('./chunk-3EE6LVWT.cjs');
|
|
53
54
|
require('./chunk-SGC7LSHF.cjs');
|
|
54
55
|
require('./chunk-HU666T3Q.cjs');
|
|
@@ -64,7 +65,7 @@ require('./chunk-6LHQPOMI.cjs');
|
|
|
64
65
|
|
|
65
66
|
Object.defineProperty(exports, "Agent", {
|
|
66
67
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunk35KBC4BX_cjs.Agent; }
|
|
68
69
|
});
|
|
69
|
-
//# sourceMappingURL=agent-
|
|
70
|
-
//# sourceMappingURL=agent-
|
|
70
|
+
//# sourceMappingURL=agent-OKP4LHG2.cjs.map
|
|
71
|
+
//# sourceMappingURL=agent-OKP4LHG2.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"agent-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"agent-OKP4LHG2.cjs"}
|