@theokit/agents 2.0.0 → 3.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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as Guardrail, L as LoopStrategy, R as ReflectionStrategy, C as CompiledAgentOptions, M as MainLoopMeta, a as CompiledTool, b as ReasoningEffort, c as RoundStreamFactory, S as StreamEvent, D as DelegationResult, d as ContextWindowOptions, H as HumanInTheLoopOptions, e as McpServersMap, f as MemoryOptions, P as ProjectContextOptions, g as SkillsOptions, h as SkillsSelection, T as ToolOptions, A as ApprovalOptions, i as AgentManifestEntry } from './bridge-entry-F9kHGaIn.js';
2
- export { j as AGENT_BRAND, k as AfterToolCallContext, l as AgentBuilder, m as AgentDefinition, n as AgentDefinitionError, o as AgentExecutionContext, p as AgentManifest, q as AgentManifestSource, r as AgentManifestTool, s as AgentOptions, 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, Q as BudgetOptions, U as CheckpointSavedEvent, V as CompiledContextWindow, W as ContextualTool, X as CostBudgetExceededError, Y as DEFAULT_MAX_ITERATIONS, Z as DefineAgentConfig, _ as DelegateFn, $ as DelegateOptions, a0 as DelegationError, a1 as DoneEvent, a2 as ErrorEvent, a3 as FileEditEvent, a4 as GuardrailAction, a5 as GuardrailPhase, a6 as GuardrailResult, a7 as GuardrailViolationError, a8 as HitlDecision, a9 as InferAgentInput, aa as InferAgentToolNames, ab as IterationEvent, ac as LLMCallContext, ad as LoopFinishReason, ae as LoopOutcome, af as LoopStrategyConfig, ag as MainLoopOptions, ah as McpApprovalSpec, ai as McpRegistryConfig, aj as McpRequestContext, ak as McpSelection, al as PartialToolCallEvent, am as PolicyHandler, an as ProcessInputContext, ao as ReflectionContext, ap as ReflectionResult, aq as ReflectionStrategyConfig, ar as RunStartedEvent, as as ScoreVerdict, at as ScoredDelegation, au as Scorer, av as SdkAgentHandle, aw as SdkMessage, ax as Segment, ay as SkillsRequestContext, az as StateUpdateEvent, aA as TextDeltaEvent, aB as ThinkingEvent, aC as TimeoutAction, aD as ToolCallEvent, aE as ToolCallVeto, aF as ToolHooks, aG as ToolHooksPlugin, aH as ToolResultEvent, aI as ToolWalkResult, aJ as ToolboxOptions, 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, bd as ladderReflectionStrategy, be as loopStrategyConfigSchema, bf as mcpRegistry, bg as mcpToolApprovals, bh as noopReflectionStrategy, bi as presentUIMessageStream, bj as projectContextMetadataOnlyKnobs, bk as reflectionStrategyConfigSchema, bl as resolveEnabledSkills, bm as resolveLoopStrategy, bn as resolveMcpServers, bo as runWithApiErrorHandling, bp as streamAgentResponse, bq as streamAgentUIMessages, br as toAgentFactory, bs as translateSdkEvent } from './bridge-entry-F9kHGaIn.js';
1
+ import { G as Guardrail, L as LoopStrategy, R as ReflectionStrategy, C as CompiledAgentOptions, M as MainLoopMeta, a as CompiledTool, b as ReasoningEffort, c as RoundStreamFactory, S as StreamEvent, D as DelegationResult, d as ContextWindowOptions, H as HumanInTheLoopOptions, e as McpServersMap, f as MemoryOptions, P as ProjectContextOptions, g as SkillsOptions, h as SkillsSelection, T as ToolOptions, A as ApprovalOptions, i as AgentManifestEntry } from './bridge-entry-8gsH0kVZ.js';
2
+ export { j as AGENT_BRAND, k as AfterToolCallContext, l as AgentBuilder, m as AgentDefinition, n as AgentDefinitionError, o as AgentExecutionContext, p as AgentManifest, q as AgentManifestSource, r as AgentManifestTool, s as AgentOptions, 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, Q as BudgetOptions, U as CheckpointSavedEvent, V as CompiledContextWindow, W as ContextualTool, X as CostBudgetExceededError, Y as DEFAULT_MAX_ITERATIONS, Z as DefineAgentConfig, _ as DelegateFn, $ as DelegateOptions, a0 as DelegationError, a1 as DoneEvent, a2 as ErrorEvent, a3 as FileEditEvent, a4 as GuardrailAction, a5 as GuardrailPhase, a6 as GuardrailResult, a7 as GuardrailViolationError, a8 as HitlDecision, a9 as InferAgentInput, aa as InferAgentToolNames, ab as IterationEvent, ac as LLMCallContext, ad as LoopFinishReason, ae as LoopOutcome, af as LoopStrategyConfig, ag as MainLoopOptions, ah as McpApprovalSpec, ai as McpRegistryConfig, aj as McpRequestContext, ak as McpSelection, al as PartialToolCallEvent, am as PolicyHandler, an as ProcessInputContext, ao as ReflectionContext, ap as ReflectionResult, aq as ReflectionStrategyConfig, ar as RunStartedEvent, as as ScoreVerdict, at as ScoredDelegation, au as Scorer, av as SdkAgentHandle, aw as SdkMessage, ax as Segment, ay as SkillsRequestContext, az as StateUpdateEvent, aA as TextDeltaEvent, aB as ThinkingEvent, aC as TimeoutAction, aD as ToolCallEvent, aE as ToolCallVeto, aF as ToolHooks, aG as ToolHooksPlugin, aH as ToolResultEvent, aI as ToolWalkResult, aJ as ToolboxOptions, 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, bd as ladderReflectionStrategy, be as loopStrategyConfigSchema, bf as mcpRegistry, bg as mcpToolApprovals, bh as noopReflectionStrategy, bi as presentUIMessageStream, bj as projectContextMetadataOnlyKnobs, bk as reflectionStrategyConfigSchema, bl as resolveEnabledSkills, bm as resolveLoopStrategy, bn as resolveMcpServers, bo as runWithApiErrorHandling, bp as streamAgentResponse, bq as streamAgentUIMessages, br as toAgentFactory, bs as translateSdkEvent } from './bridge-entry-8gsH0kVZ.js';
3
3
  import * as _theokit_sdk from '@theokit/sdk';
