@theokit/agents 0.46.0 → 1.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,8 +1,7 @@
1
- import { G as Guardrail, R as ReasoningEffort } from './types-DVA4LQsA.js';
2
- export { A as AgentOptions, a as ApprovalOptions, B as BudgetOptions, C as CostBudgetExceededError, b as GuardrailAction, c as GuardrailPhase, d as GuardrailResult, e as GuardrailViolationError, H as HumanInTheLoopOptions, M as MainLoopMeta, f as MainLoopOptions, P as PolicyHandler, T as TimeoutAction, g as ToolOptions, h as ToolboxOptions } from './types-DVA4LQsA.js';
3
- import { L as LoopStrategy, R as ReflectionStrategy, C as CompiledAgentOptions, a as CompiledTool, b as RoundStreamFactory, S as StreamEvent, D as DelegationResult, A as AgentManifestEntry } from './bridge-entry-BQ6UUSLZ.js';
4
- export { c as AGENT_BRAND, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinition, g as AgentDefinitionError, h as AgentExecutionContext, i as AgentManifest, j as AgentManifestTool, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentStreamEvent, o as AgentTurnMetadata, p as AgentWalkResult, q as AgentWarningCode, r as AgentsPluginOptions, s as ApiErrorContext, t as ApiErrorDecision, u as ApiErrorPolicy, v as ApprovalRequiredEvent, w as ArtifactChunkEvent, x as ArtifactStartEvent, B as BackgroundDelegation, y as BeforeToolCallContext, z as BudgetExceededError, E as CheckpointSavedEvent, F as CompiledContextWindow, G as ContextualTool, H as DEFAULT_MAX_ITERATIONS, I as DefineAgentConfig, J as DelegateFn, K as DelegateOptions, M as DelegationError, N as DoneEvent, O as ErrorEvent, P as FileEditEvent, Q as HitlDecision, T as InferAgentInput, U as InferAgentToolNames, V as IterationEvent, W as LLMCallContext, X as LoopFinishReason, Y as LoopOutcome, Z as LoopStrategyConfig, _ as McpApprovalSpec, $ as McpRegistryConfig, a0 as McpRequestContext, a1 as McpSelection, a2 as PartialToolCallEvent, a3 as ProcessInputContext, a4 as ReflectionContext, a5 as ReflectionResult, a6 as ReflectionStrategyConfig, a7 as RunStartedEvent, a8 as ScoreVerdict, a9 as ScoredDelegation, aa as Scorer, ab as SdkAgentHandle, ac as SdkMessage, ad as Segment, ae as SkillsRequestContext, af as SkillsSelection, ag as StateUpdateEvent, ah as TextDeltaEvent, ai as ThinkingEvent, aj as ToolCallEvent, ak as ToolCallVeto, al as ToolHooks, am as ToolHooksPlugin, an as ToolResultEvent, ao as ToolWalkResult, ap as ToolboxWalkResult, aq as agent, ar as agentsPlugin, as as buildModelSelection, at as compileAgent, au as compileAgentDefinition, av as compileAgentModule, aw as compileContextWindow, ax as compileProjectContext, ay as compileSkills, az as compileTools, aA as contextualTool, aB as createAgentExecutionContext, aC as createApiErrorHandler, aD as createSdkAgentStream, aE as createThinkTagExtractor, aF as createToolHooksPlugin, aG as delegate, aH as delegateBackground, aI as delegateWithScoring, aJ as extractThinkTagStream, aK as generateAgentManifest, aL as generateAgentRoutes, aM as isAgentContext, aN as isAgentDefinition, aO as isApprovalRequired, aP as isDone, aQ as isError, aR as isPartialToolCall, aS as isTextDelta, aT as isToolCall, aU as isToolResult, aV as ladderReflectionStrategy, aW as loopStrategyConfigSchema, aX as mcpRegistry, aY as mcpToolApprovals, aZ as noopReflectionStrategy, a_ as presentUIMessageStream, a$ as projectContextMetadataOnlyKnobs, b0 as reflectionStrategyConfigSchema, b1 as resolveEnabledSkills, b2 as resolveLoopStrategy, b3 as resolveMcpServers, b4 as runWithApiErrorHandling, b5 as streamAgentResponse, b6 as streamAgentUIMessages, b7 as toAgentFactory, b8 as translateSdkEvent, b9 as validateUniqueRoutes, ba as walkAgentMetadata } from './bridge-entry-BQ6UUSLZ.js';
5
- import { PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, CustomTool } from '@theokit/sdk';
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';
3
+ import * as _theokit_sdk from '@theokit/sdk';
4
+ import { PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, CustomTool, InlineSkill } from '@theokit/sdk';
6
5
  import { RetryOptions } from '@theokit/sdk/retry';
