@theokit/agents 3.0.0 → 4.0.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.
@@ -821,7 +821,7 @@ interface DefineAgentConfig<TInput extends z.ZodType = z.ZodType> {
821
821
  /**
822
822
  * A branded agent definition — the value {@link defineAgent} returns.
823
823
  *
824
- * `TTools` (M8) is a phantom type parameter carrying the tool-name union: the `agent()` builder
824
+ * `TTools` (M8) is a phantom type parameter carrying the tool-name union: the `AgentBuilder.create()` builder
825
825
  * threads its accumulated literal tool names here (`.build()` returns `AgentDefinition<TInput,
826
826
  * 'a' | 'b'>`), so the generated client (`.theokit/agents.d.ts`) can expose them via
827
827
  * {@link InferAgentToolNames}. `defineAgent` leaves it `string` (its tools array carries no literal
@@ -835,7 +835,7 @@ type AgentDefinition<TInput extends z.ZodType = z.ZodType, TTools extends string
835
835
  type InferAgentInput<T> = T extends AgentDefinition<infer S> ? (S extends z.ZodType ? z.infer<S> : never) : never;
836
836
  /**
837
837
  * Infer the tool-name union of an agent definition (M8). Yields the literal union for agents built
838
- * with the `agent()` builder (`'read_file' | 'count_lines'`), or `string` for `defineAgent` agents
838
+ * with the `AgentBuilder.create()` builder (`'read_file' | 'count_lines'`), or `string` for `defineAgent` agents
839
839
  * whose tools array carries no literal names.
840
840
  */
841
841
  type InferAgentToolNames<T> = T extends AgentDefinition<z.ZodType, infer N> ? N : never;
@@ -962,7 +962,7 @@ interface SdkAgentHandle {
962
962
  /**
963
963
  * #12 — bridge a builder/`defineAgent` {@link TheokitAgentDefinition} to a real `SDKAgent` FACTORY,
964
964
  * so surfaces that require an `SDKAgent` (or `(sessionId) => SDKAgent`) — notably `theokit acp`,
965
- * whose entry default-export must be one — can serve an agent defined with the `agent()` chain.
965
+ * whose entry default-export must be one — can serve an agent defined with the `AgentBuilder.create()` chain.
966
966
  *
967
967
  * The factory reuses the SAME projection the streaming path uses (`compileAgentDefinition` → tools /
968
968
  * model / `assembleM8CreateOptions`), so the served agent has identical tools, model, system prompt,
@@ -1065,9 +1065,9 @@ declare function presentUIMessageStream(events: AsyncIterable<AgentStreamEvent>,
1065
1065
  }): AsyncGenerator<UIMessageChunk, void, unknown>;
1066
1066
 
1067
1067
  /**
1068
- * M8 — `agent()`, the fluent agent builder with accumulative **type-state**.
1068
+ * M8 — `AgentBuilder.create()`, the fluent agent builder with accumulative **type-state**.
1069
1069
  *
1070
- * `agent().context<C>().tool(t).model(id).system(s).build()` accumulates type parameters the way
1070
+ * `AgentBuilder.create().context<C>().tool(t).model(id).system(s).build()` accumulates type parameters the way
1071
1071
  * the most-loved TS DX does (tRPC `t.procedure.input().query()`, Zod, Hono) and resolves to the
1072
1072
  * **SAME branded `AgentDefinition`** that {@link defineAgent} produces — one runtime, N syntaxes
1073
1073
  * (ADR-B1). The value is entirely at the type level; `.build()` delegates to `defineAgent`, so
@@ -1106,7 +1106,7 @@ type EmptyContext = Record<never, never>;
1106
1106
  /**
1107
1107
  * A tool that MAY declare, at the type level, the run-context shape it needs. A plain
1108
1108
  * {@link CustomTool} (`TRequired = unknown`) is satisfied by any agent context. Build one that
1109
- * carries a literal name + optional required-context via {@link contextualTool}.
1109
+ * carries a literal name + optional required-context via {@link ContextualTool.of}.
1110
1110
  */
1111
1111
  interface ContextualTool<TName extends string = string, TRequired = unknown> extends CustomTool {
1112
1112
  readonly name: TName;
@@ -1114,13 +1114,21 @@ interface ContextualTool<TName extends string = string, TRequired = unknown> ext
1114
1114
  readonly __requiredContext?: TRequired;
1115
1115
  }
1116
1116
  /**
1117
- * Tag a {@link CustomTool} with a literal name (so `.tool()` can accumulate the tool-name union)
1118
- * and, optionally, a required run-context type. The `requiredContext` argument is a type-only
1119
- * witness pass `undefined as C` or a sample value; it is never read at runtime.
1117
+ * Static factory for {@link ContextualTool}. M57: OO surface (`ContextualTool.of(...)`) aligned with
1118
+ * the SDK's `X.create()` shape was the free `contextualTool(...)` function. `ContextualTool` is a
1119
+ * TYPE (the interface above) and a VALUE (this const) at once, the same dual-space pattern the SDK
1120
+ * uses for `Tool`/`Agent`. No instance state, so the factory is `static`-style (`of`), not `create`.
1120
1121
  */
1121
- declare function contextualTool<TName extends string, TRequired = unknown>(tool: CustomTool & {
1122
- name: TName;
1123
- }, _requiredContext?: TRequired): ContextualTool<TName, TRequired>;
1122
+ declare const ContextualTool: {
1123
+ /**
1124
+ * Tag a {@link CustomTool} with a literal name (so `.tool()` can accumulate the tool-name union)
1125
+ * and, optionally, a required run-context type. The `requiredContext` argument is a type-only
1126
+ * witness — pass `undefined as C` or a sample value; it is never read at runtime.
1127
+ */
1128
+ of<TName extends string, TRequired = unknown>(tool: CustomTool & {
1129
+ name: TName;
1130
+ }, _requiredContext?: TRequired): ContextualTool<TName, TRequired>;
1131
+ };
1124
1132
  /**
1125
1133
  * The fluent builder. Each method returns a NEW builder type with the relevant type parameter
1126
1134
  * advanced (immutable chaining). Runtime state is a plain {@link DefineAgentConfig} accumulator.
@@ -1183,7 +1191,7 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
1183
1191
  * it runs; the other events are observational.
1184
1192
  *
1185
1193
  * ```ts
1186
- * agent().hooks({
1194
+ * AgentBuilder.create().hooks({
1187
1195
  * pre_tool_call: (c) => guard(c.name) ? undefined : { block: true, message: 'not allowed' },
1188
1196
  * on_session_start: () => log('session up'),
1189
1197
  * })
@@ -1226,10 +1234,18 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
1226
1234
  readonly __toolNames?: TTools;
1227
1235
  }
1228
1236
  /**
1229
- * Start a fluent agent definition. Chain `.model()` (required) + `.context()` / `.system()` /
1230
- * `.input()` / `.tool()` / `.use()`, then `.build()` to get the branded {@link AgentDefinition}.
1237
+ * Static entry point for the fluent builder. M57: OO surface (`AgentBuilder.create()`) aligned with
1238
+ * the SDK's `X.create()` shape was the free `agent()` function. `AgentBuilder` is a TYPE (the
1239
+ * generic interface above) and a VALUE (this const) at once; in type position the interface wins, in
1240
+ * value position the const wins — no collision, the same dual-space pattern the SDK uses for `Agent`.
1231
1241
  */
1232
- declare function agent(): AgentBuilder;
1242
+ declare const AgentBuilder: {
1243
+ /**
1244
+ * Start a fluent agent definition. Chain `.model()` (required) + `.context()` / `.system()` /
1245
+ * `.input()` / `.tool()` / `.use()`, then `.build()` to get the branded {@link AgentDefinition}.
1246
+ */
1247
+ create(): AgentBuilder;
1248
+ };
1233
1249
 
1234
1250
  /**
1235
1251
  * M4 (theokit-ai-first) — the HITL producer: a `pre_tool_call` plugin that pauses the SDK run
@@ -2046,4 +2062,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
2046
2062
  register(app: PluginApp): void;
2047
2063
  };
2048
2064
 
2049
- export { type DelegateOptions as $, type ApprovalOptions as A, type ApiErrorDecision as B, type CompiledAgentOptions as C, type DelegationResult as D, type ApiErrorPolicy as E, type ApprovalRequiredEvent as F, type Guardrail as G, type HumanInTheLoopOptions as H, type ArtifactChunkEvent as I, type ArtifactStartEvent as J, type BackgroundDelegation as K, type LoopStrategy as L, type MainLoopMeta as M, type BeforeToolCallContext as N, BudgetExceededError as O, type ProjectContextOptions as P, type BudgetOptions as Q, type ReflectionStrategy as R, type StreamEvent as S, type ToolOptions as T, type CheckpointSavedEvent as U, type CompiledContextWindow as V, type ContextualTool as W, CostBudgetExceededError as X, DEFAULT_MAX_ITERATIONS as Y, type DefineAgentConfig as Z, type DelegateFn as _, type CompiledTool as a, delegateBackground as a$, DelegationError as a0, type DoneEvent as a1, type ErrorEvent as a2, type FileEditEvent as a3, type GuardrailAction as a4, type GuardrailPhase as a5, type GuardrailResult as a6, GuardrailViolationError as a7, type HitlDecision as a8, type InferAgentInput as a9, type TextDeltaEvent as aA, type ThinkingEvent as aB, type TimeoutAction as aC, type ToolCallEvent as aD, type ToolCallVeto as aE, type ToolHooks as aF, type ToolHooksPlugin as aG, type ToolResultEvent as aH, type ToolWalkResult as aI, type ToolboxOptions as aJ, type ToolboxWalkResult as aK, agent as aL, agentsPlugin as aM, buildModelSelection as aN, compileAgentDefinition as aO, compileAgentModule as aP, compileContextWindow as aQ, compileProjectContext as aR, compileSkills as aS, compileTools as aT, contextualTool as aU, createAgentExecutionContext as aV, createApiErrorHandler as aW, createSdkAgentStream as aX, createThinkTagExtractor as aY, createToolHooksPlugin as aZ, delegate as a_, type InferAgentToolNames as aa, type IterationEvent as ab, type LLMCallContext as ac, type LoopFinishReason as ad, type LoopOutcome as ae, type LoopStrategyConfig as af, type MainLoopOptions as ag, type McpApprovalSpec as ah, type McpRegistryConfig as ai, type McpRequestContext as aj, type McpSelection as ak, type PartialToolCallEvent as al, type PolicyHandler as am, type ProcessInputContext as an, type ReflectionContext as ao, type ReflectionResult as ap, type ReflectionStrategyConfig as aq, type RunStartedEvent as ar, type ScoreVerdict as as, type ScoredDelegation as at, type Scorer as au, type SdkAgentHandle as av, type SdkMessage as aw, type Segment as ax, type SkillsRequestContext as ay, type StateUpdateEvent as az, type ReasoningEffort as b, delegateWithScoring as b0, extractThinkTagStream as b1, generateAgentManifest as b2, generateAgentRoutes as b3, isAgentContext as b4, isAgentDefinition as b5, isApprovalRequired as b6, isDone as b7, isError as b8, isPartialToolCall as b9, isTextDelta as ba, isToolCall as bb, isToolResult as bc, ladderReflectionStrategy as bd, loopStrategyConfigSchema as be, mcpRegistry as bf, mcpToolApprovals as bg, noopReflectionStrategy as bh, presentUIMessageStream as bi, projectContextMetadataOnlyKnobs as bj, reflectionStrategyConfigSchema as bk, resolveEnabledSkills as bl, resolveLoopStrategy as bm, resolveMcpServers as bn, runWithApiErrorHandling as bo, streamAgentResponse as bp, streamAgentUIMessages as bq, toAgentFactory as br, translateSdkEvent as bs, type RoundStreamFactory as c, type ContextWindowOptions as d, type McpServersMap as e, type MemoryOptions as f, type SkillsOptions as g, type SkillsSelection as h, type AgentManifestEntry as i, AGENT_BRAND as j, type AfterToolCallContext as k, type AgentBuilder as l, type AgentDefinition as m, AgentDefinitionError as n, type AgentExecutionContext as o, type AgentManifest as p, type AgentManifestSource as q, type AgentManifestTool as r, type AgentOptions as s, type AgentRoute as t, type AgentRouteContext as u, type AgentRunInfo as v, type AgentStreamEvent as w, type AgentTurnMetadata as x, type AgentsPluginOptions as y, type ApiErrorContext as z };
2065
+ export { type FileEditEvent as $, type ApprovalOptions as A, type ArtifactChunkEvent as B, type CompiledAgentOptions as C, type DelegationResult as D, type ArtifactStartEvent as E, type BackgroundDelegation as F, type Guardrail as G, type HumanInTheLoopOptions as H, type BeforeToolCallContext as I, BudgetExceededError as J, type BudgetOptions as K, type LoopStrategy as L, type MainLoopMeta as M, type CheckpointSavedEvent as N, type CompiledContextWindow as O, ContextualTool as P, CostBudgetExceededError as Q, type ReflectionStrategy as R, type StreamEvent as S, type ToolOptions as T, DEFAULT_MAX_ITERATIONS as U, type DefineAgentConfig as V, type DelegateFn as W, type DelegateOptions as X, DelegationError as Y, type DoneEvent as Z, type ErrorEvent as _, type CompiledTool as a, isAgentContext as a$, type GuardrailAction as a0, type GuardrailPhase as a1, type GuardrailResult as a2, GuardrailViolationError as a3, type HitlDecision as a4, type InferAgentInput as a5, type InferAgentToolNames as a6, type IterationEvent as a7, type LLMCallContext as a8, type LoopFinishReason as a9, type ToolCallEvent as aA, type ToolCallVeto as aB, type ToolHooks as aC, type ToolHooksPlugin as aD, type ToolResultEvent as aE, type ToolWalkResult as aF, type ToolboxOptions as aG, type ToolboxWalkResult as aH, agentsPlugin as aI, buildModelSelection as aJ, compileAgentDefinition as aK, compileAgentModule as aL, compileContextWindow as aM, compileProjectContext as aN, compileSkills as aO, compileTools as aP, createAgentExecutionContext as aQ, createApiErrorHandler as aR, createSdkAgentStream as aS, createThinkTagExtractor as aT, createToolHooksPlugin as aU, delegate as aV, delegateBackground as aW, delegateWithScoring as aX, extractThinkTagStream as aY, generateAgentManifest as aZ, generateAgentRoutes as a_, type LoopOutcome as aa, type LoopStrategyConfig as ab, type MainLoopOptions as ac, type McpApprovalSpec as ad, type McpRegistryConfig as ae, type McpRequestContext as af, type McpSelection as ag, type PartialToolCallEvent as ah, type PolicyHandler as ai, type ProcessInputContext as aj, type ReflectionContext as ak, type ReflectionResult as al, type ReflectionStrategyConfig as am, type RunStartedEvent as an, type ScoreVerdict as ao, type ScoredDelegation as ap, type Scorer as aq, type SdkAgentHandle as ar, type SdkMessage as as, type Segment as at, type SkillsRequestContext as au, type SkillsSelection as av, type StateUpdateEvent as aw, type TextDeltaEvent as ax, type ThinkingEvent as ay, type TimeoutAction as az, type ReasoningEffort as b, isAgentDefinition as b0, isApprovalRequired as b1, isDone as b2, isError as b3, isPartialToolCall as b4, isTextDelta as b5, isToolCall as b6, isToolResult as b7, ladderReflectionStrategy as b8, loopStrategyConfigSchema as b9, mcpRegistry as ba, mcpToolApprovals as bb, noopReflectionStrategy as bc, presentUIMessageStream as bd, projectContextMetadataOnlyKnobs as be, reflectionStrategyConfigSchema as bf, resolveEnabledSkills as bg, resolveLoopStrategy as bh, resolveMcpServers as bi, runWithApiErrorHandling as bj, streamAgentResponse as bk, streamAgentUIMessages as bl, toAgentFactory as bm, translateSdkEvent as bn, type RoundStreamFactory as c, type ContextWindowOptions as d, type SkillsOptions as e, type AgentManifestEntry as f, AGENT_BRAND as g, type AfterToolCallContext as h, AgentBuilder as i, type AgentDefinition as j, AgentDefinitionError as k, type AgentExecutionContext as l, type AgentManifest as m, type AgentManifestSource as n, type AgentManifestTool as o, type AgentOptions as p, type AgentRoute as q, type AgentRouteContext as r, type AgentRunInfo as s, type AgentStreamEvent as t, type AgentTurnMetadata as u, type AgentsPluginOptions as v, type ApiErrorContext as w, type ApiErrorDecision as x, type ApiErrorPolicy as y, type ApprovalRequiredEvent as z };
package/dist/bridge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { j as AGENT_BRAND, k as AfterToolCallContext, l as AgentBuilder, m as AgentDefinition, n as AgentDefinitionError, o as AgentExecutionContext, p as AgentManifest, i as AgentManifestEntry, q as AgentManifestSource, r as AgentManifestTool, t as AgentRoute, u as AgentRouteContext, v as AgentRunInfo, w as AgentStreamEvent, x as AgentTurnMetadata, y as AgentsPluginOptions, z as ApiErrorContext, B as ApiErrorDecision, E as ApiErrorPolicy, F as ApprovalRequiredEvent, I as ArtifactChunkEvent, J as ArtifactStartEvent, K as BackgroundDelegation, N as BeforeToolCallContext, O as BudgetExceededError, U as CheckpointSavedEvent, C as CompiledAgentOptions, V as CompiledContextWindow, a as CompiledTool, W as ContextualTool, Z as DefineAgentConfig, _ as DelegateFn, $ as DelegateOptions, a0 as DelegationError, D as DelegationResult, a1 as DoneEvent, a2 as ErrorEvent, a3 as FileEditEvent, a9 as InferAgentInput, aa as InferAgentToolNames, ab as IterationEvent, ac as LLMCallContext, ah as McpApprovalSpec, ai as McpRegistryConfig, aj as McpRequestContext, ak as McpSelection, al as PartialToolCallEvent, an as ProcessInputContext, ar as RunStartedEvent, as as ScoreVerdict, at as ScoredDelegation, au as Scorer, av as SdkAgentHandle, aw as SdkMessage, ax as Segment, az as StateUpdateEvent, S as StreamEvent, aA as TextDeltaEvent, aB as ThinkingEvent, aD as ToolCallEvent, aE as ToolCallVeto, aF as ToolHooks, aG as ToolHooksPlugin, aH as ToolResultEvent, aI as ToolWalkResult, aK as ToolboxWalkResult, aL as agent, aM as agentsPlugin, aN as buildModelSelection, aO as compileAgentDefinition, aP as compileAgentModule, aQ as compileContextWindow, aR as compileProjectContext, aS as compileSkills, aT as compileTools, aU as contextualTool, aV as createAgentExecutionContext, aW as createApiErrorHandler, aX as createSdkAgentStream, aY as createThinkTagExtractor, aZ as createToolHooksPlugin, a_ as delegate, a$ as delegateBackground, b0 as delegateWithScoring, b1 as extractThinkTagStream, b2 as generateAgentManifest, b3 as generateAgentRoutes, b4 as isAgentContext, b5 as isAgentDefinition, b6 as isApprovalRequired, b7 as isDone, b8 as isError, b9 as isPartialToolCall, ba as isTextDelta, bb as isToolCall, bc as isToolResult, bf as mcpRegistry, bg as mcpToolApprovals, bi as presentUIMessageStream, bj as projectContextMetadataOnlyKnobs, bn as resolveMcpServers, bo as runWithApiErrorHandling, bp as streamAgentResponse, bq as streamAgentUIMessages, br as toAgentFactory, bs as translateSdkEvent } from './bridge-entry-8gsH0kVZ.js';
1
+ export { g as AGENT_BRAND, h as AfterToolCallContext, i as AgentBuilder, j as AgentDefinition, k as AgentDefinitionError, l as AgentExecutionContext, m as AgentManifest, f as AgentManifestEntry, n as AgentManifestSource, o as AgentManifestTool, q as AgentRoute, r as AgentRouteContext, s as AgentRunInfo, t as AgentStreamEvent, u as AgentTurnMetadata, v as AgentsPluginOptions, w as ApiErrorContext, x as ApiErrorDecision, y as ApiErrorPolicy, z as ApprovalRequiredEvent, B as ArtifactChunkEvent, E as ArtifactStartEvent, F as BackgroundDelegation, I as BeforeToolCallContext, J as BudgetExceededError, N as CheckpointSavedEvent, C as CompiledAgentOptions, O as CompiledContextWindow, a as CompiledTool, P as ContextualTool, V as DefineAgentConfig, W as DelegateFn, X as DelegateOptions, Y as DelegationError, D as DelegationResult, Z as DoneEvent, _ as ErrorEvent, $ as FileEditEvent, a5 as InferAgentInput, a6 as InferAgentToolNames, a7 as IterationEvent, a8 as LLMCallContext, ad as McpApprovalSpec, ae as McpRegistryConfig, af as McpRequestContext, ag as McpSelection, ah as PartialToolCallEvent, aj as ProcessInputContext, an as RunStartedEvent, ao as ScoreVerdict, ap as ScoredDelegation, aq as Scorer, ar as SdkAgentHandle, as as SdkMessage, at as Segment, aw as StateUpdateEvent, S as StreamEvent, ax as TextDeltaEvent, ay as ThinkingEvent, aA as ToolCallEvent, aB as ToolCallVeto, aC as ToolHooks, aD as ToolHooksPlugin, aE as ToolResultEvent, aF as ToolWalkResult, aH as ToolboxWalkResult, aI as agentsPlugin, aJ as buildModelSelection, aK as compileAgentDefinition, aL as compileAgentModule, aM as compileContextWindow, aN as compileProjectContext, aO as compileSkills, aP as compileTools, aQ as createAgentExecutionContext, aR as createApiErrorHandler, aS as createSdkAgentStream, aT as createThinkTagExtractor, aU as createToolHooksPlugin, aV as delegate, aW as delegateBackground, aX as delegateWithScoring, aY as extractThinkTagStream, aZ as generateAgentManifest, a_ as generateAgentRoutes, a$ as isAgentContext, b0 as isAgentDefinition, b1 as isApprovalRequired, b2 as isDone, b3 as isError, b4 as isPartialToolCall, b5 as isTextDelta, b6 as isToolCall, b7 as isToolResult, ba as mcpRegistry, bb as mcpToolApprovals, bd as presentUIMessageStream, be as projectContextMetadataOnlyKnobs, bi as resolveMcpServers, bj as runWithApiErrorHandling, bk as streamAgentResponse, bl as streamAgentUIMessages, bm as toAgentFactory, bn as translateSdkEvent } from './bridge-entry-Ddu3Ug_3.js';
2
2
  import '@theokit/http';
3
3
  import '@theokit/sdk';
4
4
  import 'zod';
package/dist/bridge.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  AGENT_BRAND,
3
+ AgentBuilder,
3
4
  AgentDefinitionError,
4
5
  BudgetExceededError,
6
+ ContextualTool,
5
7
  DelegationError,
6
- agent,
7
8
  agentsPlugin,
8
9
  buildModelSelection,
9
10
  compileAgentDefinition,
@@ -12,7 +13,6 @@ import {
12
13
  compileProjectContext,
13
14
  compileSkills,
14
15
  compileTools,
15
- contextualTool,
16
16
  createAgentExecutionContext,
17
17
  createApiErrorHandler,
18
18
  createSdkAgentStream,
@@ -43,14 +43,15 @@ import {
43
43
  streamAgentUIMessages,
44
44
  toAgentFactory,
45
45
  translateSdkEvent
46
- } from "./chunk-C2DALG62.js";
46
+ } from "./chunk-OKG5LRGV.js";
47
47
  import "./chunk-7QVYU63E.js";
48
48
  export {
49
49
  AGENT_BRAND,
50
+ AgentBuilder,
50
51
  AgentDefinitionError,
51
52
  BudgetExceededError,
53
+ ContextualTool,
52
54
  DelegationError,
53
- agent,
54
55
  agentsPlugin,
55
56
  buildModelSelection,
56
57
  compileAgentDefinition,
@@ -59,7 +60,6 @@ export {
59
60
  compileProjectContext,
60
61
  compileSkills,
61
62
  compileTools,
62
- contextualTool,
63
63
  createAgentExecutionContext,
64
64
  createApiErrorHandler,
65
65
  createSdkAgentStream,
@@ -249,13 +249,13 @@ function compileTools(toolboxes, toolboxInstances) {
249
249
  __name(compileTools, "compileTools");
250
250
 
251
251
  // src/bridge/agent-execution-context.ts
252
- function createAgentExecutionContext(base, agent2, run, toolCall) {
252
+ function createAgentExecutionContext(base, agent, run, toolCall) {
253
253
  return {
254
254
  getRequest: /* @__PURE__ */ __name(() => base.getRequest(), "getRequest"),
255
255
  getUrl: /* @__PURE__ */ __name(() => base.getUrl(), "getUrl"),
256
256
  getClass: /* @__PURE__ */ __name(() => base.getClass(), "getClass"),
257
257
  getMethodName: /* @__PURE__ */ __name(() => base.getMethodName(), "getMethodName"),
258
- getAgent: /* @__PURE__ */ __name(() => agent2, "getAgent"),
258
+ getAgent: /* @__PURE__ */ __name(() => agent, "getAgent"),
259
259
  getRun: /* @__PURE__ */ __name(() => run, "getRun"),
260
260
  getToolCall: /* @__PURE__ */ __name(() => toolCall ?? null, "getToolCall"),
261
261
  isAgentContext: /* @__PURE__ */ __name(() => true, "isAgentContext")
@@ -1254,7 +1254,7 @@ async function* streamSdkAgent(rt, compiled, sdkTools, opts) {
1254
1254
  projectContext: applied.includes("projectContext")
1255
1255
  });
1256
1256
  }
