@theokit/sdk 2.21.0 → 2.23.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.
@@ -186,6 +186,23 @@ interface ModelSelection {
186
186
  id: string;
187
187
  params?: ModelParameterValue[];
188
188
  }
189
+ /**
190
+ * SE12 — a read-only, text-only projection of one turn of the run's conversation,
191
+ * exposed to a tool handler via `ctx.messages`. Content is flattened to text; tool
192
+ * calls / results and non-text parts are dropped, and turns that project to empty
193
+ * text are omitted. Consumed by `defineSubAgent`'s `messageFilter` to forward
194
+ * (a subset of) the supervisor transcript to a subagent.
195
+ *
196
+ * `role` includes `"system"` for type-completeness with the wire message shape,
197
+ * but the system prompt travels on a separate request field — a `"system"` entry
198
+ * does NOT appear in the current projection.
199
+ *
200
+ * @public
201
+ */
202
+ interface ToolContextMessage {
203
+ role: "system" | "user" | "assistant";
204
+ content: string;
205
+ }
189
206
  /**
190
207
  * Local function tool declared per-agent via {@link AgentOptions.tools}. The
191
208
  * handler runs in-process; no MCP server is involved. The SDK serializes
@@ -217,11 +234,14 @@ interface CustomTool {
217
234
  * carries the run's `AbortSignal`; single-argument handlers are unaffected. M7
218
235
  * — the same `ctx` also carries an optional user `context` (provided once via
219
236
  * `SendOptions.context`), so shared config like a `projectRoot` is read by
220
- * every tool instead of baked into each factory.
237
+ * every tool instead of baked into each factory. SE12 — `ctx.messages` is a
238
+ * read-only, text-only projection of the current turn's transcript (see
239
+ * {@link ToolContextMessage}); `defineSubAgent`'s `messageFilter` consumes it.
221
240
  */
222
241
  handler: (input: Record<string, unknown>, ctx?: {
223
242
  signal?: AbortSignal;
224
243
  context?: unknown;
244
+ messages?: readonly ToolContextMessage[];
225
245
  }) => string | ToolResultContentBlock[] | Promise<string | ToolResultContentBlock[]>;
226
246
  }
227
247
 
@@ -1253,4 +1273,4 @@ interface GenerateRunResult<O> {
1253
1273
  };
1254
1274
  }
1255
1275
 