4
4
  import { PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, CustomTool, InlineSkill } from '@theokit/sdk';
5
5
  import { RetryOptions } from '@theokit/sdk/retry';
@@ -294,6 +294,13 @@ interface AgentRunnerState {
294
294
  readonly agentName: string;
295
295
  /** The resolved terminal-decision strategy (parity with `delegate()`). */
296
296
  readonly loopStrategy: LoopStrategy;
297
+ /**
298
+ * M54 — true when `loopStrategy` came from `.loopStrategy(custom)` rather than a built-in name.
299
+ * A custom must NOT be re-resolved by name (its name is outside the `z.enum`); a per-run
300
+ * `maxIterations` override applies to it as a runner ceiling instead (see `stream`). Optional and
301
+ * defaults to `false`: a state built directly (tests, `delegate()`) is a by-name built-in.
302
+ */
303
+ readonly loopStrategyIsCustom?: boolean;
297
304
  /** The resolved between-round reflection (default or `.reflection(custom)` override). */
298
305
  readonly reflectionStrategy: ReflectionStrategy;
299
306
  /** Recorded streaming preference (see {@link AgentRunner.streamEnabled}). */
@@ -306,6 +313,8 @@ declare class AgentRunner {
306
313
  private readonly agentName;
307
314
  /** The resolved terminal-decision strategy (parity with `delegate()`). */
308
315
  readonly loopStrategy: LoopStrategy;
316
+ /** M54 — whether {@link loopStrategy} is a caller-injected custom (see {@link AgentRunnerState}). */
317
+ private readonly loopStrategyIsCustom;
309
318
  /** The resolved between-round reflection (default or `.reflection(custom)` override). */
310
319
  readonly reflectionStrategy: ReflectionStrategy;
311
320
  /**
@@ -336,6 +345,14 @@ declare class AgentRunner {
336
345
  /** The core stream path, after input guardrails have run (M9). */
337
346
  private streamUnguarded;
338
347
  /** Run the agent to a terminal result via the shared reflective loop (collect mode). */
348
+ /**
349
+ * Apply a per-call `maxIterations` override (M54 D4). A custom strategy must NOT be re-resolved by
350
+ * name — its name is outside the `z.enum`, which would throw — and its `shouldContinue` closure
351
+ * must survive; since the runner enforces the ceiling via `round < loop.maxIterations` (T1.1),
352
+ * overriding just that field bounds a custom without touching its logic. A built-in keeps the
353
+ * by-name re-resolution (zod fail-loud on `< 1`) — unchanged, zero-behavior.
354
+ */
355
+ private resolvePerRunLoop;
339
356
  run(message: string, opts: AgentRunnerRunOptions): Promise<DelegationResult>;
340
357
  }
341
358
  /**
@@ -364,9 +381,29 @@ declare class AgentRunnerBuilder {
364
381
  private reflectionOverride?;
365
382
  private streamEnabled;
366
383
  private compactionOverride?;
384
+ private loopStrategyOverride?;
367
385
  constructor(spec: AgentRunnerSpec);
368
386
  /** Override the default reflection strategy (OCP — plan Drawback #2). No arg ⇒ keep default. */
369
387
  reflection(strategy?: ReflectionStrategy): this;
388
+ /**
389
+ * M54 — inject a custom terminal-decision strategy (the fourth OCP axis, alongside
390
+ * `.reflection()`/`.compaction()`/`streamFactory`). WINS over the strategy the spec's name would
391
+ * resolve to, exactly as `.compaction()` outranks the spec. The runner caps ANY strategy at
392
+ * `custom.maxIterations` (T1.1), so a `shouldContinue: () => true` still terminates — never an
393
+ * infinite loop.
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * // Stop as soon as the confidence in the last round crosses 0.9, else run to the ceiling.
398
+ * const stopWhenConfident: LoopStrategy = {
399
+ * name: 'confident',
400
+ * maxIterations: 8,
401
+ * shouldContinue: (o) => !o.responseText.includes('confidence: high'),
402
+ * }
403
+ * AgentRunner.fromSpec(spec).loopStrategy(stopWhenConfident).build()
404
+ * ```
405
+ */
406
+ loopStrategy(custom: LoopStrategy): this;
370
407
  /** Record the streaming preference (see {@link AgentRunner.streamEnabled}). */
371
408
  stream(enabled?: boolean): this;
372
409
  /**
package/dist/index.js CHANGED
@@ -70,7 +70,7 @@ import {
70
70
  toolRuntimeName,
71
71
  translateSdkEvent,
72
72
  unicodeNormalizer
73
- } from "./chunk-K3VX4S65.js";
73
+ } from "./chunk-C2DALG62.js";
74
74
  import {
75
75
  __name
76
76
  } from "./chunk-7QVYU63E.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theokit/agents",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "AI agents as first-class citizens of the TheoKit pipeline. The fluent agent()/tool() builders compile to SDK Agent.create() (M31 builder-only authoring API).",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -48,8 +48,8 @@
48
48
  "typescript": "^5.9.3",
49
49
  "vitest": "^3.2.6",
50
50
  "zod": "^4.4.3",
51
- "@theokit/http": "1.0.0",
52
- "@theokit/presenter": "0.3.0"
51
+ "@theokit/presenter": "0.3.0",
52
+ "@theokit/http": "1.0.0"
53
53
  },
54
54
  "engines": {
55
55
  "node": ">=22.12.0"