1257
- const agent2 = await Agent.getOrCreate(sessionId, {
1257
+ const agent = await Agent.getOrCreate(sessionId, {
1258
1258
  apiKey,
1259
1259
  model: buildModelSelection(model, reasoningEffort),
1260
1260
  tools: sdkTools,
@@ -1272,7 +1272,7 @@ async function* streamSdkAgent(rt, compiled, sdkTools, opts) {
1272
1272
  text: message,
1273
1273
  images: overrides.images
1274
1274
  } : message;
1275
- const sendPromise = agent2.send(sendInput, sendOptions);
1275
+ const sendPromise = agent.send(sendInput, sendOptions);
1276
1276
  const openStream = /* @__PURE__ */ __name(async () => (await sendPromise).stream(), "openStream");
1277
1277
  const merged = mergeDeltaStream(queue, openStream, runId, state);
1278
1278
  for await (const event of applyTextTransforms(merged, {
@@ -1285,7 +1285,7 @@ async function* streamSdkAgent(rt, compiled, sdkTools, opts) {
1285
1285
  yield realUsageDone(await (await sendPromise).wait(), t0);
1286
1286
  }
1287
1287
  } finally {
1288
- await agent2.dispose();
1288
+ await agent.dispose();
1289
1289
  }
1290
1290
  }
1291
1291
  __name(streamSdkAgent, "streamSdkAgent");
@@ -1315,14 +1315,14 @@ function toAgentFactory(def, opts) {
1315
1315
  baseDir: overrides.baseDir
1316
1316
  };
1317
1317
  const extra = buildExtraCreateOptions(overrides, compiled);
1318
- const agent2 = await rt.Agent.getOrCreate(sessionId, {
1318
+ const agent = await rt.Agent.getOrCreate(sessionId, {
1319
1319
  apiKey: opts.apiKey,
1320
1320
  model: buildModelSelection(model, reasoningEffort),
1321
1321
  tools: sdkTools,
1322
1322
  ...m8,
1323
1323
  ...extra
1324
1324
  });
1325
- return agent2;
1325
+ return agent;
1326
1326
  };
1327
1327
  }
1328
1328
  __name(toAgentFactory, "toAgentFactory");
@@ -1962,10 +1962,16 @@ async function* presentUIMessageStream(events, opts) {
1962
1962
  __name(presentUIMessageStream, "presentUIMessageStream");
1963
1963
 
1964
1964
  // src/bridge/agent-builder.ts
1965
- function contextualTool(tool, _requiredContext) {
1966
- return tool;
1967
- }
1968
- __name(contextualTool, "contextualTool");
1965
+ var ContextualTool = {
1966
+ /**
1967
+ * Tag a {@link CustomTool} with a literal name (so `.tool()` can accumulate the tool-name union)
1968
+ * and, optionally, a required run-context type. The `requiredContext` argument is a type-only
1969
+ * witness — pass `undefined as C` or a sample value; it is never read at runtime.
1970
+ */
1971
+ of(tool, _requiredContext) {
1972
+ return tool;
1973
+ }
1974
+ };
1969
1975
  function makeBuilder(config) {
1970
1976
  const runtime = {
1971
1977
  input: /* @__PURE__ */ __name((schema) => makeBuilder({
@@ -2047,10 +2053,15 @@ function makeBuilder(config) {
2047
2053
  return runtime;
2048
2054
  }
2049
2055
  __name(makeBuilder, "makeBuilder");
2050
- function agent() {
2051
- return makeBuilder({});
2052
- }
2053
- __name(agent, "agent");
2056
+ var AgentBuilder = {
2057
+ /**
2058
+ * Start a fluent agent definition. Chain `.model()` (required) + `.context()` / `.system()` /
2059
+ * `.input()` / `.tool()` / `.use()`, then `.build()` to get the branded {@link AgentDefinition}.
2060
+ */
2061
+ create() {
2062
+ return makeBuilder({});
2063
+ }
2064
+ };
2054
2065
 
2055
2066
  // src/bridge/hitl-plugin.ts
2056
2067
  function createHitlPlugin(wiring) {
@@ -3436,8 +3447,8 @@ export {
3436
3447
  createSdkAgentStream,
3437
3448
  toAgentFactory,
3438
3449
  presentUIMessageStream,
3439
- contextualTool,
3440
- agent,
3450
+ ContextualTool,
3451
+ AgentBuilder,
3441
3452
  AgentDefinitionError,
3442
3453
  compileAgentModule,
3443
3454
  streamAgentUIMessages,
@@ -3478,4 +3489,4 @@ export {
3478
3489
  generateAgentManifest,
3479
3490
  agentsPlugin
3480
3491
  };
3481
- //# sourceMappingURL=chunk-C2DALG62.js.map
3492
+ //# sourceMappingURL=chunk-OKG5LRGV.js.map