1256
- export { type SendOptions as $, type AgentConversationTurn as A, type RunTaskStartedEvent as B, type CustomTool as C, type DoomLoopThresholds as D, type RunTaskUpdatedEvent as E, type RunToCompletionOptions as F, type GenerateOptions as G, type RunToCompletionResult as H, type ImageBlock as I, type RunToolProgressEvent as J, type SDKAssistantMessage as K, type SDKImage as L, type ModelSelection as M, type SDKImageDimension as N, type SDKObjectDelta as O, type PartialToolCallUpdate as P, type SDKRequestMessage as Q, type RunResult as R, type SDKMessage as S, type ToolResultContentBlock as T, type SDKStatusMessage as U, type SDKSystemMessage as V, type SDKTaskMessage as W, type SDKThinkingMessage as X, type SDKToolUseMessage as Y, type SDKUserMessage as Z, type SDKUserMessageEvent as _, type McpServerConfig as a, type ShellCommand as a0, type ShellConversationTurn as a1, type ShellOutput as a2, type ShellOutputDeltaUpdate as a3, type StepCompletedUpdate as a4, type StepStartedUpdate as a5, type StreamToCompletionResult as a6, type SummaryCompletedUpdate as a7, type SummaryStartedUpdate as a8, type SummaryUpdate as a9, type TextBlock as aa, type TextDeltaUpdate as ab, type ThinkingCompletedUpdate as ac, type ThinkingDeltaUpdate as ad, type ThinkingMessage as ae, type TokenDeltaUpdate as af, type TokenUsage as ag, type ToolCall as ah, type ToolCallCompletedUpdate as ai, type ToolCallStartedUpdate as aj, type ToolResult as ak, type ToolResultGuardOptions as al, type ToolUseBlock as am, type TurnEndedUpdate as an, type UserMessage as ao, type UserMessageAppendedUpdate as ap, emitRunEvent as aq, type Run as b, type MessageOrigin as c, type AssistantMessage as d, type ConversationStep as e, type ConversationTurn as f, type CostBreakdown as g, type CostSource as h, type CostStatus as i, type GenerateRunResult as j, type InteractionUpdate as k, type McpAuthConfig as l, type McpHttpServerConfig as m, type McpOAuthConfig as n, type McpStdioServerConfig as o, type ModelParameterValue as p, type RunCompactBoundaryEvent as q, type RunErrorDetail as r, type RunEvent as s, type RunEventSink as t, type RunGitInfo as u, type RunOperation as v, type RunPermissionDeniedEvent as w, type RunRateLimitEvent as x, type RunStatus as y, type RunTaskCompletedEvent as z };
1276
+ export { type SendOptions as $, type AgentConversationTurn as A, type RunTaskStartedEvent as B, type CustomTool as C, type DoomLoopThresholds as D, type RunTaskUpdatedEvent as E, type RunToCompletionOptions as F, type GenerateOptions as G, type RunToCompletionResult as H, type ImageBlock as I, type RunToolProgressEvent as J, type SDKAssistantMessage as K, type SDKImage as L, type ModelSelection as M, type SDKImageDimension as N, type SDKObjectDelta as O, type PartialToolCallUpdate as P, type SDKRequestMessage as Q, type RunResult as R, type SDKMessage as S, type ToolResultContentBlock as T, type SDKStatusMessage as U, type SDKSystemMessage as V, type SDKTaskMessage as W, type SDKThinkingMessage as X, type SDKToolUseMessage as Y, type SDKUserMessage as Z, type SDKUserMessageEvent as _, type McpServerConfig as a, type ShellCommand as a0, type ShellConversationTurn as a1, type ShellOutput as a2, type ShellOutputDeltaUpdate as a3, type StepCompletedUpdate as a4, type StepStartedUpdate as a5, type StreamToCompletionResult as a6, type SummaryCompletedUpdate as a7, type SummaryStartedUpdate as a8, type SummaryUpdate as a9, type TextBlock as aa, type TextDeltaUpdate as ab, type ThinkingCompletedUpdate as ac, type ThinkingDeltaUpdate as ad, type ThinkingMessage as ae, type TokenDeltaUpdate as af, type TokenUsage as ag, type ToolCall as ah, type ToolCallCompletedUpdate as ai, type ToolCallStartedUpdate as aj, type ToolContextMessage as ak, type ToolResult as al, type ToolResultGuardOptions as am, type ToolUseBlock as an, type TurnEndedUpdate as ao, type UserMessage as ap, type UserMessageAppendedUpdate as aq, emitRunEvent as ar, type Run as b, type MessageOrigin as c, type AssistantMessage as d, type ConversationStep as e, type ConversationTurn as f, type CostBreakdown as g, type CostSource as h, type CostStatus as i, type GenerateRunResult as j, type InteractionUpdate as k, type McpAuthConfig as l, type McpHttpServerConfig as m, type McpOAuthConfig as n, type McpStdioServerConfig as o, type ModelParameterValue as p, type RunCompactBoundaryEvent as q, type RunErrorDetail as r, type RunEvent as s, type RunEventSink as t, type RunGitInfo as u, type RunOperation as v, type RunPermissionDeniedEvent as w, type RunRateLimitEvent as x, type RunStatus as y, type RunTaskCompletedEvent as z };
@@ -186,6 +186,23 @@ interface ModelSelection {
186
186
  id: string;
187
187
  params?: ModelParameterValue[];
188
188
  }
189
+ /**
190
+ * SE12 — a read-only, text-only projection of one turn of the run's conversation,
191
+ * exposed to a tool handler via `ctx.messages`. Content is flattened to text; tool
192
+ * calls / results and non-text parts are dropped, and turns that project to empty
193
+ * text are omitted. Consumed by `defineSubAgent`'s `messageFilter` to forward
194
+ * (a subset of) the supervisor transcript to a subagent.
195
+ *
196
+ * `role` includes `"system"` for type-completeness with the wire message shape,
197
+ * but the system prompt travels on a separate request field — a `"system"` entry
198
+ * does NOT appear in the current projection.
199
+ *
200
+ * @public
201
+ */
202
+ interface ToolContextMessage {
203
+ role: "system" | "user" | "assistant";
204
+ content: string;
205
+ }
189
206
  /**
190
207
  * Local function tool declared per-agent via {@link AgentOptions.tools}. The
191
208
  * handler runs in-process; no MCP server is involved. The SDK serializes
@@ -217,11 +234,14 @@ interface CustomTool {
217
234
  * carries the run's `AbortSignal`; single-argument handlers are unaffected. M7
218
235
  * — the same `ctx` also carries an optional user `context` (provided once via
219
236
  * `SendOptions.context`), so shared config like a `projectRoot` is read by
220
- * every tool instead of baked into each factory.
237
+ * every tool instead of baked into each factory. SE12 — `ctx.messages` is a
238
+ * read-only, text-only projection of the current turn's transcript (see
239
+ * {@link ToolContextMessage}); `defineSubAgent`'s `messageFilter` consumes it.
221
240
  */
