@theokit/sdk 2.1.0 → 2.3.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 +35 -0
- package/dist/a2a/index.cjs +117 -3
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +117 -3
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-Da6vF_2y.d.ts → cron-B_H8rn-j.d.cts} +28 -2
- package/dist/{cron-CSTqNZp9.d.cts → cron-DX6HbHxd.d.ts} +28 -2
- package/dist/cron.cjs +119 -3
- 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 +119 -3
- package/dist/cron.js.map +1 -1
- package/dist/{errors--VP2qrGc.d.ts → errors-DG_7CAUg.d.ts} +1 -1
- package/dist/{errors-C9xkhNEF.d.cts → errors-QDYUPABr.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +119 -3
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +119 -3
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +202 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -7
- package/dist/index.d.ts +50 -7
- package/dist/index.js +202 -15
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/loop-types.d.ts +6 -0
- package/dist/internal/runtime/budget/budget-tracker.d.ts +8 -0
- package/dist/internal/runtime/lifecycle/run-to-completion.d.ts +22 -0
- package/dist/{run-DrwUpFxZ.d.cts → run-BPRYG1Id.d.cts} +75 -2
- package/dist/{run-DrwUpFxZ.d.ts → run-BPRYG1Id.d.ts} +75 -2
- package/dist/types/agent.d.ts +14 -0
- package/dist/types/conversation-storage.d.ts +5 -1
- package/dist/types/run.d.ts +74 -1
- package/package.json +3 -3
|
@@ -26,4 +26,10 @@ export interface AgentLoopOutput {
|
|
|
26
26
|
* message (the previous bug — sdk-error-packaging-fix-plan).
|
|
27
27
|
*/
|
|
28
28
|
error?: AgentLoopErrorDetail;
|
|
29
|
+
/**
|
|
30
|
+
* M1-2 (T2.2): true when the loop stopped at its iteration ceiling with the
|
|
31
|
+
* model still wanting to call tools (silent truncation). Copied verbatim onto
|
|
32
|
+
* `RunResult.stoppedAtIterationLimit`.
|
|
33
|
+
*/
|
|
34
|
+
stoppedAtIterationLimit?: boolean;
|
|
29
35
|
}
|
|
@@ -70,4 +70,12 @@ export interface BudgetTracker {
|
|
|
70
70
|
check(): BudgetCheck;
|
|
71
71
|
/** Snapshot of accumulated totals (for telemetry / final reporting). */
|
|
72
72
|
getTotal(): BudgetTotal;
|
|
73
|
+
/**
|
|
74
|
+
* Advance the iteration counter by one. Called by the agent loop ONCE per
|
|
75
|
+
* completed turn (M1-1) so that trackers which gate on `maxIterations`
|
|
76
|
+
* (e.g. `createCounterBudgetTracker`) actually halt. OPTIONAL: trackers that
|
|
77
|
+
* only gate on tokens/USD omit it and the loop no-ops via optional chaining.
|
|
78
|
+
* MUST be synchronous and non-throwing.
|
|
79
|
+
*/
|
|
80
|
+
nextIteration?(): void;
|
|
73
81
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `runToCompletion` continuation driver (M1 Phase 3 — plan m1-run-to-completion).
|
|
3
|
+
*
|
|
4
|
+
* Drives repeated `send()`s on a STATEFUL agent until a genuine terminal,
|
|
5
|
+
* consuming the `RunResult.stoppedAtIterationLimit` signal shipped in 2.2.0.
|
|
6
|
+
* The agent's session preserves conversation history across sends, so after a
|
|
7
|
+
* truncated round the driver only re-sends a short continuation prompt (it does
|
|
8
|
+
* NOT reconstruct history). Mirrors the injectable shape of `run-until.ts` and
|
|
9
|
+
* absorbs the outer-loop policy hand-rolled in `theocode/server/lib/agent-loop.ts`.
|
|
10
|
+
*
|
|
11
|
+
* The core is decision-pure + injectable (`agent` is only the `.send` port) so
|
|
12
|
+
* every terminal is unit-testable with a fake send — fixture mode never sets
|
|
13
|
+
* `stoppedAtIterationLimit`, so injection is the only deterministic path.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
/** Minimal agent port the driver needs — the instance `.send()` surface. */
|
|
18
|
+
export interface RunToCompletionAgent {
|
|
19
|
+
send(message: string, options?: SendOptions): Promise<{
|
|
20
|
+
wait(): Promise<RunResult>;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
@@ -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" | "fork" | "usePersonality" | "workflow";
|
|
628
|
+
type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
629
629
|
/**
|
|
630
630
|
* Git metadata attached to cloud runs.
|
|
631
631
|
*
|
|
@@ -677,6 +677,69 @@ interface RunResult {
|
|
|
677
677
|
* @public
|
|
678
678
|
*/
|
|
679
679
|
cost?: CostBreakdown;
|
|
680
|
+
/**
|
|
681
|
+
* M1-2: `true` when the run stopped because the agent loop hit its iteration
|
|
682
|
+
* ceiling (`SendOptions.maxIterations` or the default of 8) while the model
|
|
683
|
+
* still wanted to call tools — i.e. the work was silently truncated rather
|
|
684
|
+
* than finished. `undefined`/absent on a clean finish. A continuation driver
|
|
685
|
+
* (or a careful caller) inspects this to decide whether to send again.
|
|
686
|
+
*
|
|
687
|
+
* @public
|
|
688
|
+
*/
|
|
689
|
+
stoppedAtIterationLimit?: boolean;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Options for {@link SDKAgent.runToCompletion} (M1 Phase 3 — continuation driver).
|
|
693
|
+
*
|
|
694
|
+
* @public
|
|
695
|
+
*/
|
|
696
|
+
interface RunToCompletionOptions {
|
|
697
|
+
/**
|
|
698
|
+
* Maximum number of continuation rounds (re-sends) before giving up with
|
|
699
|
+
* `terminal: "step_limit"`. Default 5. A hard ceiling that prevents a
|
|
700
|
+
* runaway loop when the model keeps truncating.
|
|
701
|
+
*/
|
|
702
|
+
maxRounds?: number;
|
|
703
|
+
/**
|
|
704
|
+
* The short prompt re-sent after a truncated round to make the (stateful)
|
|
705
|
+
* agent resume. Defaults to a generic "continue" instruction. The original
|
|
706
|
+
* conversation is preserved by the agent's session, so this need not repeat
|
|
707
|
+
* the task.
|
|
708
|
+
*/
|
|
709
|
+
continuationPrompt?: string;
|
|
710
|
+
/** Called once per truncated round that triggers a re-send (for metrics/logging). */
|
|
711
|
+
onTruncated?: (event: {
|
|
712
|
+
round: number;
|
|
713
|
+
}) => void | Promise<void>;
|
|
714
|
+
/** Abort signal; checked between rounds — once aborted, no further round starts. */
|
|
715
|
+
signal?: AbortSignal;
|
|
716
|
+
/** Per-send options forwarded to each underlying `send()` (e.g. `maxIterations`). */
|
|
717
|
+
sendOptions?: SendOptions;
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Result of {@link SDKAgent.runToCompletion}.
|
|
721
|
+
*
|
|
722
|
+
* @public
|
|
723
|
+
*/
|
|
724
|
+
interface RunToCompletionResult {
|
|
725
|
+
/**
|
|
726
|
+
* Why the driver stopped:
|
|
727
|
+
* - `"done"` — a round finished without truncating (the model is done).
|
|
728
|
+
* - `"step_limit"` — `maxRounds` exhausted (or aborted) while still truncating.
|
|
729
|
+
* - `"no_progress"` — two consecutive rounds produced empty output.
|
|
730
|
+
*/
|
|
731
|
+
terminal: "done" | "step_limit" | "no_progress";
|
|
732
|
+
/**
|
|
733
|
+
* Index of the final round. Round 0 is the initial `send`; rounds ≥ 1 are
|
|
734
|
+
* continuation re-sends. So `terminal: "done"` with `rounds: 0` means the
|
|
735
|
+
* first send finished without truncating; `rounds: N` means N continuation
|
|
736
|
+
* re-sends happened. For `step_limit`, `rounds` equals `maxRounds`.
|
|
737
|
+
*/
|
|
738
|
+
rounds: number;
|
|
739
|
+
/** The `RunResult` of the final round. */
|
|
740
|
+
lastResult: RunResult;
|
|
741
|
+
/** Token usage summed across all rounds; `undefined` when no round reported usage. */
|
|
742
|
+
usage?: TokenUsage;
|
|
680
743
|
}
|
|
681
744
|
/**
|
|
682
745
|
* Structured error attached to a {@link RunResult} when the underlying run
|
|
@@ -789,6 +852,16 @@ interface SendOptions {
|
|
|
789
852
|
id?: string;
|
|
790
853
|
meta?: Record<string, unknown>;
|
|
791
854
|
};
|
|
855
|
+
/**
|
|
856
|
+
* Per-send ceiling on the agent loop's tool-calling turns (M1-2). Raises (or
|
|
857
|
+
* lowers) the default cap of 8 for this single send — useful when one heavy
|
|
858
|
+
* task needs more rounds than the agent's default. Must be a positive
|
|
859
|
+
* integer; invalid values throw `ConfigurationError` at the boundary. When
|
|
860
|
+
* unset, the loop uses the default of 8.
|
|
861
|
+
*
|
|
862
|
+
* @public
|
|
863
|
+
*/
|
|
864
|
+
maxIterations?: number;
|
|
792
865
|
}
|
|
793
866
|
/**
|
|
794
867
|
* Handle to a single prompt submission.
|
|
@@ -820,4 +893,4 @@ interface Run {
|
|
|
820
893
|
onDidChangeStatus(listener: (status: RunStatus) => void): () => void;
|
|
821
894
|
}
|
|
822
895
|
|
|
823
|
-
export type {
|
|
896
|
+
export type { TokenDeltaUpdate 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, SummaryCompletedUpdate as T, SummaryStartedUpdate as U, SummaryUpdate as V, TextBlock as W, TextDeltaUpdate as X, ThinkingCompletedUpdate as Y, ThinkingDeltaUpdate as Z, ThinkingMessage as _, McpServerConfig as a, TokenUsage as a0, ToolCall as a1, ToolCallCompletedUpdate as a2, ToolCallStartedUpdate as a3, ToolResult as a4, ToolUseBlock as a5, TurnEndedUpdate as a6, UserMessage as a7, UserMessageAppendedUpdate as a8, 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" | "fork" | "usePersonality" | "workflow";
|
|
628
|
+
type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
629
629
|
/**
|
|
630
630
|
* Git metadata attached to cloud runs.
|
|
631
631
|
*
|
|
@@ -677,6 +677,69 @@ interface RunResult {
|
|
|
677
677
|
* @public
|
|
678
678
|
*/
|
|
679
679
|
cost?: CostBreakdown;
|
|
680
|
+
/**
|
|
681
|
+
* M1-2: `true` when the run stopped because the agent loop hit its iteration
|
|
682
|
+
* ceiling (`SendOptions.maxIterations` or the default of 8) while the model
|
|
683
|
+
* still wanted to call tools — i.e. the work was silently truncated rather
|
|
684
|
+
* than finished. `undefined`/absent on a clean finish. A continuation driver
|
|
685
|
+
* (or a careful caller) inspects this to decide whether to send again.
|
|
686
|
+
*
|
|
687
|
+
* @public
|
|
688
|
+
*/
|
|
689
|
+
stoppedAtIterationLimit?: boolean;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Options for {@link SDKAgent.runToCompletion} (M1 Phase 3 — continuation driver).
|
|
693
|
+
*
|
|
694
|
+
* @public
|
|
695
|
+
*/
|
|
696
|
+
interface RunToCompletionOptions {
|
|
697
|
+
/**
|
|
698
|
+
* Maximum number of continuation rounds (re-sends) before giving up with
|
|
699
|
+
* `terminal: "step_limit"`. Default 5. A hard ceiling that prevents a
|
|
700
|
+
* runaway loop when the model keeps truncating.
|
|
701
|
+
*/
|
|
702
|
+
maxRounds?: number;
|
|
703
|
+
/**
|
|
704
|
+
* The short prompt re-sent after a truncated round to make the (stateful)
|
|
705
|
+
* agent resume. Defaults to a generic "continue" instruction. The original
|
|
706
|
+
* conversation is preserved by the agent's session, so this need not repeat
|
|
707
|
+
* the task.
|
|
708
|
+
*/
|
|
709
|
+
continuationPrompt?: string;
|
|
710
|
+
/** Called once per truncated round that triggers a re-send (for metrics/logging). */
|
|
711
|
+
onTruncated?: (event: {
|
|
712
|
+
round: number;
|
|
713
|
+
}) => void | Promise<void>;
|
|
714
|
+
/** Abort signal; checked between rounds — once aborted, no further round starts. */
|
|
715
|
+
signal?: AbortSignal;
|
|
716
|
+
/** Per-send options forwarded to each underlying `send()` (e.g. `maxIterations`). */
|
|
717
|
+
sendOptions?: SendOptions;
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Result of {@link SDKAgent.runToCompletion}.
|
|
721
|
+
*
|
|
722
|
+
* @public
|
|
723
|
+
*/
|
|
724
|
+
interface RunToCompletionResult {
|
|
725
|
+
/**
|
|
726
|
+
* Why the driver stopped:
|
|
727
|
+
* - `"done"` — a round finished without truncating (the model is done).
|
|
728
|
+
* - `"step_limit"` — `maxRounds` exhausted (or aborted) while still truncating.
|
|
729
|
+
* - `"no_progress"` — two consecutive rounds produced empty output.
|
|
730
|
+
*/
|
|
731
|
+
terminal: "done" | "step_limit" | "no_progress";
|
|
732
|
+
/**
|
|
733
|
+
* Index of the final round. Round 0 is the initial `send`; rounds ≥ 1 are
|
|
734
|
+
* continuation re-sends. So `terminal: "done"` with `rounds: 0` means the
|
|
735
|
+
* first send finished without truncating; `rounds: N` means N continuation
|
|
736
|
+
* re-sends happened. For `step_limit`, `rounds` equals `maxRounds`.
|
|
737
|
+
*/
|
|
738
|
+
rounds: number;
|
|
739
|
+
/** The `RunResult` of the final round. */
|
|
740
|
+
lastResult: RunResult;
|
|
741
|
+
/** Token usage summed across all rounds; `undefined` when no round reported usage. */
|
|
742
|
+
usage?: TokenUsage;
|
|
680
743
|
}
|
|
681
744
|
/**
|
|
682
745
|
* Structured error attached to a {@link RunResult} when the underlying run
|
|
@@ -789,6 +852,16 @@ interface SendOptions {
|
|
|
789
852
|
id?: string;
|
|
790
853
|
meta?: Record<string, unknown>;
|
|
791
854
|
};
|
|
855
|
+
/**
|
|
856
|
+
* Per-send ceiling on the agent loop's tool-calling turns (M1-2). Raises (or
|
|
857
|
+
* lowers) the default cap of 8 for this single send — useful when one heavy
|
|
858
|
+
* task needs more rounds than the agent's default. Must be a positive
|
|
859
|
+
* integer; invalid values throw `ConfigurationError` at the boundary. When
|
|
860
|
+
* unset, the loop uses the default of 8.
|
|
861
|
+
*
|
|
862
|
+
* @public
|
|
863
|
+
*/
|
|
864
|
+
maxIterations?: number;
|
|
792
865
|
}
|
|
793
866
|
/**
|
|
794
867
|
* Handle to a single prompt submission.
|
|
@@ -820,4 +893,4 @@ interface Run {
|
|
|
820
893
|
onDidChangeStatus(listener: (status: RunStatus) => void): () => void;
|
|
821
894
|
}
|
|
822
895
|
|
|
823
|
-
export type {
|
|
896
|
+
export type { TokenDeltaUpdate 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, SummaryCompletedUpdate as T, SummaryStartedUpdate as U, SummaryUpdate as V, TextBlock as W, TextDeltaUpdate as X, ThinkingCompletedUpdate as Y, ThinkingDeltaUpdate as Z, ThinkingMessage as _, McpServerConfig as a, TokenUsage as a0, ToolCall as a1, ToolCallCompletedUpdate as a2, ToolCallStartedUpdate as a3, ToolResult as a4, ToolUseBlock as a5, TurnEndedUpdate as a6, UserMessage as a7, UserMessageAppendedUpdate as a8, 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
|
@@ -608,6 +608,20 @@ export interface SDKAgent {
|
|
|
608
608
|
* @public
|
|
609
609
|
*/
|
|
610
610
|
fork?(options: import("./fork.js").ForkOptions): Promise<import("./fork.js").ForkResult>;
|
|
611
|
+
/**
|
|
612
|
+
* Drive `send` to completion across iteration-ceiling truncations (M1 Phase 3).
|
|
613
|
+
* When a `send` stops at the loop's iteration cap (`RunResult.stoppedAtIterationLimit`),
|
|
614
|
+
* this re-sends a short continuation prompt — the agent's stateful session
|
|
615
|
+
* preserves the conversation — until a genuine terminal: `done` (finished),
|
|
616
|
+
* `step_limit` (`maxRounds` exhausted), or `no_progress` (two empty rounds).
|
|
617
|
+
*
|
|
618
|
+
* Local agents only. Cloud agents throw
|
|
619
|
+
* {@link import("../errors.js").UnsupportedRunOperationError} (the cloud
|
|
620
|
+
* runtime manages its own continuation policy server-side).
|
|
621
|
+
*
|
|
622
|
+
* @public
|
|
623
|
+
*/
|
|
624
|
+
runToCompletion?(message: string, options?: import("./run.js").RunToCompletionOptions): Promise<import("./run.js").RunToCompletionResult>;
|
|
611
625
|
/**
|
|
612
626
|
* Direct API to third-party memory adapter(s) registered via
|
|
613
627
|
* `plugins: [...]` (ADR D141 / D142). Returns `null` when no adapter
|
|
@@ -20,7 +20,11 @@
|
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
22
|
export interface StoredMessage {
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Origin of the message. `tool_call` / `tool_result` are produced by
|
|
25
|
+
* `buildReplayHistory` (M1-3) for stateless replay; a consumer feeding a
|
|
26
|
+
* `user`/`assistant`-only wire-mapper must map those two roles itself.
|
|
27
|
+
*/
|
|
24
28
|
role: "user" | "assistant" | "system" | "tool_call" | "tool_result";
|
|
25
29
|
/** UTF-8 payload. May be empty string (e.g., a tool with no return value). */
|
|
26
30
|
content: string;
|
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" | "fork" | "usePersonality" | "workflow";
|
|
22
|
+
export type RunOperation = "stream" | "wait" | "cancel" | "conversation" | "listArtifacts" | "downloadArtifact" | "runUntil" | "runToCompletion" | "fork" | "usePersonality" | "workflow";
|
|
23
23
|
/**
|
|
24
24
|
* Git metadata attached to cloud runs.
|
|
25
25
|
*
|
|
@@ -71,6 +71,69 @@ export interface RunResult {
|
|
|
71
71
|
* @public
|
|
72
72
|
*/
|
|
73
73
|
cost?: CostBreakdown;
|
|
74
|
+
/**
|
|
75
|
+
* M1-2: `true` when the run stopped because the agent loop hit its iteration
|
|
76
|
+
* ceiling (`SendOptions.maxIterations` or the default of 8) while the model
|
|
77
|
+
* still wanted to call tools — i.e. the work was silently truncated rather
|
|
78
|
+
* than finished. `undefined`/absent on a clean finish. A continuation driver
|
|
79
|
+
* (or a careful caller) inspects this to decide whether to send again.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
stoppedAtIterationLimit?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Options for {@link SDKAgent.runToCompletion} (M1 Phase 3 — continuation driver).
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export interface RunToCompletionOptions {
|
|
91
|
+
/**
|
|
92
|
+
* Maximum number of continuation rounds (re-sends) before giving up with
|
|
93
|
+
* `terminal: "step_limit"`. Default 5. A hard ceiling that prevents a
|
|
94
|
+
* runaway loop when the model keeps truncating.
|
|
95
|
+
*/
|
|
96
|
+
maxRounds?: number;
|
|
97
|
+
/**
|
|
98
|
+
* The short prompt re-sent after a truncated round to make the (stateful)
|
|
99
|
+
* agent resume. Defaults to a generic "continue" instruction. The original
|
|
100
|
+
* conversation is preserved by the agent's session, so this need not repeat
|
|
101
|
+
* the task.
|
|
102
|
+
*/
|
|
103
|
+
continuationPrompt?: string;
|
|
104
|
+
/** Called once per truncated round that triggers a re-send (for metrics/logging). */
|
|
105
|
+
onTruncated?: (event: {
|
|
106
|
+
round: number;
|
|
107
|
+
}) => void | Promise<void>;
|
|
108
|
+
/** Abort signal; checked between rounds — once aborted, no further round starts. */
|
|
109
|
+
signal?: AbortSignal;
|
|
110
|
+
/** Per-send options forwarded to each underlying `send()` (e.g. `maxIterations`). */
|
|
111
|
+
sendOptions?: SendOptions;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Result of {@link SDKAgent.runToCompletion}.
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
export interface RunToCompletionResult {
|
|
119
|
+
/**
|
|
120
|
+
* Why the driver stopped:
|
|
121
|
+
* - `"done"` — a round finished without truncating (the model is done).
|
|
122
|
+
* - `"step_limit"` — `maxRounds` exhausted (or aborted) while still truncating.
|
|
123
|
+
* - `"no_progress"` — two consecutive rounds produced empty output.
|
|
124
|
+
*/
|
|
125
|
+
terminal: "done" | "step_limit" | "no_progress";
|
|
126
|
+
/**
|
|
127
|
+
* Index of the final round. Round 0 is the initial `send`; rounds ≥ 1 are
|
|
128
|
+
* continuation re-sends. So `terminal: "done"` with `rounds: 0` means the
|
|
129
|
+
* first send finished without truncating; `rounds: N` means N continuation
|
|
130
|
+
* re-sends happened. For `step_limit`, `rounds` equals `maxRounds`.
|
|
131
|
+
*/
|
|
132
|
+
rounds: number;
|
|
133
|
+
/** The `RunResult` of the final round. */
|
|
134
|
+
lastResult: RunResult;
|
|
135
|
+
/** Token usage summed across all rounds; `undefined` when no round reported usage. */
|
|
136
|
+
usage?: TokenUsage;
|
|
74
137
|
}
|
|
75
138
|
/**
|
|
76
139
|
* Structured error attached to a {@link RunResult} when the underlying run
|
|
@@ -183,6 +246,16 @@ export interface SendOptions {
|
|
|
183
246
|
id?: string;
|
|
184
247
|
meta?: Record<string, unknown>;
|
|
185
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* Per-send ceiling on the agent loop's tool-calling turns (M1-2). Raises (or
|
|
251
|
+
* lowers) the default cap of 8 for this single send — useful when one heavy
|
|
252
|
+
* task needs more rounds than the agent's default. Must be a positive
|
|
253
|
+
* integer; invalid values throw `ConfigurationError` at the boundary. When
|
|
254
|
+
* unset, the loop uses the default of 8.
|
|
255
|
+
*
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
258
|
+
maxIterations?: number;
|
|
186
259
|
}
|
|
187
260
|
/**
|
|
188
261
|
* Handle to a single prompt submission.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.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",
|
|
@@ -294,8 +294,8 @@
|
|
|
294
294
|
"typedoc": "^0.28.19",
|
|
295
295
|
"ws": "^8.18.0",
|
|
296
296
|
"zod": "^4.0.0",
|
|
297
|
-
"@theokit/sdk-
|
|
298
|
-
"@theokit/sdk-
|
|
297
|
+
"@theokit/sdk-memory": "0.1.0",
|
|
298
|
+
"@theokit/sdk-handoff": "0.1.0"
|
|
299
299
|
},
|
|
300
300
|
"scripts": {
|
|
301
301
|
"build": "tsup && cp src/internal/providers/provider-catalog.json dist/provider-catalog.json",
|