7
6
  import { CompressibleMessage } from '@theokit/sdk/compaction';
8
7
  export { CompressibleMessage } from '@theokit/sdk/compaction';
@@ -170,9 +169,8 @@ declare const tokenBudgetCompactionStrategy: TranscriptCompactionStrategy;
170
169
  /**
171
170
  * AgentRunner — the imperative twin of `@MainLoop` (plan ADR D4, V4-B).
172
171
  *
173
- * `AgentRunner.builder(AgentClass).reflection().stream().build()` walks +
174
- * compiles the agent and resolves the SAME `{ compiled, loopStrategy }` that
175
- * `delegate()` resolves for the decorator path (two on-ramps, one runtime).
172
+ * `AgentRunner.fromSpec(spec).reflection().stream().build()` resolves the loop strategy from
173
+ * an already-compiled spec (the capability-authored agent). `delegate()` shares the same runtime.
176
174
  * `build()` is the compile boundary (no I/O, no IoC — standalone, mirrors
177
175
  * Spring's `ChatClient.builder(...).build()`); `stream()`/`run()` do the I/O via
178
176
  * `runReflectiveLoopStream` (the SAME loop `delegate()` drains — DRY, ADR 0031).
@@ -206,7 +204,7 @@ interface AgentRunnerRunOptions {
206
204
  * M1 (Axis-A SWAP): per-run extended-thinking effort. Merge-over-compiled —
207
205
  * `opts.reasoningEffort ?? compiled.reasoningEffort` (resolved in the adapter, single site).
208
206
  * Mapped to the SDK `ModelSelection.params` so the provider reasons (surfaced as `thinking`
209
- * StreamEvents). Absent ⇒ the compiled `@Agent({ reasoningEffort })` (or none).
207
+ * StreamEvents). Absent ⇒ the compiled reasoning effort (or none).
210
208
  */
211
209
  readonly reasoningEffort?: ReasoningEffort;
212
210
  /**
@@ -287,7 +285,7 @@ interface AgentRunnerRunOptions {
287
285
  readonly retry?: RetryOptions;
288
286
  }
289
287
  /**
290
- * A built, runnable agent. Construct via {@link AgentRunner.builder} — the
288
+ * A built, runnable agent. Construct via {@link AgentRunner.fromSpec} — the
291
289
  * constructor takes already-resolved state and is an internal detail.
292
290
  */
293
291
  /** Already-resolved state handed to the {@link AgentRunner} constructor (internal). */
@@ -325,8 +323,8 @@ declare class AgentRunner {
325
323
  */
326
324
  readonly compaction?: TranscriptCompactionStrategy;
327
325
  constructor(state: AgentRunnerState);
328
- /** Start a fluent builder for `AgentClass`. */
329
- static builder(AgentClass: Function): AgentRunnerBuilder;
326
+ /** Start a fluent builder from an already-compiled spec. */
327
+ static fromSpec(spec: AgentRunnerSpec): AgentRunnerBuilder;
330
328
  /**
331
329
  * V4-D-stream: stream the agent's events LIVE across the reflective loop, returning
332
330
  * the aggregated {@link DelegationResult} as the generator's return value. This is the
@@ -340,13 +338,33 @@ declare class AgentRunner {
340
338
  /** Run the agent to a terminal result via the shared reflective loop (collect mode). */
341
339
  run(message: string, opts: AgentRunnerRunOptions): Promise<DelegationResult>;
342
340
  }