222
241
  handler: (input: Record<string, unknown>, ctx?: {
223
242
  signal?: AbortSignal;
224
243
  context?: unknown;
244
+ messages?: readonly ToolContextMessage[];
225
245
  }) => string | ToolResultContentBlock[] | Promise<string | ToolResultContentBlock[]>;
226
246
  }
227
247
 
@@ -1253,4 +1273,4 @@ interface GenerateRunResult<O> {
1253
1273
  };
1254
1274
  }
1255
1275
 
1256
- export { type SendOptions as $, type AgentConversationTurn as A, type RunTaskStartedEvent as B, type CustomTool as C, type DoomLoopThresholds as D, type RunTaskUpdatedEvent as E, type RunToCompletionOptions as F, type GenerateOptions as G, type RunToCompletionResult as H, type ImageBlock as I, type RunToolProgressEvent as J, type SDKAssistantMessage as K, type SDKImage as L, type ModelSelection as M, type SDKImageDimension as N, type SDKObjectDelta as O, type PartialToolCallUpdate as P, type SDKRequestMessage as Q, type RunResult as R, type SDKMessage as S, type ToolResultContentBlock as T, type SDKStatusMessage as U, type SDKSystemMessage as V, type SDKTaskMessage as W, type SDKThinkingMessage as X, type SDKToolUseMessage as Y, type SDKUserMessage as Z, type SDKUserMessageEvent as _, type McpServerConfig as a, type ShellCommand as a0, type ShellConversationTurn as a1, type ShellOutput as a2, type ShellOutputDeltaUpdate as a3, type StepCompletedUpdate as a4, type StepStartedUpdate as a5, type StreamToCompletionResult as a6, type SummaryCompletedUpdate as a7, type SummaryStartedUpdate as a8, type SummaryUpdate as a9, type TextBlock as aa, type TextDeltaUpdate as ab, type ThinkingCompletedUpdate as ac, type ThinkingDeltaUpdate as ad, type ThinkingMessage as ae, type TokenDeltaUpdate as af, type TokenUsage as ag, type ToolCall as ah, type ToolCallCompletedUpdate as ai, type ToolCallStartedUpdate as aj, type ToolResult as ak, type ToolResultGuardOptions as al, type ToolUseBlock as am, type TurnEndedUpdate as an, type UserMessage as ao, type UserMessageAppendedUpdate as ap, emitRunEvent as aq, type Run as b, type MessageOrigin as c, type AssistantMessage as d, type ConversationStep as e, type ConversationTurn as f, type CostBreakdown as g, type CostSource as h, type CostStatus as i, type GenerateRunResult as j, type InteractionUpdate as k, type McpAuthConfig as l, type McpHttpServerConfig as m, type McpOAuthConfig as n, type McpStdioServerConfig as o, type ModelParameterValue as p, type RunCompactBoundaryEvent as q, type RunErrorDetail as r, type RunEvent as s, type RunEventSink as t, type RunGitInfo as u, type RunOperation as v, type RunPermissionDeniedEvent as w, type RunRateLimitEvent as x, type RunStatus as y, type RunTaskCompletedEvent as z };
1276
+ export { type SendOptions as $, type AgentConversationTurn as A, type RunTaskStartedEvent as B, type CustomTool as C, type DoomLoopThresholds as D, type RunTaskUpdatedEvent as E, type RunToCompletionOptions as F, type GenerateOptions as G, type RunToCompletionResult as H, type ImageBlock as I, type RunToolProgressEvent as J, type SDKAssistantMessage as K, type SDKImage as L, type ModelSelection as M, type SDKImageDimension as N, type SDKObjectDelta as O, type PartialToolCallUpdate as P, type SDKRequestMessage as Q, type RunResult as R, type SDKMessage as S, type ToolResultContentBlock as T, type SDKStatusMessage as U, type SDKSystemMessage as V, type SDKTaskMessage as W, type SDKThinkingMessage as X, type SDKToolUseMessage as Y, type SDKUserMessage as Z, type SDKUserMessageEvent as _, type McpServerConfig as a, type ShellCommand as a0, type ShellConversationTurn as a1, type ShellOutput as a2, type ShellOutputDeltaUpdate as a3, type StepCompletedUpdate as a4, type StepStartedUpdate as a5, type StreamToCompletionResult as a6, type SummaryCompletedUpdate as a7, type SummaryStartedUpdate as a8, type SummaryUpdate as a9, type TextBlock as aa, type TextDeltaUpdate as ab, type ThinkingCompletedUpdate as ac, type ThinkingDeltaUpdate as ad, type ThinkingMessage as ae, type TokenDeltaUpdate as af, type TokenUsage as ag, type ToolCall as ah, type ToolCallCompletedUpdate as ai, type ToolCallStartedUpdate as aj, type ToolContextMessage as ak, type ToolResult as al, type ToolResultGuardOptions as am, type ToolUseBlock as an, type TurnEndedUpdate as ao, type UserMessage as ap, type UserMessageAppendedUpdate as aq, emitRunEvent as ar, type Run as b, type MessageOrigin as c, type AssistantMessage as d, type ConversationStep as e, type ConversationTurn as f, type CostBreakdown as g, type CostSource as h, type CostStatus as i, type GenerateRunResult as j, type InteractionUpdate as k, type McpAuthConfig as l, type McpHttpServerConfig as m, type McpOAuthConfig as n, type McpStdioServerConfig as o, type ModelParameterValue as p, type RunCompactBoundaryEvent as q, type RunErrorDetail as r, type RunEvent as s, type RunEventSink as t, type RunGitInfo as u, type RunOperation as v, type RunPermissionDeniedEvent as w, type RunRateLimitEvent as x, type RunStatus as y, type RunTaskCompletedEvent as z };
@@ -30,6 +30,23 @@ export interface ModelSelection {
30
30
  id: string;
31
31
  params?: ModelParameterValue[];
32
32
  }
