@theokit/sdk 2.6.0 → 2.8.0
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 +22 -0
- package/dist/a2a/index.cjs +90 -10
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +90 -10
- package/dist/a2a/index.js.map +1 -1
- package/dist/compaction.cjs +213 -16
- package/dist/compaction.cjs.map +1 -1
- package/dist/compaction.d.cts +63 -19
- package/dist/compaction.d.ts +63 -19
- package/dist/compaction.js +213 -17
- package/dist/compaction.js.map +1 -1
- package/dist/{cron-B656C3iq.d.cts → cron-Bhp8rP8i.d.ts} +19 -1
- package/dist/{cron-CM2M9mhB.d.ts → cron-CRPY-aKq.d.cts} +19 -1
- package/dist/cron.cjs +90 -10
- 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 +90 -10
- package/dist/cron.js.map +1 -1
- package/dist/{errors-DG_7CAUg.d.ts → errors-C8EVGqje.d.ts} +1 -1
- package/dist/{errors-QDYUPABr.d.cts → errors-FKoM44Mj.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +90 -10
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +90 -10
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +90 -10
- 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 +90 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/lifecycle/stream-to-completion.d.ts +31 -0
- package/dist/{run-BPRYG1Id.d.cts → run-D22b53SU.d.cts} +11 -2
- package/dist/{run-BPRYG1Id.d.ts → run-D22b53SU.d.ts} +11 -2
- package/dist/types/agent.d.ts +18 -0
- package/dist/types/run.d.ts +10 -1
- package/package.json +14 -14
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `streamToCompletion` — the STREAMING continuation driver (V3-4, plan
|
|
3
|
+
* v34-stream-to-completion). The streaming twin of `runToCompletion`: it yields
|
|
4
|
+
* each round's `SDKMessage`s LIVE (the V3-4 (a) gap a UI needs) while reusing the
|
|
5
|
+
* SAME terminal policy as the M1 driver — `classifyRound` (done / step_limit /
|
|
6
|
+
* no_progress) + bounded re-prompt + `addUsage` aggregation. It is NOT a second
|
|
7
|
+
* policy (D1): the only difference from `runToCompletion` is surfacing events over
|
|
8
|
+
* `Run.stream()` instead of returning only the final `Run.wait()` result.
|
|
9
|
+
*
|
|
10
|
+
* Stateful, like `runToCompletion` (the agent's session preserves history; the
|
|
11
|
+
* continuation prompt is short). The STATELESS path stays `buildReplayHistory`
|
|
12
|
+
* (D2) — a consumer reconstructs history into a fresh session, then drives this.
|
|
13
|
+
*
|
|
14
|
+
* The `StreamToCompletionResult` is the generator's RETURN value, read via a
|
|
15
|
+
* manual `gen.next()` loop (`while (!res.done) res = await gen.next()` → `res.value`).
|
|
16
|
+
* A plain `for await...of` consumes the yielded messages but discards the return
|
|
17
|
+
* value (EC-1) — see docs.md.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
import type { RunResult, SendOptions } from "../../../types/run.js";
|
|
22
|
+
/** One streamed round handle: drain `stream()` (live events) then `wait()` (terminal result). */
|
|
23
|
+
interface StreamRun {
|
|
24
|
+
stream(): AsyncGenerator<SDKMessage, void>;
|
|
25
|
+
wait(): Promise<RunResult>;
|
|
26
|
+
}
|
|
27
|
+
/** Minimal agent port the streaming driver needs — the instance `.send()` surface. */
|
|
28
|
+
export interface StreamToCompletionAgent {
|
|
29
|
+
send(message: string, options?: SendOptions): Promise<StreamRun>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -625,7 +625,7 @@ type RunStatus = "running" | "finished" | "error" | "cancelled";
|
|
|
625
625
|
*
|
|
626
626
|
* @public
|
|
627
627
|
*/
|
|
628
|
-
type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
628
|
+
type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "streamToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
629
629
|
/**
|
|
630
630
|
* Git metadata attached to cloud runs.
|
|
631
631
|
*
|
|
@@ -741,6 +741,15 @@ interface RunToCompletionResult {
|
|
|
741
741
|
/** Token usage summed across all rounds; `undefined` when no round reported usage. */
|
|
742
742
|
usage?: TokenUsage;
|
|
743
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* Result of {@link SDKAgent.streamToCompletion} (V3-4 — the STREAMING continuation
|
|
746
|
+
* driver). Same shape + terminal semantics as {@link RunToCompletionResult}; it is
|
|
747
|
+
* the generator's RETURN value (read it via a manual `gen.next()` loop — a plain
|
|
748
|
+
* `for await...of` consumes the yielded `SDKMessage`s but discards this return value).
|
|
749
|
+
*
|
|
750
|
+
* @public
|
|
751
|
+
*/
|
|
752
|
+
type StreamToCompletionResult = RunToCompletionResult;
|
|
744
753
|
/**
|
|
745
754
|
* Structured error attached to a {@link RunResult} when the underlying run
|
|
746
755
|
* transitioned to `"error"` status. `message` is always present; `code` is
|
|
@@ -893,4 +902,4 @@ interface Run {
|
|
|
893
902
|
onDidChangeStatus(listener: (status: RunStatus) => void): () => void;
|
|
894
903
|
}
|
|
895
904
|
|
|
896
|
-
export type {
|
|
905
|
+
export type { ThinkingMessage as $, AgentConversationTurn as A, SDKTaskMessage as B, CustomTool as C, SDKThinkingMessage as D, SDKToolUseMessage as E, SDKUserMessage as F, SDKUserMessageEvent as G, SendOptions as H, InteractionUpdate as I, ShellCommand as J, ShellConversationTurn as K, ShellOutput as L, ModelSelection as M, ShellOutputDeltaUpdate as N, StepCompletedUpdate as O, PartialToolCallUpdate as P, StepStartedUpdate as Q, RunResult as R, SDKMessage as S, StreamToCompletionResult as T, SummaryCompletedUpdate as U, SummaryStartedUpdate as V, SummaryUpdate as W, TextBlock as X, TextDeltaUpdate as Y, ThinkingCompletedUpdate as Z, ThinkingDeltaUpdate as _, McpServerConfig as a, TokenDeltaUpdate as a0, TokenUsage as a1, ToolCall as a2, ToolCallCompletedUpdate as a3, ToolCallStartedUpdate as a4, ToolResult as a5, ToolUseBlock as a6, TurnEndedUpdate as a7, UserMessage as a8, UserMessageAppendedUpdate as a9, Run as b, AssistantMessage as c, ConversationStep as d, ConversationTurn as e, CostBreakdown as f, CostSource as g, CostStatus as h, McpAuthConfig as i, McpHttpServerConfig as j, McpOAuthConfig as k, McpStdioServerConfig as l, ModelParameterValue as m, RunErrorDetail as n, RunGitInfo as o, RunOperation as p, RunStatus as q, RunToCompletionOptions as r, RunToCompletionResult as s, SDKAssistantMessage as t, SDKImage as u, SDKImageDimension as v, SDKObjectDelta as w, SDKRequestMessage as x, SDKStatusMessage as y, SDKSystemMessage as z };
|
|
@@ -625,7 +625,7 @@ type RunStatus = "running" | "finished" | "error" | "cancelled";
|
|
|
625
625
|
*
|
|
626
626
|
* @public
|
|
627
627
|
*/
|
|
628
|
-
type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
628
|
+
type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "streamToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
629
629
|
/**
|
|
630
630
|
* Git metadata attached to cloud runs.
|
|
631
631
|
*
|
|
@@ -741,6 +741,15 @@ interface RunToCompletionResult {
|
|
|
741
741
|
/** Token usage summed across all rounds; `undefined` when no round reported usage. */
|
|
742
742
|
usage?: TokenUsage;
|
|
743
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* Result of {@link SDKAgent.streamToCompletion} (V3-4 — the STREAMING continuation
|
|
746
|
+
* driver). Same shape + terminal semantics as {@link RunToCompletionResult}; it is
|
|
747
|
+
* the generator's RETURN value (read it via a manual `gen.next()` loop — a plain
|
|
748
|
+
* `for await...of` consumes the yielded `SDKMessage`s but discards this return value).
|
|
749
|
+
*
|
|
750
|
+
* @public
|
|
751
|
+
*/
|
|
752
|
+
type StreamToCompletionResult = RunToCompletionResult;
|
|
744
753
|
/**
|
|
745
754
|
* Structured error attached to a {@link RunResult} when the underlying run
|
|
746
755
|
* transitioned to `"error"` status. `message` is always present; `code` is
|
|
@@ -893,4 +902,4 @@ interface Run {
|
|
|
893
902
|
onDidChangeStatus(listener: (status: RunStatus) => void): () => void;
|
|
894
903
|
}
|
|
895
904
|
|
|
896
|
-
export type {
|
|
905
|
+
export type { ThinkingMessage as $, AgentConversationTurn as A, SDKTaskMessage as B, CustomTool as C, SDKThinkingMessage as D, SDKToolUseMessage as E, SDKUserMessage as F, SDKUserMessageEvent as G, SendOptions as H, InteractionUpdate as I, ShellCommand as J, ShellConversationTurn as K, ShellOutput as L, ModelSelection as M, ShellOutputDeltaUpdate as N, StepCompletedUpdate as O, PartialToolCallUpdate as P, StepStartedUpdate as Q, RunResult as R, SDKMessage as S, StreamToCompletionResult as T, SummaryCompletedUpdate as U, SummaryStartedUpdate as V, SummaryUpdate as W, TextBlock as X, TextDeltaUpdate as Y, ThinkingCompletedUpdate as Z, ThinkingDeltaUpdate as _, McpServerConfig as a, TokenDeltaUpdate as a0, TokenUsage as a1, ToolCall as a2, ToolCallCompletedUpdate as a3, ToolCallStartedUpdate as a4, ToolResult as a5, ToolUseBlock as a6, TurnEndedUpdate as a7, UserMessage as a8, UserMessageAppendedUpdate as a9, Run as b, AssistantMessage as c, ConversationStep as d, ConversationTurn as e, CostBreakdown as f, CostSource as g, CostStatus as h, McpAuthConfig as i, McpHttpServerConfig as j, McpOAuthConfig as k, McpStdioServerConfig as l, ModelParameterValue as m, RunErrorDetail as n, RunGitInfo as o, RunOperation as p, RunStatus as q, RunToCompletionOptions as r, RunToCompletionResult as s, SDKAssistantMessage as t, SDKImage as u, SDKImageDimension as v, SDKObjectDelta as w, SDKRequestMessage as x, SDKStatusMessage as y, SDKSystemMessage as z };
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -630,6 +630,24 @@ export interface SDKAgent {
|
|
|
630
630
|
* @public
|
|
631
631
|
*/
|
|
632
632
|
runToCompletion?(message: string, options?: import("./run.js").RunToCompletionOptions): Promise<import("./run.js").RunToCompletionResult>;
|
|
633
|
+
/**
|
|
634
|
+
* STREAMING continuation driver (V3-4) — the streaming twin of
|
|
635
|
+
* {@link SDKAgent.runToCompletion}. Returns an `AsyncGenerator` that yields each
|
|
636
|
+
* round's {@link import("./messages.js").SDKMessage}s LIVE (for a UI), reusing the
|
|
637
|
+
* same terminal policy (`done`/`step_limit`/`no_progress` + bounded re-prompt).
|
|
638
|
+
*
|
|
639
|
+
* The {@link import("./run.js").StreamToCompletionResult} is the generator's RETURN
|
|
640
|
+
* value — read it via a manual `gen.next()` loop (`while (!res.done) res = await
|
|
641
|
+
* gen.next()` → `res.value`); a plain `for await...of` consumes the yielded
|
|
642
|
+
* messages but discards the return value. For the STATELESS path, reconstruct
|
|
643
|
+
* history with `buildReplayHistory` into a fresh session first.
|
|
644
|
+
*
|
|
645
|
+
* Local agents only. Cloud agents throw
|
|
646
|
+
* {@link import("../errors.js").UnsupportedRunOperationError}.
|
|
647
|
+
*
|
|
648
|
+
* @public
|
|
649
|
+
*/
|
|
650
|
+
streamToCompletion?(message: string, options?: import("./run.js").RunToCompletionOptions): AsyncGenerator<import("./messages.js").SDKMessage, import("./run.js").StreamToCompletionResult>;
|
|
633
651
|
/**
|
|
634
652
|
* Direct API to third-party memory adapter(s) registered via
|
|
635
653
|
* `plugins: [...]` (ADR D141 / D142). Returns `null` when no adapter
|
package/dist/types/run.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type RunStatus = "running" | "finished" | "error" | "cancelled";
|
|
|
19
19
|
*
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
|
-
export type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
22
|
+
export type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "streamToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
23
23
|
/**
|
|
24
24
|
* Git metadata attached to cloud runs.
|
|
25
25
|
*
|
|
@@ -135,6 +135,15 @@ export interface RunToCompletionResult {
|
|
|
135
135
|
/** Token usage summed across all rounds; `undefined` when no round reported usage. */
|
|
136
136
|
usage?: TokenUsage;
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Result of {@link SDKAgent.streamToCompletion} (V3-4 — the STREAMING continuation
|
|
140
|
+
* driver). Same shape + terminal semantics as {@link RunToCompletionResult}; it is
|
|
141
|
+
* the generator's RETURN value (read it via a manual `gen.next()` loop — a plain
|
|
142
|
+
* `for await...of` consumes the yielded `SDKMessage`s but discards this return value).
|
|
143
|
+
*
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
export type StreamToCompletionResult = RunToCompletionResult;
|
|
138
147
|
/**
|
|
139
148
|
* Structured error attached to a {@link RunResult} when the underlying run
|
|
140
149
|
* transitioned to `"error"` status. `message` is always present; `code` is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
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,6 +298,15 @@
|
|
|
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
|
+
},
|
|
301
310
|
"peerDependencies": {
|
|
302
311
|
"@lancedb/lancedb": "^0.30.0",
|
|
303
312
|
"@types/ws": ">=8.0.0",
|
|
@@ -354,6 +363,8 @@
|
|
|
354
363
|
"devDependencies": {
|
|
355
364
|
"@opentelemetry/api": "^1.9.1",
|
|
356
365
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
366
|
+
"@theokit/sdk-handoff": "workspace:*",
|
|
367
|
+
"@theokit/sdk-memory": "workspace:*",
|
|
357
368
|
"@types/better-sqlite3": "^7.6.13",
|
|
358
369
|
"@types/proper-lockfile": "^4.1.4",
|
|
359
370
|
"@types/ws": "^8.18.0",
|
|
@@ -363,17 +374,6 @@
|
|
|
363
374
|
"sqlite-vec": "^0.1.9",
|
|
364
375
|
"typedoc": "^0.28.19",
|
|
365
376
|
"ws": "^8.18.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"
|
|
377
|
+
"zod": "^4.0.0"
|
|
378
378
|
}
|
|
379
|
-
}
|
|
379
|
+
}
|