341
+ /**
342
+ * M53 — what the runner actually needs in order to run: an already-compiled agent plus the two
343
+ * loop knobs. It used to derive all of this from `walkAgentMetadata`, which chained the runner to
344
+ * the decorator surface. `strategy` and `compaction` are the two non-waist channels ADR 0002 keeps
345
+ * (the builder's `.compaction()` already outranked the decorator; this just names the input).
346
+ */
347
+ /**
348
+ * The already-compiled agent the runner executes. Field-compatible with `SubAgentSpec` on purpose —
349
+ * one spec drives both `AgentRunner.fromSpec` and `delegate`.
350
+ */
351
+ interface AgentRunnerSpec {
352
+ readonly name: string;
353
+ readonly compiled: CompiledAgentOptions;
354
+ readonly strategy?: MainLoopMeta['strategy'];
355
+ readonly maxIterations?: number;
356
+ readonly compaction?: {
357
+ name: string;
358
+ keepTokens?: number;
359
+ };
360
+ }
343
361
  /** Fluent builder — accumulates config; `build()` is the compile boundary. */
344
362
  declare class AgentRunnerBuilder {
345
- private readonly AgentClass;
363
+ private readonly spec;
346
364
  private reflectionOverride?;
347
365
  private streamEnabled;
348
366
  private compactionOverride?;
349
- constructor(AgentClass: Function);
367
+ constructor(spec: AgentRunnerSpec);
350
368
  /** Override the default reflection strategy (OCP — plan Drawback #2). No arg ⇒ keep default. */
351
369
  reflection(strategy?: ReflectionStrategy): this;
352
370
  /** Record the streaming preference (see {@link AgentRunner.streamEnabled}). */
@@ -359,10 +377,254 @@ declare class AgentRunnerBuilder {
359
377
  compaction(name: string, options?: {
360
378
  keepTokens?: number;
361
379
  }): this;
362
- /** Walk + compile + resolve strategies — the compile→execute boundary (no I/O). */
380
+ /** Resolve strategies from the spec — the compile→execute boundary (no I/O). */
363
381
  build(): AgentRunner;
364
382
  }
365
383
 
384
+ /**
385
+ * M52 — the capability layer: object-oriented, composable authoring that produces the EXISTING narrow
386
+ * waist (`CompiledAgentOptions`), which `assembleM8CreateOptions` already turns into `Agent.create`
387
+ * options. No new spec and no new adapter were invented (ADR-1/ADR-2) — a third representation would be
388
+ * the very duplication this initiative removes.
389
+ */
390
+ /** Which capability contributed which fields — makes the wiring inspectable as DATA. */
391
+ interface ProvenanceEntry {
392
+ readonly capability: string;
393
+ readonly contributed: readonly string[];
394
+ }
395
+ /** The mutable draft a capability enriches. `tools`/`agents` are pre-seeded (required in the waist). */
396
+ interface CompiledAgentOptionsDraft extends Partial<Omit<CompiledAgentOptions, 'tools' | 'agents'>> {
397
+ tools: CompiledAgentOptions['tools'];
398
+ agents: CompiledAgentOptions['agents'];
399
+ readonly provenance: ProvenanceEntry[];
400
+ }
401
+ /**
402
+ * **Strategy + value-level Decorator.** N independent ways to enrich an agent (model, tools, skills,
403
+ * MCP, HITL…), added or removed without touching the builder — a central `switch` would violate OCP.
404
+ */
405
+ interface Capability {
406
+ /** Stable identity — used for provenance and conflict messages. */
407
+ readonly name: string;
408
+ apply(draft: CompiledAgentOptionsDraft): void;
409
+ }
410
+ /** Two capabilities set the same scalar field to different values — a composition bug, never last-wins. */
411
+ declare class CapabilityConflictError extends Error {
412
+ readonly name = "CapabilityConflictError";
413
+ constructor(field: string, previous: unknown, next: unknown, capability: string);
414
+ }
415
+ /**
416
+ * A fresh draft. `stream` is deliberately NOT seeded: a pre-seeded value would make
417
+ * `setOnce(draft, 'stream', false, …)` throw a conflict against a default nobody declared, so
418
+ * `stream: false` would be structurally unreachable. The default is applied at finalize instead.
419
+ */
420
+ declare function createDraft(): CompiledAgentOptionsDraft;
421
+ /** A draft that has been finalized — the waist's required `stream` is settled. */
422
+ type FinalizedDraft = CompiledAgentOptionsDraft & {
423
+ stream: boolean;
424
+ };
425
+ /** Apply capabilities in declaration order (deterministic) and return the draft. */
426
+ declare function applyCapabilities(capabilities: readonly Capability[], draft?: CompiledAgentOptionsDraft): FinalizedDraft;
427
+ /** Set a scalar exactly once — fail-fast on a conflicting redeclaration (Rule 8). */
428
+ declare function setOnce<K extends keyof CompiledAgentOptionsDraft>(draft: CompiledAgentOptionsDraft, field: K, value: CompiledAgentOptionsDraft[K], capability: string): void;
429
+
430
+ /**
431
+ * M52 — three real capabilities proving the contract against genuine variation: one that VALIDATES and
432
+ * can conflict (model), one that ACCUMULATES (tools), and one that is pure DATA (skills — a plain
433
+ * factory, because a class with no behavior would be ceremony: KISS).
434
+ */
435
+ /** Typed authoring failure — surfaced at build time, never a silent bad agent. */
436
+ declare class ConfigurationError extends Error {
437
+ readonly name = "ConfigurationError";
438
+ }
439
+ /** Sets the model id (and optional reasoning effort). CLASS: it validates and can conflict. */
440
+ declare class ModelCapability implements Capability {
441
+ private readonly id;
442
+ private readonly reasoningEffort?;
443
+ readonly name = "model";
444
+ constructor(id: string, reasoningEffort?: CompiledAgentOptionsDraft['reasoningEffort']);
445
+ apply(draft: CompiledAgentOptionsDraft): void;
446
+ }
447
+ /** Adds tools. CLASS: it ACCUMULATES (never overwrites), which is behavior worth owning. */
448
+ declare class ToolsCapability implements Capability {
449
+ #private;
450
+ readonly name = "tools";
451
+ constructor(tools: readonly CompiledTool[]);
452
+ apply(draft: CompiledAgentOptionsDraft): void;
453
+ }
454
+ /**
455
+ * Enables skills by name. FUNCTION, not class: it carries no behavior beyond assignment — a class here
456
+ * would be ceremony (the honest counter-example to "everything must be a class").
457
+ */
458
+ declare const skills: (entries: readonly (string | InlineSkill)[]) => Capability;
459
+
460
+ /**
461
+ * M52 — resolution + composition. The registry is what unlocks FILE-BASED authoring (a config lists
462
+ * capability names): resolving name → capability without a switch that grows per feature (OCP).
463
+ */
464
+ /** Fail-fast with the known set — never `undefined` leaking into the pipeline. */
465
+ declare class UnknownCapabilityError extends Error {
466
+ readonly name = "UnknownCapabilityError";
467
+ constructor(requested: string, known: readonly string[]);
468
+ }
469
+ /** **Registry + Factory Method.** */
470
+ declare class CapabilityRegistry {
471
+ #private;
472
+ register(name: string, factory: (arg: unknown) => Capability): this;
473
+ has(name: string): boolean;
474
+ names(): string[];
475
+ resolve(name: string, arg?: unknown): Capability;
476
+ }
477
+ /**
478
+ * **Composite** — a preset behaves like ONE capability, so a caller says `codingAgent()` instead of
479
+ * spreading an array at the call site. Members apply in declaration order (deterministic).
480
+ */
481
+ declare class CapabilityPreset implements Capability {
482
+ #private;
483
+ readonly name: string;
484
+ constructor(name: string, members: readonly Capability[]);
485
+ apply(draft: CompiledAgentOptionsDraft): void;
486
+ }
487
+
488
+ /** `@Memory` → `memory`. */
489
+ declare const memory: (value: NonNullable<MemoryOptions | _theokit_sdk.MemorySettings | undefined>) => Capability;
490
+ /**
491
+ * `@ContextWindow` → `context`. DELEGATES to `compileContextWindow`, which is the canonical
492
+ * `ContextWindowOptions → ContextSettings` conversion (it also reports the metadata-only knobs).
493
+ * Taking a pre-converted value here would duplicate that knowledge — the exact divergence the M52
494
+ * zero-behavior proof caught in `skills`.
495
+ */
496
+ declare const contextWindow: (options: ContextWindowOptions) => Capability;
497
+ /** `@ProjectContext` → `projectContext`. */
498
+ declare const projectContext: (value: ProjectContextOptions) => Capability;
499
+ /** `@MCP` → `mcpServers`. */
500
+ declare const mcpServers: (value: McpServersMap) => Capability;
501
+ /** `@Guardrails` → `guardrails`. */
502
+ declare const guardrails: (value: readonly Guardrail[]) => Capability;
503
+ /**
504
+ * `@Checkpoint` → `checkpoint`. Carries the non-durable WARNING the metadata walk used to emit: only
505
+ * `'filesystem'` selects the SDK's durable store, so any other storage cannot resume across
506
+ * requests. The warning moves WITH the feature — a declared checkpoint that silently cannot resume
507
+ * is exactly the kind of no-op this project refuses to ship.
508
+ */
509
+ declare const checkpoint: (options: CompiledAgentOptions["checkpoint"]) => Capability;
510
+ /** `@HumanInTheLoop` → `hitl` (keyed `"<toolbox>.<tool>"`, as `compileHitlGates` keys it today). */
511
+ declare const humanInTheLoop: (value: Map<string, HumanInTheLoopOptions>) => Capability;
512
+ /**
513
+ * `@SubAgents` → `agents`. MERGES instead of `setOnce`: `agents` is a pre-seeded collection on the
514
+ * draft (`createDraft` gives it `{}`), so a `setOnce` would conflict against the seed itself — the
515
+ * same trap the pre-seeded `stream` sprang in M52. Merging also lets a preset declare a baseline
516
+ * child set that a call site extends.
517
+ */
518
+ declare const subAgents: (children: CompiledAgentOptions["agents"]) => Capability;
519
+ /**
520
+ * `@Skills({ include, autoDiscover })` → `skills`. Delegates to `compileSkills` (same reason as
521
+ * `contextWindow`). Distinct from the M52 `skills([...])`, which takes the plain name/inline list.
522
+ */
523
+ declare const skillsOptions: (options: SkillsOptions) => Capability;
524
+ /** Functional-path fields that had no decorator source — closing the gap list, not adding surface. */
525
+ declare const settingSources: (value: readonly _theokit_sdk.SettingSource[]) => Capability;
526
+ declare const plugins: (value: readonly unknown[]) => Capability;
527
+ declare const runContext: (value: Record<string, unknown>) => Capability;
528
+ declare const skillsResolver: (value: NonNullable<SkillsSelection | undefined>) => Capability;
529
+ /** The scalar agent config (name/route are HTTP concerns, never agent config). */
530
+ interface AgentConfig {
531
+ readonly systemPrompt?: CompiledAgentOptions['systemPrompt'];
532
+ readonly parseThinkTags?: boolean;
533
+ readonly stripToolDialect?: boolean;
534
+ readonly recoverLeakedToolCalls?: boolean;
535
+ readonly stream?: boolean;
536
+ readonly maxIterations?: number;
537
+ readonly timeoutMs?: number;
538
+ }
539
+ /**
540
+ * Scalar waist fields (formerly the `@Agent` options). CLASS, not a factory: it validates, and it is the one
541
+ * capability that writes fields another capability may legitimately override (see
542
+ * {@link MainLoopCapability}).
543
+ */
544
+ declare class AgentConfigCapability implements Capability {
545
+ private readonly config;
546
+ readonly name = "agent-config";
547
+ constructor(config: AgentConfig);
548
+ apply(draft: CompiledAgentOptionsDraft): void;
549
+ }
550
+ /**
551
+ * `@MainLoop({ maxIterations, timeoutMs })` → the same two fields `@Agent` can write.
552
+ *
553
+ * PRECEDENCE, preserved deliberately: `compileAgent` resolves these as
554
+ * `mainLoop.x ?? agentConfig.x` — the main-loop declaration WINS when both are present. A plain
555
+ * `setOnce` would raise a conflict where the pipeline has a defined winner, so this capability
556
+ * OVERRIDES instead. That is the one place in the layer where a later write beats an earlier one,
557
+ * and it exists to keep behavior identical, not for convenience.
558
+ */
559
+ declare class MainLoopCapability implements Capability {
560
+ private readonly config;
561
+ readonly name = "main-loop";
562
+ constructor(config: {
563
+ maxIterations?: number;
564
+ timeoutMs?: number;
565
+ });
566
+ apply(draft: CompiledAgentOptionsDraft): void;
567
+ }
568
+
569
+ /**
570
+ * M53 — tools without `@Toolbox`/`@Tool`.
571
+ *
572
+ * A toolbox class declares its tools as DATA (`static tools`) and keeps its handlers as ordinary
573
+ * methods; the capability takes an INSTANCE. That preserves what the decorators actually bought —
574
+ * grouping under a namespace and handlers bound to the instance (so a toolbox can hold state and
575
+ * injected dependencies) — with no metadata reflection at all.
576
+ *
577
+ * The compilation itself is NOT reimplemented: it delegates to `compileTools`, the same function the
578
+ * decorator path calls, so namespacing (`toolRuntimeName`), handler binding and the fail-fast checks
579
+ * stay in one place.
580
+ *
581
+ * @example
582
+ * ```ts
583
+ * class SupportTools {
584
+ * static tools: ToolDeclaration[] = [
585
+ * { name: 'search', description: 'Search tickets', input: z.object({ q: z.string() }), method: 'search' },
586
+ * ]
587
+ * async search({ q }: { q: string }): Promise<string> { return `found ${q}` }
588
+ * }
589
+ *
590
+ * const agent = applyCapabilities([
591
+ * new ModelCapability('openai/gpt-5.4'),
592
+ * new ToolboxCapability(new SupportTools(), { namespace: 'support' }),
593
+ * ])
594
+ * ```
595
+ */
596
+ interface ToolDeclaration extends ToolOptions {
597
+ /** Method on the toolbox instance that implements this tool. */
598
+ readonly method: string;
599
+ /** Require human approval before the tool runs (surfaced in the manifest). */
600
+ readonly approval?: ApprovalOptions;
601
+ /** Gate the tool behind human-in-the-loop (M4). */
602
+ readonly hitl?: HumanInTheLoopOptions;
603
+ /** Manifest-only observability flags. */
604
+ readonly trace?: boolean;
605
+ readonly audit?: boolean;
606
+ }
607
+ /** A toolbox instance whose class declares its tools. */
608
+ interface ToolboxSource {
609
+ readonly constructor: {
610
+ tools?: readonly ToolDeclaration[];
611
+ };
612
+ }
613
+ interface ToolboxOptions {
614
+ /** Prefix for every tool name (`"<namespace>.<tool>"`), as `@Toolbox({ namespace })` did. */
615
+ readonly namespace?: string;
616
+ /** Declarations, when they are not on the class as `static tools`. */
617
+ readonly tools?: readonly ToolDeclaration[];
618
+ }
619
+ declare class ToolboxCapability implements Capability {
620
+ #private;
621
+ readonly name = "toolbox";
622
+ constructor(instance: object, options?: ToolboxOptions);
623
+ /** The compiled tools this toolbox contributes — the same shape the decorator path produces. */
624
+ compile(): CompiledTool[];
625
+ apply(draft: CompiledAgentOptionsDraft): void;
626
+ }
627
+
366
628
  /**
367
629
  * M15 (theokit-ai-first) — A2A agent card generation (ADR-0040 § D2, home/discovery concern).
368
630
  *
@@ -554,4 +816,4 @@ declare class AcpClient {
554
816
  private handleServerRequest;
555
817
  }
556
818
 
557
- export { type A2AAuth, type A2ACapabilities, type A2ASkill, type A2AToolConfig, AcpClient, AcpMessageDecoder, type AcpTransport, type AgentCard, AgentManifestEntry, AgentRunner, AgentRunnerBuilder, type AgentRunnerRunOptions, type BuildAgentCardOptions, type CompactionCallOptions, type CompactionStrategyConfig, CompiledAgentOptions, CompiledTool, type CostGuardOptions, DEFAULT_KEEP_TOKENS, DelegationResult, Guardrail, LoopStrategy, MCP_PROTOCOL_VERSION, type McpJsonSchema, type McpServerInfo, type McpToolDescriptor, type OutputModerationOptions, type PiiOptions, type PromptInjectionOptions, ReasoningEffort, ReflectionStrategy, RoundStreamFactory, StreamEvent, type Summarize, type TranscriptCompactionStrategy, buildAgentCard, buildMcpToolDescriptors, compactionStrategyConfigSchema, costGuard, createA2ATool, deriveConversationId, encodeAcpMessage, estimateTokens, mcpServerInfo, moderateOutputStream, outputModeration, parseConversationId, piiDetector, promptInjectionDetector, resolveCompactionStrategy, runInputGuards, runOutputGuards, tokenBudgetCompactionStrategy, unicodeNormalizer, wellKnownCardPath };
819
+ export { type A2AAuth, type A2ACapabilities, type A2ASkill, type A2AToolConfig, AcpClient, AcpMessageDecoder, type AcpTransport, type AgentCard, type AgentConfig, AgentConfigCapability, AgentManifestEntry, AgentRunner, AgentRunnerBuilder, type AgentRunnerRunOptions, ApprovalOptions, type BuildAgentCardOptions, type Capability, CapabilityConflictError, CapabilityPreset, CapabilityRegistry, type CompactionCallOptions, type CompactionStrategyConfig, CompiledAgentOptions, type CompiledAgentOptionsDraft, CompiledTool, ConfigurationError, type CostGuardOptions, DEFAULT_KEEP_TOKENS, DelegationResult, type FinalizedDraft, Guardrail, HumanInTheLoopOptions, LoopStrategy, MCP_PROTOCOL_VERSION, MainLoopCapability, MainLoopMeta, type McpJsonSchema, type McpServerInfo, type McpToolDescriptor, ModelCapability, type OutputModerationOptions, type PiiOptions, type PromptInjectionOptions, type ProvenanceEntry, ReasoningEffort, ReflectionStrategy, RoundStreamFactory, SkillsSelection, StreamEvent, type Summarize, type ToolDeclaration, ToolOptions, ToolboxCapability, type ToolboxSource, ToolsCapability, type TranscriptCompactionStrategy, UnknownCapabilityError, applyCapabilities, buildAgentCard, buildMcpToolDescriptors, checkpoint, compactionStrategyConfigSchema, contextWindow, costGuard, createA2ATool, createDraft, deriveConversationId, encodeAcpMessage, estimateTokens, guardrails, humanInTheLoop, mcpServerInfo, mcpServers, memory, moderateOutputStream, outputModeration, parseConversationId, piiDetector, plugins, projectContext, promptInjectionDetector, resolveCompactionStrategy, runContext, runInputGuards, runOutputGuards, setOnce, settingSources, skills, skillsOptions, skillsResolver, subAgents, tokenBudgetCompactionStrategy, unicodeNormalizer, wellKnownCardPath };