33
+ /**
34
+ * SE12 — a read-only, text-only projection of one turn of the run's conversation,
35
+ * exposed to a tool handler via `ctx.messages`. Content is flattened to text; tool
36
+ * calls / results and non-text parts are dropped, and turns that project to empty
37
+ * text are omitted. Consumed by `defineSubAgent`'s `messageFilter` to forward
38
+ * (a subset of) the supervisor transcript to a subagent.
39
+ *
40
+ * `role` includes `"system"` for type-completeness with the wire message shape,
41
+ * but the system prompt travels on a separate request field — a `"system"` entry
42
+ * does NOT appear in the current projection.
43
+ *
44
+ * @public
45
+ */
46
+ export interface ToolContextMessage {
47
+ role: "system" | "user" | "assistant";
48
+ content: string;
49
+ }
33
50
  /**
34
51
  * Local function tool declared per-agent via {@link AgentOptions.tools}. The
35
52
  * handler runs in-process; no MCP server is involved. The SDK serializes
@@ -61,10 +78,13 @@ export interface CustomTool {
61
78
  * carries the run's `AbortSignal`; single-argument handlers are unaffected. M7
62
79
  * — the same `ctx` also carries an optional user `context` (provided once via
63
80
  * `SendOptions.context`), so shared config like a `projectRoot` is read by
64
- * every tool instead of baked into each factory.
81
+ * every tool instead of baked into each factory. SE12 — `ctx.messages` is a
82
+ * read-only, text-only projection of the current turn's transcript (see
83
+ * {@link ToolContextMessage}); `defineSubAgent`'s `messageFilter` consumes it.
65
84
  */
66
85
  handler: (input: Record<string, unknown>, ctx?: {
67
86
  signal?: AbortSignal;
68
87
  context?: unknown;
88
+ messages?: readonly ToolContextMessage[];
69
89
  }) => string | import("./content-blocks.js").ToolResultContentBlock[] | Promise<string | import("./content-blocks.js").ToolResultContentBlock[]>;
70
90
  }
@@ -2,7 +2,7 @@ import type { ContextSettings, SDKContextManager } from "./context.js";
2
2
  import type { McpServerConfig } from "./mcp.js";
3
3
  import type { PluginsSettings, ProviderRoutingSettings, SDKProvidersManager } from "./providers.js";
4
4
  import type { Run, SDKUserMessage, SendOptions } from "./run.js";
5
- export type { CustomTool, ModelParameterValue, ModelSelection } from "./agent-prims.js";
5
+ export type { CustomTool, ModelParameterValue, ModelSelection, ToolContextMessage, } from "./agent-prims.js";
6
6
  import type { Plugin } from "../internal/plugins/types.js";
7
7
  import type { CustomTool, ModelSelection } from "./agent-prims.js";
8
8
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theokit/sdk",
3
- "version": "2.21.0",
3
+ "version": "2.23.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",